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

FreeTDS API

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 /* $Id: tdsconvert.h,v 1.29 2011-08-08 12:33:18 freddy77 Exp $ */
34
35 typedef union conv_result
36 {
37 /* fixed */
38 TDS_TINYINT ti;
39 TDS_SMALLINT si;
40 TDS_USMALLINT usi;
41 TDS_INT i;
42 TDS_UINT ui;
43 TDS_INT8 bi;
44 TDS_UINT8 ubi;
45 TDS_FLOAT f;
46 TDS_REAL r;
47 TDS_MONEY m;
48 TDS_MONEY4 m4;
49 TDS_DATETIME dt;
50 TDS_DATETIME4 dt4;
51 TDS_DATETIMEALL dta;
52 TDS_NUMERIC n;
53 TDS_UNIQUE u;
54
55 /* variable */
56 TDS_CHAR *c;
57 TDS_CHAR *ib;
58
59 /* sized buffer types */
60 struct cc_t {
61 TDS_CHAR *c;
62 TDS_UINT len;
63 } cc;
64 struct cb_t {
65 TDS_CHAR *ib;
66 TDS_UINT len;
67 } cb;
68 }
69 CONV_RESULT;
70
71 /*
72 * Failure return codes for tds_convert()
73 */
74 #define TDS_CONVERT_FAIL -1 /* unspecified failure */
75 #define TDS_CONVERT_NOAVAIL -2 /* conversion does not exist */
76 #define TDS_CONVERT_SYNTAX -3 /* syntax error in source field */
77 #define TDS_CONVERT_NOMEM -4 /* insufficient memory */
78 #define TDS_CONVERT_OVERFLOW -5 /* result too large */
79
80 /* sized types */
81 #define TDS_CONVERT_CHAR 256
82 #define TDS_CONVERT_BINARY 257
83
84 unsigned char tds_willconvert(int srctype, int desttype);
85
86 TDS_INT tds_get_null_type(int srctype);
87 TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen);
88 TDS_INT tds_convert(const TDSCONTEXT * context, int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr);
89
90 size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr, int prec);
91
92 #ifdef __cplusplus
93 #if 0
94 {
95 #endif
96 }
97 #endif
98
99 #include <freetds/popvis.h>
100
101 #endif /* _tdsconvert_h_ */
tdsdatetime4
Definition: proto.h:55
tdsnumeric
Definition: proto.h:25
tdsmoney
Definition: proto.h:38
tds_convert
TDS_INT tds_convert(const TDSCONTEXT *context, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
tds_convert convert a type to another.
Definition: convert.c:1794
tdsmoney4
Definition: proto.h:44
tds_context
Definition: tds.h:996
TDS_DATETIMEALL
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information...
Definition: tds.h:141
tdsdatetime
Definition: proto.h:49
conv_result::cc_t
Definition: convert.h:60
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:2907
tdsunique
Definition: proto.h:61
tdsdaterec
Used by tds_datecrack.
Definition: tds.h:154
tds_willconvert
unsigned char tds_willconvert(int srctype, int desttype)
Test if a conversion is possible.
Definition: convert.c:2988
tds_get_null_type
TDS_INT tds_get_null_type(int srctype)
Get same type but nullable.
Definition: convert.c:2859
conv_result
Definition: convert.h:35
conv_result::cb_t
Definition: convert.h:64