DataMgr.h
. It discusses the following topics:
DmOpenRef
type defines a pointer to an open database. The database pointer is created and returned by
DmOpenDatabase
. It is used in any function that requires access to an open database.
typedef void* DmOpenRef
DmResID
type defines a resource identifier. You assign each resource an ID at creation time. Note that resource IDs greater than 10000 are reserved for system use.
typedef UInt16 DmResID;
DmResType
type defines the type of a resource. The resource type is a four-character code such as 'Tbmp'
for bitmap resources.
typedef UInt32 DmResType;
SortRecordInfoType
structure specifies information that might be used to sort a record. It is used in the database sorting functions. To create this structure, you can call
DmRecordInfo
, which returns these values for a given record.
typedef struct {
    UInt8 attributes;
    UInt8 uniqueID[3];
} SortRecordInfoType;
typedef SortRecordInfoType * SortRecordInfoPtr;
attributes
| The record's attributes. See "Record Attribute Constants." |
uniqueID
| The unique identifier for the record. |
NULL
or 0 instead of an error code. In many cases, you can call
DmGetLastErr
upon receiving this value and receive a more descriptive error code.
ErrFatalDisplayIf
macro if certain error conditions are true. Because the Palm OS ROMs are usually shipped with error checking set to partial, you receive the fatal error message. If a ROM is built with error checking set to none, the function returns one of the error codes listed here. (Note that Palm has never released a ROM with error checking set to none and has no plans to do so.)
DmOpenDatabase
,
DmOpenDatabaseByTypeCreator
, or
DmOpenDBNoOverlay
:
Err DmArchiveRecord (DmOpenRef dbP, UInt16 index)
errNone
if no error, or one of the following if an error occurs:
DmRemoveRecord
,
DmDetachRecord
,
DmNewRecord
,
DmDeleteRecord
Err DmAttachRecord (DmOpenRef dbP, UInt16* atP, MemHandle newH, MemHandle* oldHP)
  |
-> |
DmOpenRef to open database. |
  |
<-> |
Pointer to the index where the new record should be placed. Specify the value dmMaxRecordIndex to add the record to the end of the database. |
  |
-> |
Handle of the new record. |
  |
<-> |
If non-NULL upon entry, indicates that the record at *atP should be replaced. Upon return, contains the handle to the replaced record. |
errNone
if no error, or one of the following if an error occurs:
atP
points to an index variable. If oldHP
is NULL
, the new record is inserted at index *atP
and all record indices that follow are shifted down. If *atP
is greater than the number of records currently in the database, the new record is appended to the end and its index is returned in *atP
. If oldHP
is not NULL
, the new record replaces an existing record at index *atP
and the handle of the old record is returned in *oldHP
so that the application can free it or attach it to another database.
DmDetachRecord
,
DmNewRecord
,
DmNewHandle
,
DmFindSortPosition
Err DmAttachResource (DmOpenRef dbP, MemHandle newH, DmResType resType, DmResID resID)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Handle of new resource's data. |
  |
-> |
Type of the new resource. |
  |
-> |
ID of the new resource. |
errNone
if no error, or one of the following if an error occurs:
DmDetachResource
,
DmRemoveResource
,
DmNewHandle
,
DmNewResource
Err DmCloseDatabase (DmOpenRef dbP)
errNone
if no error, or dmErrInvalidParam if an error occurs. Some releases may display a fatal error message instead of returning the error code.
DmDatabaseProtect
before closing.
DmCloseDatabase
closes the overlay as well.
DmCloseDatabase
updates the database's modification date.
DmReleaseRecord
, rearranging or deleting categories, or updating the database header fields using
DmSetDatabaseInfo
.
DmSetDatabaseInfo
to set the modification date explicitly.
DmOpenDatabase
,
DmDeleteDatabase
,
DmOpenDatabaseByTypeCreator
Err DmCreateDatabase (UInt16 cardNo, const Char * nameP, UInt32 creator, UInt32 type, Boolean resDB)
  |
-> |
The card number to create the database on. |
  |
-> |
Creator of the database. |
  |
-> |
Type of the database. |
  |
-> |
If true , create a resource database. |
errNone
if no error, or one of the following if an error occurs:
dmErrAlreadyExists
error code. Once created, the database ID can be retrieved by calling
DmFindDatabase
. The database can be opened using the database ID. To create a resource database instead of a record-based database, set the resDB
Boolean to true
.
DmSetDatabaseInfo
to set the version number. Databases default to version 0 if the version isn't explicitly set.
DmCreateDatabaseFromImage
,
DmOpenDatabase
,
DmDeleteDatabase
Err DmCreateDatabaseFromImage (MemPtr bufferP)
errNone
if no error.
DmCreateDatabase
,
DmOpenDatabase
Err DmDatabaseInfo (UInt16 cardNo, LocalID dbID, Char* nameP, UInt16* attributesP, UInt16* versionP, UInt32* crDateP, UInt32* modDateP, UInt32* bckUpDateP, UInt32* modNumP, LocalID* appInfoIDP, LocalID* sortInfoIDP, UInt32* typeP, UInt32* creatorP)
  |
-> |
Number of the card the database resides on. |
  |
-> |
Database ID of the database. |
  |
<- |
The database's name. Pass a pointer to 32-byte character array for this parameter, or NULL if you don't care about the name. |
  |
