51Degrees Device Detection C/C++  4.1

A device detection library that is used natively or by 51Degrees products

headers.h

1 /* *********************************************************************
2  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3  * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
5  *
6  * This Original Work is licensed under the European Union Public Licence (EUPL)
7  * v.1.2 and is subject to its terms as set out below.
8  *
9  * If a copy of the EUPL was not distributed with this file, You can obtain
10  * one at https://opensource.org/licenses/EUPL-1.2.
11  *
12  * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13  * amended by the European Commission) shall be deemed incompatible for
14  * the purposes of the Work and the provisions of the compatibility
15  * clause in Article 5 of the EUPL shall not apply.
16  *
17  * If using the Work as, or as part of, a network application, by
18  * including the attribution notice(s) required under Article 5 of the EUPL
19  * in the end user terms of the application under an appropriate heading,
20  * such notice(s) shall fulfill the requirements of that article.
21  * ********************************************************************* */
22 
23 #ifndef FIFTYONE_DEGREES_HEADERS_H_INCLUDED
24 #define FIFTYONE_DEGREES_HEADERS_H_INCLUDED
25 
91 #include <stdbool.h>
92 #include <stdint.h>
93 #include <stdlib.h>
94 #ifdef _MSC_FULL_VER
95 #include <string.h>
96 #else
97 #include <strings.h>
98 #define _stricmp strcasecmp
99 #define _strnicmp strncasecmp
100 #endif
101 #include "list.h"
102 #include "evidence.h"
103 #include "array.h"
104 
105 #ifdef __cplusplus
106 #define EXTERNAL extern "C"
107 #else
108 #define EXTERNAL
109 #endif
110 
114 typedef struct fiftyone_degrees_header_t {
118  uint32_t uniqueId;
121 
122 #define FIFTYONE_DEGREES_HEADERS_MEMBERS \
123 bool expectUpperPrefixedHeaders;
127 FIFTYONE_DEGREES_ARRAY_TYPE(
130 
135 
144 typedef long(*fiftyoneDegreesHeadersGetMethod)(
145  void *state,
146  uint32_t index,
148 
155 EXTERNAL size_t fiftyoneDegreesHeadersSize(int count);
156 
169  bool useUpperPrefixedHeaders,
170  void *state,
172 
180 EXTERNAL int fiftyoneDegreesHeaderGetIndex(
181  fiftyoneDegreesHeaders *headers,
182  const char* httpHeaderName,
183  size_t length);
184 
196  fiftyoneDegreesHeaders *headers,
197  uint32_t uniqueId);
198 
203 EXTERNAL void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers);
204 
211 EXTERNAL bool fiftyoneDegreesHeadersIsHttp(
212  void *state,
214 
219 #endif
fiftyoneDegreesHeaders * fiftyoneDegreesHeadersCreate(bool useUpperPrefixedHeaders, void *state, fiftyoneDegreesHeadersGetMethod get)
Creates a new headers instance configured with the unique HTTP names needed from evidence.
size_t fiftyoneDegreesHeadersSize(int count)
Returns the number of bytes that will be allocated for a headers structure created using the fiftyone...
#define FIFTYONE_DEGREES_HEADERS_MEMBERS
True if the headers structure should expect input header to be prefixed with 'HTTP_'.
Definition: headers.h:122
void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers)
Frees the memory allocated by the fiftyoneDegreesHeadersCreate method.
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition: collection.h:309
fiftyoneDegreesHeader * fiftyoneDegreesHeadersGetHeaderFromUniqueId(fiftyoneDegreesHeaders *headers, uint32_t uniqueId)
Gets a pointer to the header in the headers structure with a unique id matching the one provided.
Evidence key value pair structure which combines the prefix, key and value.
Definition: evidence.h:165
Array of items of type fiftyoneDegreesHeader used to easily access and track the size of the array.
Definition: headers.h:131
Header structure containing the name and unique id.
Definition: headers.h:114
bool fiftyoneDegreesHeadersIsHttp(void *state, fiftyoneDegreesEvidenceKeyValuePair *pair)
Determines if the key of an evidence pair is an HTTP header.
fiftyoneDegreesHeaderArray fiftyoneDegreesHeaders
Array of headers used to easily access and track the size of the array.
Definition: headers.h:131
int fiftyoneDegreesHeaderGetIndex(fiftyoneDegreesHeaders *headers, const char *httpHeaderName, size_t length)
Provides the integer index of the HTTP header name.
uint32_t uniqueId
Id which uniquely identifies the header within the data set.
Definition: headers.h:118
long(* fiftyoneDegreesHeadersGetMethod)(void *state, uint32_t index, fiftyoneDegreesCollectionItem *nameItem)
Gets the unique id and name of the header at the requested index.
Definition: headers.h:146
fiftyoneDegreesCollectionItem name
Collection item containing the name of the header as a fiftyoneDegreesString.
Definition: headers.h:115