\r\n

51Degrees Device Detection C/C++  4.5

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 2023 51 Degrees Mobile Experts Limited, Davidson House,
4  * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5  *
6  * This Original Work is licensed under the European Union Public Licence
7  * (EUPL) 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 
92 #include <stdbool.h>
93 #include <stdint.h>
94 #include <stdlib.h>
95 #ifdef _MSC_FULL_VER
96 #include <string.h>
97 #else
98 #include <strings.h>
99 #define _stricmp strcasecmp
100 #define _strnicmp strncasecmp
101 #endif
102 #include "list.h"
103 #include "array.h"
104 #include "common.h"
105 
106 #define FIFTYONE_DEGREES_PSEUDO_HEADER_SEP '\x1F'
114 typedef uint32_t fiftyoneDegreesHeaderID;
115 
119 typedef struct fiftyone_degrees_header_t fiftyoneDegreesHeader;
120 
124 typedef fiftyoneDegreesHeader* fiftyoneDegreesHeaderPtr;
125 
131  );
133 
138  uint32_t index;
139  const char* name;
141  size_t nameLength;
145  bool isDataSet;
152 };
153 
154 #define FIFTYONE_DEGREES_HEADERS_MEMBERS \
155 bool expectUpperPrefixedHeaders;
163 FIFTYONE_DEGREES_ARRAY_TYPE(
164  fiftyoneDegreesHeader,
166 
171 
181 typedef long(*fiftyoneDegreesHeadersGetMethod)(
182  void *state,
183  uint32_t index,
185 
201  bool useUpperPrefixedHeaders,
202  void *state,
204  fiftyoneDegreesException* exception);
205 
214 EXTERNAL int fiftyoneDegreesHeaderGetIndex(
215  fiftyoneDegreesHeaders *headers,
216  const char* httpHeaderName,
217  size_t length);
218 
229 EXTERNAL fiftyoneDegreesHeader* fiftyoneDegreesHeadersGetHeaderFromUniqueId(
230  fiftyoneDegreesHeaders *headers,
231  fiftyoneDegreesHeaderID uniqueId);
232 
238 EXTERNAL void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers);
239 
247 EXTERNAL bool fiftyoneDegreesHeadersIsHttp(
248  void *state,
249  const char* field,
250  size_t length);
251 
256 #endif
#define FIFTYONE_DEGREES_HEADERS_MEMBERS
True if the headers structure should expect input header to be prefixed with 'HTTP_'.
Definition: headers.h:154
fiftyoneDegreesHeader * fiftyoneDegreesHeadersGetHeaderFromUniqueId(fiftyoneDegreesHeaders *headers, fiftyoneDegreesHeaderID uniqueId)
Gets a pointer to the header in the headers structure with a unique id matching the one provided.
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
uint32_t fiftyoneDegreesHeaderID
The unique id for the header field string in the data set.
Definition: headers.h:114
fiftyoneDegreesHeaders * fiftyoneDegreesHeadersCreate(bool useUpperPrefixedHeaders, void *state, fiftyoneDegreesHeadersGetMethod get, fiftyoneDegreesException *exception)
Creates a new headers instance configured with the unique HTTP names needed from evidence.
fiftyoneDegreesHeader * fiftyoneDegreesHeaderPtr
Pointer to a header structure.
Definition: headers.h:124
fiftyoneDegreesHeaderPtrs * pseudoHeaders
Array of pointers to related pseudo headers.
Definition: headers.h:147
Structure for a header known to the corresponding data set.
Definition: headers.h:137
size_t nameLength
Length of the name string excluding the terminating null.
Definition: headers.h:141
uint32_t index
Index of the header in the array of all headers.
Definition: headers.h:138
bool isDataSet
True if the header originates from the data set and the headerId is valid.
Definition: headers.h:145
fiftyoneDegreesHeaderID headerId
Unique id in the data set for this full header.
Definition: headers.h:143
Array of header indexes.
Definition: headers.h:131
bool fiftyoneDegreesHeadersIsHttp(void *state, const char *field, size_t length)
Determines if the field is an HTTP header.
Array of Headers which should always be ordered in ascending order of fullHeaderId.
Definition: headers.h:167
fiftyoneDegreesHeaderPtrs * segmentHeaders
Array of pointers to raw headers that form this pseudo header.
Definition: headers.h:149
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:111
const char * name
Name of the header or pseudo header field as a null terminated string.
Definition: headers.h:139
fiftyoneDegreesHeaderArray fiftyoneDegreesHeaders
Array of headers used to easily access and track the size of the array.
Definition: headers.h:167
int fiftyoneDegreesHeaderGetIndex(fiftyoneDegreesHeaders *headers, const char *httpHeaderName, size_t length)
Provides the integer index of the HTTP header name, or -1 if there is no matching header.
#define FIFTYONE_DEGREES_ARRAY_TYPE(t, m)
Simple array structure definition macro used for generic types.
Definition: array.h:51
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:183