libalpm
Arch Linux Package Manager Library
|
00001 /** 00002 * \file base64.h 00003 * 00004 * Copyright (C) 2006-2010, Brainspark B.V. 00005 * 00006 * This file is part of PolarSSL (http://www.polarssl.org) 00007 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> 00008 * 00009 * All rights reserved. 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef _BASE64_H 00026 #define _BASE64_H 00027 00028 #include <string.h> 00029 00030 #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010 /**< Output buffer too small. */ 00031 #define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012 /**< Invalid character in input. */ 00032 00033 #if 0 00034 /** 00035 * \brief Encode a buffer into base64 format 00036 * 00037 * \param dst destination buffer 00038 * \param dlen size of the buffer 00039 * \param src source buffer 00040 * \param slen amount of data to be encoded 00041 * 00042 * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL. 00043 * *dlen is always updated to reflect the amount 00044 * of data that has (or would have) been written. 00045 * 00046 * \note Call this function with *dlen = 0 to obtain the 00047 * required buffer size in *dlen 00048 */ 00049 int base64_encode( unsigned char *dst, size_t *dlen, 00050 const unsigned char *src, size_t slen ); 00051 #endif 00052 00053 /** 00054 * \brief Decode a base64-formatted buffer 00055 * 00056 * \param dst destination buffer 00057 * \param dlen size of the buffer 00058 * \param src source buffer 00059 * \param slen amount of data to be decoded 00060 * 00061 * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or 00062 * POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not 00063 * correct. *dlen is always updated to reflect the amount 00064 * of data that has (or would have) been written. 00065 * 00066 * \note Call this function with *dlen = 0 to obtain the 00067 * required buffer size in *dlen 00068 */ 00069 int base64_decode( unsigned char *dst, size_t *dlen, 00070 const unsigned char *src, size_t slen ); 00071 00072 #endif /* base64.h */