\r\n

51Degrees Device Detection Varnish  4.3Newer Version 4.4

A device detection module for Varnish

vmod_fiftyonedegrees_interface.h

1 /* *********************************************************************
2  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3  * Copyright 2020 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
5  *
6  * This Original Work is the subject of the following patents and patent
7  * applications, owned by 51 Degrees Mobile Experts Limited of 5 Charlotte
8  * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY:
9  * European Patent No. 2871816; and
10  * United States Patent Nos. 9,332,086 and 9,350,823.
11  *
12  * This Original Work is licensed under the European Union Public Licence (EUPL)
13  * v.1.2 and is subject to its terms as set out below.
14  *
15  * If a copy of the EUPL was not distributed with this file, You can obtain
16  * one at https://opensource.org/licenses/EUPL-1.2.
17  *
18  * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
19  * amended by the European Commission) shall be deemed incompatible for
20  * the purposes of the Work and the provisions of the compatibility
21  * clause in Article 5 of the EUPL shall not apply.
22  *
23  * If using the Work as, or as part of, a network application, by
24  * including the attribution notice(s) required under Article 5 of the EUPL
25  * in the end user terms of the application under an appropriate heading,
26  * such notice(s) shall fulfill the requirements of that article.
27  * ********************************************************************* */
28 
29 #ifndef VMOD_FIFTYONEDEGREES_INTERFACE_H
30 #define VMOD_FIFTYONEDEGREES_INTERFACE_H
31 
32 #include <stdio.h>
33 #include <string.h>
34 
35 #ifndef FIFTYONEDEGREES_PROPERTY_NOT_FOUND
36 #define FIFTYONEDEGREES_PROPERTY_NOT_FOUND "N/A"
37 #endif
38 
39 #include "device-detection-cxx/src/hash/fiftyone.h"
40 #include "device-detection-cxx/src/hash/hash.h"
41 #include "vmod_fiftyonedegrees_extra.h"
42 
43 #define CONFIG_OPTION(t) \
44 typedef struct vmodfod_config_##t##_t{ \
45  bool set; \
46  t value; \
47 } vmodfod_config_##t;
48 
49 CONFIG_OPTION(int)
50 CONFIG_OPTION(bool)
51 
52 
55 typedef struct vmodfod_setHeader_t {
56  const char *name;
57  size_t propertyCount;
58  int *propertyIndexes;
60 } vmodfod_setHeader;
61 
66 typedef struct vmodfod_global_t {
67  ResourceManager *manager;
68  ConfigHash *config;
69  vmodfod_config_int drift;
71  vmodfod_config_int difference;
73  vmodfod_config_int maxConcurrency;
74  vmodfod_config_bool allowUnmatched;
75  vmodfod_config_bool usePerformanceGraph;
76  vmodfod_config_bool usePredictiveGraph;
77  const char *performanceProfile;
78  const char *requiredProperties;
79  const char *propertyDelimiter;
80  StatusCode status;
81  size_t setHeadersCount;
82  vmodfod_setHeader *setHeaders;
86 
90 #define VMODFOD_DEFAULTGLOBAL \
91 { \
92  NULL, \
93  NULL, \
94  {false, 0}, \
95  {false, 0}, \
96  {false, 0}, \
97  {false, false}, \
98  {false, true}, \
99  {false, true}, \
100  "DEFAULT", \
101  NULL, \
102  ",", \
103  NOT_SET, \
104  0, \
105  NULL \
106 }
107 
108 /*
109  * Convert string 'YES'|'NO' to corresponding boolean value
110  */
111 #define VMODFOD_GET_BOOL(s) strcmp(s, "YES") == 0 ? true : false
112 
113 /* Forward declarations */
114 bool RESULTS_HASH_GET_HAS_VALUES(
115  ResultsHash *results,
116  int requiredPropertyIndex,
117  Exception *exception);
118 
119 ResultsHash *OBTAIN_RESULTS_FROM_AVAILABLE_HEADERS(
120  const struct vrt_ctx *ctx,
121  Exception *exception);
122 
123 #endif
vmodfod_setHeader * setHeaders
Array of response headers to set in the set_resp_headers function.
Definition: vmod_fiftyonedegrees_interface.h:82
size_t setHeadersCount
Number of headers in the setHeaders array.
Definition: vmod_fiftyonedegrees_interface.h:81
vmodfod_config_int drift
Drift value that allows substrings to be matched in a wider range of character positions.
Definition: vmod_fiftyonedegrees_interface.h:69
const char * requiredProperties
The required properties.
Definition: vmod_fiftyonedegrees_interface.h:78
ConfigHash * config
Single config instance constructed at startup.
Definition: vmod_fiftyonedegrees_interface.h:68
vmodfod_config_int maxConcurrency
Max number of concurrent requests to be expected.
Definition: vmod_fiftyonedegrees_interface.h:73
vmodfod_config_bool usePredictiveGraph
Use predictive optimized graph.
Definition: vmod_fiftyonedegrees_interface.h:76
vmodfod_config_bool allowUnmatched
Allow unmatched results.
Definition: vmod_fiftyonedegrees_interface.h:74
StatusCode status
Status returned when the provider is initialised.
Definition: vmod_fiftyonedegrees_interface.h:80
vmodfod_config_int difference
Difference value to allow User-Agents where the character is slightly different from what is expected...
Definition: vmod_fiftyonedegrees_interface.h:71
const char * propertyDelimiter
The delimiter to use when returning value strings.
Definition: vmod_fiftyonedegrees_interface.h:79
vmodfod_config_bool usePerformanceGraph
Use performance optimized graph.
Definition: vmod_fiftyonedegrees_interface.h:75
ResourceManager * manager
Single manager instance constructed at startup.
Definition: vmod_fiftyonedegrees_interface.h:67
Global structure used by the module.
Definition: vmod_fiftyonedegrees_interface.h:66
const char * performanceProfile
The performance profile name.
Definition: vmod_fiftyonedegrees_interface.h:77