NCBI C++ ToolKit
Classes | Macros | Typedefs | Functions | Variables
convert.c File Reference
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <freetds/time.h>
#include <assert.h>
#include <ctype.h>
#include <freetds/tds.h>
#include <freetds/convert.h>
#include <freetds/bytes.h>
#include "replacements.h"
#include "tds_willconvert.h"
+ Include dependency graph for convert.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  tds_time
 

Macros

#define test_alloc(x)   {if ((x)==NULL) return TDS_CONVERT_NOMEM;}
 
#define IS_TINYINT(x)   ( 0 <= (x) && (x) <= 0xff )
 
#define IS_SMALLINT(x)   ( -32768 <= (x) && (x) <= 32767 )
 
#define IS_USMALLINT(x)   ( 0 <= (x) && (x) <= 65535 )
 
#define TDS_INT_MIN   (-2147483647l-1l)
 
#define TDS_INT_MAX   2147483647l
 
#define IS_INT(x)   (TDS_INT_MIN <= (x) && (x) <= TDS_INT_MAX)
 
#define TDS_UINT_MAX   4294967295lu
 
#define IS_UINT(x)   (0 <= (x) && (x) <= TDS_UINT_MAX)
 
#define TDS_INT8_MAX   ((((TDS_INT8) 0x7fffffffl) << 32) + (TDS_INT8) 0xfffffffflu)
 
#define TDS_INT8_MIN   (-TDS_INT8_MAX - (TDS_INT8) 1)
 
#define IS_INT8(x)   (TDS_INT8_MIN <= (x) && (x) <= TDS_INT8_MAX)
 
#define TDS_UINT8_MAX   ((((TDS_UINT8) 0xfffffffflu) << 32) + 0xfffffffflu)
 
#define IS_UINT8(x)   (0 <= (x) && (x) <= TDS_UINT8_MAX)
 
#define TDS_ISDIGIT(c)   ((c) >= '0' && (c) <= '9')
 
#define BIGDATETIME_BIAS   693961
 
#define is_monthname(s)   (store_monthname(s, NULL) >= 0)
 
#define string_to_result(s, cr)    string_to_result_(desttype, s, cr)
 
#define CASE_ALL_CHAR
 
#define CASE_ALL_BINARY
 
#define SKIP_IF(cond)   while (p != pend && (cond)) ++p;
 

Typedefs

typedef unsigned short utf16_t
 

Functions

