a_type.c revision 2139:6243c3338933
179265Sdillon/* crypto/asn1/a_type.c */
279265Sdillon/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
379265Sdillon * All rights reserved.
479265Sdillon *
5118848Simp * This package is an SSL implementation written
6118848Simp * by Eric Young (eay@cryptsoft.com).
7118848Simp * The implementation was written so as to conform with Netscapes SSL.
8118848Simp *
9118848Simp * This library is free for commercial and non-commercial use as long as
10118848Simp * the following conditions are aheared to.  The following conditions
11118848Simp * apply to all code found in this distribution, be it the RC4, RSA,
12118848Simp * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13118848Simp * included with this distribution is covered by the same copyright terms
14118848Simp * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15118848Simp *
16118848Simp * Copyright remains Eric Young's, and as such any Copyright notices in
1779265Sdillon * the code are not to be removed.
18118848Simp * If this package is used in a product, Eric Young should be given attribution
19118848Simp * as the author of the parts of the library used.
20118848Simp * This can be in the form of a textual message at program startup or
21118848Simp * in documentation (online or textual) provided with the package.
22118848Simp *
23118848Simp * Redistribution and use in source and binary forms, with or without
24118848Simp * modification, are permitted provided that the following conditions
25118848Simp * are met:
26118848Simp * 1. Redistributions of source code must retain the copyright
27118848Simp *    notice, this list of conditions and the following disclaimer.
28118848Simp * 2. Redistributions in binary form must reproduce the above copyright
29118848Simp *    notice, this list of conditions and the following disclaimer in the
3079265Sdillon *    documentation and/or other materials provided with the distribution.
3179265Sdillon * 3. All advertising materials mentioning features or use of this software
32126588Sbde *    must display the following acknowledgement:
3379265Sdillon *    "This product includes cryptographic software written by
3479265Sdillon *     Eric Young (eay@cryptsoft.com)"
35116226Sobrien *    The word 'cryptographic' can be left out if the rouines from the library
36116226Sobrien *    being used are not cryptographic related :-).
37116226Sobrien * 4. If you include any Windows specific code (or a derivative thereof) from
38134649Sscottl *    the apps directory (application code) you must include an acknowledgement:
39134649Sscottl *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
4079265Sdillon *
4179265Sdillon * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4282314Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4379265Sdillon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4482314Speter * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4579265Sdillon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4682314Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4779265Sdillon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48104964Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4979265Sdillon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5082314Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51125314Sjeff * SUCH DAMAGE.
5279265Sdillon *
5379265Sdillon * The licence and distribution terms for any publically available version or
5479265Sdillon * derivative of this code cannot be changed.  i.e. this code cannot simply be
5579265Sdillon * copied and put under another distribution licence
5679265Sdillon * [including the GNU Public Licence.]
5779265Sdillon */
5879265Sdillon
59126588Sbde#include <stdio.h>
60126588Sbde#include "cryptlib.h"
6179265Sdillon#include <openssl/asn1t.h>
62134461Siedowse
63134461Siedowseint ASN1_TYPE_get(ASN1_TYPE *a)
64134461Siedowse	{
65134461Siedowse	if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL))
6682314Speter		return(a->type);
6782314Speter	else
6882314Speter		return(0);
6982314Speter	}
7082314Speter
7182314Spetervoid ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
7279265Sdillon	{
7379265Sdillon	if (a->value.ptr != NULL)
7479265Sdillon		{
7579265Sdillon		ASN1_TYPE **tmp_a = &a;
7679265Sdillon		ASN1_primitive_free((ASN1_VALUE **)tmp_a, NULL);
7779265Sdillon		}
7879265Sdillon	a->type=type;
79137104Salc	a->value.ptr=value;
8082314Speter	}
8182314Speter
8282314Speter
8382314SpeterIMPLEMENT_STACK_OF(ASN1_TYPE)
8479265SdillonIMPLEMENT_ASN1_SET_OF(ASN1_TYPE)
8579265Sdillon