Use err(3). Use An/Aq for author name.

This commit is contained in:
Philippe Charnier 1997-09-17 06:24:58 +00:00
parent d82e5f5287
commit 873c7a4e8f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29526
11 changed files with 97 additions and 92 deletions

View File

@ -10,7 +10,7 @@
.\"
.\" CTM and ctm(1) by <phk@login.dknet.dk>
.\"
.\" $Id$
.\" $Id: ctm.1,v 1.12 1997/02/22 16:05:19 peter Exp $
.\"
.Dd Mar 25, 1995
.Os
@ -28,7 +28,7 @@
.Op Fl T Ar tmpdir
.Op Fl V Ar level
.Op Fl x Ar exclude-regex
.Ar file...
.Ar
.Sh DESCRIPTION
.Nm Ctm
was originally
@ -46,7 +46,7 @@ entirely different things.
.Ss Usage
To apply a CTM delta, you pass it to the
.Nm ctm
.Nm
command. You can pass a CTM delta on stdin, or you can give the
filename as an argument. If you do the latter, you make life a lot
easier for your self, since the program can accept gzip'ed files and
@ -55,22 +55,22 @@ specify multiple deltas at one time, they will be proccessed one at a
time. Deltas that are already applied will be ignored.
The
.Nm ctm
.Nm
command runs in a number of passes. It will process the entire
input file in each pass, before commencing with the next pass.
Before working on a file
.Ar name
.Nm ctm
.Nm
first checks for the existence of the file
.Ar name.ctm .
If this file exists,
.Nm ctm
.Nm
works on it instead.
Pass 1 will verify that the input file is OK. The syntax, the data
and the global MD5 checksum will be checked. If any of these fail,
.Nm ctm
.Nm
will simply reject the input file.
Pass 2 will validate that the directory tree is in the state expected by
@ -82,7 +82,7 @@ If a
had been specified using the
.Fl B
option, all files that would be modified by this
.Nm ctm
.Nm
invocation are backed up
to this file using the archiver command specified by the
.Fl t
@ -92,7 +92,7 @@ option. The default archiver command is
Pass 3 will actually apply the delta.
The list of files that would be modified by
.Nm ctm
.Nm
is subject to filtering regular expressions specified
using the
.Fl e
@ -280,18 +280,22 @@ options.
.Sh HISTORY
Initial trials were run during the work on FreeBSD 1.1.5, and many bugs and
Initial trials were run during the work on
.Fx 1.1.5 ,
and many bugs and
methods were hashed out.
The
.Nm ctm
command appeared in FreeBSD 2.1.
.Nm
command appeared in
.Fx 2.1 .
.Sh AUTHORS
The CTM system has been designed and implemented by
Poul-Henning Kamp
.An Poul-Henning Kamp
.Aq phk@FreeBSD.org .
Joerg Wunsch wrote this man-page.
.Aq joerg@FreeBSD.org .
.An Joerg Wunsch
.Aq joerg@FreeBSD.org
wrote this man-page.

View File

