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