/[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.10 by nmav, Sun Sep 29 11:00:04 2002 UTC revision 1.11 by nmav, Sun Sep 29 12:02:57 2002 UTC
# Line 386  void rfc822_time_buf(char *buf, time_t s Line 386  void rfc822_time_buf(char *buf, time_t s
386      memcpy(p, day_tab + t->tm_wday * 4, 4);      memcpy(p, day_tab + t->tm_wday * 4, 4);
387  }  }
388    
389  void simple_itoa(unsigned long int i, char buf[22])  /* Returns the number of digits */
390    int simple_itoa(unsigned long int i, char buf[22])
391  {  {
392      /* 21 digits plus null terminator, good for 64-bit or smaller ints      /* 21 digits plus null terminator, good for 64-bit or smaller ints
393       * for bigger ints, use a bigger buffer!       * for bigger ints, use a bigger buffer!
# Line 407  void simple_itoa(unsigned long int i, ch Line 408  void simple_itoa(unsigned long int i, ch
408      p++;      p++;
409      if (p!=buf) memmove( buf, p, digits);      if (p!=buf) memmove( buf, p, digits);
410    
411      return;      return digits - 1;
412  }  }
413    
414    /* Generates an Etag, by using the file size, and the modification time
415     */
416    int create_etag(unsigned long int size, unsigned long int mod_time,
417       char etag[MAX_ETAG_LENGTH])
418    {
419    char buf[22];
420    int len, len2;
421    
422        etag[0] = '\"';
423        len = 1;
424    
425        len2 = simple_itoa( size % 10000, buf); /* up to 4 digits */
426        memcpy( &etag[len], buf, len2);
427        len += len2;
428    
429        etag[len++] = '-';
430        len2 = simple_itoa( mod_time % 10000, buf); /* also 4 digits */
431        memcpy( &etag[len], buf, len2);
432        len += len2;
433    
434        etag[len++] = '\"';
435        etag[len] = 0; /* etag is null terminated */
436    
437        return len;
438    }
439    
440    
441  /* I don't "do" negative conversions  /* I don't "do" negative conversions
442   * Therefore, -1 indicates error   * Therefore, -1 indicates error
443   */   */

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26