Hia, Just a tidbit of code I had lying around, an improved log function using variable args... (compiled and 100% working on Linux system) Add this to utils.h extern void log( char *format, ... ); Add this to the top of utils.c #include <stdarg.h> And this somewhere in between: /* writes a string to the log * New version, allows printf like call */ void log(char *format, ... ) { va_list args; time_t ct; char *tmstr; char buf[512]; va_start( args, format ); vsprintf( buf, format, args ); ct = time(0); tmstr = asctime(localtime(&ct)); *(tmstr + strlen(tmstr) - 1) = '\0'; fprintf(stderr, "%-19.19s :: %s\n", tmstr, buf ); va_end( args ); } Ok what's the use of this: allows calls like log("SYSERR: well somebody goofed up this time"); log("SYSERR: he goofed this up %s", buf ); log("SYSERR: he did it using a %ld", some_long_int ); I guess it makes the code a bit more readable (and shorter) Could do the same to mudlog and send_char.... Enjoy.... Greetinx GrimReaper of Realms Of Frustration (130.89.230.13 4000) -----+++++*****************************************************+++++++++------- - Ric Klaren - j.klaren@student.utwente.nl - ia_ric@cs.utwente.nl ------------- -----+++++*****************************************************+++++++++------- ``Why don't we just invite them to dinner and massacre them all when they're drunk?'' ``You heard the man. There's seven hundred thousand of them.'' ``Ah? So it'd have to be something simple with pasta, then.'' ------------------------------------------------------------------------------- From: Interesting Times by Terry Pratchet -----+++++*****************************************************+++++++++------- +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST