static char *sccsid
= "@(#)catman.c 4.2 (Berkeley) %G%";
# define SYSTEM(str) (pflag ? printf("%s\n", str) : system(str))
reg
char *tsp
, *msp
, *csp
, *sp
;
static char man
[MAXNAMLEN
+6] = "manx/";
static char cat
[MAXNAMLEN
+6] = "catx/";
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");
for (sp
= sections
; *sp
; sp
++) {
if ((mdir
= opendir(man
)) == NULL
) {
fprintf(stderr
, "opendir:");
if (stat(cat
, &sbuf
) < 0) {
sprintf(buf
, "mkdir %s", cat
);
if ((sbuf
.st_mode
& 0777) != 0777)
while ((dir
= readdir(mdir
)) != NULL
) {
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
))
strcpy(msp
, dir
->d_name
);
if ((inf
= fopen(man
, "r")) == NULL
) {
if (getc(inf
) == '.' && getc(inf
) == 's'
strcpy(csp
, dir
->d_name
);
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");