# Internal bcp functions
[Bulk copy functions]

Static functions internal to the bcp library. More...

## Functions

static int | _bcp_add_fixed_columns (DBPROCESS *dbproc, BEHAVIOUR behaviour, BYTE *rowbuffer, int start)
| Add fixed size columns to the row.
static int | _bcp_add_variable_columns (DBPROCESS *dbproc, BEHAVIOUR behaviour, BYTE *rowbuffer, int start, int *pncols)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static RETCODE | _bcp_build_bulk_insert_stmt (TDSSOCKET *tds, TDS_PBCB *clause, TDSCOLUMN *bcpcol, int first)

Parameters:

  | tds |

static RETCODE | _bcp_exec_in (DBPROCESS *dbproc, DBINT *rows_copied)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static RETCODE | _bcp_exec_out (DBPROCESS *dbproc, DBINT *rows_copied)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static char * | _bcp_fgets (char *buffer, size_t size, FILE *f)

Parameters:

  | buffer |

static void | _bcp_free_columns (DBPROCESS *dbproc)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static void | _bcp_free_storage (DBPROCESS *dbproc)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static RETCODE | _bcp_get_col_data (DBPROCESS *dbproc, TDSCOLUMN *bindcol)
| For a bcp in from program variables, get the data from the host variable.
static RETCODE | _bcp_get_term_var (BYTE *pdata, BYTE *term, int term_len)
| Get the data for bcp-in from program variables, where the program data have been identified as character terminated, This is a low-level, internal function.
static offset_type | _bcp_measure_terminated_field (FILE *hostfile, BYTE *terminator, int term_len)

Parameters:

  | hostfile |

static RETCODE | _bcp_read_hostfile (DBPROCESS *dbproc, FILE *hostfile, int *row_error)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static int | _bcp_readfmt_colinfo (DBPROCESS *dbproc, char *buf, BCP_HOSTCOLINFO *ci)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static RETCODE | _bcp_send_bcp_record (DBPROCESS *dbproc, BEHAVIOUR behaviour)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static RETCODE | _bcp_send_colmetadata (DBPROCESS *dbproc)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static RETCODE | _bcp_start_copy_in (DBPROCESS *dbproc)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static RETCODE | _bcp_start_new_batch (DBPROCESS *dbproc)

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

static int | rtrim (char *str, int len)
| trim a string of trailing blanks

## Detailed Description

Static functions internal to the bcp library.

## Function Documentation

static int _bcp_add_fixed_columns | ( | DBPROCESS * | dbproc,
|  | BEHAVIOUR | behaviour,
|  | BYTE * | rowbuffer,
|  | int | start |
| ) |  |  | `[static]`

Add fixed size columns to the row.

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.
  | behaviour |
  | rowbuffer |
  | start |

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static int _bcp_add_variable_columns | ( | DBPROCESS * | dbproc,
|  | BEHAVIOUR | behaviour,
|  | BYTE * | rowbuffer,
|  | int | start,
|  | int * | pncols |
| ) |  |  | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Parameters:

  | behaviour | Whether the data are already in the TDSCOLUMN or should by copied from the buffer bound by bcp_bind().
  | rowbuffer | The row image that will be sent to the server.
  | start | Where to begin copying data into the rowbuffer.
  | pncols | Address of output variable holding the count of columns added to the rowbuffer.

Returns:
  length of (potentially modified) rowbuffer, or FAIL.

See also:
  _bcp_send_bcp_record(), _bcp_get_col_data

static RETCODE _bcp_build_bulk_insert_stmt | ( | TDSSOCKET * | tds,
|  | TDS_PBCB * | clause,
|  | TDSCOLUMN * | bcpcol,
|  | int | first |
| ) |  |  | `[static]`

Parameters:

  | tds |

Parameters:

  | clause |
  | bcpcol |
  | first |

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static RETCODE _bcp_exec_in | ( | DBPROCESS * | dbproc,
|  | DBINT * | rows_copied |
| ) |  |  | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Parameters:

  | rows_copied |

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static RETCODE _bcp_exec_out | ( | DBPROCESS * | dbproc,
|  | DBINT * | rows_copied |
| ) |  |  | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Parameters:

  | rows_copied |

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static char* _bcp_fgets | ( | char * | buffer,
|  | size_t | size,
|  | FILE * | f |
| ) |  |  | `[static]`

Parameters:

  | buffer |

Parameters:

  | size |
  | f |

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static void _bcp_free_columns | ( | DBPROCESS * | dbproc | ) | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Returns:
  SUCCEED or FAIL.

static void _bcp_free_storage | ( | DBPROCESS * | dbproc | ) | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Returns:
  SUCCEED or FAIL.

See also:
  bcp_done(), bcp_exec(), bcp_init()

static RETCODE _bcp_get_col_data | ( | DBPROCESS * | dbproc,
|  | TDSCOLUMN * | bindcol |
| ) |  |  | `[static]`

For a bcp in from program variables, get the data from the host variable.

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.
  | bindcol |

Returns:
  SUCCEED or FAIL.

See also:
  _bcp_add_fixed_columns, _bcp_add_variable_columns, _bcp_send_bcp_record

static RETCODE _bcp_get_term_var | ( | BYTE * | pdata,
|  | BYTE * | term,
|  | int | term_len |
| ) |  |  | `[static]`

Get the data for bcp-in from program variables, where the program data have been identified as character terminated, This is a low-level, internal function.

Call it correctly.

Parameters:

  | pdata |
  | term |
  | term_len |

Returns:
  SUCCEED or FAIL.

static offset_type _bcp_measure_terminated_field | ( | FILE * | hostfile,
|  | BYTE * | terminator,
|  | int | term_len |
| ) |  |  | `[static]`

Parameters:

  | hostfile |

Parameters:

  | terminator |
  | term_len |

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static RETCODE _bcp_read_hostfile | ( | DBPROCESS * | dbproc,
|  | FILE * | hostfile,
|  | int * | row_error |
| ) |  |  | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Parameters:

  | hostfile |
  | row_error |

Returns:
  MORE_ROWS, NO_MORE_ROWS, or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static int _bcp_readfmt_colinfo | ( | DBPROCESS * | dbproc,
|  | char * | buf,
|  | BCP_HOSTCOLINFO * | ci |
| ) |  |  | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Parameters:

  | buf |
  | ci |

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static RETCODE _bcp_send_bcp_record | ( | DBPROCESS * | dbproc,
|  | BEHAVIOUR | behaviour |
| ) |  |  | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Parameters:

  | behaviour |

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static RETCODE _bcp_send_colmetadata | ( | DBPROCESS * | dbproc | ) | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static RETCODE _bcp_start_copy_in | ( | DBPROCESS * | dbproc | ) | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static RETCODE _bcp_start_new_batch | ( | DBPROCESS * | dbproc | ) | `[static]`

Parameters:

  | dbproc | contains all information needed by db-lib to manage communications with the server.

Returns:
  SUCCEED or FAIL.

See also:
  BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()

static int rtrim | ( | char * | str,
|  | int | len |
| ) |  |  | `[static]`

trim a string of trailing blanks

Replaces spaces at the end of a string with NULs

Parameters:

  | str | pointer to a character buffer (not null-terminated)
  | len | size of the str in bytes

Returns:
  modified length