<- |
The database's attribute flags. The section "Database Attribute Constants" lists constants you can use to query the values returned in this parameter. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The application-specific version number. The default version number is 0. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The date the database was created, expressed as the number of seconds since the first instant of Jan 1, 1904. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The date the database was last modified, expressed as the number of seconds since the first instant of Jan 1, 1904. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The date the database was backed up, expressed as the number of seconds since the first instant of Jan 1, 1904. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The modification number, which is incremented every time a record in the database is added, modified, or deleted. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The local ID of the database's sort table. This is an optional field in the database header. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The database's type, specified when it is created. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The database's creator, specified when it is created. Pass NULL for this parameter if you don't want to retrieve it. |
errNone
if no error, or
dmErrInvalidParam
if an error occurs.
DmReleaseRecord
, rearranging or deleting categories, or updating the database header fields using
DmSetDatabaseInfo
.
DmSetDatabaseInfo
to set the modification date explicitly.
DmSetDatabaseInfo
,
DmDatabaseSize
,
DmOpenDatabaseInfo
,
DmFindDatabase
,
DmGetNextDatabaseByTypeCreator
,
TimSecondsToDateTime
Err DmDatabaseProtect (UInt16 cardNo, LocalID dbID, Boolean protect)
  |
-> |
Card number of database to protect/unprotect. |
  |
-> |
Local ID of database to protect/unprotect. |
  |
-> |
If true , protect count will be incremented. If false , protect count will be decremented. |
errNone
if no error, or one of the following if an error occurs:
true
for the protect
parameter). It increments the protect count if protect
is true
and decrements it if protect
is false
. All true
calls should be balanced by false
calls before the application terminates.
Err DmDatabaseSize (UInt16 cardNo, LocalID dbID, UInt32* numRecordsP, UInt32* totalBytesP, UInt32* dataBytesP)
  |
-> |
Card number the database resides on. |
  |
-> |
Database ID of the database. |
  |
<- |
The total number of records in the database. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The total number of bytes used by the database including the overhead. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The total number of bytes used to store just each record's data, not including overhead. Pass NULL for this parameter if you don't want to retrieve it. |
errNone
if no error, or
dmErrMemError
if an error occurs.
DmDatabaseInfo
,
DmOpenDatabaseInfo
,
DmFindDatabase
,
DmGetNextDatabaseByTypeCreator
Err DmDeleteCategory (DmOpenRef dbR, UInt16 categoryNum)
  |
-> |
Database access pointer. |
  |
-> |
Category of records to delete. Category masks such as dmAllCategories are invalid. |
errNone
if no error, or one of the following if an error occurs:
DmDeleteCategory
marks the delete
bit in the database header for the record and disposes of the record's data chunk. The record entry in the database header remains, but its localChunkID
is set to NULL
.
errNone
to indicate success. The categoryNum
parameter is assumed to represent a single category. If you pass a category mask to specify more than one category, this function interprets that value as a single category, finds no records to delete in that category, and returns errNone
.
DmRecordInfo
call to obtain a category index from a given record. For example:
DmOpenRef myDB;
UInt16 record, attr, category, total;
DmRecordInfo(myDB, record, &attr, NULL, NULL);
category = attr & dmRecAttrCategoryMask;
err = DmDeleteCategory(myDB, category);
Err DmDeleteDatabase (UInt16 cardNo, LocalID dbID)
errNone
if no error, or one of the following if an error occurs:
DmDeleteDatabase
.
DmFindDatabase
or
DmGetDatabase
with a database index.
DmDeleteRecord
,
DmRemoveRecord
,
DmRemoveResource
,
DmCreateDatabase
,
DmGetNextDatabaseByTypeCreator
,
DmFindDatabase
delete
bit for the next sync.
Err DmDeleteRecord (DmOpenRef dbP, UInt16 index)
errNone
if no error, or one of the following if an error occurs:
delete
bit in the database header for the record and disposes of the record's data chunk. Does not remove the record entry from the database header, but simply sets the localChunkID
of the record entry to NULL
.
DmDetachRecord
,
DmRemoveRecord
,
DmArchiveRecord
,
DmNewRecord
Err DmDetachRecord (DmOpenRef dbP, UInt16 index, MemHandle* oldHP)
  |
-> |
DmOpenRef to open. |
  |
-> |
Index of the record to detach. |
  |
<-> |
Pointer to return handle of the detached record. |
errNone
if no error, or one of the following if an error occurs:
*oldHP
. Unlike
DmDeleteRecord
, this routine removes its entry in the database header but it does not delete the actual record.
DmAttachRecord
,
DmRemoveRecord
,
DmArchiveRecord
,
DmDeleteRecord
Err DmDetachResource (DmOpenRef dbP, UInt16 index, MemHandle* oldHP)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Index of resource to detach. |
  |
<-> |
Pointer to return handle of the detached record. |
errNone
if no error, or one of the following if an error occurs:
oldHP
.
DmAttachResource
,
DmRemoveResource
LocalID DmFindDatabase (UInt16 cardNo, const Char* nameP)
  |
-> |
Number of card to search. |
  |
-> |
Name of the database to look for. |
DmGetLastErr
returns an error code indicating the reason for failure.
DmGetNextDatabaseByTypeCreator
,
DmDatabaseInfo
,
DmOpenDatabase
Err DmFindRecordByID (DmOpenRef dbP, UInt32 uniqueID, UInt16* indexP)
  |
-> |
Database access pointer. |
  |
-> |
Unique ID to search for. |
  |
<- |
Return index. |
dmErrUniqueIDNotFound
. May display a fatal error message if the unique ID is invalid.
DmQueryRecord
,
DmGetRecord
,
DmRecordInfo
NULL
.
UInt16 DmFindResource (DmOpenRef dbP, DmResType resType, DmResID resID, MemHandle resH)
  |
