-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.h
More file actions
40 lines (28 loc) · 929 Bytes
/
list.h
File metadata and controls
40 lines (28 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <limits.h>
// Portable PATH_MAX definition
#ifndef PATH_MAX
#ifdef _POSIX_PATH_MAX
#define PATH_MAX _POSIX_PATH_MAX
#else
#define PATH_MAX 4096
#endif
#endif
typedef struct linked_list_node *nptr;
typedef struct linked_list_node {
nptr next;
const char *data;
int len;
} linked_list_node;
nptr create_node(const char *w, const int len);
// Create node with normalized path (removes trailing slashes)
nptr create_node_normalized(const char *w, const int len);
char *copy_data(char *buf, nptr node, int max_len);
int valid_path(nptr node);
// Alternative validation with error reporting (not currently used)
// Returns: 1 for valid directory, 0 for invalid, -1 for stat error
int valid_path_verbose(nptr node);
void print_node(nptr node);
int compare_node(nptr lhs, nptr rhs);
int compare_data(nptr lhs, const char *w, const int len);
nptr add_node(nptr node, const char *w, const int len);