home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / network / dlgtin.lha / source / doarchive.c next >
Encoding:
C/C++ Source or Header  |  1992-08-23  |  1.6 KB  |  82 lines

  1. /*
  2.     Doarchive - news bundling for TIN / DLG
  3.  
  4.   Reads the users user.data file to determine the archiver type. [If
  5.   you add different archivers to your system you will have to modify
  6.   this program to reflect your changes]
  7.  
  8.   News articles saved from within TIN [to $HOME/News] are archived with
  9.   the appropriate archiver and called MESSAGES.lzh|zoo|arc
  10.  
  11. */
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <exec/types.h>
  15. #include <libraries/dosextens.h>
  16.  
  17.  
  18. main(argc,argv)
  19. int     argc;
  20. char     *argv[];
  21.  
  22. {
  23. int        items,
  24.         success;
  25. unsigned short    counter;
  26. char        filename[80],
  27.         command[80],
  28.         pattern[5],
  29.         suffix[5],
  30.         userdata[70];
  31. FILE         *userfile;
  32. BOOL        done;
  33.  
  34. strcpy(filename,"user:");
  35. strcat(filename,argv[1]);
  36. strcat(filename,"/user.data");
  37. if ((userfile = fopen(filename,"rb"))==NULL)
  38.     {
  39.     perror("Unable to open user.data file");
  40.      return(1);
  41.     }
  42. items = fread(&userdata,67,1,userfile);
  43. counter = userdata[65];
  44. if ((counter > 0) && (counter < 4))
  45.     {
  46.     switch (counter)
  47.         {
  48.         case 1    :
  49.             {
  50.             strcpy(command,"arc a user:");
  51.             strcpy(pattern,"*");
  52.             strcpy(suffix,"");
  53.             break;
  54.             }
  55.         case 2    :
  56.             {
  57.             strcpy(command,"zoo a user:");
  58.             strcpy(pattern,"*");
  59.             strcpy(suffix,"");
  60.             break;
  61.             }
  62.         case 3    :
  63.             {
  64.             strcpy(command,"lharc a -r -0 user:");
  65.             strcpy(pattern,"#?");
  66.             strcpy(suffix,".LZH");
  67.             break;
  68.             }
  69.         }
  70.     strcat(command,argv[1]);
  71.     strcat(command,"/news/");
  72.     strcat(command,"messages");
  73.     strcat(command,suffix);
  74.     strcat(command," user:");
  75.     strcat(command,argv[1]);
  76.     strcat(command,"/news/");
  77.     strcat(command,pattern);
  78.     success = Execute(command,0,0);
  79.     return(0);
  80.     }
  81. return(1);
  82. }