home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / FIDO / PUP_V2B.ZIP / 2A-TO-2B.C next >
Encoding:
C/C++ Source or Header  |  1988-01-28  |  1.4 KB  |  67 lines

  1.  
  2. #include <puppy.h>
  3.  
  4. struct _time {
  5.     BYTE year;
  6.     BYTE month;
  7.     BYTE day;
  8.     BYTE hour;
  9.     BYTE minute;
  10.     BYTE second;
  11. };
  12.  
  13. struct _oldmsg {
  14.     char from[36];        /* who from, */
  15.     char to[36];        /* who to, */
  16.     char subj[36];        /* message subject, */
  17.     struct _time time;
  18.     WORD attr;        /* attribute bits (see below) */
  19.     WORD topic;        /* topic selection(s) */
  20.     WORD topic_map;        /* shared topics */
  21. };
  22.  
  23. main() {
  24. int i;
  25. struct _oldmsg msg;
  26. struct _msg *m;
  27. long pos;
  28.  
  29.     printf("converts Pup 2a message base to Pup 2b message base (very quickly)\r\n");
  30.     i= open("puppy.idx",2);
  31.     if (i == -1) return;
  32.  
  33.     pos= 0L;
  34.     m= (struct _msg *) &msg;
  35.     while (read(i,&msg,sizeof(struct _oldmsg))) {
  36.         if (m-> extra != 0) {
  37.             m-> date= ((msg.time.year - 80) << 9) | ((msg.time.month) << 5) | (msg.time.day);
  38.             m-> time= (msg.time.hour << 11) | (msg.time.minute << 5);
  39.             m-> extra= 0;
  40.         }
  41.         prdate(m-> date); printf(" "); prtime(m-> time); printf("\r\n");
  42.         lseek(i,pos,0);
  43.         write(i,&msg,sizeof(struct _msg));
  44.         pos += sizeof(struct _oldmsg);
  45.     }
  46.     close(i);
  47. }
  48. /* Display the date. */
  49.  
  50. prdate(t)
  51. WORD t;
  52. {
  53.     printf("%02u-%02d-%02u",        /* the format, */
  54.         (t >> 5) & 0x0f,            /* the month */
  55.         t & 0x1f,                /* the day, */
  56.         ((t >> 9) & 0x3f) + 80);        /* the year */
  57. }
  58.  
  59. /* Display the time. */
  60.  
  61. prtime(t)
  62. WORD t;
  63. {
  64.     printf("%d:%02d",t >> 11,(t >> 5) & 0x3f);
  65. }
  66.  
  67.