home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / happydays-src-1.37.tar.gz / happydays-src-1.37.tar / happydays-1.37 / memodb.c < prev    next >
C/C++ Source or Header  |  2000-07-27  |  2KB  |  64 lines

  1. /*
  2. HappyDays - A Birthdate displayer for the PalmPilot
  3. Copyright (C) 1999-2000 JaeMok Jeong
  4.  
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. */
  19.  
  20. /*
  21.  * Just so you know these routines are pulled from the Memo source code
  22.  * as provided by Palm.  At least that is what I started from, I may have
  23.  * touched a few lines to get it to compile with gcc without warnings.
  24.  */
  25.  
  26. // Set this to get to private database defines
  27. #define __MEMOMGR_PRIVATE__
  28.  
  29. #include <PalmOS.h>
  30. #include "memodb.h"
  31.  
  32.  
  33.  
  34. Err MemoNewRecord (DmOpenRef dbP, MemoItemPtr item, UInt16 *index)
  35. {
  36.     Err                     result;
  37.     UInt32                    size = 0;
  38.     MemHandle                recordH;
  39.     MemoDBRecordPtr    recordP;
  40.  
  41.     // Compute the size of the new memo record.
  42.     size = StrLen (item->note);
  43.  
  44.     //  Allocate a chunk in the database for the new record.
  45.     recordH = (MemHandle)DmNewHandle(dbP, size+1);
  46.     if (recordH == NULL)
  47.         return dmErrMemError;
  48.  
  49.     // Pack the the data into the new record.
  50.     recordP = MemHandleLock (recordH);
  51.     DmStrCopy(recordP, 0, item->note);
  52.  
  53.     MemPtrUnlock (recordP);
  54.  
  55.     // Insert the record.
  56.     *index = dmMaxRecordIndex;
  57.     result = DmAttachRecord(dbP, index, recordH, 0);
  58.     if (result)
  59.         MemHandleFree(recordH);
  60.  
  61.     return result;
  62. }
  63.  
  64.