* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static const char copyright[] =
+__used static const char copyright[] =
"@(#) Copyright (c) 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/compress/compress.c,v 1.21 2003/06/14 13:41:31 trhodes Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/compress/compress.c,v 1.23 2010/12/11 08:32:16 joel Exp $");
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <sys/attr.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <locale.h>
#include "zopen.h"
exit (eval);
}
- if (cat == 1 && argc > 1)
- errx(1, "the -c option permits only a single file argument");
+ /*
+ * The UNIX standard requires that `uncompress -c` be able to have multiple file parameters given.
+ */
for (; *argv; ++argv)
switch(style) {
{
size_t nr;
struct stat isb, sb;
- FILE *ifp, *ofp;
+ FILE *ifp = NULL, *ofp = NULL;
int exists, isreg, oreg;
u_char buf[1024];
}
isreg = oreg = !exists || S_ISREG(sb.st_mode);
- ifp = ofp = NULL;
if ((ifp = fopen(in, "r")) == NULL) {
cwarn("%s", in);
return;
}
isreg = oreg = !exists || S_ISREG(sb.st_mode);
- ifp = ofp = NULL;
+ ofp = NULL;
if ((ifp = zopen(in, "r", bits)) == NULL) {
cwarn("%s", in);
return;
void
setfile(const char *name, struct stat *fs)
{
- static struct timeval tv[2];
+ struct attrlist ts_req = {};
+ struct {
+ struct timespec mtime;
+ struct timespec atime;
+ } set_ts;
fs->st_mode &= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
- TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
- TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
- if (utimes(name, tv))
- cwarn("utimes: %s", name);
+ ts_req.bitmapcount = ATTR_BIT_MAP_COUNT;
+ ts_req.commonattr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME;
+ set_ts.mtime = fs->st_mtimespec;
+ set_ts.atime = fs->st_atimespec;
+
+ if (setattrlist(name, &ts_req, &set_ts, sizeof(set_ts), 0))
+ cwarn("setattrlist: %s", name);
/*
* Changing the ownership probably won't succeed, unless we're root
permission(const char *fname)
{
int ch, first;
+ char resp[] = {'\0', '\0'};
if (!isatty(fileno(stderr)))
return (0);
(void)fprintf(stderr, "overwrite %s? ", fname);
+
+ /* Load user specified locale */
+ setlocale(LC_MESSAGES, "");
+
first = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
- return (first == 'y');
+
+ /* only care about first character */
+ resp[0] = first;
+
+ return (rpmatch(resp) == 1);
}
void
"usage: compress [-cfv] [-b bits] [file ...]\n");
else
(void)fprintf(stderr,
- "usage: uncompress [-cfv] [-b bits] [file ...]\n");
+ "usage: uncompress [-cfv] [file ...]\n");
exit(1);
}