8 #include <cherokee/cherokee.h>
11 get_all_configurations(cherokee_avl_r_t
*avl_r
, cherokee_buffer_t
*user
, cherokee_buffer_t
*buffer
) {
15 struct dirent
*result
;
18 snprintf(file
, 1023, "/mnt/netapp/users/%s", user
->buf
);
20 if ((dir
= opendir(file
)) == NULL
)
21 perror("opendir() error");
23 unsigned int offset
= strlen(file
);
26 for (return_code
= readdir_r(dir
, &entry
, &result
);
27 result
!= NULL
&& return_code
== 0;
28 return_code
= readdir_r(dir
, &entry
, &result
)) {
30 snprintf(&file
[offset
], 1023 - offset
, "%s/index.xml", entry
.d_name
);
32 if (stat(file
, &statbuf
) == 0) {
33 cherokee_buffer_t domain
= CHEROKEE_BUF_INIT
;
34 cherokee_buffer_t
*host
;
35 cherokee_buffer_add_va (&domain
, "%s_%s", user
->buf
, entry
.d_name
);
37 ret_t status
= cherokee_avl_r_get (avl_r
, &domain
, (void **) &host
);
39 cherokee_buffer_add_str (buffer
, " <domain");
41 if (status
== ret_ok
) {
42 cherokee_buffer_add_str (buffer
, " status=\"running\"");
45 cherokee_buffer_add_str (buffer
, "><name>");
46 cherokee_buffer_add_buffer(buffer
, &domain
);
47 cherokee_buffer_add_str (buffer
, "</name></domain>\n");
49 cherokee_buffer_mrproper(&domain
);
51 strcpy(&file
[offset
], "index.xml.deleted");
52 if (stat(file
, &statbuf
) == 0)
53 cherokee_buffer_add_va (buffer
, " <domain status=\"deleted\"><name>%s_%s</name></domain>\n", user
->buf
, entry
.d_name
);
57 perror("readdir_r() error");