[BACK]Return to main.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / compress

Diff for /src/usr.bin/compress/main.c between version 1.102 and 1.103

version 1.102, 2022/10/22 14:41:27 version 1.103, 2022/10/23 19:06:35
Line 61 
Line 61 
         const char *name;          const char *name;
         const char *suffix;          const char *suffix;
         const u_char *magic;          const u_char *magic;
         const char *comp_opts;          const char *opts;
         const char *decomp_opts;  
         const char *cat_opts;  
         void *(*ropen)(int, char *, int);          void *(*ropen)(int, char *, int);
         int (*read)(void *, char *, int);          int (*read)(void *, char *, int);
 #ifndef SMALL  #ifndef SMALL
Line 78 
Line 76 
                 ".gz",                  ".gz",
                 "\037\213",                  "\037\213",
                 "123456789ab:cdfhkLlNnOo:qrS:tVv",                  "123456789ab:cdfhkLlNnOo:qrS:tVv",
                 "cfhkLlNno:qrtVv",  
                 "fhqr",  
                 gz_ropen,                  gz_ropen,
                 gz_read,                  gz_read,
 #ifndef SMALL  #ifndef SMALL
Line 95 
Line 91 
                 ".Z",                  ".Z",
                 "\037\235",                  "\037\235",
                 "123456789ab:cdfghlNnOo:qrS:tv",                  "123456789ab:cdfghlNnOo:qrS:tv",
                 "cfhlNno:qrtv",  
                 "fghqr",  
                 z_ropen,                  z_ropen,
                 zread,                  zread,
                 z_wopen,                  z_wopen,
Line 109 
Line 103 
                 ".zip",                  ".zip",
                 "PK",                  "PK",
                 NULL,                  NULL,
                 "cfhkLlNno:qrtVv",  
                 "fhqr",  
                 zip_ropen,                  zip_ropen,
                 zip_read,                  zip_read,
                 NULL,                  NULL,
Line 127 
Line 119 
         ".nul",          ".nul",
         "XX",          "XX",
         "123456789ab:cdfghlNnOo:qrS:tv",          "123456789ab:cdfghlNnOo:qrS:tv",
         "cfhlNno:qrtv",  
         "fghqr",  
         null_ropen,          null_ropen,
         null_read,          null_read,
         null_wopen,          null_wopen,
Line 137 
Line 127 
 };  };
 #endif /* SMALL */  #endif /* SMALL */
   
 int permission(const char *);  static int permission(const char *);
 __dead void usage(int);  static __dead void usage(int);
 int docompress(const char *, char *, const struct compressor *,  static int docompress(const char *, char *, const struct compressor *,
     int, struct stat *);      int, struct stat *);
 int dodecompress(const char *, char *, struct stat *);  static int dodecompress(const char *, char *, struct stat *);
 const struct compressor *check_method(int);  static const char *check_suffix(const char *);
 const char *check_suffix(const char *);  static char *set_outfile(const char *, char *, size_t);
 char *set_outfile(const char *, char *, size_t);  static void list_stats(const char *, const struct compressor *,
 void list_stats(const char *, const struct compressor *, struct z_info *);      struct z_info *);
 void verbose_info(const char *, off_t, off_t, u_int32_t);  static void verbose_info(const char *, off_t, off_t, u_int32_t);
   
 const struct option longopts[] = {  
 #ifndef SMALL  #ifndef SMALL
   const struct option longopts[] = {
         { "ascii",      no_argument,            0, 'a' },          { "ascii",      no_argument,            0, 'a' },
         { "stdout",     no_argument,            0, 'c' },          { "stdout",     no_argument,            0, 'c' },
         { "to-stdout",  no_argument,            0, 'c' },          { "to-stdout",  no_argument,            0, 'c' },
Line 170 
Line 160 
         { "version",    no_argument,            0, 'V' },          { "version",    no_argument,            0, 'V' },
         { "fast",       no_argument,            0, '1' },          { "fast",       no_argument,            0, '1' },
         { "best",       no_argument,            0, '9' },          { "best",       no_argument,            0, '9' },
 #endif /* SMALL */  
         { NULL }          { NULL }
 };  };
   #else /* SMALL */
   const struct option *longopts = NULL;
   #endif /* SMALL */
   
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
Line 202 
Line 194 
                 method = M_COMPRESS;                  method = M_COMPRESS;
 #endif /* SMALL */  #endif /* SMALL */
         }          }
         optstr = method->comp_opts;          optstr = method->opts;
   
         decomp = 0;          decomp = 0;
         pmode = MODE_COMP;          pmode = MODE_COMP;
Line 617 
Line 609 
 #endif  #endif
 }  }
   
 const struct compressor *  static const struct compressor *
 check_method(int fd)  check_method(int fd)
 {  {
         const struct compressor *method;          const struct compressor *method;
Line 640 
Line 632 
         return (NULL);          return (NULL);
 }  }
   
 int  static int
 dodecompress(const char *in, char *out, struct stat *sb)  dodecompress(const char *in, char *out, struct stat *sb)
 {  {
         const struct compressor *method;          const struct compressor *method;
Line 690 
Line 682 
                 return (FAILURE);                  return (FAILURE);
         }          }
         if (storename && oldname[0] != '\0') {          if (storename && oldname[0] != '\0') {
                 char *oldbase = basename(oldname);                  const char *oldbase = basename(oldname);
                 char *cp = strrchr(out, '/');                  char *cp = strrchr(out, '/');
                 if (cp != NULL) {                  if (cp != NULL) {
                         *(cp + 1) = '\0';                          *(cp + 1) = '\0';
Line 834 
Line 826 
                 warn("futimens: %s", name);                  warn("futimens: %s", name);
 }  }
   
 int  static int
 permission(const char *fname)  permission(const char *fname)
 {  {
         int ch, first;          int ch, first;
Line 851 
Line 843 
 /*  /*
  * Check infile for a known suffix and return the suffix portion or NULL.   * Check infile for a known suffix and return the suffix portion or NULL.
  */   */
 const char *  static const char *
 check_suffix(const char *infile)  check_suffix(const char *infile)
 {  {
         int i;          int i;
Line 878 
Line 870 
  * Set outfile based on the suffix.  In most cases we just strip   * Set outfile based on the suffix.  In most cases we just strip
  * off the suffix but things like .tgz and .taz are special.   * off the suffix but things like .tgz and .taz are special.
  */   */
 char *  static char *
 set_outfile(const char *infile, char *outfile, size_t osize)  set_outfile(const char *infile, char *outfile, size_t osize)
 {  {
         const char *s;          const char *s;
Line 905 
Line 897 
 /*  /*
  * Print output for the -l option.   * Print output for the -l option.
  */   */
 void  static void
 list_stats(const char *name, const struct compressor *method,  list_stats(const char *name, const struct compressor *method,
     struct z_info *info)      struct z_info *info)
 {  {
Line 954 
Line 946 
         }          }
 }  }
   
 void  static void
 verbose_info(const char *file, off_t compressed, off_t uncompressed,  verbose_info(const char *file, off_t compressed, off_t uncompressed,
     u_int32_t hlen)      u_int32_t hlen)
 {  {
Line 973 
Line 965 
             (long long)(decomp ? uncompressed : compressed));              (long long)(decomp ? uncompressed : compressed));
 }  }
   
 __dead void  static __dead void
 usage(int status)  usage(int status)
 {  {
         const bool gzip = (__progname[0] == 'g');          const bool gzip = (__progname[0] == 'g');

Legend:
Removed from v.1.102  
changed lines
  Added in v.1.103