| … | |
… | |
| 39 | #define RC_LINEBUFFER 4096 |
39 | #define RC_LINEBUFFER 4096 |
| 40 | |
40 | |
| 41 | /* Good defaults just incase user has none set */ |
41 | /* Good defaults just incase user has none set */ |
| 42 | #define RC_NET_FS_LIST_DEFAULT "afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs" |
42 | #define RC_NET_FS_LIST_DEFAULT "afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs" |
| 43 | |
43 | |
|
|
44 | #define ERRX fprintf (stderr, "out of memory\n"); exit (1) |
|
|
45 | |
|
|
46 | static inline void *rc_xmalloc (size_t size) |
|
|
47 | { |
|
|
48 | void *value = malloc (size); |
|
|
49 | |
|
|
50 | if (value) |
|
|
51 | return (value); |
|
|
52 | |
|
|
53 | ERRX; |
|
|
54 | } |
|
|
55 | |
|
|
56 | static inline void *rc_xrealloc (void *ptr, size_t size) |
|
|
57 | { |
|
|
58 | void *value = realloc (ptr, size); |
|
|
59 | |
|
|
60 | if (value) |
|
|
61 | return (value); |
|
|
62 | |
|
|
63 | ERRX; |
|
|
64 | } |
|
|
65 | |
|
|
66 | static inline char *rc_xstrdup (const char *str) |
|
|
67 | { |
|
|
68 | char *value; |
|
|
69 | |
|
|
70 | if (! str) |
|
|
71 | return (NULL); |
|
|
72 | |
|
|
73 | value = strdup (str); |
|
|
74 | |
|
|
75 | if (value) |
|
|
76 | return (value); |
|
|
77 | |
|
|
78 | ERRX; |
|
|
79 | } |
|
|
80 | |
|
|
81 | #undef ERRX |
|
|
82 | |
| 44 | static inline bool rc_exists (const char *pathname) |
83 | static inline bool rc_exists (const char *pathname) |
| 45 | { |
84 | { |
| 46 | struct stat buf; |
85 | struct stat buf; |
| 47 | int serrno = errno; |
86 | int serrno = errno; |
| 48 | |
87 | |