db.h

Go to the documentation of this file.
00001 
00002 /*  $Id: db.h 355 2005-01-11 22:48:55Z andreradke $    */
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 
00030 #ifndef dbinclude /*so other includes can tell if we've been loaded*/
00031 #define dbinclude /*so other includes can tell if we've been loaded*/
00032 
00033 
00034 #ifdef HEADERTRACE
00035 #pragma message( "**Compiling " __FILE__ )
00036 #endif
00037 
00038 
00039 #ifndef memoryinclude
00040     #include "memory.h"
00041 #endif
00042 
00043 #define nildbaddress 0L
00044 
00045 
00046 #define ctviews 3 /*leave room for 3 different views in a database header*/
00047 #define cancoonview 0
00048 
00049 typedef long dbaddress, *ptrdbaddress, **hdldbaddress;
00050 
00051 
00052 typedef struct tydatabaserecord { /*stored at offset 0 in the db file*/
00053     
00054 
00055     unsigned char systemid;     /* 0 = MAC (compatiblity)  */
00056 
00057 
00058     unsigned char versionnumber; /*which version created this file?*/
00059     
00060     dbaddress availlist; /*avail list is singly-linked, nil terminated*/
00061     
00062     short oldfnumdatabase; /*only applies when database record is in memory*/
00063     
00064     short flags; /*any changes to header since it was last flushed?*/
00065     
00066     dbaddress views [ctviews]; /*addresses of the root of each view*/
00067     
00068     Handle releasestack; /*holds addresses of nodes waiting to be released*/
00069     
00070 
00071                         /* RAB 9/2/96 - fnumdatabase is delibritly declared
00072 
00073                         as a long not a hdlfilenum. This is to allow for a consistent header
00074 
00075                         size between Mac and Win platforms even though hdlfilenum is 
00076 
00077                         system dependent.
00078 
00079                         It has been moved to this position to allow view and fldirty
00080 
00081                         to remain the same as version 3 files.
00082 
00083                         */
00084 
00085     long fnumdatabase; /* file handle while in memory - New to version 5*/
00086 
00087     long headerLength;      /*size of header - New to version 5*/
00088 
00089     short longversionMajor; /*new extended version id - new to version 5*/
00090 
00091     short longversionMinor; /*new extended version id - new to version 5*/
00092     
00093     union {
00094         char growthspace [50]; /*room for new fields without format change*/
00095         
00096         struct {
00097             dbaddress availlistblock; /*6.2a9 AR: on-disk structure mirroring availlist, a contiguous block*/
00098             
00099             handlestream availlistshadow; /*never saved to disk; in-memory structure mirroring availlist*/
00100 
00101             boolean flreadonly; /*6.2a9 AR: never saved to disk; if this is true, don't write to the file*/
00102             } extensions;
00103         } u;
00104     } tydatabaserecord, *ptrdatabaserecord, **hdldatabaserecord;
00105     
00106     
00107 extern hdldatabaserecord databasedata; /*can be set by external user*/
00108 
00109 extern boolean fldatabasesaveas;
00110 
00111 
00112 #ifdef DATABASE_DEBUG
00113 
00114 typedef struct {
00115     dbaddress   adr;
00116     long        id;
00117     long        line;
00118     Handle      file;
00119     } tydbreleasestackframe;
00120 
00121 #define dbpushreleasestack(adr, valtype) \
00122     debug_dbpushreleasestack(adr, valtype, __LINE__, __FILE__);
00123 
00124 extern boolean debug_dbpushreleasestack (dbaddress adr, long valtype, long line, char *sourcefile);
00125 
00126 #else
00127 
00128 extern boolean dbpushreleasestack (dbaddress, long);
00129 
00130 #endif
00131 
00132 /*prototypes*/
00133 
00134 extern boolean dbpushdatabase (hdldatabaserecord);
00135 
00136 extern boolean dbpopdatabase (void);
00137 
00138 extern boolean dbreference (dbaddress, long, ptrvoid);
00139 
00140 extern boolean dbrefhandle (dbaddress, Handle *);
00141 
00142 extern boolean dbassign (dbaddress *, long, ptrvoid);
00143 
00144 extern boolean dbcopy (dbaddress, dbaddress *);
00145 
00146 extern boolean dballochandle (Handle, dbaddress *);
00147 
00148 extern boolean dbassignhandle (Handle, dbaddress *);
00149 
00150 extern boolean dbsavehandle (Handle, dbaddress *);
00151 
00152 extern boolean dbrefheapstring (dbaddress, hdlstring *);
00153 
00154 extern boolean dbassignheapstring (dbaddress *, hdlstring);
00155 
00156 extern void dbsetview (short, dbaddress);
00157 
00158 extern void dbgetview (short, dbaddress *);
00159 
00160 extern void dbcurrentdatabase (hdldatabaserecord);
00161 
00162 extern void dbgetcurrentdatabase (hdldatabaserecord *);
00163 
00164 extern boolean dbflushreleasestack (void);
00165 
00166 extern boolean dbfnumchanged (hdlfilenum);
00167 
00168 extern boolean dbdispose (void);
00169 
00170 extern boolean dbnew (hdlfilenum);
00171 
00172 extern boolean dbopenfile (hdlfilenum, boolean);
00173 
00174 extern boolean dbclose (void);
00175 
00176 extern boolean dbstartsaveas (hdlfilenum);
00177 
00178 extern boolean dbendsaveas (void);
00179 
00180 extern boolean statsblockinuse (dbaddress, bigstring); /*dbstats.c*/
00181 
00182 extern boolean dbstatsmessage (hdldatabaserecord, boolean); /*6.2a8 AR*/
00183 
00184 extern boolean statsstart (void);
00185 
00186 #endif
00187 
00188 
00189 

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