Initial revision
[LeanCalc.git] / calc / calc / value.h
1 /*
2  * value - definitions of general values  and related routines used by calc
3  *
4  * Copyright (C) 1999  David I. Bell
5  *
6  * Calc is open software; you can redistribute it and/or modify it under
7  * the terms of the version 2.1 of the GNU Lesser General Public License
8  * as published by the Free Software Foundation.
9  *
10  * Calc is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
13  * Public License for more details.
14  *
15  * A copy of version 2.1 of the GNU Lesser General Public License is
16  * distributed with calc under the filename COPYING-LGPL.  You should have
17  * received a copy with calc; if not, write to Free Software Foundation, Inc.
18  * 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * @(#) $Revision$
21  * @(#) $Id$
22  * @(#) $Source$
23  *
24  * Under source code control:   1993/07/30 19:42:47
25  * File existed as early as:    1993
26  *
27  * Share and enjoy!  :-)        http://www.isthe.com/chongo/tech/comp/calc/
28  */
29
30
31 #if !defined(__VALUE_H__)
32 #define __VALUE_H__
33
34
35 #if defined(CALC_SRC)   /* if we are building from the calc source tree */
36 # include "calc/win32dll.h"
37 # include "calc/cmath.h"
38 # include "calc/config.h"
39 # include "calc/shs.h"
40 # include "calc/calcerr.h"
41 # include "calc/hash.h"
42 # include "calc/block.h"
43 # include "calc/nametype.h"
44 # include "calc/string.h"
45 #else
46 # include <calc/win32dll.h>
47 # include <calc/cmath.h>
48 # include <calc/config.h>
49 # include <calc/shs.h>
50 # include <calc/calcerr.h>
51 # include <calc/hash.h>
52 # include <calc/block.h>
53 # include <calc/nametype.h>
54 # include <calc/string.h>
55 #endif
56
57
58 #define MAXDIM          4       /* maximum number of dimensions in matrices */
59 #define USUAL_ELEMENTS  4       /* usual number of elements for objects */
60
61
62 /*
63  * Flags to modify results from the printvalue routine.
64  * These flags are OR'd together.
65  */
66 #define PRINT_NORMAL    0x00    /* print in normal manner */
67 #define PRINT_SHORT     0x01    /* print in short format (no elements) */
68 #define PRINT_UNAMBIG   0x02    /* print in non-ambiguous manner */
69
70
71 /*
72  * Definition of values of various types.
73  */
74 typedef struct value VALUE;
75 typedef struct object OBJECT;
76 typedef struct matrix MATRIX;
77 typedef struct list LIST;
78 typedef struct assoc ASSOC;
79 typedef long FILEID;
80 typedef struct rand RAND;
81 typedef struct random RANDOM;
82
83
84 /*
85  * calc values
86  *
87  * See below for information on what needs to be added for a new type.
88  */
89 struct value {
90         short v_type;                   /* type of value */
91         short v_subtype;                /* other data related to some types */
92         union {                         /* types of values (see V_XYZ below) */
93                 long vv_int;            /* 1: small integer value */
94                 NUMBER *vv_num;         /* 2, 21: real number */
95                 COMPLEX *vv_com;        /* 3: complex number */
96                 VALUE *vv_addr;         /* 4, 18: address of variable value */
97                 STRING *vv_str;         /* 5, 20: string value */
98                 MATRIX *vv_mat;         /* 6: address of matrix */
99                 LIST *vv_list;          /* 7: address of list */
100                 ASSOC *vv_assoc;        /* 8: address of association */
101                 OBJECT *vv_obj;         /* 9: address of object */
102                 FILEID vv_file;         /* 10: id of opened file */
103                 RAND *vv_rand;          /* 11: additive 55 random state */
104                 RANDOM *vv_random;      /* 12: Blum random state */
105                 CONFIG *vv_config;      /* 13: configuration state */
106                 HASH *vv_hash;          /* 14: hash state */
107                 BLOCK *vv_block;        /* 15: memory block */
108                 OCTET *vv_octet;        /* 16, 19: octet addr (unsigned char) */
109                 NBLOCK *vv_nblock;      /* 17: named memory block */
110         } v_union;
111 };
112
113
114 /*
115  * For ease in referencing
116  */
117 #define v_int   v_union.vv_int
118 #define v_file  v_union.vv_file
119 #define v_num   v_union.vv_num
120 #define v_com   v_union.vv_com
121 #define v_addr  v_union.vv_addr
122 #define v_str   v_union.vv_str
123 #define v_mat   v_union.vv_mat
124 #define v_list  v_union.vv_list
125 #define v_assoc v_union.vv_assoc
126 #define v_obj   v_union.vv_obj
127 #define v_valid v_union.vv_int
128 #define v_rand  v_union.vv_rand
129 #define v_random v_union.vv_random
130 #define v_config v_union.vv_config
131 #define v_hash  v_union.vv_hash
132 #define v_block v_union.vv_block
133 #define v_octet v_union.vv_octet
134 #define v_nblock v_union.vv_nblock
135
136
137 /*
138  * Value types.
139  *
140  * NOTE: The following files should be checked/adjusted for a new type:
141  *
142  *      size.c          - elm_count(), lsizeof()
143  *      help/size       - update what the size() builtin will report
144  *      hash.c          - hash_value()
145  *      quickhash.c     - hashvalue()
146  *      value.c         - freevalue(), copyvalue(), comparevalue(),
147  *                        printvalue(),
148  *                        and other as needed such as testvalue(), etc.
149  *
150  * There may be others, but at is at least a start.
151  */
152 #define V_NULL  0       /* null value */
153 #define V_INT   1       /* normal integer */
154 #define V_NUM   2       /* number */
155 #define V_COM   3       /* complex number */
156 #define V_ADDR  4       /* address of variable value */
157 #define V_STR   5       /* address of string */
158 #define V_MAT   6       /* address of matrix structure */
159 #define V_LIST  7       /* address of list structure */
160 #define V_ASSOC 8       /* address of association structure */
161 #define V_OBJ   9       /* address of object structure */
162 #define V_FILE  10      /* opened file id */
163 #define V_RAND  11      /* address of additive 55 random state */
164 #define V_RANDOM 12     /* address of Blum random state */
165 #define V_CONFIG 13     /* configuration state */
166 #define V_HASH  14      /* hash state */
167 #define V_BLOCK 15      /* memory block */
168 #define V_OCTET 16      /* octet (unsigned char) */
169 #define V_NBLOCK 17     /* named memory block */
170 #define V_VPTR  18      /* value address as pointer */
171 #define V_OPTR  19      /* octet address as pointer */
172 #define V_SPTR  20      /* string address as pointer */
173 #define V_NPTR  21      /* number address as pointer */
174 #define V_MAX   21      /* highest legal value */
175
176 #define V_NOSUBTYPE     0       /* subtype has no meaning */
177 #define V_NOASSIGNTO    1       /* protection status 1 */
178 #define V_NONEWVALUE    2       /* protection status 2 */
179 #define V_NONEWTYPE     4       /* protection status 4 */
180 #define V_NOERROR       8       /* protection status 8 */
181 #define V_NOCOPYTO      16      /* protection status 16 */
182 #define V_NOREALLOC     32      /* protection status 32 */
183 #define V_NOASSIGNFROM  64      /* protection status 64 */
184 #define V_NOCOPYFROM    128     /* protection status 128 */
185 #define V_PROTECTALL    256     /* protection status 256 */
186
187 #define MAXPROTECT      511
188
189 /*
190  * At present protect(var, sts) determines bits in var->v_subtype
191  * corresponding to 4 * sts.  MAXPROTECT is the sum of the simple
192  * (power of two) protection status values.
193  */
194
195
196 #define TWOVAL(a,b) ((a) << 5 | (b))    /* for switch of two values */
197
198 #define NULL_VALUE      ((VALUE *) 0)
199
200
201 /*
202  * value functions
203  */
204 extern DLL void freevalue(VALUE *vp);
205 extern DLL void copyvalue(VALUE *vp, VALUE *vres);
206 extern DLL void negvalue(VALUE *vp, VALUE *vres);
207 extern DLL void addvalue(VALUE *v1, VALUE *v2, VALUE *vres);
208 extern DLL void subvalue(VALUE *v1, VALUE *v2, VALUE *vres);
209 extern DLL void mulvalue(VALUE *v1, VALUE *v2, VALUE *vres);
210 extern DLL void orvalue(VALUE *v1, VALUE *v2, VALUE *vres);
211 extern DLL void andvalue(VALUE *v1, VALUE *v2, VALUE *vres);
212 extern DLL void compvalue(VALUE *vp, VALUE *vres);
213 extern DLL void xorvalue(VALUE *v1, VALUE *v2, VALUE *vres);
214 extern DLL void squarevalue(VALUE *vp, VALUE *vres);
215 extern DLL void invertvalue(VALUE *vp, VALUE *vres);
216 extern DLL void roundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
217 extern DLL void broundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
218 extern DLL void setminusvalue(VALUE *, VALUE *, VALUE *);
219 extern DLL void backslashvalue(VALUE *, VALUE *);
220 extern DLL void contentvalue(VALUE *, VALUE *);
221 extern DLL void hashopvalue(VALUE *, VALUE *, VALUE *);
222 extern DLL void apprvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
223 extern DLL void intvalue(VALUE *vp, VALUE *vres);
224 extern DLL void fracvalue(VALUE *vp, VALUE *vres);
225 extern DLL void incvalue(VALUE *vp, VALUE *vres);
226 extern DLL void decvalue(VALUE *vp, VALUE *vres);
227 extern DLL void conjvalue(VALUE *vp, VALUE *vres);
228 extern DLL void sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
229 extern DLL void rootvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
230 extern DLL void absvalue(VALUE *v1, VALUE *v2, VALUE *vres);
231 extern DLL void normvalue(VALUE *vp, VALUE *vres);
232 extern DLL void shiftvalue(VALUE *v1, VALUE *v2, BOOL rightshift, VALUE *vres);
233 extern DLL void scalevalue(VALUE *v1, VALUE *v2, VALUE *vres);
234 extern DLL void powivalue(VALUE *v1, VALUE *v2, VALUE *vres);
235 extern DLL void powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
236 extern DLL void divvalue(VALUE *v1, VALUE *v2, VALUE *vres);
237 extern DLL void quovalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
238 extern DLL void modvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
239 extern DLL BOOL testvalue(VALUE *vp);
240 extern DLL BOOL comparevalue(VALUE *v1, VALUE *v2);
241 extern DLL BOOL acceptvalue(VALUE *v1, VALUE *v2);
242 extern DLL void relvalue(VALUE *v1, VALUE *v2, VALUE *vres);
243 extern DLL void sgnvalue(VALUE *vp, VALUE *vres);
244 extern DLL QCKHASH hashvalue(VALUE *vp, QCKHASH val);
245 extern DLL void printvalue(VALUE *vp, int flags);
246 extern DLL BOOL precvalue(VALUE *v1, VALUE *v2);
247 extern DLL VALUE error_value(int e);
248 extern DLL int set_errno(int e);
249 extern DLL int set_errcount(int e);
250 extern DLL long countlistitems(LIST *lp);
251 extern DLL void addlistitems(LIST *lp, VALUE *vres);
252 extern DLL void addlistinv(LIST *lp, VALUE *vres);
253 extern DLL void copy2octet(VALUE *, OCTET *);
254 extern DLL int copystod(VALUE *, long, long, VALUE *, long);
255 extern DLL void protectall(VALUE *, int);
256 extern DLL void set_update(int);
257
258
259 /*
260  * Structure of a matrix.
261  */
262 struct matrix {
263         long m_dim;             /* dimension of matrix */
264         long m_size;            /* total number of elements */
265         long m_min[MAXDIM];     /* minimum bound for indices */
266         long m_max[MAXDIM];     /* maximum bound for indices */
267         VALUE m_table[1];       /* actually varying length table */
268 };
269
270 #define matsize(n) (sizeof(MATRIX) - sizeof(VALUE) + ((n) * sizeof(VALUE)))
271
272
273 extern DLL MATRIX *matadd(MATRIX *m1, MATRIX *m2);
274 extern DLL MATRIX *matsub(MATRIX *m1, MATRIX *m2);
275 extern DLL MATRIX *matmul(MATRIX *m1, MATRIX *m2);
276 extern DLL MATRIX *matneg(MATRIX *m);
277 extern DLL MATRIX *matalloc(long size);
278 extern DLL MATRIX *matcopy(MATRIX *m);
279 extern DLL MATRIX *matinit(MATRIX *m, VALUE *v1, VALUE *v2);
280 extern DLL MATRIX *matsquare(MATRIX *m);
281 extern DLL MATRIX *matinv(MATRIX *m);
282 extern DLL MATRIX *matscale(MATRIX *m, long n);
283 extern DLL MATRIX *matshift(MATRIX *m, long n);
284 extern DLL MATRIX *matmulval(MATRIX *m, VALUE *vp);
285 extern DLL MATRIX *matpowi(MATRIX *m, NUMBER *q);
286 extern DLL MATRIX *matconj(MATRIX *m);
287 extern DLL MATRIX *matquoval(MATRIX *m, VALUE *vp, VALUE *v3);
288 extern DLL MATRIX *matmodval(MATRIX *m, VALUE *vp, VALUE *v3);
289 extern DLL MATRIX *matint(MATRIX *m);
290 extern DLL MATRIX *matfrac(MATRIX *m);
291 extern DLL MATRIX *matappr(MATRIX *m, VALUE *v2, VALUE *v3);
292 extern DLL VALUE mattrace(MATRIX *m);
293 extern DLL MATRIX *mattrans(MATRIX *m);
294 extern DLL MATRIX *matcross(MATRIX *m1, MATRIX *m2);
295 extern DLL BOOL mattest(MATRIX *m);
296 extern DLL void matsum(MATRIX *m, VALUE *vres);
297 extern DLL BOOL matcmp(MATRIX *m1, MATRIX *m2);
298 extern DLL int matsearch(MATRIX *m, VALUE *vp, long start, long end, ZVALUE *index);
299 extern DLL int matrsearch(MATRIX *m, VALUE *vp, long start, long end, ZVALUE *index);
300 extern DLL VALUE matdet(MATRIX *m);
301 extern DLL VALUE matdot(MATRIX *m1, MATRIX *m2);
302 extern DLL void matfill(MATRIX *m, VALUE *v1, VALUE *v2);
303 extern DLL void matfree(MATRIX *m);
304 extern DLL void matprint(MATRIX *m, long max_print);
305 extern DLL VALUE *matindex(MATRIX *mp, BOOL create, long dim, VALUE *indices);
306 extern DLL void matreverse(MATRIX *m);
307 extern DLL void matsort(MATRIX *m);
308 extern DLL BOOL matisident(MATRIX *m);
309 extern DLL MATRIX *matround(MATRIX *m, VALUE *v2, VALUE *v3);
310 extern DLL MATRIX *matbround(MATRIX *m, VALUE *v2, VALUE *v3);
311
312
313 /*
314  * List definitions.
315  * An individual list element.
316  */
317 typedef struct listelem LISTELEM;
318 struct listelem {
319         LISTELEM *e_next;       /* next element in list (or NULL) */
320         LISTELEM *e_prev;       /* previous element in list (or NULL) */
321         VALUE e_value;          /* value of this element */
322 };
323
324
325 /*
326  * Structure for a list of elements.
327  */
328 struct list {
329         LISTELEM *l_first;      /* first list element (or NULL) */
330         LISTELEM *l_last;       /* last list element (or NULL) */
331         LISTELEM *l_cache;      /* cached list element (or NULL) */
332         long l_cacheindex;      /* index of cached element (or undefined) */
333         long l_count;           /* total number of elements in the list */
334 };
335
336
337 extern DLL void insertlistfirst(LIST *lp, VALUE *vp);
338 extern DLL void insertlistlast(LIST *lp, VALUE *vp);
339 extern DLL void insertlistmiddle(LIST *lp, long index, VALUE *vp);
340 extern DLL void removelistfirst(LIST *lp, VALUE *vp);
341 extern DLL void removelistlast(LIST *lp, VALUE *vp);
342 extern DLL void removelistmiddle(LIST *lp, long index, VALUE *vp);
343 extern DLL void listfree(LIST *lp);
344 extern DLL void listprint(LIST *lp, long max_print);
345 extern DLL int listsearch(LIST *lp, VALUE *vp, long start, long end, ZVALUE *index);
346 extern DLL int listrsearch(LIST *lp, VALUE *vp, long start, long end, ZVALUE *index);
347 extern DLL BOOL listcmp(LIST *lp1, LIST *lp2);
348 extern DLL VALUE *listfindex(LIST *lp, long index);
349 extern DLL LIST *listalloc(void);
350 extern DLL LIST *listcopy(LIST *lp);
351 extern DLL void listreverse(LIST *lp);
352 extern DLL void listsort(LIST *lp);
353 extern DLL LIST *listappr(LIST *lp, VALUE *v2, VALUE *v3);
354 extern DLL LIST *listround(LIST *m, VALUE *v2, VALUE *v3);
355 extern DLL LIST *listbround(LIST *m, VALUE *v2, VALUE *v3);
356 extern DLL LIST *listquo(LIST *lp, VALUE *v2, VALUE *v3);
357 extern DLL LIST *listmod(LIST *lp, VALUE *v2, VALUE *v3);
358 extern DLL BOOL evp(LISTELEM *cp, LISTELEM *x, VALUE *vres);
359 extern DLL BOOL evalpoly(LIST *clist, LISTELEM *x, VALUE *vres);
360 extern DLL void insertitems(LIST *lp1, LIST *lp2);
361 extern DLL LISTELEM *listelement(LIST *, long);
362 extern DLL LIST *listsegment(LIST *, long, long);
363
364
365 /*
366  * Structures for associations.
367  * Associations are "indexed" by one or more arbitrary values, and are
368  * stored in a hash table with their hash values for quick indexing.
369  */
370 typedef struct assocelem ASSOCELEM;
371 struct assocelem {
372         ASSOCELEM *e_next;      /* next element in list (or NULL) */
373         long e_dim;             /* dimension of indexing for this element */
374         QCKHASH e_hash;         /* hash value for this element */
375         VALUE e_value;          /* value of association */
376         VALUE e_indices[1];     /* index values (variable length) */
377 };
378
379
380 struct assoc {
381         long a_count;           /* number of elements in the association */
382         long a_size;            /* current size of association hash table */
383         ASSOCELEM **a_table;    /* current hash table for elements */
384 };
385
386
387 extern DLL ASSOC *assocalloc(long initsize);
388 extern DLL ASSOC *assoccopy(ASSOC *ap);
389 extern DLL void assocfree(ASSOC *ap);
390 extern DLL void assocprint(ASSOC *ap, long max_print);
391 extern DLL int assocsearch(ASSOC *ap, VALUE *vp, long start, long end, ZVALUE *index);
392 extern DLL int assocrsearch(ASSOC *ap, VALUE *vp, long start, long end, ZVALUE *index);
393 extern DLL BOOL assoccmp(ASSOC *ap1, ASSOC *ap2);
394 extern DLL VALUE *assocfindex(ASSOC *ap, long index);
395 extern DLL VALUE *associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices);
396
397
398 /*
399  * Object actions.
400  */
401 #define OBJ_PRINT       0       /* print the value */
402 #define OBJ_ONE         1       /* create the multiplicative identity */
403 #define OBJ_TEST        2       /* test a value for "zero" */
404 #define OBJ_ADD         3       /* add two values */
405 #define OBJ_SUB         4       /* subtrace one value from another */
406 #define OBJ_NEG         5       /* negate a value */
407 #define OBJ_MUL         6       /* multiply two values */
408 #define OBJ_DIV         7       /* divide one value by another */
409 #define OBJ_INV         8       /* invert a value */
410 #define OBJ_ABS         9       /* take absolute value of value */
411 #define OBJ_NORM        10      /* take the norm of a value */
412 #define OBJ_CONJ        11      /* take the conjugate of a value */
413 #define OBJ_POW         12      /* take the power function */
414 #define OBJ_SGN         13      /* return the sign of a value */
415 #define OBJ_CMP         14      /* compare two values for equality */
416 #define OBJ_REL         15      /* compare two values for inequality */
417 #define OBJ_QUO         16      /* integer quotient of values */
418 #define OBJ_MOD         17      /* remainder of division of values */
419 #define OBJ_INT         18      /* integer part of */
420 #define OBJ_FRAC        19      /* fractional part of */
421 #define OBJ_INC         20      /* increment by one */
422 #define OBJ_DEC         21      /* decrement by one */
423 #define OBJ_SQUARE      22      /* square value */
424 #define OBJ_SCALE       23      /* scale by power of two */
425 #define OBJ_SHIFT       24      /* shift left (or right) by number of bits */
426 #define OBJ_ROUND       25      /* round to specified decimal places */
427 #define OBJ_BROUND      26      /* round to specified binary places */
428 #define OBJ_ROOT        27      /* take nth root of value */
429 #define OBJ_SQRT        28      /* take square root of value */
430 #define OBJ_OR          29      /* take bitwise or of values */
431 #define OBJ_AND         30      /* take bitwise and of values */
432 #define OBJ_NOT         31      /* take logical not of value */
433 #define OBJ_FACT        32      /* factorial or postfix ! */
434 #define OBJ_MIN         33      /* minimum value */
435 #define OBJ_MAX         34      /* maximum value */
436 #define OBJ_SUM         35      /* sum value */
437 #define OBJ_ASSIGN      36      /* assign value */
438 #define OBJ_XOR         37      /* ~ difference of values */
439 #define OBJ_COMP        38      /* ~ complement of value */
440 #define OBJ_CONTENT     39      /* unary hash op */
441 #define OBJ_HASHOP      40      /* binary hash op */
442 #define OBJ_BACKSLASH   41      /* unary backslash op */
443 #define OBJ_SETMINUS    42      /* binary backslash op */
444 #define OBJ_PLUS        43      /* unary + op */
445 #define OBJ_MAXFUNC     43      /* highest function */
446
447
448 /*
449  * Definition of an object type.
450  * This is actually a varying sized structure.
451  */
452 typedef struct {
453         int oa_index;                   /* index of object type */
454         int oa_count;                   /* number of elements defined */
455         long oa_indices[OBJ_MAXFUNC+1]; /* function indices for actions */
456         int oa_elements[1];             /* element indices (MUST BE LAST) */
457 } OBJECTACTIONS;
458
459 #define objectactionsize(elements) \
460         (sizeof(OBJECTACTIONS) + ((elements) - 1) * sizeof(int))
461
462
463 /*
464  * Structure of an object.
465  * This is actually a varying sized structure.
466  * However, there are always at least USUAL_ELEMENTS values in the object.
467  */
468 struct object {
469         OBJECTACTIONS *o_actions;       /* action table for this object */
470         VALUE o_table[USUAL_ELEMENTS];  /* object values (MUST BE LAST) */
471 };
472
473 #define objectsize(elements) \
474         (sizeof(OBJECT) + ((elements) - USUAL_ELEMENTS) * sizeof(VALUE))
475
476
477 extern DLL OBJECT *objcopy(OBJECT *op);
478 extern DLL OBJECT *objalloc(long index);
479 extern DLL VALUE objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3);
480 extern DLL void objfree(OBJECT *op);
481 extern DLL int addelement(char *name);
482 extern DLL int defineobject(char *name, int indices[], int count);
483 extern DLL int checkobject(char *name);
484 extern DLL void showobjfuncs(void);
485 extern DLL void showobjtypes(void);
486 extern DLL int findelement(char *name);
487 extern DLL char *objtypename(unsigned long index);
488 extern DLL int objoffset(OBJECT *op, long index);
489
490
491 /*
492  * Configuration parameter name and type.
493  */
494 extern NAMETYPE configs[];
495 extern DLL void config_value(CONFIG *cfg, int type, VALUE *ret);
496 extern DLL void setconfig(int type, VALUE *vp);
497 extern DLL void config_print(CONFIG *cfg);      /* the CONFIG to print */
498
499
500 /*
501  * size, memsize and sizeof support
502  */
503 extern DLL long elm_count(VALUE *vp);
504 extern DLL long lsizeof(VALUE *vp);
505 extern DLL long memsize(VALUE *vp);
506
507 /*
508  * String functions
509  */
510 extern DLL STRING *stringadd(STRING *, STRING *);
511 extern DLL STRING *stringcopy(STRING *);
512 extern DLL STRING *stringsub(STRING *, STRING *);
513 extern DLL STRING *stringmul(NUMBER *, STRING *);
514 extern DLL STRING *stringand(STRING *, STRING *);
515 extern DLL STRING *stringor(STRING *, STRING *);
516 extern DLL STRING *stringxor(STRING *, STRING *);
517 extern DLL STRING *stringdiff(STRING *, STRING *);
518 extern DLL STRING *stringsegment(STRING *, long, long);
519 extern DLL STRING *stringshift(STRING *, long);
520 extern DLL STRING *stringcomp(STRING *);
521 extern DLL STRING *stringneg(STRING *);
522 extern DLL STRING *stringcpy(STRING *, STRING *);
523 extern DLL STRING *stringncpy(STRING *, STRING *, long);
524 extern DLL long stringcontent(STRING *s);
525 extern DLL long stringlowbit(STRING *s);
526 extern DLL long stringhighbit(STRING *s);
527 extern DLL BOOL stringcmp(STRING *, STRING *);
528 extern DLL BOOL stringrel(STRING *, STRING *);
529 extern DLL int stringbit(STRING *, long);
530 extern DLL BOOL stringtest(STRING *);
531 extern DLL int stringsetbit(STRING *, long, BOOL);
532 extern DLL int stringsearch(STRING *, STRING *, long, long, ZVALUE *);
533 extern DLL int stringrsearch(STRING *, STRING *, long, long, ZVALUE *);
534
535 #endif /* !__VALUE_H__ */