Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
rw_braceexp.h
Go to the documentation of this file.
1
27#ifndef RW_BRACEEXP_H_INCLUDED
28#define RW_BRACEEXP_H_INCLUDED
29
30
31#include <rw_testdefs.h>
32
33// rw_brace_expand() performs brace expansion similar to the csh shell.
34// the base grammar for the brace expansion is supposed to be..
35//
36// string ::= <brace-expr> | [ <chars> ]
37// brace-expr ::= <string> '{' <brace-list> | <brace-sequ> '}' <string> |
38// <string>
39// brace-list ::= <string> ',' <brace-list> | <string>
40// brace-sequ ::= <upper> '.' '.' <upper> |
41// <lower> '.' '.' <lower> |
42// <integer> '.' '.' <integer>
43// chars ::= <pcs-char> <string> | <pcs-char>
44// integer ::= ['+' | '-'] <digits>
45// upper ::= pcs-char 'a-z'
46// lower ::= pcs-char 'A-Z'
47// digit ::= pcs-char '0-9'
48// digits ::= <digit> <digits> | <digit>
49// pcs-char ::= character in the Portable Character Set
50//
51// many examples can be found in the test 0.braceexp.cpp.
52//
53
54//
55// this function will attempt to expand `sz' bytes of the brace expression
56// `brace_expr' into `n' bytes of the output buffer `s', seperating each
57// expansion with a single seperator character `sep'. if the output buffer
58// `s' is is null, or the number of bytes `n' is insufficient to contain
59// all expansions of `brace_expr', an appropriately sized buffer will be
60// allocated with malloc(). a pointer to the output buffer that is used
61// will be returned. if the pointer returned is not equal to the user
62// supplied input buffer `s', then the caller is expected to free() the
63// returned pointer.
64//
65// this function can return null if the brace expansion could not be
66// processed. this can happen if, for example, the brace expression string
67// contains an unmatched unescaped open brace. the function can also fail
68// and return null if a memory allocation request fails.
69//
70_TEST_EXPORT char*
71rw_brace_expand (const char* brace_expr, _RWSTD_SIZE_T sz,
72 char* s, _RWSTD_SIZE_T n, char sep);
73
74
75//
76// this function is similar to rw_brace_expand, except that the input
77// string `shell_expr' is tokenized on whitespace, and each non-whitespace
78// token is expanded seperately. this function will fail if an attempt to
79// brace expand one of the tokens fails, regardless of the reason for that
80// failure.
81//
82// the caller may need to free() the returned pointer. please see comments
83// above for details.
84//
85// this function only does tokenization and brace expansion at this time.
86// at some point it may make sense to add environment variable expansion.
87//
88_TEST_EXPORT char*
89rw_shell_expand (const char* shell_expr, _RWSTD_SIZE_T sz,
90 char* s, _RWSTD_SIZE_T n, char sep);
91
92
93#endif // RW_BRACEEXP_H_INCLUDED
94
#define sz
Definition 17.names.cpp:550
#define s
#define n
Definition 17.names.cpp:130
_TEST_EXPORT char * rw_shell_expand(const char *shell_expr, _RWSTD_SIZE_T sz, char *s, _RWSTD_SIZE_T n, char sep)
_TEST_EXPORT char * rw_brace_expand(const char *brace_expr, _RWSTD_SIZE_T sz, char *s, _RWSTD_SIZE_T n, char sep)
#define _TEST_EXPORT
Definition rw_testdefs.h:55