51Degrees Device Detection C/C++  4.2Newer Version 4.4

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


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  * ********************************************************************* */
66 #include <stdint.h>
67 #include <ctype.h>
68 #include "exceptions.h"
69 #include "collection.h"
70 #include "float.h"
72 #ifdef __cplusplus
73 #define EXTERNAL extern "C"
74 #else
75 #define EXTERNAL
76 #endif
83 typedef enum fiftyone_degrees_string_format {
96  (const char*)(s == NULL ? NULL : &((fiftyoneDegreesString*)s)->value)
106  (const char*)(s == NULL \
107  || ((fiftyoneDegreesString*)s)->value \
109  NULL : \
110  &((fiftyoneDegreesString*)s)->trail.secondValue)
113 #pragma pack(push, 1)
114 typedef struct fiftyone_degrees_string_t {
115  int16_t size;
116  char value;
117  union {
118  char secondValue;
119  struct {
122  } coordinate;
123  } trail;
125 #pragma pack(pop)
139 EXTERNAL void* fiftyoneDegreesStringRead(
140  const fiftyoneDegreesCollectionFile *file,
141  uint32_t offset,
142  fiftyoneDegreesData *data,
143  fiftyoneDegreesException *exception);
145 #endif
157  fiftyoneDegreesCollection *strings,
158  uint32_t offset,
160  fiftyoneDegreesException *exception);
170  char const *a,
171  char const *b,
172  size_t length);
180 EXTERNAL int fiftyoneDegreesStringCompare(const char *a, const char *b);
189 EXTERNAL char *fiftyoneDegreesStringSubString(const char *a, const char *b);
195 #endif
int fiftyoneDegreesStringCompare(const char *a, const char *b)
Case insensitively compare two strings.
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
Format is a pair of floats for latitude and longitude values.
Definition: string.h:84
Type of collection where the collection is streamed from file.
Definition: collection.h:446
char secondValue
If the string is an IP address, this will be the start byte.
Definition: string.h:118
int fiftyoneDegreesStringCompareLength(char const *a, char const *b, size_t length)
Case insensitively compare two strings up to the length requested.
String structure containing its value and size.
Definition: string.h:114
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:106
int16_t size
Size of the string in memory.
Definition: string.h:115
Format is a byte array representation of an IP address.
Definition: string.h:86
char * fiftyoneDegreesStringSubString(const char *a, const char *b)
Case insensitively searching a first occurence of a substring.
Struture that represents 51Degrees implementation, which encapsulate an array of 4 bytes.
Definition: float.h:122
Enumeration to indicate what format is held in a string item These are the values that can be held at...
Definition: string.h:83
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:116
fiftyoneDegreesString * fiftyoneDegreesStringGet(fiftyoneDegreesCollection *strings, uint32_t offset, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the string at the required offset from the collection provided.
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:409
void * fiftyoneDegreesStringRead(const fiftyoneDegreesCollectionFile *file, uint32_t offset, fiftyoneDegreesData *data, fiftyoneDegreesException *exception)
Reads a string from the source file at the offset within the string structure.
char value
The first character of the string.
Definition: string.h:116