FreeTDS API: include/freetds/string.h Source File

FreeTDS API

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
string.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20 #ifndef _tdsstring_h_
21 #define _tdsstring_h_
22
23 /* $Id: tdsstring.h,v 1.21 2010-01-25 23:05:59 freddy77 Exp $ */
24
25 #include <freetds/pushvis.h>
26
27 extern const struct tds_dstr tds_str_empty;
28
29 /* TODO do some function and use inline if available */
30
35 #if ENABLE_EXTRA_CHECKS
36 void tds_dstr_init(DSTR * s);
37 int tds_dstr_isempty(DSTR * s);
38 char *tds_dstr_buf(DSTR * s);
39 size_t tds_dstr_len(DSTR * s);
40 #else
41
42 #define tds_dstr_init(s) \
43 do { *(s) = (struct tds_dstr*) &tds_str_empty; } while(0)
44
46 #define tds_dstr_isempty(s) \
47 ((*(s))->dstr_size == 0)
48 #define tds_dstr_buf(s) \
49 ((*(s))->dstr_s)
50 #define tds_dstr_len(s) \
51 ((*(s))->dstr_size)
52 #endif
53
54 #define tds_dstr_cstr(s) \
55 ((const char* ) tds_dstr_buf(s))
56
57 void tds_dstr_zero(DSTR * s);
58 void tds_dstr_free(DSTR * s);
59
61 #define tds_dstr_empty(s) \
62 tds_dstr_free(s)
63
64 #if ENABLE_EXTRA_CHECKS && defined(__GNUC__) && __GNUC__ >= 4
65 #define TDS_WUR __attribute__ ((__warn_unused_result__))
66 #else
67 #define TDS_WUR
68 #endif
69 DSTR* tds_dstr_dup(DSTR * s, const DSTR * src) TDS_WUR;
70 DSTR* tds_dstr_copy(DSTR * s, const char *src) TDS_WUR;
71 DSTR* tds_dstr_copyn(DSTR * s, const char *src, size_t length) TDS_WUR;
72 DSTR* tds_dstr_set(DSTR * s, char *src) TDS_WUR;
73
75 DSTR* tds_dstr_setlen(DSTR *s, size_t length);
77 DSTR* tds_dstr_alloc(DSTR *s, size_t length) TDS_WUR;
78
81 #include <freetds/popvis.h>
82
83 #endif /* _tdsstring_h_ */
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:80
tds_dstr_zero
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition: tdsstring.c:58
tds_dstr_init
#define tds_dstr_init(s)
init a string with empty
Definition: string.h:42
tds_dstr_set
DSTR * tds_dstr_set(DSTR *s, char *src)
set a string from another buffer.
Definition: tdsstring.c:110
tds_dstr_setlen
DSTR * tds_dstr_setlen(DSTR *s, size_t length)
limit length of string, MUST be <= current length
Definition: tdsstring.c:142
tds_dstr_copy
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:125
tds_dstr
Structure to hold a string.
Definition: tds.h:93
tds_dstr_free
void tds_dstr_free(DSTR *s)
free string
Definition: tdsstring.c:65
tds_dstr_alloc
DSTR * tds_dstr_alloc(DSTR *s, size_t length)
allocate space for length char
Definition: tdsstring.c:162
tds_dstr_isempty
#define tds_dstr_isempty(s)
test if string is empty
Definition: string.h:46