Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/catman Add catman.
details: https://anonhg.NetBSD.org/src/rev/b27e662eb39e
branches: trunk
changeset: 471540:b27e662eb39e
user: dante <dante%NetBSD.org@localhost>
date: Sun Apr 04 10:56:38 1999 +0000
description:
Add catman.
It require "_crunch" section in /etc/man.conf to re-compress the compressed man pages.
It handle symbolic links, but at this time no hard links.
config files are stolen from man with few changes to support "_crunch" section.
catman.8 miss the "full moon" joke, I can't remember it, if you can pleas add it :-)
diffstat:
usr.sbin/catman/Makefile | 3 +-
usr.sbin/catman/TODO | 1 -
usr.sbin/catman/catman.8 | 18 +-
usr.sbin/catman/catman.c | 642 +++++++++++++++++++++++++++++++++++--------
usr.sbin/catman/config.c | 216 ++++++++++++++
usr.sbin/catman/config.h | 61 ++++
usr.sbin/catman/pathnames.h | 45 +-
7 files changed, 828 insertions(+), 158 deletions(-)
diffs (truncated from 1173 to 300 lines):
diff -r e9be1da26736 -r b27e662eb39e usr.sbin/catman/Makefile
--- a/usr.sbin/catman/Makefile Sun Apr 04 09:58:57 1999 +0000
+++ b/usr.sbin/catman/Makefile Sun Apr 04 10:56:38 1999 +0000
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.4 1997/10/18 04:37:17 lukem Exp $
+# $NetBSD: Makefile,v 1.5 1999/04/04 10:56:38 dante Exp $
BINDIR= /usr/sbin
PROG= catman
+SRCS= config.c catman.c
MAN= catman.8
.include <bsd.prog.mk>
diff -r e9be1da26736 -r b27e662eb39e usr.sbin/catman/TODO
--- a/usr.sbin/catman/TODO Sun Apr 04 09:58:57 1999 +0000
+++ b/usr.sbin/catman/TODO Sun Apr 04 10:56:38 1999 +0000
@@ -1,2 +1,1 @@
-Use man.conf
Handle hard-linked manpages.
diff -r e9be1da26736 -r b27e662eb39e usr.sbin/catman/catman.8
--- a/usr.sbin/catman/catman.8 Sun Apr 04 09:58:57 1999 +0000
+++ b/usr.sbin/catman/catman.8 Sun Apr 04 10:56:38 1999 +0000
@@ -27,7 +27,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $NetBSD: catman.8,v 1.8 1997/10/18 04:37:19 lukem Exp $
+.\" $NetBSD: catman.8,v 1.9 1999/04/04 10:56:38 dante Exp $
.\"
.Dd July 30, 1993
.Dt CATMAN 8
@@ -38,6 +38,10 @@
.Sh SYNOPSIS
.Nm
.Op Fl knpsw
+.Op Fl m Ar directory
+.Op Ar sections
+.Nm ""
+.Op Fl knpsw
.Op Fl M Ar directory
.Op Ar sections
.Sh DESCRIPTION
@@ -58,8 +62,8 @@
argument is one word, and contains the section numbers of all the
sections to be checked. For example, if
.Ar sections
-is ``138'', the
-manual pages in sections 1, 3, and 8 will be checked and regenerated.
+is ``13f8'', the
+manual pages in sections 1, 3f, and 8 will be checked and regenerated.
If no
.Ar sections
argument is provided,
@@ -86,6 +90,10 @@
Only create the
.Pa whatis
database.
+.It Fl m Ar directory
+Add
+.Ar directory
+to the set of directories to be updated.
.It Fl M Ar directory
Update manual pages in
.Ar directory.
@@ -95,6 +103,4 @@
.Xr man 1 ,
.Xr whatis 1
.Sh BUGS
-Currently knows nothing about
-.Pa /etc/man.conf
-and machine specific man pages.
+Currently does not handle hard links.
diff -r e9be1da26736 -r b27e662eb39e usr.sbin/catman/catman.c
--- a/usr.sbin/catman/catman.c Sun Apr 04 09:58:57 1999 +0000
+++ b/usr.sbin/catman/catman.c Sun Apr 04 10:56:38 1999 +0000
@@ -1,7 +1,11 @@
+/* $NetBSD: catman.c,v 1.10 1999/04/04 10:56:38 dante Exp $ */
+
/*
- * Copyright (c) 1993 Winning Strategies, Inc.
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * Author: Baldassare Dante Profeta <dante%mclink.it@localhost>
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -12,67 +16,82 @@
* 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 Winning Strategies, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/types.h>
+#include <sys/queue.h>
#include <sys/cdefs.h>
-#ifndef lint
-__RCSID("$NetBSD: catman.c,v 1.9 1997/10/24 01:31:35 mrg Exp $");
-#endif /* not lint */
-
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/stat.h>
#include <sys/wait.h>
+#include <ctype.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
+#include <fnmatch.h>
#include <limits.h>
+#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <paths.h>
+#include <glob.h>
+#include "config.h"
#include "pathnames.h"
-int f_nowhatis;
-int f_noaction;
-int f_noformat;
-int f_ignerr;
-int f_noprint;
+#ifndef MACHINE
+#define MACHINE __ARCHITECTURE__
+#endif
-int dowhatis;
+int f_nowhatis = 0;
+int f_noaction = 0;
+int f_noformat = 0;
+int f_ignerr = 0;
+int f_noprint = 0;
+int dowhatis = 0;
-char *mp = _PATH_MAN;
-char *sp = _MAN_SECTIONS;
+int main __P((int, char **));
+static void setdefentries __P((char *, char *, char *));
+static void uniquepath __P((void));
+static void catman __P((void));
+static void scanmandir __P((const char *, const char *));
+static int splitentry __P((char *, char *, char *));
+static void setcatsuffix __P((char *, const char *, const char *));
+static void makecat __P((const char *, const char *, const char *,
+ const char *));
+static void makewhatis __P((void));
+static void dosystem __P((const char *));
+static void usage __P((void));
-void catman __P((const char *, char *));
-int main __P((int, char **));
-void makewhatis __P((const char *));
-void dosystem __P((const char *));
-void usage __P((void));
int
main(argc, argv)
int argc;
char **argv;
{
+ char *m_path = NULL;
+ char *m_add = NULL;
int c;
- while ((c = getopt(argc, argv, "knpswM:")) != -1) {
+ while ((c = getopt(argc, argv, "km:M:npsw")) != -1) {
switch (c) {
case 'k':
f_ignerr = 1;
@@ -89,8 +108,11 @@
case 'w':
f_noformat = 1;
break;
+ case 'm':
+ m_add = optarg;
+ break;
case 'M':
- mp = optarg;
+ m_path = optarg;
break;
case '?':
@@ -107,143 +129,501 @@
if (argc > 1)
usage();
- if (argc == 1)
- sp = *argv;
+
+ config(_PATH_MANCONF);
+ setdefentries(m_path, m_add, (argc == 0)? NULL : argv[argc-1]);
+ uniquepath();
if (f_noformat == 0 || f_nowhatis == 0)
- catman(mp, sp);
+ catman();
if (f_nowhatis == 0 && dowhatis)
- makewhatis(mp);
+ makewhatis();
+
+ return(0);
+}
+
+static void
+setdefentries(m_path, m_add, sections)
+ char *m_path;
+ char *m_add;
+ char *sections;
+{
+ TAG *defp, *defnewp, *sectnewp, *subp;
+ ENTRY *e_defp, *e_sectp, *e_subp, *ep;
+ char *p, *slashp, *machine;
+ char section[10];
+ char buf[MAXPATHLEN * 2];
+ int i;
+
+ /* Get the machine type. */
+ if ((machine = getenv("MACHINE")) == NULL)
+ machine = MACHINE;
+
+ /* If there's no _default list, create an empty one. */
+ if ((defp = getlist("_default")) == NULL)
+ defp = addlist("_default");
+
+ /*
+ * 0: If one or more sections was specified, rewrite _subdir list.
+ */
+ if (sections != NULL) {
+ sectnewp = addlist("_section_new");
+ for(p=sections; *p;) {
+ section[0] = *p++;
+ for(i=1; *p && !isdigit(*p) && i<10; i++)
+ section[i] = *p++;
+ section[i] = '\0';
+ snprintf(buf, sizeof(buf), "man%s", section);
+ if(!(e_sectp = malloc(sizeof(ENTRY))))
+ err(1, "malloc");
+ if(!(e_sectp->s = strdup(buf)))
+ err(1, "malloc");
+ TAILQ_INSERT_TAIL(§newp->list, e_sectp, q);
+ }
+ removelist("_subdir");
+ renamelist("_section_new", "_subdir");
+ }
- exit(0);
+ /*
+ * 1: If the user specified a MANPATH variable, or set the -M
+ * option, we replace the _default list with the user's list,
+ * appending the entries in the _subdir list and the machine.
+ */
+ if (m_path == NULL)
+ m_path = getenv("MANPATH");
+ if (m_path != NULL) {
+ while ((e_defp = defp->list.tqh_first) != NULL) {
+ free(e_defp->s);
+ TAILQ_REMOVE(&defp->list, e_defp, q);
+ }
+ for (p = strtok(m_path, ":");
+ p != NULL; p = strtok(NULL, ":")) {
+ slashp = p[strlen(p) - 1] == '/' ? "" : "/";
+ e_subp = (subp = getlist("_subdir")) == NULL ?
+ NULL : subp->list.tqh_first;
+ for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ if(!strncmp(e_subp->s, "cat", 3))
Home |
Main Index |
Thread Index |
Old Index