| 1 | /* |
| 2 | * Copyright (c) 2015, 2017 Moritz Grimm <[email protected]> |
| 3 | * |
| 4 | * Permission to use, copy, modify, and distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __CFG_PRIVATE_H__ |
| 18 | #define __CFG_PRIVATE_H__cxx . . $ `src/cfg_private.h:18:9`! |
| 19 | |
| 20 | #include "cfg.h"cxx . . $ `<file>/src/cfg.h`/ |
| 21 | |
| 22 | #include <sys/queue.h> |
| 23 | |
| 24 | #include <limits.h> |
| 25 | #include <netdb.h> |
| 26 | #include <stdio.h> |
| 27 | #include <string.h> |
| 28 | |
| 29 | #define UCREDS_SIZEcxx . . $ `src/cfg_private.h:29:9`! 256 |
| 30 | #define CSUITE_SIZEcxx . . $ `src/cfg_private.h:30:9`! 2048 |
| 31 | |
| 32 | struct cfg_programcxx . . $ cfg_program# { |
| 33 | char namecxx . . $ cfg_program#name.[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 34 | enum cfg_config_typecxx . . $ cfg_config_type# config_typecxx . . $ cfg_program#config_type.; |
| 35 | char config_filecxx . . $ cfg_program#config_file.[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 36 | char pid_filecxx . . $ cfg_program#pid_file.[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 37 | int quiet_stderrcxx . . $ cfg_program#quiet_stderr.; |
| 38 | int rtstatus_outputcxx . . $ cfg_program#rtstatus_output.; |
| 39 | unsigned int verbositycxx . . $ cfg_program#verbosity.; |
| 40 | }; |
| 41 | |
| 42 | struct cfgcxx . . $ cfg# { |
| 43 | cfg_decoder_list_tcxx . . $ cfg_decoder_list_t# decoderscxx . . $ cfg#decoders.; |
| 44 | cfg_encoder_list_tcxx . . $ cfg_encoder_list_t# encoderscxx . . $ cfg#encoders.; |
| 45 | cfg_intake_list_tcxx . . $ cfg_intake_list_t# intakescxx . . $ cfg#intakes.; |
| 46 | cfg_server_list_tcxx . . $ cfg_server_list_t# serverscxx . . $ cfg#servers.; |
| 47 | cfg_stream_list_tcxx . . $ cfg_stream_list_t# streamscxx . . $ cfg#streams.; |
| 48 | struct metadatacxx . . $ metadata# { |
| 49 | char programcxx . . $ metadata#program.[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 50 | char *format_strcxx . . $ metadata#format_str.; |
| 51 | int refresh_intervalcxx . . $ metadata#refresh_interval.; |
| 52 | int normalize_stringscxx . . $ metadata#normalize_strings.; |
| 53 | int no_updatescxx . . $ metadata#no_updates.; |
| 54 | } metadatacxx . . $ cfg#metadata.; |
| 55 | }; |
| 56 | |
| 57 | #define SET_STRLCPYcxx . . $ `src/cfg_private.h:57:9`!(t, s, e) do { \ |
| 58 | if (!(s) || !(s)[0]) { \ |
| 59 | if ((e)) \ |
| 60 | *(e) = "empty"; \ |
| 61 | return (-1); \ |
| 62 | } \ |
| 63 | if (sizeof((t)) <= \ |
| 64 | strlcpy((t), (s), sizeof((t)))) { \ |
| 65 | if ((e)) \ |
| 66 | *(e) = "too long"; \ |
| 67 | return (-1); \ |
| 68 | } \ |
| 69 | } while (0) |
| 70 | |
| 71 | #define SET_XSTRDUPcxx . . $ `src/cfg_private.h:71:9`!(t, s, e) do { \ |
| 72 | if (!(s) || !(s)[0]) { \ |
| 73 | if ((e)) \ |
| 74 | *(e) = "empty"; \ |
| 75 | return (-1); \ |
| 76 | } \ |
| 77 | xfreecxx . . $ `src/xalloc.h:26:9`!((t)); \ |
| 78 | (t) = xstrdupcxx . . $ `src/xalloc.h:25:9`!((s)); \ |
| 79 | } while (0) |
| 80 | |
| 81 | #define SET_BOOLEANcxx . . $ `src/cfg_private.h:81:9`!(t, s, e) do { \ |
| 82 | int val; \ |
| 83 | if (!(s) || !(s)[0]) { \ |
| 84 | if ((e)) \ |
| 85 | *(e) = "empty"; \ |
| 86 | return (-1); \ |
| 87 | } \ |
| 88 | if (0 == strcasecmp((s), "true") || \ |
| 89 | 0 == strcasecmp((s), "yes") || \ |
| 90 | 0 == strcasecmp((s), "1")) { \ |
| 91 | val = 1; \ |
| 92 | } else if (0 == strcasecmp((s), "false") || \ |
| 93 | 0 == strcasecmp((s), "no") || \ |
| 94 | 0 == strcasecmp((s), "0")) { \ |
| 95 | val = 0; \ |
| 96 | } else { \ |
| 97 | if ((e)) \ |
| 98 | *(e) = "invalid"; \ |
| 99 | return (-1); \ |
| 100 | } \ |
| 101 | (t) = val; \ |
| 102 | } while (0) |
| 103 | |
| 104 | #define SET_UINTNUMcxx . . $ `src/cfg_private.h:104:9`!(t, s, e) do { \ |
| 105 | const char *errstr; \ |
| 106 | unsigned int num; \ |
| 107 | \ |
| 108 | if (!(s) || !(s)[0]) { \ |
| 109 | if ((e)) \ |
| 110 | *(e) = "empty"; \ |
| 111 | return (-1); \ |
| 112 | } \ |
| 113 | \ |
| 114 | num = (unsigned int)strtonum((s), 0, UINT_MAXcxx . . $ `<external>/2419331716647297546/limits.h:124:9`!, &errstr); \ |
| 115 | if (errstr) { \ |
| 116 | if ((e)) \ |
| 117 | *(e) = errstr; \ |
| 118 | return (-1); \ |
| 119 | } \ |
| 120 | (t) = num; \ |
| 121 | } while (0) |
| 122 | |
| 123 | #define SET_INTNUMcxx . . $ `src/cfg_private.h:123:9`!(t, s, e) do { \ |
| 124 | const char *errstr; \ |
| 125 | int num; \ |
| 126 | \ |
| 127 | if (!(s) || !(s)[0]) { \ |
| 128 | if ((e)) \ |
| 129 | *(e) = "empty"; \ |
| 130 | return (-1); \ |
| 131 | } \ |
| 132 | \ |
| 133 | num = (int)strtonum((s), INT_MINcxx . . $ `<external>/2419331716647297546/limits.h:118:9`!, INT_MAXcxx . . $ `<external>/2419331716647297546/limits.h:120:9`!, &errstr); \ |
| 134 | if (errstr) { \ |
| 135 | if ((e)) \ |
| 136 | *(e) = errstr; \ |
| 137 | return (-1); \ |
| 138 | } \ |
| 139 | (t) = num; \ |
| 140 | } while (0) |
| 141 | |
| 142 | #define CHECKPH_PROHIBITEDcxx . . $ `src/cfg_private.h:142:9`!(s, p) do { \ |
| 143 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! != strstrcxx . . $ `<external>/13506128340496143423/string.h:380:11`!((s), (p))) { \ |
| 144 | if (errstrp) \ |
| 145 | *errstrp = "prohibited placeholder " p; \ |
| 146 | return (-1); \ |
| 147 | } \ |
| 148 | } while (0) |
| 149 | |
| 150 | #define CHECKPH_DUPLICATEcxx . . $ `src/cfg_private.h:150:9`!(s, p) do { \ |
| 151 | char *c; \ |
| 152 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! != (c = strstrcxx . . $ `<external>/13506128340496143423/string.h:380:11`!((s), (p)))) { \ |
| 153 | c += strlen((p)); \ |
| 154 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! != strstrcxx . . $ `<external>/13506128340496143423/string.h:380:11`!(c, (p))) { \ |
| 155 | if (errstrp) \ |
| 156 | *errstrp = "duplicate placeholder " p; \ |
| 157 | return (-1); \ |
| 158 | } \ |
| 159 | } \ |
| 160 | } while (0) |
| 161 | |
| 162 | #define CHECKPH_REQUIREDcxx . . $ `src/cfg_private.h:162:9`!(s, p) do { \ |
| 163 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! == strstrcxx . . $ `<external>/13506128340496143423/string.h:380:11`!((s), (p))) { \ |
| 164 | if (errstrp) \ |
| 165 | *errstrp = "missing placeholder " p; \ |
| 166 | return (-1); \ |
| 167 | } \ |
| 168 | } while (0) |
| 169 | |
| 170 | #endif /* __CFG_PRIVATE_H__ */ |