static TDS_INT tds_convert_int (TDS_INT num, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_int1 (const TDS_TINYINT *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_int2 (const TDS_SMALLINT *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_uint2 (const TDS_USMALLINT *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_int4 (const TDS_INT *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_uint4 (const TDS_UINT *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_int8 (const TDS_INT8 *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_uint8 (const TDS_UINT8 *src, int desttype, CONV_RESULT *cr)
 
static int string_to_datetime (const char *datestr, TDS_UINT len, int desttype, CONV_RESULT *cr)
 
static bool is_dd_mon_yyyy (char *t)
 
static int store_dd_mon_yyy_date (char *datestr, struct tds_time *t)
 
static const char * parse_numeric (const char *buf, const char *pend, bool *p_negative, size_t *p_digits, size_t *p_decimals)
 Parse a string for numbers. More...
 
static int string_to_numeric (const char *instr, const char *pend, CONV_RESULT *cr)
 convert a number in string to a TDSNUMERIC More...
 
static int stringz_to_numeric (const char *instr, CONV_RESULT *cr)
 convert a zero terminated string to NUMERIC More...
 
static TDS_INT string_to_int (const char *buf, const char *pend, TDS_INT *res)
 convert a number in string to TDS_INT More...
 
static TDS_INT string_to_int8 (const char *buf, const char *pend, TDS_INT8 *res)
 convert a number in string to TDS_INT8 More...
 
static TDS_INT string_to_uint8 (const char *buf, const char *pend, TDS_UINT8 *res)
 convert a number in string to TDS_UINT8 More...
 
static TDS_INT string_to_float (const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
 
static int store_hour (const char *, const char *, struct tds_time *)
 
static int store_time (const char *, struct tds_time *)
 
static int store_yymmdd_date (const char *, struct tds_time *)
 
static int store_monthname (const char *datestr, struct tds_time *t)
 Test if a string is a month name and store correct month number. More...
 
static int store_numeric_date (const char *, struct tds_time *)
 
static int store_mday (const char *, struct tds_time *)
 
static int store_year (int, struct tds_time *)
 
static bool is_timeformat (const char *)
 
static bool is_numeric (const char *)
 
static bool is_alphabetic (const char *)
 
static bool is_ampm (const char *)
 
static bool is_numeric_dateformat (const char *)
 
static TDS_INT string_to_result_ (int desttype, const char *s, CONV_RESULT *cr)
 Copy a terminated string to result and return len or TDS_CONVERT_NOMEM. More...
 
static TDS_INT binary_to_result (int desttype, const void *data, size_t len, CONV_RESULT *cr)
 Copy binary data to to result and return len or TDS_CONVERT_NOMEM. More...
 
static TDS_INT tds_convert_binary (const TDS_UCHAR *src, TDS_INT srclen, int desttype, CONV_RESULT *cr)
 
ssize_t tds_char2hex (TDS_CHAR *dest, size_t destlen, const TDS_CHAR *src, size_t srclen)
 
static TDS_INT tds_convert_char (const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_bit (const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_int_numeric (unsigned char scale, unsigned char sign, TDS_UINT num, CONV_RESULT *cr)
 
static TDS_INT tds_convert_int8_numeric (unsigned char scale, unsigned char sign, TDS_UINT8 num, CONV_RESULT *cr)
 
static TDS_INT tds_convert_numeric (const TDS_NUMERIC *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_money4 (const TDS_MONEY4 *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_money (const TDS_MONEY *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_datetimeall (const TDSCONTEXT *tds_ctx, int srctype, const TDS_DATETIMEALL *dta, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_datetime (const TDSCONTEXT *tds_ctx, const TDS_DATETIME *dt, int desttype, unsigned precision, CONV_RESULT *cr)
 
static TDS_INT tds_convert_datetime4 (const TDSCONTEXT *tds_ctx, const TDS_DATETIME4 *dt4, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_time (const TDSCONTEXT *tds_ctx, const TDS_TIME *time, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_date (const TDSCONTEXT *tds_ctx, const TDS_DATE *date, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_bigtime (const TDSCONTEXT *tds_ctx, const TDS_BIGTIME *bigtime, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_bigdatetime (const TDSCONTEXT *tds_ctx, const TDS_BIGDATETIME *bigdatetime, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_real (const TDS_REAL *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_flt8 (const TDS_FLOAT *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_unique (const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
 
static TDS_INT tds_convert_to_binary (int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
 
TDS_INT tds_convert (const TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
 tds_convert convert a type to another. More...
 
TDS_SERVER_TYPE tds_get_null_type (TDS_SERVER_TYPE srctype)
 Get same type but nullable. More...
 
size_t tds_strftime (char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr, int prec)
 format a date string according to an "extended" strftime(3) formatting definition. More...
 
unsigned char tds_willconvert (int srctype, int desttype)
 Test if a conversion is possible. More...
 
TDSRET tds_datecrack (TDS_INT datetype, const void *di, TDSDATEREC *dr)
 Convert from db date format to a structured date format. More...
 
static TDS_INT parse_int8 (const char *buf, const char *pend, TDS_UINT8 *res, bool *p_negative)
 convert a number in string to TDS_INT8 More...
 

Variables

const char tds_hex_digits [] = "0123456789abcdef"
 

Macro Definition Documentation

◆ BIGDATETIME_BIAS

#define BIGDATETIME_BIAS   693961

Definition at line 104 of file convert.c.

◆ IS_INT

#define IS_INT (   x)    (TDS_INT_MIN <= (x) && (x) <= TDS_INT_MAX)

Definition at line 90 of file convert.c.

◆ IS_INT8

#define IS_INT8 (   x)    (TDS_INT8_MIN <= (x) && (x) <= TDS_INT8_MAX)

Definition at line 97 of file convert.c.

◆ IS_SMALLINT

#define IS_SMALLINT (   x)    ( -32768 <= (x) && (x) <= 32767 )

Definition at line 82 of file convert.c.

◆ IS_TINYINT

#define IS_TINYINT (   x)    ( 0 <= (x) && (x) <= 0xff )

Definition at line 81 of file convert.c.

◆ IS_UINT

#define IS_UINT (   x)    (0 <= (x) && (x) <= TDS_UINT_MAX)

Definition at line 93 of file convert.c.

◆ IS_UINT8

#define IS_UINT8 (   x)    (0 <= (x) && (x) <= TDS_UINT8_MAX)

Definition at line 100 of file convert.c.

◆ IS_USMALLINT

#define IS_USMALLINT (   x)    ( 0 <= (x) && (x) <= 65535 )

Definition at line 83 of file convert.c.

◆ SKIP_IF

#define SKIP_IF (   cond)    while (p != pend && (cond)) ++p;

◆ TDS_INT8_MAX

#define TDS_INT8_MAX   ((((TDS_INT8) 0x7fffffffl) << 32) + (TDS_INT8) 0xfffffffflu)

Definition at line 95 of file convert.c.

◆ TDS_INT8_MIN

#define TDS_INT8_MIN   (-TDS_INT8_MAX - (TDS_INT8) 1)

Definition at line 96 of file convert.c.

◆ TDS_INT_MAX

#define TDS_INT_MAX   2147483647l

Definition at line 89 of file convert.c.

◆ TDS_INT_MIN

#define TDS_INT_MIN   (-2147483647l-1l)

Definition at line 88 of file convert.c.

◆ TDS_ISDIGIT

#define TDS_ISDIGIT (   c)    ((c) >= '0' && (c) <= '9')

Definition at line 102 of file convert.c.

◆ TDS_UINT8_MAX

#define TDS_UINT8_MAX   ((((TDS_UINT8) 0xfffffffflu) << 32) + 0xfffffffflu)

Definition at line 99 of file convert.c.

◆ TDS_UINT_MAX

#define TDS_UINT_MAX   4294967295lu

Definition at line 92 of file convert.c.

◆ test_alloc

#define test_alloc (   x)    {if ((x)==NULL) return TDS_CONVERT_NOMEM;}

Definition at line 79 of file convert.c.

Typedef Documentation

◆ utf16_t

typedef unsigned short utf16_t

Definition at line 52 of file convert.c.

Modified on Mon Jun 24 05:23:25 2024 by modify_doxy.py rev. 669887