diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-12-29 09:44:39 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-12-29 09:44:39 +0200 |
commit | a66d9bb29b7a8bb357f7a085e152e10ed7a1d2ad (patch) | |
tree | 53d2950acd081c73f376941d3de96045f8d9235d /include | |
parent | 6b6a4fba1a69ccf0d2d22a238d7f8373c84526a3 (diff) | |
download | smap-a66d9bb29b7a8bb357f7a085e152e10ed7a1d2ad.tar.gz smap-a66d9bb29b7a8bb357f7a085e152e10ed7a1d2ad.tar.bz2 |
wordsplit: sync with mailutils
Diffstat (limited to 'include')
-rw-r--r-- | include/smap/wordsplit.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/include/smap/wordsplit.h b/include/smap/wordsplit.h index 204a9e0..3c4d8b1 100644 --- a/include/smap/wordsplit.h +++ b/include/smap/wordsplit.h @@ -19,8 +19,7 @@ #include <stddef.h> -struct wordsplit -{ +struct wordsplit { size_t ws_wordc; char **ws_wordv; size_t ws_offs; @@ -35,7 +34,8 @@ struct wordsplit __attribute__ ((__format__ (__printf__, 1, 2))); const char **ws_env; - char *(*ws_getvar)(const char *, size_t); + const char *(*ws_getvar) (const char *, size_t, void *); + void *ws_closure; const char *ws_input; size_t ws_len; @@ -62,11 +62,11 @@ struct wordsplit is expanded. */ #define WRDSF_UNDEF 0x0000020 -/* Don't do variable expansion. Reserved for future use. */ +/* Don't do variable expansion. */ #define WRDSF_NOVAR 0x0000040 /* Abort on ENOMEM error */ #define WRDSF_ENOMEMABRT 0x0000080 -/* Treat whitespace as delimiters */ +/* Trim off any leading and trailind whitespace */ #define WRDSF_WS 0x0000100 /* Handle quotes and escape directives */ #define WRDSF_QUOTE 0x0000200 @@ -103,9 +103,15 @@ struct wordsplit /* Handle C escapes */ #define WRDSF_CESCAPES 0x1000000 +/* ws_closure is set */ +#define WRDSF_CLOSURE 0x2000000 +/* ws_env is a Key/Value environment, i.e. the value of a variable is + stored in the element that follows its name. */ +#define WRDSF_ENV_KV 0x4000000 + #define WRDSF_DEFFLAGS \ (WRDSF_NOVAR | WRDSF_NOCMD | \ - WRDSF_WS | WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS | WRDSF_CESCAPES) + WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS | WRDSF_CESCAPES) #define WRDSE_EOF 0 #define WRDSE_QUOTE 1 @@ -116,11 +122,15 @@ struct wordsplit #define WRDSE_UNDEF 6 int wordsplit(const char *s, struct wordsplit *p, int flags); +int wordsplit_len(const char *s, size_t len, + struct wordsplit *p, int flags); void wordsplit_free(struct wordsplit *p); +void wordsplit_free_words(struct wordsplit *ws); int wordsplit_c_unquote_char(int c); int wordsplit_c_quote_char(int c); -size_t wordsplit_c_quoted_length(const char *str, int quote_hex, int *quote); +size_t wordsplit_c_quoted_length(const char *str, int quote_hex, + int *quote); void wordsplit_sh_unquote_copy(char *dst, const char *src, size_t n); void wordsplit_c_unquote_copy(char *dst, const char *src, size_t n); void wordsplit_c_quote_copy(char *dst, const char *src, int quote_hex); |