Browse Subversion Repository
Diff of /branches/mty-makai/mty.c
Parent Directory
| Revision Log
| Patch
| 17 |
|
|
| 18 |
#include <assert.h> |
#include <assert.h> |
| 19 |
#include <ctype.h> |
#include <ctype.h> |
| 20 |
|
#include <errno.h> |
| 21 |
#include <malloc.h> |
#include <malloc.h> |
| 22 |
#include <limits.h> |
#include <limits.h> |
| 23 |
|
#include <stdarg.h> |
| 24 |
#include <stddef.h> |
#include <stddef.h> |
| 25 |
#include <stdio.h> |
#include <stdio.h> |
| 26 |
#include <stdlib.h> |
#include <stdlib.h> |
| 1363 |
#endif |
#endif |
| 1364 |
} |
} |
| 1365 |
|
|
| 1366 |
|
static |
| 1367 |
|
int |
| 1368 |
|
log_printf(FILE *ofp, char const *fmt, ...) |
| 1369 |
|
{ |
| 1370 |
|
int r; |
| 1371 |
|
va_list ap; |
| 1372 |
|
va_start(ap, fmt); |
| 1373 |
|
vfprintf(stdout, fmt, ap); |
| 1374 |
|
r = vfprintf(ofp, fmt, ap); |
| 1375 |
|
va_end(ap); |
| 1376 |
|
if (r > 0) |
| 1377 |
|
return r; |
| 1378 |
|
perror("log_printf"); |
| 1379 |
|
exit(errno); |
| 1380 |
|
} |
| 1381 |
|
|
| 1382 |
/*************************************************************** |
/*************************************************************** |
| 1383 |
* |
* |
| 1384 |
* メインループとか |
* メインループとか |
| 1533 |
assert(!((ptrdiff_t)&key64 & (sizeof(WS_T) - 1))); |
assert(!((ptrdiff_t)&key64 & (sizeof(WS_T) - 1))); |
| 1534 |
assert(!((ptrdiff_t)¶m64 & (sizeof(WS_T) - 1))); |
assert(!((ptrdiff_t)¶m64 & (sizeof(WS_T) - 1))); |
| 1535 |
|
|
| 1536 |
if ((ofp = fopen("log.txt", "at")) != NULL) |
if ((ofp = fopen("log.txt", "at")) == NULL) |
| 1537 |
setvbuf(ofp, NULL, _IONBF, BUFSIZ); /* XXX MSVCRT では _IOLBF が期待通りに動作しない */ |
{ |
| 1538 |
|
perror("log.txt"); |
| 1539 |
|
return errno; |
| 1540 |
|
} |
| 1541 |
|
|
| 1542 |
|
setvbuf(ofp, NULL, _IONBF, BUFSIZ); /* XXX MSVCRT では _IOLBF が期待通りに動作しない */ |
| 1543 |
|
|
| 1544 |
for (i = 0; i < N_TS; i++) |
for (i = 0; i < N_TS; i++) |
| 1545 |
ts[i].t = ts[i].c = 0; |
ts[i].t = ts[i].c = 0; |
| 1621 |
if (cr) |
if (cr) |
| 1622 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
| 1623 |
cr = 0; |
cr = 0; |
| 1624 |
printf("◆%s #%-10.10s(%02X %02X %02X %02X %02X %02X %02X %02X/%02X)\n", |
log_printf(ofp, |
| 1625 |
hash, |
"◆%s #%-10.10s(%02X %02X %02X %02X %02X %02X %02X %02X/%02X)\n", |
| 1626 |
buf, |
hash, |
| 1627 |
buf[0], buf[1], buf[2], buf[3], |
buf, |
| 1628 |
buf[4], buf[5], buf[6], buf[7], |
buf[0], buf[1], buf[2], buf[3], |
| 1629 |
buf[8]); |
buf[4], buf[5], buf[6], buf[7], |
| 1630 |
if (ofp) |
buf[8]); |
|
fprintf(ofp, |
|
|
"◆%s #%-10.10s(%02X %02X %02X %02X %02X %02X %02X %02X/%02X)\n", |
|
|
hash, |
|
|
buf, |
|
|
buf[0], buf[1], buf[2], buf[3], |
|
|
buf[4], buf[5], buf[6], buf[7], |
|
|
buf[8]); |
|
| 1631 |
} |
} |
| 1632 |
else |
else |
| 1633 |
{ |
{ |
| 1635 |
if (cr) |
if (cr) |
| 1636 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
| 1637 |
cr = 0; |
cr = 0; |
| 1638 |
printf("◆%s (%02X %02X %02X %02X %02X %02X %02X %02X )\n", |
log_printf(ofp, |
| 1639 |
hash, |
"◆%s (%02X %02X %02X %02X %02X %02X %02X %02X )\n", |
| 1640 |
buf[0], buf[1], buf[2], buf[3], |
hash, |
| 1641 |
buf[4], buf[5], buf[6], buf[7]); |
buf[0], buf[1], buf[2], buf[3], |
| 1642 |
if (ofp) |
buf[4], buf[5], buf[6], buf[7]); |
|
fprintf(ofp, |
|
|
"◆%s (%02X %02X %02X %02X %02X %02X %02X %02X )\n", |
|
|
hash, |
|
|
buf[0], buf[1], buf[2], buf[3], |
|
|
buf[4], buf[5], buf[6], buf[7]); |
|
| 1643 |
#endif |
#endif |
| 1644 |
} |
} |
| 1645 |
} |
} |
|
|
Legend:
| Removed from v.23 |
|
| changed lines |
| |
Added in v.24 |
|
|
| |