Fixed bug #2068: pkg-config trouble.
[yaz-moved-to-github.git] / src / odr_use.c
1 /*
2  * Copyright (C) 1995-2007, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: odr_use.c,v 1.5 2007-01-03 08:42:15 adam Exp $
6  */
7 /**
8  * \file odr_use.c
9  * \brief Implements misc ODR types.
10  */
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #include "odr-priv.h"
16
17 int odr_external(ODR o, Odr_external **p, int opt, const char *name)
18 {
19     Odr_external *pp;
20     static Odr_arm arm[] =
21     {
22         {ODR_EXPLICIT, ODR_CONTEXT, 0, ODR_EXTERNAL_single, 
23          (Odr_fun)odr_any, "single"},
24         {ODR_IMPLICIT, ODR_CONTEXT, 1, ODR_EXTERNAL_octet,
25          (Odr_fun)odr_octetstring, "octet"},
26         {ODR_IMPLICIT, ODR_CONTEXT, 2, ODR_EXTERNAL_arbitrary,
27          (Odr_fun)odr_bitstring, "arbitrary"},
28         {-1, -1, -1, -1, 0, 0}
29     };
30
31     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
32     if (!odr_sequence_begin(o, p, sizeof(Odr_external), name))
33         return odr_missing(o, opt, name);
34     pp = *p;
35     return
36         odr_oid(o, &pp->direct_reference, 1, "direct") &&
37         odr_integer(o, &pp->indirect_reference, 1, "indirect") &&
38         odr_graphicstring(o, &pp->descriptor, 1, "descriptor") &&
39         odr_choice(o, arm, &pp->u, &pp->which, 0) &&
40         odr_sequence_end(o);
41 }
42
43 int odr_visiblestring(ODR o, char **p, int opt, const char *name)
44 {
45     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
46                             ODR_VISIBLESTRING, opt, name);
47 }    
48
49 /*
50  * a char may not be sufficient to hold a general string, but we'll deal
51  * with that once we start looking more closely at UniCode & co.
52  */
53 int odr_generalstring(ODR o, char **p, int opt, const char *name)
54 {
55     return odr_implicit_tag(o, odr_iconv_string, p, ODR_UNIVERSAL,
56                             ODR_GENERALSTRING,opt, name);
57 }    
58
59 int odr_graphicstring(ODR o, char **p, int opt, const char *name)
60 {
61     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
62                         ODR_GRAPHICSTRING, opt, name);
63 }    
64
65 int odr_generalizedtime(ODR o, char **p, int opt, const char *name)
66 {
67     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
68                             ODR_GENERALIZEDTIME, opt, name);
69 }
70 /*
71  * Local variables:
72  * c-basic-offset: 4
73  * indent-tabs-mode: nil
74  * End:
75  * vim: shiftwidth=4 tabstop=8 expandtab
76  */
77