|
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.
Enumerations | |
| enum | WhenceFlags { WH_ALL = 1 , WH_VERBOSE = 2 } |
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 **sp) |
| Extract the next directory path from the PATH string. | |
| void | normalend () |
| Exit the program successfully. | |
| void | 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 * | file_name [MAXLEN+1] |
| 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 |
| 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 236 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 175 of file whence.c.
References strnz__cat(), and strnz__cpy().
Referenced by whence().
| int main | ( | int | argc, |
| char ** | argv ) |
Definition at line 77 of file whence.c.
References ABEND(), normalend(), path_p, WH_VERBOSE, and whence().
| int next_path | ( | char * | dp, |
| char ** | sp ) |
Extract the next directory path from the PATH string.
| dp | A buffer to store the extracted directory path |
| sp | A pointer to the current position in the PATH string |
This function takes a buffer and a pointer to the current position in the PATH string, and extracts the next directory path. If the next character in the PATH string is a colon, it treats it as an empty path and uses the current working directory. Otherwise, it copies characters until it reaches a colon or the end of the string, and returns the length of the extracted path.
Definition at line 146 of file whence.c.
Referenced by whence().
| void normalend | ( | ) |
| void 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 103 of file whence.c.
References file_spec_parts(), next_path(), path_p, path_s, strnz__cat(), strnz__cpy(), WH_ALL, and WH_VERBOSE.
Referenced by main().
| const char* argp_program_bug_address = "billxwaller@gmail.com" |
| const char* argp_program_version = CM_VERSION |