Loading...
Searching...
No Matches
string.h
/* 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 _tdsguard_d2McTbRS3vmVcq0ls4BzwH_
#define _tdsguard_d2McTbRS3vmVcq0ls4BzwH_
#include <freetds/macros.h>
#include <freetds/pushvis.h>
typedef struct tds_dstr {
size_t dstr_size;
char dstr_s[1];
} *DSTR;
extern const struct tds_dstr tds_str_empty;
#define DSTR_INITIALIZER ((struct tds_dstr*) &tds_str_empty)
static inline void
tds_dstr_init(DSTR * s)
{
*(s) = DSTR_INITIALIZER;
}
static inline int
tds_dstr_isempty(const DSTR * s)
{
return (*s)->dstr_size == 0;
}
static inline char *
tds_dstr_buf(DSTR * s)
{
return (*s)->dstr_s;
}
static inline const char *
tds_dstr_cstr(const DSTR * s)
{
return (*s)->dstr_s;
}
static inline size_t
tds_dstr_len(const DSTR * s)
{
return (*s)->dstr_size;
}
#define tds_dstr_empty(s) \
tds_dstr_free(s)
void tds_dstr_zero(DSTR * s);
void tds_dstr_free(DSTR * s);
DSTR* tds_dstr_dup(DSTR * s, const DSTR * src) TDS_WUR;
DSTR* tds_dstr_copy(DSTR * s, const char *src) TDS_WUR;
DSTR* tds_dstr_copyn(DSTR * s, const char *src, size_t length) TDS_WUR;
DSTR* tds_dstr_set(DSTR * s, char *src) TDS_WUR;
DSTR* tds_dstr_setlen(DSTR *s, size_t length);
DSTR* tds_dstr_alloc(DSTR *s, size_t length) TDS_WUR;
#include <freetds/popvis.h>
#endif /* _tdsguard_d2McTbRS3vmVcq0ls4BzwH_ */
tds_dstr_setlen
DSTR * tds_dstr_setlen(DSTR *s, size_t length)
limit length of string, MUST be <= current length
Definition tdsstring.c:145
tds_dstr_isempty
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition string.h:60
tds_dstr_zero
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition tdsstring.c:55
tds_dstr_len
static size_t tds_dstr_len(const DSTR *s)
Returns the length of the string in bytes.
Definition string.h:85
tds_dstr_dup
DSTR * tds_dstr_dup(DSTR *s, const DSTR *src)
Duplicate a string from another dynamic string.
Definition tdsstring.c:134
DSTR_INITIALIZER
#define DSTR_INITIALIZER
Initializer, used to initialize string like in the following example.
Definition string.h:49
tds_dstr_copyn
DSTR * tds_dstr_copyn(DSTR *s, const char *src, size_t length)
Set string to a given buffer of characters.
Definition tdsstring.c:77
tds_str_empty
const struct tds_dstr tds_str_empty
Internal representation for an empty string.
Definition tdsstring.c:45
tds_dstr_alloc
DSTR * tds_dstr_alloc(DSTR *s, size_t length)
allocate space for length char
Definition tdsstring.c:165
tds_dstr_init
static void tds_dstr_init(DSTR *s)
init a string with empty
Definition string.h:53
tds_dstr_set
DSTR * tds_dstr_set(DSTR *s, char *src)
set a string from another buffer.
Definition tdsstring.c:107
tds_dstr_cstr
static const char * tds_dstr_cstr(const DSTR *s)
Returns a C version (NUL terminated string) of dstr.
Definition string.h:78
tds_dstr_free
void tds_dstr_free(DSTR *s)
free string
Definition tdsstring.c:62
tds_dstr_copy
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition tdsstring.c:122
tds_dstr_buf
static char * tds_dstr_buf(DSTR *s)
Returns a buffer to edit the string.
Definition string.h:71
DSTR
struct tds_dstr * DSTR
Structure to hold a string.
tds_dstr
Structure to hold a string.
Definition string.h:36