1/* 2 * Portions Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") 3 * Portions Copyright (C) 2001 Internet Software Consortium. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 11 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY 12 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * 17 * Portions Copyright (C) 2001 Nominum, Inc. 18 * 19 * Permission to use, copy, modify, and/or distribute this software for any 20 * purpose with or without fee is hereby granted, provided that the above 21 * copyright notice and this permission notice appear in all copies. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL 24 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 25 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY 26 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 27 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 28 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 29 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 30 */ 31 32/* $Id: base64.h,v 1.10 2007/08/28 07:20:43 tbox Exp $ */ 33 34#ifndef ISCCC_BASE64_H 35#define ISCCC_BASE64_H 1 36 37/*! \file isccc/base64.h */ 38 39#include <isc/lang.h> 40#include <isccc/types.h> 41 42ISC_LANG_BEGINDECLS 43 44/*** 45 *** Functions 46 ***/ 47 48isc_result_t 49isccc_base64_encode(isccc_region_t *source, int wordlength, 50 const char *wordbreak, isccc_region_t *target); 51/*%< 52 * Convert data into base64 encoded text. 53 * 54 * Notes: 55 *\li The base64 encoded text in 'target' will be divided into 56 * words of at most 'wordlength' characters, separated by 57 * the 'wordbreak' string. No parentheses will surround 58 * the text. 59 * 60 * Requires: 61 *\li 'source' is a region containing binary data. 62 *\li 'target' is a text region containing available space. 63 *\li 'wordbreak' points to a null-terminated string of 64 * zero or more whitespace characters. 65 */ 66 67isc_result_t 68isccc_base64_decode(const char *cstr, isccc_region_t *target); 69/*%< 70 * Decode a null-terminated base64 string. 71 * 72 * Requires: 73 *\li 'cstr' is non-null. 74 *\li 'target' is a valid region. 75 * 76 * Returns: 77 *\li #ISC_R_SUCCESS -- the entire decoded representation of 'cstring' 78 * fit in 'target'. 79 *\li #ISC_R_BADBASE64 -- 'cstr' is not a valid base64 encoding. 80 *\li #ISC_R_NOSPACE -- 'target' is not big enough. 81 */ 82 83ISC_LANG_ENDDECLS 84 85#endif /* ISCCC_BASE64_H */ 86