1
0

separate out libpsargs

This commit is contained in:
dtb
2023-09-12 22:05:20 -04:00
parent 51fec46387
commit c39523fff4
5 changed files with 11 additions and 13 deletions

17
libpsargs/libpsargs.h Normal file
View File

@@ -0,0 +1,17 @@
/* pscat(1) and pspipe(1) arguments are flanked by { '[', '\0' } and
* { ']', '\0' }. Nesting is allowed to facilitate nesting of pscat(1) and
* pspipe(1). This checks to make sure grouping symbols in args are balanced.
* args is the argv that was passed to main, incremented. l is the left
* grouping character (usually '[') and r is the right grouping character
* (usually ']').
* Returns 0 in the events of a syntax error or there being no arguments.
* Otherwise, returns the number of top-level right grouping arguments
* (i.e. the number of terms). */
int check_arg(char **args, char l, char r);
/* arg is the location of the argument with the left grouping symbol within
* argv, l is the left grouping character itself, r is the right grouping
* character itself.
* Returns the location of the argument with the corresponding left grouping
* symbol within argv. */
char **corresponding_arg(char **arg, char l, char r);