diff options
author | Chuck Miller <shadowmil@gmail.com> | 2009-12-25 05:00:31 -0500 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-12-26 00:40:11 -0700 |
commit | 634aeeb9d58b01f9de6632a014a063ef0c4cf31e (patch) | |
tree | 70023dd2bcc12a3f96ec6f118d80e27411920531 /src/common/utils.c | |
parent | 113fcc4f0a7a0921e94bc415515dd4b393a29d60 (diff) | |
download | tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.gz tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.bz2 tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.xz tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.zip |
Used the "indent" C formatting program from GNU to do some clean ups
The command options used was:
-nbad -bap -sc -bl -blf -bli0 -cli4 -cbi0
-di5 -nbc -bls -ip2 -nut -ts4 -bap -i4 -sob -npsl
Diffstat (limited to 'src/common/utils.c')
-rw-r--r-- | src/common/utils.c | 163 |
1 files changed, 88 insertions, 75 deletions
diff --git a/src/common/utils.c b/src/common/utils.c index b0ecd26..1433a5e 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2,107 +2,120 @@ #include "utils.h" #include <stdio.h> -void dump(unsigned char *buffer, int num) +void dump (unsigned char *buffer, int num) { - int icnt,jcnt; - - printf(" Hex ASCII\n"); - printf(" ----------------------------------------------- ----------------"); - - for (icnt=0;icnt<num;icnt+=16) { - printf("\n%p ",&buffer[icnt]); - for (jcnt=icnt;jcnt<icnt+16;++jcnt) { - if (jcnt < num) { - printf("%02hX ",buffer[jcnt]); - } else - printf(" "); + int icnt, jcnt; + + printf + (" Hex ASCII\n"); + printf + (" ----------------------------------------------- ----------------"); + + for (icnt = 0; icnt < num; icnt += 16) + { + printf ("\n%p ", &buffer[icnt]); + for (jcnt = icnt; jcnt < icnt + 16; ++jcnt) + { + if (jcnt < num) + { + printf ("%02hX ", buffer[jcnt]); + } + else + printf (" "); + } + + printf (" | "); + + for (jcnt = icnt; jcnt < icnt + 16; ++jcnt) + { + if (jcnt < num) + { + if (buffer[jcnt] > 31 && buffer[jcnt] < 127) + printf ("%c", buffer[jcnt]); + else + printf ("."); + } + else + printf (" "); + } } - - printf(" | "); - - for (jcnt=icnt;jcnt<icnt+16;++jcnt) { - if (jcnt < num) { - if (buffer[jcnt] > 31 && buffer[jcnt] < 127) - printf("%c",buffer[jcnt]); - else - printf("."); - } else - printf(" "); - } - } - printf("\n"); + printf ("\n"); } - #ifdef LCCWIN32 -char *rindex(char *str, char c) +char *rindex (char *str, char c) { - char *sptr; - - sptr = str; - while(*sptr) - ++sptr; - if (c == '\0') - return(sptr); - while(str != sptr) - if (*sptr-- == c) - return(++sptr); - return(NULL); + char *sptr; + + sptr = str; + while (*sptr) + ++sptr; + if (c == '\0') + return (sptr); + while (str != sptr) + if (*sptr-- == c) + return (++sptr); + return (NULL); } -int strcasecmp(const char *arg1, const char *arg2) +int strcasecmp (const char *arg1, const char *arg2) { - int chk, i; + int chk, i; - if (arg1 == NULL || arg2 == NULL) { - printf("SYSERR: str_cmp() passed a NULL pointer, %p or %p.\n", arg1, arg2); - return (0); - } + if (arg1 == NULL || arg2 == NULL) + { + printf ("SYSERR: str_cmp() passed a NULL pointer, %p or %p.\n", arg1, + arg2); + return (0); + } - for (i = 0; arg1[i] || arg2[i]; i++) - if ((chk = LOWER(arg1[i]) - LOWER(arg2[i])) != 0) - return (chk); /* not equal */ + for (i = 0; arg1[i] || arg2[i]; i++) + if ((chk = LOWER (arg1[i]) - LOWER (arg2[i])) != 0) + return (chk); /* not equal */ - return (0); + return (0); } -int strncasecmp(const char *arg1, const char *arg2, int n) +int strncasecmp (const char *arg1, const char *arg2, int n) { - int chk, i; + int chk, i; - if (arg1 == NULL || arg2 == NULL) { - printf("SYSERR: strn_cmp() passed a NULL pointer, %p or %p.\n", arg1, arg2); - return (0); - } + if (arg1 == NULL || arg2 == NULL) + { + printf ("SYSERR: strn_cmp() passed a NULL pointer, %p or %p.\n", arg1, + arg2); + return (0); + } - for (i = 0; (arg1[i] || arg2[i]) && (n > 0); i++, n--) - if ((chk = LOWER(arg1[i]) - LOWER(arg2[i])) != 0) - return (chk); /* not equal */ + for (i = 0; (arg1[i] || arg2[i]) && (n > 0); i++, n--) + if ((chk = LOWER (arg1[i]) - LOWER (arg2[i])) != 0) + return (chk); /* not equal */ - return (0); + return (0); } -void str_upper(char *name) +void str_upper (char *name) { - int len = strlen(name); - while (len--) { - if (*name >= 'a' && *name <= 'z') - *name -= ('a' - 'A'); - name++; - } + int len = strlen (name); + while (len--) + { + if (*name >= 'a' && *name <= 'z') + *name -= ('a' - 'A'); + name++; + } } -void str_lower(char *name) +void str_lower (char *name) { - int len = strlen(name); + int len = strlen (name); - while (len--) { - if (*name >= 'A' && *name <= 'Z') - *name += ('a' - 'A'); - name++; - } + while (len--) + { + if (*name >= 'A' && *name <= 'Z') + *name += ('a' - 'A'); + name++; + } } #endif - |