xref: /onnv-gate/usr/src/lib/libkmf/ber_der/inc/kmfber_int.h (revision 3433:2971a4d3cf72)
13089Swyllys /*
23089Swyllys  * -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
33089Swyllys  *
43089Swyllys  * The contents of this file are subject to the Netscape Public License
53089Swyllys  * Version 1.0 (the "NPL"); you may not use this file except in
63089Swyllys  * compliance with the NPL.  You may obtain a copy of the NPL at
73089Swyllys  * http://www.mozilla.org/NPL/
83089Swyllys  *
93089Swyllys  * Software distributed under the NPL is distributed on an "AS IS" basis,
103089Swyllys  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
113089Swyllys  * for the specific language governing rights and limitations under the
123089Swyllys  * NPL.
133089Swyllys  *
143089Swyllys  * The Initial Developer of the Original Code is Netscape
153089Swyllys  * Communications Corporation. Portions created by Netscape are
163089Swyllys  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
173089Swyllys  * Rights Reserved.
183089Swyllys  */
193089Swyllys 
203089Swyllys /*
213089Swyllys  * Copyright (c) 1990 Regents of the University of Michigan.
223089Swyllys  * All rights reserved.
233089Swyllys  *
243089Swyllys  * Redistribution and use in source and binary forms are permitted
253089Swyllys  * provided that this notice is preserved and that due credit is given
263089Swyllys  * to the University of Michigan at Ann Arbor. The name of the University
273089Swyllys  * may not be used to endorse or promote products derived from this
283089Swyllys  * software without specific prior written permission. This software
293089Swyllys  * is provided ``as is'' without express or implied warranty.
303089Swyllys  */
313089Swyllys /*
32*3433Shaimay  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
333089Swyllys  * Use is subject to license terms.
343089Swyllys  */
353089Swyllys 
363089Swyllys #pragma ident	"%Z%%M%	%I%	%E% SMI"
373089Swyllys 
383089Swyllys 
393089Swyllys 
403089Swyllys #ifndef _KMFBER_INT_H
413089Swyllys #define	_KMFBER_INT_H
423089Swyllys 
433089Swyllys #ifdef __cplusplus
443089Swyllys extern "C" {
453089Swyllys #endif
463089Swyllys 
473089Swyllys #include <stdio.h>
483089Swyllys #include <ctype.h>
493089Swyllys #include <stdarg.h>
503089Swyllys #include <stdlib.h>
513089Swyllys 
523089Swyllys #include <malloc.h>
533089Swyllys #include <errno.h>
543089Swyllys #include <sys/types.h>
553089Swyllys #include <unistd.h>
563089Swyllys 
573089Swyllys #include <memory.h>
583089Swyllys #include <string.h>
593089Swyllys 
603089Swyllys typedef struct seqorset {
613089Swyllys 	ber_len_t	sos_clen;
623089Swyllys 	ber_tag_t	sos_tag;
633089Swyllys 	char		*sos_first;
643089Swyllys 	char		*sos_ptr;
653089Swyllys 	struct seqorset	*sos_next;
663089Swyllys } Seqorset;
673089Swyllys #define	NULLSEQORSET	((Seqorset *) 0)
683089Swyllys 
693089Swyllys #define	SOS_STACK_SIZE 8 /* depth of the pre-allocated sos structure stack */
703089Swyllys 
713089Swyllys struct berelement {
723089Swyllys 	char		*ber_buf;
733089Swyllys 	char		*ber_ptr;
743089Swyllys 	char		*ber_end;
753089Swyllys 	struct seqorset	*ber_sos;
763089Swyllys 	ber_tag_t	ber_tag;
773089Swyllys 	ber_len_t	ber_len;
783089Swyllys 	int		ber_usertag;
793089Swyllys 	char		ber_options;
803089Swyllys 	char		*ber_rwptr;
813089Swyllys 	BERTranslateProc ber_encode_translate_proc;
823089Swyllys 	BERTranslateProc ber_decode_translate_proc;
833089Swyllys 	int		ber_flags;
843089Swyllys #define	KMFBER_FLAG_NO_FREE_BUFFER	1	/* don't free ber_buf */
853089Swyllys 	int		ber_sos_stack_posn;
863089Swyllys 	Seqorset	ber_sos_stack[SOS_STACK_SIZE];
873089Swyllys };
883089Swyllys 
893089Swyllys /* function prototypes */
903089Swyllys void ber_err_print(char *data);
913089Swyllys 
923089Swyllys #define	THEMEMCPY(d, s, n)	memmove(d, s, n)
933089Swyllys 
943089Swyllys #ifdef SAFEMEMCPY
953089Swyllys #undef SAFEMEMCPY
963089Swyllys #define	SAFEMEMCPY(d, s, n) memmove(d, s, n);
973089Swyllys #endif
983089Swyllys 
993089Swyllys /* allow the library to access the debug variable */
1003089Swyllys 
1013089Swyllys #ifdef KMFBER_DEBUG
1023089Swyllys extern int kmfber_debug;
1033089Swyllys #endif
1043089Swyllys 
1053089Swyllys #ifdef __cplusplus
1063089Swyllys }
1073089Swyllys #endif
1083089Swyllys #endif /* _KMFBER_INT_H */
109