home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume3
/
dnamail
/
dnamisc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-03
|
794b
|
34 lines
/*************************************************************
miscellaneous routines
*************************************************************/
#include <stdio.h>
#include <sys/time.h>
/* returns a newly allocated copy of a string */
char *copystr(str)
char *str;
{
char *tmp, *calloc();
if (!str)
return NULL;
tmp = calloc(strlen(str)+1, 1);
strcpy(tmp, str);
return tmp;
}
/* figure out correct time and timezone */
char *mailtime() {
long my_time;
char *atime;
static char buf[32];
struct timeval tv;
struct timezone tzp;
my_time = time(0L);
atime = asctime(localtime(&my_time));
atime[strlen(atime)-1] = '\0'; /* zap "\n" */
gettimeofday(&tv, &tzp);
sprintf(buf, "%s %s", atime, timezone(tzp.tz_minuteswest, tzp.tz_dsttime));
return buf;
}