-> |
Open resource database access pointer. |
  |
-> |
Type of resource to search for. |
  |
-> |
ID of resource to search for. |
  |
-> |
Pointer to locked resource, or NULL . |
IMPORTANT: This function searches for the resource only in the database you specify. If you pass a pointer to a base resource database, its overlay is not searched. To search both a base database and its overlay for a localized resource, useDmGet1Resource
instead of this function.
resH
is NULL
, the resource is searched for by type and ID.
resH
is not NULL
, resType
and resID
are ignored and the index of the given locked resource is returned.
DmGetResourceIndex
.
DmGetResource
,
DmSearchResource
,
DmResourceInfo
,
DmGetResourceIndex
,
DmFindResourceType
UInt16 DmFindResourceType (DmOpenRef dbP, DmResType resType, UInt16 typeIndex)
  |
-> |
Open resource database access pointer. |
  |
-> |
Type of resource to search for. |
  |
-> |
Index of given resource type. |
typeIndex
0 and incrementing until an error is returned, the total number of resources of a given type and the index of each of these resources can be determined. Once the index of a resource is determined, it can be locked down and accessed by calling
DmGetResourceIndex
.
IMPORTANT: This function searches for resources only in the database you specify. If you pass a pointer to a base resource database, its overlay is not searched. To search both a base database and its overlay for a localized resource, useDmGet1Resource
instead of this function.
DmGetResource
,
DmSearchResource
,
DmResourceInfo
,
DmGetResourceIndex
,
DmFindResource
DmAttachRecord
. Uses a binary search.
UInt16 DmFindSortPosition (DmOpenRef dbP, void* newRecord, SortRecordInfoPtr newRecordInfo, DmComparF *compar, Int16 other)
  |
-> |
Database access pointer. |
  |
-> |
Pointer to the new record. |
  |
-> |
Sort information about the new record. See SortRecordInfoType . |
  |
-> |
Pointer to comparison function. See DmComparF . |
  |
-> |
Any value the application wants to pass to the comparison function. |
newRecord
has the same key as another record in the database, DmFindSortPosition
assumes that newRecord
should be inserted after that record. If there are several records with the same key, newRecord
is inserted after all of them. For this reason, if you use DmFindSortPosition
to search for the location of a record that you know is already in the database, you must subtract 1 from the result. (Be sure to check that the value is not 0.)
DmFindSortPosition
only works if those records are at the end of the database. DmFindSortPosition
always assumes that a deleted record is greater than or equal to any other record.
DmFindSortPositionV10
DmAttachRecord
. Uses a binary search.
UInt16 DmFindSortPositionV10 (DmOpenRef dbP, void* newRecord, DmComparF *compar, Int16 other)
  |
-> |
Database access pointer. |
  |
-> |
Pointer to the new record. |
  |
-> |
Pointer to comparison function. See DmComparF . |
  |
-> |
Any value the application wants to pass to the comparison function. |
DmFindSortPositionV10
only works if those records are at the end of the database. DmFindSortPositionV10
always assumes that a deleted record is greater than or equal to any other record.
DmFindSortPosition
.
DmFindSortPosition
,
DmQuickSort
,
DmInsertionSort
LocalID DmGetAppInfoID (DmOpenRef dbP).
DmDatabaseInfo
,
DmOpenDatabase
LocalID DmGetDatabase (UInt16 cardNo, UInt16 index)
DmNumDatabases
-1.
DmOpenDatabase
,
DmNumDatabases
,
DmDatabaseInfo
,
DmDatabaseSize
void DmGetDatabaseLockState (DmOpenRef dbR, UInt8* highest, UInt32* count, UInt32* busy)
  |
-> |
Database access pointer. |
  |
<- |
The number of records that have the lock count that is returned in the highest parameter. Pass NULL for this parameter if you don't want to retrieve it. |
  |
<- |
The number of records that have the busy bit set. Pass NULL for this parameter if you don't want to retrieve it. |
Err DmGetLastErr (void)
DmGetRecord
return 0 if unsuccessful, so calling
DmGetLastErr
is the only way to determine why they failed.
DmGetLastErr
does not always reflect the error status of the last data manager call. Rather, it reflects the error status of data manager calls that don't return an error code. For some of those calls, the saved error code value is not set to 0 when the call is successful.
DmOpenDatabaseByTypeCreator
returns NULL
for database reference (that is, it fails), DmGetLastErr
returns something meaningful; otherwise, it returns the error value of some previous data manager call.
DmGetLastErr
:
DmFindDatabase
|
DmOpenDatabaseByTypeCreator
|
DmOpenDatabase
|
DmNewRecord
|
DmQueryRecord
|
DmGetRecord
|
DmQueryNextInCategory
|
DmPositionInCategory
|
DmSeekRecordInCategory
|
DmResizeRecord
|
DmGetResource
|
DmGet1Resource
|
DmNewResource
|
DmGetResourceIndex
|
DmNewHandle | DmOpenDBNoOverlay |
DmResizeResource |
Err DmGetNextDatabaseByTypeCreator (Boolean newSearch, DmSearchStatePtr stateInfoP, UInt32 type, UInt32 creator, Boolean onlyLatestVers, UInt16* cardNoP, LocalID* dbIDP)
  |
-> |
true if starting a new search. |
  |
<-> |
If newSearch is false , this must point to the same data used for the previous invocation. |
  |
