refactor code

This commit is contained in:
2022-11-20 20:23:39 -05:00
parent a2ae9d1ae8
commit 19f091eead
4 changed files with 103 additions and 74 deletions
+22
View File
@@ -0,0 +1,22 @@
#if !defined _PSARGS_H
# define _PSARGS_H
/* 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);
#endif