SourceForge.net Logo
/******************************************************************************
 *
 * Copyright (c) 1995-2000 Palm, Inc. or its subsidiaries.
 * All rights reserved.
 *
 * File: DateDB.h
 *
 * Release: Palm OS SDK 4.0 (63220)
 *
 * Description:
 *Header for the Appointment Manager
 *
 * History:
 *   1/25/95  rsf - Created
 *
 *****************************************************************************/

#ifndef __TDAPPTMGR_H__
#define __TDAPPTMGR_H__


typedef struct {
  UInt16renamedCategories;// bitfield of categories with a different name
  char categoryLabels[dmRecNumCategories][dmCategoryLength];
  UInt8categoryUniqIDs[dmRecNumCategories];
  UInt8lastUniqID;// Uniq IDs generated by the device are between
  // 0 - 127.  Those from the PC are 128 - 255.
  UInt8reserved1;// from the compiler word aligning things
  UInt16reserved2;
  UInt8startOfWeek;
  UInt8reserved;
} ApptAppInfoType;


typedef ApptAppInfoType * ApptAppInfoPtr;


/************************************************************
 *
 * Appointment Database constants.
 *
 *************************************************************/
#define apptMaxPerDay 100// max appointments displayable on a day.
#define apptNoTime-1// start time of an untimed appt.
#define apptNoEndDate0xffff// end date of appts that repeat forever
#define apptNoAlarm-1
#define apptMaxEndTime0x1737// 11:55 pm, hours in high byte, minutes in low byte
#define apptDawnOfTime0
#define apptEndOfTime0xffffffff

#define apptMaxDisplayableAlarms 10


/************************************************************
 *
 * Appointment Database structures.
 *
 *************************************************************/

// The format of a packed appointment record is as follows:
//
//ApptDateTimeType when;
//ApptDBRecordFlagsflags;// A flag set for each datum present
//AlarmInfoTypealarm;// optional
//RepeatInfoTyperepeat;// optional
//ExceptionsListTypeexceptions;// optional
//char []note;// null terminated, optional
//char []description;// null terminated
//
// All optional data may or may not appear.



// Alarm advance - the period of time before the appointment that the 
// alarm should sound.
//
typedef enum alarmTypes {aauMinutes, aauHours, aauDays} AlarmUnitType;

typedef struct {
  Int8advance;// Alarm advance (-1 = no alarm)
  AlarmUnitTypeadvanceUnit;// minutes, hours, days
} AlarmInfoType;


// The following enum is used to specify the frequency of
// repeating appointments.
//
enum repeatTypes {
  repeatNone, 
  repeatDaily, 
  repeatWeekly, 
  repeatMonthlyByDay, 
  repeatMonthlyByDate,
  repeatYearly
};
typedef enum repeatTypes RepeatType;


// This structure contains information about repeat appointments.  The 
// repeatOn member is only used by weelky and monthly-by-day repeating
// appointments.  For weekly the byte is a bit field that contains the 
// days of the week the appointments occurs on (bit: 0-sun, 1-mon, 
// 2-tue, etc.).  For monthly-by-day the byte contains the day the 
// appointments occurs, (ex: the 3rd friday), the byte is of type 
// DayOfMonthType.
//
typedef struct {
  RepeatTyperepeatType;// daily, weekly, monthlyByDay, etc.
  UInt8reserved1;
  DateTyperepeatEndDate;// minus one if forever
  UInt8repeatFrequency;// i.e. every 2 days if repeatType daily
  UInt8repeatOn;// monthlyByDay and repeatWeekly only
  UInt8  repeatStartOfWeek;// repeatWeekly only
  UInt8reserved2;
} RepeatInfoType;

typedef RepeatInfoType * RepeatInfoPtr;


