]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/q9snprintf.c
A4STATS: remove E style escapes and switch to createtable for indices
[irc/quakenet/newserv.git] / chanserv / q9snprintf.c
index 701d7dc1d111bfd485791959aa72c0db7152489f..78219469917affecf4310f410569425007d75d52 100644 (file)
@@ -5,17 +5,26 @@
 #include <time.h>
 #include "../lib/sstring.h"
 #include "../lib/stringbuf.h"
+#include "../lib/ccassert.h"
 #include "../core/error.h"
+#include "chanserv_messages.h"
 
 #define MAXARGS 10
 #define CONVBUF 512
 
+void q9strftime(char *buf, size_t size, time_t t) {
+  strftime(buf, size, Q9_FORMAT_TIME, gmtime(&t));
+}
+
 void q9vsnprintf(char *buf, size_t size, const char *format, const char *args, va_list ap) {
   StringBuf b;
   const char *p;
   char *c;
+
   char convbuf[MAXARGS][CONVBUF];
 
+  CCASSERT(CONVBUF > TIMELEN);
+
   if(size == 0)
     return;
 
@@ -53,7 +62,7 @@ void q9vsnprintf(char *buf, size_t size, const char *format, const char *args, v
           break;
         case 'T':
           t = va_arg(ap, time_t);
-          strftime(cb, 15, "%d/%m/%y %H:%M", gmtime(&t));
+          q9strftime(cb, CONVBUF, t);
           break;
         default:
           /* calls exit(0) */
@@ -62,9 +71,7 @@ void q9vsnprintf(char *buf, size_t size, const char *format, const char *args, v
     }
   }
 
-  b.buf = buf;
-  b.capacity = size;
-  b.len = 0;
+  sbinit(&b, buf, size);
 
   for(p=format;*p;p++) {
     if(*p != '$') {