io.c revision 56664548661c43ae04de4a32bce3510ed36aeaf9
/*
* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <ber_der.h>
#include "kmfber_int.h"
#define EXBUFSIZ 1024
/*
* Note: kmfber_read() only uses the ber_end and ber_ptr elements of ber.
* Functions like kmfber_get_tag(), kmfber_skip_tag, and kmfber_peek_tag()
* rely on that fact, so if this code is changed to use any additional
* elements of the ber structure, those functions will need to be changed
* as well.
*/
{
}
/*
* enlarge the ber buffer.
* return 0 on success, -1 on error.
*/
int
{
Seqorset *s;
char *oldbuf;
== NULL) {
return (-1);
}
} else {
/* transition to malloc'd buffer */
return (-1);
}
/* copy existing data into new malloc'd buffer */
} else {
return (-1);
}
}
}
/*
* If the stinking thing was moved, we need to go through and
* reset all the sos and ber pointers. Offsets would've been
* a better idea... oh well.
*/
}
}
return (0);
}
/*
* returns "len" on success and -1 on failure.
*/
{
return (-1);
}
return (len);
} else {
return (-1);
}
return (len);
}
}
void
{
if (freebuf &&
}
}
/* we pre-allocate a buffer to save the extra malloc later */
kmfber_alloc_t(int options)
{
return (NULL);
}
return (ber);
}
{
return (kmfber_alloc_t(0));
}
{
return (kmfber_alloc_t(KMFBER_OPT_USE_DER));
}
{
return (NULL);
return (new);
}
void
{
}
void
{
if (was_writing) {
} else {
}
}
#ifdef KMFBER_DEBUG
void
{
char msg[128];
if (inout == 1) {
} else {
}
}
void
{
char msg[80];
ber_err_print("*** sos dump ***\n");
while (sos != NULLSEQORSET) {
}
ber_err_print("*** end dump ***\n");
}
#endif
/* new dboreham code below: */
struct byte_buffer {
unsigned char *p;
int offset;
int length;
};
typedef struct byte_buffer byte_buffer;
/*
* The kmfber_flatten routine allocates a struct berval whose contents
* are a BER encoding taken from the ber argument. The bvPtr pointer
* points to the returned berval, which must be freed using
* kmfber_bvfree(). This routine returns 0 on success and -1 on error.
* The use of kmfber_flatten on a BerElement in which all '{' and '}'
* format modifiers have not been properly matched can result in a
* berval whose contents are not a valid BER encoding.
* Note that the ber_ptr is not modified.
*/
int
{
/* allocate a struct berval */
return (-1);
}
/*
* Copy everything from the BerElement's ber_buf to ber_ptr
* into the berval structure.
*/
} else {
return (-1);
}
}
/* set bvPtr pointer to point to the returned berval */
return (0);
}
{
/* construct BerElement */
/* copy data from the bv argument into BerElement */
/* XXXmcs: had to cast unsigned long bv_len to long */
return (NULL);
}
}
/*
* reset ber_ptr back to the beginning of buffer so that this new
* and initialized ber element can be READ
*/
/*
* return a ptr to a new BerElement containing a copy of the data
* in the bv argument or a null pointer on error
*/
return (ber);
}
{
/* construct BerElement */
/* copy data from the bv argument into BerElement */
/* XXXmcs: had to cast unsigned long bv_len to long */
return (NULL);
}
}
/*
* reset ber_ptr back to the beginning of buffer so that this new
* and initialized ber element can be READ
*/
/*
* return a ptr to a new BerElement containing a copy of the data
* in the bv argument or a null pointer on error
*/
return (ber);
}