// This checks a weekly appointment's repeat info and returns true if the
// appointment occurs on only one day per week.
// The form (x & (x - 1)) masks out the lowest order bit in x.  (K&R, p. 51)
// If only one bit is set, which occurs iff the appointment is only
// once per week, then (x & (x - 1)) == 0.
#define OnlyRepeatsOncePerWeek(R)  (((R).repeatOn & ((R).repeatOn - 1)) == 0)


// RepeatOnDOW - true if repeat info R repeats on day of week D
#define RepeatOnDOW(R, D)   ((1 << (D)) & ((R)->repeatOn))


// This structure contains information about the date and time of an 
// appointment.
//
typedef struct {
  TimeTypestartTime;// Time the appointment starts
  TimeTypeendTime;// Time the appointment ends
  DateTypedate;// date of appointment
} ApptDateTimeType;



// This is the structure for a repeating appointment's exceptions list.  The
// exceptions list is a variable length list of dates that the repeating appointment
// should not appear on.  The list is in chronological order.
//
typedef struct {
  UInt16    numExceptions;
  DateTypeexception;
} ExceptionsListType;

typedef ExceptionsListType * ExceptionsListPtr;



// This structure describes what information is present in an
// AppointmentPackedDBRecordType
typedef struct {
  unsigned when:1;// set if when info changed (ApptChangeRecord)
  unsigned alarm:1;// set if record contains alarm info
  unsigned repeat:1;// set if record contains repeat info
  unsigned note:1;// set if record contains a note
  unsigned exceptions:1;// set if record contains exceptions list
  unsigned description:1;
} ApptDBRecordFlags;


// ApptDBRecordType
//
// This is the record used by the application.  All pointers are either NULL 
// or point to data within the PackedDB record.  All strings are null 
// character terminated.

typedef struct {
  ApptDateTimeType *when;
  AlarmInfoType *alarm;
  RepeatInfoType *repeat;
  ExceptionsListType *exceptions;
  Char *description;
  Char *note;
} ApptDBRecordType;

typedef ApptDBRecordType * ApptDBRecordPtr;


// ApptGetAppointments returns an array of the following structures.
typedef struct {
  TimeTypestartTime;
  TimeTypeendTime;
  UInt16recordNum;
} ApptInfoType;
typedef ApptInfoType * ApptInfoPtr;



/************************************************************
 *
 * Appointment database routines.
 *
 *************************************************************/

#ifdef __cplusplus
extern "C" {
#endif


  Err ApptAppInfoInit (DmOpenRef dbP);

  Err ApptGetRecord (DmOpenRef dbP, UInt16 index, ApptDBRecordPtr r,
		     MemHandle * handleP);

  Err ApptNewRecord (DmOpenRef dbP, ApptDBRecordPtr r, UInt16 *index);

  Err ApptChangeRecord (DmOpenRef dbP, UInt16 *index, ApptDBRecordPtr r, 
			ApptDBRecordFlags changedFields);

  Err ApptAddException (DmOpenRef dbP, UInt16 *index, DateType date);

  Boolean ApptFindFirst (DmOpenRef dbP, DateType date, UInt16 * indexP);

  BooleanApptRepeatsOnDate  (ApptDBRecordPtr apptRec, DateType date);

  BooleanApptNextRepeat (ApptDBRecordPtr apptRec, DatePtr dateP, Boolean searchForward);

  BooleanApptHasMultipleOccurences (ApptDBRecordPtr apptRec);

  UInt32ApptGetAlarmTime (ApptDBRecordPtr apptRec, UInt32 currentTime, Boolean searchForward);

  UInt32ApptGetTimeOfNextAlarm (DmOpenRef dbP, UInt32 timeInSeconds);

  void ApptPostTriggeredAlarms (DmOpenRef inDbR, UInt32 inAlarmTime);

  voidApptSort (DmOpenRef dbP);

  void ApptGetAppointments (DmOpenRef dbP, DateType date, UInt16 days,
			    MemHandle apptLists [], UInt16 counts []);


#ifdef __cplusplus
}
#endif

