PostgreSQL Source Code: src/backend/utils/misc/conffiles.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20
22
27
28
29
30
31
32
33
34
35char *
37{
40 else
41 {
43
44 if (calling_file != NULL)
45 {
46 strlcpy(abs_path, calling_file, sizeof(abs_path));
50 }
51 else
52 {
56 }
58 }
59}
60
61
62
63
64
65
66
67
68
69char **
71 int elevel, int *num_filenames, char **err_msg)
72{
76 char **filenames = NULL;
77 int size_filenames;
78
79
80
81
82
83
84 if (strspn(includedir, " \t\r\n") == strlen(includedir))
85 {
87 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
88 errmsg("empty configuration directory name: \"%s\"",
89 includedir)));
90 *err_msg = "empty configuration directory name";
91 return NULL;
92 }
93
96 if (d == NULL)
97 {
100 errmsg("could not open configuration directory \"%s\": %m",
102 *err_msg = psprintf("could not open directory \"%s\"", directory);
104 }
105
106
107
108
109
110 size_filenames = 32;
111 filenames = (char **) palloc(size_filenames * sizeof(char *));
112 *num_filenames = 0;
113
115 {
118
119
120
121
122
123
124 if (strlen(de->d_name) < 6)
125 continue;
126 if (de->d_name[0] == '.')
127 continue;
128 if (strcmp(de->d_name + strlen(de->d_name) - 5, ".conf") != 0)
129 continue;
130
135 {
137 pfree(filenames);
138 filenames = NULL;
140 }
142 {
143
144 if (*num_filenames >= size_filenames)
145 {
146 size_filenames += 32;
147 filenames = (char **) repalloc(filenames,
148 size_filenames * sizeof(char *));
149 }
151 (*num_filenames)++;
152 }
153 }
154
155
156 if (*num_filenames > 0)
158
160 if (d)
163 return filenames;
164}
static void cleanup(void)
char * AbsoluteConfigLocation(const char *location, const char *calling_file)
char ** GetConfFilesInDir(const char *includedir, const char *calling_file, int elevel, int *num_filenames, char **err_msg)
int errcode_for_file_access(void)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
DIR * AllocateDir(const char *dirname)
struct dirent * ReadDir(DIR *dir, const char *dirname)
PGFileType get_dirent_type(const char *path, const struct dirent *de, bool look_through_symlinks, int elevel)
Assert(PointerIsAligned(start, uint64))
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void join_path_components(char *ret_path, const char *head, const char *tail)
#define is_absolute_path(filename)
void canonicalize_path(char *path)
int pg_qsort_strcmp(const void *a, const void *b)
void get_parent_directory(char *path)
#define qsort(a, b, c, d)
size_t strlcpy(char *dst, const char *src, size_t siz)
char * psprintf(const char *fmt,...)
static const char * directory