MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_daemon_hello_compare

Function cbm_daemon_hello_compare

src/daemon/service.c:164–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164cbm_daemon_hello_status_t cbm_daemon_hello_compare(const cbm_daemon_build_identity_t *active,
165 const cbm_daemon_build_identity_t *requested,
166 cbm_daemon_conflict_t *conflict_out) {
167 if (conflict_out) {
168 memset(conflict_out, 0, sizeof(*conflict_out));
169 conflict_out->status = CBM_DAEMON_HELLO_INVALID;
170 }
171 if (!conflict_out || !identity_valid(active) || !identity_valid(requested)) {
172 return CBM_DAEMON_HELLO_INVALID;
173 }
174
175 (void)snprintf(conflict_out->active_version, sizeof(conflict_out->active_version), "%s",
176 active->semantic_version);
177 (void)snprintf(conflict_out->active_build_fingerprint,
178 sizeof(conflict_out->active_build_fingerprint), "%s", active->build_fingerprint);
179 (void)snprintf(conflict_out->requested_version, sizeof(conflict_out->requested_version), "%s",
180 requested->semantic_version);
181 (void)snprintf(conflict_out->requested_build_fingerprint,
182 sizeof(conflict_out->requested_build_fingerprint), "%s",
183 requested->build_fingerprint);
184 if (active->cache_fingerprint) {
185 (void)snprintf(conflict_out->active_cache_fingerprint,
186 sizeof(conflict_out->active_cache_fingerprint), "%s",
187 active->cache_fingerprint);
188 }
189 if (requested->cache_fingerprint) {
190 (void)snprintf(conflict_out->requested_cache_fingerprint,
191 sizeof(conflict_out->requested_cache_fingerprint), "%s",
192 requested->cache_fingerprint);
193 }
194
195 cbm_daemon_hello_status_t status = CBM_DAEMON_HELLO_COMPATIBLE;
196 if (strcmp(active->semantic_version, requested->semantic_version) != 0) {
197 status = CBM_DAEMON_HELLO_VERSION_CONFLICT;
198 } else if (strcmp(active->build_fingerprint, requested->build_fingerprint) != 0) {
199 status = CBM_DAEMON_HELLO_BUILD_CONFLICT;
200 } else if (active->protocol_abi != requested->protocol_abi) {
201 status = CBM_DAEMON_HELLO_PROTOCOL_ABI_CONFLICT;
202 } else if (active->store_abi != requested->store_abi) {
203 status = CBM_DAEMON_HELLO_STORE_ABI_CONFLICT;
204 } else if (active->feature_abi != requested->feature_abi) {
205 status = CBM_DAEMON_HELLO_FEATURE_ABI_CONFLICT;
206 }
207 conflict_out->status = status;
208 return status;
209}
210
211bool cbm_daemon_conflict_format(const cbm_daemon_conflict_t *conflict, char *out, size_t out_size) {
212 if (!out || out_size == 0) {

Callers 5

version_test_compareFunction · 0.85

Calls 1

identity_validFunction · 0.85

Tested by 2

version_test_compareFunction · 0.68