diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /indexing/upmendex/source/kp.c |
Initial commit
Diffstat (limited to 'indexing/upmendex/source/kp.c')
-rw-r--r-- | indexing/upmendex/source/kp.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/indexing/upmendex/source/kp.c b/indexing/upmendex/source/kp.c new file mode 100644 index 0000000000..7633f8ebfc --- /dev/null +++ b/indexing/upmendex/source/kp.c @@ -0,0 +1,48 @@ +/* Written by K.Asayayam Sep. 1995 */ + +#include "mendex.h" +#include <kpathsea/expand.h> +#include <kpathsea/pathsearch.h> + +#include "kp.h" + +/* KP_get_path(char *var, char *def_val) + ARGUMENTS: + char *var: name of variable. + char *def_val: default value. + */ +static const char *KP_get_path(const char *var, const char *def_val) +{ + char avar[264]; + const char *p; + strcpy(avar, "${"); + strncat(avar, var, 260); + strcat(avar, "}"); + p = kpse_path_expand(avar); + return (p && *p) ? p : def_val; +} + +/* + */ +void KP_entry_filetype(KpathseaSupportInfo *info) +{ + info->path = KP_get_path(info->var_name,info->path); +} + +/* KP_find_file(KpathseaSupportInfo *info, char *name) + ARGUMENTS: + KpathseaSupportInfo *info: Informations about the type of files. + char *name: Name of file. + */ +const char *KP_find_file(KpathseaSupportInfo *info, const char *name) +{ + char *ret; + ret = kpse_path_search(info->path,name,1); + if (!ret && info->suffix && !find_suffix(name)) { + char *suff_name; + suff_name = concat3(name,".",info->suffix); + ret = kpse_path_search(info->path,suff_name,1); + free(suff_name); + } + return ret ? ret : name; +} |