@ -10,7 +10,7 @@
.\"
.\" CTM and ctm(1) by <phk@login.dknet.dk>
.\"
.\" $Id$
.\" $Id: ctm.5,v 1.5 1997/02/22 16:05:20 peter Exp $
.\"
.Dd March 25, 1995
.Os
@ -21,7 +21,7 @@
.Sh DESCRIPTION
The
.Nm ctm
.Nm
transfers data in a specific file format, called a CTM delta.
CTM deltas consist of control lines and data chunks. Each control
@ -61,7 +61,7 @@ meaning this is a UTC timestamp
.Pc .
The
.Ar prefix
This field is currently not implemented.
field is currently not implemented.
.It _END Ar md5
@ -196,15 +196,19 @@ CTM_END 74ddd298d76215ae45a077a4b6a74e9c
.Sh HISTORY
Initial trials ran during the FreeBSD 1.1.5, and many bugs and
Initial trials ran during the
.Fx 1.1.5 ,
and many bugs and
methods were hashed out.
The CTM system has been made publically available in FreeBSD 2.1.
The CTM system has been made publically available in
.Fx 2.1 .
.Sh AUTHORS
The CTM system has been designed and implemented by
Poul-Henning Kamp
.An Poul-Henning Kamp
.Aq phk@FreeBSD.org .
Joerg Wunsch wrote this man-page.
.Aq joerg@FreeBSD.org .
.An Joerg Wunsch
.Aq joerg@FreeBSD.org
wrote this man-page.

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id$
* $Id: ctm.c,v 1.16 1997/02/22 16:05:21 peter Exp $
*
* This is the client program of 'CTM'. It will apply a CTM-patch to a
* collection of files.
@ -50,8 +50,6 @@ main(int argc, char **argv)
{
int stat=0, err=0;
int c;
extern int optopt,optind;
extern char * optarg;
unsigned applied = 0;
FILE *statfile;
struct CTM_Filter *nfilter = NULL; /* new filter */
@ -90,10 +88,8 @@ main(int argc, char **argv)
case 'e': /* filter expressions */
case 'x':
if (NULL == (nfilter = Malloc(sizeof(struct CTM_Filter)))) {
fprintf(stderr,
"Out of memory for expressions: \"%s\"\n",
optarg);
stat++;
warnx("out of memory for expressions: \"%s\"", optarg);
stat++;
break;
}
@ -106,7 +102,7 @@ main(int argc, char **argv)
regerror(err, &nfilter->CompiledRegex, errmsg,
sizeof(errmsg));
fprintf(stderr, "Regular expression: \"%s\"\n", errmsg);
warnx("regular expression: \"%s\"", errmsg);
stat++;
break;
}
@ -125,21 +121,21 @@ main(int argc, char **argv)
}
break;
case ':':
fprintf(stderr,"Option '%c' requires an argument.\n",optopt);
warnx("option '%c' requires an argument",optopt);
stat++;
break;
case '?':
fprintf(stderr,"Option '%c' not supported.\n",optopt);
warnx("option '%c' not supported",optopt);
stat++;
break;
default:
fprintf(stderr,"Option '%c' not yet implemented.\n",optopt);
warnx("option '%c' not yet implemented",optopt);
break;
}
}
if(stat) {
fprintf(stderr,"%d errors during option processing\n",stat);
warnx("%d errors during option processing",stat);
return Exit_Pilot;
}
stat = Exit_Done;
@ -166,7 +162,7 @@ main(int argc, char **argv)
else
if((statfile = fopen(Buffer, "r")) == NULL) {
if (Verbose > 0)
fprintf(stderr, "Warning: %s not found.\n", Buffer);
warnx("warning: %s not found", Buffer);
} else {
fscanf(statfile, "%*s %u", &applied);
fclose(statfile);
@ -184,7 +180,7 @@ main(int argc, char **argv)
stat = Exit_OK;
if(Verbose > 0)
fprintf(stderr,"Exit(%d)\n",stat);
warnx("exit(%d)",stat);
if (FilterList)
for (nfilter = FilterList; nfilter; ) {
@ -210,13 +206,13 @@ Proc(char *filename, unsigned applied)
strcpy(p,"gunzip < ");
strcat(p,filename);
f = popen(p,"r");
if(!f) { perror(p); return Exit_Garbage; }
if(!f) { warn("%s", p); return Exit_Garbage; }
} else {
p = 0;
f = fopen(filename,"r");
}
if(!f) {
perror(filename);
warn("%s", filename);
return Exit_Garbage;
}
@ -233,7 +229,7 @@ Proc(char *filename, unsigned applied)
int i;
if(!f2) {
perror(fn);
warn("%s", fn);
fclose(f);
return Exit_Broke;
}
@ -265,7 +261,7 @@ Proc(char *filename, unsigned applied)
} else {
pclose(f);
f = popen(p,"r");
if(!f) { perror(p); return Exit_Broke; }
if(!f) { warn("%s", p); return Exit_Broke; }
}
i=Pass2(f);
@ -275,7 +271,7 @@ Proc(char *filename, unsigned applied)
} else {
pclose(f);
f = popen(p,"r");
if(!f) { perror(p); return Exit_Broke; }
if(!f) { warn("%s", p); return Exit_Broke; }
}
if(i) {
@ -300,7 +296,7 @@ Proc(char *filename, unsigned applied)
} else {
pclose(f);
f = popen(p,"r");
if(!f) { perror(p); return Exit_Broke; }
if(!f) { warn("%s", p); return Exit_Broke; }
}
}

