Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/mty-makai/mty.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23 by notanpe, Sat Mar 17 10:23:30 2007 UTC revision 24 by chapuni, Sat Mar 17 12:11:18 2007 UTC
# Line 17  Line 17 
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>
# Line 1361  usec() Line 1363  usec()
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   *      メインループとか   *      メインループとか
# Line 1515  main(int argc, char *argv[]) Line 1533  main(int argc, char *argv[])
1533    assert(!((ptrdiff_t)&key64 & (sizeof(WS_T) - 1)));    assert(!((ptrdiff_t)&key64 & (sizeof(WS_T) - 1)));
1534    assert(!((ptrdiff_t)&param64 & (sizeof(WS_T) - 1)));    assert(!((ptrdiff_t)&param64 & (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;
# Line 1598  main(int argc, char *argv[]) Line 1621  main(int argc, char *argv[])
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                                  {                                  {
# Line 1619  main(int argc, char *argv[]) Line 1635  main(int argc, char *argv[])
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

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26