|
C-Menu 0.2.9
A User Interface Toolkit
|
Find the full path of a file in the directories specified by the. More...
#include <argp.h>#include <cm.h>#include <fcntl.h>#include <limits.h>#include <stdbool.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>Go to the source code of this file.
Macros | |
| #define | _GNU_SOURCE |
Enumerations | |
| enum | WhenceFlags { WH_ALL = 1 , WH_VERBOSE = 2 , WH_EXECUTABLE = 4 , WH_SETUID = 8 } |
Functions | |
| void | ABEND (char *pgmid, int rc, char *err_msg) |
| Exit the program with an error message. | |
| int | file_spec_parts (char *file_spec, char *file_path, char *file_name) |
| Split a file specification into directory and file name components. | |
| int | main (int argc, char **argv) |
| int | next_path (char *dp, char **pp) |
| Get the next directory path from a colon-separated list of paths. | |
| size_t | strnz__cat (char *, const char *, size_t) |
| safer alternative to strncat | |
| size_t | strnz__cat (char *d, const char *s, size_t max_len) |
| safer alternative to strncat | |
| size_t | strnz__cpy (char *, const char *, size_t) |
| safer alternative to strncpy | |
| size_t | strnz__cpy (char *d, const char *s, size_t max_len) |
| safer alternative to strncpy | |
| int | whence (char *file_spec_p, int flags) |
| Find the full path of a file in the directories specified by the PATH environment variable. | |
Variables | |
| const char * | argp_program_bug_address = "billxwaller@gmail.com" |
| const char * | argp_program_version = CM_VERSION |
| char * | path_p |
| char | path_s [MAXLEN] |
| int | wh_flags = 0 |
Find the full path of a file in the directories specified by the.
Definition in file whence.c.
| enum WhenceFlags |
| Enumerator | |
|---|---|
| WH_ALL | |
| WH_VERBOSE | |
| WH_EXECUTABLE | |
| WH_SETUID | |
| void ABEND | ( | char * | pgmid, |
| int | rc, | ||
| char * | err_msg ) |
Exit the program with an error message.
| pgmid | The name of the program |
| rc | The return code to exit with |
| err_msg | The error message to display |
This function is called to exit the program with an error status. It prints the program name, return code, and error message to the standard error stream, and then exits with the specified return code.
Definition at line 266 of file whence.c.
| int file_spec_parts | ( | char * | file_spec, |
| char * | file_path, | ||
| char * | file_name ) |
Split a file specification into directory and file name components.
| file_spec | The full file specification to split |
| file_path | A buffer to store the extracted directory path |
| file_name | A buffer to store the extracted file name |
This function takes a file specification, checks if it is a directory, and if so, it sets the file path accordingly. If the file specification is empty, it defaults to the current directory. Otherwise, it splits the file specification into the directory and file name components based on the last occurrence of a slash ('/').
Definition at line 209 of file whence.c.
References strnz__cat(), and strnz__cpy().
Referenced by whence().
| int main | ( | int | argc, |
| char ** | argv ) |
Definition at line 90 of file whence.c.
References ABEND(), path_p, WH_VERBOSE, and whence().
| int next_path | ( | char * | dp, |
| char ** | pp ) |
Get the next directory path from a colon-separated list of paths.
| dp | A buffer to store the extracted directory path |
| pp | A pointer to the current position in the path string |
This function takes a pointer to a colon-separated list of paths and extracts the next directory path from it. If the current character is a colon, it retrieves the current working directory instead. The extracted directory path is stored in the provided buffer, and the function returns the length of the extracted path.
Definition at line 180 of file whence.c.
Referenced by whence().
| int whence | ( | char * | file_spec_p, |
| int | flags ) |
Find the full path of a file in the directories specified by the PATH environment variable.
| file_spec_p | The file specification to search for |
| flags | Flags to control the behavior of the search (e.g., verbose mode, list all matches) |
This function takes a file specification, extracts the directory and file name components, and searches through the directories specified in the PATH environment variable to find matches. It prints the full path of each match found, and if verbose mode is enabled, it also indicates whether each attempted path was found or not.
Definition at line 119 of file whence.c.
References file_spec_parts(), next_path(), path_p, path_s, strnz__cat(), strnz__cpy(), WH_ALL, WH_EXECUTABLE, WH_SETUID, and WH_VERBOSE.
Referenced by main().
| const char* argp_program_bug_address = "billxwaller@gmail.com" |
| const char* argp_program_version = CM_VERSION |