View File

@ -6,23 +6,24 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id$
* $Id: ctm.h,v 1.12 1997/02/22 16:05:21 peter Exp $
*
*/
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <md5.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <regex.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/time.h>
#include <regex.h>
#define VERSION "2.0"
#define MAXSIZE (1024*1024*10)

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id$
* $Id: ctm_ed.c,v 1.8 1997/02/22 16:05:23 peter Exp $
*
*/
@ -21,13 +21,13 @@ ctm_edit(u_char *script, int length, char *filein, char *fileout)
fi = fopen(filein,"r");
if(!fi) {
perror(filein);
warn("%s", filein);
return 8;
}
fo = fopen(fileout,"w");
if(!fo) {
perror(fileout);
warn("%s", fileout);
fclose(fi);
return 4;
}
@ -96,17 +96,17 @@ ctm_edit(u_char *script, int length, char *filein, char *fileout)
bye:
if(fi) {
if(fclose(fi) != 0) {
perror(filein);
warn("%s", filein);
ret = 1;
}
}
if(fo) {
if(fflush(fo) != 0) {
perror(fileout);
warn("%s", fileout);
ret = 1;
}
if(fclose(fo) != 0) {
perror(fileout);
warn("%s", fileout);
ret = 1;
}
}

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id$
* $Id: ctm_pass2.c,v 1.15 1997/02/22 16:05:26 peter Exp $
*
*/
@ -209,13 +209,13 @@ Pass2(FILE *fd)
}
fprintf(ed,"e %s\n", name);
if (cnt != fwrite(trash,1,cnt,ed)) {
perror(name);
warn("%s", name);
pclose(ed);
WRONG
}
fprintf(ed,"w %s\n",p);
if (pclose(ed)) {
perror(p);
warn("%s", p);
WRONG
}
if(strcmp(md5,MD5File(p,md5_1))) {

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id$
* $Id: ctm_pass3.c,v 1.17 1997/02/22 16:05:27 peter Exp $
*
*/
@ -22,7 +22,7 @@ settime(const char *name, const struct timeval *times)
{
if (SetTime)
if (utimes(name,times)) {
fprintf(stderr, " utimes(): %s: %s\n", name, strerror(errno));
warn("utimes(): %s", name);
return -1;
}
return 0;
@ -178,11 +178,11 @@ Pass3(FILE *fd)
if(!strcmp(sp->Key,"FM") || !strcmp(sp->Key, "FS")) {
i = open(name,O_WRONLY|O_CREAT|O_TRUNC,0666);
if(i < 0) {
perror(name);
warn("%s", name);
WRONG
}
if(cnt != write(i,trash,cnt)) {
perror(name);
warn("%s", name);
WRONG
}
close(i);
@ -201,13 +201,13 @@ Pass3(FILE *fd)
}
fprintf(ed,"e %s\n",name);
if(cnt != fwrite(trash,1,cnt,ed)) {
perror(name);
warn("%s", name);
pclose(ed);
WRONG
}
fprintf(ed,"w %s\n",name);
if(pclose(ed)) {
perror("ed");
warn("ed");
WRONG
}
if(strcmp(md5,MD5File(name,md5_1))) {

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Joseph Koshy
* ----------------------------------------------------------------------------
*
* $Id$
* $Id: ctm_passb.c,v 1.3 1997/02/22 16:05:28 peter Exp $
*
*/
@ -38,7 +38,7 @@ PassB(FILE *fd)
MD5Init (&ctx);
sprintf(buf, TarCmd, BackupFile);
b=popen(buf, "w");
if(!b) { perror(buf); return Exit_Garbage; }
if(!b) { warn("%s", buf); return Exit_Garbage; }
GETFIELD(p,' '); if(strcmp("CTM_BEGIN",p)) WRONG
GETFIELD(p,' '); if(strcmp(Version,p)) WRONG
@ -117,7 +117,7 @@ PassB(FILE *fd)
/* send name to the archiver for a backup */
cnt = strlen(name);
if (cnt != fwrite(name,1,cnt,b) || EOF == fputc('\n',b)) {
perror(name);
warn("%s", name);
pclose(b);
WRONG;
}

View File

@ -471,9 +471,9 @@ turn up here too. Error messages should be self explanatory.
.\" .Sh STANDARDS
.\" .Sh HISTORY
.Sh AUTHOR
Stephen McKay <mckay@FreeBSD.org>
.An Stephen McKay Aq mckay@FreeBSD.org
.\" .Sh BUGS
.\" Gosh! No bugs here!
.\" This message brought to you by the Coalition for More Humour in Man Pages.
.\"
.\" $Id: ctm_rmail.1,v 1.10 1997/02/22 16:05:35 peter Exp $
.\" $Id: ctm_rmail.1,v 1.11 1997/08/30 11:05:34 jmg Exp $

View File

@ -6,13 +6,14 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id$
* $Id: ctm_scan.c,v 1.15 1997/02/22 16:05:40 peter Exp $
*
*/
#include <err.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
@ -45,7 +46,7 @@ Do(char *path)
npde = 1;
pde = malloc(sizeof *pde * (npde+1));
d = opendir(path);
if(!d) { perror(path); return 2; }
if(!d) { warn("%s", path); return 2; }
if(!strcmp(path,".")) {
*buf = 0;
} else {
@ -163,7 +164,7 @@ main(int argc, char **argv)
*/
if (argc > 1) {
if(chdir(argv[1])) {
perror(argv[1]);
warn("%s", argv[1]);
return 2;
}
argc--;

View File

@ -53,10 +53,9 @@ u_long s_sub_files, s_sub_bytes;
void
Usage(void)
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\tmkctm [-options] name number timestamp prefix");
fprintf(stderr, " dir1 dir2");
fprintf(stderr, "Options:\n");
fprintf(stderr,
"usage: mkctm [-options] name number timestamp prefix dir1 dir2\n");
fprintf(stderr, "options:\n");
fprintf(stderr, "\t\t-B bogus_regexp\n");
fprintf(stderr, "\t\t-D damage_limit\n");
fprintf(stderr, "\t\t-I ignore_regexp\n");
@ -105,7 +104,7 @@ static __inline struct stat *
StatFile(char *name)
{
if (lstat(name, &st) < 0)
err(1, "Couldn't stat %s\n", name);
err(1, "couldn't stat %s", name);
return &st;
}
@ -160,13 +159,13 @@ Equ(const char *dir1, const char *dir2, const char *name, struct dirent *de)
strcat(buf1, "/"); strcat(buf1, name);
strcat(buf1, "/"); strcat(buf1, de->d_name);
fd1 = open(buf1, O_RDONLY);
if(fd1 < 0) { perror(buf1); exit(3); }
if(fd1 < 0) { err(3, "%s", buf1); }
fstat(fd1, &s1);
strcpy(buf2, dir2);
strcat(buf2, "/"); strcat(buf2, name);
strcat(buf2, "/"); strcat(buf2, de->d_name);
fd2 = open(buf2, O_RDONLY);
if(fd2 < 0) { perror(buf2); exit(3); }
if(fd2 < 0) { err(3, "%s", buf2); }
fstat(fd2, &s2);
#if 0
/* XXX if we could just trust the size to change... */
@ -179,11 +178,11 @@ Equ(const char *dir1, const char *dir2, const char *name, struct dirent *de)
}
#endif
p1=mmap(0, s1.st_size, PROT_READ, MAP_PRIVATE, fd1, 0);
if (p1 == (u_char *)MAP_FAILED) { perror(buf1); exit(3); }
if (p1 == (u_char *)MAP_FAILED) { err(3, "%s", buf1); }
close(fd1);
p2=mmap(0, s2.st_size, PROT_READ, MAP_PRIVATE, fd2, 0);
if (p2 == (u_char *)MAP_FAILED) { perror(buf2); exit(3); }
if (p2 == (u_char *)MAP_FAILED) { err(3, "%s", buf2); }
close(fd2);
/* If identical, we're done. */
@ -319,10 +318,10 @@ Add(const char *dir1, const char *dir2, const char *name, struct dirent *de)
strcat(buf2, "/"); strcat(buf2, name);
strcat(buf2, "/"); strcat(buf2, de->d_name);
fd1 = open(buf2, O_RDONLY);
if (fd1 < 0) {perror(buf2); exit (3); }
if (fd1 < 0) { err(3, "%s", buf2); }
fstat(fd1, &st);
p1=mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd1, 0);
if (p1 == (u_char *)MAP_FAILED) { perror(buf2); exit(3); }
if (p1 == (u_char *)MAP_FAILED) { err(3, "%s", buf2); }
close(fd1);
m2 = MD5Data(p1, st.st_size, md5_2);
name_stat("CTMFM", dir2, name, de);
@ -501,12 +500,12 @@ main(int argc, char **argv)
#if 0
if (regcomp(&reg_bogus, DEFAULT_BOGUS, REG_EXTENDED | REG_NEWLINE))
/* XXX use regerror to explain it */
errx(1, "Default regular expression argument to -B is botched");
errx(1, "default regular expression argument to -B is botched");
flag_bogus = 1;
if (regcomp(&reg_ignore, DEFAULT_IGNORE, REG_EXTENDED | REG_NEWLINE))
/* XXX use regerror to explain it */
errx(1, "Default regular expression argument to -I is botched");
errx(1, "default regular expression argument to -I is botched");
flag_ignore = 1;
#endif
@ -515,7 +514,7 @@ main(int argc, char **argv)
case 'D':
damage_limit = strtol(optarg, 0, 0);
if (damage_limit < 0)
errx(1, "Damage limit must be positive");
errx(1, "damage limit must be positive");
break;
case 'I':
if (flag_ignore)
@ -526,7 +525,7 @@ main(int argc, char **argv)
if (regcomp(&reg_ignore, optarg,
REG_EXTENDED | REG_NEWLINE))
/* XXX use regerror to explain it */
errx(1, "Regular expression argument to -I is botched");
errx(1, "regular expression argument to -I is botched");
flag_ignore = 1;
break;
case 'B':
@ -538,13 +537,13 @@ main(int argc, char **argv)
if (regcomp(&reg_bogus, optarg,
REG_EXTENDED | REG_NEWLINE))
/* XXX use regerror to explain it */
errx(1, "Regular expression argument to -B is botched");
errx(1, "regular expression argument to -B is botched");
flag_bogus = 1;
break;
case 'l':
logf = fopen(optarg, "w");
if (!logf)
err(1, optarg);
err(1, "%s", optarg);
break;
case 'q':
verbose--;
@ -581,10 +580,10 @@ main(int argc, char **argv)
DoDir(argv[4], argv[5], "");
if (damage_limit && damage > damage_limit) {
print_stat(stderr, "DAMAGE: ");
errx(1, "Damage of %d would exceed %d files",
errx(1, "damage of %d would exceed %d files",
damage, damage_limit);
} else if (change < 2) {
errx(4, "No changes");
errx(4, "no changes");
} else {
printf("CTM_END ");
fprintf(logf, "CTM_END\n");