MorePalmOS
A development library for developing Palm OS applications

MoreDataMgr.c

Go to the documentation of this file.
00001 /******************************************************************************
00002  * MorePalmOS
00003  * Copyright (c) 2004 Steven Fisher
00004  *
00005  * Distributed under the Boost Software License, Version 1.0. See accompanying
00006  * license file License.txt or <http://www.boost.org/LICENSE_1_0.txt>.
00007  *
00008  * http://morepalmos.sourceforge.net
00009  *
00010  *   MorePalmOS is the humble begining of an attempt to provide a library for
00011  *   Palm OS development which works around system bugs, illustrate how to
00012  *   use system calls, and provide "glue code" for programming Palm OS
00013  *   applications in a more straightforward way while minimally impacting
00014  *   code size.
00015  *****************************************************************************/
00016 
00017 #include "MorePrefix.h"
00018 #include "MoreDataMgr.h"
00019 #include "MorePrivate.h"
00020 
00021 //-----------------------------------------------------------------------------
00022 
00023 MemHandle MDmQueryRecordByID( DmOpenRef dbP, UInt32 recID, Err* errCode,
00024                 UInt32 *recIdx )
00025 {
00026         MemHandle recH = NULL;
00027         UInt16 idsIdx;
00028         Err err = DmFindRecordByID( dbP, recID, &idsIdx );
00029         _reject( err, failedDmFind );
00030         if ( recIdx )
00031                 *recIdx = idsIdx;
00032         recH = DmQueryRecord( dbP, idsIdx );
00033         _require( recH, failedDmQuery );
00034         err = errNone;
00035         goto succeed;
00036 failedDmQuery:
00037         err = DmGetLastErr( );
00038         // fall through 
00039 failedDmFind:
00040 succeed:
00041         if ( errCode )
00042                 *errCode = err;
00043         return recH;
00044 }
00045 
00046 //-----------------------------------------------------------------------------
00047 
00048 MemHandle MDmGetRecordByID( DmOpenRef dbP, UInt32 recID, Err* errCode,
00049                 UInt32 *recIdx )
00050 {
00051         MemHandle recH = NULL;
00052         UInt16 idsIdx;
00053         Err err = DmFindRecordByID( dbP, recID, &idsIdx );
00054         _reject( err, failedDmFind );
00055         if ( recIdx )
00056                 *recIdx = idsIdx;
00057         recH = DmGetRecord( dbP, idsIdx );
00058         _require( recH, failedDmQuery );
00059         err = errNone;
00060         goto succeed;
00061 failedDmQuery:
00062         err = DmGetLastErr( );
00063         // fall through 
00064 failedDmFind:
00065 succeed:
00066         if ( errCode )
00067                 *errCode = err;
00068         return recH;
00069 }
00070 
00071 //-----------------------------------------------------------------------------
00072 
00073 Err MDmReleaseRecordByID( DmOpenRef dbP, UInt32 recID, Boolean dirty,
00074                 UInt32 *recIdx )
00075 {
00076         UInt16 idsIdx;
00077         Err err = DmFindRecordByID( dbP, recID, &idsIdx );
00078         if ( recIdx )
00079                 *recIdx = idsIdx;
00080         _reject( err, failedDmFind );
00081         return DmReleaseRecord( dbP, idsIdx, dirty );
00082 failedDmFind:
00083         return err;
00084 }

SourceForge.net Logo