home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / WWIVMODS / MODSUNKN.ZIP / WWIV2ZIP.MOD < prev    next >
Text File  |  1992-01-29  |  6KB  |  144 lines

  1. WWIV2ZIP.C Source code --- Finally!!
  2.  
  3. /*------------------------------------------------------------*/
  4. /* Bilbo Baggin's WWIV TO ZIP conversion utility. Version 1.0 */
  5. /*          Released to the Public Domain on 3-17-89          */
  6. /*------------------------------------------------------------*/
  7. /*                                                            */
  8. /* Sorry I didn't get this out as son as promised, but a tiny */
  9. /* mistake on my part (and Turbo C's) caused me one heck of   */
  10. /* a lot of searching for the tiniest of bugs. It seems that  */
  11. /* omitting IO.H does not cause a compiler error, though it   */
  12. /* certainly should! Try it for laughs.                       */
  13. /*                                                            */
  14. /* You may not need this now, since Doug Field's blatantly    */
  15. /* stole my idea, but it may be good for future reference in  */
  16. /* case there is need for further conversion.                 */
  17. /*                                                            */
  18. /* Please note that I give this source code freely and w/o    */
  19. /* obligation on your part or mine. You accept all risks of   */
  20. /* using this program and I expect nothing in return if you   */
  21. /* use it, other than a "Thanks, Bilbo." if you feel so       */
  22. /* inclined.                                                  */
  23. /*                                                            */
  24. /* Note that the programming here is not 100% efficient and   */
  25. /* you may want to tidy some things up, but for the most part */
  26. /* it's good enuff. What do you want for free?? Hehehehe!!!!  */
  27. /*                                                            */
  28.  
  29.  
  30. #include <stdio.h>
  31. #include <fcntl.h>
  32. #include <ctype.h>
  33. #include <stdlib.h>
  34. #include <io.h>
  35.  
  36. /* DATA HELD FOR EVERY UPLOAD */
  37. typedef struct {
  38.         char            filename[13],           /* filename */
  39.                         description[59],        /* file description */
  40.                         date[9],                /* date u/l'ed */
  41.                         upby[46];               /* name of upload user */
  42.         unsigned char   filetype;               /* file type for apples */
  43.         unsigned short  numdloads,              /* number times d/l'ed */
  44.                         ownersys,ownerusr,      /* who uploaded it */
  45.                         mask;                   /* file type mask */
  46.         unsigned long   daten,                  /* date uploaded */
  47.                         numbytes;               /* number bytes long file is */
  48. } uploadsrec;
  49.  
  50.  
  51. makefile(fn1,fn2,subdir)
  52.  
  53.    char fn1[14],fn2[14],subdir[40];
  54.  
  55. {
  56.    static int     fp,fq,fr,i,j;
  57.    static uploadsrec up;
  58.    static uploadsrec new_up;
  59.    static long   thisrec, reccnt;
  60.    static char     str[13],s[54];
  61.  
  62.      reccnt = 0;
  63.      fr=open(fn1, (O_BINARY));
  64.      fp=open(fn2,( O_CREAT | O_APPEND | O_BINARY ));
  65.      thisrec = filelength(fr) / (long)sizeof(uploadsrec);
  66.      while (reccnt < thisrec)
  67.      {
  68.          lseek(fr, (reccnt) * (long)sizeof(uploadsrec), SEEK_SET);
  69.          read(fr, (void *)(&up), sizeof(uploadsrec));
  70.          strcpy(s,"                                                    ");
  71.          strcpy(s,subdir);
  72.          j = 0;
  73.          strcpy(str,"            ");
  74.          for (i=0;i<9 ;i++ )  {
  75.              if (up.filename[i] != ' '){
  76.                 str[j] = up.filename[i] ;
  77.                 j++;
  78.                 }
  79.              new_up.filename[i]    =    up.filename[i];
  80.          }
  81.          new_up.filename[9]     =    'Z';
  82.          new_up.filename[10]    =    'I';
  83.          new_up.filename[11]    =    'P';
  84.          str[j] = 'Z';
  85.          str[j+1] = 'I';
  86.          str[j+2] = 'P';
  87.          strcat(s,str);
  88.          printf("Searching for file %s\n",str);
  89.  
  90.          fq=open(s,O_RDONLY | O_BINARY);
  91.  
  92.          new_up.numbytes = filelength(fq) ;
  93.          if (fq<0) {
  94.           printf("DOS error - File not found.\n\n");
  95.           new_up.numbytes = 0 ;
  96.          }
  97.          close(fq);
  98.          if (reccnt == 0 )
  99.            new_up.numbytes = up.numbytes ;
  100.  
  101.          for (i=0;i<53 ;i++ )
  102.              new_up.description[i] =    up.description[i];
  103.          for (i=0;i<8 ;i++ )
  104.              new_up.date[i]        =    up.date[i];
  105.          for (i=0;i<45 ;i++ )
  106.              new_up.upby[i]        =    up.upby[i];
  107.          new_up.filetype    =    up.filetype;
  108.          new_up.numdloads   =    up.numdloads;
  109.          new_up.ownersys    =    up.ownersys;
  110.          new_up.ownerusr    =    up.ownerusr;
  111.          new_up.mask        =    up.mask;
  112.          new_up.daten       =    up.daten;
  113.          write(fp, (void *)(&new_up), sizeof(uploadsrec));
  114.          reccnt++;
  115.      }
  116.      close(fp);
  117.      close(fr);
  118. }
  119.  
  120. main()
  121. {
  122.    char s[13],s1[13],subdir[40];
  123.    char answer[2];
  124.  
  125.    printf("Welcome to Bilbo Baggins' WWIV to ZIP conversion program!!\n\n");
  126.    printf("Contact me at 1@7303 if you have questions/problems.\n\n\n");
  127.    do {
  128.    printf("Enter the name of the .DIR file you want converted, \n\n");
  129.    printf("Enter filename ONLY (ie NO extension) :");
  130.    scanf("%s",&s);
  131.    printf("Enter drive/directory the ZIPs are in ( ex. D:\\GAMES\\NEW\\ ) :");
  132.    scanf("%s",&subdir);
  133.    strcpy(s1,s);
  134.    strcat(s,".DIR");
  135.    strcat(s1,".NEW");
  136.    printf("Converting %s to %s ...",s,s1);
  137.    makefile(&s,&s1,&subdir);
  138.    printf("Convert another .DIR file ?? ");
  139.    scanf("%s",&answer);
  140.    } while (toupper(answer[0]) == 'Y' );
  141. }
  142.  
  143. _______________________________________________________________________________
  144.