Print this page
Add catman, makewhatis functionality.  Print an error if the whatis database
is missing.

@@ -157,10 +157,11 @@
 static int      makewhatis = 0;
 static int      printmp = 0;
 static int      sargs = 0;
 static int      psoutput = 0;
 static int      whatis = 0;
+static int      makewhatishere = 0;
 
 static char     *mansec;
 static char     *pager;
 
 static char     *addlocale(char *);

@@ -189,10 +190,12 @@
 static int      searchdir(char *, char *, char *);
 static void     sortdir(DIR *, char ***);
 static char     **split(char *, char);
 static void     usage_man(void);
 static void     usage_whatapro(void);
+static void     usage_catman(void);
+static void     usage_makewhatis(void);
 static void     whatapro(struct man_node *, char *);
 
 static char     language[MAXPATHLEN];   /* LC_MESSAGES */
 static char     localedir[MAXPATHLEN];  /* locale specific path component */
 

@@ -211,10 +214,11 @@
         static struct man_node *mandirs = NULL;
         int             bmp_flags = 0;
         int             ret = 0;
         char            *opts;
         char            *mwstr;
+        int             catman = 0;
 
         (void) setlocale(LC_ALL, "");
         (void) strcpy(language, setlocale(LC_MESSAGES, (char *)NULL));
         if (strcmp("C", language) != 0)
                 (void) strlcpy(localedir, language, MAXPATHLEN);

@@ -229,10 +233,19 @@
                 opts = "M:ds:";
         } else if (strcmp(__progname, "whatis") == 0) {
                 apropos++;
                 whatis++;
                 opts = "M:ds:";
+        } else if (strcmp(__progname, "catman") == 0) {
+                catman++;
+                makewhatis++;
+                opts = "M:w";
+        } else if (strcmp(__progname, "makewhatis") == 0) {
+                makewhatis++;
+                makewhatishere++;
+                manpath = ".";
+                opts = "";
         } else {
                 opts = "M:adfklps:tw";
         }
 
         opterr = 0;

@@ -271,10 +284,14 @@
                         break;
                 case '?':
                 default:
                         if (apropos)
                                 usage_whatapro();
+                        else if (catman)
+                                usage_catman();
+                        else if (makewhatishere)
+                                usage_makewhatis();
                         else
                                 usage_man();
                 }
         }
         argc -= optind;

@@ -688,12 +705,14 @@
         regex_t         preg;
         char            **ss = NULL;
         char            s[MAXNAMELEN];
         int             i;
 
-        if ((fp = fopen(whatpath, "r")) == NULL)
+        if ((fp = fopen(whatpath, "r")) == NULL) {
+                perror(whatpath);
                 return;
+        }
 
         DPRINTF("-- Found %s: %s\n", WHATIS, whatpath);
 
         /* Build keyword regex */
         if (asprintf(&pkwd, "%s%s%s", (whatis) ? "\\<" : "",

@@ -1562,6 +1581,23 @@
         (void) fprintf(stderr, gettext(
 "usage: %s [-M path] [-s section] keyword ...\n"),
             whatis ? "whatis" : "apropos");
 
         exit(1);
+}
+
+static void
+usage_catman(void)
+{
+        (void) fprintf(stderr, gettext(
+"usage: catman [-M path] [-w]\n"));
+
+        exit(1);
+}
+
+static void
+usage_makewhatis(void)
+{
+        (void) fprintf(stderr, gettext("usage: makewhatis\n"));
+
+        exit(1);
 }