00001 /* 00002 * Copyright 2003-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /* 00018 * This software consists of voluntary contributions made by many 00019 * individuals on behalf of the Apache Software Foundation. For more 00020 * information on the Apache Software Foundation, please see 00021 * <http://www.apache.org/>. 00022 * 00023 * The apr_vsnprintf/apr_snprintf functions are based on, and used with the 00024 * permission of, the SIO stdio-replacement strx_* functions by Panos 00025 * Tsirigotis <panos@alumni.cs.colorado.edu> for xinetd. 00026 */ 00027 00028 /* 00029 * @file apr_base64.h 00030 * @brief APR-UTIL Base64 Encoding 00031 */ 00032 #ifndef APR_BASE64_H 00033 #define APR_BASE64_H 00034 00035 /*#include "apu.h"*/ 00036 /*#include "apr_general.h"*/ 00037 00038 #define APU_DECLARE(x) x 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* 00045 * @defgroup APR_Util_Base64 Base64 Encoding 00046 * @ingroup APR_Util 00047 */ 00048 00049 /* Simple BASE64 encode/decode functions. 00050 * 00051 * As we might encode binary strings, hence we require the length of 00052 * the incoming plain source. And return the length of what we decoded. 00053 * 00054 * The decoding function takes any non valid char (i.e. whitespace, \0 00055 * or anything non A-Z,0-9 etc as terminal. 00056 * 00057 * plain strings/binary sequences are not assumed '\0' terminated. Encoded 00058 * strings are neither. But probably should. 00059 * 00060 */ 00061 00062 /* 00063 * Given the length of an un-encrypted string, get the length of the 00064 * encrypted string. 00065 * @param len the length of an unencrypted string. 00066 * @return the length of the string after it is encrypted 00067 */ 00068 APU_DECLARE(int) apr_base64_encode_len(int len); 00069 00070 /* 00071 * Encode a text string using base64encoding. 00072 * @param coded_dst The destination string for the encoded string. 00073 * @param plain_src The original string in plain text 00074 * @param len_plain_src The length of the plain text string 00075 * @return the length of the encoded string 00076 */ 00077 APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src, 00078 int len_plain_src); 00079 00080 /* 00081 * Encode an EBCDIC string using base64encoding. 00082 * @param coded_dst The destination string for the encoded string. 00083 * @param plain_src The original string in plain text 00084 * @param len_plain_src The length of the plain text string 00085 * @return the length of the encoded string 00086 */ 00087 APU_DECLARE(int) apr_base64_encode_binary(char * coded_dst, 00088 const unsigned char *plain_src, 00089 int len_plain_src); 00090 00091 /* 00092 * Determine the length of a plain text string given the encoded version 00093 * @param coded_src The encoded string 00094 * @return the length of the plain text string 00095 */ 00096 APU_DECLARE(int) apr_base64_decode_len(const char * coded_src); 00097 00098 /* 00099 * Decode a string to plain text 00100 * @param plain_dst The destination string for the plain text 00101 * @param coded_src The encoded string 00102 * @return the length of the plain text string 00103 */ 00104 APU_DECLARE(int) apr_base64_decode(char * plain_dst, const char *coded_src); 00105 00106 /* 00107 * Decode an EBCDIC string to plain text 00108 * @param plain_dst The destination string for the plain text 00109 * @param coded_src The encoded string 00110 * @return the length of the plain text string 00111 */ 00112 APU_DECLARE(int) apr_base64_decode_binary(unsigned char * plain_dst, 00113 const char *coded_src); 00114 00115 /* @} */ 00116 #ifdef __cplusplus 00117 } 00118 #endif 00119 00120 #endif /* !APR_BASE64_H */