From: Peep P. <so...@us...> - 2004-03-21 19:53:22
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25538/src Modified Files: dfdecl.in dfuns.c Log Message: New dfun: strftime() Index: dfuns.c =================================================================== RCS file: /cvsroot/agd/server/src/dfuns.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- dfuns.c 21 Mar 2004 10:35:53 -0000 1.15 +++ dfuns.c 21 Mar 2004 18:32:35 -0000 1.16 @@ -128,23 +128,6 @@ push_string(s, ST_STATIC); } -void df_time(void) -{ - push_int(time(NULL)); -} - -void df_asctime(void) -{ - time_t t; - char *s; - - t = fp->u.i; - s = ctime(&t); - s[strlen(s)-1] = '\0'; /* Remove the newline. */ - pop_stack(); - push_string(s, ST_STATIC); -} - void df_shout(void) { shout(fp[0].u.s, fp[1].u.ob); @@ -249,13 +232,6 @@ push_string(ret, ST_STATIC); } -void df_uptime(void) -{ - time_t t; - time(&t); - push_int(t - startup_time); -} - void df_query_idle(void) { int ret; @@ -276,6 +252,45 @@ push_int(j); } +/* Time. */ +void df_uptime(void) +{ + time_t t; + time(&t); + push_int(t - startup_time); +} + +void df_time(void) +{ + push_int(time(NULL)); +} + +void df_asctime(void) +{ + time_t t; + char *s; + + t = fp->u.i; + s = ctime(&t); + s[strlen(s)-1] = '\0'; /* Remove the newline. */ + pop_stack(); + push_string(s, ST_STATIC); +} + +void df_strftime(void) +{ + struct tm *tm; + time_t t; + static char buf[512]; + + t = fp[0].u.i; + tm = localtime(&t); + strftime(buf, 512, fp[1].u.s, tm); + pop_stack(); pop_stack(); + + push_string(buf, ST_STATIC); +} + /* Strings. */ void df_strlen(void) { Index: dfdecl.in =================================================================== RCS file: /cvsroot/agd/server/src/dfdecl.in,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- dfdecl.in 21 Mar 2004 10:36:28 -0000 1.8 +++ dfdecl.in 21 Mar 2004 18:32:35 -0000 1.9 @@ -26,9 +26,12 @@ string query_ip(object) string query_hostname(object) -# misc +# Time. int time() string asctime(int) +string strftime(int, string) + +# misc string version() string platform() int uptime() |