GETALLARGS(3)
π GETALLARGS(3) π
okay bestie, so this is a page from SchilyΒ΄s LIBRARY FUNCTIONS, section 3 of the manual. Yes we're in the library functions section, and yes this one is about options β get comfy π
β¨ NAME β¨
getallargs() β it parses, like, all the flag-type arguments. every single one. no cap π₯
π¦ 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 */
π DESCRIPTION π
so getallargs() is part of the advanced option parsing interface, and it runs with its besties β the getargs() and getfiles() family. the whole squad π«Ά
getallargs() parses all the flag (option) arguments, and it does them anywhere on the command line β not just at the front, iykyk. it literally does not return until all the arguments have been parsed correctly (which returns 0), or an error has occurred (which returns something < 0). it's committed. main character energy π
getlallargs() is similar to getallargs() but it implements an additional ga_props parameter that must be initialized with getarginit() before it is passed. don't skip that step bestie, it's giving undefined behaviour otherwise π
getvallargs() is similar to getlallargs() but uses a structure ga_flags instead of a format string and a variable arg list with pointers. and here's the array of structures ga_flags:
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 (&/~) */
};
and how do you know you've hit the end? 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.
if you want a more detailed description of the parameter matching, go see getargs() β she explains it all π
πΈ RETURNS πΈ
NOARGSβ0β all arguments have been successfully examined. slay β¨BADFLAGβ-1β a bad flag (option) argument was supplied to the program. and*pavcontains the offending command line argument, so you can point right at the culprit πBADFMTβ-2β a bad format descriptor string has been detected. and ngl this one means an error in the calling program, not a user input data error. so that's on you, not them π«£
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.
π¨ important: flag and file arg processing should be terminated after getting a return code <= 0. like, stop there. periodt.
π§ SEE ALSO π§
getargs(3), getargerror(3), getfiles(3).
π NOTES π
okay this bit matters, so listen up bestie π§
getallargs() must be called with the address of a count of items in the vector and the address of a pointer to the vector. and both addresses must already have been properly treated in order to skip over the first parameter, which is the name of the program β like --ac; ++av, for example π
since getallargs() will destroy these values, copies should be made for later use in the program π (yes, really, make the copies). and if an error occurs, av[0] points to the unmatched argument.
the special argument -- is ignored, but the following argument in the command line is treated as a literal filename argument. that's the whole trick that lets filenames beginning with -, +, or containing = be passed to the routine. iconic β¨
π BUGS π
none currently known. we love a clean record π
mail bugs and suggestions to schilytools@mlists.in-berlin.de or open a ticket at https://codeberg.org/schilytools/schilytools/issues β the devs are lovely, 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.
okay that's the whole page babes π quick sign-off so you have the deets: this gem is by Joerg Schilling, dated 2022/09/09, and it comes from that GETALLARGS(3) source β go parse some args, you're gonna eat π
π¦ 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