Parse --ui= and --port= into a per-field daemon mutation. */
| 1326 | |
| 1327 | /* Parse --ui= and --port= into a per-field daemon mutation. */ |
| 1328 | static uint8_t parse_ui_flags(int argc, char **argv, bool *ui_enabled, int *ui_port, |
| 1329 | bool *explicit_enable) { |
| 1330 | uint8_t update_mask = 0; |
| 1331 | for (int i = SKIP_ONE; i < argc; i++) { |
| 1332 | if (strncmp(argv[i], "--ui=", SLEN("--ui=")) == 0) { |
| 1333 | *ui_enabled = strcmp(argv[i] + MAIN_FLAG_OFF, "true") == 0; |
| 1334 | if (explicit_enable && *ui_enabled) { |
| 1335 | *explicit_enable = true; |
| 1336 | } |
| 1337 | update_mask |= CBM_DAEMON_APPLICATION_UI_CONFIG_ENABLED; |
| 1338 | } |
| 1339 | if (strncmp(argv[i], "--port=", SLEN("--port=")) == 0) { |
| 1340 | const char *value = argv[i] + MAIN_PORT_OFF; |
| 1341 | char *end = NULL; |
| 1342 | errno = 0; |
| 1343 | long port = strtol(value, &end, CBM_DECIMAL_BASE); |
| 1344 | if (errno == 0 && end != value && end && *end == '\0' && port > 0 && |
| 1345 | port < MAIN_MAX_PORT) { |
| 1346 | *ui_port = (int)port; |
| 1347 | update_mask |= CBM_DAEMON_APPLICATION_UI_CONFIG_PORT; |
| 1348 | } |
| 1349 | } |
| 1350 | } |
| 1351 | return update_mask; |
| 1352 | } |
| 1353 | |
| 1354 | /* Install platform-specific signal handlers. */ |
| 1355 | static void setup_signal_handlers(void) { |