Ben51Degrees | 31c3d51 | 2019-06-12 15:42:53 +0100 | [diff] [blame] | 1 | /* ********************************************************************* |
| 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 | |
Ben51Degrees | f4a82fb | 2019-06-13 16:51:59 +0100 | [diff] [blame] | 27 | #ifndef FIFTYONEDEGREES_DUMMY_LIB |
| 28 | #define FIFTYONEDEGREES_DUMMY_LIB |
| 29 | #endif |
| 30 | |
Ben51Degrees | 31c3d51 | 2019-06-12 15:42:53 +0100 | [diff] [blame] | 31 | #include <stdint.h> |
| 32 | |
| 33 | typedef enum e_fiftyoneDegrees_MatchMethod { |
| 34 | NONE, |
| 35 | EXACT, |
| 36 | NUMERIC, |
| 37 | NEAREST, |
| 38 | CLOSEST |
| 39 | } fiftyoneDegreesMatchMethod; |
| 40 | |
| 41 | typedef 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 | |
| 52 | typedef struct fiftyoneDegrees_ascii_string_t { |
| 53 | const int16_t length; |
| 54 | const char firstByte; |
| 55 | } fiftyoneDegreesAsciiString; |
| 56 | |
| 57 | typedef struct fiftyoneDegrees_dataset_header_t { |
| 58 | } fiftyoneDegreesDataSetHeader; |
| 59 | |
| 60 | typedef struct fiftyoneDegrees_workset_pool_t { |
| 61 | } fiftyoneDegreesWorksetPool; |
| 62 | |
| 63 | typedef struct fiftyoneDegrees_property_t { |
| 64 | } fiftyoneDegreesProperty; |
| 65 | |
| 66 | typedef struct fiftyoneDegrees_value_t { |
| 67 | } fiftyoneDegreesValue; |
| 68 | |
| 69 | typedef struct fiftyoneDegrees_resultset_cache_t { |
| 70 | } fiftyoneDegreesResultsetCache; |
| 71 | |
| 72 | typedef struct fiftyoneDegrees_http_header_t { |
| 73 | int32_t headerNameOffset; |
| 74 | const char *headerName; |
| 75 | } fiftyoneDegreesHttpHeader; |
| 76 | |
| 77 | typedef struct fiftyoneDegrees_http_header_workset_t { |
| 78 | fiftyoneDegreesHttpHeader *header; |
| 79 | const char *headerValue; |
| 80 | int headerValueLength; |
| 81 | } fiftyoneDegreesHttpHeaderWorkset; |
| 82 | |
| 83 | |
| 84 | typedef struct fiftyoneDegrees_dataset_t { |
| 85 | int32_t httpHeadersCount; |
| 86 | fiftyoneDegreesHttpHeader *httpHeaders; |
| 87 | int32_t requiredPropertyCount; |
| 88 | const fiftyoneDegreesProperty **requiredProperties; |
| 89 | } fiftyoneDegreesDataSet; |
| 90 | |
| 91 | typedef 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 | |
| 100 | int32_t fiftyoneDegreesGetSignatureRank(fiftyoneDegreesWorkset *ws); |
| 101 | |
| 102 | const char* fiftyoneDegreesGetPropertyName( |
| 103 | const fiftyoneDegreesDataSet *dataSet, |
| 104 | const fiftyoneDegreesProperty *property); |
| 105 | |
| 106 | int32_t fiftyoneDegreesSetValues( |
| 107 | fiftyoneDegreesWorkset *ws, |
| 108 | int32_t requiredPropertyIndex); |
| 109 | |
| 110 | const char* fiftyoneDegreesGetValueName( |
| 111 | const fiftyoneDegreesDataSet *dataSet, |
| 112 | const fiftyoneDegreesValue *value); |
| 113 | |
| 114 | fiftyoneDegreesWorkset *fiftyoneDegreesWorksetPoolGet( |
| 115 | fiftyoneDegreesWorksetPool *pool); |
| 116 | |
| 117 | void fiftyoneDegreesWorksetPoolRelease( |
| 118 | fiftyoneDegreesWorksetPool *pool, |
| 119 | fiftyoneDegreesWorkset *ws); |
| 120 | |
| 121 | void fiftyoneDegreesMatchForHttpHeaders(fiftyoneDegreesWorkset *ws); |
| 122 | |
| 123 | void fiftyoneDegreesMatch( |
| 124 | fiftyoneDegreesWorkset *ws, |
| 125 | const char* userAgent); |
| 126 | |
| 127 | fiftyoneDegreesDataSetInitStatus fiftyoneDegreesInitWithPropertyArray( |
| 128 | const char *fileName, |
| 129 | fiftyoneDegreesDataSet *dataSet, |
| 130 | const char** properties, |
| 131 | int32_t count); |
| 132 | |
| 133 | fiftyoneDegreesWorksetPool *fiftyoneDegreesWorksetPoolCreate( |
| 134 | fiftyoneDegreesDataSet *dataSet, |
| 135 | fiftyoneDegreesResultsetCache *cache, |
| 136 | int32_t size); |
| 137 | |
| 138 | void fiftyoneDegreesWorksetPoolFree( |
| 139 | const fiftyoneDegreesWorksetPool *pool); |
| 140 | |
| 141 | void fiftyoneDegreesDataSetFree(const fiftyoneDegreesDataSet *dataSet); |
| 142 | |
| 143 | const fiftyoneDegreesAsciiString* fiftyoneDegreesGetString( |
| 144 | const fiftyoneDegreesDataSet *dataSet, |
| 145 | int32_t offset); |
| 146 | |
| 147 | #endif |