NCBI C++ ToolKit
Classes | Macros | Typedefs | Enumerations | Functions | Variables
describecol.c File Reference
#include "common.h"
#include <ctype.h>
#include "parser.h"
#include <odbcss.h>
#include <freetds/bool.h>
#include <freetds/test_assert.h>
+ Include dependency graph for describecol.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  lookup_int
 
struct  attribute
 

Macros

#define TYPE(s)   { #s, s }
 
#define ATTR(s, t)   { #s, s, type_##t, NULL }
 
#define ATTR2(s, t, l)   { #s, s, type_##t, l }
 
#define ATTR_PARAMS   const struct attribute *attr, const char *expected_values[]
 
#define TEST_FILE   "describecol.in"
 

Typedefs

typedef void(* check_attr_t) (const struct attribute *attr, const char *expected_values[])
 

Enumerations

enum  test_type_t {
  type_INTEGER , type_UINTEGER , type_SMALLINT , type_LEN ,
  type_CHARP , type_DESC , type_VOIDP , type_INTEGER ,
  type_SMALLINT , type_LEN , type_CHARP , type_INTEGER ,
  type_UINTEGER , type_SMALLINT , type_LEN , type_CHARP ,
  type_DESC , type_VOIDP , type_INTEGER , type_SMALLINT ,
  type_LEN , type_CHARP
}
 

Functions

static int get_int (const char *s)
 
static int lookup (const char *name, const struct lookup_int *table)
 
static const char * unlookup (SQLINTEGER value, const struct lookup_int *table)
 
static const struct attributelookup_attr (const char *name)
 
static bool is_contained (const char *s, const char *list[])
 
static bool is_contained_lookup (SQLINTEGER i, const char *list[], const struct lookup_int *table)
 
static void print_values (FILE *f, const char *list[])
 
static void check_attr_ird (const struct attribute *attr, const char *expected_values[])
 
static void check_attr_ard (const struct attribute *attr, const char *expected_values[])
 
static void check_attr_none (const struct attribute *attr, const char *expected_values[])
 
int main (int argc, char *argv[])
 

Variables

static int g_result = 0
 
static struct lookup_int sql_types []
 
static struct lookup_int sql_bools []
 
static const struct attribute attributes []
 

Macro Definition Documentation

◆ ATTR

