SpatiaLite  5.0.0
gaiaaux.h
Go to the documentation of this file.
1 /*
2  gaiaaux.h -- Gaia common utility functions
3 
4  version 5.0, 2020 August 1
5 
6  Author: Sandro Furieri a.furieri@lqt.it
7 
8  ------------------------------------------------------------------------------
9 
10  Version: MPL 1.1/GPL 2.0/LGPL 2.1
11 
12  The contents of this file are subject to the Mozilla Public License Version
13  1.1 (the "License"); you may not use this file except in compliance with
14  the License. You may obtain a copy of the License at
15  http://www.mozilla.org/MPL/
16 
17 Software distributed under the License is distributed on an "AS IS" basis,
18 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19 for the specific language governing rights and limitations under the
20 License.
21 
22 The Original Code is the SpatiaLite library
23 
24 The Initial Developer of the Original Code is Alessandro Furieri
25 
26 Portions created by the Initial Developer are Copyright (C) 2008-2020
27 the Initial Developer. All Rights Reserved.
28 
29 Contributor(s):
30 
31 Alternatively, the contents of this file may be used under the terms of
32 either the GNU General Public License Version 2 or later (the "GPL"), or
33 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34 in which case the provisions of the GPL or the LGPL are applicable instead
35 of those above. If you wish to allow use of your version of this file only
36 under the terms of either the GPL or the LGPL, and not to allow others to
37 use your version of this file under the terms of the MPL, indicate your
38 decision by deleting the provisions above and replace them with the notice
39 and other provisions required by the GPL or the LGPL. If you do not delete
40 the provisions above, a recipient may use your version of this file under
41 the terms of any one of the MPL, the GPL or the LGPL.
42 
43 */
44 
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 #ifdef DLL_EXPORT
52 #define GAIAAUX_DECLARE __declspec(dllexport)
53 #else
54 #define GAIAAUX_DECLARE extern
55 #endif
56 #endif
57 
58 #ifndef _GAIAAUX_H
59 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 #define _GAIAAUX_H
61 #endif
62 
63 #ifdef __cplusplus
64 extern "C"
65 {
66 #endif
67 
68 /* constants */
70 #define GAIA_SQL_SINGLE_QUOTE 1001
71 
72 #define GAIA_SQL_DOUBLE_QUOTE 1002
73 
74 /* function prototypes */
75 
81  GAIAAUX_DECLARE const char *gaiaGetLocaleCharset (void);
82 
95  GAIAAUX_DECLARE int gaiaConvertCharset (char **buf, const char *fromCs,
96  const char *toCs);
97 
110  GAIAAUX_DECLARE void *gaiaCreateUTF8Converter (const char *fromCS);
111 
120  GAIAAUX_DECLARE void gaiaFreeUTF8Converter (void *cvtCS);
121 
140  GAIAAUX_DECLARE char *gaiaConvertToUTF8 (void *cvtCS, const char *buf,
141  int len, int *err);
142 
152  GAIAAUX_DECLARE int gaiaIsReservedSqliteName (const char *name);
153 
163  GAIAAUX_DECLARE int gaiaIsReservedSqlName (const char *name);
164 
174  GAIAAUX_DECLARE int gaiaIllegalSqlName (const char *name);
175 
190  GAIAAUX_DECLARE char *gaiaSingleQuotedSql (const char *value);
191 
206  GAIAAUX_DECLARE char *gaiaDoubleQuotedSql (const char *value);
207 
223  GAIAAUX_DECLARE char *gaiaQuotedSql (const char *value, int quote);
224 
239  GAIAAUX_DECLARE char *gaiaDequotedSql (const char *value);
240 
241 /*
242 / DEPRECATED FUNCTION: gaiaCleanSqlString()
243 / this function must not be used for any new project
244 / it's still maintained for backward compatibility,
245 / but will be probably removed in future versions
246 */
247 
260  GAIAAUX_DECLARE void gaiaCleanSqlString (char *value);
261 
277  GAIAAUX_DECLARE void gaiaInsertIntoSqlLog (sqlite3 * sqlite,
278  const char *user_agent,
279  const char *utf8Sql,
280  sqlite3_int64 * sqllog_pk);
281 
297  GAIAAUX_DECLARE void gaiaUpdateSqlLog (sqlite3 * sqlite,
298  sqlite3_int64 sqllog_pk,
299  int success, const char *errMsg);
300 
311  GAIAAUX_DECLARE void *gaiaCreateMD5Checksum (void);
312 
321  GAIAAUX_DECLARE void gaiaFreeMD5Checksum (void *md5);
322 
339  GAIAAUX_DECLARE void gaiaUpdateMD5Checksum (void *md5,
340  const unsigned char *blob,
341  int blob_len);
342 
361  GAIAAUX_DECLARE char *gaiaFinalizeMD5Checksum (void *md5);
362 
381  GAIAAUX_DECLARE int gaiaParseDMS (const char *dms, double *longitude,
382  double *latitude);
383 
401  GAIAAUX_DECLARE char *gaiaConvertToDMSex (double longitude, double latitude,
402  int decimal_digits);
403 
421  GAIAAUX_DECLARE char *gaiaConvertToDMS (double longitude, double latitude);
422 
438  GAIAAUX_DECLARE char *gaiaEncodeURL (const char *url,
439  const char *in_charset);
440 
456  GAIAAUX_DECLARE char *gaiaDecodeURL (const char *encoded,
457  const char *out_charset);
458 
473  GAIAAUX_DECLARE char *gaiaDirNameFromPath (const char *path);
474 
489  GAIAAUX_DECLARE char *gaiaFullFileNameFromPath (const char *path);
490 
505  GAIAAUX_DECLARE char *gaiaFileNameFromPath (const char *path);
506 
520  GAIAAUX_DECLARE char *gaiaFileExtFromPath (const char *path);
521 
534  GAIAAUX_DECLARE char *gaiaRemoveExtraSpaces (const char *string);
535 
536 #ifdef __cplusplus
537 }
538 #endif
539 
540 #endif /* _GAIAAUX_H */
GAIAAUX_DECLARE char * gaiaConvertToUTF8(void *cvtCS, const char *buf, int len, int *err)
Converts a text string to UTF8.
GAIAAUX_DECLARE void gaiaFreeMD5Checksum(void *md5)
Destroys an MD5 checksum object.
GAIAAUX_DECLARE int gaiaIsReservedSqliteName(const char *name)
Checks if a name is a reserved SQLite name.
GAIAAUX_DECLARE char * gaiaFinalizeMD5Checksum(void *md5)
Return an MD5 checksum value.
GAIAAUX_DECLARE const char * gaiaGetLocaleCharset(void)
Retrieves the Locale Charset.
GAIAAUX_DECLARE char * gaiaFileNameFromPath(const char *path)
Return the FileName from a Path.
GAIAAUX_DECLARE char * gaiaDirNameFromPath(const char *path)
Return the DirName component (if any) from a Path.
GAIAAUX_DECLARE void gaiaFreeUTF8Converter(void *cvtCS)
Destroys an UTF8 converter object.
GAIAAUX_DECLARE char * gaiaConvertToDMSex(double longitude, double latitude, int decimal_digits)
Return a DMS string - extended.
GAIAAUX_DECLARE char * gaiaSingleQuotedSql(const char *value)
Properly formats an SQL text constant.
GAIAAUX_DECLARE void * gaiaCreateMD5Checksum(void)
Creates a persistent MD5 checksum object.
GAIAAUX_DECLARE char * gaiaFullFileNameFromPath(const char *path)
Return the FullFileName from a Path.
GAIAAUX_DECLARE void gaiaUpdateMD5Checksum(void *md5, const unsigned char *blob, int blob_len)
Updates an MD5 checksum object.
GAIAAUX_DECLARE char * gaiaConvertToDMS(double longitude, double latitude)
Return a DMS string.
GAIAAUX_DECLARE char * gaiaFileExtFromPath(const char *path)
Return the FileExtension from a Path.
GAIAAUX_DECLARE int gaiaIllegalSqlName(const char *name)
Checks if a name is an illegal SQL name.
GAIAAUX_DECLARE void * gaiaCreateUTF8Converter(const char *fromCS)
Creates a persistent UTF8 converter object.
GAIAAUX_DECLARE char * gaiaDecodeURL(const char *encoded, const char *out_charset)
Return a clean URL from its percent-encoded representation.
GAIAAUX_DECLARE int gaiaIsReservedSqlName(const char *name)
Checks if a name is a reserved SQL name.
GAIAAUX_DECLARE void gaiaUpdateSqlLog(sqlite3 *sqlite, sqlite3_int64 sqllog_pk, int success, const char *errMsg)
SQL log: statement start.
GAIAAUX_DECLARE char * gaiaDequotedSql(const char *value)
Properly formats an SQL generic string (dequoting)
GAIAAUX_DECLARE int gaiaConvertCharset(char **buf, const char *fromCs, const char *toCs)
Converts a text string from one charset to another.
GAIAAUX_DECLARE char * gaiaEncodeURL(const char *url, const char *in_charset)
Return a percent-encoded URL.
GAIAAUX_DECLARE void gaiaCleanSqlString(char *value)
deprecated function
GAIAAUX_DECLARE char * gaiaDoubleQuotedSql(const char *value)
Properly formats an SQL name.
GAIAAUX_DECLARE char * gaiaRemoveExtraSpaces(const char *string)
Return a text string containing no repeated whitespaces.
GAIAAUX_DECLARE char * gaiaQuotedSql(const char *value, int quote)
Properly formats an SQL generic string.
GAIAAUX_DECLARE void gaiaInsertIntoSqlLog(sqlite3 *sqlite, const char *user_agent, const char *utf8Sql, sqlite3_int64 *sqllog_pk)
SQL log: statement start.
GAIAAUX_DECLARE int gaiaParseDMS(const char *dms, double *longitude, double *latitude)
Return longitude and latitude angles from a DMS string.