|
Packit Service |
ae04f2 |
/*
|
|
Packit Service |
ae04f2 |
* Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
Packit Service |
ae04f2 |
*
|
|
Packit Service |
ae04f2 |
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
Packit Service |
ae04f2 |
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
Packit Service |
ae04f2 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
Packit Service |
ae04f2 |
*
|
|
Packit Service |
ae04f2 |
* See the COPYRIGHT file distributed with this work for additional
|
|
Packit Service |
ae04f2 |
* information regarding copyright ownership.
|
|
Packit Service |
ae04f2 |
*
|
|
Packit Service |
ae04f2 |
* Portions Copyright (C) 2001 Nominum, Inc.
|
|
Packit Service |
ae04f2 |
*
|
|
Packit Service |
ae04f2 |
* Permission to use, copy, modify, and/or distribute this software for any
|
|
Packit Service |
ae04f2 |
* purpose with or without fee is hereby granted, provided that the above
|
|
Packit Service |
ae04f2 |
* copyright notice and this permission notice appear in all copies.
|
|
Packit Service |
ae04f2 |
*
|
|
Packit Service |
ae04f2 |
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
|
|
Packit Service |
ae04f2 |
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
Packit Service |
ae04f2 |
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
|
|
Packit Service |
ae04f2 |
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
Packit Service |
ae04f2 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
Packit Service |
ae04f2 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
Packit Service |
ae04f2 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
Packit Service |
ae04f2 |
*/
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
/*! \file */
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
#include <config.h>
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
#include <isc/base64.h>
|
|
Packit Service |
ae04f2 |
#include <isc/buffer.h>
|
|
Packit Service |
ae04f2 |
#include <isc/region.h>
|
|
Packit Service |
ae04f2 |
#include <isc/result.h>
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
#include <isccc/base64.h>
|
|
Packit Service |
ae04f2 |
#include <isccc/result.h>
|
|
Packit Service |
ae04f2 |
#include <isccc/util.h>
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
isc_result_t
|
|
Packit Service |
ae04f2 |
isccc_base64_encode(isccc_region_t *source, int wordlength,
|
|
Packit Service |
ae04f2 |
const char *wordbreak, isccc_region_t *target)
|
|
Packit Service |
ae04f2 |
{
|
|
Packit Service |
ae04f2 |
isc_region_t sr;
|
|
Packit Service |
ae04f2 |
isc_buffer_t tb;
|
|
Packit Service |
ae04f2 |
isc_result_t result;
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
sr.base = source->rstart;
|
|
Packit Service |
ae04f2 |
sr.length = (unsigned int)(source->rend - source->rstart);
|
|
Packit Service |
ae04f2 |
isc_buffer_init(&tb, target->rstart,
|
|
Packit Service |
ae04f2 |
(unsigned int)(target->rend - target->rstart));
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
result = isc_base64_totext(&sr, wordlength, wordbreak, &tb);
|
|
Packit Service |
ae04f2 |
if (result != ISC_R_SUCCESS)
|
|
Packit Service |
ae04f2 |
return (result);
|
|
Packit Service |
ae04f2 |
source->rstart = source->rend;
|
|
Packit Service |
ae04f2 |
target->rstart = isc_buffer_used(&tb);
|
|
Packit Service |
ae04f2 |
return (ISC_R_SUCCESS);
|
|
Packit Service |
ae04f2 |
}
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
isc_result_t
|
|
Packit Service |
ae04f2 |
isccc_base64_decode(const char *cstr, isccc_region_t *target) {
|
|
Packit Service |
ae04f2 |
isc_buffer_t b;
|
|
Packit Service |
ae04f2 |
isc_result_t result;
|
|
Packit Service |
ae04f2 |
|
|
Packit Service |
ae04f2 |
isc_buffer_init(&b, target->rstart,
|
|
Packit Service |
ae04f2 |
(unsigned int)(target->rend - target->rstart));
|
|
Packit Service |
ae04f2 |
result = isc_base64_decodestring(cstr, &b);
|
|
Packit Service |
ae04f2 |
if (result != ISC_R_SUCCESS)
|
|
Packit Service |
ae04f2 |
return (result);
|
|
Packit Service |
ae04f2 |
target->rstart = isc_buffer_used(&b);
|
|
Packit Service |
ae04f2 |
return (ISC_R_SUCCESS);
|
|
Packit Service |
ae04f2 |
}
|