From 7780a78a93acd23abd4f69d26a41690ce75dc0ba Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 10 Mar 2003 02:03:09 +0000 Subject: [PATCH] util-symbol-renaming-and-cleanup-20030309 rename more stuff into the util_ space use it some other cleanup in the util package --- src/bozo/bos.c | 4 +- src/kauth/admin_tools.c | 4 +- src/util/afsutil_prototypes.h | 69 ++++++++++++++++++++++++++------- src/util/hputil.c | 17 +++------ src/util/isathing.c | 16 ++++---- src/util/ktime.c | 72 +++++++++++++++++------------------ src/util/serverLog.c | 4 +- src/util/volparse.c | 21 ++++------ 8 files changed, 115 insertions(+), 92 deletions(-) diff --git a/src/bozo/bos.c b/src/bozo/bos.c index e82fa5e573..14c02ba7d0 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -1450,8 +1450,8 @@ struct cmd_syndesc *as; { printf("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n"); return EINVAL; } - code = GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data, - &mrafsParm.OptResidencies); + code = util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data, + &mrafsParm.OptResidencies); if (code) { printf("bos: '%s' is not a valid residency mask.\n", as->parms[MRAFS_OFFSET + 13].items->data); diff --git a/src/kauth/admin_tools.c b/src/kauth/admin_tools.c index a614c5a9a7..3af6fea300 100644 --- a/src/kauth/admin_tools.c +++ b/src/kauth/admin_tools.c @@ -584,7 +584,7 @@ int SetFields ( for (i=0;i<4;misc_auth_bytes[i++] = 0); if (as->parms[4].items) { - if (isint(as->parms[4].items->data)) + if (util_isint(as->parms[4].items->data)) pwexpiry = atoi (as->parms[4].items->data); else { fprintf(stderr,"Password lifetime specified must be a non-negative decimal integer.\n"); @@ -620,7 +620,7 @@ int SetFields ( int nfailures; - if (isint(as->parms[6].items->data) && + if (util_isint(as->parms[6].items->data) && ((nfailures = atoi(as->parms[6].items->data)) < 255)) { misc_auth_bytes[2] = nfailures+1; } diff --git a/src/util/afsutil_prototypes.h b/src/util/afsutil_prototypes.h index 4eb1a205bc..e1babe30c8 100644 --- a/src/util/afsutil_prototypes.h +++ b/src/util/afsutil_prototypes.h @@ -17,31 +17,49 @@ /* assert.c */ +extern void AssertionFailed(char *file, int line); /* base32.c */ - +extern char *int_to_base32(b32_string_t s, int a); +extern int base32_to_int(char *s); /* base64.c */ - +extern char *int_to_base64(b64_string_t s, int a); +extern int base64_to_int(char *s); /* casestrcpy.c */ - +extern char *lcstring (char *d, char *s, int n); +extern char *ucstring (char *d, char *s, int n); /* dirpath.c */ - +extern unsigned int initAFSDirPath(void); +extern const char *getDirPath(afsdir_id_t string_id); +extern int ConstructLocalPath(const char *cpath, const char *relativeTo, + char **fullPathBufp); +extern int ConstructLocalBinPath(const char *cpath, char **fullPathBufp); +extern int ConstructLocalLogPath(const char *cpath, char **fullPathBufp); /* errmap_nt.c */ - +extern int nterr_nt2unix(long ntErr, int defaultErr); /* fileutil.c */ - +extern int renamefile(const char *oldname, const char *newname); +extern void FilepathNormalizeEx(char *path, int slashType); +extern void FilepathNormalize(char *path); /* flipbase64.c */ +#ifdef AFS_64BIT_ENV +extern char *int64_to_flipbase64(lb64_string_t s, afs_int64 a); +extern afs_int64 flipbase64_to_int64(char *s); +#else +extern char *int64_to_flipbase64(lb64_string_t s, u_int64_t a); +extern int64_t flipbase64_to_int64(char *s); +#endif /* get_krbrlm.c */ - +extern int afs_krb_get_lrealm(char *r, int n); /* hostparse.c */ extern struct hostent *hostutil_GetHostByName(register char *ahost); @@ -52,10 +70,19 @@ extern char *afs_inet_ntoa_r(afs_uint32 addr, char *buf); extern char *gettmpdir(void); /* hputil.c */ - +#ifdef AFS_HPUX_ENV +#ifndef AFS_HPUX102_ENV +extern int utimes(char *file, struct timeval tvp[2]); +#endif +extern int random(void); +extern void srandom(int seed); +extern int getdtablesize(void); +extern void setlinebuf(FILE *file); +extern void psignal(unsigned int sig, char *s); +#endif /* isathing.c */ - +extern int util_isint(char *str); /* kreltime.c */ extern afs_int32 ktimeRelDate_ToInt32(struct ktime_date *kdptr); @@ -65,9 +92,15 @@ extern afs_int32 ParseRelDate(char *dateStr, struct ktime_date *relDatePtr); extern char *RelDatetoString(struct ktime_date *datePtr); extern afs_int32 Add_RelDate_to_Time(struct ktime_date *relDatePtr, afs_int32 atime); - /* ktime.c */ - +extern char *ktime_DateOf(afs_int32 atime); +extern afs_int32 ktime_Str2int32(register char *astr); +extern int ktime_ParsePeriodic(char *adate, register struct ktime *ak); +extern int ktime_DisplayString(struct ktime *aparm, register char *astring); +extern afs_int32 ktime_next(struct ktime *aktime, afs_int32 afrom); +extern afs_int32 ktime_DateToInt32(char *adate, afs_int32 *aint32); +extern char *ktime_GetDateUsage(void); +extern afs_int32 ktime_InterpretDate(struct ktime_date *akdate); /* netutils.c */ extern afs_uint32 extract_Addr(char *line, int maxSize); @@ -96,7 +129,12 @@ extern int parseNetFiles(afs_uint32 addrbuf[], afs_uint32 maskbuf[], afs_uint32 /* serverLog.c */ - +extern void WriteLogBuffer(char *buf, afs_uint32 len); +extern void SetDebug_Signal(int signo); +extern void ResetDebug_Signal(int signo); +extern void SetupLogSignals(void); +extern int OpenLog(const char *fileName); +extern int ReOpenLog(const char *fileName); /* snprintf.c */ @@ -112,9 +150,12 @@ extern void afs_ntohuuid(afsUUID *uuidp); extern afs_int32 afs_uuid_create (afsUUID *uuid); extern u_short afs_uuid_hash (afsUUID *uuid); - /* volparse.c */ - +extern afs_int32 volutil_GetPartitionID(char *aname); +extern char *volutil_PartitionName_r(int avalue, char *tbuffer, int buflen); +extern char *volutil_PartitionName(int avalue); +extern afs_int32 util_GetInt32(register char *as, afs_int32 *aval); +extern afs_uint32 util_GetUInt32(register char *as, afs_uint32 *aval); /* winsock_nt.c */ diff --git a/src/util/hputil.c b/src/util/hputil.c index 88534ac549..1e95f690f4 100644 --- a/src/util/hputil.c +++ b/src/util/hputil.c @@ -21,9 +21,7 @@ RCSID("$Header$"); /* insque/remque moved to timer.c where they are used. */ #ifndef AFS_HPUX102_ENV -utimes(file,tvp) -char *file; -struct timeval tvp[2]; +int utimes(char *file, struct timeval tvp[2]) { struct utimbuf times; @@ -33,30 +31,27 @@ struct timeval tvp[2]; } #endif -random() +int random(void) { return rand(); } -srandom(seed) +void srandom(int seed) { srand(seed); } -getdtablesize() +int getdtablesize(void) { return (20); } -setlinebuf(file) -FILE *file; +void setlinebuf(FILE *file) { setbuf(file,NULL); } -psignal(sig,s) -unsigned sig; -char *s; +void psignal(unsigned int sig, char *s) { fprintf (stderr,"%s: signal %d\n",s,sig); } diff --git a/src/util/isathing.c b/src/util/isathing.c index e97f4fee4d..cb669fd32e 100644 --- a/src/util/isathing.c +++ b/src/util/isathing.c @@ -15,16 +15,14 @@ RCSID("$Header$"); #include /* checks a string to determine whether it's a non-negative decimal integer or not */ -int -isint (str) -char *str; +int util_isint(char *str) { -char *i; + char *i; -for (i=str; *i && !isspace(*i); i++) { - if (!isdigit(*i)) - return 0; - } + for (i=str; *i && !isspace(*i); i++) { + if (!isdigit(*i)) + return 0; + } -return 1; + return 1; } diff --git a/src/util/ktime.c b/src/util/ktime.c index 8095a00c18..fd2debb398 100644 --- a/src/util/ktime.c +++ b/src/util/ktime.c @@ -31,10 +31,6 @@ RCSID("$Header$"); #include "ktime.h" -/* some forward reference dcls */ -static afs_int32 ktime_ParseDate(); -static ParseTime(); - /* some date parsing routines */ struct token { @@ -168,17 +164,6 @@ char *ktime_DateOf(afs_int32 atime) return tbuffer; } -afs_int32 ktime_Str2int32(register char *astr) -{ -struct ktime tk; - -memset(&tk, 0, sizeof(tk)); -if ( ParseTime(&tk, astr) ) - return (-1); /* syntax error */ - -return ((tk.hour*60 + tk.min)*60 + tk.sec); -} - /* ParseTime * parse 12:33:12 or 12:33 or 12 into ktime structure * entry: @@ -225,6 +210,17 @@ static int ParseTime(register struct ktime *ak, register char *astr) return 0; } +afs_int32 ktime_Str2int32(register char *astr) +{ + struct ktime tk; + + memset(&tk, 0, sizeof(tk)); + if ( ParseTime(&tk, astr) ) + return (-1); /* syntax error */ + + return ((tk.hour*60 + tk.min)*60 + tk.sec); +} + /* ktime_ParsePeriodic * Parses periodic date of form * now | never | at [time spec] | every [time spec] @@ -443,29 +439,6 @@ static int KDateCmp(register struct ktime_date *akdate, register struct tm *atm) return 0; } -/* ktime_DateToInt32 - * Converts a ktime date string into an afs_int32 - * entry: - * adate - ktime date string - * aint32 - ptr to afs_int32 - * exit: - * 0 - aint32 contains converted date. - */ - -afs_int32 ktime_DateToInt32(char *adate, afs_int32 *aint32) -{ - struct ktime_date tdate; - register afs_int32 code; - - /* parse the date into a ktime_date structure */ - code = ktime_ParseDate(adate, &tdate); - if (code) return code; /* failed to parse */ - - code = ktime_InterpretDate(&tdate); /* interpret date as seconds since 1970 */ - *aint32 = code; /* return it */ - return 0; /* and declare no errors */ -} - /* ktime_ParseDate * parse date string into ktime_date structure * entry: @@ -531,6 +504,29 @@ static afs_int32 ktime_ParseDate(char *adate, struct ktime_date *akdate) return 0; } +/* ktime_DateToInt32 + * Converts a ktime date string into an afs_int32 + * entry: + * adate - ktime date string + * aint32 - ptr to afs_int32 + * exit: + * 0 - aint32 contains converted date. + */ + +afs_int32 ktime_DateToInt32(char *adate, afs_int32 *aint32) +{ + struct ktime_date tdate; + register afs_int32 code; + + /* parse the date into a ktime_date structure */ + code = ktime_ParseDate(adate, &tdate); + if (code) return code; /* failed to parse */ + + code = ktime_InterpretDate(&tdate); /* interpret as seconds since 1970 */ + *aint32 = code; /* return it */ + return 0; /* and declare no errors */ +} + /* get useful error message to print about date input format */ char *ktime_GetDateUsage(void) { diff --git a/src/util/serverLog.c b/src/util/serverLog.c index 9bad59b379..f9757dc463 100644 --- a/src/util/serverLog.c +++ b/src/util/serverLog.c @@ -82,9 +82,7 @@ int mrafsStyleLogs = 0; int printLocks = 0; static char ourName[MAXPATHLEN]; -void WriteLogBuffer(buf,len) - char *buf; - afs_uint32 len; +void WriteLogBuffer(char *buf, afs_uint32 len) { LOCK_SERVERLOG(); if (serverLogFD > 0) diff --git a/src/util/volparse.c b/src/util/volparse.c index 727c2ec08f..132660e818 100644 --- a/src/util/volparse.c +++ b/src/util/volparse.c @@ -24,8 +24,8 @@ RCSID("$Header$"); #endif /* map a partition id from any partition-style name */ -afs_int32 volutil_GetPartitionID(aname) -char *aname; { +afs_int32 volutil_GetPartitionID(char *aname) +{ register char tc; afs_int32 temp; char ascii[3]; @@ -113,9 +113,8 @@ char *volutil_PartitionName(int avalue) } /* is this a digit or a digit-like thing? */ -static int ismeta(ac, abase) -register int abase; -register int ac; { +static int ismeta(register int ac, register int abase) +{ /* if (ac == '-' || ac == 'x' || ac == 'X') return 1; */ if (ac >= '0' && ac <= '7') return 1; if (abase <= 8) return 0; @@ -127,17 +126,15 @@ register int ac; { } /* given that this is a digit or a digit-like thing, compute its value */ -static int getmeta(ac) -register int ac; { +static int getmeta(register int ac) +{ if (ac >= '0' && ac <= '9') return ac - '0'; if (ac >= 'a' && ac <= 'f') return ac - 'a' + 10; if (ac >= 'A' && ac <= 'F') return ac - 'A' + 10; return 0; } -afs_int32 util_GetInt32 (as, aval) -register char *as; -afs_int32 *aval; +afs_int32 util_GetInt32(register char *as, afs_int32 *aval) { register afs_int32 total; register int tc; @@ -183,9 +180,7 @@ afs_int32 *aval; } afs_uint32 -GetUInt32 (as, aval) -register char *as; -afs_uint32 *aval; +util_GetUInt32(register char *as, afs_uint32 *aval) { register afs_uint32 total; register int tc;