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