|
From: <cre...@us...> - 2007-02-19 01:19:36
|
Revision: 1613
http://svn.sourceforge.net/frontierkernel/?rev=1613&view=rev
Author: creecode
Date: 2007-02-18 17:19:36 -0800 (Sun, 18 Feb 2007)
Log Message:
-----------
support for long odb item names and file paths
formatting tweaks
Modified Paths:
--------------
Frontier/branches/Frontier_Long_File_Paths/Common/source/dbverbs.c
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/dbverbs.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/dbverbs.c 2007-02-19 01:18:30 UTC (rev 1612)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/dbverbs.c 2007-02-19 01:19:36 UTC (rev 1613)
@@ -84,7 +84,7 @@
#else
- /*Prototypes*/
+ // Prototypes
boolean odbnewfile (hdlfilenum fnum);
@@ -96,31 +96,31 @@
boolean odbclosefile (odbref odb);
- boolean odbdefined (odbref odb, bigstring bspath);
+ boolean odbdefined ( odbref, const Handle );
- boolean odbdelete (odbref odb, bigstring bspath);
+ boolean odbdelete ( odbref, const Handle );
- boolean odbgettype (odbref odb, bigstring bspath, OSType *odbType);
+ boolean odbgettype ( odbref, const Handle, OSType * );
- boolean odbgetvalue (odbref odb, bigstring bspath, odbValueRecord *value);
+ boolean odbgetvalue ( odbref, const Handle, odbValueRecord * );
- boolean odbsetvalue (odbref odb, bigstring bspath, odbValueRecord *value);
+ boolean odbsetvalue ( odbref, const Handle, odbValueRecord *value );
- boolean odbnewtable (odbref odb, bigstring bspath);
+ boolean odbnewtable ( odbref, const Handle );
- boolean odbcountitems (odbref odb, bigstring bspath, long *count);
+ boolean odbcountitems ( odbref, const Handle, long * );
- boolean odbgetnthitem (odbref odb, bigstring bspath, long n, bigstring bsname);
+ boolean odbgetnthitem ( odbref, const Handle, long, Handle );
- boolean odbgetmoddate (odbref odb, bigstring bspath, unsigned long *date);
+ boolean odbgetmoddate ( odbref, const Handle, unsigned long * );
boolean odbdisposevalue (odbref odb, odbValueRecord *value);
- /*Functions*/
+ // Functions
boolean odbnewfile (hdlfilenum fnum) {
-
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -135,10 +135,12 @@
swapinthreadglobals (htg);
return (fl);
+
}
+
boolean odbaccesswindow (WindowPtr w, odbref *odb) {
-
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -153,10 +155,12 @@
swapinthreadglobals (htg);
return (fl);
+
}
+
boolean odbopenfile (hdlfilenum fnum, odbref *odb, boolean flreadonly) {
-
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -171,10 +175,12 @@
swapinthreadglobals (htg);
return (fl);
+
}
+
boolean odbsavefile (odbref odb) {
-
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -189,10 +195,12 @@
swapinthreadglobals (htg);
return (fl);
+
}
+
boolean odbclosefile (odbref odb) {
-
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -207,10 +215,16 @@
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbdefined (odbref odb, bigstring bspath) {
+ boolean odbdefined (odbref odb, const Handle handlePath) {
+
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -218,17 +232,19 @@
swapinthreadglobals (nil);
- fl = odbDefined (odb, bspath);
+ fl = odbDefined (odb, handlePath);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbdelete (odbref odb, bigstring bspath) {
+ boolean odbdelete (odbref odb, const Handle handlePath) {
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -236,17 +252,19 @@
swapinthreadglobals (nil);
- fl = odbDelete (odb, bspath);
+ fl = odbDelete (odb, handlePath);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbgettype (odbref odb, bigstring bspath, OSType *odbType) {
+ boolean odbgettype (odbref odb, const Handle handlePath, OSType *odbType) {
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -254,17 +272,19 @@
swapinthreadglobals (nil);
- fl = odbGetType (odb, bspath, odbType);
+ fl = odbGetType (odb, handlePath, odbType);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbgetvalue (odbref odb, bigstring bspath, odbValueRecord *value) {
+ boolean odbgetvalue (odbref odb, const Handle handlePath, odbValueRecord *value) {
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -272,17 +292,19 @@
swapinthreadglobals (nil);
- fl = odbGetValue (odb, bspath, value);
+ fl = odbGetValue (odb, handlePath, value);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbsetvalue (odbref odb, bigstring bspath, odbValueRecord *value) {
+ boolean odbsetvalue (odbref odb, const Handle handlePath, odbValueRecord *value) {
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -290,17 +312,19 @@
swapinthreadglobals (nil);
- fl = odbSetValue (odb, bspath, value);
+ fl = odbSetValue (odb, handlePath, value);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbnewtable (odbref odb, bigstring bspath) {
+ boolean odbnewtable (odbref odb, const Handle handlePath) {
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -308,17 +332,19 @@
swapinthreadglobals (nil);
- fl = odbNewTable (odb, bspath);
+ fl = odbNewTable (odb, handlePath);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbcountitems (odbref odb, bigstring bspath, long *count) {
+ boolean odbcountitems (odbref odb, const Handle handlePath, long *count) {
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -326,17 +352,19 @@
swapinthreadglobals (nil);
- fl = odbCountItems (odb, bspath, count);
+ fl = odbCountItems (odb, handlePath, count);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbgetnthitem (odbref odb, bigstring bspath, long n, bigstring bsname) {
+ boolean odbgetnthitem (odbref odb, const Handle handlePath, long n, Handle handleName) {
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -344,17 +372,19 @@
swapinthreadglobals (nil);
- fl = odbGetNthItem (odb, bspath, n, bsname);
+ fl = odbGetNthItem (odb, handlePath, n, handleName);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
- boolean odbgetmoddate (odbref odb, bigstring bspath, unsigned long *date) {
+ boolean odbgetmoddate (odbref odb, const Handle handlePath, unsigned long *date) {
+
boolean fl;
hdlthreadglobals htg = getcurrentthreadglobals ();
@@ -362,17 +392,19 @@
swapinthreadglobals (nil);
- fl = odbGetModDate (odb, bspath, date);
+ fl = odbGetModDate (odb, handlePath, date);
cancoonglobals = nil;
swapinthreadglobals (htg);
return (fl);
+
}
+
boolean odbdisposevalue (odbref odb, odbValueRecord *value) {
-
+
hdlthreadglobals htg = getcurrentthreadglobals ();
copythreadglobals (htg);
@@ -386,10 +418,12 @@
swapinthreadglobals (htg);
return (true);
+
}
- #define odbgeterror odbGetError
+ #define odbgeterror odbGetError
+
#endif
@@ -444,56 +478,67 @@
getmoddatefunc,
ctdbverbs
+
} tydbtoken;
static boolean odberror (boolean flresult) {
-
+
bigstring bserror;
if (flresult)
return (false);
-
+
odbgeterror (bserror);
langerrormessage (bserror);
return (true);
+
} /*odberror*/
-
+
static boolean getodbparam (hdltreenode hparam1, short pnum, hdlodbrecord *hodbrecord) {
//
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
// 2006-06-23 creedon: for Mac, FSRef-zed
//
-
+
+ Handle h;
bigstring bs;
hdlodbrecord hodb;
+ ptrfilespec ptrfs;
tyfilespec fs;
- ptrfilespec ptrfs;
ptrfs = &fs;
-
+
if (!getfilespecvalue (hparam1, pnum, ptrfs))
return (false);
-
+
( void ) extendfilespec ( ptrfs, ptrfs );
for (hodb = hodblist; hodb != nil; hodb = (**hodb).hnext) {
if ( equalfilespecs ( &( **hodb ).fs, ptrfs ) ) {
-
+
*hodbrecord = hodb;
return (true);
+
}
}
getfsfile ( ptrfs, bs );
- lang2paramerror (dbnotopenederror, bsfunctionname, bs );
+ if ( ! newtexthandle ( bs, &h ) )
+ return ( false );
+
+ lang2paramerror ( dbnotopenederror, handleFunctionName, h );
+ disposehandle ( h );
+
return (false);
} // getodbparam
@@ -502,6 +547,8 @@
static boolean getodbvalue (hdltreenode hparam1, short pnum, tyodbrecord *odb, boolean flreadonly) {
//
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
// 2006-06-23 creedon: for Mac, FSRef-ized
//
@@ -514,13 +561,20 @@
if ((*odb).flreadonly && !flreadonly) {
+ Handle h;
bigstring bs;
getfsfile ( &( *odb ).fs, bs );
- lang2paramerror (dbopenedreadonlyerror, bsfunctionname, bs );
+ if ( ! newtexthandle ( bs, &h ) )
+ return ( false );
+
+ lang2paramerror ( dbopenedreadonlyerror, handleFunctionName, h );
+ disposehandle ( h );
+
return (false);
+
}
return (true);
@@ -710,12 +764,14 @@
static boolean dbdefinedverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
- /*
- 4.1b5 dmb: new verb
- */
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+ // 4.1b5 dmb: new verb
+ //
tyodbrecord odbrec;
- bigstring bsaddress;
+ Handle handleAddress;
boolean fl;
if (!getodbvalue (hparam1, 1, &odbrec, true))
@@ -723,28 +779,31 @@
flnextparamislast = true;
- if (!getstringvalue (hparam1, 2, bsaddress))
- return (false);
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
+ return ( false );
- fl = odbdefined (odbrec.odb, bsaddress);
+ fl = odbdefined (odbrec.odb, handleAddress);
return (setbooleanvalue (fl, vreturned));
+
} /*dbdefinedverb*/
static boolean dbgetvalueverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
- /*
- 4.1.1b1 dmb: fixed memory leak; push value on temp stack
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+ // 5.0.1 dmb: but only pushtmpstack if heapallocated
+ //
+ // 5.0b17 dmb: use pushtmpstackvalue to put external types returned from
+ // the other odb onto our temp stack
+ //
+ // 4.1.1b1 dmb: fixed memory leak; push value on temp stack
+ //
- 5.0b17 dmb: use pushtmpstackvalue to put external types returned from
- the other odb onto our temp stack
-
- 5.0.1 dmb: but only pushtmpstack if heapallocated
- */
-
tyodbrecord odbrec;
- bigstring bsaddress;
+ Handle handleAddress;
odbValueRecord value;
tyvaluetype type;
@@ -753,62 +812,58 @@
flnextparamislast = true;
- if (!getstringvalue (hparam1, 2, bsaddress))
- return (false);
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
+ return ( false );
- if (odberror (odbgetvalue (odbrec.odb, bsaddress, &value)))
+ if (odberror (odbgetvalue (odbrec.odb, handleAddress, &value)))
return (false);
-
+
type = langexternalgetvaluetype (value.valuetype);
- if (type == (tyvaluetype) -1) {
-
+ if (type == (tyvaluetype) -1)
return (setbinaryvalue (value.data.binaryvalue, value.valuetype, vreturned));
- }
else {
-
+
initvalue (vreturned, type);
(*vreturned).data.binaryvalue = value.data.binaryvalue;
if (langheapallocated (vreturned, nil))
pushtmpstackvalue (vreturned); //5.0b17
-
+
return (true);
- /*
- initvalue (&val, type);
+ }
- val.data.binaryvalue = value.data.binaryvalue;
-
- return (copyvaluerecord (val, vreturned));
- */
- }
} /*dbgetvalueverb*/
static boolean dbsetvalueverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
+
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+ Handle handleAddress;
+ boolean flerror;
+ odbValueRecord value;
tyodbrecord odbrec;
- bigstring bsaddress;
- odbValueRecord value;
tyvaluerecord val;
- boolean flerror;
if (!getodbvalue (hparam1, 1, &odbrec, false))
return (false);
-
- if (!getstringvalue (hparam1, 2, bsaddress))
- return (false);
-
+
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
+ return ( false );
+
flnextparamislast = true;
if (!getparamvalue (hparam1, 3, &val))
return (false);
-
+
if (!copyvaluedata (&val))
return (false);
-
+
value.valuetype = (odbValueType) langexternalgettypeid (val);
/*
@@ -818,142 +873,182 @@
value.data.binaryvalue = val.data.binaryvalue; /*largest field covers everything*/
- flerror = odberror (odbsetvalue (odbrec.odb, bsaddress, &value));
+ flerror = odberror (odbsetvalue (odbrec.odb, handleAddress, &value));
disposevaluerecord (val, false);
if (flerror)
return (false);
-
+
return (setbooleanvalue (true, vreturned));
+
} /*dbsetvalueverb*/
static boolean dbdeleteverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+
+ Handle handleAddress;
tyodbrecord odbrec;
- bigstring bsaddress;
if (!getodbvalue (hparam1, 1, &odbrec, false))
return (false);
flnextparamislast = true;
- if (!getstringvalue (hparam1, 2, bsaddress))
- return (false);
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
+ return ( false );
- if (odberror (odbdelete (odbrec.odb, bsaddress)))
+ if (odberror (odbdelete (odbrec.odb, handleAddress)))
return (false);
+
+ return (setbooleanvalue (true, vreturned));
- return (setbooleanvalue (true, vreturned));
} /*dbdeleteverb*/
static boolean dbnewtableverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+
+ Handle handleAddress;
tyodbrecord odbrec;
- bigstring bsaddress;
if (!getodbvalue (hparam1, 1, &odbrec, false))
return (false);
flnextparamislast = true;
- if (!getstringvalue (hparam1, 2, bsaddress))
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
return (false);
-
- if (odberror (odbnewtable (odbrec.odb, bsaddress)))
+
+ if (odberror (odbnewtable (odbrec.odb, handleAddress)))
return (false);
-
+
return (setbooleanvalue (true, vreturned));
+
} /*dbnewtableverb*/
static boolean dbistableverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+
+ Handle handleAddress;
+ OSType odbtype;
tyodbrecord odbrec;
- bigstring bsaddress;
- OSType odbtype;
if (!getodbvalue (hparam1, 1, &odbrec, true))
return (false);
flnextparamislast = true;
- if (!getstringvalue (hparam1, 2, bsaddress))
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
return (false);
- if (odberror (odbgettype (odbrec.odb, bsaddress, &odbtype)))
+ if (odberror (odbgettype (odbrec.odb, handleAddress, &odbtype)))
return (false);
+
+ return (setbooleanvalue (odbtype == tableT, vreturned));
- return (setbooleanvalue (odbtype == tableT, vreturned));
} /*dbistableverb*/
static boolean dbcountitemsverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+
+ Handle handleAddress;
+ long ctitems;
tyodbrecord odbrec;
- bigstring bsaddress;
- long ctitems;
if (!getodbvalue (hparam1, 1, &odbrec, true))
return (false);
-
+
flnextparamislast = true;
- if (!getstringvalue (hparam1, 2, bsaddress))
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
return (false);
- if (odberror (odbcountitems (odbrec.odb, bsaddress, &ctitems)))
+ if (odberror (odbcountitems (odbrec.odb, handleAddress, &ctitems)))
return (false);
+
+ return (setlongvalue (ctitems, vreturned));
- return (setlongvalue (ctitems, vreturned));
} /*dbcountitemsverb*/
static boolean dbgetnthitemverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+
+ Handle handleAddress, handleName;
+ boolean fl;
+ long n;
tyodbrecord odbrec;
- bigstring bsaddress;
- bigstring bsname;
- long n;
if (!getodbvalue (hparam1, 1, &odbrec, true))
return (false);
- if (!getstringvalue (hparam1, 2, bsaddress))
- return (false);
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
+ return ( false );
flnextparamislast = true;
if (!getlongvalue (hparam1, 3, &n))
return (false);
+
+ if (odberror (odbgetnthitem (odbrec.odb, handleAddress, n, handleName))) {
- if (odberror (odbgetnthitem (odbrec.odb, bsaddress, n, bsname)))
+ disposehandle ( handleName );
+
return (false);
+
+ }
+
+ fl = newheapvalue ( *handleName, gethandlesize ( handleName ), stringvaluetype, vreturned );
+
+ disposehandle ( handleName );
- return (setstringvalue (bsname, vreturned));
+ return ( fl );
+
} /*dbgetnthitemverb*/
static boolean dbgetmoddateverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
+ //
+ // 2007-02-18 creedon: support for long odb item names and file paths
+ //
+
+ Handle handleAddress;
tyodbrecord odbrec;
- bigstring bsaddress;
unsigned long moddate;
if (!getodbvalue (hparam1, 1, &odbrec, true))
return (false);
-
+
flnextparamislast = true;
- if (!getstringvalue (hparam1, 2, bsaddress))
+ if ( ! getreadonlytextvalue ( hparam1, 2, &handleAddress ) )
+ return ( false );
+
+ if (odberror (odbgetmoddate (odbrec.odb, handleAddress, &moddate)))
return (false);
+
+ return (setdatevalue (moddate, vreturned));
- if (odberror (odbgetmoddate (odbrec.odb, bsaddress, &moddate)))
- return (false);
-
- return (setdatevalue (moddate, vreturned));
} /*dbgetmoddateverb*/
@@ -1015,6 +1110,7 @@
default:
return (false);
}
+
} /*dbfunctionvalue*/
@@ -1027,5 +1123,6 @@
return (false);
return (true);
+
} /*dbinitverbs*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|