home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / SHAR324X.ZIP / SHAR.DIF < prev    next >
Text File  |  1990-06-05  |  10KB  |  381 lines

  1. diff -cbBw orig/shar.c shar.c
  2. *** orig/shar.c    Sun May 20 23:38:18 1990
  3. --- shar.c    Sun May 20 23:53:28 1990
  4. ***************
  5. *** 120,125 ****
  6. --- 120,128 ----
  7.    */
  8.   
  9.   #include <stdio.h>
  10. + #ifdef MSDOS
  11. + #include <stdlib.h>
  12. + #endif
  13.   #include <sys/types.h>
  14.   #include <time.h>
  15.   #include <sys/stat.h>
  16. ***************
  17. *** 180,185 ****
  18. --- 183,189 ----
  19.   #define DeBug(f,v)        /* do nothing */
  20.   #endif
  21.   
  22. + char *SHAR;
  23.   FILE *fpout = stdout;
  24.   char *Rname();            /* file restore name */
  25.   unsigned limit = 0;
  26. ***************
  27. *** 204,209 ****
  28. --- 208,217 ----
  29.   extern int optind;
  30.   extern char *optarg;
  31.   
  32. + #ifdef MSDOS
  33. +     putenv("_POSIX_OPTION_ORDER=TRUE"); /* for GNU getopt */
  34. + #endif
  35.           while((c = getopt(argc,argv,"VSvwd:btCxXcfMpPas:n:l:L:o:h")) != -1)
  36.       {
  37.           switch(c)
  38. ***************
  39. *** 311,316 ****
  40. --- 319,326 ----
  41.           }
  42.       }
  43.   
  44. +         SHAR = argv[0];
  45. +  
  46.       if(Vanilla)
  47.       {
  48.           fprintf(stderr,"Vanilla mode disabling years of progress :-)\n");
  49. ***************
  50. *** 357,363 ****
  51.   
  52.       if(optind >= argc)
  53.       {
  54. -         fprintf(stderr,"shar: No input files\n");
  55.           helpuser();
  56.           exit(1);
  57.       }
  58. --- 367,372 ----
  59. ***************
  60. *** 421,427 ****
  61. --- 430,444 ----
  62.                   continue;
  63.               }
  64.           }
  65. + #ifdef MSDOS
  66. +                 if ( *argv[optind] != 0 )
  67. +             status += shar(argv[optind]);
  68. +             
  69. +         optind++;
  70. + #else        
  71.           status += shar(argv[optind++]);
  72. + #endif
  73.       }
  74.   
  75.       /* delete the sequence file, if any */
  76. ***************
  77. *** 555,562 ****
  78. --- 572,583 ----
  79.           /* at this point I check to see that this is a regular file */
  80.           if(status != S_IFREG)
  81.           { /* this is not a regular file */
  82. + #ifdef MSDOS
  83. +                         *argv[i] = 0;
  84. + #else
  85.               fprintf(stderr,"shar: %s is not a regular file\n",argv[i]);
  86.               return(1);
  87. + #endif            
  88.           }
  89.       }
  90.   
  91. ***************
  92. *** 587,592 ****
  93. --- 608,616 ----
  94.       fputs(submitter,fpout);
  95.       fputs("\n",fpout);
  96.   
  97. + #if defined(MSDOS)
  98. +     getcwd(s128, sizeof(s128));
  99. + #else
  100.   #if defined(SYS5)
  101.       if(!(fpsource = popen("/bin/pwd","r")))
  102.           return(-1);
  103. ***************
  104. *** 600,605 ****
  105. --- 624,630 ----
  106.   #include "Need_conditional_compile_fix"
  107.   #endif
  108.   #endif
  109. + #endif
  110.       fprintf(fpout,"# Source directory %s\n",s128);
  111.   
  112.       fprintf(fpout,"#\n# existing files %s be overwritten\n",
  113. ***************
  114. *** 636,641 ****
  115. --- 661,670 ----
  116.                strcmp(argv[i],"-t") == 0 ||
  117.                strcmp(argv[i],"-C") == 0))
  118.               continue;
  119. + #ifdef MSDOS
  120. +             if ( *argv[i] == 0 )
  121. +               continue;
  122. + #endif
  123.           stat(argv[i],&fst);
  124.           fst.st_mode &= ~(07000); /* turn off setuid, setgid and sticky bits */
  125.           fprintf(fpout,"# %6ld %s %s\n",fst.st_size,
  126. ***************
  127. *** 801,810 ****
  128.   
  129.       if(Binary)
  130.       { /* fork a uuencode process */
  131.           static int pid,pipex[2];
  132.   
  133.           pipe(pipex);
  134. -         fflush(fpout);
  135.   
  136.           if(pid = fork())
  137.           { /* parent, create a file to read */
  138. --- 830,869 ----
  139.   
  140.       if(Binary)
  141.       { /* fork a uuencode process */
  142. +         fflush(fpout);
  143. +         filetype = (Compress ? "Compressed" : "Binary");
  144. + #ifdef MSDOS
  145. +         if ( Compress )
  146. +         {
  147. +           if ( _osmode == DOS_MODE )
  148. +           {
  149. +             char temp[128];
  150. +             
  151. +             strcpy(temp, "~CXXXXXX");
  152. +             Mktemp(temp);
  153. +                 sprintf (line, "compress <%s >%s", file, temp);
  154. +                 system(line);
  155. +                 
  156. +                 sprintf (line, "uuencode %s shar3_cmp_.tmp", temp);
  157. +             fpsource = popen (line, "r");
  158. +             unlink(temp);
  159. +           }
  160. +           else
  161. +           {
  162. +                 sprintf (line, "compress <%s | uuencode shar3_cmp_.tmp", file);
  163. +             fpsource = popen (line, "r");
  164. +               }
  165. +             }
  166. +         else
  167. +         {
  168. +               sprintf (line, "uuencode %s %s", file, file);
  169. +           fpsource = popen (line, "r");
  170. +         }
  171. + #else
  172.           static int pid,pipex[2];
  173.   
  174.           pipe(pipex);
  175.   
  176.           if(pid = fork())
  177.           { /* parent, create a file to read */
  178. ***************
  179. *** 815,821 ****
  180.               }
  181.               close(pipex[1]);
  182.               fpsource = fdopen(pipex[0],"r");
  183. -             filetype = (Compress ? "Compressed" : "Binary");
  184.           }
  185.           else
  186.           { /* start writing the pipe with encodes */
  187. --- 874,879 ----
  188. ***************
  189. *** 839,844 ****
  190. --- 897,903 ----
  191.                   fclose(fpsource);
  192.               exit(0);
  193.           }
  194. + #endif        
  195.       }
  196.       else
  197.       {
  198. ***************
  199. *** 992,997 ****
  200. --- 1051,1061 ----
  201.               }
  202.           }
  203.   
  204. + #ifdef MSDOS
  205. +             if ( Binary )
  206. +                 (void) pclose(fpsource);
  207. +             else
  208. + #endif
  209.           (void) fclose(fpsource);
  210.   
  211.           if(line[strlen(line) - 1] != '\n')
  212. ***************
  213. *** 1067,1073 ****
  214.       }
  215.       else
  216.       {
  217. !         fprintf(stderr,"shar: Can't open %s (%s): ",file,filetype);
  218.           perror("");
  219.           return(1);
  220.       }
  221. --- 1131,1137 ----
  222.       }
  223.       else
  224.       {
  225. !         fprintf(stderr,"shar: Can't open '%s' (%s): ",file,filetype);
  226.           perror("");
  227.           return(1);
  228.       }
  229. ***************
  230. *** 1107,1113 ****
  231.   {
  232.       "-V  produce \"vanilla\" shars demanding little of the unshar environment",
  233.       "-v  verbose messages OFF while executing",
  234. !     "-w  don't check with 'wc -c' after unpack",
  235.       "-n  Name of archive (documentation)",
  236.       "-a  Generate Submitted-by: & Archive-name: headers",
  237.       "-s  override automatically determined submitter name",
  238. --- 1171,1177 ----
  239.       {
  240.           "  -V  produce \"vanilla\" shars demanding little of the unshar environment",
  241.           "  -v  verbose messages OFF while executing",
  242. !         "  -w  don't check with \"wc -c\" after unpack",
  243.           "  -n  Name of archive (documentation)",
  244.           "  -a  Generate Submitted-by: & Archive-name: headers",
  245.           "  -s  override automatically determined submitter name",
  246. ***************
  247. *** 1130,1136 ****
  248.       "-LXX    limit output file size to XXk bytes (may split files)",
  249.       "-S      read files to wrap from stdin, ignoring argument line",
  250.       "\nThe -S option reads filenames one per line from stdin; input",
  251. !     "format must be similar to 'find' output, except that if -p",
  252.       "is specified, -b, -t or -C may be used (on lines by themselves)",
  253.       "e.g., find . -type f -print | sort | shar -C -L50 -o /tmp/big",
  254.       "\nThe 'o' option is required if the 'l' or 'L' option is used",
  255. --- 1194,1200 ----
  256.           "  -LXX    limit output file size to XXk bytes (may split files)",
  257.           "  -S      read files to wrap from stdin, ignoring argument line",
  258.           "\nThe -S option reads filenames one per line from stdin; input",
  259. !         "format must be similar to \"find\" output, except that if -p",
  260.           "is specified, -b, -t or -C may be used (on lines by themselves)",
  261.           "e.g., find . -type f -print | sort | shar -C -L50 -o /tmp/big",
  262.           "\nThe 'o' option is required if the 'l' or 'L' option is used",
  263. ***************
  264. *** 1145,1154 ****
  265.   helpuser()
  266.   {                /* output a command format message */
  267.       register char **ptr;
  268. !     fprintf(stderr,
  269. !         "shar %s\nusage: shar [ options ] file [ file1 ... ] ]\n",revision);
  270.       for(ptr = helpinfo; *ptr; ptr++)
  271. !         fprintf(stderr,"%s\n",*ptr);
  272.   
  273.       exit(1);
  274.   }
  275. --- 1209,1220 ----
  276.   helpuser()
  277.   {                /* output a command format message */
  278.           register char **ptr;
  279. !     printf("\n%s %s\n\nUsage: %s [ options ] file [ file1 ... ] ]\n\n",
  280. !             SHAR,SHAR,revision);
  281. !         
  282.       for(ptr = helpinfo; *ptr; ptr++)
  283. !                 printf("%s\n",*ptr);
  284.   
  285.       exit(1);
  286.   }
  287. diff -cbBw orig/whowhere.c whowhere.c
  288. *** orig/whowhere.c    Sun May 20 23:38:18 1990
  289. --- whowhere.c        Sun May 20 23:45:38 1990
  290. ***************
  291. *** 11,17 ****
  292. --- 11,21 ----
  293.   
  294.   #include <stdio.h>
  295.   #include <sys/types.h>
  296. + #ifdef MSDOS
  297. + #include <stdlib.h>
  298. + #else
  299.   #include <pwd.h>
  300. + #endif
  301.   
  302.   /* assume system v unless otherwise fixed */
  303.   #if (defined(pyr) || defined(vax) || defined(sequent)) && !defined(BSD42) && !defined(SYS5)
  304. ***************
  305. *** 34,40 ****
  306. --- 38,46 ----
  307.   #include <sys/time.h>
  308.   extern int errno;
  309.   #else
  310. + #ifndef MSDOS
  311.   #include <sys/utsname.h>
  312. + #endif
  313.   #include <time.h>
  314.   #endif    /* system dependencies */
  315.   
  316. ***************
  317. *** 44,49 ****
  318. --- 50,65 ----
  319.   char *
  320.   who_am_i()
  321.   {
  322. + #ifdef MSDOS
  323. +     char *name;
  324. +     
  325. +     if ( (name = getenv("USER")) != NULL )
  326. +         return name;
  327. +     else if ( (name = getenv("MAILNAME")) != NULL )
  328. +         return name;
  329. +     else
  330. +         return "unknown";
  331. + #else
  332.       struct passwd *getpwuid();
  333.       struct passwd *passwd;
  334.       passwd = getpwuid(getuid());
  335. ***************
  336. *** 51,57 ****
  337.       if(passwd == (struct passwd *)0)
  338.           return("???");
  339.       return(passwd->pw_name);
  340.   }    /* end of who_am_i */
  341.   
  342.   /*+-------------------------------------------------------------------------
  343. --- 67,73 ----
  344.       if(passwd == (struct passwd *)0)
  345.           return("???");
  346.       return(passwd->pw_name);
  347. ! #endif
  348.   }    /* end of who_am_i */
  349.   
  350.   /*+-------------------------------------------------------------------------
  351. ***************
  352. *** 60,65 ****
  353. --- 76,86 ----
  354.   char *
  355.   where_am_i()
  356.   {
  357. + #ifdef MSDOS
  358. +     return (_osmode == DOS_MODE) ? "MS-DOS" : "OS/2";
  359. +     /* perhaps an OS/2 workstation provides an API for getting
  360. +        the node name if the LAN Manager is installed. */
  361. + #else
  362.   #if defined(M_SYS5)    /* SCO UNIX or XENIX */
  363.   FILE *fpsid = fopen("/etc/systemid","r");
  364.   static char s20[20];
  365. ***************
  366. *** 80,85 ****
  367. --- 101,107 ----
  368.       return(where_i_am);
  369.   #endif /* SYS5 */
  370.   #endif /* M_SYS5 */
  371. + #endif
  372.   }    /* end of where_am_i */
  373.   
  374.   /*+-------------------------------------------------------------------------
  375. Only in .: wild.c
  376.