blob: 9aaf9498ea323c52cd0330e31c028e0dedf2e093 [file] [log] [blame]
Ben51Degrees31c3d512019-06-12 15:42:53 +01001/* *********************************************************************
2 * This Source Code Form is copyright of 51Degrees Mobile Experts Limited.
3 * Copyright 2019 51Degrees Mobile Experts Limited, 5 Charlotte Close,
4 * Caversham, Reading, Berkshire, United Kingdom RG4 7BY
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0.
8 *
9 * If a copy of the MPL was not distributed with this file, You can obtain
10 * one at http://mozilla.org/MPL/2.0/.
11 *
12 * This Source Code Form is "Incompatible With Secondary Licenses", as
13 * defined by the Mozilla Public License, v. 2.0.
14 * *********************************************************************/
15
16/* *********************************************************************
17 * Dummy library for HAProxy. This does not function, and is designed
18 * solely for HAProxy testing purposes.
19 * *********************************************************************/
20#ifndef FIFTYONEDEGREES_H_INCLUDED
21#define FIFTYONEDEGREES_H_INCLUDED
22
23#ifndef FIFTYONEDEGREES_H_PATTERN_INCLUDED
24#define FIFTYONEDEGREES_H_PATTERN_INCLUDED
25#endif
26
Ben51Degreesf4a82fb2019-06-13 16:51:59 +010027#ifndef FIFTYONEDEGREES_DUMMY_LIB
28#define FIFTYONEDEGREES_DUMMY_LIB
29#endif
30
Ben51Degrees31c3d512019-06-12 15:42:53 +010031#include <stdint.h>
32
33typedef enum e_fiftyoneDegrees_MatchMethod {
34 NONE,
35 EXACT,
36 NUMERIC,
37 NEAREST,
38 CLOSEST
39} fiftyoneDegreesMatchMethod;
40
41typedef enum e_fiftyoneDegrees_DataSetInitStatus {
42 DATA_SET_INIT_STATUS_SUCCESS,
43 DATA_SET_INIT_STATUS_INSUFFICIENT_MEMORY,
44 DATA_SET_INIT_STATUS_CORRUPT_DATA,
45 DATA_SET_INIT_STATUS_INCORRECT_VERSION,
46 DATA_SET_INIT_STATUS_FILE_NOT_FOUND,
47 DATA_SET_INIT_STATUS_NOT_SET,
48 DATA_SET_INIT_STATUS_POINTER_OUT_OF_BOUNDS,
49 DATA_SET_INIT_STATUS_NULL_POINTER
50} fiftyoneDegreesDataSetInitStatus;
51
52typedef struct fiftyoneDegrees_ascii_string_t {
53 const int16_t length;
54 const char firstByte;
55} fiftyoneDegreesAsciiString;
56
57typedef struct fiftyoneDegrees_dataset_header_t {
58} fiftyoneDegreesDataSetHeader;
59
60typedef struct fiftyoneDegrees_workset_pool_t {
61} fiftyoneDegreesWorksetPool;
62
63typedef struct fiftyoneDegrees_property_t {
64} fiftyoneDegreesProperty;
65
66typedef struct fiftyoneDegrees_value_t {
67} fiftyoneDegreesValue;
68
69typedef struct fiftyoneDegrees_resultset_cache_t {
70} fiftyoneDegreesResultsetCache;
71
72typedef struct fiftyoneDegrees_http_header_t {
73 int32_t headerNameOffset;
74 const char *headerName;
75} fiftyoneDegreesHttpHeader;
76
77typedef struct fiftyoneDegrees_http_header_workset_t {
78 fiftyoneDegreesHttpHeader *header;
79 const char *headerValue;
80 int headerValueLength;
81} fiftyoneDegreesHttpHeaderWorkset;
82
83
84typedef struct fiftyoneDegrees_dataset_t {
85 int32_t httpHeadersCount;
86 fiftyoneDegreesHttpHeader *httpHeaders;
87 int32_t requiredPropertyCount;
88 const fiftyoneDegreesProperty **requiredProperties;
89} fiftyoneDegreesDataSet;
90
91typedef struct fiftyoneDegrees_workset_t {
92 fiftyoneDegreesDataSet *dataSet;
93 int32_t importantHeadersCount;
94 fiftyoneDegreesHttpHeaderWorkset *importantHeaders;
95 fiftyoneDegreesMatchMethod method;
96 int32_t difference;
97 const fiftyoneDegreesValue **values;
98} fiftyoneDegreesWorkset;
99
100int32_t fiftyoneDegreesGetSignatureRank(fiftyoneDegreesWorkset *ws);
101
102const char* fiftyoneDegreesGetPropertyName(
103 const fiftyoneDegreesDataSet *dataSet,
104 const fiftyoneDegreesProperty *property);
105
106int32_t fiftyoneDegreesSetValues(
107 fiftyoneDegreesWorkset *ws,
108 int32_t requiredPropertyIndex);
109
110const char* fiftyoneDegreesGetValueName(
111 const fiftyoneDegreesDataSet *dataSet,
112 const fiftyoneDegreesValue *value);
113
114fiftyoneDegreesWorkset *fiftyoneDegreesWorksetPoolGet(
115 fiftyoneDegreesWorksetPool *pool);
116
117void fiftyoneDegreesWorksetPoolRelease(
118 fiftyoneDegreesWorksetPool *pool,
119 fiftyoneDegreesWorkset *ws);
120
121void fiftyoneDegreesMatchForHttpHeaders(fiftyoneDegreesWorkset *ws);
122
123void fiftyoneDegreesMatch(
124 fiftyoneDegreesWorkset *ws,
125 const char* userAgent);
126
127fiftyoneDegreesDataSetInitStatus fiftyoneDegreesInitWithPropertyArray(
128 const char *fileName,
129 fiftyoneDegreesDataSet *dataSet,
130 const char** properties,
131 int32_t count);
132
133fiftyoneDegreesWorksetPool *fiftyoneDegreesWorksetPoolCreate(
134 fiftyoneDegreesDataSet *dataSet,
135 fiftyoneDegreesResultsetCache *cache,
136 int32_t size);
137
138void fiftyoneDegreesWorksetPoolFree(
139 const fiftyoneDegreesWorksetPool *pool);
140
141void fiftyoneDegreesDataSetFree(const fiftyoneDegreesDataSet *dataSet);
142
143const fiftyoneDegreesAsciiString* fiftyoneDegreesGetString(
144 const fiftyoneDegreesDataSet *dataSet,
145 int32_t offset);
146
147#endif