source: trunk/gsdl/packages/yaz/odr/ber_bool.c@ 1343

Last change on this file since 1343 was 1343, checked in by johnmcp, 24 years ago

Added the YAZ toolkit source to the packages directory (for z39.50 stuff)

  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/*
2 * Copyright (c) 1995-2000, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
5 *
6 * $Log$
7 * Revision 1.1 2000/08/03 03:11:13 johnmcp
8 * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
9 *
10 * Revision 1.11 2000/02/29 13:44:55 adam
11 * Check for config.h (currently not generated).
12 *
13 * Revision 1.10 2000/01/31 13:15:21 adam
14 * Removed uses of assert(3). Cleanup of ODR. CCL parser update so
15 * that some characters are not surrounded by spaces in resulting term.
16 * ILL-code updates.
17 *
18 * Revision 1.9 1999/11/30 13:47:11 adam
19 * Improved installation. Moved header files to include/yaz.
20 *
21 * Revision 1.8 1995/09/29 17:12:16 quinn
22 * Smallish
23 *
24 * Revision 1.7 1995/09/27 15:02:55 quinn
25 * Modified function heads & prototypes.
26 *
27 * Revision 1.6 1995/05/16 08:50:43 quinn
28 * License, documentation, and memory fixes
29 *
30 * Revision 1.5 1995/04/18 08:15:14 quinn
31 * Added dynamic memory allocation on encoding (whew). Code is now somewhat
32 * neater. We'll make the same change for decoding one day.
33 *
34 * Revision 1.4 1995/03/21 10:17:27 quinn
35 * Fixed little bug in decoder.
36 *
37 * Revision 1.3 1995/03/08 12:12:06 quinn
38 * Added better error checking.
39 *
40 * Revision 1.2 1995/02/09 15:51:45 quinn
41 * Works better now.
42 *
43 * Revision 1.1 1995/02/02 16:21:51 quinn
44 * First kick.
45 *
46 */
47
48#if HAVE_CONFIG_H
49#include <config.h>
50#endif
51
52#include <stdio.h>
53#include <yaz/odr.h>
54
55int ber_boolean(ODR o, int *val)
56{
57 int res, len;
58
59 switch (o->direction)
60 {
61 case ODR_ENCODE:
62 if (ber_enclen(o, 1, 1, 1) != 1)
63 return 0;
64 if (odr_putc(o, *val) < 0)
65 return 0;
66#ifdef ODR_DEBUG
67 fprintf(stderr, "[val=%d]\n", *val);
68#endif
69 return 1;
70 case ODR_DECODE:
71 if ((res = ber_declen(o->bp, &len)) < 0)
72 {
73 o->error = OPROTO;
74 return 0;
75 }
76 if (len != 1)
77 {
78 o->error = OPROTO;
79 return 0;
80 }
81 o->bp+= res;
82 *val = *o->bp;
83 o->bp++;
84#ifdef ODR_DEBUG
85 fprintf(stderr, "[val=%d]\n", *val);
86#endif
87 return 1;
88 case ODR_PRINT:
89 return 1;
90 default: o->error = OOTHER; return 0;
91 }
92}
Note: See TracBrowser for help on using the repository browser.