]>
git.cameronkatri.com Git - mandoc.git/blob - apropos.c
1 /* $Id: apropos.c,v 1.35 2013/12/27 18:51:25 schwarze Exp $ */
3 * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <sys/param.h>
31 #include "mansearch.h"
34 main(int argc
, char *argv
[])
37 struct mansearch search
;
40 struct manpaths paths
;
41 char *defpaths
, *auxpaths
;
47 progname
= strrchr(argv
[0], '/');
53 whatis
= (0 == strncmp(progname
, "whatis", 6));
55 memset(&paths
, 0, sizeof(struct manpaths
));
56 memset(&search
, 0, sizeof(struct mansearch
));
58 auxpaths
= defpaths
= NULL
;
61 while (-1 != (ch
= getopt(argc
, argv
, "C:M:m:S:s:")))
88 search
.deftype
= whatis
? TYPE_Nm
: TYPE_Nm
| TYPE_Nd
;
89 search
.flags
= whatis
? MANSEARCH_WHATIS
: 0;
91 manpath_parse(&paths
, conf_file
, defpaths
, auxpaths
);
92 ch
= mansearch(&search
, &paths
, argc
, argv
, &res
, &sz
);
98 for (i
= 0; i
< sz
; i
++) {
99 printf("%s - %s\n", res
[i
].names
, res
[i
].desc
);
106 return(sz
? EXIT_SUCCESS
: EXIT_FAILURE
);
108 fprintf(stderr
, "usage: %s [-C file] [-M path] [-m path] "
109 "[-S arch] [-s section]%s ...\n", progname
,
110 whatis
? " name" : "\n expression");
111 return(EXIT_FAILURE
);