FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Macros | Functions
token.c File Reference

Contains all routines to get replies from server. More...

#include <config.h>
#include <assert.h>
#include <freetds/tds.h>
#include <freetds/utils/string.h>
#include <freetds/convert.h>
#include <freetds/iconv.h>
#include <freetds/checks.h>
#include <freetds/bytes.h>
#include <freetds/alloca.h>
#include "replacements.h"
Include dependency graph for token.c:

Classes

struct  namelist
 Holds list of names. More...
 

Macros

#define GET_STRING(dest, len_type)
 
#define SET_RETURN(ret, f)
 
#define TDS_GET_COLUMN_INFO(tds, col)   TDS_PROPAGATE(col->funcs->get_info(tds, col))
 
#define TDS_GET_COLUMN_TYPE(col)
 
#define TYPE(con, s)   case con: return s; break
 
#define TYPE(con, s)   case con: return s; break
 
#define USE_ICONV   (tds->conn->use_iconv)
 

Functions

static void adjust_character_column_size (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Adjust column size according to client's encoding. More...
 
int determine_adjusted_size (const TDSICONV *char_conv, int size)
 Allow for maximum possible size of converted data, while being careful about integer division truncation. More...
 
static TDSRET tds5_process_dyn_result2 (TDSSOCKET *tds)
 Process new TDS 5.0 token for describing output parameters. More...
 
static TDSRET tds5_process_optioncmd (TDSSOCKET *tds)
 Process option cmd results. More...
 
static TDSRET tds5_process_result (TDSSOCKET *tds)
 tds5_process_result() is the TDS 5.0 result set processing routine. More...
 
static TDSRET tds5_process_result2 (TDSSOCKET *tds)
 tds5_process_result2() is the new TDS 5.0 result set processing routine. More...
 
static int tds71_read_table_names (TDSSOCKET *tds, int remainder, struct namelist **p_head)
 Reads table names for TDS 7.1+. More...
 
static TDSRET tds7_get_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Reads data information from wire. More...
 
static TDSRET tds7_process_compute_result (TDSSOCKET *tds)
 tds7_process_compute_result() processes compute result sets for TDS 7/8. More...
 
static TDSRET tds7_process_result (TDSSOCKET *tds)
 tds7_process_result() is the TDS 7.0 result set processing routine. More...
 
static int tds_alloc_get_string (TDSSOCKET *tds, char **string, size_t len)
 Reads a string from wire in a new allocated buffer. More...
 
static void tds_free_namelist (struct namelist *head)
 Frees list of names. More...
 
static TDSRET tds_get_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol, int is_param)
 Reads data metadata from wire. More...
 
int tds_get_token_size (int marker)
 tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determine how to read past a token More...
 
TDSDYNAMICtds_lookup_dynamic (TDSCONNECTION *conn, const char *id)
 Finds a dynamic given string id. More...
 
static const char * tds_pr_op (int op)
 Returns string representation for a given operation. More...
 
static TDSRET tds_process_auth (TDSSOCKET *tds)
 Process authentication token. More...
 
TDSRET tds_process_cancel (TDSSOCKET *tds)
 
static TDSRET tds_process_col_fmt (TDSSOCKET *tds)
 tds_process_col_fmt() is the other half of result set processing under TDS 4.2. More...
 
static TDSRET tds_process_col_name (TDSSOCKET *tds)
 tds_process_col_name() is one half of the result set under TDS 4.2 it contains all the column names, a TDS_COLFMT_TOKEN should immediately follow this token with the datatype/size information This is a 4.2 only function More...
 
static TDSRET tds_process_colinfo (TDSSOCKET *tds, char **names, int num_names)
 Reads column information. More...
 
static TDSRET tds_process_compute (TDSSOCKET *tds)
 tds_process_compute() processes compute rows and places them in the row buffer. More...
 
static TDSRET tds_process_compute_names (TDSSOCKET *tds)
 tds_process_compute_names() processes compute result sets. More...
 
static TDSRET tds_process_compute_result (TDSSOCKET *tds)
 tds_process_compute_result() processes compute result sets. More...
 
