| 2992 | /*************************************************************/ |
| 2993 | |
| 2994 | static int |
| 2995 | JSON_write(int fd, cJSON *json) |
| 2996 | { |
| 2997 | uint32_t hsize, nsize; |
| 2998 | char *str; |
| 2999 | int r = 0; |
| 3000 | |
| 3001 | str = cJSON_PrintUnformatted(json); |
| 3002 | if (str == NULL) |
| 3003 | r = -1; |
| 3004 | else { |
| 3005 | hsize = strlen(str); |
| 3006 | nsize = htonl(hsize); |
| 3007 | if (Nwrite(fd, (char*) &nsize, sizeof(nsize), Ptcp) < 0) |
| 3008 | r = -1; |
| 3009 | else { |
| 3010 | if (Nwrite(fd, str, hsize, Ptcp) < 0) |
| 3011 | r = -1; |
| 3012 | } |
| 3013 | cJSON_free(str); |
| 3014 | } |
| 3015 | return r; |
| 3016 | } |
| 3017 | |
| 3018 | /*************************************************************/ |
| 3019 |
no test coverage detected
searching dependent graphs…