config.c

Go to the documentation of this file.
00001 
00002 /*  $Id: config.c 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 #ifdef MACVERSION
00029 #include <standard.h>
00030 #endif
00031 
00032 #ifdef WIN95VERSION
00033 #include "standard.h"
00034 #endif
00035 
00036 #include "memory.h"
00037 #include "quickdraw.h"
00038 #include "font.h"
00039 #include "resources.h"
00040 #include "strings.h"
00041 #include "dialogs.h"
00042 #include "shell.rsrc.h"
00043 #include "config.h"
00044 #include "shell.h"
00045 
00046 
00047 #ifdef MACVERSION
00048 #define configresourcetype 'cnfg'
00049 #endif
00050 
00051 #ifdef WIN95VERSION
00052 //#define configresourcetype 1000
00053 #define configresourcetype 'cnfg'
00054 #endif
00055 
00056 tyconfigrecord config;
00057 
00058 short iddefaultconfig = idtableconfig;
00059 
00060 
00061 
00062 
00063 static void initconfigrecord (tyconfigrecord *configrecord) {
00064     
00065     register ptrconfigrecord p = configrecord;
00066     
00067     clearbytes (p, longsizeof (tyconfigrecord)); /*initalize all fields to 0*/
00068     
00069     (*p).flhorizscroll = true;
00070     
00071     (*p).flvertscroll = true;
00072     
00073     (*p).flmessagearea = true;
00074     
00075     (*p).flgrowable = true;
00076     
00077     (*p).messageareafraction = 3;
00078     
00079     (*p).filecreator = typeunknown;
00080     
00081     (*p).filetype = typeunknown;
00082 
00083 #ifdef MACVERSION
00084     (*p).defaultfont = systemFont;
00085 #endif
00086 #ifdef WIN95VERSION
00087     (*p).defaultfont = 0;
00088 #endif
00089 
00090     (*p).defaultsize = 12;
00091     } /*initconfigrecord*/
00092 
00093 
00094 void loadconfigresource (short configresnum, tyconfigrecord *cr) {
00095     
00096     /*
00097     2.1b5 dmb: release the config resource when done with it
00098     */
00099     
00100     register Handle h;
00101     bigstring bs;
00102     
00103     h = getresourcehandle (configresourcetype, configresnum);
00104 
00105     if (h != nil) {
00106     
00107         moveleft (*h, cr, sizeof (tyconfigrecord)); 
00108         
00109         getstringlist (fontnamelistnumber, (*cr).defaultfont, bs);
00110         
00111         fontgetnumber (bs, &(*cr).defaultfont);
00112         
00113         centerrectondesktop (&(*cr).defaultwindowrect);
00114     
00115         releaseresourcehandle (h);
00116         }
00117     else
00118         initconfigrecord (cr);
00119     } /*loadconfigresource*/
00120     
00121     
00122 /*
00123 boolean saveconfigresource (short configresnum, tyconfigrecord *cr) {
00124 
00125     Handle h;
00126     
00127     h = GetResource (configresourcetype, configresnum);
00128     
00129     if (h != nil) { /%resource already exists%/
00130     
00131         moveleft ((ptrchar) cr, (ptrchar) *h, longsizeof (tyconfigrecord)); 
00132         
00133         ChangedResource (h);
00134         }
00135     else {
00136         if (!newfilledhandle ((ptrchar) cr, longsizeof (tyconfigrecord), &h)) 
00137             return (false);
00138         
00139         AddResource (h, configresourcetype, configresnum, emptystring);
00140         }
00141         
00142     return (ResError () == noErr);
00143     } /%saveconfigresource*/
00144     
00145     
00146 boolean getprogramname (bigstring bs) {
00147     
00148     return (getstringlist (defaultlistnumber, programname, bs));
00149     } /*getprogramname*/
00150     
00151     
00152 boolean getuntitledfilename (bigstring bs) {
00153     
00154     /*
00155     5.0d6 dmb: added numeric sequencing
00156     */
00157     
00158     static long untitledsequencer = 0;
00159     
00160     if (!getstringlist (defaultlistnumber, untitledfilename, bs))
00161         return (false);
00162     
00163     if (++untitledsequencer > 1) {
00164     
00165         pushchar ('-', bs);
00166         
00167         pushlong (untitledsequencer, bs);
00168         }
00169     
00170     return (true);
00171     } /*getuntitledfilename*/
00172     
00173     
00174 boolean getdefaultfilename (bigstring bs) {
00175     
00176     return (getstringlist (defaultlistnumber, defaultfilename, bs));
00177     } /*getdefaultfilename*/
00178     
00179 /*
00180 boolean getusername (bigstring bs) {
00181     
00182     return (getstringlist (defaultlistnumber, username, bs));
00183     } /%getusername*/
00184     
00185     
00186 void initconfig (void) {
00187     
00188     initconfigrecord (&config);
00189     } /*initconfig*/
00190     
00191     
00192     

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