For internal use only.
This file contains the implementation of the tc_path() function, used to locate files in a given path.
Definition in file tc_path.c.
#include <errno.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "treeconf_int.h"
Include dependency graph for tc_path.c:
Go to the source code of this file.
Data Structures | |
struct | buf |
File name buffer. More... | |
Defines | |
#define | BUF_CHUNK |
Buffer chunk. | |
#define | STOP |
Stop file search loop return value. | |
#define | CONTINUE |
Continue file search loop return value. | |
#define | stop(e) |
Stop file search loop. | |
#define | cont() |
Continue file search loop. | |
#define | _TC_PATH_DEFAULT |
Default path has been searched. | |
#define | _TC_PATH_PERCENT |
Percent character. | |
Functions | |
unsigned int | _get_pwd (struct passwd **pwd_p, const char *uname, int len) |
Look up password structure. | |
unsigned int | _add_str (struct buf *buf, const char *str, int len) |
Add string to buffer. | |
unsigned int | _tilde (struct buf *buf, const char *uname, int len) |
Add user home directory to buffer. | |
int | _subst (struct buf *buf, treeconf_str_t *element, treeconf_subst_t substs[], int s_cnt, unsigned int flags, treeconf_file_t call, void *call_data, unsigned int *err) |
Perform file name substitution and process a file. | |
unsigned int | tc_path (const char *path, const char *def, treeconf_subst_t substs[], int s_cnt, unsigned int flags, treeconf_file_t call, void *call_data) |
Search a path-like string for readable files. |
|
For internal use only. This flag, if set, indicates that the default path has been searched. It is used to avoid searching the default more than once. |
|
For internal use only. This flag, if set, indicates that the previous character processed was a percent character. This will trigger a search of the substitutions passed to _subst() to fill in the appropriate data. |
|
For internal use only. This macro sets the allocation size for a file name. If the buffer is too short to accommodate the name, the buffer size will be incremented by this amount. |
|
For internal use only. This macro exits the _subst() routine with an instruction to tc_path() to continue the file search loop. Definition at line 207 of file tc_path.c. Referenced by _subst(). |
|
For internal use only. The _subst() function is called in a loop by tc_path(). If _subst() returns this value to tc_path(), tc_path() will continue on to the next file in the path. Definition at line 188 of file tc_path.c. Referenced by _subst(). |
|
For internal use only.
This macro exits the _subst() routine with an instruction to tc_path() to terminate the file search loop. It may be used to signal an error condition, thus the
Definition at line 199 of file tc_path.c. Referenced by _subst(). |
|
For internal use only. The _subst() function is called in a loop by tc_path(). If _subst() returns this value to tc_path(), the file search loop will be exited. |
|
For internal use only.
This function simply adds the given
Definition at line 111 of file tc_path.c. References _get_pwd(), buf::len, buf::size, and buf::str. |
Here is the call graph for this function:
|
For internal use only.
This function looks up a given user's password file entry. If
Definition at line 74 of file tc_path.c. Referenced by _add_str(), and _tilde(). |
|
For internal use only.
This is the workhorse routine for tc_path(). This routine is passed an element of the path list, and processes that element, performing tilde and percent substitutions to determine the actual file name. Then, that file is checked for readability; if it is readable, the
Definition at line 257 of file tc_path.c. References _add_str(), _tilde(), access(), cont, CONTINUE, buf::len, stop, buf::str, substs, TC_PATH_ALL, treeconf_str_t, treeconf_subst_t, _treeconf_str_s::ts_length, _treeconf_str_s::ts_string, _treeconf_subst_s::tu_char, _treeconf_subst_s::tu_flags, and tu_value. Referenced by tc_path(). |
Here is the call graph for this function:
|
For internal use only. This simple helper function simply adds the given user's home directory to the file name buffer.
Definition at line 163 of file tc_path.c. References _add_str(), and _get_pwd(). Referenced by _subst(). |
Here is the call graph for this function: