dbverbs.c

Go to the documentation of this file.
00001 
00002 /*  $Id: dbverbs.c 1200 2006-04-05 22:19:55Z karstenw $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 /*
00029     4.1b4 dmb: new verbs based on ODB Engine API
00030 */
00031 
00032 #include "frontier.h"
00033 #include "standard.h"
00034 
00035 #ifdef MACVERSION
00036 #include <land.h>
00037 #include "mac.h"
00038 #endif
00039 
00040 #include "ops.h"
00041 #include "memory.h"
00042 #include "error.h"
00043 #include "file.h"
00044 #include "resources.h"
00045 #include "scrap.h"
00046 #include "strings.h"
00047 #include "launch.h"
00048 #include "notify.h"
00049 #include "shell.h"
00050 #include "lang.h"
00051 #include "langexternal.h"
00052 #include "langinternal.h"
00053 #include "langipc.h"
00054 #include "kernelverbs.h"
00055 #include "kernelverbdefs.h"
00056 #include "tablestructure.h"
00057 #include "process.h"
00058 #include "processinternal.h"
00059 #include "odbinternal.h"
00060 
00061 /*
00062 if we're generating cfm (powerpc), we're linking to an odb engine shared 
00063 library, which has it's own globals. on 68k machines, we're staically linked,
00064 so the odb calls mess with out global data. so we need to protect it.
00065 */
00066 
00067 #ifdef usingsharedlibrary
00068 
00069     #define odbnewfile      odbNewFile
00070     #define odbopenfile     odbOpenFile
00071     #define odbsavefile     odbSaveFile
00072     #define odbclosefile    odbCloseFile
00073     #define odbdefined      odbDefined
00074     #define odbdelete       odbDelete
00075     #define odbgettype      odbGetType
00076     #define odbgetvalue     odbGetValue
00077     #define odbsetvalue     odbSetValue
00078     #define odbnewtable     odbNewTable
00079     #define odbcountitems   odbCountItems
00080     #define odbgetnthitem   odbGetNthItem
00081     #define odbgetmoddate   odbGetModDate
00082     #define odbdisposevalue odbDisposeValue
00083     #define odbgeterror     odbGetError
00084 
00085 #else
00086 
00087     /*Prototypes*/
00088 
00089     boolean odbnewfile (hdlfilenum fnum);
00090     
00091     boolean odbaccesswindow (WindowPtr w, odbref *odb);
00092     
00093     boolean odbopenfile (hdlfilenum fnum, odbref *odb, boolean flreadonly);
00094     
00095     boolean odbsavefile (odbref odb);
00096     
00097     boolean odbclosefile (odbref odb);
00098     
00099     boolean odbdefined (odbref odb, bigstring bspath);
00100     
00101     boolean odbdelete (odbref odb, bigstring bspath);
00102     
00103     boolean odbgettype (odbref odb, bigstring bspath, OSType *odbType);
00104     
00105     boolean odbgetvalue (odbref odb, bigstring bspath, odbValueRecord *value);
00106     
00107     boolean odbsetvalue (odbref odb, bigstring bspath, odbValueRecord *value);
00108     
00109     boolean odbnewtable (odbref odb, bigstring bspath);
00110     
00111     boolean odbcountitems (odbref odb, bigstring bspath, long *count);
00112     
00113     boolean odbgetnthitem (odbref odb, bigstring bspath, long n, bigstring bsname);
00114     
00115     boolean odbgetmoddate (odbref odb, bigstring bspath, unsigned long *date);
00116     
00117     boolean odbdisposevalue (odbref odb, odbValueRecord *value);
00118     
00119     
00120     /*Functions*/
00121     
00122     boolean odbnewfile (hdlfilenum fnum) {
00123 
00124         boolean fl;
00125         hdlthreadglobals htg = getcurrentthreadglobals ();
00126         
00127         copythreadglobals (htg);
00128         
00129         swapinthreadglobals (nil);
00130         
00131         fl = odbNewFile (fnum);
00132         
00133         cancoonglobals = nil;
00134         
00135         swapinthreadglobals (htg);
00136         
00137         return (fl);
00138         }
00139 
00140     boolean odbaccesswindow (WindowPtr w, odbref *odb) {
00141 
00142         boolean fl;
00143         hdlthreadglobals htg = getcurrentthreadglobals ();
00144         
00145         copythreadglobals (htg);
00146         
00147         swapinthreadglobals (nil);
00148         
00149         fl = odbAccessWindow (w, odb);
00150         
00151         cancoonglobals = nil;
00152         
00153         swapinthreadglobals (htg);
00154         
00155         return (fl);
00156         }
00157 
00158     boolean odbopenfile (hdlfilenum fnum, odbref *odb, boolean flreadonly) {
00159 
00160         boolean fl;
00161         hdlthreadglobals htg = getcurrentthreadglobals ();
00162         
00163         copythreadglobals (htg);
00164         
00165         swapinthreadglobals (nil);
00166         
00167         fl = odbOpenFile (fnum, odb, flreadonly);
00168         
00169         cancoonglobals = nil;
00170         
00171         swapinthreadglobals (htg);
00172         
00173         return (fl);
00174         }
00175 
00176     boolean odbsavefile (odbref odb) {
00177 
00178         boolean fl;
00179         hdlthreadglobals htg = getcurrentthreadglobals ();
00180         
00181         copythreadglobals (htg);
00182         
00183         swapinthreadglobals (nil);
00184         
00185         fl = odbSaveFile (odb);
00186         
00187         cancoonglobals = nil;
00188         
00189         swapinthreadglobals (htg);
00190         
00191         return (fl);
00192         }
00193 
00194     boolean odbclosefile (odbref odb) {
00195 
00196         boolean fl;
00197         hdlthreadglobals htg = getcurrentthreadglobals ();
00198         
00199         copythreadglobals (htg);
00200         
00201         swapinthreadglobals (nil);
00202         
00203         fl = odbCloseFile (odb);
00204         
00205         cancoonglobals = nil;
00206         
00207         swapinthreadglobals (htg);
00208         
00209         return (fl);
00210         }
00211 
00212     boolean odbdefined (odbref odb, bigstring bspath) {
00213 
00214         boolean fl;
00215         hdlthreadglobals htg = getcurrentthreadglobals ();
00216         
00217         copythreadglobals (htg);
00218         
00219         swapinthreadglobals (nil);
00220         
00221         fl = odbDefined (odb, bspath);
00222                 
00223         cancoonglobals = nil;
00224         
00225         swapinthreadglobals (htg);
00226         
00227         return (fl);
00228         }
00229 
00230     boolean odbdelete (odbref odb, bigstring bspath) {
00231 
00232         boolean fl;
00233         hdlthreadglobals htg = getcurrentthreadglobals ();
00234         
00235         copythreadglobals (htg);
00236         
00237         swapinthreadglobals (nil);
00238         
00239         fl = odbDelete (odb, bspath);
00240                 
00241         cancoonglobals = nil;
00242         
00243         swapinthreadglobals (htg);
00244         
00245         return (fl);
00246         }
00247 
00248     boolean odbgettype (odbref odb, bigstring bspath, OSType *odbType) {
00249 
00250         boolean fl;
00251         hdlthreadglobals htg = getcurrentthreadglobals ();
00252         
00253         copythreadglobals (htg);
00254         
00255         swapinthreadglobals (nil);
00256         
00257         fl = odbGetType (odb, bspath, odbType);
00258                 
00259         cancoonglobals = nil;
00260         
00261         swapinthreadglobals (htg);
00262         
00263         return (fl);
00264         }
00265 
00266     boolean odbgetvalue (odbref odb, bigstring bspath, odbValueRecord *value) {
00267 
00268         boolean fl;
00269         hdlthreadglobals htg = getcurrentthreadglobals ();
00270         
00271         copythreadglobals (htg);
00272         
00273         swapinthreadglobals (nil);
00274         
00275         fl = odbGetValue (odb, bspath, value);
00276                 
00277         cancoonglobals = nil;
00278         
00279         swapinthreadglobals (htg);
00280         
00281         return (fl);
00282         }
00283 
00284     boolean odbsetvalue (odbref odb, bigstring bspath, odbValueRecord *value) {
00285 
00286         boolean fl;
00287         hdlthreadglobals htg = getcurrentthreadglobals ();
00288         
00289         copythreadglobals (htg);
00290         
00291         swapinthreadglobals (nil);
00292         
00293         fl = odbSetValue (odb, bspath, value);
00294                 
00295         cancoonglobals = nil;
00296         
00297         swapinthreadglobals (htg);
00298         
00299         return (fl);
00300         }
00301 
00302     boolean odbnewtable (odbref odb, bigstring bspath) {
00303 
00304         boolean fl;
00305         hdlthreadglobals htg = getcurrentthreadglobals ();
00306         
00307         copythreadglobals (htg);
00308         
00309         swapinthreadglobals (nil);
00310         
00311         fl = odbNewTable (odb, bspath);
00312                 
00313         cancoonglobals = nil;
00314         
00315         swapinthreadglobals (htg);
00316         
00317         return (fl);
00318         }
00319 
00320     boolean odbcountitems (odbref odb, bigstring bspath, long *count) {
00321 
00322         boolean fl;
00323         hdlthreadglobals htg = getcurrentthreadglobals ();
00324         
00325         copythreadglobals (htg);
00326         
00327         swapinthreadglobals (nil);
00328         
00329         fl = odbCountItems (odb, bspath, count);
00330                 
00331         cancoonglobals = nil;
00332         
00333         swapinthreadglobals (htg);
00334         
00335         return (fl);
00336         }
00337 
00338     boolean odbgetnthitem (odbref odb, bigstring bspath, long n, bigstring bsname) {
00339 
00340         boolean fl;
00341         hdlthreadglobals htg = getcurrentthreadglobals ();
00342         
00343         copythreadglobals (htg);
00344         
00345         swapinthreadglobals (nil);
00346         
00347         fl = odbGetNthItem (odb, bspath, n, bsname);
00348                 
00349         cancoonglobals = nil;
00350         
00351         swapinthreadglobals (htg);
00352         
00353         return (fl);
00354         }
00355 
00356     boolean odbgetmoddate (odbref odb, bigstring bspath, unsigned long *date) {
00357 
00358         boolean fl;
00359         hdlthreadglobals htg = getcurrentthreadglobals ();
00360         
00361         copythreadglobals (htg);
00362         
00363         swapinthreadglobals (nil);
00364         
00365         fl = odbGetModDate (odb, bspath, date);
00366                 
00367         cancoonglobals = nil;
00368         
00369         swapinthreadglobals (htg);
00370         
00371         return (fl);
00372         }
00373 
00374     boolean odbdisposevalue (odbref odb, odbValueRecord *value) {
00375 
00376         hdlthreadglobals htg = getcurrentthreadglobals ();
00377         
00378         copythreadglobals (htg);
00379         
00380         swapinthreadglobals (nil);
00381         
00382         odbDisposeValue (odb, value);
00383                 
00384         cancoonglobals = nil;
00385         
00386         swapinthreadglobals (htg);
00387         
00388         return (true);
00389         }
00390 
00391     #define odbgeterror     odbGetError
00392 
00393 #endif
00394 
00395 
00396 typedef struct tyodblistrecord {
00397     
00398     struct tyodblistrecord **hnext;
00399     
00400     tyfilespec fs;
00401     
00402     hdlfilenum fref;
00403     
00404     boolean flreadonly;
00405     
00406     odbref odb;
00407     } tyodbrecord, *ptrodbrecord, **hdlodbrecord;
00408 
00409 
00410 static hdlodbrecord hodblist = nil;
00411 
00412 
00413 typedef enum tydbtoken { /*verbs that are processed by db*/
00414     
00415     newfunc,
00416     
00417     openfunc,
00418     
00419     savefunc,
00420     
00421     closefunc,
00422     
00423     definedfunc,
00424     
00425     /*
00426     gettypefunc,
00427     */
00428     
00429     getvaluefunc,
00430     
00431     setvaluefunc,
00432     
00433     deletefunc,
00434     
00435     newtablefunc,
00436     
00437     istablefunc,
00438     
00439     countitemsfunc,
00440     
00441     getnthitemfunc,
00442     
00443     getmoddatefunc,
00444     
00445     ctdbverbs
00446     } tydbtoken;
00447 
00448 
00449 static boolean odberror (boolean flresult) {
00450     
00451     bigstring bserror;
00452     
00453     if (flresult)
00454         return (false);
00455     
00456     odbgeterror (bserror);
00457     
00458     langerrormessage (bserror);
00459     
00460     return (true);
00461     } /*odberror*/
00462 
00463     
00464 static boolean getodbparam (hdltreenode hparam1, short pnum, hdlodbrecord *hodbrecord) {
00465 
00466     hdlodbrecord hodb;
00467     tyfilespec fs;
00468     tyfilespec * ptrfs;
00469     
00470     ptrfs = &fs; 
00471 
00472     if (!getfilespecvalue (hparam1, pnum, ptrfs))
00473         return (false);
00474     
00475     for (hodb = hodblist; hodb != nil; hodb = (**hodb).hnext) {
00476         
00477         if (equalfilespecs (&(**hodb).fs, ptrfs)) {
00478             
00479             *hodbrecord = hodb;
00480             
00481             return (true);
00482             }
00483         }
00484     
00485     lang2paramerror (dbnotopenederror, bsfunctionname, fsname(ptrfs));
00486     
00487     return (false);
00488     } /*getodbparam*/
00489 
00490 
00491 static boolean getodbvalue (hdltreenode hparam1, short pnum, tyodbrecord *odb, boolean flreadonly) {
00492 
00493     hdlodbrecord hodb;
00494     
00495     if (!getodbparam (hparam1, pnum, &hodb))
00496         return (false);
00497     
00498     *odb = **hodb;
00499     
00500     if ((*odb).flreadonly && !flreadonly) {
00501         
00502         lang2paramerror (dbopenedreadonlyerror, bsfunctionname, fsname(&(*odb).fs));
00503         
00504         return (false);
00505         }
00506     
00507     return (true);
00508     } /*getodbvalue*/
00509 
00510 
00511 static boolean dbclosefile (hdlodbrecord hodb) {
00512     
00513     if (!odbclosefile ((**hodb).odb))
00514         return (false);
00515     
00516     closefile ((**hodb).fref);
00517     
00518     listunlink ((hdllinkedlist) hodblist, (hdllinkedlist) hodb);
00519     
00520     disposehandle ((Handle) hodb);
00521     
00522     return (true);
00523     } /*dbclosefile*/
00524 
00525 
00526 boolean dbcloseallfiles (long refcon) {
00527 #pragma unused (refcon)
00528 
00529     return (true);
00530     } /*dbcloseallfiles*/
00531 
00532 
00533 #if 0
00534 
00535 static ptrfilespec fsfind;
00536 
00537 static WindowPtr wfound;
00538 
00539 static boolean odbfindfilevisit (WindowPtr w) {
00540     
00541     /*
00542     if the filespec for the given window is the one we're looking for, 
00543     select that window and stop visiting
00544     */
00545     
00546     tyfilespec fs;
00547     
00548     windowgetfspec (w, &fs);
00549     
00550     if (equalfilespecs (fsfind, &fs)) {
00551         
00552         wfound = w;
00553         
00554         return (false);
00555         }
00556     
00557     return (true);
00558     } /*odbfindfilevisit*/
00559 
00560 #endif
00561 
00562 
00563 static boolean dbnewverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00564     
00565     /*
00566     4.1b5 dmb: new verb
00567     */
00568     
00569     tyodbrecord odbrec;
00570     boolean fl;
00571     
00572     flnextparamislast = true;
00573     
00574     if (!getfilespecvalue (hparam1, 1, &odbrec.fs))
00575         return (false);
00576     
00577     shellpushdefaultglobals (); /*so that config is correct*/
00578     
00579     fl = opennewfile (&odbrec.fs, config.filecreator, config.filetype, &odbrec.fref);
00580     
00581     shellpopglobals ();
00582     
00583     if (!fl)
00584         return (false);
00585     
00586     fl = odbnewfile (odbrec.fref);
00587     
00588     closefile (odbrec.fref);
00589     
00590     if (odberror (fl)) {
00591         
00592         deletefile (&odbrec.fs);
00593         
00594         return (false);
00595         }
00596     
00597     return (setbooleanvalue (true, vreturned));
00598     } /*dbnewverb*/
00599 
00600 
00601 static boolean dbopenverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00602     
00603     /*
00604     4.1b5 dmb: added ability to access already-open root in Frontier
00605     */
00606     
00607     tyodbrecord odbrec;
00608     hdlodbrecord hodb;
00609     WindowPtr w;
00610     
00611     odbrec.fref = 0;
00612     
00613     if (!getfilespecvalue (hparam1, 1, &odbrec.fs))
00614         return (false);
00615     
00616     flnextparamislast = true;
00617     
00618     if (!getbooleanvalue (hparam1, 2, &odbrec.flreadonly))
00619         return (false);
00620     
00621     w = shellfindfilewindow (&odbrec.fs);
00622     
00623     if (w != nil) {
00624         
00625         if (odberror (odbaccesswindow (w, &odbrec.odb)))
00626             return (false);
00627         
00628         /*fref remains zero, so unwanted closefiles aren't a problem*/
00629         }
00630     else {
00631         
00632         if (!openfile (&odbrec.fs, &odbrec.fref, odbrec.flreadonly))
00633             return (false);
00634         
00635         if (odberror (odbopenfile (odbrec.fref, &odbrec.odb, odbrec.flreadonly))) {
00636             
00637             closefile (odbrec.fref);
00638             
00639             return (false);
00640             }
00641         }
00642     
00643     if (!newfilledhandle (&odbrec, sizeof (odbrec), (Handle *) &hodb)) {
00644         
00645         odbclosefile (odbrec.odb);
00646         
00647         closefile (odbrec.fref);
00648         
00649         return (false);
00650         }
00651     
00652     listlink ((hdllinkedlist) hodblist, (hdllinkedlist) hodb);
00653     
00654     return (setbooleanvalue (true, vreturned));
00655     } /*dbopenverb*/
00656 
00657 
00658 static boolean dbsaveverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00659 
00660     tyodbrecord odbrec;
00661     
00662     flnextparamislast = true;
00663     
00664     if (!getodbvalue (hparam1, 1, &odbrec, false))
00665         return (false);
00666     
00667     return (setbooleanvalue (odbsavefile (odbrec.odb), vreturned));
00668     } /*dbsaveverb*/
00669 
00670 
00671 static boolean dbcloseverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00672 
00673     hdlodbrecord hodb;
00674     
00675     flnextparamislast = true;
00676     
00677     if (!getodbparam (hparam1, 1, &hodb))
00678         return (false);
00679     
00680     return (setbooleanvalue (dbclosefile (hodb), vreturned));
00681     } /*dbcloseverb*/
00682 
00683 
00684 static boolean dbdefinedverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00685 
00686     /*
00687     4.1b5 dmb: new verb
00688     */
00689     
00690     tyodbrecord odbrec;
00691     bigstring bsaddress;
00692     boolean fl;
00693     
00694     if (!getodbvalue (hparam1, 1, &odbrec, true))
00695         return (false);
00696     
00697     flnextparamislast = true;
00698     
00699     if (!getstringvalue (hparam1, 2, bsaddress))
00700         return (false);
00701     
00702     fl = odbdefined (odbrec.odb, bsaddress);
00703     
00704     return (setbooleanvalue (fl, vreturned));
00705     } /*dbdefinedverb*/
00706 
00707 
00708 static boolean dbgetvalueverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00709 
00710     /*
00711     4.1.1b1 dmb: fixed memory leak; push value on temp stack
00712     
00713     5.0b17 dmb: use pushtmpstackvalue to put external types returned from 
00714     the other odb onto our temp stack
00715 
00716     5.0.1 dmb: but only pushtmpstack if heapallocated
00717     */
00718     
00719     tyodbrecord odbrec;
00720     bigstring bsaddress;
00721     odbValueRecord value;
00722     tyvaluetype type;
00723     
00724     if (!getodbvalue (hparam1, 1, &odbrec, true))
00725         return (false);
00726     
00727     flnextparamislast = true;
00728     
00729     if (!getstringvalue (hparam1, 2, bsaddress))
00730         return (false);
00731     
00732     if (odberror (odbgetvalue (odbrec.odb, bsaddress, &value)))
00733         return (false);
00734     
00735     type = langexternalgetvaluetype (value.valuetype);
00736     
00737     if (type == (tyvaluetype) -1) {
00738     
00739         return (setbinaryvalue (value.data.binaryvalue, value.valuetype, vreturned));
00740         }
00741     else {
00742         
00743         initvalue (vreturned, type);
00744         
00745         (*vreturned).data.binaryvalue = value.data.binaryvalue;
00746         
00747         if (langheapallocated (vreturned, nil))
00748             pushtmpstackvalue (vreturned); //5.0b17
00749         
00750         return (true);
00751         
00752         /*
00753         initvalue (&val, type);
00754         
00755         val.data.binaryvalue = value.data.binaryvalue;
00756         
00757         return (copyvaluerecord (val, vreturned));
00758         */
00759         }
00760     } /*dbgetvalueverb*/
00761 
00762 
00763 static boolean dbsetvalueverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00764     
00765     tyodbrecord odbrec;
00766     bigstring bsaddress;
00767     odbValueRecord value;
00768     tyvaluerecord val;
00769     boolean flerror;
00770     
00771     if (!getodbvalue (hparam1, 1, &odbrec, false))
00772         return (false);
00773     
00774     if (!getstringvalue (hparam1, 2, bsaddress))
00775         return (false);
00776     
00777     flnextparamislast = true;
00778     
00779     if (!getparamvalue (hparam1, 3, &val))
00780         return (false);
00781     
00782     if (!copyvaluedata (&val))
00783         return (false);
00784     
00785     value.valuetype = (odbValueType) langexternalgettypeid (val);
00786     
00787     /*
00788     if (val.valuetype == binaryvaluetype)
00789         pullfromhandle (val.data.binaryvalue, 0L, sizeof (value.valuetype), &value.valuetype);
00790     */
00791     
00792     value.data.binaryvalue = val.data.binaryvalue; /*largest field covers everything*/
00793     
00794     flerror = odberror (odbsetvalue (odbrec.odb, bsaddress, &value));
00795     
00796     disposevaluerecord (val, false);
00797     
00798     if (flerror)
00799         return (false);
00800 
00801     return (setbooleanvalue (true, vreturned));
00802     } /*dbsetvalueverb*/
00803 
00804 
00805 static boolean dbdeleteverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00806 
00807     tyodbrecord odbrec;
00808     bigstring bsaddress;
00809     
00810     if (!getodbvalue (hparam1, 1, &odbrec, false))
00811         return (false);
00812     
00813     flnextparamislast = true;
00814     
00815     if (!getstringvalue (hparam1, 2, bsaddress))
00816         return (false);
00817     
00818     if (odberror (odbdelete (odbrec.odb, bsaddress)))
00819         return (false);
00820     
00821     return (setbooleanvalue (true, vreturned));
00822     } /*dbdeleteverb*/
00823 
00824 
00825 static boolean dbnewtableverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00826 
00827     tyodbrecord odbrec;
00828     bigstring bsaddress;
00829     
00830     if (!getodbvalue (hparam1, 1, &odbrec, false))
00831         return (false);
00832     
00833     flnextparamislast = true;
00834     
00835     if (!getstringvalue (hparam1, 2, bsaddress))
00836         return (false);
00837     
00838     if (odberror (odbnewtable (odbrec.odb, bsaddress)))
00839         return (false);
00840 
00841     return (setbooleanvalue (true, vreturned));
00842     } /*dbnewtableverb*/
00843 
00844 
00845 static boolean dbistableverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00846 
00847     tyodbrecord odbrec;
00848     bigstring bsaddress;
00849     OSType odbtype;
00850     
00851     if (!getodbvalue (hparam1, 1, &odbrec, true))
00852         return (false);
00853     
00854     flnextparamislast = true;
00855     
00856     if (!getstringvalue (hparam1, 2, bsaddress))
00857         return (false);
00858     
00859     if (odberror (odbgettype (odbrec.odb, bsaddress, &odbtype)))
00860         return (false);
00861     
00862     return (setbooleanvalue (odbtype == tableT, vreturned));
00863     } /*dbistableverb*/
00864 
00865 
00866 static boolean dbcountitemsverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00867 
00868     tyodbrecord odbrec;
00869     bigstring bsaddress;
00870     long ctitems;
00871     
00872     if (!getodbvalue (hparam1, 1, &odbrec, true))
00873         return (false);
00874     
00875     flnextparamislast = true;
00876     
00877     if (!getstringvalue (hparam1, 2, bsaddress))
00878         return (false);
00879     
00880     if (odberror (odbcountitems (odbrec.odb, bsaddress, &ctitems)))
00881         return (false);
00882     
00883     return (setlongvalue (ctitems, vreturned));
00884     } /*dbcountitemsverb*/
00885 
00886 
00887 static boolean dbgetnthitemverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00888 
00889     tyodbrecord odbrec;
00890     bigstring bsaddress;
00891     bigstring bsname;
00892     long n;
00893     
00894     if (!getodbvalue (hparam1, 1, &odbrec, true))
00895         return (false);
00896     
00897     if (!getstringvalue (hparam1, 2, bsaddress))
00898         return (false);
00899     
00900     flnextparamislast = true;
00901     
00902     if (!getlongvalue (hparam1, 3, &n))
00903         return (false);
00904     
00905     if (odberror (odbgetnthitem (odbrec.odb, bsaddress, n, bsname)))
00906         return (false);
00907     
00908     return (setstringvalue (bsname, vreturned));
00909     } /*dbgetnthitemverb*/
00910 
00911 
00912 static boolean dbgetmoddateverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00913 
00914     tyodbrecord odbrec;
00915     bigstring bsaddress;
00916     unsigned long moddate;
00917     
00918     if (!getodbvalue (hparam1, 1, &odbrec, true))
00919         return (false);
00920     
00921     flnextparamislast = true;
00922     
00923     if (!getstringvalue (hparam1, 2, bsaddress))
00924         return (false);
00925     
00926     if (odberror (odbgetmoddate (odbrec.odb, bsaddress, &moddate)))
00927         return (false);
00928     
00929     return (setdatevalue (moddate, vreturned));
00930     } /*dbgetmoddateverb*/
00931 
00932 
00933 static boolean dbfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
00934 #pragma unused (bserror)
00935 
00936     /*
00937     4.1b4 dmb: new verb set based on odbEngine
00938     
00939     5.0b17 dmb: use swapinthreadglobals (nil) for all our odb calls to protect ours
00940     */
00941     
00942     register hdltreenode hp1 = hparam1;
00943     register tyvaluerecord *v = vreturned;
00944     
00945     setbooleanvalue (false, v); /*assume the worst*/
00946     
00947     switch (token) {
00948         
00949         case newfunc:
00950             return (dbnewverb (hp1, v));
00951         
00952         case openfunc:
00953             return (dbopenverb (hp1, v));
00954         
00955         case savefunc:
00956             return (dbsaveverb (hp1, v));
00957         
00958         case closefunc:
00959             return (dbcloseverb (hp1, v));
00960         
00961         case definedfunc:
00962             return (dbdefinedverb (hp1, v));
00963         
00964         case getvaluefunc:
00965             return (dbgetvalueverb (hp1, v));
00966         
00967         case setvaluefunc:
00968             return (dbsetvalueverb (hp1, v));
00969         
00970         case deletefunc:
00971             return (dbdeleteverb (hp1, v));
00972         
00973         case newtablefunc:
00974             return (dbnewtableverb (hp1, v));
00975         
00976         case istablefunc:
00977             return (dbistableverb (hp1, v));
00978         
00979         case countitemsfunc:
00980             return (dbcountitemsverb (hp1, v));
00981         
00982         case getnthitemfunc:
00983             return (dbgetnthitemverb (hp1, v));
00984         
00985         case getmoddatefunc:
00986             return (dbgetmoddateverb (hp1, v));
00987         
00988         default:
00989             return (false);
00990         }
00991     } /*dbfunctionvalue*/
00992 
00993 
00994 boolean dbinitverbs (void) {
00995     
00996     if (!loadfunctionprocessor (iddbverbs, &dbfunctionvalue))
00997         return (false);
00998     
00999     if (!newclearhandle (sizeof (tyodbrecord), (Handle *) &hodblist))
01000         return (false);
01001     
01002     return (true);
01003     } /*dbinitverbs*/
01004 
01005 
01006 
01007 

Generated on Wed May 31 18:19:46 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6