static char *sccsid
= "@(#)catman.c 4.1 (Berkeley) %G%";
# define SYSTEM(str) (pflag ? printf("%s\n", str) : system(str))
reg
char *tsp
, *msp
, *csp
, *man
, *cat
, *sp
;
if (strcmp(*av
, "-p") == 0)
else if (strcmp(*av
, "-n") == 0)
else if (strcmp(*av
, "-w") == 0)
printf("usage: catman [ -p ] [ -n ] [ -w ] [ sections ]\n");
man
= "manx/xxxxxxxxxxxxxx";
cat
= "catx/xxxxxxxxxxxxxx";
for (sp
= sections
; *sp
; sp
++) {
if ((mdir
= fopen(man
, "r")) == NULL
) {
fprintf(stderr
, "fopen:");
if (stat(cat
, &sbuf
) < 0) {
sprintf(buf
, "mkdir %s", cat
);
if ((sbuf
.st_mode
& 0777) != 0777)
while (fread((char *) &dir
, sizeof dir
, 1, mdir
) > 0) {
if (dir
.d_ino
== 0 || dir
.d_name
[0] == '.')
* make sure this is a man file, i.e., that it
* ends in .[0-9] or .[0-9][a-z]
tsp
= rindex(dir
.d_name
, '.');
if (!isdigit(*++tsp
) || ((*++tsp
&& !isalpha(*tsp
)) || *++tsp
))
strncpy(msp
, dir
.d_name
, DIRSIZ
);
if ((inf
= fopen(man
, "r")) == NULL
) {
if (getc(inf
) == '.' && getc(inf
) == 's'
strncpy(csp
, dir
.d_name
, DIRSIZ
);
if (stat(cat
, &sbuf
) >= 0) {
if (time
>= sbuf
.st_mtime
)
sprintf(buf
, "nroff -man %s > %s", man
, cat
);
printf("/bin/sh /usr/lib/makewhatis\n");
execl("/bin/sh", "/bin/sh", "/usr/lib/makewhatis", 0);
perror("/bin/sh /usr/lib/makewhatis");