VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/lib/libc/include/plbase64.h@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef _plbase64_h
39#define _plbase64_h
40
41#include "prtypes.h"
42
43PR_BEGIN_EXTERN_C
44
45/*
46 * PL_Base64Encode
47 *
48 * This routine encodes the data pointed to by the "src" parameter using the
49 * base64 algorithm, and returns a pointer to the result. If the "srclen"
50 * parameter is not zero, it specifies the length of the source data. If it
51 * is zero, the source data is assumed to be null-terminated, and PL_strlen
52 * is used to determine the source length. If the "dest" parameter is not
53 * null, it is assumed to point to a buffer of sufficient size (which may be
54 * calculated: ((srclen + 2)/3)*4) into which the encoded data is placed
55 * (without any termination). If the "dest" parameter is null, a buffer is
56 * allocated from the heap to hold the encoded data, and the result *will*
57 * be terminated with an extra null character. It is the caller's
58 * responsibility to free the result when it is allocated. A null is returned
59 * if the allocation fails.
60 */
61
62PR_EXTERN(char *)
63PL_Base64Encode
64(
65 const char *src,
66 PRUint32 srclen,
67 char *dest
68);
69
70/*
71 * PL_Base64Decode
72 *
73 * This routine decodes the data pointed to by the "src" parameter using
74 * the base64 algorithm, and returns a pointer to the result. The source
75 * may either include or exclude any trailing '=' characters. If the
76 * "srclen" parameter is not zero, it specifies the length of the source
77 * data. If it is zero, PL_strlen will be used to determine the source
78 * length. If the "dest" parameter is not null, it is assumed to point to
79 * a buffer of sufficient size (which may be calculated: (srclen * 3)/4
80 * when srclen includes the '=' characters) into which the decoded data
81 * is placed (without any termination). If the "dest" parameter is null,
82 * a buffer is allocated from the heap to hold the decoded data, and the
83 * result *will* be terminated with an extra null character. It is the
84 * caller's responsibility to free the result when it is allocated. A null
85 * is retuned if the allocation fails, or if the source is not well-coded.
86 */
87
88PR_EXTERN(char *)
89PL_Base64Decode
90(
91 const char *src,
92 PRUint32 srclen,
93 char *dest
94);
95
96PR_END_EXTERN_C
97
98#endif /* _plbase64_h */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette