00001 /********************************************************************** 00002 * Copyright 2002 Jeff Rush <jrush@taupro.com> 00003 * Original Copyright 1979-2002 Udanax.com 00004 * 00005 * This file is part of the Udanax xanalogical storage system. 00006 * 00007 * Udanax is free software; you can redistribute it and/or modify it 00008 * under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * Udanax is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with Udanax; if not, write to the Free Software Foundation, 00019 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 **********************************************************************/ 00021 00030 /* Modification History: 00031 * $Log: rcfile.cxx,v $ 00032 * Revision 1.8 2004/09/11 13:59:21 jrush 00033 * Changed all fprintf's to stderr to use the Nana library L() macro. Also 00034 * removed a 2-3 minor compiler warnings. 00035 * 00036 * Revision 1.7 2004/09/04 16:02:18 jrush 00037 * Added Doxygen headers before each and every function definition. 00038 * 00039 * Revision 1.6 2002/05/28 03:58:42 jrush 00040 * Sources modified to comply with GPL licensing. 00041 * 00042 * Revision 1.5 2002/04/12 11:48:51 jrush 00043 * Major reorganization of includes into a single base-include style. 00044 * 00045 * Revision 1.4 2002/04/12 10:43:50 jrush 00046 * Moved libsrc/rcfile.cxx to server/rcfile.cxx 00047 * 00048 * Revision 1.4 2002/04/06 15:01:17 jrush 00049 * Changed INT to just 'int'. 00050 * 00051 * Revision 1.3 2002/02/17 10:10:45 jrush 00052 * Commented out unused Udanax-configuration file directives, to avoid confusion. 00053 * 00054 * Revision 1.2 2002/02/14 09:27:43 jrush 00055 * Cleaned up source: 00056 * 00057 * 1. ran thru the indent tool to achieve a standard look, 00058 * 2. added structured comments at top for use with DOxygen reporting 00059 * as well as CVS keywords, 00060 * 3. fixed compiler warnings re ambiguous assign/compares, 00061 * needed casts and unused/uninitialized variables, 00062 * 4. fixed funcs that didn't specify a return type, 00063 * 5. centralized prototypes in protos.h, removing incomplete ones, 00064 * 6. cleaned up use of bool/BOOLEAN type to suit C++ type, 00065 * 7. fixed initializer nesting in tumbler constants, 00066 * 8. renamed vars that conflict with C++ keywords (new, this), 00067 * 9. fixed global/extern confusion re some global vars. 00068 * 00069 */ 00070 00071 #include <stdio.h> 00072 #include <string.h> 00073 #include "udanax.h" 00074 #include "port.h" 00075 00076 #define RCFILENAME ".backendrc" 00077 #define PORTMETANAME "port" 00078 #define HOSTMETANAME "host" 00079 //UNUSED #define BACKENDDIRECTORYMETANAME "backenddir" 00080 //UNUSED #define BACKENDFILEMETANAME "backend" 00081 //UNUSED #define ACCOUNTFILEMETANAME "accountfile" 00082 //UNUSED #define FRONTENDFILEMETANAME "frontend" 00083 //UNUSED #define BACKENDGLUEFILEMETANAME "backglue" 00084 //UNUSED #define FRONTENDGLUEFILEMETANAME "frontglue" 00085 #define ALLOCSIZENAME "allocsize" 00086 #define INCREMENTALALLOCSIZENAME "incrementalallocsize" 00087 00088 int portname = PORT; 00089 char hostname[256] = "localhost"; 00090 //UNUSED char backenddirectoryname[256] = "."; 00091 //UNUSED char backendfilename[256] = "backenddaemon"; 00092 //UNUSED char accountfilename[256] = "accountfile"; 00093 //UNUSED char frontendfilename[256] = "fex"; 00094 //UNUSED char backendgluefilename[256] = "intx"; 00095 //UNUSED char frontendgluefilename[256] = "ints"; 00096 00097 int incrementalallocsize = INCREMENTALALLOCSIZE; 00098 int allocsize = ALLOCSIZE; 00099 00107 /* Read run-time parameters from ./.backendrc ECH 7-7-88 This is real dumb, but it should be enough to get the job done 00108 * for now. */ 00109 void 00110 processrcfile() 00111 { 00112 FILE *rcfd; 00113 static char buf[BUFSIZ]; 00114 static char line[256]; 00115 static char name[256]; 00116 int temp; 00117 00118 if ((rcfd = fopen(RCFILENAME, "r")) != NULL) { 00119 while (fgets(buf, BUFSIZ, rcfd)) { 00120 if (buf[0] != '#' && sscanf(buf, "%s = %s", name, line) == 2) { 00121 //UNUSED if (!strcmp(name, BACKENDFILEMETANAME)) 00122 //UNUSED strcpy(backendfilename, line); 00123 //UNUSED else if (!strcmp(name, ACCOUNTFILEMETANAME)) 00124 //UNUSED strcpy(accountfilename, line); 00125 //UNUSED else 00126 if (!strcmp(name, PORTMETANAME)) { 00127 if (sscanf(line, "%d", &portname) < 1) { 00128 L("Could not use port = %s, using %d\n", line, PORT); 00129 portname = PORT; 00130 } 00131 } else if (!strcmp(name, HOSTMETANAME)) 00132 strcpy(hostname, line); 00133 //UNUSED else if (!strcmp(name, BACKENDDIRECTORYMETANAME)) 00134 //UNUSED strcpy(backenddirectoryname, line); 00135 //UNUSED else if (!strcmp(name, BACKENDGLUEFILEMETANAME)) 00136 //UNUSED strcpy(backendgluefilename, line); 00137 //UNUSED else if (!strcmp(name, FRONTENDGLUEFILEMETANAME)) 00138 //UNUSED strcpy(frontendgluefilename, line); 00139 //UNUSED else if (!strcmp(name, FRONTENDFILEMETANAME)) 00140 //UNUSED strcpy(frontendfilename, line); 00141 else if (!strcmp(name, ALLOCSIZENAME)) { 00142 temp = allocsize; 00143 sscanf(line, "%d", &allocsize); 00144 if (allocsize < 100000 || allocsize > 300000000) { /* minimal sanity checking */ 00145 incrementalallocsize = temp; 00146 } 00147 } else if (!strcmp(name, INCREMENTALALLOCSIZENAME)) { 00148 temp = incrementalallocsize; 00149 sscanf(line, "%d", &incrementalallocsize); 00150 if (incrementalallocsize < 10000 || incrementalallocsize > 100000000) { 00151 incrementalallocsize = temp; 00152 } 00153 } else 00154 L("Don't know about %s = %s\n", name, line); 00155 } 00156 } 00157 fclose(rcfd); 00158 } 00159 }
1.3.4