From 6acb4b68f68d516e2ac3c47e500f5600d653435e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 Nov 1998 21:17:20 +0000 Subject: Makefile.in: Added maintainer mode fixes. aclocal.m4: Added AC_LIBTESTFUNC. configure.in: Fixed -lsecurity -lsec problems. client.c: dos_ fixes. groupdb/aliasunix.c: Dead code removal. include/includes.h: Added default PRINTCAP_NAME. lib/genrand.c: dos_ fixes. lib/replace.c: Added strtoul. lib/system.c: dos_ fixes. lib/util.c: dos_ fixes. lib/util_sid.c: Signed/unsigned fixes. lib/util_str.c: removed bad const. locking/locking_slow.c: dos_ fixes. printing/printing.c: dos_ fixes. rpc_server/srv_samr.c: Dead code removal. rpc_server/srv_sid.c: global_myworkgroup defined with wrong size AGAIN ! smbd/dir.c: dos_ fixes. smbd/open.c: dos_ fixes. smbd/oplock.c: dos_ fixes. smbd/reply.c smbd/server.c smbd/service.c smbd/uid.c: dos_ fixes. Jeremy. --- source/lib/util.c | 199 ++++++------------------------------------------------ 1 file changed, 20 insertions(+), 179 deletions(-) (limited to 'source/lib/util.c') diff --git a/source/lib/util.c b/source/lib/util.c index ad5dbcf1069..757abc81751 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -100,30 +100,6 @@ char *tmpdir(void) return "/tmp"; } - - -/**************************************************************************** -prompte a dptr (to make it recently used) -****************************************************************************/ -static void array_promote(char *array,int elsize,int element) -{ - char *p; - if (element == 0) - return; - - p = (char *)malloc(elsize); - - if (!p) - { - DEBUG(5,("Ahh! Can't malloc\n")); - return; - } - memcpy(p,array + element * elsize, elsize); - memmove(array + elsize,array,elsize*element); - memcpy(array,p,elsize); - free(p); -} - /**************************************************************************** determine whether we are in the specified group ****************************************************************************/ @@ -189,7 +165,7 @@ char *Atoic(char *p, int *n, char *c) return p; } -int* add_num_to_list(uint32 **num, int *count, int val) +uint32 *add_num_to_list(uint32 **num, int *count, int val) { (*num) = Realloc((*num), ((*count)+1) * sizeof(uint32)); if ((*num) == NULL) @@ -201,6 +177,7 @@ int* add_num_to_list(uint32 **num, int *count, int val) return (*num); } + /************************************************************************* reads a list of numbers *************************************************************************/ @@ -383,7 +360,7 @@ BOOL file_exist(char *fname,SMB_STRUCT_STAT *sbuf) SMB_STRUCT_STAT st; if (!sbuf) sbuf = &st; - if (dos_stat(fname,sbuf) != 0) + if (sys_stat(fname,sbuf) != 0) return(False); return(S_ISREG(sbuf->st_mode)); @@ -396,7 +373,7 @@ time_t file_modtime(char *fname) { SMB_STRUCT_STAT st; - if (dos_stat(fname,&st) != 0) + if (sys_stat(fname,&st) != 0) return(0); return(st.st_mtime); @@ -412,7 +389,7 @@ BOOL directory_exist(char *dname,SMB_STRUCT_STAT *st) if (!st) st = &st2; - if (dos_stat(dname,st) != 0) + if (sys_stat(dname,st) != 0) return(False); ret = S_ISDIR(st->st_mode); @@ -428,7 +405,8 @@ SMB_OFF_T file_size(char *file_name) { SMB_STRUCT_STAT buf; buf.st_size = 0; - dos_stat(file_name,&buf); + if(sys_stat(file_name,&buf) != 0) + return (SMB_OFF_T)-1; return(buf.st_size); } @@ -451,8 +429,6 @@ char *attrib_string(uint16 mode) return(attrstr); } - - /**************************************************************************** make a file into unix format ****************************************************************************/ @@ -667,141 +643,6 @@ void unix_clean_name(char *s) trim_string(s,NULL,"/.."); } - -/******************************************************************* -a wrapper for the normal chdir() function -********************************************************************/ -int ChDir(char *path) -{ - int res; - static pstring LastDir=""; - - if (strcsequal(path,".")) return(0); - - if (*path == '/' && strcsequal(LastDir,path)) return(0); - DEBUG(3,("chdir to %s\n",path)); - res = dos_chdir(path); - if (!res) - pstrcpy(LastDir,path); - return(res); -} - -/* number of list structures for a caching GetWd function. */ -#define MAX_GETWDCACHE (50) - -struct -{ - SMB_DEV_T dev; /* These *must* be compatible with the types returned in a stat() call. */ - SMB_INO_T inode; /* These *must* be compatible with the types returned in a stat() call. */ - char *text; /* The pathname in DOS format. */ - BOOL valid; -} ino_list[MAX_GETWDCACHE]; - -BOOL use_getwd_cache=True; - -/******************************************************************* - return the absolute current directory path - given a UNIX pathname. - Note that this path is returned in DOS format, not UNIX - format. -********************************************************************/ -char *GetWd(char *str) -{ - pstring s; - static BOOL getwd_cache_init = False; - SMB_STRUCT_STAT st, st2; - int i; - - *s = 0; - - if (!use_getwd_cache) - return(dos_getwd(str)); - - /* init the cache */ - if (!getwd_cache_init) - { - getwd_cache_init = True; - for (i=0;i