-> |
Type of database to search for, pass 0 as a wildcard. |
  |
-> |
Creator of database to search for, pass 0 as a wildcard. |
  |
-> |
If true , only the latest version of a database with a given type and creator is returned. |
  |
<- |
On exit, the card number of the found database. |
  |
<- |
Database local ID of the found database. |
errNone
if no error, or
dmErrCantFind
if no matches were found.
true
for newSearch
. Allocate a DmSearchStateType
structure and pass it as the stateInfoP
parameter. DmGetNextDatabaseByTypeCreator
stores private information in stateInfoP
and uses it if the search is continued.
false
for newSearch
and pass the same stateInfoP
that you used during the previous call to this function.
NULL
as a wildcard operator for the type
or creator
parameter to conduct searches of wider scope. If the type
parameter is NULL
, this routine can be called successively to return all databases of the given creator. If the creator
parameter is NULL
, this routine can be called successively to return all databases of the given type. You can also pass NULL
as the value for both of these parameters to return all available databases without regard to type or creator.
onlyLatestVers
parameter is false
, this function may return a database which is not the most recent version matching the specified type/creator pair. To obtain only the latest version of a database matching the search criteria, set the value of the onlyLatestVers
parameter to true
.
onlyLatestVers
is true
, you only receive one matching database for each type/creator pair. In version 3.0 and earlier, you could receive multiple matching databases if onlyLatestVers
was true
.
type
and creator
and onlyLatestVers
is true
.
DmSearchStateType state;
Boolean latestVer;
UInt16 card;
LocalID currentDB = 0;
theErr = DmGetNextDatabaseByTypeCreator(true,
    &state, myType, myCreator, latestVer, &card,
    ¤tDB);
while (!theErr && currentDB) {
    /* do something with currentDB */
    /* now get the next DB */
    theErr = DmGetNextDatabaseByTypeCreator(
    false, &state, myType, myCreator,
    latestVer, &card, ¤tDB);
}
latestVer
is false
, then your code will work the same on all versions of Palm OS and will return all three databases whose type and creator match those specified. If latestVer
is true
, this code returns all three databases on Palm OS version 3.0 and earlier, but only returns one database on version 3.1 and higher. (Exactly which database it returns is unspecified.)
DmGetNextDatabaseByTypeCreator
in one of the following ways to ensure that your code operates the same on all Palm OS versions:
DmGetDatabase
,
DmFindDatabase
,
DmDatabaseInfo
,
DmOpenDatabaseByTypeCreator
,
DmDatabaseSize
MemHandle DmGetRecord (DmOpenRef dbP, UInt16 index)
DmGetRecord
for the same record is attempted before the record is released, NULL
is returned and
DmGetLastErr
returns an error code indicating the reason for failure.
busy
bit for the record.
DmAccessType
structure.
DmReleaseRecord
should be called as soon as the caller finishes viewing or editing the record.
DmSearchRecord
,
DmFindRecordByID
,
DmRecordInfo
,
DmReleaseRecord
,
DmQueryRecord
MemHandle DmGetResource (DmResType type, DmResID resID)
NULL
and
DmGetLastErr
returns an error code indicating the reason for failure.
DmReleaseResource
as soon as it finishes accessing the resource data. The resource handle is not locked by this function.
DmGet1Resource
,
DmReleaseResource
,
ResLoadConstant
MemHandle DmGetResourceIndex (DmOpenRef dbP, UInt16 index)
  |
-> |
Access pointer to open database. |
  |
-> |
Index of resource to lock down. |
NULL
and
DmGetLastErr
returns an error code indicating the reason for failure.
IMPORTANT: This function accesses the resource only in the database you specify. If you pass a pointer to a base resource database, its overlay is not accessed. Therefore, you should use care when using this function to access a potentially localized resource. You can useDmSearchResource
to obtain a pointer to the overlay database if the resource is localized; however, it's more convenient to use
DmGetResource
or
DmGet1Resource
.
DmFindResource
,
DmFindResourceType
,
DmSearchResource
MemHandle DmGet1Resource (DmResType type, DmResID resID)
NULL
and
DmGetLastErr
returns an error code indicating the reason for failure.
DmReleaseResource
as soon as it finishes accessing the resource data. The resource handle is not locked by this function.
DmGetResource
,
DmReleaseResource
,
ResLoadConstant
Err DmInsertionSort (DmOpenRef dbR, DmComparF *compar, Int16 other)
  |
-> |
Database access pointer. |
  |
-> |
Comparison function. See DmComparF . |
  |
-> |
Any value the application wants to pass to the comparison function. |
errNone
if no error, or one of the following if an error occurs:
DmQuickSort
Err DmMoveCategory (DmOpenRef dbP, UInt16 toCategory, UInt16 fromCategory, Boolean dirty)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Category to which the records should be added. |
  |
-> |
Category from which to remove records. |
  |
-> |
If true , set the dirty bit. |
dirty
is true
, the moved records are marked as dirty.
toCategory
and fromCategory
parameters hold category index values. You can learn which category a record is in with the
DmRecordInfo
call and use that value in this function. For example, the following code, ensures that the records rec1 and rec2 are in the same category:
DmOpenRef myDB;
UInt16 rec1, rec2;
UInt16 rec1Attr, rec2Attr;
UInt16 category1, category2;
DmRecordInfo (myDB, rec1, &rec1Attr, NULL,
    NULL);
category1 = rec1Attr & dmRecAttrCategoryMask;
DmRecordInfo(myDB, rec2, &rec2Attr, NULL,
    NULL);
