51Degrees Device Detection Varnish  4.1

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 
56 typedef struct vmodfod_global_t {
57  ResourceManager *manager;
58  ConfigHash *config;
59  vmodfod_config_int drift;
61  vmodfod_config_int difference;
63  vmodfod_config_int maxConcurrency;
64  vmodfod_config_bool allowUnmatched;
65  vmodfod_config_bool usePerformanceGraph;
66  vmodfod_config_bool usePredictiveGraph;
67  const char *performanceProfile;
68  const char *requiredProperties;
69  const char *propertyDelimiter;
70  StatusCode status;
71 } vmodfod_global;
72 
76 #define VMODFOD_DEFAULTGLOBAL \
77 { \
78  NULL, \
79  NULL, \
80  {false, 0}, \
81  {false, 0}, \
82  {false, 0}, \
83  {false, false}, \
84  {false, true}, \
85  {false, true}, \
86  "DEFAULT", \
87  NULL, \
88  ",", \
89  NOT_SET \
90 }
91 
92 /*
93  * Convert string 'YES'|'NO' to corresponding boolean value
94  */
95 #define VMODFOD_GET_BOOL(s) strcmp(s, "YES") == 0 ? true : false
96 
97 /* Forward declarations */
98 bool RESULTS_HASH_GET_HAS_VALUES(
99  ResultsHash *results,
100  int requiredPropertyIndex,
101  Exception *exception);
102 
103 ResultsHash *OBTAIN_RESULTS_FROM_AVAILABLE_HEADERS(
104  const struct vrt_ctx *ctx,
105  Exception *exception);
106 
107 #endif