1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _tdsstring_h_
#define _tdsstring_h_
/* $Id: tdsstring.h,v 1.21 2010/01/25 23:05:59 freddy77 Exp $ */
#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
#pragma GCC visibility push(hidden)
#endif
extern const char tds_str_empty[1];
/* TODO do some function and use inline if available */
/** \addtogroup dstring
* @{
*/
#if ENABLE_EXTRA_CHECKS
void tds_dstr_init(DSTR * s);
int tds_dstr_isempty(DSTR * s);
char *tds_dstr_buf(DSTR * s);
size_t tds_dstr_len(DSTR * s);
#else
/** init a string with empty */
#define tds_dstr_init(s) \
do { DSTR *_tds_s = (s); _tds_s->dstr_size = 0; _tds_s->dstr_s = (char*) tds_str_empty; } while(0)
/** test if string is empty */
#define tds_dstr_isempty(s) \
((s)->dstr_size == 0)
#define tds_dstr_buf(s) \
((s)->dstr_s)
#define tds_dstr_len(s) \
((s)->dstr_size)
#endif
#define tds_dstr_cstr(s) \
((const char* ) tds_dstr_buf(s))
void tds_dstr_zero(DSTR * s);
void tds_dstr_free(DSTR * s);
DSTR* tds_dstr_dup(DSTR * s, const DSTR * src);
DSTR* tds_dstr_copy(DSTR * s, const char *src);
DSTR* tds_dstr_copyn(DSTR * s, const char *src, size_t length);
DSTR* tds_dstr_set(DSTR * s, char *src);
/** limit length of string, MUST be <= current length */
DSTR* tds_dstr_setlen(DSTR *s, size_t length);
/** allocate space for length char */
DSTR* tds_dstr_alloc(DSTR *s, size_t length);
/** @} */
#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
#pragma GCC visibility pop
#endif
#endif /* _tdsstring_h_ */
|