1 // vim:ts=4:sw=4:expandtab
4 #include <yajl/yajl_gen.h>
5 #include <yajl/yajl_version.h>
9 void print_path_exists(yajl_gen json_gen, char *buffer, const char *title, const char *path, const char *format, const char *format_down) {
11 char *outwalk = buffer;
13 const bool exists = (stat(path, &st) == 0);
15 if (exists || format_down == NULL) {
23 START_COLOR((exists ? "color_good" : "color_bad"));
25 for (; *walk != '\0'; walk++) {
29 } else if (BEGINS_WITH(walk + 1, "title")) {
30 outwalk += sprintf(outwalk, "%s", title);
31 walk += strlen("title");
33 } else if (BEGINS_WITH(walk + 1, "status")) {
34 outwalk += sprintf(outwalk, "%s", (exists ? "yes" : "no"));
35 walk += strlen("status");
43 OUTPUT_FULL_TEXT(buffer);