aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fs.c6
-rw-r--r--src/manifest.c6
-rw-r--r--src/relocation.c2
-rw-r--r--src/strings.c12
4 files changed, 15 insertions, 11 deletions
diff --git a/src/fs.c b/src/fs.c
index 42172f9..f729c2a 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -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;
}
/**