[BACK]Return to apropos.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/Attic/apropos.c between version 1.31 and 1.35

version 1.31, 2012/06/08 10:44:52 version 1.35, 2013/12/27 18:51:25
Line 21 
Line 21 
   
 #include <assert.h>  #include <assert.h>
 #include <getopt.h>  #include <getopt.h>
   #include <stdint.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
Line 32 
Line 33 
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
         int              ch;          int              ch, whatis;
           struct mansearch search;
         size_t           i, sz;          size_t           i, sz;
         struct manpage  *res;          struct manpage  *res;
         char            *conf_file, *defpaths, *auxpaths,  
                         *arch, *sec;  
         struct manpaths  paths;          struct manpaths  paths;
           char            *defpaths, *auxpaths;
           char            *conf_file;
         char            *progname;          char            *progname;
         extern char     *optarg;          extern char     *optarg;
         extern int       optind;          extern int       optind;
Line 48  main(int argc, char *argv[])
Line 50  main(int argc, char *argv[])
         else          else
                 ++progname;                  ++progname;
   
         auxpaths = defpaths = conf_file = arch = sec = NULL;          whatis = (0 == strncmp(progname, "whatis", 6));
   
         memset(&paths, 0, sizeof(struct manpaths));          memset(&paths, 0, sizeof(struct manpaths));
           memset(&search, 0, sizeof(struct mansearch));
   
           auxpaths = defpaths = NULL;
           conf_file = NULL;
   
         while (-1 != (ch = getopt(argc, argv, "C:M:m:S:s:")))          while (-1 != (ch = getopt(argc, argv, "C:M:m:S:s:")))
                 switch (ch) {                  switch (ch) {
                 case ('C'):                  case ('C'):
Line 63  main(int argc, char *argv[])
Line 70  main(int argc, char *argv[])
                         auxpaths = optarg;                          auxpaths = optarg;
                         break;                          break;
                 case ('S'):                  case ('S'):
                         arch = optarg;                          search.arch = optarg;
                         break;                          break;
                 case ('s'):                  case ('s'):
                         sec = optarg;                          search.sec = optarg;
                         break;                          break;
                 default:                  default:
                         goto usage;                          goto usage;
Line 78  main(int argc, char *argv[])
Line 85  main(int argc, char *argv[])
         if (0 == argc)          if (0 == argc)
                 goto usage;                  goto usage;
   
           search.deftype = whatis ? TYPE_Nm : TYPE_Nm | TYPE_Nd;
           search.flags = whatis ? MANSEARCH_WHATIS : 0;
   
         manpath_parse(&paths, conf_file, defpaths, auxpaths);          manpath_parse(&paths, conf_file, defpaths, auxpaths);
         ch = mansearch(&paths, arch, sec, argc, argv, &res, &sz);          ch = mansearch(&search, &paths, argc, argv, &res, &sz);
         manpath_free(&paths);          manpath_free(&paths);
   
         if (0 == ch)          if (0 == ch)
                 goto usage;                  goto usage;
   
         for (i = 0; i < sz; i++) {          for (i = 0; i < sz; i++) {
                 printf("%s - %s\n", res[i].file, res[i].desc);                  printf("%s - %s\n", res[i].names, res[i].desc);
                   free(res[i].file);
                   free(res[i].names);
                 free(res[i].desc);                  free(res[i].desc);
         }          }
   
         free(res);          free(res);
         return(sz ? EXIT_SUCCESS : EXIT_FAILURE);          return(sz ? EXIT_SUCCESS : EXIT_FAILURE);
 usage:  usage:
         fprintf(stderr, "usage: %s [-C conf] "          fprintf(stderr, "usage: %s [-C file] [-M path] [-m path] "
                                   "[-M paths] "                          "[-S arch] [-s section]%s ...\n", progname,
                                   "[-m paths] "                          whatis ? " name" : "\n               expression");
                                   "[-S arch] "  
                                   "[-s section] "  
                                   "expr ...\n",  
                                   progname);  
         return(EXIT_FAILURE);          return(EXIT_FAILURE);
 }  }

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.35

CVSweb