/* * Copyright 2006 Eduard Bloch * * Uses my config parser code and small wrappers to provide the old interface. * */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * this program; see the file COPYING. If not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include enum parstate { KEYBEGINSEARCH, KEYCOMPARE, EQSIGNSEARCH, VALBEGINSEARCH, LASTCHARSEARCH }; #define GETVAL_BUF_LEN 512 #define isUspace(x) isspace( (int) (unsigned char) x) static FILE *glob_cfg_ptr = NULL; /* * Warning, uses static line buffer, not reentrant. NULL returned if the key isn't found. */ static char *get_value(FILE *srcfile, const char *key, int dorewind) { static char linebuf[GETVAL_BUF_LEN]; if(!srcfile) return ((char *) NULL); if(dorewind) rewind(srcfile); if(!key) return NULL; next_line: while(fgets(linebuf, sizeof(linebuf)-1, srcfile)) { int i; int keybeg=0; int s=KEYBEGINSEARCH; char *ret=NULL; int lastchar=0; /* simple state machine, char position moved by the states (or not), * state change is done by the state (or not) */ for( i=0 ; i