2 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009,
3 * 2010 Free Software Foundation, Inc.
5 * Author: Nikos Mavrogiannopoulos
7 * This file is part of GNUTLS.
9 * The GNUTLS library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
29 #include <gnutls_int.h>
31 void _gnutls_str_cpy (char *dest
, size_t dest_tot_size
, const char *src
);
32 void _gnutls_mem_cpy (char *dest
, size_t dest_tot_size
, const char *src
,
34 void _gnutls_str_cat (char *dest
, size_t dest_tot_size
, const char *src
);
38 opaque
*allocd
; /* pointer to allocated data */
39 opaque
*data
; /* API: pointer to data to copy from */
41 size_t length
; /* API: current length */
42 gnutls_realloc_function realloc_func
;
43 gnutls_alloc_function alloc_func
;
44 gnutls_free_function free_func
;
47 void _gnutls_string_init (gnutls_string
*, gnutls_alloc_function
,
48 gnutls_realloc_function
, gnutls_free_function
);
49 void _gnutls_string_clear (gnutls_string
*);
50 int _gnutls_string_resize (gnutls_string
*, size_t new_size
);
52 int _gnutls_string_append_str (gnutls_string
*, const char *str
);
53 int _gnutls_string_append_data (gnutls_string
*, const void *data
,
56 void _gnutls_string_get_data (gnutls_string
*, void *, size_t * size
);
57 void _gnutls_string_get_datum (gnutls_string
*, gnutls_datum_t
*,
61 /* This feature is available in gcc versions 2.5 and later. */
62 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
63 # define __attribute__(Spec) /* empty */
67 int _gnutls_string_append_printf (gnutls_string
* dest
, const char *fmt
, ...)
68 __attribute__ ((format (printf
, 2, 3)));
70 typedef gnutls_string gnutls_buffer
;
72 #define _gnutls_buffer_init(buf) _gnutls_string_init(buf, gnutls_malloc, gnutls_realloc, gnutls_free);
73 #define _gnutls_buffer_clear _gnutls_string_clear
74 #define _gnutls_buffer_append _gnutls_string_append_data
75 #define _gnutls_buffer_get_datum _gnutls_string_get_datum
76 #define _gnutls_buffer_get_data _gnutls_string_get_data
77 #define _gnutls_buffer_resize _gnutls_string_resize
79 char *_gnutls_bin2hex (const void *old
, size_t oldlen
, char *buffer
,
81 int _gnutls_hex2bin (const opaque
* hex_data
, int hex_size
, opaque
* bin_data
,
84 int _gnutls_hostname_compare (const char *certname
, size_t certnamesize
,
85 const char *hostname
);