]>
git.cameronkatri.com Git - mandoc.git/blob - apropos.c
1 /* $Id: apropos.c,v 1.33 2012/06/09 17:49:13 kristaps 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 char *conf_file
, *defpaths
, *auxpaths
;
41 struct manpaths paths
;
46 progname
= strrchr(argv
[0], '/');
52 auxpaths
= defpaths
= conf_file
= NULL
;
53 memset(&paths
, 0, sizeof(struct manpaths
));
54 memset(&search
, 0, sizeof(struct mansearch
));
55 whatis
= (0 == strcmp(progname
, "whatis"));
57 while (-1 != (ch
= getopt(argc
, argv
, "C:M:m:S:s:")))
84 search
.deftype
= whatis
? TYPE_Nm
: TYPE_Nm
| TYPE_Nd
;
85 search
.flags
= whatis
? MANSEARCH_WHATIS
: 0;
87 manpath_parse(&paths
, conf_file
, defpaths
, auxpaths
);
88 ch
= mansearch(&search
, &paths
, argc
, argv
, &res
, &sz
);
94 for (i
= 0; i
< sz
; i
++) {
95 printf("%s - %s\n", res
[i
].file
, res
[i
].desc
);
100 return(sz
? EXIT_SUCCESS
: EXIT_FAILURE
);
102 fprintf(stderr
, "usage: %s [-C conf] "
109 return(EXIT_FAILURE
);