2 * Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved.
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 2.1 as
6 * published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11 * License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 * Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
18 * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
25 # ifdef HAVE_SYS_TYPES_H
26 # include <sys/types.h>
36 /* number of raw bytes in MD5 hash */
37 #define S3_MD5_HASH_BYTE_LEN 16
38 /* length of an MD5 hash encoded as base64 (not including terminating NULL) */
39 #define S3_MD5_HASH_B64_LEN 25
40 /* length of an MD5 hash encoded as hexadecimal (not including terminating NULL) */
41 #define S3_MD5_HASH_HEX_LEN 32
48 typedef GRegex* regex_t;
50 typedef gint regoff_t;
53 regoff_t rm_so; /* Byte offset from string's start to substring's start. */
54 regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
59 REG_NOERROR = 0, /* Success. */
60 REG_NOMATCH /* Didn't find a match (for regexec). */
69 /* we don't use gettextize, so hack around this ... */
74 * Wrapper around regexec to handle programmer errors.
75 * Only returns if the regexec returns 0 (match) or REG_NOMATCH.
76 * See regexec(3) documentation for the rest.
79 s3_regexec_wrap(regex_t *regex,
88 find_regex_substring(const char* base_string,
89 const regmatch_t match);
93 * Encode bytes using Base-64
95 * @note: GLib 2.12+ has a function for this (g_base64_encode)
96 * but we support much older versions. gnulib does as well, but its
97 * hard to use correctly (see its notes).
99 * @param to_enc: The data to encode.
100 * @returns: A new, null-terminated string or NULL if to_enc is NULL.
103 s3_base64_encode(const GByteArray *to_enc);
106 * Encode bytes using hexadecimal
108 * @param to_enc: The data to encode.
109 * @returns: A new, null-terminated string or NULL if to_enc is NULL.
112 s3_hex_encode(const GByteArray *to_enc);
115 * Compute the MD5 hash of a blob of data.
117 * @param to_hash: The data to compute the hash for.
118 * @returns: A new GByteArray containing the MD5 hash of data or
119 * NULL if to_hash is NULL.
122 s3_compute_md5_hash(const GByteArray *to_hash);