1 //--------------------------------------------------------------------------
2 // Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved.
3 // Copyright (C) 2005-2013 Sourcefire, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License Version 2 as published
7 // by the Free Software Foundation.  You may not use, modify or distribute
8 // this program under any other version of the GNU General Public License.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 //--------------------------------------------------------------------------
19 
20 // parse_ports.h derived from sfportobject.h by Marc Noron
21 
22 #ifndef PARSE_PORTS_H
23 #define PARSE_PORTS_H
24 
25 #include "ports/port_var_table.h"
26 
27 //-------------------------------------------------------------------------
28 // parser
29 //-------------------------------------------------------------------------
30 
31 #define POPERR_NO_NAME            1
32 #define POPERR_NO_ENDLIST_BRACKET 2
33 #define POPERR_NOT_A_NUMBER       3
34 #define POPERR_EXTRA_BRACKET      4
35 #define POPERR_NO_DATA            5
36 #define POPERR_ADDITEM_FAILED     6
37 #define POPERR_MALLOC_FAILED      7
38 #define POPERR_INVALID_RANGE      8
39 #define POPERR_DUPLICATE_ENTRY    9
40 #define POPERR_BOUNDS             10
41 #define POPERR_BAD_VARIABLE       11
42 
43 #define POP_MAX_BUFFER_SIZE 256
44 
45 struct PortObject;
46 
47 struct POParser
48 {
49     const char* s;          /* current string pointer */
50     int slen;         /* bytes left in string */
51     int pos;          /* position in string of last GetChar() */
52     char token[POP_MAX_BUFFER_SIZE+4];   /* single number, or range, or not flag */
53     int errflag;
54     /* for handling PortObject references when parsing */
55     PortObject* po_ref;
56     SF_LNODE* poi_pos;
57     PortVarTable* pvTable;
58 };
59 
60 PortObject* PortObjectParseString(
61     PortVarTable* pvTable, POParser* pop, const char* name,  const
62     char* s,int nameflag);
63 
64 const char* PortObjectParseError(POParser* p);
65 
66 #endif
67 
68