diff options
-rw-r--r-- | include/spm.h | 12 | ||||
-rw-r--r-- | src/fs.c | 6 | ||||
-rw-r--r-- | src/manifest.c | 6 | ||||
-rw-r--r-- | src/relocation.c | 2 | ||||
-rw-r--r-- | src/strings.c | 12 |
5 files changed, 22 insertions, 16 deletions
diff --git a/include/spm.h b/include/spm.h index bf04fd3..c011e34 100644 --- a/include/spm.h +++ b/include/spm.h @@ -214,6 +214,12 @@ void strsort(char **arr); int find_in_file(const char *filename, const char *pattern); int isrelational(char ch); void print_banner(const char *s, int len); +char *strstr_array(char **arr, const char *str); +char **strdeldup(char **arr); +char *lstrip(char *sptr); +char *strip(char *sptr); +int isempty(char *sptr); +int isquoted(char *sptr); // find.c char *find_executable(const char *program); @@ -233,7 +239,7 @@ int rpath_set(const char *filename, const char *rpath); // fs.c int _fstree_compare(const FTSENT **a, const FTSENT **b); void fstree_free(FSTree *fsdata); -FSTree *fstree(const char *_path); +FSTree *fstree(const char *_path, char **filter_by); int rmdirs(const char *_path); long int get_file_size(const char *filename); int mkdirs(const char *_path, mode_t mode); @@ -261,10 +267,6 @@ int install(const char *destroot, const char *_package); // config.c #define CONFIG_BUFFER_SIZE 1024 -char *lstrip(char *sptr); -char *strip(char *sptr); -int isempty(char *sptr); -int isquoted(char *sptr); ConfigItem **config_read(const char *filename); ConfigItem *config_get(ConfigItem **item, const char *key); void config_free(ConfigItem **item); @@ -8,8 +8,8 @@ * @param _path * @return */ -FSTree *fstree(const char *_path) { - // TODO: Add an argument to filter FSTree content... probably a callback function +FSTree *fstree(const char *_path, char **filter_by) { + // TODO: Implement filter_by FTS *parent = NULL; FTSENT *node = NULL; FSTree *fsdata = NULL; @@ -89,7 +89,7 @@ int rmdirs(const char *_path) { return -1; } - FSTree *data = fstree(_path); + FSTree *data = fstree(_path, NULL); if (data->files) { for (size_t i = 0; data->files[i] != NULL; i++) { remove(data->files[i]); diff --git a/src/manifest.c b/src/manifest.c index c401cb2..df8d056 100644 --- a/src/manifest.c +++ b/src/manifest.c @@ -13,7 +13,11 @@ */ Manifest *manifest_from(const char *package_dir) { FSTree *fsdata = NULL; - fsdata = fstree(package_dir); + char *filter[] = { + SPM_PACKAGE_EXTENSION, + NULL, + }; + fsdata = fstree(package_dir, filter); Manifest *info = (Manifest *)calloc(1, sizeof(Manifest)); info->records = fsdata->files_length; diff --git a/src/relocation.c b/src/relocation.c index 1ba95d5..9407036 100644 --- a/src/relocation.c +++ b/src/relocation.c @@ -253,7 +253,7 @@ int prefixes_write(const char *output_file, int mode, char **prefix, const char return -1; } - FSTree *fsdata = fstree(tree); + FSTree *fsdata = fstree(tree, NULL); if (!fsdata) { fclose(fp); fprintf(SYSERROR); diff --git a/src/strings.c b/src/strings.c index 0dc9c47..46ef9ea 100644 --- a/src/strings.c +++ b/src/strings.c @@ -368,19 +368,19 @@ void strsortlen(char **arr, unsigned int sort_mode) { * Search for string in an array of strings * @param arr array of strings * @param str string to search for - * @return yes=0, no=1, failure=-1 + * @return yes=`pointer to string`, no=`NULL`, failure=`NULL` */ -int strstr_array(char **arr, const char *str) { - if (!arr) { - return -1; +char *strstr_array(char **arr, const char *str) { + if (arr == NULL) { + return NULL; } for (int i = 0; arr[i] != NULL; i++) { if (strstr(arr[i], str) != NULL) { - return 0; + return arr[i]; } } - return 1; + return NULL; } /** |