From: Peep P. <so...@us...> - 2004-03-16 14:23:21
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7923 Modified Files: sys.c Log Message: Removed unnecessary code. Index: sys.c =================================================================== RCS file: /cvsroot/agd/server/src/sys.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- sys.c 12 Mar 2004 16:02:05 -0000 1.8 +++ sys.c 16 Mar 2004 14:14:04 -0000 1.9 @@ -163,92 +163,9 @@ free(p); } -/* Unnecessary. But lets keep it for a couple of versions, just in case. */ -#if 0 -static char *cwd; - -char *get_working_dir(void) -{ -#ifdef __linux - cwd = getcwd(NULL, 0); /* This uses malloc(), so we don't get stats for this. */ - if(!cwd) { - debug("something bad happened.\n"); - return NULL; - } -#else - int size = 256; - char *buf = xmalloc(sizeof(char) * size); - while(1) { - cwd = getcwd(buf, size); - if(!cwd) { - if(errno == ERANGE) { - buf = realloc(buf, sizeof(char) * (size*=2)); - continue; - } else { - debug("something bad happened.\n"); - xfree(buf); - return NULL; - } - } - break; - } - cwd = buf; -#endif - return cwd; -} - -char *remove_file_name(char *path) -{ - int len; - char *name; - - len = strlen(path); - name = xmalloc(sizeof(char) * (len + 1)); - strcpy(name, path); - - if(path[len-1] == 'c' && path[len - 2] == '.') { - char *p = &name[len]; - while(p && *p != '/' && p >= name) p--; - p[1] = '\0'; - - } - - if(strlen(name) != len) - name = realloc(name, sizeof(char) * (strlen(name) + 1)); - return name; -} - -int dir_exists(char *name, int verbose) -{ - int doesit; - char *cwd; - char *_name; - - if(!name) - return; - _name = remove_file_name(name); - - cwd = get_working_dir(); - if(chdir(_name) == -1) { - doesit = 0; - if(verbose) - printf("Directory \"%s\" does not exist (or isn't accessable).\n", _name); - } else - doesit = 1; - - chdir(cwd); - xfree(cwd); - xfree(_name); - - return doesit; -} -#endif - int legal_path(char *fn) { char *p; -/* if(fn[0] == '/') - return 0;*/ p = fn; if(p = strstr(p, "..")) return 0; /* found it */ @@ -259,7 +176,7 @@ /* stringdup() isn't ANSI, so we need this replacement. */ char *stringdup(char *s) { - char *p = xmalloc(strlen(s) + 1); /* legit */ + char *p = xmalloc(strlen(s) + 1); strcpy(p, s); return p; } |