| 209 | } |
| 210 | |
| 211 | bool cbm_daemon_conflict_format(const cbm_daemon_conflict_t *conflict, char *out, size_t out_size) { |
| 212 | if (!out || out_size == 0) { |
| 213 | return false; |
| 214 | } |
| 215 | out[0] = '\0'; |
| 216 | const char *reason = conflict ? conflict_reason(conflict->status) : NULL; |
| 217 | if (!reason || !conflict_valid(conflict)) { |
| 218 | return false; |
| 219 | } |
| 220 | int written; |
| 221 | if (conflict->status == CBM_DAEMON_HELLO_CACHE_CONFLICT) { |
| 222 | written = |
| 223 | snprintf(out, out_size, |
| 224 | "CBM could not start because the active account daemon uses a " |
| 225 | "different cache directory (active cache %s; requested cache %s). " |
| 226 | "Close all CBM sessions and commands, then retry with one " |
| 227 | "consistent CBM_CACHE_DIR.", |
| 228 | conflict->active_cache_fingerprint, conflict->requested_cache_fingerprint); |
| 229 | } else { |
| 230 | written = snprintf(out, out_size, |
| 231 | "CBM could not start because a conflicting CBM process is active " |
| 232 | "(%s; active version %s, build %s; requested version %s, build %s). " |
| 233 | "Close all CBM sessions and commands, then retry.", |
| 234 | reason, conflict->active_version, conflict->active_build_fingerprint, |
| 235 | conflict->requested_version, conflict->requested_build_fingerprint); |
| 236 | } |
| 237 | if (written < 0 || (size_t)written >= out_size) { |
| 238 | out[0] = '\0'; |
| 239 | return false; |
| 240 | } |
| 241 | return true; |
| 242 | } |
| 243 | |
| 244 | static bool json_escape_version(const char *value, char out[DAEMON_SERVICE_ESCAPED_VERSION_CAP]) { |
| 245 | static const char hex[] = "0123456789abcdef"; |
no test coverage detected