sipxportlib  Version 3.3
OsTokenizer.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 /* This code was taken from a program I wrote some time ago. It parses a string
13  * for whitespace and quotes much like a shell would. Characters enclosed in
14  * quotes are counted as a single token. Extra whitespace at the beginning and
15  * end of the string is removed. The tokenizing function returns a token
16  * structure, which can be used to access the tokens in the original string
17  * (which will have been modified). Once the tokens have been used by the
18  * caller, the token structure must be destroyed to free the token pointers. */
19 
20 #ifndef __OsTokenizer_h
21 #define __OsTokenizer_h
22 
23 typedef struct PT_TOKEN {
24  char * string;
25  int offset[8];
26  int offsets;
27  struct PT_TOKEN * next;
28 } pt_token_t;
29 
30 /* parse a string and return a (pointer to a) token structure */
31 /* sets the token count in *args */
32 pt_token_t * parse_tokenize(char * string, int * args);
33 
34 /* return a pointer to the given token */
35 const char * parse_token(pt_token_t * t, int which);
36 
37 /* destroy the token structure */
38 void parse_kill(pt_token_t * t);
39 
40 #endif /* __OsTokenizer_h */
struct PT_TOKEN * next
Definition: OsTokenizer.h:27
Definition: OsTokenizer.h:23
int offset[8]
Definition: OsTokenizer.h:25
pt_token_t * parse_tokenize(char *string, int *args)
Definition: OsTokenizer.cpp:25
void parse_kill(pt_token_t *t)
Definition: OsTokenizer.cpp:114
struct PT_TOKEN pt_token_t
char * string
Definition: OsTokenizer.h:24
const char * parse_token(pt_token_t *t, int which)
Definition: OsTokenizer.cpp:91
int offsets
Definition: OsTokenizer.h:26