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

Function cbm_env_long

src/foundation/platform.c:473–495  ·  view source on GitHub ↗

See platform.h. The shape here is the one src/main.c:1104 already uses for * --port=: an end pointer says where the read stopped, errno catches a number * too large, and *end == '\0' catches anything left over. */

Source from the content-addressed store, hash-verified

471 * --port=: an end pointer says where the read stopped, errno catches a number
472 * too large, and *end == '\0' catches anything left over. */
473bool cbm_env_long(const char *name, long *out) {
474 if (!out) {
475 return false;
476 }
477 char raw[CBM_SZ_64] = {0};
478 if (!cbm_safe_getenv(name, raw, sizeof(raw), NULL) || !raw[0]) {
479 return false;
480 }
481 /* strtol skips leading blanks of its own accord, so " 5" would read as 5.
482 * A blank in front of a setting is a slip, not a number, so refuse it here
483 * rather than let strtol quietly step over it. */
484 if (isspace((unsigned char)raw[0])) {
485 return false;
486 }
487 char *end = NULL;
488 errno = 0;
489 long value = strtol(raw, &end, CBM_DECIMAL_BASE);
490 if (errno != 0 || !end || end == raw || *end != '\0') {
491 return false;
492 }
493 *out = value;
494 return true;
495}
496
497/* ── Home directory (cross-platform) ───────────────────── */
498

Callers 4

ha_deadline_msFunction · 0.85
index_restart_capFunction · 0.85
worker_quiet_timeout_msFunction · 0.85
test_platform.cFile · 0.85

Calls 1

cbm_safe_getenvFunction · 0.85

Tested by

no test coverage detected