diff options
| author | @syxhe <https://t.me/syxhe> | 2025-04-15 18:02:06 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2025-04-15 18:02:06 -0500 |
| commit | 54b82706a01049e4ed5e4d417f50f642c701105b (patch) | |
| tree | e0749b503a5cf5351fd46db1990bdd266f02c22d /src/main.c | |
| parent | fce48bb669691b6d3690b032f7a88e22c6f5614a (diff) | |
Finish prototype scanning code
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 22 |
1 files changed, 13 insertions, 9 deletions
| @@ -22,6 +22,13 @@ int selector(const struct dirent *ent) { | |||
| 22 | return 1; | 22 | return 1; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | int printnames(void *data) { | ||
| 26 | struct dirent *node = (struct dirent *)data; | ||
| 27 | |||
| 28 | printf("%s\n", (node) ? node->d_name : "null"); | ||
| 29 | return 0; | ||
| 30 | } | ||
| 31 | |||
| 25 | int main() { | 32 | int main() { |
| 26 | // error(1, ENOTSUP, "No main file lol"); | 33 | // error(1, ENOTSUP, "No main file lol"); |
| 27 | 34 | ||
| @@ -32,16 +39,13 @@ int main() { | |||
| 32 | if(numentries < 0) | 39 | if(numentries < 0) |
| 33 | error(1, errno, "Ran into error scanning dir"); | 40 | error(1, errno, "Ran into error scanning dir"); |
| 34 | 41 | ||
| 35 | dlinkedlist *ll = dlinkedlist_init(); | 42 | dlinkedlist *list = dlinkedlist_init(); |
| 36 | for(int i = 0; i < numentries; i++) { | 43 | for(int i = 0; i < numentries; i++) |
| 37 | if(dlinkedlist_append(ll, (void *)namelist[i], free) != 0) | 44 | dlinkedlist_append(list, (void *)(namelist[i]), free); |
| 38 | error(1, errno, "Could not add file entry to linked list"); | ||
| 39 | |||
| 40 | free(namelist[i]); | ||
| 41 | } | ||
| 42 | free(namelist); | 45 | free(namelist); |
| 43 | 46 | ||
| 44 | dlinkedlist_free(&ll); | 47 | dlinkedlist_foreach(list, printnames); |
| 48 | dlinkedlist_free(list); | ||
| 45 | 49 | ||
| 46 | return 0; | 50 | return 0; |
| 47 | } \ No newline at end of file | 51 | } \ No newline at end of file |
