Strict shared fields and deterministic application_settings.ini lookup. More...
#include "inference_settings.h"#include <stdio.h>#include <string.h>#include <sys/stat.h>#include <unistd.h>
Go to the source code of this file.
Data Structures | |
| struct | settings_parser |
| Borrowed dispatch state scoped to one destructive INI parse. More... | |
Functions | |
| void | inference_settings_init (struct inference_settings *settings, enum inference_backend backend) |
| Reset storage and select conservative thread/timeout defaults. | |
| static bool | text_copy (char *destination, size_t capacity, const char *source) |
| Reject truncation and control characters before accepting configuration text. | |
| int | inference_settings_field (struct inference_settings *settings, const char *key, const char *value) |
| Parse one common key without consuming module-specific keys. | |
| bool | inference_resolve_path (const char *base_file, const char *value, char *destination, size_t capacity) |
| Resolve an INI-relative path without requiring its destination to exist yet. | |
| static bool | settings_field (void *context, const char *key, const char *value) |
| Delegate only unknown common keys; an invalid common key must not be accepted by a module. | |
| bool | inference_settings_read (struct inference_settings *settings, const char *filename, ini_field_handler extra, void *context, char *error, size_t capacity) |
| Parse one flat INI, delegate application keys and resolve paths against the selected file. | |
| bool | inference_settings_find (const char *application, const char *module, char *filename, size_t capacity) |
| Discover application_settings.ini in adjacent, development-module, then installed-share order. | |
Detailed Description
Strict shared fields and deterministic application_settings.ini lookup.
Module callbacks own module-specific keys; this layer never guesses a model's meaning.
Definition in file inference_settings.c.
Function Documentation
◆ inference_resolve_path()
| bool inference_resolve_path | ( | const char * | base_file, |
| const char * | value, | ||
| char * | destination, | ||
| size_t | capacity ) |
Resolve an INI-relative path without requiring its destination to exist yet.
- Parameters
-
base_file Settings filename whose parent supplies the relative base. value Absolute or relative path; control characters are rejected. destination Writable normalized absolute path, distinct from the inputs. capacity Destination capacity including its terminator.
- Returns
- True for a complete, nontruncated path. This is lexical normalization, not symlink resolution.
Definition at line 93 of file inference_settings.c.
◆ inference_settings_field()
| int inference_settings_field | ( | struct inference_settings * | settings, |
| const char * | key, | ||
| const char * | value ) |
Parse one common key without consuming module-specific keys.
- Parameters
-
settings Initialized destination; its seen mask rejects duplicates. key Flat key emitted by the bounded INI parser. value Nonempty parsed value; no pointer into it is retained.
- Returns
- One if accepted, zero if unknown, minus one if invalid/duplicate.
Definition at line 53 of file inference_settings.c.
◆ inference_settings_find()
| bool inference_settings_find | ( | const char * | application, |
| const char * | module, | ||
| char * | filename, | ||
| size_t | capacity ) |
Discover application_settings.ini in adjacent, development-module, then installed-share order.
Supports both bin/ application executables and the root-level USHER owner, without consulting the caller's current directory.
- Parameters
-
application Lowercase executable name without an architecture suffix. module Lowercase module directory name, such as spotter_cam. filename Destination path; meaningful only on success. capacity Available bytes in filename.
- Returns
- True after finding a regular file, never a current-directory fallback.
Definition at line 202 of file inference_settings.c.
◆ inference_settings_init()
| void inference_settings_init | ( | struct inference_settings * | settings, |
| enum inference_backend | backend ) |
Reset storage and select conservative thread/timeout defaults.
- Parameters
-
settings Writable owner, or NULL to do nothing. backend Application default used when the INI omits the backend.
Definition at line 28 of file inference_settings.c.
◆ inference_settings_read()
| bool inference_settings_read | ( | struct inference_settings * | settings, |
| const char * | filename, | ||
| ini_field_handler | extra, | ||
| void * | context, | ||
| char * | error, | ||
| size_t | capacity ) |
Parse one flat INI, delegate application keys and resolve paths against the selected file.
- Parameters
-
settings Initialized destination; discard partially parsed values on failure. filename Selected settings file, independent of the caller's current directory. extra Optional handler for application-specific fields. context Borrowed extra-handler state, used only during this call. error Writable failure diagnostic, cleared on success. capacity Available bytes in error.
- Returns
- True for valid bounded syntax, accepted fields and resolvable lexical paths.
AUTO resolves .onnx/.rpk suffixes and an omitted ONNX descriptor to the same-name .ini. It does not test availability or fall back after errors.
Definition at line 158 of file inference_settings.c.
◆ settings_field()
|
static |
Delegate only unknown common keys; an invalid common key must not be accepted by a module.
Definition at line 151 of file inference_settings.c.
◆ text_copy()
|
static |
Reject truncation and control characters before accepting configuration text.
Definition at line 40 of file inference_settings.c.