#define ATTR (   s,
  t 
)    { #s, s, type_##t, NULL }

◆ ATTR2

#define ATTR2 (   s,
  t,
  l 
)    { #s, s, type_##t, l }

◆ ATTR_PARAMS

#define ATTR_PARAMS   const struct attribute *attr, const char *expected_values[]

Definition at line 159 of file describecol.c.

◆ TEST_FILE

#define TEST_FILE   "describecol.in"

◆ TYPE

#define TYPE (   s)    { #s, s }

Typedef Documentation

◆ check_attr_t

typedef void(* check_attr_t) (const struct attribute *attr, const char *expected_values[])

Definition at line 160 of file describecol.c.

Enumeration Type Documentation

◆ test_type_t

Enumerator
type_INTEGER 
type_UINTEGER 
type_SMALLINT 
type_LEN 
type_CHARP 
type_DESC 
type_VOIDP 
type_INTEGER 
type_SMALLINT 
type_LEN 
type_CHARP 
type_INTEGER 
type_UINTEGER 
type_SMALLINT 
type_LEN 
type_CHARP 
type_DESC 
type_VOIDP 
type_INTEGER 
type_SMALLINT 
type_LEN 
type_CHARP 

Definition at line 110 of file describecol.c.

Function Documentation

◆ check_attr_ard()

static void check_attr_ard ( const struct attribute attr,
const char *  expected_values[] 
)
static

◆ check_attr_ird()

static void check_attr_ird ( const struct attribute attr,
const char *  expected_values[] 
)
static

◆ check_attr_none()

static void check_attr_none ( const struct attribute attr,
const char *  expected_values[] 
)
static

Definition at line 290 of file describecol.c.

Referenced by main().

◆ get_int()

static int get_int ( const char *  s)
static

Definition at line 17 of file describecol.c.

References l(), and odbc_fatal().

Referenced by lookup(), and main().

◆ is_contained()

static bool is_contained ( const char *  s,
const char *  list[] 
)
static

Definition at line 163 of file describecol.c.

References util::strcmp().

Referenced by check_attr_ard(), and check_attr_ird().

◆ is_contained_lookup()

static bool is_contained_lookup ( SQLINTEGER  i,
const char *  list[],
const struct lookup_int table 
)
static

Definition at line 173 of file describecol.c.

References i, lookup(), and table.

Referenced by check_attr_ard(), and check_attr_ird().

◆ lookup()

static int lookup ( const char *  name,
const struct lookup_int table 
)
static

Definition at line 37 of file describecol.c.

References get_int(), util::strcmp(), and table.

Referenced by is_contained_lookup(), and main().

◆ lookup_attr()

static const struct attribute* lookup_attr ( const char *  name)
static

Definition at line 146 of file describecol.c.

References attributes, i, attribute::name, NULL, odbc_fatal(), util::strcmp(), and TDS_VECTOR_SIZE.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ print_values()

static void print_values ( FILE *  f,
const char *  list[] 
)
static

Definition at line 183 of file describecol.c.

References f.

Referenced by check_attr_ard(), and check_attr_ird().

◆ unlookup()

static const char* unlookup ( SQLINTEGER  value,
const struct lookup_int table 
)
static

Definition at line 50 of file describecol.c.

References buf, table, and rapidjson::value.

Referenced by check_attr_ard(), and check_attr_ird().

Variable Documentation

◆ attributes

const struct attribute attributes[]
static
Initial value:
= {
#define ATTR(s,t)
#define ATTR2(s,t,l)
{ "SQL_COLUMN_LENGTH", SQL_COLUMN_LENGTH , type_INTEGER , NULL },
{ "SQL_COLUMN_PRECISION", SQL_COLUMN_PRECISION , type_INTEGER , NULL },
{ "SQL_COLUMN_SCALE", SQL_COLUMN_SCALE , type_INTEGER , NULL },
{ "SQL_DESC_LENGTH", SQL_DESC_LENGTH , type_LEN , NULL },
{ "SQL_DESC_OCTET_LENGTH", SQL_DESC_OCTET_LENGTH , type_LEN , NULL },
{ "SQL_DESC_PRECISION", SQL_DESC_PRECISION , type_SMALLINT , NULL },
{ "SQL_DESC_SCALE", SQL_DESC_SCALE , type_SMALLINT , NULL },
{ "SQL_DESC_DISPLAY_SIZE", SQL_DESC_DISPLAY_SIZE , type_INTEGER , NULL },
{ "SQL_DESC_TYPE_NAME", SQL_DESC_TYPE_NAME , type_CHARP , NULL },
{ "SQL_DESC_CONCISE_TYPE", SQL_DESC_CONCISE_TYPE , type_SMALLINT , sql_types },
{ "SQL_DESC_TYPE", SQL_DESC_TYPE , type_SMALLINT , sql_types },
{ "SQL_DESC_UNSIGNED", SQL_DESC_UNSIGNED , type_SMALLINT , sql_bools }
}
@ type_CHARP
Definition: describecol.c:114
@ type_LEN
Definition: describecol.c:113
@ type_INTEGER
Definition: describecol.c:111
@ type_SMALLINT
Definition: describecol.c:112
static struct lookup_int sql_types[]
Definition: describecol.c:66
static struct lookup_int sql_bools[]
Definition: describecol.c:104
#define NULL
Definition: ncbistd.hpp:225
#define SQL_DESC_TYPE
Definition: sql.h:100
#define SQL_DESC_PRECISION
Definition: sql.h:103
#define SQL_DESC_LENGTH
Definition: sql.h:101
#define SQL_DESC_SCALE
Definition: sql.h:104
#define SQL_DESC_OCTET_LENGTH
Definition: sql.h:111
#define SQL_DESC_TYPE_NAME
Definition: sqlext.h:411
#define SQL_DESC_DISPLAY_SIZE
Definition: sqlext.h:395
#define SQL_COLUMN_SCALE
Definition: sqlext.h:635
#define SQL_DESC_CONCISE_TYPE
Definition: sqlext.h:393
#define SQL_COLUMN_PRECISION
Definition: sqlext.h:634
#define SQL_COLUMN_LENGTH
Definition: sqlext.h:633
#define SQL_DESC_UNSIGNED
Definition: sqlext.h:413

Definition at line 50 of file describecol.c.

Referenced by lookup_attr().

◆ g_result

int g_result = 0
static

Definition at line 14 of file describecol.c.

Referenced by check_attr_ard(), check_attr_ird(), and main().

◆ sql_bools

struct lookup_int sql_bools[]
static
Initial value:
= {
{ "SQL_TRUE", SQL_TRUE },
{ "SQL_FALSE", SQL_FALSE },
{ NULL, 0 }
}
#define SQL_TRUE
Definition: sql.h:219
#define SQL_FALSE
Definition: sql.h:218

Definition at line 50 of file describecol.c.

◆ sql_types

struct lookup_int sql_types[]
static

Definition at line 50 of file describecol.c.

Modified on Fri Sep 20 14:56:57 2024 by modify_doxy.py rev. 669887