xref: /titanic_50/usr/src/lib/libast/common/man/vecargs.3 (revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0)
.fp 5 CW .. .nr ;G \\n(.f .Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" \\*(;G .. .aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" .. .aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" .. .aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" ..

0

..

..

VECARGS 3
NAME
vecargs - command argument vector insertion routines
SYNOPSIS
.L "#include <vecargs.h>" .L "char** vecload(char* string);" .L "char** vecfile(const char* path);" .L "char** vecstring(const char* string);" .L "void vecfree(char**, int);" .L "int vecargs(char** vec, int* argcp, char*** argvp);"
DESCRIPTION
.L vecload loads a string vector from lines in .LR string . .L string may be modified upon return. Each line in .L string is treated as a new vector element. Lines with .L # as the first character are comments. \enewline joins consecutive lines. A string vector pointer is returned, 0 on error.

.L vecfile constructs a string vector by calling .L vecload on the contents of the file named by .LR path . The string vector pointer is returned, 0 on error.

.L vecstring constructs a string vector by calling .L vecload on a copy of .LR string . The string vector pointer is returned, 0 on error.

.L vecfree frees a string vector allocated by .LR vecfile , .L vecload or .LR vecstring .

.L vecargs inserts the string vector .L vec (as returned by .LR vecfile , .L vecload or .LR vecstring ) between .L "(*argvp)[0]" and .LR "(*argvp)[1]" , sliding .L "(*argvp)[1] ..." over. NULL and empty string args in .L vec are not copied. .L "vecfree(vec)" is called before the return. .L -1 is returned if the insertion failed.

EXAMPLES
.L vecargs is commonly used to modify command .L argv from fixed files. For example, make (1) checks for the files .L ./Makeargs and .L ./makeargs to modify its arguments on startup. Its a handy way to override default options on a directory by directory basis without modify the standard control files (\f5Makefile in this case.)
CAVEATS
This paradigm is not recommended for all commands; only a few exceptions make sense.