\r\n

51Degrees Device Detection C/C++  4.4

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

string.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_STRING_H_INCLUDED
24 #define FIFTYONE_DEGREES_STRING_H_INCLUDED
25 
66 #include <stdint.h>
67 #include <ctype.h>
68 #include "exceptions.h"
69 #include "collection.h"
70 #include "float.h"
71 #include "common.h"
72 
78 typedef enum fiftyone_degrees_string_format {
84 
90 #define FIFTYONE_DEGREES_STRING(s) \
91  (const char*)(s == NULL ? NULL : &((fiftyoneDegreesString*)s)->value)
92 
100 #define FIFTYONE_DEGREES_IP_ADDRESS(s) \
101  (const char*)(s == NULL \
102  || ((fiftyoneDegreesString*)s)->value \
103  != FIFTYONE_DEGREES_STRING_IP_ADDRESS ? \
104  NULL : \
105  &((fiftyoneDegreesString*)s)->trail.secondValue)
106 
108 #pragma pack(push, 1)
109 typedef struct fiftyone_degrees_string_t {
110  int16_t size;
111  char value;
112  union {
113  char secondValue;
114  struct {
117  } coordinate;
118  } trail;
120 #pragma pack(pop)
121 
122 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
123 
134 EXTERNAL void* fiftyoneDegreesStringRead(
135  const fiftyoneDegreesCollectionFile *file,
136  uint32_t offset,
137  fiftyoneDegreesData *data,
138  fiftyoneDegreesException *exception);
139 
140 #endif
141 
152  fiftyoneDegreesCollection *strings,
153  uint32_t offset,
155  fiftyoneDegreesException *exception);
156 
165  char const *a,
166  char const *b,
167  size_t length);
168 
175 EXTERNAL int fiftyoneDegreesStringCompare(const char *a, const char *b);
176 
184 EXTERNAL char *fiftyoneDegreesStringSubString(const char *a, const char *b);
185 
190 #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:308
Format is a pair of floats for latitude and longitude values.
Definition: string.h:79
Type of collection where the collection is streamed from file.
Definition: collection.h:445
char secondValue
If the string is an IP address, this will be the start byte.
Definition: string.h:113
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:109
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:101
int16_t size
Size of the string in memory.
Definition: string.h:110
Format is a byte array representation of an IP address.
Definition: string.h:81
char * fiftyoneDegreesStringSubString(const char *a, const char *b)
Case insensitively searching a first occurrence of a substring.
Struture that represents 51Degrees implementation, which encapsulate an array of 4 bytes.
Definition: float.h:111
fiftyoneDegreesStringFormat
Enumeration to indicate what format is held in a string item These are the values that can be held at...
Definition: string.h:78
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:111
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:408
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:111