category2 = rec2Attr & dmRecAttrCategoryMask;
if (category1 != category2)
    DmMoveCategory(myDB, category1, category2,
    true);
Err DmMoveRecord (DmOpenRef dbP, UInt16 from, UInt16 to)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Index of record to move. |
  |
-> |
Where to move the record. |
errNone
if no error, or one of the following if an error occurs:
to
index and move other records down. The to
position should be viewed as an insertion position. This value may be one greater than the index of the last record in the database. In cases where to
is greater than from
, the new index of the record becomes to
-1 after the move is complete.
MemHandle DmNewHandle (DmOpenRef dbP, UInt32 size)
chunkID
of new chunk. If an error occurs, returns 0, and
DmGetLastErr
returns an error code indicating the reason for failure.
LocalID
in the appInfoID
or sortInfoID
fields of the header.
MemHandle DmNewRecord (DmOpenRef dbP, UInt16* atP, UInt32 size)
  |
-> |
DmOpenRef to open database. |
  |
<-> |
Pointer to index where new record should be placed. Specify the value dmMaxRecordIndex to add the record to the end of the database. |
  |
-> |
Size of new record. |
DmGetLastErr
returns an error code indicating the reason for failure.
atP
points to an index variable. The new record is inserted at index *atP
and all record indices that follow are shifted down. If *atP
is greater than the number of records currently in the database, the new record is appended to the end and its index is returned in *atP
.
busy
and dirty
bits are set for the new record and a unique ID is automatically created.
DmReleaseRecord
should be called as soon as the caller finishes viewing or editing the record.
DmAttachRecord
,
DmRemoveRecord
,
DmDeleteRecord
MemHandle DmNewResource (DmOpenRef dbP, DmResType resType, DmResID resID, UInt32 size)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Type of the new resource. |
  |
-> |
ID of the new resource. |
  |
-> |
Desired size of the new resource. |
NULL
and
DmGetLastErr
returns an error code indicating the reason for failure.
DmReleaseResource
as soon as it finishes initializing the resource.
DmAttachResource
,
DmRemoveResource
DmOpenRef
to next open database for the current task.
DmOpenRef DmNextOpenDatabase (DmOpenRef currentP)
DmOpenRef
to next open database, or NULL
if there are no more.
DmOpenRefs
of all open databases. Pass NULL
for currentP
to get the first one. Applications don't usually call this function, but is useful for system information.
DmOpenDatabaseInfo
,
DmDatabaseInfo
DmOpenRef DmNextOpenResDatabase (DmOpenRef dbP)
NULL
for dbP
. This is the database that is searched when
DmGet1Resource
is called.
DmOpenRef
returned by this function is a pointer to the overlay database, not the base database. If you subsequently pass this pointer to
DmFindResource
, you'll receive a handle to the overlaid resource. If you're searching for a resource that is found only in the base, you won't find it. Instead, always use
DmGetResource
or
DmGet1Resource
to obtain a resource. Both of those functions search both the overlay databases and their associated base databases.
UInt16 DmNumDatabases (UInt16 cardNo)
DmGetDatabase
accepts an index from 0 to
DmNumDatabases
-1 and returns a database ID by index.
DmGetDatabase
UInt16 DmNumRecords (DmOpenRef dbP)
deleted
bit set (that is, records that will be deleted during the next synchronization because the user has marked them deleted) are included in the count. If you want to exclude these records from your count, use
DmNumRecordsInCategory
and pass dmAllCategories
as the category.
DmNumRecordsInCategory
,
DmRecordInfo
,
DmSetRecordInfo
UInt16 DmNumRecordsInCategory (DmOpenRef dbP, UInt16 category)
deleted
bit set are not counted, and if the user has specified to hide or mask private records, private records are not counted either.
DmRecordInfo
call to obtain a category index from a given record. For example:
DmOpenRef myDB;
UInt16 record, attr, category, total;
DmRecordInfo(myDB, record, &attr, NULL, NULL);
category = attr & dmRecAttrCategoryMask;
total = DmNumRecordsInCategory(myDB, category);
DmNumRecords
,
DmQueryNextInCategory
,
DmPositionInCategory
,
DmSeekRecordInCategory
,
DmMoveCategory
UInt16 DmNumResources (DmOpenRef dbP)
DmNumResources
only counts the resources in the database indicated by the DmOpenRef
parameter. If the database is a resource database that has an overlay associated with it, this function only returns the number of resources in the base database, not in the overlay.
DmOpenRef DmOpenDatabase (UInt16 cardNo, LocalID dbID, UInt16 mode)
  |
-> |
Card number database resides on. |
  |
-> |
The database ID of the database. |
  |
