version 1.3, 2011/11/24 10:44:56 |
version 1.4, 2011/11/26 22:38:11 |
|
|
#include "config.h" |
#include "config.h" |
#endif |
#endif |
|
|
|
#include <sys/types.h> |
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <limits.h> |
#include <limits.h> |
|
|
static void manpath_add(struct manpaths *, const char *); |
static void manpath_add(struct manpaths *, const char *); |
|
|
void |
void |
manpath_parse(struct manpaths *dirs, char *defp, char *auxp) |
manpath_parse(struct manpaths *dirs, char *defp, char *auxp) |
{ |
{ |
|
|
if (NULL != getenv("MANPATH")) |
manpath_parseline(dirs, auxp); |
|
|
|
if (NULL == defp) |
defp = getenv("MANPATH"); |
defp = getenv("MANPATH"); |
|
|
if (NULL == defp) |
if (NULL == defp) |
manpath_parseconf(dirs); |
manpath_parseconf(dirs); |
else |
else |
manpath_parseline(dirs, defp); |
manpath_parseline(dirs, defp); |
|
|
manpath_parseline(dirs, auxp); |
|
} |
} |
|
|
/* |
/* |
* Parse a FULL pathname from a colon-separated list of arrays. |
* Parse a FULL pathname from a colon-separated list of arrays. |
*/ |
*/ |
void |
void |
manpath_parseline(struct manpaths *dirs, char *path) |
manpath_parseline(struct manpaths *dirs, char *path) |
{ |
{ |
char *dir; |
char *dir; |
|
|
Line 69 manpath_parseline(struct manpaths *dirs, char *path) |
|
Line 70 manpath_parseline(struct manpaths *dirs, char *path) |
|
* Grow the array one-by-one for simplicity's sake. |
* Grow the array one-by-one for simplicity's sake. |
*/ |
*/ |
static void |
static void |
manpath_add(struct manpaths *dirs, const char *dir) |
manpath_add(struct manpaths *dirs, const char *dir) |
{ |
{ |
char buf[PATH_MAX]; |
char buf[PATH_MAX]; |
char *cp; |
char *cp; |
Line 83 manpath_add(struct manpaths *dirs, const char *dir) |
|
Line 84 manpath_add(struct manpaths *dirs, const char *dir) |
|
return; |
return; |
|
|
dirs->paths = mandoc_realloc |
dirs->paths = mandoc_realloc |
(dirs->paths, |
(dirs->paths, |
((size_t)dirs->sz + 1) * sizeof(char *)); |
((size_t)dirs->sz + 1) * sizeof(char *)); |
|
|
dirs->paths[dirs->sz++] = mandoc_strdup(cp); |
dirs->paths[dirs->sz++] = mandoc_strdup(cp); |
Line 143 manpath_manconf(const char *file, struct manpaths *dir |
|
Line 144 manpath_manconf(const char *file, struct manpaths *dir |
|
{ |
{ |
FILE *stream; |
FILE *stream; |
char *p, *q; |
char *p, *q; |
size_t len, keysz; |
size_t len, keysz; |
|
|
keysz = strlen(MAN_CONF_KEY); |
keysz = strlen(MAN_CONF_KEY); |
assert(keysz > 0); |
assert(keysz > 0); |