/[hydra]/hydra/src/util.c
ViewVC logotype

Diff of /hydra/src/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by nmav, Sat Sep 21 13:53:50 2002 UTC revision 1.2 by nmav, Sun Sep 22 09:07:57 2002 UTC
# Line 87  void clean_pathname(char *pathname) Line 87  void clean_pathname(char *pathname)
87   *   *
88   */   */
89    
90  char *get_commonlog_time(void)  void get_commonlog_time(char buf[30])
91  {  {
92      struct tm *t;      struct tm *t;
93      char *p;      char *p;
94      unsigned int a;      unsigned int a;
     static char buf[30];  
95      int time_offset;      int time_offset;
96    
97      if (use_localtime) {      if (use_localtime) {
# Line 143  char *get_commonlog_time(void) Line 142  char *get_commonlog_time(void)
142      *p-- = '0' + a % 10;      *p-- = '0' + a % 10;
143      *p-- = '0' + a / 10;      *p-- = '0' + a / 10;
144      *p = '[';      *p = '[';
145      return p;                   /* should be same as returning buf */      return;                   /* should be same as returning buf */
146  }  }
147    
148  /*  /*
# Line 386  void rfc822_time_buf(char *buf, time_t s Line 385  void rfc822_time_buf(char *buf, time_t s
385      memcpy(p, day_tab + t->tm_wday * 4, 4);      memcpy(p, day_tab + t->tm_wday * 4, 4);
386  }  }
387    
388  char *simple_itoa(unsigned int i)  void simple_itoa(unsigned int i, char buf[22])
389  {  {
390      /* 21 digits plus null terminator, good for 64-bit or smaller ints      /* 21 digits plus null terminator, good for 64-bit or smaller ints
391       * for bigger ints, use a bigger buffer!       * for bigger ints, use a bigger buffer!
# Line 394  char *simple_itoa(unsigned int i) Line 393  char *simple_itoa(unsigned int i)
393       * 4294967295 is, incidentally, MAX_UINT (on 32bit systems at this time)       * 4294967295 is, incidentally, MAX_UINT (on 32bit systems at this time)
394       * and is 10 bytes long       * and is 10 bytes long
395       */       */
396      static char local[22];      /* FIXME */
397      char *p = &local[21];      char *p = &buf[21];
398      *p-- = '\0';      *p-- = '\0';
399      do {      do {
400          *p-- = '0' + i % 10;          *p-- = '0' + i % 10;
401          i /= 10;          i /= 10;
402      } while (i > 0);      } while (i > 0);
403      return p + 1;  
404        return;
405  }  }
406    
407  /* I don't "do" negative conversions  /* I don't "do" negative conversions
# Line 411  char *simple_itoa(unsigned int i) Line 411  char *simple_itoa(unsigned int i)
411  int boa_atoi(char *s)  int boa_atoi(char *s)
412  {  {
413      int retval;      int retval;
414      char *reconv;      char reconv[22];
415    
416      if (!isdigit(*s))      if (!isdigit(*s))
417          return -1;          return -1;
# Line 420  int boa_atoi(char *s) Line 420  int boa_atoi(char *s)
420      if (retval < 0)      if (retval < 0)
421          return -1;          return -1;
422    
423      reconv = simple_itoa(retval);      simple_itoa(retval, reconv);
424      if (memcmp(s,reconv,strlen(s)) != 0) {      if (memcmp(s,reconv,strlen(s)) != 0) {
425          return -1;          return -1;
426      }      }
# Line 429  int boa_atoi(char *s) Line 429  int boa_atoi(char *s)
429    
430  int create_temporary_file(short want_unlink, char *storage, int size)  int create_temporary_file(short want_unlink, char *storage, int size)
431  {  {
432      static char boa_tempfile[MAX_PATH_LENGTH + 1];      char boa_tempfile[MAX_PATH_LENGTH + 1];
433      int fd;      int fd;
434    
435      snprintf(boa_tempfile, MAX_PATH_LENGTH,      snprintf(boa_tempfile, MAX_PATH_LENGTH,

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26