Raw ↗
+ +
a18b27f fix(windows): resolve Win32 Winsock, signal, and CLI test compatibility
saifmukhtar · 2026-11-24
1 /*
2 * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0
3 * Copyright (c) 2026 Saif Mukhtar
4 *
5 * OpenAVX - Open Audio-Video eXchange
6 * include/avx_config.h - JSON configuration parser (openavx.json)
7 */
8  
9 #ifndef AVX_CONFIG_H
10 #define AVX_CONFIG_H
11  
12 #include <stdbool.h>
13 #include <stddef.h>
14 #include "openavx.h"
15  
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19  
20 /* Standard JSON Schema URI */
21 #define OAVX_CONFIG_SCHEMA_URI "https://raw.githubusercontent.com/saifmukhtar/openavx/main/schema/v1.0.json"
22  
23 typedef struct avx_config_t {
24 char discovery_servers[512]; /* Registry / discovery servers (e.g. "192.168.1.100:7959,10.0.0.1") */
25 char static_peers[512]; /* Static unicast peer endpoints (e.g. "10.0.0.1,10.0.0.2") */
26 char channels_publish[256]; /* Publish channels / domains (e.g. "Public,StudioA") */
27 char channels_subscribe[256];/* Subscribe channels / domains (e.g. "Public,StudioA") */
28 bool multicast_enabled; /* Multicast transport enabled */
29 int multicast_ttl; /* Multicast packet TTL (default 1) */
30 char multicast_prefix[64]; /* Multicast prefix / CIDR (e.g. "239.255.0.0/16") */
31 char multicast_netmask[64]; /* Multicast netmask (e.g. "255.255.0.0") */
32 int max_clients; /* Max simultaneous client connections per sender (default 32) */
33 char bind_ip[64]; /* Explicit IP or NIC interface to bind (e.g. "10.0.0.100" or "eth1") */
34 char nic_interface[64]; /* Explicit network interface adapter name (e.g. "eth1", "enp4s0") */
35 char transport[32]; /* Transport mode: "tcp" (default), "rudp", or "udp" */
36 bool loaded; /* True if config was successfully loaded from file */
37 char config_path[512]; /* Path to loaded config file */
38 } avx_config_t;
39  
40 /* Initialize and parse configuration from disk according to standard search order:
41 * 0. $OPENAVX_CONFIG_FILE
42 * 1. $OPENAVX_CONFIG_DIR/openavx.json
43 * 2. $HOME/.openavx/openavx.json
44 * 3. /etc/openavx/openavx.json
45 */
46 OPENAVX_API void avx_config_init(void);
47  
48 /* Free/reset cached configuration */
49 OPENAVX_API void avx_config_cleanup(void);
50  
51 /* Get pointer to cached global configuration */
52 OPENAVX_API const avx_config_t* avx_config_get(void);
53  
54 /* Locate configuration file path according to standard precedence.
55 * Returns true if file exists and is readable, populating out_path.
56 */
57 OPENAVX_API bool avx_config_find_path(char* out_path, size_t max_len);
58  
59 /* Pure in-memory JSON parser for openavx.json.
60 * Populates out_cfg with parsed fields.
61 * Returns true if valid JSON and configuration was parsed.
62 */
63 OPENAVX_API bool avx_config_parse_json(const char* json_str, avx_config_t* out_cfg);
64  
65 #ifdef __cplusplus
66 }
67 #endif
68  
69 #endif /* AVX_CONFIG_H */