diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-04-20 14:48:39 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-04-20 14:48:39 +0300 |
commit | 0f081a2643ba0a7f7a5dcfb6a5977d9da1d2b6db (patch) | |
tree | b62e9404cd5dfdfa471ec1202e183f9ca92187e5 /src/wordsplit.h | |
parent | 0983c9ab7a6ea5b3592a297e029a935cc0e4bebc (diff) | |
download | grecs-0f081a2643ba0a7f7a5dcfb6a5977d9da1d2b6db.tar.gz grecs-0f081a2643ba0a7f7a5dcfb6a5977d9da1d2b6db.tar.bz2 |
Diverge from Wydawca gconf/ subdirectory into a separate project
Diffstat (limited to 'src/wordsplit.h')
-rw-r--r-- | src/wordsplit.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/wordsplit.h b/src/wordsplit.h new file mode 100644 index 0000000..d4d1f0c --- /dev/null +++ b/src/wordsplit.h @@ -0,0 +1,88 @@ +/* wordsplit - a word splitter + Copyright (C) 2009 Sergey Poznyakoff + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see <http://www.gnu.org/licenses/>. */ + +struct wordsplit +{ + size_t ws_wordc; + char **ws_wordv; + size_t ws_offs; + size_t ws_wordn; + int ws_flags; + const char *ws_delim; + const char *ws_comment; + + const char *ws_input; + size_t ws_len; + size_t ws_endp; +}; + +/* Append the words found to the array resulting from a previous + call. */ +#define WRDSF_APPEND 0x0001 +/* Insert we_offs initial NULLs in the array ws_wordv. + (These are not counted in the returned ws_wordc.) */ +#define WRDSF_DOOFFS 0x0002 +/* Don't do command substitution. Reserved for future use. */ +#define WRDSF_NOCMD 0x0004 +/* The parameter p resulted from a previous call to + wordsplit(), and wordsplit_free() was not called. Reuse the + allocated storage. */ +#define WRDSF_REUSE 0x0008 +/* Print errors */ +#define WRDSF_SHOWERR 0x0010 +/* Consider it an error if an undefined shell variable + is expanded. */ +#define WRDSF_UNDEF 0x0020 + +/* Don't do variable expansion. Reserved for future use. */ +#define WRDSF_NOVAR 0x0040 +/* Abort on ENOMEM error */ +#define WRDSF_ENOMEMABRT 0x0080 +/* Treat whitespace as delimiters */ +#define WRDSF_WS 0x0100 +/* Handle quotes and escape directives */ +#define WRDSF_QUOTE 0x0200 +/* Replace each input sequence of repeated delimiters with a single + delimiter */ +#define WRDSF_SQUEEZE_DELIMS 0x0400 +/* Return delimiters */ +#define WRDSF_RETURN_DELIMS 0x0800 +/* Treat sed expressions as words */ +#define WRDSF_SED_EXPR 0x1000 +/* ws_delim field is initialized */ +#define WRDSF_DELIM 0x2000 +/* ws_comment field is initialized */ +#define WRDSF_COMMENT 0x4000 + +#define WRDSF_DEFFLAGS \ + (WRDSF_NOVAR | WRDSF_NOCMD | \ + WRDSF_WS | WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS) + +#define WRDSE_EOF 0 +#define WRDSE_QUOTE 1 +#define WRDSE_NOSPACE 2 + +int wordsplit (const char *s, struct wordsplit *p, int flags); +void wordsplit_free (struct wordsplit *p); + +int wordsplit_unquote_char (int c); +int wordsplit_quote_char (int c); +size_t wordsplit_quoted_length (const char *str, int quote_hex, int *quote); +void wordsplit_unquote_copy (char *dst, const char *src, size_t n); +void wordsplit_quote_copy (char *dst, const char *src, int quote_hex); + + + |