FreeTDS API: include/freetds/convert.h Source File

FreeTDS API

convert.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2 * Copyright (C) 1998-1999 Brian Bruns
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20 #ifndef _tdsconvert_h_
21 #define _tdsconvert_h_
22
23 #include <freetds/pushvis.h>
24
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #if 0
29 }
30 #endif
31 #endif
32
33 typedef union conv_result
34 {
35 /* fixed */
36 TDS_TINYINT ti;
37 TDS_SMALLINT si;
38 TDS_USMALLINT usi;
39 TDS_INT i;
40 TDS_UINT ui;
41 TDS_INT8 bi;
42 TDS_UINT8 ubi;
43 TDS_FLOAT f;
44 TDS_REAL r;
45 TDS_MONEY m;
46 TDS_MONEY4 m4;
47 TDS_DATETIME dt;
48 TDS_DATETIME4 dt4;
49 TDS_DATETIMEALL dta;
50 TDS_TIME time;
51 TDS_DATE date;
52 TDS_BIGTIME bigtime;
53 TDS_BIGDATETIME bigdatetime;
54 TDS_NUMERIC n;
55 TDS_UNIQUE u;
56
57 /* variable */
58 TDS_CHAR *c;
59 TDS_CHAR *ib;
60
61 /* sized buffer types */
62 struct cc_t {
63 TDS_CHAR *c;
64 TDS_UINT len;
65 } cc;
66 struct cb_t {
67 TDS_CHAR *ib;
68 TDS_UINT len;
69 } cb;
70 }
71 CONV_RESULT;
72
73 /*
74 * Failure return codes for tds_convert()
75 */
76 #define TDS_CONVERT_FAIL -1 /* unspecified failure */
77 #define TDS_CONVERT_NOAVAIL -2 /* conversion does not exist */
78 #define TDS_CONVERT_SYNTAX -3 /* syntax error in source field */
79 #define TDS_CONVERT_NOMEM -4 /* insufficient memory */
80 #define TDS_CONVERT_OVERFLOW -5 /* result too large */
81
82 /* sized types */
83 #define TDS_CONVERT_CHAR 256
84 #define TDS_CONVERT_BINARY 257
85
86 unsigned char tds_willconvert(int srctype, int desttype);
87
88 TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype);
89 TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen);
90 TDS_INT tds_convert(const TDSCONTEXT *context, int srctype, const void *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr);
91
92 size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr, int prec);
93
94 #ifdef __cplusplus
95 #if 0
96 {
97 #endif
98 }
99 #endif
100
101 #include <freetds/popvis.h>
102
103 #endif /* _tdsconvert_h_ */
tdsmoney
Definition: proto.h:39
TDS_DATETIMEALL
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.
Definition: tds.h:147
tdsmoney4
Definition: proto.h:45
conv_result::cc_t
Definition: convert.h:62
tds_willconvert
unsigned char tds_willconvert(int srctype, int desttype)
Test if a conversion is possible.
Definition: convert.c:3058
tds_context
Definition: tds.h:1030
tds_strftime
size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *timeptr, int prec)
format a date string according to an "extended" strftime(3) formatting definition.
Definition: convert.c:2970
tdsdatetime4
Definition: proto.h:56
tds_convert
TDS_INT tds_convert(const TDSCONTEXT *context, int srctype, const void *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
tds_convert convert a type to another.
Definition: convert.c:1878
tds_get_null_type
TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype)
Get same type but nullable.
Definition: convert.c:2915
conv_result
Definition: convert.h:34
tdsdatetime
Definition: proto.h:50
conv_result::cb_t
Definition: convert.h:66
tdsdaterec
Used by tds_datecrack.
Definition: tds.h:160
tdsnumeric
Definition: proto.h:26
tdsunique
Definition: proto.h:62