|
Apache Portable Runtime
|
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more 00002 * contributor license agreements. See the NOTICE file distributed with 00003 * this work for additional information regarding copyright ownership. 00004 * The ASF licenses this file to You under the Apache License, Version 2.0 00005 * (the "License"); you may not use this file except in compliance with 00006 * the License. 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 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 * The handling of terminating \0 characters differs from function to 00049 * function. 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, including the 00058 * trailing \0 00059 */ 00060 APR_DECLARE(int) apr_base64_encode_len(int len) __attribute__((pure)); 00061 00062 /** 00063 * Encode a text string using base64encoding. On EBCDIC machines, the input 00064 * is first converted to ASCII. 00065 * @param coded_dst The destination string for the encoded string. A \0 is 00066 * appended. 00067 * @param plain_src The original string in plain text 00068 * @param len_plain_src The length of the plain text string 00069 * @return the length of the encoded string, including the trailing \0 00070 */ 00071 APR_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src, 00072 int len_plain_src) 00073 __attribute__((nonnull(1,2))); 00074 00075 /** 00076 * Encode an text string using base64encoding. This is the same as 00077 * apr_base64_encode() except on EBCDIC machines, where the conversion of the 00078 * input to ASCII is left out. 00079 * @param coded_dst The destination string for the encoded string. A \0 is 00080 * appended. 00081 * @param plain_src The original string in plain text 00082 * @param len_plain_src The length of the plain text string 00083 * @return the length of the encoded string, including the trailing \0 00084 */ 00085 APR_DECLARE(int) apr_base64_encode_binary(char * coded_dst, 00086 const unsigned char *plain_src, 00087 int len_plain_src) 00088 __attribute__((nonnull(1,2))); 00089 00090 /** 00091 * Determine the maximum buffer length required to decode the plain text 00092 * string given the encoded string. 00093 * @param coded_src The encoded string 00094 * @return the maximum required buffer length for the plain text string 00095 */ 00096 APR_DECLARE(int) apr_base64_decode_len(const char * coded_src) 00097 __attribute__((nonnull(1))) __attribute__((pure)); 00098 00099 /** 00100 * Decode a string to plain text. On EBCDIC machines, the result is then 00101 * converted to EBCDIC. 00102 * @param plain_dst The destination string for the plain text. A \0 is 00103 * appended. 00104 * @param coded_src The encoded string 00105 * @return the length of the plain text string (excluding the trailing \0) 00106 */ 00107 APR_DECLARE(int) apr_base64_decode(char * plain_dst, const char *coded_src) 00108 __attribute__((nonnull(1,2))); 00109 00110 /** 00111 * Decode an string to plain text. This is the same as apr_base64_decode() 00112 * except no \0 is appended and on EBCDIC machines, the conversion of the 00113 * output to EBCDIC is left out. 00114 * @param plain_dst The destination string for the plain text. The string is 00115 * not \0-terminated. 00116 * @param coded_src The encoded string 00117 * @return the length of the plain text string 00118 */ 00119 APR_DECLARE(int) apr_base64_decode_binary(unsigned char * plain_dst, 00120 const char *coded_src) 00121 __attribute__((nonnull(1,2))); 00122 00123 /** @} */ 00124 #ifdef __cplusplus 00125 } 00126 #endif 00127 00128 #endif /* !APR_BASE64_H */
1.7.5