apr_base64.h

Go to the documentation of this file.
00001 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
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  * The apr_vsnprintf/apr_snprintf functions are based on, and used with the
00016  * permission of, the  SIO stdio-replacement strx_* functions by Panos
00017  * Tsirigotis <panos@alumni.cs.colorado.edu> for xinetd.
00018  */
00019 
00020 /**
00021  * @file apr_base64.h
00022  * @brief APR-UTIL Base64 Encoding
00023  */
00024 #ifndef APR_BASE64_H
00025 #define APR_BASE64_H
00026 
00027 #include "apu.h"
00028 #include "apr_general.h"
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 /**
00035  * @defgroup APR_Util_Base64 Base64 Encoding
00036  * @ingroup APR_Util
00037  * @{
00038  */
00039 
00040 /* Simple BASE64 encode/decode functions.
00041  * 
00042  * As we might encode binary strings, hence we require the length of
00043  * the incoming plain source. And return the length of what we decoded.
00044  *
00045  * The decoding function takes any non valid char (i.e. whitespace, \0
00046  * or anything non A-Z,0-9 etc as terminal.
00047  * 
00048  * plain strings/binary sequences are not assumed '\0' terminated. Encoded
00049  * strings are neither. But probably should.
00050  *
00051  */
00052 
00053 /**
00054  * Given the length of an un-encrypted string, get the length of the 
00055  * encrypted string.
00056  * @param len the length of an unencrypted string.
00057  * @return the length of the string after it is encrypted
00058  */ 
00059 APU_DECLARE(int) apr_base64_encode_len(int len);
00060 
00061 /**
00062  * Encode a text string using base64encoding.
00063  * @param coded_dst The destination string for the encoded string.
00064  * @param plain_src The original string in plain text
00065  * @param len_plain_src The length of the plain text string
00066  * @return the length of the encoded string
00067  */ 
00068 APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src, 
00069                                  int len_plain_src);
00070 
00071 /**
00072  * Encode an EBCDIC string using base64encoding.
00073  * @param coded_dst The destination string for the encoded string.
00074  * @param plain_src The original string in plain text
00075  * @param len_plain_src The length of the plain text string
00076  * @return the length of the encoded string
00077  */ 
00078 APU_DECLARE(int) apr_base64_encode_binary(char * coded_dst, 
00079                                         const unsigned char *plain_src,
00080                                         int len_plain_src);
00081 
00082 /**
00083  * Determine the length of a plain text string given the encoded version
00084  * @param coded_src The encoded string
00085  * @return the length of the plain text string
00086  */ 
00087 APU_DECLARE(int) apr_base64_decode_len(const char * coded_src);
00088 
00089 /**
00090  * Decode a string to plain text
00091  * @param plain_dst The destination string for the plain text
00092  * @param coded_src The encoded string 
00093  * @return the length of the plain text string
00094  */ 
00095 APU_DECLARE(int) apr_base64_decode(char * plain_dst, const char *coded_src);
00096 
00097 /**
00098  * Decode an EBCDIC string to plain text
00099  * @param plain_dst The destination string for the plain text
00100  * @param coded_src The encoded string 
00101  * @return the length of the plain text string
00102  */ 
00103 APU_DECLARE(int) apr_base64_decode_binary(unsigned char * plain_dst, 
00104                                         const char *coded_src);
00105 
00106 /** @} */
00107 #ifdef __cplusplus
00108 }
00109 #endif
00110 
00111 #endif  /* !APR_BASE64_H */

Generated on Tue Nov 6 14:40:16 2007 for Apache Portable Runtime by  doxygen 1.5.2