home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume3 / dnamail / dnamisc.c < prev    next >
C/C++ Source or Header  |  1989-02-03  |  794b  |  34 lines

  1. /*************************************************************
  2.   miscellaneous routines
  3.  *************************************************************/
  4.  
  5. #include <stdio.h>
  6. #include <sys/time.h>
  7.  
  8. /* returns a newly allocated copy of a string */
  9. char *copystr(str)
  10.       char *str;
  11. {
  12.   char *tmp, *calloc();
  13.   if (!str)
  14.     return NULL;
  15.   tmp = calloc(strlen(str)+1, 1);
  16.   strcpy(tmp, str);
  17.   return tmp;
  18. }
  19.  
  20. /* figure out correct time and timezone */
  21. char *mailtime() {
  22.   long my_time;
  23.   char *atime;
  24.   static char buf[32];
  25.   struct timeval tv;
  26.   struct timezone tzp;
  27.   my_time = time(0L);
  28.   atime = asctime(localtime(&my_time));
  29.   atime[strlen(atime)-1] = '\0';    /* zap "\n" */
  30.   gettimeofday(&tv, &tzp);
  31.   sprintf(buf, "%s %s", atime, timezone(tzp.tz_minuteswest, tzp.tz_dsttime));
  32.   return buf;
  33. }
  34.