-> |
Which mode to open database in (see "Open Mode Constants"). |
DmOpenRef
to open database. May display a fatal error message if the database parameter is NULL
. On all other errors, this function returns 0 and
DmGetLastErr
returns an error code indicating the reason for failure.
DmOpenRef
which must be used to access particular records in a database. If unsuccessful, 0 is returned and the cause of the error can be determined by calling
DmGetLastErr
.
OmGetCurrentLocale
returns the current locale.) Overlays are resource databases typically used to localize applications, shared libraries, and panels. They have the same creator as the base database, a type of 'ovly'
(symbolically named omOverlayDBType
), and contain resources with the same IDs and types as the resources in the base database. When you request a resource from the database using
DmGetResource
or
DmGet1Resource
, the overlay is searched first. If the overlay contains a resource for the given ID, it is returned. If not, the resource from the base database is returned.
DmOpenRef
returned by this function is the pointer to the base database, not to the overlay database, so care should be taken when passing this pointer to functions such as
DmFindResource
because this circumvents the overlay.
DmOpenDatabase
only opens a stripped database if its corresponding overlay exists. If the overlay does not exist or if the overlay doesn't match the resource database, DmOpenDatabase
returns NULL
and
DmGetLastErr
returns the error code omErrBaseRequiresOverlay.
TIP: If you want to prevent your resource database from being overlaid, include an'xprf'
resource (symbolically namedsysResTExtPrefs
) in the database with the ID 0 (sysResIDExtPrefs
) and set itsdisableOverlays
flag. This resource is defined inUIResources.r
.
DmCloseDatabase
,
DmCreateDatabase
,
DmFindDatabase
,
DmOpenDatabaseByTypeCreator
,
DmDeleteDatabase
,
DmOpenDBNoOverlay
DmOpenRef DmOpenDatabaseByTypeCreator (UInt32 type, UInt32 creator, UInt16 mode)
  |
-> |
Type of database. |
  |
-> |
Creator of database. |
  |
-> |
Which mode to open database in (see "Open Mode Constants"). |
DmOpenRef
to open database. If the database couldn't be found, this function returns 0 and
DmGetLastErr
returns an error code indicating the reason for failure.
DmOpenDatabase
for more information on overlays and resource databases.
DmCreateDatabase
,
DmOpenDatabase
,
DmOpenDatabaseInfo
,
DmCloseDatabase
,
DmOpenDBNoOverlay
Err DmOpenDatabaseInfo (DmOpenRef dbP, LocalID* dbIDP, UInt16* openCountP, UInt16* modeP, UInt16* cardNoP, Boolean* resDBP)
  |
-> |
DmOpenRef to open database. |
  |
<- |
The ID of the database. Pass NULL for this parameter if you don't want to retrieve this information. |
  |
<- |
The number of applications that have this database open. Pass NULL for this parameter if you don't want to retrieve this information. |
  |
<- |
The mode used to open the database (see "Open Mode Constants"). Pass NULL for this parameter if you don't want to retrieve this information. |
  |
<- |
The number of the card on which this database resides. Pass NULL for this parameter if you don't want to retrieve this information. |
  |
<- |
If true upon return, the database is a resource database, false otherwise. Pass NULL for this parameter if you don't want to retrieve this information. |
errNone
if no error.
DmDatabaseInfo
DmOpenRef DmOpenDBNoOverlay (UInt16 cardNo, LocalID dbID, UInt16 mode)
  |
-> |
Card number database resides on. |
  |
-> |
The database ID of the database. |
  |
-> |
Which mode to open database in (see "Open Mode Constants"). |
DmOpenRef
to open database. May display a fatal error message if the database parameter is NULL
. On all other errors, this function returns 0 and
DmGetLastErr
returns an error code indicating the reason for failure.
DmOpenRef
which must be used to access particular records in a database. If unsuccessful, 0 is returned and the cause of the error can be determined by calling
DmGetLastErr
.
DmCloseDatabase
,
DmCreateDatabase
,
DmFindDatabase
,
DmOpenDatabaseByTypeCreator
,
DmDeleteDatabase
,
DmOpenDatabase
UInt16 DmPositionInCategory (DmOpenRef dbP, UInt16 index, UInt16 category)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Index of the record. |
  |
-> |
Index of category to search. |
DmGetLastErr
returns an error code indicating the reason for failure. Note that this means a 0 return value might indicate either success or failure. If this function returns 0 and DmGetLastErr
returns errNone
, the return value indicates that this is the first record in the category.
DmAccessType
structure.
DmRecordInfo
.
DmQueryNextInCategory
,
DmSeekRecordInCategory
,
DmMoveCategory
busy
bit).
MemHandle DmQueryNextInCategory (DmOpenRef dbP, UInt16* indexP, UInt16 category)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Index of a known record (often retrieved with DmPositionInCategory ). |
  |
-> |
Index of category to query, or dmAllCategories to find the next record in any category. |
NULL
, and
DmGetLastErr
returns an error code indicating the reason for failure.
*indexP
for a record that is in the specified category. If the record at *indexP
belongs to that category, then a handle to it is returned. If not, the function continues searching until it finds a record in the category.
DmOpenRef myDB;
UInt16 record, attr, category, pos;
MemHandle newRecH;
DmRecordInfo(myDB, record, &attr, NULL, NULL);
category = attr & dmRecAttrCategoryMask;
pos = DmPositionInCategory(myDB, record,
    category);
pos++;
newRecH = DmQueryNextInCategory(myDB, &pos, category);
DmNumRecordsInCategory
,
DmPositionInCategory
,
DmSeekRecordInCategory
busy
bit).
MemHandle DmQueryRecord (DmOpenRef dbP, UInt16 index)
NULL
, and
DmGetLastErr
returns an error code indicating the reason for failure.
Err DmQuickSort (DmOpenRef dbP, DmComparF *compar, Int16 other)
  |
-> |
Database access pointer. |
  |
-> |
Comparison function. See DmComparF . |
  |
-> |
Any value the application wants to pass to the comparison function. |
errNone
if no error, or one of the following if an error occurs:
DmQuickSort
returns, equal database records do not have a consistent order. That is, if DmQuickSort
is passed two equal records, their resulting order is unpredictable. To prevent records that contain the same data from being rearranged in an unpredictable order, pass the record's unique ID to the comparison function (using the
SortRecordInfoType
structure).
DmFindSortPositionV10
,
DmInsertionSort
Err DmRecordInfo (DmOpenRef dbP, UInt16 index, UInt16* attrP, UInt32* uniqueIDP, LocalID* chunkIDP)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Index of the record. |
  |