#endif



Tutorials

Linux System Admin Tips: There are over 200 Linux tips and tricks in this article. That is over 100 pages covering everything from NTP, setting up 2 IP address on one NIC, sharing directories among several users, putting running jobs in the background, find out who is doing what on your system by examining open sockets and the ps command, how to watch a file, how to prevent even root from deleting a file, tape commands, setting up cron jobs, using rsync, using screen conveniently with emacs, how to kill every process for a user, security tips and a lot more. These tip grow weekly. The above link will download the text version for easy grep searching. There is also an html version here.

Breaking Firewalls with OpenSSH and PuTTY: If the system administrator deliberately filters out all traffic except port 22 (ssh), to a single server, it is very likely that you can still gain access other computers behind the firewall. This article shows how remote Linux and Windows users can gain access to firewalled samba, mail, and http servers. In essence, it shows how openSSH and Putty can be used as a VPN solution for your home or workplace.

MySQL Tips and Tricks: Find out who is doing what in MySQL and how to kill the process, create binary log files, connect, create and select with Perl and Java, remove duplicates in a table with the index command, rollback and how to apply, merging several tables into one, updating foreign keys, monitor port 3306 with the tcpdump command, creating a C API, complex selects, and much more.

Create a Live Linux CD - BusyBox and OpenSSH Included: These steps will show you how to create a functioning Linux system, with the latest 2.6 kernel compiled from source, and how to integrate the BusyBox utilities including the installation of DHCP. Plus, how to compile in the OpenSSH package on this CD based system. On system boot-up a filesystem will be created and the contents from the CD will be uncompressed and completely loaded into RAM -- the CD could be removed at this point for boot-up on a second computer. The remaining functioning system will have full ssh capabilities. You can take over any PC assuming, of course, you have configured the kernel with the appropriate drivers and the PC can boot from a CD. This tutorial steps you through the whole processes.

SQLite Tutorial : This article explores the power and simplicity of sqlite3, first by starting with common commands and triggers, then the attach statement with the union operation is introduced in a way that allows multiple tables, in separate databases, to be combined as one virtual table, without the overhead of copying or moving data. Next, the simple sign function and the amazingly powerful trick of using this function in SQL select statements to solve complex queries with a single pass through the data is demonstrated, after making a brief mathematical case for how the sign function defines the absolute value and IF conditions.

The Lemon Parser Tutorial: This article explains how to build grammars and programs using the lemon parser, which is faster than yacc. And, unlike yacc, it is thread safe.

How to Compile the 2.6 kernel for Red Hat 9 and 8.0 and get Fedora Updates: This is a step by step tutorial on how to compile the 2.6 kernel from source.

Virtual Filesystem: Building A Linux Filesystem From An Ordinary File. You can take a disk file, format it as ext2, ext3, or reiser filesystem and then mount it, just like a physical drive. Yes, it then possible to read and write files to this newly mounted device. You can also copy the complete filesystem, since it is just a file, to another computer. If security is an issue, read on. This article will show you how to encrypt the filesystem, and mount it with ACL (Access Control Lists), which give you rights beyond the traditional read (r) write (w) and execute (x) for the 3 user groups file, owner and other.

Working With Time: What? There are 61 seconds in a minute? We can go back in time? We still tell time by the sun?



Chirico img Mike Chirico, a father of triplets (all girls) lives outside of Philadelphia, PA, USA. He has worked with Linux since 1996, has a Masters in Computer Science and Mathematics from Villanova University, and has worked in computer-related jobs from Wall Street to the University of Pennsylvania. His hero is Paul Erdos, a brilliant number theorist who was known for his open collaboration with others.


Mike's notes page is souptonuts. For open source consulting needs, please send an email to mchirico@gmail.com. All consulting work must include a donation to SourceForge.net.

SourceForge.net Logo


SourceForge.net Logo