home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / MPack1_2_1.lha / MPack / src / unixunpk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-05  |  2.1 KB  |  87 lines

  1. /* (C) Copyright 1993 by John G. Myers
  2.  * All Rights Reserved.
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software
  5.  * and its documentation for any purpose is hereby granted without
  6.  * fee, provided that the above copyright notice appear in all copies
  7.  * and that both that copyright notice and this permission notice
  8.  * appear in supporting documentation, and that the name of John G.
  9.  * Myers not be used in advertising or publicity pertaining to
  10.  * distribution of the software without specific, written prior
  11.  * permission.  John G. Myers makes no representations about the
  12.  * suitability of this software for any purpose.  It is provided "as
  13.  * is" without express or implied warranty.
  14.  *
  15.  * JOHN G. MYERS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  16.  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17.  * FITNESS, IN NO EVENT SHALL JOHN G. MYERS BE LIABLE FOR ANY SPECIAL,
  18.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  19.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
  21.  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23. #include <stdio.h>
  24. #include "version.h"
  25.  
  26. extern int optind;
  27. extern char *optarg;
  28.  
  29. extern int overwrite_files;
  30.  
  31. main(argc, argv)
  32. int argc;
  33. char **argv;
  34. {
  35.     int opt;
  36.     FILE *file;
  37.     
  38.     while ((opt = getopt(argc, argv, "fC:")) != EOF) {
  39.     switch (opt) {
  40.     case 'f':
  41.         overwrite_files = 1;
  42.         break;
  43.  
  44.     case 'C':
  45.         if (chdir(optarg)) {
  46.         perror(optarg);
  47.         exit(1);
  48.         }
  49.         break;
  50.  
  51.     default:
  52.         usage();
  53.     }
  54.     }
  55.  
  56.     if (optind == argc) {
  57.     fprintf(stderr, "munpack: reading from standard input\n");
  58.     handleMessage(stdin, "text/plain", 0);
  59.     exit(0);
  60.     }
  61.  
  62.     while (argv[optind]) {
  63.     file = fopen(argv[optind], "r");
  64.     if (!file) {
  65.         perror(argv[optind]);
  66.     }
  67.     else {
  68.         handleMessage(file, "text/plain", 0);
  69.         fclose(file);
  70.     }
  71.     optind++;
  72.     }
  73.     exit(0);
  74. }
  75.  
  76. usage() {
  77.     fprintf(stderr, "munpack version %s\n", MPACK_VERSION);
  78.     fprintf(stderr, "usage: munpack [-C directory] [files...]\n");
  79.     exit(1);
  80. }
  81.  
  82. warn(s)
  83. char *s;
  84. {
  85.     fprintf(stderr, "munpack: warning: %s\n", s);
  86. }
  87.