<- |
The record's attributes. See "Record Attribute Constants." Pass NULL for this parameter if you don't want to retrieve this value. |
  |
<- |
The record's unique ID. Pass NULL for this parameter if you don't want to retrieve this value. |
  |
<- |
The record's local ID. Pass NULL for this parameter if you don't want to retrieve this value. |
errNone
if no error or dmErrIndexOutOfRange if the specified record can't be found. Some releases may display a fatal error message instead of returning the error code.
DmNumRecords
,
DmSetRecordInfo
,
DmQueryNextInCategory
busy
bit for the given record and set the dirty
bit if dirty is true
.
Err DmReleaseRecord (DmOpenRef dbP, UInt16 index, Boolean dirty)
  |
-> |
DmOpenRef to open database. |
  |
-> |
The record to unlock. |
  |
-> |
If true , set the dirty bit. |
errNone
if no error, or dmErrIndexOutOfRange if the specified index is out of range. Some releases may display a fatal error message instead of returning the error code.
DmGetRecord
on or created using
DmNewRecord
.
DmGetRecord
DmGetResource
.
Err DmReleaseResource (MemHandle resourceH)
errNone
if no error.
DmGet1Resource
,
DmGetResource
Err DmRemoveRecord (DmOpenRef dbP, UInt16 index)
errNone
if no error, or one of the following if an error occurs:
DmDetachRecord
,
DmDeleteRecord
,
DmArchiveRecord
,
DmNewRecord
Err DmRemoveResource (DmOpenRef dbP, UInt16 index)
DmDetachResource
,
DmRemoveResource
,
DmAttachResource
Err DmRemoveSecretRecords (DmOpenRef dbP)
errNone
if no error, or one of the following if an error occurs:
DmRemoveRecord
,
DmRecordInfo
,
DmSetRecordInfo
MemHandle DmResizeRecord (DmOpenRef dbP, UInt16 index, UInt32 newSize)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Which record to retrieve. |
  |
-> |
New size of record. |
NULL
if there is not enough space to resize the record, and
DmGetLastErr
returns an error code indicating the reason for failure. Some releases may display a fatal error message instead of returning the error code.
MemHandle DmResizeResource (MemHandle resourceH, UInt32 newSize)
NULL
if there is not enough space to resize the resource, and
DmGetLastErr
returns an error code indicating the reason for failure. Some releases may display a fatal error message instead of returning the error code.
Err DmResourceInfo (DmOpenRef dbP, UInt16 index, DmResType* resTypeP, DmResID* resIDP, LocalID* chunkLocalIDP)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Index of resource to get info on. |
  |
<- |
The resource type. Pass NULL if you don't want to retrieve this information. |
  |
<- |
The resource ID. Pass NULL if you don't want to retrieve this information. |
  |
<- |
The memory manager local ID of the resource data. Pass NULL if you don't want to retrieve this information. |
errNone
if no error or
dmErrIndexOutOfRange
if an error occurred. May display a fatal error message if the database is not a resource database.
dbP
is a pointer to a base resource database, the information returned is about the resource from that database alone; this function ignores any associated overlay.
DmGetResource
,
DmGet1Resource
,
DmSetResourceInfo
,
DmFindResource
,
DmFindResourceType
UInt16 DmSearchRecord (MemHandle recH, DmOpenRef* dbPP)
*dbPP
is 0.
DmGetRecord
,
DmFindRecordByID
,
DmRecordInfo
NULL
.
UInt16 DmSearchResource (DmResType resType, DmResID resID, MemHandle resH, DmOpenRef* dbPP)
  |
-> |
Type of resource to search for. |
  |
-> |
ID of resource to search for. |
  |
-> |
Pointer to locked resource, or NULL . |
  |
<- |
The resource database that contains the specified resource. |
DmOpenRef
in dbPP
.
resH
is NULL
, the resource is searched for by type and ID. If resH
is not NULL
, resType
and resID
is ignored and the index of the resource handle is returned. On return, *dbPP
contains the access pointer of the resource database that the resource was eventually found in. Once the index of a resource is determined, it can be locked down and accessed by calling
DmGetResourceIndex.
dbPP
return value is a pointer to the overlay database, not the base resource database.
DmGetResource
,
DmFindResourceType
,
DmResourceInfo
,
DmFindResource
offset
parameter indicates the number of records to move forward or backward.)
Err DmSeekRecordInCategory (DmOpenRef dbP, UInt16* indexP, Int16 offset, Int16 direction, UInt16 category)
  |
-> |
DmOpenRef to open database. |
  |
<-> |
The index to start the search at. Upon return, contains the index of the record at offset from the index that you passed in. |
  |
-> |
Offset of the passed record index. This must be a positive number; use dmSeekBackward for the direction parameter to search backwards. |
  |
-> |
Must be either dmSeekForward or dmSeekBackward . |
  |
