Argx 1.0.2-build
Simple argument parser made in C
 
Loading...
Searching...
No Matches
Argx.c
Go to the documentation of this file.
1/* src/argxc.c
2 * Owned and created by: pcannon09
3 * Converted to C API
4 */
5
6#include <stdlib.h>
7#include <string.h>
8#include <stdio.h>
9#include <stdbool.h>
10
11#include "../inc/Argx.h"
12#include "../inc/types.h"
13
14// Internal structure definition
15struct Argxc {
16 char *id;
17 char **mainArgs;
19 unsigned int mainArgc;
23};
24
25// Static helper functions
26static char *stringDuplicate(const char *str)
27{
28 if (!str) return NULL;
29 size_t len = strlen(str) + 1;
30 char *dup = malloc(len);
31 if (dup)
32 {
33 memcpy(dup, str, len);
34 }
35 return dup;
36}
37
38static void freeStringArray(char **array, size_t count)
39{
40 if (!array) return;
41 for (size_t i = 0; i < count; i++)
42 {
43 if (array[i]) free(array[i]);
44 }
45
46 if (array)
47 { free(array); array = NULL; }
48}
49
50static void freeOptionsArray(ArgxcOptions *options, size_t count)
51{
52 if (!options) return;
53
54 for (size_t i = 0; i < count; i++)
55 {
56 if (&options[i]) argxcFreeOption(&options[i]);
57 }
58
59 if (options)
60 { free(options); options = NULL; }
61}
62
63// Constructor/Destructor implementations
64Argxc *argxcCreate(const char *id, int argc, char *argv[])
65{
66 Argxc *argxc = malloc(sizeof(Argxc));
67 if (!argxc) return NULL;
68
69 argxc->id = stringDuplicate(id);
70 argxc->mainArgc = argc;
71 argxc->mainArgsCount = argc;
72 argxc->mainArgs = malloc(argc * sizeof(char*));
73 argxc->optionsCount = 0;
74 argxc->optionsCapacity = 10;
75 argxc->options = malloc(argxc->optionsCapacity * sizeof(ArgxcOptions));
76
77 if (!argxc->mainArgs || !argxc->options)
78 {
79 argxcDestroy(argxc);
80 return NULL;
81 }
82
83 for (int i = 0; i < argc; i++)
84 {
85 argxc->mainArgs[i] = stringDuplicate(argv[i]);
86 }
87
88 return argxc;
89}
90
92{
93 Argxc *argxc = malloc(sizeof(Argxc));
94 if (!argxc) return NULL;
95
96 argxc->id = NULL;
97 argxc->mainArgs = NULL;
98 argxc->mainArgsCount = 0;
99 argxc->mainArgc = 0;
100 argxc->optionsCount = 0;
101 argxc->optionsCapacity = 10;
102 argxc->options = malloc(argxc->optionsCapacity * sizeof(ArgxcOptions));
103
104 if (!argxc->options)
105 {
106 free(argxc); argxc = NULL;
107 return NULL;
108 }
109
110 return argxc;
111}
112
113void argxcDestroy(Argxc *argxc)
114{
115 if (!argxc) return;
116
117 free(argxc->id); argxc->id = NULL;
118 if (argxc->mainArgs) freeStringArray(argxc->mainArgs, argxc->mainArgsCount);
119 if (argxc->options) freeOptionsArray(argxc->options, argxc->optionsCount);
120 free(argxc); argxc = NULL;
121}
122
123// Core functionality implementations
125{
126 if (!argxc) return;
127
128 if (argxc->optionsCount >= argxc->optionsCapacity)
129 {
130 argxc->optionsCapacity *= 2;
131 argxc->options = realloc(argxc->options, argxc->optionsCapacity * sizeof(ArgxcOptions));
132 if (!argxc->options) return;
133 }
134
135 argxc->options[argxc->optionsCount++] = option;
136}
137
139{
140 if (!parent) return;
141
142 if (parent->subParamsCount >= parent->subParamsCapacity)
143 {
144 size_t newCapacity = parent->subParamsCapacity == 0 ? 2 : parent->subParamsCapacity * 2;
145 ArgxcOptions *newSubParams = realloc(parent->subParams, newCapacity * sizeof(ArgxcOptions));
146 if (!newSubParams) return;
147
148 parent->subParams = newSubParams;
149 parent->subParamsCapacity = newCapacity;
150 }
151
152 parent->subParams[parent->subParamsCount++] = subOption;
153}
154
155int argxcFindParam(Argxc *argxc, const char *id)
156{
157 if (!argxc || !id) return -1;
158
159 // First check if it's a main parameter
160 for (size_t i = 0; i < argxc->optionsCount; i++)
161 {
162 if (argxc->options[i].id && strcmp(argxc->options[i].id, id) == 0)
163 {
164 // Check if this main parameter exists in arguments
165 for (size_t j = 0; j < argxc->mainArgsCount; j++)
166 {
167 if ((argxc->options[i].param && strcmp(argxc->mainArgs[j], argxc->options[i].param) == 0) ||
168 (argxc->options[i].sparam && strcmp(argxc->mainArgs[j], argxc->options[i].sparam) == 0))
169 {
170 return (int)i;
171 }
172 }
173 }
174 }
175
176 // Then look for sub-parameters
177 for (size_t i = 0; i < argxc->optionsCount; i++)
178 {
179 ArgxcOptions *opt = &argxc->options[i];
180
181 // Check if the parent option exists in the arguments
182 bool parentExists = false;
183 for (size_t j = 0; j < argxc->mainArgsCount; j++)
184 {
185 if ((opt->param && strcmp(argxc->mainArgs[j], opt->param) == 0) ||
186 (opt->sparam && strcmp(argxc->mainArgs[j], opt->sparam) == 0))
187 {
188 parentExists = true;
189 break;
190 }
191 }
192
193 if (parentExists)
194 {
195 // Find the index of the requested sub-parameter
196 for (size_t j = 0; j < opt->subParamsCount; j++)
197 {
198 if (opt->subParams[j].id && strcmp(opt->subParams[j].id, id) == 0)
199 {
200 return (int)j;
201 }
202 }
203 }
204 }
205
206 return -1; // Not found
207}
208
209bool argxcParamExists(Argxc *argxc, const char *id)
210{
211 return argxcFindParam(argxc, id) >= 0;
212}
213
214ArgxcParam argxcGetParam(Argxc *argxc, const char *id)
215{
216 ArgxcParam result = {false, NULL, 0};
217
218 if (!argxc || !id || argxc->mainArgc <= 1)
219 {
220 return result;
221 }
222
223 // First, check if this is a top-level option
224 for (size_t i = 0; i < argxc->optionsCount; i++)
225 {
226 ArgxcOptions *opt = &argxc->options[i];
227
228 if (opt->id && strcmp(opt->id, id) == 0)
229 {
230 // Find the position of the main option in arguments
231 int mainOptionPos = -1;
232
233 for (size_t j = 0; j < argxc->mainArgsCount; j++)
234 {
235 if ((opt->param && strcmp(argxc->mainArgs[j], opt->param) == 0) ||
236 (opt->sparam && strcmp(argxc->mainArgs[j], opt->sparam) == 0))
237 {
238 result.exists = true;
239 mainOptionPos = j;
240 break;
241 }
242 }
243
244 if (result.exists)
245 {
246 if (opt->hasSubParams || opt->hasAnySubParams)
247 {
248 // Allocate memory for sub-parameter existence array
249 result.subExistsCount = opt->subParamsCount;
250 result.subExists = malloc(result.subExistsCount * sizeof(bool));
251
252 if (result.subExists)
253 {
254 // Check each sub-parameter
255 for (size_t j = 0; j < opt->subParamsCount; j++)
256 {
257 bool subMatched = false;
258 ArgxcOptions *sub = &opt->subParams[j];
259
260 // Look for sub-parameters after the main option
261 for (size_t k = mainOptionPos + 1; k < argxc->mainArgsCount; k++)
262 {
263 if ((sub->param && strcmp(argxc->mainArgs[k], sub->param) == 0) ||
264 (sub->sparam && strcmp(argxc->mainArgs[k], sub->sparam) == 0))
265 {
266 subMatched = true;
267 break;
268 }
269 }
270
271 result.subExists[j] = subMatched;
272 }
273 }
274 }
275
276 return result;
277 }
278 }
279 }
280
281 // If not found as top-level, check if it's a sub-parameter
282 for (size_t i = 0; i < argxc->optionsCount; i++)
283 {
284 ArgxcOptions *opt = &argxc->options[i];
285
286 // Find if the parent option exists and get its position
287 int parentPos = -1;
288
289 for (size_t j = 0; j < argxc->mainArgsCount; j++)
290 {
291 if ((opt->param && strcmp(argxc->mainArgs[j], opt->param) == 0) ||
292 (opt->sparam && strcmp(argxc->mainArgs[j], opt->sparam) == 0))
293 {
294 parentPos = j;
295 break;
296 }
297 }
298
299 if (parentPos >= 0 && (opt->hasSubParams || opt->hasAnySubParams))
300 {
301 // Check if the requested sub-parameter exists after the parent
302 for (size_t j = 0; j < opt->subParamsCount; j++)
303 {
304 ArgxcOptions *sub = &opt->subParams[j];
305
306 if (sub->id && strcmp(sub->id, id) == 0)
307 {
308 for (size_t k = parentPos + 1; k < argxc->mainArgsCount; k++)
309 {
310 if ((sub->param && strcmp(argxc->mainArgs[k], sub->param) == 0) ||
311 (sub->sparam && strcmp(argxc->mainArgs[k], sub->sparam) == 0))
312 {
313 result.exists = true;
314 break;
315 }
316 }
317
318 if (!result.exists && (size_t)(parentPos + 1) < argxc->mainArgsCount)
319 {
320 char *nextArg = argxc->mainArgs[parentPos + 1];
321
322 if ((sub->param && strcmp(nextArg, sub->param) == 0) ||
323 (sub->sparam && strcmp(nextArg, sub->sparam) == 0))
324 {
325 result.exists = true;
326 }
327 }
328
329 // Handle any sub-sub-parameters if they exist
330 if (result.exists && (sub->hasSubParams || sub->hasAnySubParams))
331 {
332 result.subExistsCount = sub->subParamsCount;
333 result.subExists = malloc(result.subExistsCount * sizeof(bool));
334
335 if (result.subExists)
336 {
337 for (size_t k = 0; k < sub->subParamsCount; k++)
338 {
339 bool subsubMatched = false;
340 ArgxcOptions *subsub = &sub->subParams[k];
341
342 for (size_t l = 0; l < argxc->mainArgsCount; l++)
343 {
344 if ((subsub->param && strcmp(argxc->mainArgs[l], subsub->param) == 0) ||
345 (subsub->sparam && strcmp(argxc->mainArgs[l], subsub->sparam) == 0))
346 {
347 subsubMatched = true;
348 break;
349 }
350 }
351
352 result.subExists[k] = subsubMatched;
353 }
354 }
355 }
356
357 return result;
358 }
359 }
360 }
361 }
362
363 return result;
364}
365
366bool argxcGetSubParam(Argxc *argxc, const ArgxcParam *param, const char *id)
367{
368 if (!argxc || !param || !id) return false;
369
370 int index = argxcFindParam(argxc, id);
371 return argxcParamExists(argxc, id) && param->subExists && index >= 0 &&
372 (size_t)index < param->subExistsCount && param->subExists[index];
373}
374
375char *argxcCreateDocs(Argxc *argxc, ArgxcStyle style, const char *title, const char *mainInfo)
376{
377 if (!argxc) return NULL;
378
379 size_t bufferSize = 4096;
380 char *contentStr = malloc(bufferSize);
381 if (!contentStr) return NULL;
382
383 contentStr[0] = '\0';
384
385 if (style == ARGX_STYLE_PROFESSIONAL)
386 {
387 for (size_t i = 0; i < argxc->optionsCount; i++)
388 {
389 ArgxcOptions *opt = &argxc->options[i];
390
391 // Main option header line
392 char temp[512];
393 snprintf(temp, sizeof(temp), "ID: %s\n", opt->id ? opt->id : "");
394 strcat(contentStr, temp);
395
396 snprintf(temp, sizeof(temp), "[ %s | %s",
397 opt->sparam ? opt->sparam : "",
398 opt->param ? opt->param : "");
399 strcat(contentStr, temp);
400
401 if (opt->hasSubParams && opt->subParamsCount > 0)
402 {
403 strcat(contentStr, " [ ");
404
405 for (size_t j = 0; j < opt->subParamsCount; j++)
406 {
407 strcat(contentStr, opt->subParams[j].param ? opt->subParams[j].param : "");
408
409 if (j < opt->subParamsCount - 1)
410 {
411 strcat(contentStr, " | ");
412 } else if (j <= opt->subParamsCount)
413 {
414 strcat(contentStr, " ");
415 }
416 }
417
418 strcat(contentStr, "] ] ");
419 } else {
420 strcat(contentStr, " ] ");
421 }
422
423 strcat(contentStr, opt->info ? opt->info : "");
424 strcat(contentStr, "\n");
425
426 // Print all sub-options
427 if (opt->hasSubParams && opt->subParamsCount > 0)
428 {
429 for (size_t j = 0; j < opt->subParamsCount; j++)
430 {
431 ArgxcOptions *sub = &opt->subParams[j];
432
433 // Create spacing for alignment
434 size_t paramLen = opt->param ? strlen(opt->param) : 0;
435 for (size_t k = 0; k < paramLen; k++)
436 {
437 strcat(contentStr, " ");
438 }
439
440 snprintf(temp, sizeof(temp), " [ %s | %s ] %s\n",
441 sub->sparam ? sub->sparam : "",
442 sub->param ? sub->param : "",
443 sub->info ? sub->info : "");
444 strcat(contentStr, temp);
445 }
446 }
447 }
448 } else if (style == ARGX_STYLE_SIMPLE)
449 {
450 for (size_t i = 0; i < argxc->optionsCount; i++)
451 {
452 ArgxcOptions *opt = &argxc->options[i];
453
454 char temp[256];
455 snprintf(temp, sizeof(temp), "%s, %s - %s\n",
456 opt->sparam ? opt->sparam : "",
457 opt->param ? opt->param : "",
458 opt->info ? opt->info : "");
459 strcat(contentStr, temp);
460
461 if (opt->hasSubParams && opt->subParamsCount > 0)
462 {
463 for (size_t j = 0; j < opt->subParamsCount; j++)
464 {
465 ArgxcOptions *sub = &opt->subParams[j];
466
467 snprintf(temp, sizeof(temp), " %s, %s - %s\n",
468 sub->sparam ? sub->sparam : "",
469 sub->param ? sub->param : "",
470 sub->info ? sub->info : "");
471 strcat(contentStr, temp);
472 }
473 }
474 }
475 }
476
477 // Combine title, mainInfo, and content
478 size_t titleLen = title ? strlen(title) : 0;
479 size_t mainInfoLen = mainInfo ? strlen(mainInfo) : 0;
480 size_t contentLen = strlen(contentStr);
481 size_t totalLen = titleLen + mainInfoLen + contentLen + 10; // Extra space for newlines
482
483 char *result = malloc(totalLen);
484 if (!result)
485 {
486 free(contentStr); contentStr = NULL;
487 return NULL;
488 }
489
490 snprintf(result, totalLen, "%s\n%s\n%s",
491 title ? title : "",
492 mainInfo ? mainInfo : "",
493 contentStr);
494
495 free(contentStr); contentStr = NULL;
496 return result;
497}
498
499bool argxcCompareArgs(ArgxcOptions *options, size_t optionsCount, char **argv, size_t argvCount)
500{
501 if (!options || !argv) return false;
502
503 for (size_t i = 1; i < argvCount; i++)
504 {
505 const char *arg = argv[i];
506
507 bool found = false;
508 bool hasSubParams = false;
509 bool hasAnySubParams = false;
510 ArgxcOptions *matchedOption = NULL;
511
512 // Find the matching option
513 for (size_t j = 0; j < optionsCount; j++)
514 {
515 if ((options[j].sparam && strcmp(options[j].sparam, arg) == 0) ||
516 (options[j].param && strcmp(options[j].param, arg) == 0))
517 {
518 found = true;
519 hasSubParams = options[j].hasSubParams;
520 hasAnySubParams = options[j].hasAnySubParams;
521 matchedOption = &options[j];
522 break;
523 }
524 }
525
526 if (!found) return false;
527
528 if (hasSubParams || hasAnySubParams)
529 {
530 // Check if there's a next argument
531 if (i + 1 < argvCount)
532 {
533 const char *nextArg = argv[i + 1];
534
535 // Check if next argument is a sub-parameter
536 bool isSubParam = false;
537
538 if (nextArg && strlen(nextArg) > 0 && nextArg[0] != '-')
539 {
540 // Validate if it's a valid sub-parameter
541 for (size_t k = 0; k < matchedOption->subParamsCount; k++)
542 {
543 if ((matchedOption->subParams[k].param && strcmp(matchedOption->subParams[k].param, nextArg) == 0) ||
544 (matchedOption->subParams[k].sparam && strcmp(matchedOption->subParams[k].sparam, nextArg) == 0))
545 {
546 isSubParam = true;
547 break;
548 }
549 }
550
551 if (isSubParam)
552 {
553 i++; // Skip the sub-parameter
554 } else if (hasSubParams || hasAnySubParams)
555 {
556 return false;
557 }
558 } else if (hasSubParams || hasAnySubParams)
559 {
560 return false;
561 }
562 }
563 }
564 }
565
566 return true;
567}
568
569// Getters
570char **argxcGetMainArgs(Argxc *argxc, size_t *count)
571{
572 if (!argxc || !count) return NULL;
573
574 *count = argxc->mainArgsCount;
575
576 // Create a copy of the array
577 char **copy = malloc(argxc->mainArgsCount * sizeof(char*));
578 if (!copy) return NULL;
579
580 for (size_t i = 0; i < argxc->mainArgsCount; i++)
581 {
582 copy[i] = stringDuplicate(argxc->mainArgs[i]);
583 }
584
585 return copy;
586}
587
589{
590 return argxc ? argxc->mainArgc : 0;
591}
592
593ArgxcOptions *argxcGetOptions(Argxc *argxc, size_t *count)
594{
595 if (!argxc || !count) return NULL;
596
597 *count = argxc->optionsCount;
598 return argxc->options; // Return direct reference (be careful with modification)
599}
600
601const char *argxcGetId(Argxc *argxc)
602{
603 return argxc ? argxc->id : NULL;
604}
605
606// Utility functions for memory management
607ArgxcOptions argxcCreateOption(const char *id, const char *param, const char *sparam,
608 const char *info, bool hasSubParams, bool hasAnySubParams)
609{
610 ArgxcOptions option = {0};
611
612 option.id = stringDuplicate(id);
613 option.param = stringDuplicate(param);
614 option.sparam = stringDuplicate(sparam);
615 option.info = stringDuplicate(info);
616 option.hasSubParams = hasSubParams;
617 option.hasAnySubParams = hasAnySubParams;
618 option.subParams = NULL;
619 option.subParamsCount = 0;
620
621 return option;
622}
623
625{
626 if (!option) return;
627
628 if (option->id)
629 { free(option->id); option->id = NULL; }
630 if (option->param)
631 { free(option->param); option->param = NULL; }
632 if (option->sparam)
633 { free(option->sparam); option->sparam = NULL; }
634 if (option->info)
635 { free(option->info); option->info = NULL; }
636
637 if (option->subParams)
638 {
639 for (size_t i = 0; i < option->subParamsCount; i++)
640 {
641 argxcFreeOption(&option->subParams[i]);
642 }
643
644 free(option->subParams);
645 option->subParams = NULL;
646 option->subParamsCapacity = 0;
647 option->subParamsCount = 0;
648 }
649
650 memset(option, 0, sizeof(ArgxcOptions));
651}
652
654{
655 if (!param) return;
656
657 free(param->subExists); param->subExists = NULL;
658 memset(param, 0, sizeof(ArgxcParam));
659}
660
661void argxcFreeStringArray(char **array, size_t count)
662{
663 freeStringArray(array, count);
664}
665
666// Error handling
667ArgxcError argxcCreateError(const char *type, const char *error, const char *help, int code)
668{
669 ArgxcError err = {0};
670
671 err.type = stringDuplicate(type);
672 err.error = stringDuplicate(error);
673 err.help = stringDuplicate(help);
674 err.code = code;
675
676 return err;
677}
678
680{
681 if (!error) return;
682
683 free(error->type); error->type = NULL;
684 free(error->error); error->error = NULL;
685 free(error->help); error->help = NULL;
686 memset(error, 0, sizeof(ArgxcError));
687}
bool argxcParamExists(Argxc *argxc, const char *id)
Check if a parameter with the given ID exists.
Definition Argx.c:209
Argxc * argxcCreate(const char *id, int argc, char *argv[])
Create a new Argxc instance with a specified ID and command-line arguments.
Definition Argx.c:64
bool argxcGetSubParam(Argxc *argxc, const ArgxcParam *param, const char *id)
Retrieve a sub-parameter from a given parameter by ID.
Definition Argx.c:366
int argxcGetArgc(Argxc *argxc)
Get the number of command-line arguments passed.
Definition Argx.c:588
const char * argxcGetId(Argxc *argxc)
Get the identifier of the Argxc instance.
Definition Argx.c:601
bool argxcCompareArgs(ArgxcOptions *options, size_t optionsCount, char **argv, size_t argvCount)
Compare if the given argv matches a list of ArgxcOptions.
Definition Argx.c:499
static void freeStringArray(char **array, size_t count)
Definition Argx.c:38
void argxcFreeStringArray(char **array, size_t count)
Free a string array returned from Argxc (e.g., argv array).
Definition Argx.c:661
int argxcFindParam(Argxc *argxc, const char *id)
Find the index of a parameter by ID.
Definition Argx.c:155
void argxcAddOption(Argxc *argxc, ArgxcOptions option)
Add a new option to the Argxc instance.
Definition Argx.c:124
ArgxcOptions argxcCreateOption(const char *id, const char *param, const char *sparam, const char *info, bool hasSubParams, bool hasAnySubParams)
Create a new option.
Definition Argx.c:607
char ** argxcGetMainArgs(Argxc *argxc, size_t *count)
Get the raw command-line arguments passed to Argxc.
Definition Argx.c:570
void argxcFreeParam(ArgxcParam *param)
Free resources associated with an ArgxcParam struct.
Definition Argx.c:653
void argxcAddSubOption(ArgxcOptions *parent, ArgxcOptions subOption)
Add a sub-option to a parent option.
Definition Argx.c:138
ArgxcParam argxcGetParam(Argxc *argxc, const char *id)
Retrieve a parameter by ID.
Definition Argx.c:214
Argxc * argxcCreateDefault(void)
Create a new Argxc instance with default values (empty ID and no arguments).
Definition Argx.c:91
static char * stringDuplicate(const char *str)
Definition Argx.c:26
void argxcDestroy(Argxc *argxc)
Destroy an Argxc instance and free all associated memory.
Definition Argx.c:113
static void freeOptionsArray(ArgxcOptions *options, size_t count)
Definition Argx.c:50
char * argxcCreateDocs(Argxc *argxc, ArgxcStyle style, const char *title, const char *mainInfo)
Generate documentation for the defined options.
Definition Argx.c:375
void argxcFreeOption(ArgxcOptions *option)
Free resources associated with an ArgxcOptions struct.
Definition Argx.c:624
void argxcFreeError(ArgxcError *error)
Free resources associated with an ArgxcError struct.
Definition Argx.c:679
ArgxcOptions * argxcGetOptions(Argxc *argxc, size_t *count)
Get all top-level options defined for the Argxc instance.
Definition Argx.c:593
ArgxcError argxcCreateError(const char *type, const char *error, const char *help, int code)
Create an ArgxcError object.
Definition Argx.c:667
int code
Definition types.h:19
char * error
Definition types.h:17
char * help
Definition types.h:18
char * type
Definition types.h:16
size_t subParamsCount
Definition types.h:33
char * param
Definition types.h:27
char * sparam
Definition types.h:28
char * id
Definition types.h:26
struct ArgxcOptions * subParams
Definition types.h:32
char * info
Definition types.h:29
size_t subParamsCapacity
Definition types.h:34
bool hasAnySubParams
Definition types.h:31
bool hasSubParams
Definition types.h:30
size_t subExistsCount
Definition types.h:40
bool exists
Definition types.h:38
bool * subExists
Definition types.h:39
Definition Argx.c:15
size_t mainArgsCount
Definition Argx.c:18
char ** mainArgs
Definition Argx.c:17
size_t optionsCapacity
Definition Argx.c:22
char * id
Definition Argx.c:16
size_t optionsCount
Definition Argx.c:21
unsigned int mainArgc
Definition Argx.c:19
ArgxcOptions * options
Definition Argx.c:20
ArgxcStyle
Definition types.h:10
@ ARGX_STYLE_PROFESSIONAL
Definition types.h:11
@ ARGX_STYLE_SIMPLE
Definition types.h:12