static TDSRET tds_process_cursor_tokens (TDSSOCKET *tds)
 Reads cursor command results. More...
 
static TDSRET tds_process_default_tokens (TDSSOCKET *tds, int marker)
 tds_process_default_tokens() is a catch all function that is called to process tokens not known to other tds_process_* routines More...
 
static TDSRET tds_process_dyn_result (TDSSOCKET *tds)
 Process results from dynamic. More...
 
static TDSDYNAMICtds_process_dynamic (TDSSOCKET *tds)
 tds_process_dynamic() finds the element of the dyns array for the id More...
 
static TDSRET tds_process_end (TDSSOCKET *tds, int marker, int *flags_parm)
 tds_process_end() processes any of the DONE, DONEPROC, or DONEINPROC tokens. More...
 
static TDSRET tds_process_env_chg (TDSSOCKET *tds)
 tds_process_env_chg() when ever certain things change on the server, such as database, character set, language, or block size. More...
 
static TDSRET tds_process_env_routing (TDSSOCKET *tds)
 
static TDSRET tds_process_featureextack (TDSSOCKET *tds)
 
static TDSRET tds_process_info (TDSSOCKET *tds, int marker)
 tds_process_info() is called for INFO, ERR, or EED tokens and is responsible for calling the CLI's message handling routine More...
 
TDSRET tds_process_login_tokens (TDSSOCKET *tds)
 tds_process_login_tokens() is called after sending the login packet to the server. More...
 
static TDSRET tds_process_loginack (TDSSOCKET *tds, TDSRET *login_succeeded)
 
static TDSRET tds_process_nbcrow (TDSSOCKET *tds)
 tds_process_nbcrow() processes rows and places them in the row buffer.
 
static TDSRET tds_process_param_result (TDSSOCKET *tds, TDSPARAMINFO **pinfo)
 process output parameters of a stored procedure. More...
 
static TDSRET tds_process_param_result_tokens (TDSSOCKET *tds)
 Process parameters from networks. More...
 
static TDSRET tds_process_params_result_token (TDSSOCKET *tds)
 tds_process_params_result_token() processes params on TDS5. More...
 
static void tds_process_pending_closes (TDSSOCKET *tds)
 Attempt to close all deferred closes (dynamics and cursors). More...
 
static TDSRET tds_process_row (TDSSOCKET *tds)
 tds_process_row() processes rows and places them in the row buffer. More...
 
TDSRET tds_process_simple_query (TDSSOCKET *tds)
 Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results, beware they are discarded. More...
 
static TDSRET tds_process_tabname (TDSSOCKET *tds)
 Process list of table from network. More...
 
TDSRET tds_process_tokens (TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
 process all streams. More...
 
const char * tds_prtype (int type)
 Returns string representation of the given type. More...
 
static int tds_read_namelist (TDSSOCKET *tds, int remainder, struct namelist **p_head, int large)
 Reads list of names (usually table names) More...
 
static const char * tds_token_name (unsigned char marker)
 Returns string representation for a given token type. More...
 

Detailed Description

Contains all routines to get replies from server.

Macro Definition Documentation

#define GET_STRING (   dest,
  len_type 
)
Value:
do { \
unsigned int to_read_size = tds_get_ ## len_type(tds); \
char_len += to_read_size; \
rc += tds_alloc_get_string(tds, dest, to_read_size); \
} while(0)
#define SET_RETURN (   ret,
 
)
Value:
do { \
*result_type = ret; \
return_flag = TDS_RETURN_##f | TDS_STOPAT_##f; \
if (flag & TDS_STOPAT_##f) {\
tds_unget_byte(tds); \
tdsdump_log(TDS_DBG_FUNC, "tds_process_tokens::SET_RETURN stopping on current token\n"); \
goto set_return_exit; \
} } while(0)
#define TDS_GET_COLUMN_TYPE (   col)
Value:
do { \
TDS_TINYINT _tds_type = tds_get_byte(tds); \
if (!is_tds_type_valid(_tds_type)) \
return TDS_FAIL; \
tds_set_column_type(tds->conn, col, (TDS_SERVER_TYPE) _tds_type); \
} while(0)