liblscp  0.5.7
parser.h
Go to the documentation of this file.
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 
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
const char * lscp_parser_strtok(char *pchBuffer, const char *pszDelim, char **ppch)
Definition: parser.c:34
int cchBuffer
Definition: parser.h:46
struct _lscp_parser_t lscp_parser_t
void lscp_parser_free(lscp_parser_t *pParser)
Definition: parser.c:128
int lscp_parser_nextint(lscp_parser_t *pParser)
Definition: parser.c:84
int lscp_parser_test(lscp_parser_t *pParser, const char *pszToken)
Definition: parser.c:108
Definition: parser.h:43
int lscp_parser_test2(lscp_parser_t *pParser, const char *pszToken, const char *pszToken2)
Definition: parser.c:119
const char * lscp_parser_next(lscp_parser_t *pParser)
Definition: parser.c:74
const char * pszToken
Definition: parser.h:47
char * pchBuffer
Definition: parser.h:45
char * pch
Definition: parser.h:48
void lscp_parser_init(lscp_parser_t *pParser, const char *pchBuffer, int cchBuffer)
Definition: parser.c:60
float lscp_parser_nextnum(lscp_parser_t *pParser)
Definition: parser.c:96