24 sprintf(txt,
"%d", (
int) (n));
27 sprintf(txt,
"%.1f K", (n/1e3));
30 sprintf(txt,
"%.1f M", (n/1e6));
33 sprintf(txt,
"%.1f G", (n/1e9));
36 sprintf(txt,
"%.1f T", (n/1e12));
39 sprintf(txt,
"%.1e", n);
49 sprintf(txt,
"%d", (
int) (n));
52 sprintf(txt,
"%.1e", n);
70 sprintf(txt,
"%02d:%02d:%02d", h,m,s);
72 sprintf(txt,
"%02d:%02d", m,s);
90 sprintf(txt,
"%02d:%02d:%02d", h,m,s);
98 int d = 1, h = 0, m = 0, s = 0;
119 sprintf(txt,
"%02d/%02d:%02d:%02d", d, h, m, s);
121 sprintf(txt,
"Day %02d %02d:%02d:%02d", d, h, m, s);
129 int d = 1, h = 0, m = 0, s = 0;
137 sprintf(txt,
"Day %02d", d);
152 sprintf(txt,
"(%s, %s, %s)", x, y, z);
159 static const char* month[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
160 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" };
161 static const char* meridian[2] = {
"AM",
"PM" };
167 struct tm *t = localtime(&aclock);
170 sprintf(buffer,
"%d %s %d, %2d:%02d:%02d %s",
171 t->tm_mday, month[t->tm_mon], 1900 + t->tm_year,
172 t->tm_hour > 12 ? t->tm_hour-12 : t->tm_hour,
173 t->tm_min, t->tm_sec, meridian[t->tm_hour > 12]);
180 static char safe_str[2048];
184 ZeroMemory(safe_str,
sizeof(safe_str));
190 for (
int i = 0; i < len; i++) {
194 safe_str[n++] =
'\\';
198 else if (c ==
'\t') {
199 safe_str[n++] =
'\\';
204 safe_str[n++] =
'\'';
207 else if (c ==
'\\' && i < len-1) {
208 safe_str[n++] = s[i++];
209 safe_str[n++] = s[i++];
212 else if (c < 32 || c > 126) {
235 while (*msg && dst < 254) {
237 safe_str[dst++] =
'\'';
240 else if (isspace(*msg)) {
241 safe_str[dst++] =
' ';
245 safe_str[dst++] = *msg++;
258 if (!msg || !tgt || !val)
261 if (!strchr(msg, *tgt))
265 char* buffer =
new char[strlen(msg) + 1];
268 int tgtlen = strlen(tgt);
271 if (!strncmp(p, tgt, tgtlen)) {
301 if (!strchr(msg,
'\\'))
305 char* buffer =
new char[strlen(msg) + 1];
318 else if (*p ==
't') {