Revision 37cf7d8f9e336376dc0ecdb1b80e4776721a950b, 0.9 kB
(checked in by Theo Schlossnagle <jesus@omniti.com>, 10 years ago)
|
A 'simple' tokenizer to help us with the console
|
- Property mode set to
100644
|
Line | |
---|
1 |
/* |
---|
2 |
* Copyright (c) 2007, OmniTI Computer Consulting, Inc. |
---|
3 |
* All rights reserved. |
---|
4 |
*/ |
---|
5 |
|
---|
6 |
#ifndef _NOIT_TOKENIZER_H |
---|
7 |
#define _NOIT_TOKENIZER_H |
---|
8 |
|
---|
9 |
/* Pass a string as input and an allocation array of char * place holders. |
---|
10 |
The function will white-space slit them and return each token (malloc'd) |
---|
11 |
in vector[ 0 .. *cnt-1 ]. |
---|
12 |
|
---|
13 |
This function is smart, handling quoted strings and escape sequences. |
---|
14 |
'enclosed strings' may contain any character except ' |
---|
15 |
"enclosed strings" are interpretted with all C escape sequences. |
---|
16 |
unenclosed\ strings are may not start wth ' or ", |
---|
17 |
but may contain escaped spaces (not tabs). |
---|
18 |
|
---|
19 |
*cnt will be set to the number of tokens placed in vector. |
---|
20 |
|
---|
21 |
RETURNS: |
---|
22 |
the number of tokens found (may be larger than *cnt), |
---|
23 |
or |
---|
24 |
-X where X is the character offset of the parser error. |
---|
25 |
*/ |
---|
26 |
|
---|
27 |
int noit_tokenize(const char *input, char **vector, int *cnt); |
---|
28 |
|
---|
29 |
#endif |
---|