|
ODB Engine API
/*© copyright 1996 UserLand Software, Inc. All Rights Reserved.*/
#ifndef odbEngineInclude
#define odbEngineInclude
#if !defined (MACVERSION) && !defined (WIN95VERSION)
#if defined (WIN32) || defined (_WIN32)
#define WIN95VERSION
#endif
#if defined (macintosh)
#define MACVERSION
#endif
#endif
#ifdef MACVERSION
#include <Types.h>
#include <QuickDraw.h>
#include <Files.h>
#define xpascal pascal
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef MACVERSION
#define gettickcount() TickCount()
typedef short hdlfilenum;
#endif
#ifdef WIN95VERSION
#define NEWFILESPECTYPE 1
#define xpascal
#define gettickcount() ((GetTickCount()*60L)/1000L)
typedef HANDLE hdlfilenum;
typedef char * Ptr;
typedef Ptr * Handle;
typedef unsigned long OSType;
typedef struct tyRect
{
short top;
short left;
short bottom;
short right;
} Rect;
typedef struct tyPoint
{
short v;
short h;
} Point, *PointPtr;
#endif
#ifdef NEWFILESPECTYPE
typedef struct newtyfilespec {
short fileTypeID;
short lengthOfFileSpecifier;
long volumeID;
char fullSpecifier[258];
Handle fileSpecifier;
long macSpecifier;
} tyfilespec, *ptrfilespec, **hdlfilespec;
#else
typedef FSSpec tyfilespec, *ptrfilespec, **hdlfilespec;
#endif
#ifdef MACVERSION
#ifdef __MWERKS__
#pragma options align = mac68k
#endif
#endif
typedef struct odb_ * odbRef;
typedef unsigned char odbBool;
typedef unsigned char odbString [256];
typedef enum odbDirection {
nodirection = 0,
dir_up = 1,
dir_down = 2,
dir_left = 3,
dir_right = 4,
dir_flatup = 5,
dir_flatdown = 6,
dir_sorted = 8,
dir_pageup = 9,
dir_pagedown = 10,
dir_pageleft = 11,
dir_pageright = 12
} odbDirection;
typedef enum odbValueType {
unknownvaluetype = '\?\?\?\?',
charvaluetype = 'char',
shortvaluetype = 'shor',
longvaluetype = 'long',
binaryvaluetype = 'data',
booleanvaluetype = 'bool',
tokenvaluetype = 'tokn',
datevaluetype = 'date',
addressvaluetype = 'addr',
codevaluetype = 'code',
extendedvaluetype = 'exte',
stringvaluetype = 'TEXT',
externalvaluetype = 'xtrn',
directionvaluetype = 'dir ',
string4valuetype = 'type',
pointvaluetype = 'QDpt',
rectvaluetype = 'qdrt',
patternvaluetype = 'tptn',
rgbvaluetype = 'cRGB',
fixedvaluetype = 'fixd',
singlevaluetype = 'sing',
// doublevaluetype = 'exte',
doublevaluetype = 'doub',
objspecvaluetype = 'obj ',
filespecvaluetype = 'fss ',
aliasvaluetype = 'alis',
enumeratorvaluetype = 'enum',
listvaluetype = 'list',
recordvaluetype = 'reco',
outlinevaluetype = 'optx',
wptextvaluetype = 'wptx',
tablevaluetype = 'tabl',
scriptvaluetype = 'scpt',
menubarvaluetype = 'mbar',
picturevaluetype = 'pict'
} odbValueType;
typedef union odbValueData {
odbBool flvalue;
unsigned char chvalue;
short intvalue;
long longvalue;
unsigned long datevalue;
odbDirection dirvalue;
OSType ostypevalue;
Handle stringvalue;
Handle addressvalue;
Handle binaryvalue;
Handle externalvalue;
Point pointvalue;
Rect **rectvalue;
#ifdef MACVERSION
Pattern **patternvalue;
RGBColor **rgbvalue;
Fixed fixedvalue;
FSSpec **filespecvalue;
#endif
float singlevalue;
// extended80 **doublevalue;
double **doublevalue;
Handle objspecvalue;
Handle aliasvalue; /*AliasHandle*/
OSType enumvalue;
Handle listvalue;
Handle recordvalue;
} odbValueData;
typedef struct odbValueRecord {
odbValueType valuetype;
odbValueData data;
} odbValueRecord;
/*prototypes*/
extern xpascal odbBool odbNewFile (hdlfilenum);
extern xpascal odbBool odbOpenFile (hdlfilenum, odbRef *odb);
extern xpascal odbBool odbSaveFile (odbRef odb);
extern xpascal odbBool odbCloseFile (odbRef odb);
extern xpascal odbBool odbDefined (odbRef odb, odbString bspath);
extern xpascal odbBool odbDelete (odbRef odb, odbString bspath);
extern xpascal odbBool odbGetType (odbRef odb, odbString bspath, OSType *type);
extern xpascal odbBool odbGetValue (odbRef odb, odbString bspath, odbValueRecord *value);
extern xpascal odbBool odbSetValue (odbRef odb, odbString bspath, odbValueRecord *value);
extern xpascal odbBool odbNewTable (odbRef odb, odbString bspath);
extern xpascal odbBool odbCountItems (odbRef odb, odbString bspath, long *count);
extern xpascal odbBool odbGetNthItem (odbRef odb, odbString bspath, long n, odbString bsname);
extern xpascal odbBool odbGetModDate (odbRef odb, odbString bspath, unsigned long *date);
extern xpascal void odbDisposeValue (odbRef odb, odbValueRecord *value);
extern xpascal void odbGetError (odbString bs);
#ifdef MACVERSION
#ifdef __MWERKS__
#pragma options align = reset
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif
Notes odbNewFile creates a new database structure in an existing file. It does not leave the database open. odbOpenFile opens a database given a file reference number. It must be balanced by a odbClose. odbGetType, odbGetValue, odbCountItems, and odbGetNthItem all retrieve information about the value associated with the given address. odbDisposeValue must be called to deallocate a value retrieved by odbGetValue. odbDelete and odbSetValue allow you to modify the database. Use odbSaveFile to save changes. |