GETALLARGS(3)
π GETALLARGS(3) β SchilyΒ΄s LIBRARY FUNCTIONS, bestie edition π
okay so this page lives in section 3 of SchilyΒ΄s LIBRARY FUNCTIONS and it's literally all about letting getallargs() do the flag-wrangling for you. it's giving "let the library handle the boring part" energy and honestly? we love that for us β¨
πΈ NAME πΈ
getallargs() β parses all the flag-type arguments. that's it, that's the vibe. π¦
β¨ SYNOPSIS β¨
#include <schily/getargs.h>
int getallargs(pac, pav, fmt, a1, ..., an)
int *pac; /* pointer to arg count */
char *(*pav)[]; /* pointer to address of arg vector */
char *fmt; /* format string */
type *a1; /* pointer to result 1 */
/* (corresponding to the */
/* first descriptor in fmt) */
type *an; /* pointer to result n */
/* (corresponding to the */
/* nth descriptor in fmt) */
int getlallargs(pac, pav, props, fmt, a1, ..., an)
int *pac; /* pointer to arg count */
char *(*pav)[]; /* pointer to address of arg vector */
struct ga_props *props; /* control properties */
char *fmt; /* format string */
type *a1; /* pointer to result 1 */
/* (corresponding to the */
/* first descriptor in fmt) */
type *an; /* pointer to result n */
/* (corresponding to the */
/* nth descriptor in fmt) */
int getvallargs(pac, pav, props, vfmt)
int *pac; /* pointer to arg count */
char *(*pav)[]; /* pointer to address of arg vector */
struct ga_props *props; /* control properties */
struct ga_flags *vfmt; /* array of formats and args */
like, look at those three siblings. iconic family lineup fr fr π
π DESCRIPTION π
getallargs() is part of the advanced option parsing interface β it's literally in the same friend group as the getargs() and getfiles() family π«Ά
getallargs() parses all flag (option) arguments, and bestie, "anywhere on the command line" means anywhere. it does not return until all the arguments have been parsed correctly (returning 0), or an error has occurred (returning < 0). no half-jobs, no "ehh close enough" β it commits to the bit π
getlallargs() is similar to getallargs() but it implements an additional ga_props parameter that must be initialized with getarginit() before it is passed. like, do not skip that step, that's the whole point π
getvallargs() is similar to getlallargs() but uses a structure ga_flags instead of a format string and a variable arg list with pointers. here's the array of structures ga_flags in all its glory:
struct ga_flags {
const char *ga_format; /* Comma separated list for one flag */
void *ga_arg; /* Ptr. to variable to fill for flag */
getpargfun ga_funcp; /* Ptr. for function to call (&/~) */
};
the array is terminated by an element with ga_format == NULL. and for a ga_format that does not expect a function pointer, ga_funcp is NULL. no cap, that's how you know it's done π
if you want a more detailed description of the parameter matching, go see getargs() β it's the lore drop you're looking for π
π RETURNS π
NOARGS0β all arguments have been successfully examined. slay πBADFLAG-1β a bad flag (option) argument was supplied to the program. the argument*pavcontains the offending command line argument. (rude of it, but ok π)BADFMT-2β a bad format descriptor string has been detected. this means an error in the calling program, not a user input data error. so likeβ¦ that one's on you, bestie π
β general rules for the return code β
> 0β a file type argument was found.0β all arguments have been parsed.< 0β an error occurred or not a file type argument.
flag and file arg processing should be terminated after getting a return code <= 0. like, that's your cue to stop. take the hint π
π¦ SEE ALSO π¦
getargs(3), getargerror(3), getfiles(3). the whole squad, go read them π
π NOTES π
getallargs() must be called with the address of a count of items in the vector and the address of a pointer to the vector. both addresses must already have been properly treated in order to skip over the first parameter which is the name of the program. e.g. --ac; ++av β yes, exactly like that β¨
since getallargs() will destroy these values, copies should be made for later use in the program. and if an error occurs, av[0] points to the unmatched argument. so keep your receipts, bestie π§Ύ
the special argument, "--", is ignored, but the following argument in the command line is treated as a literal filename argument. this way, filenames beginning with '-', '+', or containing '=' can be passed to the routine. literally the escape hatch for chaotic filenames, and we're obsessed πΈ
π BUGS π
none currently known. flawless behavior, we stan π
mail bugs and suggestions to schilytools@mlists.in-berlin.de or open a ticket at https://codeberg.org/schilytools/schilytools/issues. they genuinely want to hear from you, fr fr π
the mailing list archive may be found at:
https://mlists.in-berlin.de/mailman/listinfo/schilytools-mlists-in-berlin.de
π AUTHOR π
Joerg Schilling and the schilytools project authors. legends, honestly π
and that's the whole page, bestie!! this little masterpiece was written by Joerg Schilling, dated 2022/09/09, and it lives at GETALLARGS(3) β go forth and parse those flags, you gorgeous main character πβ¨ππ¦π
π¦ where this page comes from
- opensuse-leap 16.0: libschily-devel-doc 2022.10.16-160000.2.2 Β· CDDL-1.0
- Copyright 1985-2020 J. Schilling
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms