GETFILES(3)
π GETFILES(3) β getfiles() gets the next non flag-type argument
okay so this is from SchilyΒ΄s LIBRARY FUNCTIONS and it's genuinely one of those little functions that makes life so much easier, bestie. let's get into it π
β¨ NAME β¨
getfiles() β gets next non flag-type argument. that's it, that's the whole vibe π
πΈ SYNOPSIS πΈ
#include <schily/getargs.h>
int getfiles(pac, pav, fmt)
int *pac; /* pointer to arg count */
char *(*pav)[]; /* pointer to address of arg vector */
char *fmt; /* format string */
int getlfiles(pac, pav, props, fmt)
int *pac; /* pointer to arg count */
char *(*pav)[]; /* pointer to address of arg vector */
struct ga_props *props; /* control properties */
char *fmt; /* format string */
int getvfiles(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 π¦
okay so getfiles() is part of the advanced option parsing interface, and it's literally in the same friend group as the getargs() and getallrgs() family. what it does is lowkey iconic: getfiles() skips options until a file type argument is encountered β like it's scrolling past all the flags in the group chat until it finds the actual message π
getfiles() returns, with a value of +1 (NOTAFLAG) or +2 (FLAGDELIM), whenever a non-flag type argument is encountered. and the flag-type (option) arguments? along with their values? completely ignored, not even a read receipt. the filename is at *pav[0]. π«Ά
β οΈ heads up bestie: the caller must increment*pavand decrement*pacbefore callinggetfiles()again. do not skip this step, i'm begging π
getlfiles() is similar to getfiles() but it implements an additional ga_props parameter that must be initialized with getarginit() before it is passed. no cap, initialize it first β¨
getvfiles() is similar to getlfiles() 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:
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 (&/~) */
};
it 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. mmmhmm, that's the whole structure, she's giving minimal and efficient π
π₯ RETURNS π₯
FLAGDELIM2β the command line argument"--"stopped flag processing. the flag era is over, periodt.NOTAFLAG1β the argument*pavdoes not appear to be a flag. not a flag, not the vibe, moving on β¨NOARGS0β all arguments have been successfully examined. you ate that πBADFLAG-1β a bad flag (option) argument was supplied to the program. the argument*pavcontains the offending command line argument. π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β¦ not the user's fault, it's yours, sorry 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, stop, the party's over, go home π
π SEE ALSO π
getallargs(3), getargerror(3), getargs(3) β go read those too, they're the rest of the friend group π«Ά
π NOTES π
initially, *pav must point to the first argument (not the program name) and *pac must not count the program name. before calling getfiles() again, decrement *pac and increment *pav, or the same name will be pointed to by *pav. and we do NOT want that, it's giving dΓ©jΓ vu π
π§ BUGS π§
None currently known. π flawless, honestly.
mail bugs and suggestions to schilytools@mlists.in-berlin.de or open a ticket at https://codeberg.org/schilytools/schilytools/issues.
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. absolute main character energy β
and that's a wrap, bestie π this page was written by Joerg Schilling on 2022/09/09 and it's page GETFILES(3) of the manual β go forth and parse those args, you've got this πβ¨
π¦ 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