aboutsummaryrefslogtreecommitdiff
path: root/include/wordsplit.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/wordsplit.h')
-rw-r--r--include/wordsplit.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/include/wordsplit.h b/include/wordsplit.h
index a175275..d7eb26f 100644
--- a/include/wordsplit.h
+++ b/include/wordsplit.h
@@ -75,6 +75,16 @@ struct wordsplit
75 char **ws_envbuf; /* Storage for variables */ 75 char **ws_envbuf; /* Storage for variables */
76 size_t ws_envidx; /* Index of first free slot */ 76 size_t ws_envidx; /* Index of first free slot */
77 size_t ws_envsiz; /* Size of the ws_envbuf array */ 77 size_t ws_envsiz; /* Size of the ws_envbuf array */
78
79 char const **ws_paramv; /* [WRDSO_PARAMV] User-supplied positional
80 parameters */
81 size_t ws_paramc; /* Number of positional parameters */
82
83 /* Temporary storage for parameters. Works similarly to ws_enbuf.
84 */
85 char **ws_parambuf;
86 size_t ws_paramidx;
87 size_t ws_paramsiz;
78 88
79 int (*ws_getvar) (char **ret, const char *var, size_t len, void *clos); 89 int (*ws_getvar) (char **ret, const char *var, size_t len, void *clos);
80 /* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up 90 /* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up
@@ -99,7 +109,7 @@ struct wordsplit
99 109
100 See ws_getvar for a discussion of possible 110 See ws_getvar for a discussion of possible
101 return values. */ 111 return values. */
102 112
103 const char *ws_input; /* Input string (the S argument to wordsplit. */ 113 const char *ws_input; /* Input string (the S argument to wordsplit. */
104 size_t ws_len; /* Length of ws_input. */ 114 size_t ws_len; /* Length of ws_input. */
105 size_t ws_endp; /* Points past the last processed byte in 115 size_t ws_endp; /* Points past the last processed byte in
@@ -226,6 +236,12 @@ struct wordsplit
226 $(echo foo bar) */ 236 $(echo foo bar) */
227#define WRDSO_NOCMDSPLIT 0x00002000 237#define WRDSO_NOCMDSPLIT 0x00002000
228 238
239/* Enable positional parameters */
240#define WRDSO_PARAMV 0x00004000
241/* Enable negative positional indices (${-1} is the last positional
242 parameter) */
243#define WRDSO_PARAM_NEGIDX 0x00008000
244
229#define WRDSO_BSKEEP WRDSO_BSKEEP_WORD 245#define WRDSO_BSKEEP WRDSO_BSKEEP_WORD
230#define WRDSO_OESC WRDSO_OESC_WORD 246#define WRDSO_OESC WRDSO_OESC_WORD
231#define WRDSO_XESC WRDSO_XESC_WORD 247#define WRDSO_XESC WRDSO_XESC_WORD
@@ -250,12 +266,14 @@ struct wordsplit
250#define WRDSE_PAREN 7 266#define WRDSE_PAREN 7
251#define WRDSE_GLOBERR 8 267#define WRDSE_GLOBERR 8
252#define WRDSE_USERERR 9 268#define WRDSE_USERERR 9
269#define WRDSE_BADPARAM 10
253 270
254int wordsplit (const char *s, wordsplit_t *ws, int flags); 271int wordsplit (const char *s, wordsplit_t *ws, int flags);
255int wordsplit_len (const char *s, size_t len, wordsplit_t *ws, int flags); 272int wordsplit_len (const char *s, size_t len, wordsplit_t *ws, int flags);
256void wordsplit_free (wordsplit_t *ws); 273void wordsplit_free (wordsplit_t *ws);
257void wordsplit_free_words (wordsplit_t *ws); 274void wordsplit_free_words (wordsplit_t *ws);
258void wordsplit_free_envbuf (wordsplit_t *ws); 275void wordsplit_free_envbuf (wordsplit_t *ws);
276void wordsplit_free_parambuf (struct wordsplit *ws);
259int wordsplit_get_words (wordsplit_t *ws, size_t *wordc, char ***wordv); 277int wordsplit_get_words (wordsplit_t *ws, size_t *wordc, char ***wordv);
260 278
261static inline void wordsplit_getwords (wordsplit_t *ws, size_t *wordc, char ***wordv) 279static inline void wordsplit_getwords (wordsplit_t *ws, size_t *wordc, char ***wordv)

Return to:

Send suggestions and report system problems to the System administrator.