1 /* $Id: $ */
2
3 /* Copyright (C) 1998 Sverre Hvammen Johansen,
4 * Department of Informatics, University of Oslo.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
18
19 #include <obstack.h>
20
21 char *xmalloc();
22 void free();
23
24 #define obstack_chunk_alloc xmalloc
25 #define obstack_chunk_free free
26
27 static struct obstack osMell;
28
29 static char *mstring, *mend;
30 char *mpointer;
31
32 /******************************************************************************
33 MBUILDERINIT */
34
mbuilderInit()35 mbuilderInit()
36 {
37 obstack_init(&osMell);
38 }
39
40 /******************************************************************************
41 MOUT */
42
mout(x)43 mout(x)unsigned char x;
44 {
45 obstack_1grow(&osMell, x);
46 }
47
48 /******************************************************************************
49 MOUTIVAL */
50
moutIval(x)51 moutIval(x)long x;
52 {
53 obstack_grow(&osMell, &x, sizeof (long));
54 }
55
56 /******************************************************************************
57 MOUTRVAL */
58
moutRval(x)59 moutRval(x)double x;
60 {
61 obstack_grow(&osMell, &x,sizeof (double));
62 }
63
64 /******************************************************************************
65 MOUTTVAL */
66
moutTval(x)67 moutTval(x)char *x;
68 {
69 obstack_grow(&osMell, &x, sizeof (char *));
70 }
71
72 /******************************************************************************
73 MOUTID */
74
moutId(x)75 moutId(x)char *x;
76 {
77 obstack_grow(&osMell, &x, sizeof (char *));
78 }
79
80 /******************************************************************************
81 MBUILDERREINIT */
82
mbuilderReinit()83 mbuilderReinit()
84 {
85 long i;
86 i= obstack_object_size(&osMell);
87 mpointer= mstring= (char *)obstack_finish (&osMell);
88 mend= mpointer+i;
89 }
90
91 /******************************************************************************
92 MIN */
93
min()94 int min()
95 {
96 unsigned char x;
97 if (mpointer>=mend) return -1;
98 x= *(mpointer++);
99 return (x);
100 }
101
102 /******************************************************************************
103 MINIVAL */
104
minIval()105 long minIval()
106 {
107 long x;
108 memmove (&x,mpointer,sizeof(long));
109 mpointer += sizeof(long);
110 return (x);
111 }
112
113 /******************************************************************************
114 MINRVAL */
115
minRval()116 double minRval()
117 {
118 double x;
119 memmove (&x,mpointer,sizeof (double));
120 mpointer += sizeof (double);
121 return (x);
122 }
123
124 /******************************************************************************
125 MINTVAL */
126
minTval()127 char *minTval()
128 {
129 char *x;
130 memmove(&x,mpointer,sizeof(char *));
131 mpointer += sizeof(char *);
132 return(x);
133 }
134
135 /******************************************************************************
136 MINID */
137
minId()138 char *minId()
139 {
140 char *x;
141 memmove (&x,mpointer,sizeof(char *));
142 mpointer += sizeof(char *);
143 return(x);
144 }
145
146
147