1 |
// parser.h |
2 |
// |
3 |
/**************************************************************************** |
4 |
liblscp - LinuxSampler Control Protocol API |
5 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
7 |
This library is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU Lesser General Public |
9 |
License as published by the Free Software Foundation; either |
10 |
version 2.1 of the License, or (at your option) any later version. |
11 |
|
12 |
This library is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
Lesser General Public License for more details. |
16 |
|
17 |
You should have received a copy of the GNU General Public License along |
18 |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
21 |
*****************************************************************************/ |
22 |
|
23 |
#ifndef __LSCP_PARSER_H |
24 |
#define __LSCP_PARSER_H |
25 |
|
26 |
#include <stdio.h> |
27 |
#include <stdlib.h> |
28 |
#include <string.h> |
29 |
|
30 |
#if (defined(_WIN32) || defined(__WIN32__)) |
31 |
#if (!defined(WIN32)) |
32 |
#define WIN32 |
33 |
#endif |
34 |
#endif |
35 |
|
36 |
#if defined(__cplusplus) |
37 |
extern "C" { |
38 |
#endif |
39 |
|
40 |
//------------------------------------------------------------------------- |
41 |
// Simple token parser. |
42 |
|
43 |
typedef struct _lscp_parser_t |
44 |
{ |
45 |
char *pchBuffer; |
46 |
int cchBuffer; |
47 |
const char *pszToken; |
48 |
char *pch; |
49 |
|
50 |
} lscp_parser_t; |
51 |
|
52 |
const char *lscp_parser_strtok (char *pchBuffer, const char *pszDelim, char **ppch); |
53 |
|
54 |
void lscp_parser_init (lscp_parser_t *pParser, const char *pchBuffer, int cchBuffer); |
55 |
const char *lscp_parser_next (lscp_parser_t *pParser); |
56 |
int lscp_parser_nextint (lscp_parser_t *pParser); |
57 |
float lscp_parser_nextnum (lscp_parser_t *pParser); |
58 |
int lscp_parser_test (lscp_parser_t *pParser, const char *pszToken); |
59 |
int lscp_parser_test2 (lscp_parser_t *pParser, const char *pszToken, const char *pszToken2); |
60 |
void lscp_parser_free (lscp_parser_t *pParser); |
61 |
|
62 |
#if defined(__cplusplus) |
63 |
} |
64 |
#endif |
65 |
|
66 |
#endif // __LSCP_PARSER_H |
67 |
|
68 |
// end of parser.h |