version 1.5, 2011/11/16 13:23:27 |
version 1.6, 2011/11/17 14:52:32 |
|
|
#include <string.h> |
#include <string.h> |
|
|
#include "apropos_db.h" |
#include "apropos_db.h" |
|
#include "man_conf.h" |
#include "mandoc.h" |
#include "mandoc.h" |
|
|
static int cmp(const void *, const void *); |
static int cmp(const void *, const void *); |
|
|
int |
int |
apropos(int argc, char *argv[]) |
apropos(int argc, char *argv[]) |
{ |
{ |
int ch; |
struct man_conf dirs; |
|
int ch, use_man_conf; |
size_t terms; |
size_t terms; |
struct opts opts; |
struct opts opts; |
struct expr *e; |
struct expr *e; |
extern int optind; |
extern int optind; |
extern char *optarg; |
extern char *optarg; |
|
|
|
memset(&dirs, 0, sizeof(struct man_conf)); |
memset(&opts, 0, sizeof(struct opts)); |
memset(&opts, 0, sizeof(struct opts)); |
|
use_man_conf = 1; |
|
|
progname = strrchr(argv[0], '/'); |
progname = strrchr(argv[0], '/'); |
if (progname == NULL) |
if (progname == NULL) |
|
|
else |
else |
++progname; |
++progname; |
|
|
while (-1 != (ch = getopt(argc, argv, "S:s:"))) |
while (-1 != (ch = getopt(argc, argv, "M:m:S:s:"))) |
switch (ch) { |
switch (ch) { |
|
case ('M'): |
|
use_man_conf = 0; |
|
/* FALLTHROUGH */ |
|
case ('m'): |
|
manpath_parse(&dirs, optarg); |
|
break; |
case ('S'): |
case ('S'): |
opts.arch = optarg; |
opts.arch = optarg; |
break; |
break; |
|
|
* The index database is a recno. |
* The index database is a recno. |
*/ |
*/ |
|
|
apropos_search(&opts, e, terms, NULL, list); |
if (use_man_conf) |
|
man_conf_parse(&dirs); |
|
apropos_search(dirs.argc, dirs.argv, &opts, |
|
e, terms, NULL, list); |
|
|
|
man_conf_free(&dirs); |
exprfree(e); |
exprfree(e); |
return(EXIT_SUCCESS); |
return(EXIT_SUCCESS); |
} |
} |
|
|
{ |
{ |
|
|
fprintf(stderr, "usage: %s " |
fprintf(stderr, "usage: %s " |
"[-I] " |
"[-M path] " |
|
"[-m path] " |
"[-S arch] " |
"[-S arch] " |
"[-s section] " |
"[-s section] " |
"EXPR\n", |
"EXPR\n", |