diff options
| author | svn2git <svn2git@FreeBSD.org> | 1994-05-01 08:00:00 +0000 |
|---|---|---|
| committer | svn2git <svn2git@FreeBSD.org> | 1994-05-01 08:00:00 +0000 |
| commit | a16f65c7d117419bd266c28a1901ef129a337569 (patch) | |
| tree | 2626602f66dc3551e7a7c7bc9ad763c3bc7ab40a /gnu/usr.bin/man/lib | |
| parent | 8503f4f13f77abf7adc8f7e329c6f9c1d52b6a20 (diff) | |
Release FreeBSD 1.1upstream/1.1.0_cvsrelease/1.1.0_cvs
This commit was manufactured to restore the state of the 1.1-RELEASE image.
Releases prior to 5.3-RELEASE are omitting the secure/ and crypto/ subdirs.
Diffstat (limited to 'gnu/usr.bin/man/lib')
| -rw-r--r-- | gnu/usr.bin/man/lib/Makefile | 30 | ||||
| -rw-r--r-- | gnu/usr.bin/man/lib/config.h_dist | 216 | ||||
| -rw-r--r-- | gnu/usr.bin/man/lib/gripes.c | 180 | ||||
| -rw-r--r-- | gnu/usr.bin/man/lib/gripes.h | 30 | ||||
| -rw-r--r-- | gnu/usr.bin/man/lib/util.c | 149 |
5 files changed, 605 insertions, 0 deletions
diff --git a/gnu/usr.bin/man/lib/Makefile b/gnu/usr.bin/man/lib/Makefile new file mode 100644 index 000000000000..d364b32f4b7a --- /dev/null +++ b/gnu/usr.bin/man/lib/Makefile @@ -0,0 +1,30 @@ +LIB = man + +.if exists(${.CURDIR}/obj) +CONFH= ${.CURDIR}/obj/config.h +.else +CONFH= ${.CURDIR}/config.h +.endif + + +CFLAGS+= -I${.CURDIR} -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_UNCOMPRESS -DALT_SYSTEMS +CLEANFILES+= ${CONFH} +SRCS = util.c gripes.c + +libman.a:: ${CONFH} + +install: + @echo -n + +depend ${CONFH}: ${.CURDIR}/config.h_dist ../Makefile.inc + sed -e 's,%apropos%,${apropos},' -e 's,%whatis%,${whatis},' \ + -e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \ + -e 's,%nroff%,${nroff},' -e 's,%tbl%,${tbl},' \ + -e 's,%col%,${col},' -e 's,%pic%,${pic},' \ + -e 's,%eqn%,${eqn},' -e 's,%neqn%,${neqn},' \ + -e 's,%vgrind%,${vgrind},' -e 's,%refer%,${refer},' \ + -e 's,%grap%,${grap},' -e 's,%zcat%,${zcat},' \ + -e 's,%manpath_config_file%,${manpath_config_file},' \ + ${.CURDIR}/config.h_dist > ${CONFH} + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/man/lib/config.h_dist b/gnu/usr.bin/man/lib/config.h_dist new file mode 100644 index 000000000000..74122df0370b --- /dev/null +++ b/gnu/usr.bin/man/lib/config.h_dist @@ -0,0 +1,216 @@ +/* + * config.h + * + * If you haven't read the README file, now might be a good time. + * + * This file is edited by configure, so you shouldn't have to. + * If that doesn't work, edit this file to match your site. + * + * Sorry it's so long, but there are lots of things you might want to + * customize for your site. + * + * Copyright (c) 1990, 1991, John W. Eaton. + * + * You may distribute under the terms of the GNU General Public + * License as specified in the file COPYING that comes with the man + * distribution. + * + * John W. Eaton + * jwe@che.utexas.edu + * Department of Chemical Engineering + * The University of Texas at Austin + * Austin, Texas 78712 + */ + +#ifdef COMPRESS +#define DO_COMPRESS +#define DO_UNCOMPRESS +#endif + +/* + * This is the size of a number of internal buffers. It should + * probably not be less than 512. + */ +#ifndef BUFSIZ +#define BUFSIZ 1024 +#endif + +/* + * This should be at least the size of the longest path. + */ +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 +#endif + +/* + * This is the maximum number of directories expected in the manpath. + */ +#ifndef MAXDIRS +#define MAXDIRS 64 +#endif + +/* + * This is the name of the group that owns the preformatted man pages. + * If you are running man as a setgid program, you should make sure + * that all of the preformatted man pages and the directories that + * they live in are readable and writeable and owned by this group. + */ +#ifdef SECURE_MAN_UID +#define MAN_USER "" +#endif + +/* + * It's probably best to define absolute paths to all of these. If + * you don't, you'll be depending on the user's path to be correct + * when system () is called. This can result in weird behavior that's + * hard to track down, especially after you forget how this program + * works... If you don't have some of these programs, simply define + * them to be empty strings (i.e. ""). As a minimum, you must have + * nroff installed. + */ +#ifndef APROPOS +#define APROPOS "%apropos%" +#endif + +#ifndef WHATIS +#define WHATIS "%whatis%" +#endif + +#ifndef PAGER +#define PAGER "%pager%" +#endif + +#ifdef HAS_TROFF +#ifndef TROFF +#define TROFF "%troff%" +#endif +#endif + +#ifndef NROFF +#define NROFF "%nroff%" +#endif + +#ifndef EQN +#define EQN "%eqn%" +#endif + +#ifndef NEQN +#define NEQN "%neqn%" +#endif + +#ifndef TBL +#define TBL "%tbl%" +#endif + +#ifndef COL +#define COL "%col%" +#endif + +#ifndef VGRIND +#define VGRIND "%vgrind%" +#endif + +#ifndef REFER +#define REFER "%refer%" +#endif + +#ifndef GRAP +#define GRAP "%grap%" +#endif + +#ifndef PIC +#define PIC "%pic%" +#endif + +/* + * Define the absolute path to the configuration file. + */ +#ifndef MAN_MAIN + static char config_file[] = "%manpath_config_file%" ; +#endif + +/* + * Define the uncompression program(s) to use for those preformatted + * pages that end in the given character. If you add extras here, you + * may need to change man.c. + */ +#ifdef DO_UNCOMPRESS +/* .F files */ +#define FCAT "" +/* .Y files */ +#define YCAT "" +/* .Z files */ +#define ZCAT "%zcat%" +#endif + +/* + * This is the standard program to use on this system for compressing + * pages once they have been formatted, and the character to tack on + * to the end of those files. The program listed is expected to read + * from the standard input and write compressed output to the standard + * output. + */ +#ifdef DO_COMPRESS +#define COMPRESSOR "" +#define COMPRESS_EXT "" +#endif + +/* + * Define the standard manual sections. For example, if your man + * directory tree has subdirectories man1, man2, man3, mann, + * and man3foo, std_sections[] would have "1", "2", "3", "n", and + * "3foo". Directories are searched in the order they appear. Having + * extras isn't fatal, it just slows things down a bit. + * + * Note that this is just for directories to search. If you have + * files like .../man3/foobar.3Xtc, you don't need to have "3Xtc" in + * the list below -- this is handled separately, so that `man 3Xtc foobar', + * `man 3 foobar', and `man foobar' should find the file .../man3/foo.3Xtc, + * (assuming, of course, that there isn't a .../man1/foo.1 or somesuch + * that we would find first). + * + * Note that this list should be in the order that you want the + * directories to be searched. Is there a standard for this? What is + * the normal order? If anyone knows, please tell me! + */ +#ifndef MANPATH_MAIN + static char *std_sections[] = + { + "1", "n", "l", "6", "8", "2", "3", "4", "5", "7", "p", "o", NULL + }; +#endif + +/* + * Not all systems define these in stat.h. + */ +#ifndef S_IRUSR +#define S_IRUSR 00400 /* read permission: owner */ +#endif +#ifndef S_IWUSR +#define S_IWUSR 00200 /* write permission: owner */ +#endif +#ifndef S_IRGRP +#define S_IRGRP 00040 /* read permission: group */ +#endif +#ifndef S_IWGRP +#define S_IWGRP 00020 /* write permission: group */ +#endif +#ifndef S_IROTH +#define S_IROTH 00004 /* read permission: other */ +#endif +#ifndef S_IWOTH +#define S_IWOTH 00002 /* write permission: other */ +#endif + +/* + * This is the mode used for formatted pages that we create. If you + * are using the setgid option, you should use 664. If you are not, + * you should use 666 and make the cat* directories mode 777. + */ +#ifndef CATMODE +#ifdef SECURE_MAN_UID +#define CATMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH +#else +#define CATMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH +#endif +#endif diff --git a/gnu/usr.bin/man/lib/gripes.c b/gnu/usr.bin/man/lib/gripes.c new file mode 100644 index 000000000000..76f8e703ada5 --- /dev/null +++ b/gnu/usr.bin/man/lib/gripes.c @@ -0,0 +1,180 @@ +/* + * gripes.c + * + * Copyright (c) 1990, 1991, John W. Eaton. + * + * You may distribute under the terms of the GNU General Public + * License as specified in the file COPYING that comes with the man + * distribution. + * + * John W. Eaton + * jwe@che.utexas.edu + * Department of Chemical Engineering + * The University of Texas at Austin + * Austin, Texas 78712 + */ + +#include <stdio.h> +#include "gripes.h" + +#ifdef STDC_HEADERS +#include <stdlib.h> +#else +extern int fprintf (); +extern int fflush (); +extern int exit (); +#endif + +extern char *prognam; + +void +gripe_no_name (section) + char *section; +{ + if (section) + fprintf (stderr, "What manual page do you want from section %s?\n", + section); + else + fprintf (stderr, "What manual page do you want?\n"); + + fflush (stderr); +} + +void +gripe_reading_man_file (name) + char *name; +{ + fprintf (stderr, "Read access denied for file %s\n", name); + + fflush (stderr); +} + +void +gripe_converting_name (name, to_cat) + char *name; + int to_cat; +{ + if (to_cat) + fprintf (stderr, "Error converting %s to cat name\n", name); + else + fprintf (stderr, "Error converting %s to man name\n", name); + + fflush (stderr); + + exit (1); +} + +void +gripe_system_command (status) + int status; +{ + fprintf (stderr, "Error executing formatting or display command.\n"); + fprintf (stderr, "system command exited with status %d\n", status); + + fflush (stderr); +} + +void +gripe_not_found (name, section) + char *name, *section; +{ + if (section) + fprintf (stderr, "No entry for %s in section %s of the manual\n", + name, section); + else + fprintf (stderr, "No manual entry for %s\n", name); + + fflush (stderr); +} + +void +gripe_incompatible (s) + char *s; +{ + fprintf (stderr, "%s: incompatible options %s\n", prognam, s); + + fflush (stderr); + + exit (1); +} + +void +gripe_getting_mp_config (file) + char *file; +{ + fprintf (stderr, "%s: unable to find the file %s\n", prognam, file); + + fflush (stderr); + + exit (1); +} + +void +gripe_reading_mp_config (file) + char *file; +{ + fprintf (stderr, "%s: unable to make sense of the file %s\n", prognam, file); + + fflush (stderr); + + exit (1); +} + +void +gripe_invalid_section (section) + char *section; +{ + fprintf (stderr, "%s: invalid section (%s) selected\n", prognam, section); + + fflush (stderr); + + exit (1); +} + +void +gripe_manpath () +{ + fprintf (stderr, "%s: manpath is null\n", prognam); + + fflush (stderr); + + exit (1); +} + +void +gripe_alloc (bytes, object) + int bytes; + char *object; +{ + fprintf (stderr, "%s: can't malloc %d bytes for %s\n", + prognam, bytes, object); + + fflush (stderr); + + exit (1); +} + +void +gripe_roff_command_from_file (file) + char *file; +{ + fprintf (stderr, "Error parsing *roff command from file %s\n", file); + + fflush (stderr); +} + +void +gripe_roff_command_from_env () +{ + fprintf (stderr, "Error parsing MANROFFSEQ. Using system defaults.\n"); + + fflush (stderr); +} + +void +gripe_roff_command_from_command_line () +{ + fprintf (stderr, "Error parsing *roff command from command line.\n"); + + fflush (stderr); +} diff --git a/gnu/usr.bin/man/lib/gripes.h b/gnu/usr.bin/man/lib/gripes.h new file mode 100644 index 000000000000..e3be4a08b19e --- /dev/null +++ b/gnu/usr.bin/man/lib/gripes.h @@ -0,0 +1,30 @@ +/* + * gripes.h + * + * Copyright (c) 1990, 1991, John W. Eaton. + * + * You may distribute under the terms of the GNU General Public + * License as specified in the file COPYING that comes with the man + * distribution. + * + * John W. Eaton + * jwe@che.utexas.edu + * Department of Chemical Engineering + * The University of Texas at Austin + * Austin, Texas 78712 + */ + +extern void gripe_no_name (); +extern void gripe_converting_name (); +extern void gripe_system_command (); +extern void gripe_reading_man_file (); +extern void gripe_not_found (); +extern void gripe_invalid_section (); +extern void gripe_manpath (); +extern void gripe_alloc (); +extern void gripe_incompatible (); +extern void gripe_getting_mp_config (); +extern void gripe_reading_mp_config (); +extern void gripe_roff_command_from_file (); +extern void gripe_roff_command_from_env (); +extern void gripe_roff_command_from_command_line (); diff --git a/gnu/usr.bin/man/lib/util.c b/gnu/usr.bin/man/lib/util.c new file mode 100644 index 000000000000..e8253a8a993f --- /dev/null +++ b/gnu/usr.bin/man/lib/util.c @@ -0,0 +1,149 @@ +/* + * util.c + * + * Copyright (c) 1990, 1991, John W. Eaton. + * + * You may distribute under the terms of the GNU General Public + * License as specified in the file COPYING that comes with the man + * distribution. + * + * John W. Eaton + * jwe@che.utexas.edu + * Department of Chemical Engineering + * The University of Texas at Austin + * Austin, Texas 78712 + */ + +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/wait.h> + +#ifdef STDC_HEADERS +#include <stdlib.h> +#else +extern int fprintf (); +extern int tolower (); +#endif + +extern char *strdup (); +extern int system (); + +#include "gripes.h" + +/* + * Extract last element of a name like /foo/bar/baz. + */ +char * +mkprogname (s) + register char *s; +{ + char *t; + + t = strrchr (s, '/'); + if (t == (char *)NULL) + t = s; + else + t++; + + return strdup (t); +} + +void +downcase (s) + char *s; +{ + register char c; + while ((c = *s) != '\0') + { + if (isalpha (c)) + *s++ = tolower (c); + } +} + +/* + * Is file a newer than file b? + * + * case: + * + * a newer than b returns 1 + * a older than b returns 0 + * stat on a fails returns -1 + * stat on b fails returns -2 + * stat on a and b fails returns -3 + */ +int +is_newer (fa, fb) + register char *fa; + register char *fb; +{ + struct stat fa_sb; + struct stat fb_sb; + register int fa_stat; + register int fb_stat; + register int status = 0; + + fa_stat = stat (fa, &fa_sb); + if (fa_stat != 0) + status = 1; + + fb_stat = stat (fb, &fb_sb); + if (fb_stat != 0) + status |= 2; + + if (status != 0) + return -status; + + return (fa_sb.st_mtime > fb_sb.st_mtime); +} + +/* + * Is path a directory? + */ +int +is_directory (path) + char *path; +{ + struct stat sb; + register int status; + + status = stat (path, &sb); + + if (status != 0) + return -1; + + return ((sb.st_mode & S_IFDIR) == S_IFDIR); + +} + +/* + * Attempt a system () call. Return 1 for success and 0 for failure + * (handy for counting successes :-). + */ +int +do_system_command (command) + char *command; +{ + int status = 0; + extern int debug; + + /* + * If we're debugging, don't really execute the command -- you never + * know what might be in that mangled string :-O. + */ + if (debug) + fprintf (stderr, "\ntrying command: %s\n", command); + else + status = system (command); + + if (WIFSIGNALED(status)) + return 0; + else if (WEXITSTATUS(status)) { + gripe_system_command (status); + return 0; + } + else + return 1; +} |
