\r\n

51Degrees Device Detection C/C++  4.2

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

dataset.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_DATASET_H_INCLUDED
24 #define FIFTYONE_DEGREES_DATASET_H_INCLUDED
25 
89 #include "exceptions.h"
90 #include "file.h"
91 #include "memory.h"
92 #include "resource.h"
93 #include "properties.h"
94 #include "headers.h"
95 #include "config.h"
96 #include "overrides.h"
97 
101 typedef struct fiftyone_degrees_dataset_base_t {
102  const char fileName[FIFTYONE_DEGREES_FILE_MAX_PATH];
109  const char masterFileName[FIFTYONE_DEGREES_FILE_MAX_PATH];
113  void *memoryToFree;
118  bool isInMemory;
120  bool isClientHintsEnabled;
129  const void *config;
131 
149  void *dataSet,
150  const void *config,
152  void *memory,
153  long size,
154  fiftyoneDegreesException *exception);
155 
176  void *dataSet,
177  const void *config,
179  const char *fileName,
180  fiftyoneDegreesException *exception);
181 
199  void *state,
200  fiftyoneDegreesPropertiesGetMethod getPropertyMethod,
201  fiftyoneDegreesEvidencePropertiesGetMethod getEvidencePropertiesMethod);
202 
217  void *state,
218  fiftyoneDegreesHeadersGetMethod getHeaderMethod);
219 
235  const char *fileName,
236  long bytesToCompare);
237 
249 
255 
265 
272 
279 
304  void *source,
305  long length,
306  size_t dataSetSize,
308  fiftyoneDegreesException *exception);
309 
332  const char *fileName,
333  size_t dataSetSize,
335  fiftyoneDegreesException *exception);
336 
344 #define FIFTYONE_DEGREES_DATASET_RELOAD(t) \
345  \
363 fiftyoneDegreesStatusCode fiftyoneDegrees##t##ReloadManagerFromMemory( \
364 fiftyoneDegreesResourceManager *manager, \
365 void *source, \
366 long length, \
367 fiftyoneDegreesException *exception) { \
368  return fiftyoneDegreesDataSetReloadManagerFromMemory( \
369  manager, \
370  source, \
371  length, \
372  sizeof(DataSet##t), \
373  initDataSetFromMemory, \
374  exception); \
375 } \
376  \
392 fiftyoneDegreesStatusCode fiftyoneDegrees##t##ReloadManagerFromFile( \
393 fiftyoneDegreesResourceManager* manager, \
394 const char *fileName, \
395 fiftyoneDegreesException *exception) { \
396  return fiftyoneDegreesDataSetReloadManagerFromFile( \
397  manager, \
398  fileName, \
399  sizeof(DataSet##t), \
400  initDataSetFromFile, \
401  exception); \
402 } \
403  \
418 fiftyoneDegreesStatusCode fiftyoneDegrees##t##ReloadManagerFromOriginalFile( \
419 fiftyoneDegreesResourceManager* manager, \
420 fiftyoneDegreesException *exception) { \
421  fiftyoneDegreesStatusCode status = FIFTYONE_DEGREES_STATUS_NOT_SET; \
422  DataSet##t* dataSet = fiftyoneDegreesDataSet##t##Get(manager); \
423  status = fiftyoneDegrees##t##ReloadManagerFromFile( \
424  manager, \
425  dataSet->b.b.masterFileName, \
426  exception); \
427  fiftyoneDegreesDataSet##t##Release(dataSet); \
428  return status; \
429 }
430 
435 #endif
bool isInMemory
True if the data file has been read into continuous memory.
Definition: dataset.h:118
fiftyoneDegreesFilePool filePool
True if client hints is enabled.
Definition: dataset.h:121
fiftyoneDegreesStatusCode fiftyoneDegreesDataSetInitProperties(fiftyoneDegreesDataSetBase *dataSet, fiftyoneDegreesPropertiesRequired *properties, void *state, fiftyoneDegreesPropertiesGetMethod getPropertyMethod, fiftyoneDegreesEvidencePropertiesGetMethod getEvidencePropertiesMethod)
Initialises the properties in the data set.
fiftyoneDegreesStatusCode
Status returned from the initialisation of a resource.
Definition: status.h:82
fiftyoneDegreesStatusCode fiftyoneDegreesDataSetInitHeaders(fiftyoneDegreesDataSetBase *dataSet, void *state, fiftyoneDegreesHeadersGetMethod getHeaderMethod)
Initialises the HTTP headers in the data set.
fiftyoneDegreesStatusCode fiftyoneDegreesDataSetReloadManagerFromMemory(fiftyoneDegreesResourceManager *manager, void *source, long length, size_t dataSetSize, fiftyoneDegreesDataSetInitFromMemoryMethod initDataSet, fiftyoneDegreesException *exception)
Reload the data set being used by the resource manager using a data file loaded into contiguous memor...
fiftyoneDegreesResourceHandle * handle
Pointer to the handle that tracks this data set instance.
Definition: dataset.h:122
fiftyoneDegreesStatusCode(* fiftyoneDegreesDataSetInitFromMemoryMethod)(void *dataSet, const void *config, fiftyoneDegreesPropertiesRequired *properties, void *memory, long size, fiftyoneDegreesException *exception)
Initialses the data set from data stored in continuous memory.
Definition: dataset.h:148
fiftyoneDegreesStatusCode fiftyoneDegreesDataSetInitInMemory(fiftyoneDegreesDataSetBase *dataSet, fiftyoneDegreesMemoryReader *reader)
Initialses the data set from data stored in continuous memory.
void * memoryToFree
A pointer to the memory where the data within the data set is held.
Definition: dataset.h:113
void fiftyoneDegreesDataSetFree(fiftyoneDegreesDataSetBase *dataSet)
Closes the data set by freeing anything which has been initialised at creation.
Used to read data from memory in a similar manner to a file handle.
Definition: memory.h:58
uint32_t(* fiftyoneDegreesEvidencePropertiesGetMethod)(void *state, fiftyoneDegreesPropertyAvailable *property, fiftyoneDegreesEvidenceProperties *evidenceProperties)
Populates the evidence properties structure with the indexes of the properties required by the proper...
Definition: properties.h:218
fiftyoneDegreesPropertiesAvailable * available
Available properties.
Definition: dataset.h:124
fiftyoneDegreesStatusCode fiftyoneDegreesDataSetReloadManagerFromFile(fiftyoneDegreesResourceManager *manager, const char *fileName, size_t dataSetSize, fiftyoneDegreesDataSetInitFromFileMethod initDataSet, fiftyoneDegreesException *exception)
Reload the data set being used by the resource manager using the data file location specified.
Array of items of type fiftyoneDegreesHeader used to easily access and track the size of the array.
Definition: headers.h:135
fiftyoneDegreesStatusCode fiftyoneDegreesDataSetInitFromFile(fiftyoneDegreesDataSetBase *dataSet, const char *fileName, long bytesToCompare)
Initialses the data set from data stored on file.
fiftyoneDegreesString *(* fiftyoneDegreesPropertiesGetMethod)(void *state, uint32_t index, fiftyoneDegreesCollectionItem *item)
Returns a string for the property at the index provided or NULL if there is no property available at ...
Definition: properties.h:200
Array of items of type fiftyoneDegreesPropertyAvailable used to easily access and track the size of t...
Definition: properties.h:170
Handle for a shared resource.
Definition: resource.h:162
const void * config
Pointer to the config used to create the dataset.
Definition: dataset.h:129
fiftyoneDegreesOverridePropertyArray * overridable
Array of properties that can be overridden.
Definition: dataset.h:126
fiftyoneDegreesStatusCode(* fiftyoneDegreesDataSetInitFromFileMethod)(void *dataSet, const void *config, fiftyoneDegreesPropertiesRequired *properties, const char *fileName, fiftyoneDegreesException *exception)
Initialses the data set from data stored on file.
Definition: dataset.h:175
Defines a set of properties which are required by a caller.
Definition: properties.h:180
Manager structure used to provide access to a shared and changing resource.
Definition: resource.h:178
Base data set structure which contains the 'must have's for all data sets.
Definition: dataset.h:101
void fiftyoneDegreesDataSetReset(fiftyoneDegreesDataSetBase *dataSet)
Resets a newly allocated data set structure ready for initialisation.
fiftyoneDegreesDataSetBase * fiftyoneDegreesDataSetGet(fiftyoneDegreesResourceManager *manager)
Gets a pointer to the active data set from a resource manager.
fiftyoneDegreesHeaders * uniqueHeaders
Related HTTP headers.
Definition: dataset.h:125
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:116
Stack of handles used to read data from a single source file.
Definition: file.h:222
void fiftyoneDegreesDataSetRelease(fiftyoneDegreesDataSetBase *dataSet)
Releases a reference to a data set which has been fetched via the DataSetGet method.
#define FIFTYONE_DEGREES_FILE_MAX_PATH
Define the max path length on the target system.
Definition: file.h:202
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:150
Array of items of type fiftyoneDegreesOverrideProperty used to easily access and track the size of th...
Definition: overrides.h:108