-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.h
69 lines (63 loc) · 1.83 KB
/
parse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright (c) 2013 The Board of Trustees of Carnegie Mellon University.
*
* Author: Chris Rapier <[email protected]>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MIT License.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the MIT License for more details.
*
* You should have received a copy of the MIT License along with this library;
* if not, see http://opensource.org/licenses/MIT.
*
*/
#ifndef PARSE_H
#define PARSE_H
#include "config.h"
#ifdef HAVE_LIBJSONC
#include <json-c/json.h>
#else
#include <json/json.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
typedef enum RequestTypes {
list,
exclude,
include,
filterip,
appexclude,
appinclude,
report
} RequestTypes;
typedef struct CommandList {
char *commands[10];
char *options[10];
char *mask;
int maxindex;
} CommandList;
typedef struct FilterList {
char *commands[10]; //the command
char **strings[10]; // either app name or ips
int *ports[10]; // port array
int arrindex[10]; // number of elements in the strings or ports array
int maxindex;
int reportcid;
char *mask;
} FilterList;
int include_port (int, int, int [], int);
int exclude_port (int, int, int [], int);
int exclude_app (char*, char**, int);
int include_app (char*, char**, int);
int filter_ips( char*, char*, char**, int);
int parse_ints(struct FilterList *, char *, int);
int parse_strings(struct FilterList *, char *, int);
void parse_json_array (json_object *, char *, struct CommandList *);
void parse_json (json_object *, struct CommandList *);
void parse_comlist (struct CommandList *, struct FilterList *);
RequestTypes parse_string_to_enum( const char * );
#endif