-> |
Category index. |
errNone
if no error; returns
dmErrIndexOutOfRange
or
dmErrSeekFailed
if an error occurred.
DmSeekRecordInCategory
searches for a record in the specified category. The search begins with the record at index
. When it finds a record in the specified category, it decrements the offset
parameter and continues searching until a match is found and offset
is 0.
DmSeekRecordInCategory
to find the nearest matching record in a particular category, you must pass different offset
parameters if the starting record is in the category than if it isn't. If the record at index
is in the category, then you must pass an offset
of 1 to find the next record in the category because the comparison is performed before the index
value changes. If the record at index
isn't in the category, you must pass an offset
of 0 to find the next record in the category. In this case, an offset
of 1 skips the first matching record.
DmNumRecordsInCategory
,
DmQueryNextInCategory
,
DmPositionInCategory
,
DmMoveCategory
Err DmSet (void* recordP, UInt32 offset, UInt32 bytes, UInt8 value)
  |
-> |
Pointer to locked data record (chunk pointer). |
  |
-> |
Offset within record to start writing. |
  |
-> |
Number of bytes to write. |
  |
-> |
Byte value to write. |
errNone
if no error. May display a fatal error message if the record pointer is invalid or the function overwrites the record.
DmWrite
Err DmSetDatabaseInfo (UInt16 cardNo, LocalID dbID, const Char* nameP, UInt16* attributesP, UInt16* versionP, UInt32* crDateP, UInt32* modDateP, UInt32* bckUpDateP, UInt32* modNumP, LocalID* appInfoIDP, LocalID* sortInfoIDP, UInt32* typeP, UInt32* creatorP)
  |
-> |
Card number the database resides on. |
  |
-> |
Database ID of the database. |
  |
-> |
Pointer to 32-byte character array for new name, or NULL . |
  |
-> |
Pointer to new attributes variable, or NULL . See "Database Attribute Constants" for a list of possible values. |
  |
-> |
Pointer to new version, or NULL . |
  |
-> |
Pointer to new creation date variable, or NULL . Specify the value as a number of seconds since Jan 1, 1904. |
  |
-> |
Pointer to new modification date variable, or NULL . Specify the value as a number of seconds since Jan 1, 1904. |
  |
-> |
Pointer to new backup date variable, or NULL . Specify the value as a number of seconds since Jan 1, 1904. |
  |
-> |
Pointer to new modification number variable, or NULL . |
  |
-> |
Pointer to new appInfoID variable, or NULL . |
  |
-> |
Pointer to new sortInfoID variable, or NULL . |
  |
-> |
Pointer to new type variable, or NULL . |
  |
-> |
Pointer to new creator variable, or NULL . |
appInfoID
or sortInfoID
, the old chunk ID (if any) is marked as an orphan chunk and the new chunk ID is unorphaned. Consequently, you shouldn't replace an existing appInfoID
or sortInfoID
if that chunk has already been attached to another database.
NULL
parameter.
DmDatabaseInfo
,
DmOpenDatabaseInfo
,
DmFindDatabase
,
DmGetNextDatabaseByTypeCreator
,
TimDateTimeToSeconds
Err DmSetRecordInfo (DmOpenRef dbP, UInt16 index, UInt16* attrP, UInt32* uniqueIDP)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Index of record. |
  |
-> |
Pointer to new attribute variable, or NULL . See "Record Attribute Constants" for a list of possible values. |
  |
-> |
Pointer to new unique ID variable, or NULL . |
errNone
if no error, or one of the following if an error occurred:
DmNewRecord
, so an application would not typically change the unique ID.
DmNumRecords
,
DmRecordInfo
Err DmSetResourceInfo (DmOpenRef dbP, UInt16 index, DmResType* resTypeP, DmResID* resIDP)
  |
-> |
DmOpenRef to open database. |
  |
-> |
Index of resource to set info for. |
  |
-> |
Pointer to new resType (resource type), or NULL . |
  |
-> |
Pointer to new resource ID, or NULL . |
NULL
. If not NULL
, the type and ID of the resource are changed to *resTypeP
and *resIDP
.
Err DmStrCopy (void* recordP, UInt32 offset, const Char * srcP)
  |
<-> |
Pointer to data record (chunk pointer). |
  |
-> |
Offset within record to start writing. |
  |
-> |
Pointer to null-terminated string. |
errNone
if no error. May display a fatal error message if the record pointer is invalid or the function overwrites the record.
DmWrite
,
DmSet
Err DmWrite (void* recordP, UInt32 offset, const void * srcP, UInt32 bytes)
  |
<-> |
Pointer to locked data record (chunk pointer). |
  |
-> |
Offset within record to start writing. |
  |
-> |
Pointer to data to copy into record. |
  |
-> |
Number of bytes to write. |
errNone
if no error. May display a fatal error message if the record pointer is invalid or the function overwrites the record.
DmSet
Err DmWriteCheck (void* recordP, UInt32 offset, UInt32 bytes)
  |
-> |
Locked pointer to recordH . |
  |
-> |
Offset into record to start writing. |
  |
-> |
Number of bytes to write. |
errNone
if no error; returns
dmErrNotValidRecord
or
dmErrWriteOutOfBounds
if an error occurred.
typedef Int16 DmComparF (void* rec1, void* rec2, Int16 other, SortRecordInfoPtr rec1SortInfo, SortRecordInfoPtr rec2SortInfo, MemHandle appInfoH)
  |
-> |
Pointers to the two records to sort. |
  |
-> |
Any other custom information you want passed to the comparison function. |
  |
-> |
Pointers to SortRecordInfoType structures that specify unique sorting information for the two records. |
  |
-> |
A handle to the database's application info block. |
DmFindSortPosition
,
DmInsertionSort
, and
DmQuickSort
.
DmComparF
prototype changed in Palm OS® version 2.0. Previously, the prototype only defined the first three parameters.
  |   |