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) {
11 char *outwalk = buffer;
13 const bool exists = (stat(path, &st) == 0);
17 START_COLOR((exists ? "color_good" : "color_bad"));
19 for (walk = format; *walk != '\0'; walk++) {
25 if (BEGINS_WITH(walk + 1, "title")) {
26 outwalk += sprintf(outwalk, "%s", title);
27 walk += strlen("title");
28 } else if (BEGINS_WITH(walk + 1, "status")) {
29 outwalk += sprintf(outwalk, "%s", (exists ? "yes" : "no"));
30 walk += strlen("status");
35 OUTPUT_FULL_TEXT(buffer);