aboutsummaryrefslogtreecommitdiff
path: root/include/wordsplit.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/wordsplit.h')
-rw-r--r--include/wordsplit.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/include/wordsplit.h b/include/wordsplit.h
index d7eb26f..d4975b3 100644
--- a/include/wordsplit.h
+++ b/include/wordsplit.h
@@ -27,22 +27,22 @@ typedef struct wordsplit wordsplit_t;
27 used, the member is internal and must not be used by the caller. 27 used, the member is internal and must not be used by the caller.
28 28
29 In the comments below, the identifiers in parentheses indicate bits that 29 In the comments below, the identifiers in parentheses indicate bits that
30 must be set (or unset, if starting with !) in ws_flags (if starting with 30 must be set (or unset, if starting with !) in ws_flags (if starting with
31 WRDSF_) or ws_options (if starting with WRDSO_) to initialize or use the 31 WRDSF_) or ws_options (if starting with WRDSO_) to initialize or use the
32 given member. 32 given member.
33 33
34 If not redefined explicitly, most of them are set to some reasonable 34 If not redefined explicitly, most of them are set to some reasonable
35 default value upon entry to wordsplit(). */ 35 default value upon entry to wordsplit(). */
36struct wordsplit 36struct wordsplit
37{ 37{
38 size_t ws_wordc; /* [Output] Number of words in ws_wordv. */ 38 size_t ws_wordc; /* [Output] Number of words in ws_wordv. */
39 char **ws_wordv; /* [Output] Array of parsed out words. */ 39 char **ws_wordv; /* [Output] Array of parsed out words. */
40 size_t ws_offs; /* [Input] (WRDSF_DOOFFS) Number of initial 40 size_t ws_offs; /* [Input] (WRDSF_DOOFFS) Number of initial
41 elements in ws_wordv to fill with NULLs. */ 41 elements in ws_wordv to fill with NULLs. */
42 size_t ws_wordn; /* Number of elements ws_wordv can accomodate. */ 42 size_t ws_wordn; /* Number of elements ws_wordv can accomodate. */
43 int ws_flags; /* [Input] Flags passed to wordsplit. */ 43 int ws_flags; /* [Input] Flags passed to wordsplit. */
44 int ws_options; /* [Input] (WRDSF_OPTIONS) 44 int ws_options; /* [Input] (WRDSF_OPTIONS)
45 Additional options. */ 45 Additional options. */
46 size_t ws_maxwords; /* [Input] (WRDSO_MAXWORDS) Return at most that 46 size_t ws_maxwords; /* [Input] (WRDSO_MAXWORDS) Return at most that
47 many words */ 47 many words */
48 size_t ws_wordi; /* [Output] (WRDSF_INCREMENTAL) Total number of 48 size_t ws_wordi; /* [Output] (WRDSF_INCREMENTAL) Total number of
@@ -50,21 +50,21 @@ struct wordsplit
50 50
51 const char *ws_delim; /* [Input] (WRDSF_DELIM) Word delimiters. */ 51 const char *ws_delim; /* [Input] (WRDSF_DELIM) Word delimiters. */
52 const char *ws_comment; /* [Input] (WRDSF_COMMENT) Comment characters. */ 52 const char *ws_comment; /* [Input] (WRDSF_COMMENT) Comment characters. */
53 const char *ws_escape[2]; /* [Input] (WRDSF_ESCAPE) Characters to be escaped 53 const char *ws_escape[2]; /* [Input] (WRDSF_ESCAPE) Characters to be escaped
54 with backslash. */ 54 with backslash. */
55 void (*ws_alloc_die) (wordsplit_t *wsp); 55 void (*ws_alloc_die) (wordsplit_t *wsp);
56 /* [Input] (WRDSF_ALLOC_DIE) Function called when 56 /* [Input] (WRDSF_ALLOC_DIE) Function called when
57 out of memory. Must not return. */ 57 out of memory. Must not return. */
58 void (*ws_error) (const char *, ...) 58 void (*ws_error) (const char *, ...)
59 __attribute__ ((__format__ (__printf__, 1, 2))); 59 __attribute__ ((__format__ (__printf__, 1, 2)));
60 /* [Input] (WRDSF_ERROR) Function used for error 60 /* [Input] (WRDSF_ERROR) Function used for error
61 reporting */ 61 reporting */
62 void (*ws_debug) (const char *, ...) 62 void (*ws_debug) (const char *, ...)
63 __attribute__ ((__format__ (__printf__, 1, 2))); 63 __attribute__ ((__format__ (__printf__, 1, 2)));
64 /* [Input] (WRDSF_DEBUG) Function used for debug 64 /* [Input] (WRDSF_DEBUG) Function used for debug
65 output. */ 65 output. */
66 const char **ws_env; /* [Input] (WRDSF_ENV, !WRDSF_NOVAR) Array of 66 const char **ws_env; /* [Input] (WRDSF_ENV, !WRDSF_NOVAR) Array of
67 environment variables. */ 67 environment variables. */
68 68
69 /* Temporary storage for environment variables. It is initialized 69 /* Temporary storage for environment variables. It is initialized
70 upon first assignment which occurs during the parsing process 70 upon first assignment which occurs during the parsing process
@@ -77,52 +77,52 @@ struct wordsplit
77 size_t ws_envsiz; /* Size of the ws_envbuf array */ 77 size_t ws_envsiz; /* Size of the ws_envbuf array */
78 78
79 char const **ws_paramv; /* [WRDSO_PARAMV] User-supplied positional 79 char const **ws_paramv; /* [WRDSO_PARAMV] User-supplied positional
80 parameters */ 80 parameters */
81 size_t ws_paramc; /* Number of positional parameters */ 81 size_t ws_paramc; /* Number of positional parameters */
82 82
83 /* Temporary storage for parameters. Works similarly to ws_enbuf. 83 /* Temporary storage for parameters. Works similarly to ws_enbuf.
84 */ 84 */
85 char **ws_parambuf; 85 char **ws_parambuf;
86 size_t ws_paramidx; 86 size_t ws_paramidx;
87 size_t ws_paramsiz; 87 size_t ws_paramsiz;
88 88
89 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);
90 /* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up 90 /* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up
91 the name VAR (LEN bytes long) in the table of 91 the name VAR (LEN bytes long) in the table of
92 variables and if found returns in memory 92 variables and if found returns in memory
93 location pointed to by RET the value of that 93 location pointed to by RET the value of that
94 variable. Returns WRDSE_OK (0) on success, 94 variable. Returns WRDSE_OK (0) on success,
95 and an error code (see WRDSE_* defines below) 95 and an error code (see WRDSE_* defines below)
96 on error. User-specific errors can be returned 96 on error. User-specific errors can be returned
97 by storing the error diagnostic string in RET 97 by storing the error diagnostic string in RET
98 and returning WRDSE_USERERR. 98 and returning WRDSE_USERERR.
99 Whatever is stored in RET, it must be allocated 99 Whatever is stored in RET, it must be allocated
100 using malloc(3). */ 100 using malloc(3). */
101 void *ws_closure; /* [Input] (WRDSF_CLOSURE) Passed as the CLOS 101 void *ws_closure; /* [Input] (WRDSF_CLOSURE) Passed as the CLOS
102 argument to ws_getvar and ws_command. */ 102 argument to ws_getvar and ws_command. */
103 int (*ws_command) (char **ret, const char *cmd, size_t len, char **argv, 103 int (*ws_command) (char **ret, const char *cmd, size_t len, char **argv,
104 void *clos); 104 void *clos);
105 /* [Input] (!WRDSF_NOCMD) Returns in the memory 105 /* [Input] (!WRDSF_NOCMD) Returns in the memory
106 location pointed to by RET the expansion of 106 location pointed to by RET the expansion of
107 the command CMD (LEN bytes long). On input, 107 the command CMD (LEN bytes long). On input,
108 ARGV contains CMD split out to words. 108 ARGV contains CMD split out to words.
109 109
110 See ws_getvar for a discussion of possible 110 See ws_getvar for a discussion of possible
111 return values. */ 111 return values. */
112 112
113 const char *ws_input; /* Input string (the S argument to wordsplit. */ 113 const char *ws_input; /* Input string (the S argument to wordsplit. */
114 size_t ws_len; /* Length of ws_input. */ 114 size_t ws_len; /* Length of ws_input. */
115 size_t ws_endp; /* Points past the last processed byte in 115 size_t ws_endp; /* Points past the last processed byte in
116 ws_input. */ 116 ws_input. */
117 int ws_errno; /* [Output] Error code, if an error occurred. */ 117 int ws_errno; /* [Output] Error code, if an error occurred. */
118 char *ws_usererr; /* Points to textual description of 118 char *ws_usererr; /* Points to textual description of
119 the error, if ws_errno is WRDSE_USERERR. Must 119 the error, if ws_errno is WRDSE_USERERR. Must
120 be allocated with malloc(3). */ 120 be allocated with malloc(3). */
121 struct wordsplit_node *ws_head, *ws_tail; 121 struct wordsplit_node *ws_head, *ws_tail;
122 /* Doubly-linked list of parsed out nodes. */ 122 /* Doubly-linked list of parsed out nodes. */
123 int ws_lvl; /* Invocation nesting level. */ 123 int ws_lvl; /* Invocation nesting level. */
124}; 124};
125 125
126/* Initial size for ws_env, if allocated automatically */ 126/* Initial size for ws_env, if allocated automatically */
127#define WORDSPLIT_ENV_INIT 16 127#define WORDSPLIT_ENV_INIT 16
128 128
@@ -239,15 +239,15 @@ struct wordsplit
239/* Enable positional parameters */ 239/* Enable positional parameters */
240#define WRDSO_PARAMV 0x00004000 240#define WRDSO_PARAMV 0x00004000
241/* Enable negative positional indices (${-1} is the last positional 241/* Enable negative positional indices (${-1} is the last positional
242 parameter) */ 242 parameter) */
243#define WRDSO_PARAM_NEGIDX 0x00008000 243#define WRDSO_PARAM_NEGIDX 0x00008000
244 244
245#define WRDSO_BSKEEP WRDSO_BSKEEP_WORD 245#define WRDSO_BSKEEP WRDSO_BSKEEP_WORD
246#define WRDSO_OESC WRDSO_OESC_WORD 246#define WRDSO_OESC WRDSO_OESC_WORD
247#define WRDSO_XESC WRDSO_XESC_WORD 247#define WRDSO_XESC WRDSO_XESC_WORD
248 248
249/* Indices into ws_escape */ 249/* Indices into ws_escape */
250#define WRDSX_WORD 0 250#define WRDSX_WORD 0
251#define WRDSX_QUOTE 1 251#define WRDSX_QUOTE 1
252 252
253/* Set escape option F in WS for words (Q==0) or quoted strings (Q==1) */ 253/* Set escape option F in WS for words (Q==0) or quoted strings (Q==1) */

Return to:

Send suggestions and report system problems to the System administrator.