33 for (
const registry_entry_t *e =
g_category_builders[i].entries; e->long_name != NULL; e++) {
38 if (offset + count <= 2048) {
48 .type = OPTION_TYPE_BOOL,
50 .default_value = NULL,
51 .default_value_size = 0,
59 .optional_arg =
false,
60 .mode_bitmask = OPTION_MODE_NONE,
75 if (!long_name || long_name[0] ==
'\0') {
81 return SET_ERRNO(ERROR_CONFIG,
"Duplicate long option '--%s' at registry indices %zu and %zu", long_name, i, j);
89 if (short_name ==
'\0') {
95 return SET_ERRNO(ERROR_CONFIG,
96 "Duplicate short option '-%c' for '--%s' and '--%s' at registry indices %zu and %zu",
162 option_descriptor_t desc = {0};
164 desc.long_name = entry->long_name;
165 desc.short_name = entry->short_name;
166 desc.type = entry->type;
167 desc.offset = entry->offset;
168 desc.help_text = entry->help_text;
169 desc.group = entry->group;
170 desc.arg_placeholder = entry->arg_placeholder;
171 desc.hide_from_mode_help =
false;
173 desc.hide_from_binary_help = (entry->mode_bitmask == OPTION_MODE_DISCOVERY_SVC);
174 desc.default_value = entry->default_value;
175 desc.required = entry->required;
176 desc.env_var_name = entry->env_var_name;
177 desc.validate = entry->validate_fn;
178 desc.parse_fn = entry->parse_fn;
179 desc.action_fn = NULL;
180 desc.owns_memory = entry->owns_memory;
181 desc.optional_arg = entry->optional_arg;
182 desc.mode_bitmask = entry->mode_bitmask;
183 desc.metadata = entry->metadata;
184 desc.mode_default_getter = entry->mode_default_getter;
202 SET_ERRNO(ERROR_INVALID_PARAM,
"Entry is NULL");
208 const char *hidden_from_binary[] = {NULL};
212 if (for_binary_help) {
214 for (
int i = 0; hidden_from_binary[i] != NULL; i++) {
215 if (strcmp(entry->long_name, hidden_from_binary[i]) == 0) {
222 return (entry->mode_bitmask & OPTION_MODE_ALL) != 0;
227 if (mode < 0 || mode > MODE_DISCOVERY) {
230 option_mode_bitmask_t mode_bit = (1 << mode);
233 if ((entry->mode_bitmask & OPTION_MODE_BINARY) && !(entry->mode_bitmask & mode_bit)) {
237 return (entry->mode_bitmask & mode_bit) != 0;
bool registry_entry_applies_to_mode(const registry_entry_t *entry, asciichat_mode_t mode, bool for_binary_help)
Check if an option applies to the given mode for display purposes.