Use libtasn1 v2.4.
[gnutls.git] / lib / gnutls_str.h
blob32ee16cf33e247233aa7b823c8d3c9eaa7ae361e
1 /*
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,
22 * USA
26 #ifndef GNUTLS_STR_H
27 # define GNUTLS_STR_H
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,
33 size_t src_size);
34 void _gnutls_str_cat (char *dest, size_t dest_tot_size, const char *src);
36 typedef struct
38 opaque *allocd; /* pointer to allocated data */
39 opaque *data; /* API: pointer to data to copy from */
40 size_t max_length;
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;
45 } gnutls_string;
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,
54 size_t data_size);
56 void _gnutls_string_get_data( gnutls_string *, void*, size_t *size);
57 void _gnutls_string_get_datum( gnutls_string *, gnutls_datum_t *, size_t max_size);
59 #ifndef __attribute__
60 /* This feature is available in gcc versions 2.5 and later. */
61 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
62 # define __attribute__(Spec) /* empty */
63 # endif
64 #endif
66 int _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
67 __attribute__ ((format (printf, 2, 3)));
69 typedef gnutls_string gnutls_buffer;
71 #define _gnutls_buffer_init(buf) _gnutls_string_init(buf, gnutls_malloc, gnutls_realloc, gnutls_free);
72 #define _gnutls_buffer_clear _gnutls_string_clear
73 #define _gnutls_buffer_append _gnutls_string_append_data
74 #define _gnutls_buffer_get_datum _gnutls_string_get_datum
75 #define _gnutls_buffer_get_data _gnutls_string_get_data
76 #define _gnutls_buffer_resize _gnutls_string_resize
78 char *_gnutls_bin2hex (const void *old, size_t oldlen, char *buffer,
79 size_t buffer_size);
80 int _gnutls_hex2bin (const opaque * hex_data, int hex_size, opaque * bin_data,
81 size_t * bin_size);
83 int _gnutls_hostname_compare (const char *certname, size_t certnamesize, const char *hostname);
84 #define MAX_CN 256
86 #endif