00001 /* 00002 * Portions Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") 00003 * Portions Copyright (C) 2001 Internet Software Consortium. 00004 * 00005 * Permission to use, copy, modify, and/or distribute this software for any 00006 * purpose with or without fee is hereby granted, provided that the above 00007 * copyright notice and this permission notice appear in all copies. 00008 * 00009 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL 00010 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 00011 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY 00012 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00013 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00014 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00015 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00016 * 00017 * Portions Copyright (C) 2001 Nominum, Inc. 00018 * 00019 * Permission to use, copy, modify, and/or distribute this software for any 00020 * purpose with or without fee is hereby granted, provided that the above 00021 * copyright notice and this permission notice appear in all copies. 00022 * 00023 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL 00024 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 00025 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY 00026 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00027 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00028 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00029 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00030 */ 00031 00032 /* $Id: base64.h,v 1.10 2007/08/28 07:20:43 tbox Exp $ */ 00033 00034 #ifndef ISCCC_BASE64_H 00035 #define ISCCC_BASE64_H 1 00036 00037 /*! \file isccc/base64.h */ 00038 00039 #include <isc/lang.h> 00040 #include <isccc/types.h> 00041 00042 ISC_LANG_BEGINDECLS 00043 00044 /*** 00045 *** Functions 00046 ***/ 00047 00048 isc_result_t 00049 isccc_base64_encode(isccc_region_t *source, int wordlength, 00050 const char *wordbreak, isccc_region_t *target); 00051 /*%< 00052 * Convert data into base64 encoded text. 00053 * 00054 * Notes: 00055 *\li The base64 encoded text in 'target' will be divided into 00056 * words of at most 'wordlength' characters, separated by 00057 * the 'wordbreak' string. No parentheses will surround 00058 * the text. 00059 * 00060 * Requires: 00061 *\li 'source' is a region containing binary data. 00062 *\li 'target' is a text region containing available space. 00063 *\li 'wordbreak' points to a null-terminated string of 00064 * zero or more whitespace characters. 00065 */ 00066 00067 isc_result_t 00068 isccc_base64_decode(const char *cstr, isccc_region_t *target); 00069 /*%< 00070 * Decode a null-terminated base64 string. 00071 * 00072 * Requires: 00073 *\li 'cstr' is non-null. 00074 *\li 'target' is a valid region. 00075 * 00076 * Returns: 00077 *\li #ISC_R_SUCCESS -- the entire decoded representation of 'cstring' 00078 * fit in 'target'. 00079 *\li #ISC_R_BADBASE64 -- 'cstr' is not a valid base64 encoding. 00080 *\li #ISC_R_NOSPACE -- 'target' is not big enough. 00081 */ 00082 00083 ISC_LANG_ENDDECLS 00084 00085 #endif /* ISCCC_BASE64_H */