51Degrees Common C/C++  4.1

A shared functionality library that is used by 51Degrees products

headers.h

1 /* *********************************************************************
2  * This Source Code Form 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 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 #ifndef FIFTYONE_DEGREES_HEADERS_H_INCLUDED
17 #define FIFTYONE_DEGREES_HEADERS_H_INCLUDED
18 
84 #include <stdbool.h>
85 #include <stdint.h>
86 #include <stdlib.h>
87 #ifdef _MSC_FULL_VER
88 #include <string.h>
89 #else
90 #include <strings.h>
91 #define _stricmp strcasecmp
92 #define _strnicmp strncasecmp
93 #endif
94 #include "list.h"
95 #include "evidence.h"
96 #include "array.h"
97 
98 #ifdef __cplusplus
99 #define EXTERNAL extern "C"
100 #else
101 #define EXTERNAL
102 #endif
103 
107 typedef struct fiftyone_degrees_header_t {
111  uint32_t uniqueId;
114 
115 #define FIFTYONE_DEGREES_HEADERS_MEMBERS \
116 bool expectUpperPrefixedHeaders;
120 FIFTYONE_DEGREES_ARRAY_TYPE(
123 
128 
137 typedef long(*fiftyoneDegreesHeadersGetMethod)(
138  void *state,
139  uint32_t index,
141 
148 EXTERNAL size_t fiftyoneDegreesHeadersSize(int count);
149 
162  bool useUpperPrefixedHeaders,
163  void *state,
165 
173 EXTERNAL int fiftyoneDegreesHeaderGetIndex(
174  fiftyoneDegreesHeaders *headers,
175  const char* httpHeaderName,
176  size_t length);
177 
189  fiftyoneDegreesHeaders *headers,
190  uint32_t uniqueId);
191 
196 EXTERNAL void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers);
197 
204 EXTERNAL bool fiftyoneDegreesHeadersIsHttp(
205  void *state,
207 
212 #endif
#define FIFTYONE_DEGREES_HEADERS_MEMBERS
True if the headers structure should expect input header to be prefixed with 'HTTP_'.
Definition: headers.h:115
EXTERNAL bool fiftyoneDegreesHeadersIsHttp(void *state, fiftyoneDegreesEvidenceKeyValuePair *pair)
Determines if the key of an evidence pair is an HTTP header.
Definition: headers.c:155
EXTERNAL 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.
Definition: headers.c:131
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition: collection.h:302
EXTERNAL void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers)
Frees the memory allocated by the fiftyoneDegreesHeadersCreate method.
Definition: headers.c:143
EXTERNAL fiftyoneDegreesHeaders * fiftyoneDegreesHeadersCreate(bool useUpperPrefixedHeaders, void *state, fiftyoneDegreesHeadersGetMethod get)
Creates a new headers instance configured with the unique HTTP names needed from evidence.
Definition: headers.c:82
Evidence key value pair structure which combines the prefix, key and value.
Definition: evidence.h:158
Array of items of type fiftyoneDegreesHeader used to easily access and track the size of the array.
Definition: headers.h:124
Header structure containing the name and unique id.
Definition: headers.h:107
EXTERNAL int fiftyoneDegreesHeaderGetIndex(fiftyoneDegreesHeaders *headers, const char *httpHeaderName, size_t length)
Provides the integer index of the HTTP header name.
Definition: headers.c:96
fiftyoneDegreesHeaderArray fiftyoneDegreesHeaders
Array of headers used to easily access and track the size of the array.
Definition: headers.h:124
uint32_t uniqueId
Id which uniquely identifies the header within the data set.
Definition: headers.h:111
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:139
fiftyoneDegreesCollectionItem name
Collection item containing the name of the header as a fiftyoneDegreesString.
Definition: headers.h:108
EXTERNAL size_t fiftyoneDegreesHeadersSize(int count)
Returns the number of bytes that will be allocated for a headers structure created using the fiftyone...
Definition: headers.c:168