-
Notifications
You must be signed in to change notification settings - Fork 51
/
hash.c
1058 lines (920 loc) · 31.5 KB
/
hash.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* hash - one-way hash routines
*
* Copyright (C) 1999-2007,2021-2023 Landon Curt Noll
*
* Calc is open software; you can redistribute it and/or modify it under
* the terms of the version 2.1 of the GNU Lesser General Public License
* as published by the Free Software Foundation.
*
* Calc is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
* Public License for more details.
*
* A copy of version 2.1 of the GNU Lesser General Public License is
* distributed with calc under the filename COPYING-LGPL. You should have
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Under source code control: 1995/11/23 05:13:11
* File existed as early as: 1995
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
#include <stdio.h>
#include "have_string.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "calc.h"
#include "alloc.h"
#include "value.h"
#include "zrand.h"
#include "zrandom.h"
#include "hash.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
/*
* external hash_setup functions
*/
E_FUNC void shs_init_state(HASH*);
E_FUNC void sha1_init_state(HASH*);
E_FUNC void MD5_init_state(HASH*);
/*
* hash_long can deal with bool's, int's, FLAGS's and LEN's
*/
#define hash_bool(type, val, state) (hash_long((type), (long)(val), (state)))
#define hash_int(type, val, state) (hash_long((type), (long)(val), (state)))
#define hash_flag(type, val, state) (hash_long((type), (long)(val), (state)))
#define hash_len(type, val, state) (hash_long((type), (long)(val), (state)))
/*
* hash_setup - setup the hash state for a given hash
*/
STATIC struct hash_setup {
int type; /* hash type (see XYZ_HASH_TYPE below) */
void (*init_state)(HASH*); /* initialize a hash state */
} htbl[] = {
{ SHA1_HASH_TYPE, sha1_init_state }, /* SHA-1 / SHA-1 */
{ -1, NULL } /* must be last */
};
/*
* hash_init - initialize a hash state
*
* given:
* type - hash type (see hash.h)
* state - the state to initialize, or NULL to malloc it
*
* returns:
* initialized state
*/
HASH *
hash_init(int type, HASH *state)
{
int i;
/*
* malloc if needed
*/
if (state == NULL) {
state = (HASH *)malloc(sizeof(HASH));
if (state == NULL) {
math_error("hash_init: cannot malloc HASH");
not_reached();
}
}
/*
* clear hash value
*/
memset((void*)state, 0, sizeof(HASH));
state->bytes = true;
/*
* search for the hash_setup function
*/
for (i=0; htbl[i].init_state != NULL; ++i) {
/* if we found the state that we were looking for */
if (type == htbl[i].type) {
/* initialize state and return */
(htbl[i].init_state)(state);
/* firewall - MAX_CHUNKSIZE must be >= chunksize */
if (state->chunksize > MAX_CHUNKSIZE) {
math_error(
"internal error: MAX_CHUNKSIZE is too small");
not_reached();
}
return state;
}
}
/*
* no such hash state
*/
math_error("internal error: hash type not found in htbl[]");
return NULL;
}
/*
* hash_free - free the hash state
*/
void
hash_free(HASH *state)
{
/*
* do nothing if state is NULL
*/
if (state == NULL) {
return;
}
/*
* free main state and return
*/
free(state);
return;
}
/*
* hash_copy - copy a hash state
*
* given:
* state - the state to copy
*
* returns:
* pointer to copy of state
*/
HASH *
hash_copy(HASH *state)
{
HASH *hnew; /* copy of state */
/*
* malloc new state
*/
hnew = (HASH *)malloc(sizeof(HASH));
if (hnew == NULL) {
math_error("hash_init: cannot malloc HASH");
not_reached();
}
/*
* duplicate state
*/
memcpy((void *)hnew, (void *)state, sizeof(HASH));
return hnew;
}
/*
* hash_cmp - compare hash values
*
* given:
* a first hash state
* b second hash state
*
* returns:
* true => hash states are different
* false => hash states are the same
*/
int
hash_cmp(HASH *a, HASH *b)
{
/*
* firewall and quick check
*/
if (a == b) {
/* pointers to the same object */
return false;
}
if (a == NULL || b == NULL) {
/* one pointer is NULL, so they differ */
return true;
}
if (a->cmp == NULL || b->cmp == NULL) {
/* one cmp function is NULL, so they differ */
return true;
}
/*
* compare hash types
*/
if (a->hashtype != b->hashtype) {
/* different hash types are different */
return true;
}
/*
* perform the hash specific comparison
*/
return ((a->cmp)(a,b));
}
/*
* hash_print - print the name and value of a hash
*
* given:
* state the hash state to print name and value of
*/
void
hash_print(HASH *state)
{
/* print the hash */
(state->print)(state);
return;
}
/*
* hash_final - finalize the state of a hash and return a ZVALUE
*
* given:
* state the hash state to finalize
*
* returns:
* hash state as a ZVALUE
*/
ZVALUE
hash_final(HASH *state)
{
/* return the finalized the hash value */
return (state->final)(state);
}
/*
* hash_long - note a long value
*
* given:
* type - hash type (see hash.h)
* longval - a long value
* state - the state to hash
*
* returns:
* the new state
*
* This function will hash a long value as if it were a 64 bit value.
* The input is a long. If a long is smaller than 64 bits, we will
* hash a final 32 bits of zeros.
*
* This function is OK to hash bool's, unsigned long's, unsigned int's
* signed int's as well as FLAG's and LEN's.
*/
HASH *
hash_long(int type, long longval, HASH *state)
{
long lval[64/LONG_BITS]; /* 64 bits of longs */
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* setup for the hash_long
*/
(state->chkpt)(state);
state->bytes = false; /* data to be read as words */
/*
* catch the zero numeric value special case
*/
if (longval == 0) {
/* note a zero numeric value and return */
(state->note)(HASH_ZERO(state->base), state);
return state;
}
/*
* prep for a long value hash
*/
(state->note)(state->base, state);
/*
* hash as if we have a 64 bit value
*/
memset((char *)lval, 0, sizeof(lval));
lval[0] = longval;
(state->update)(state, (USB8 *)lval, sizeof(lval));
/*
* all done
*/
return state;
}
/*
* hash_zvalue - hash a ZVALUE
*
* given:
* type - hash type (see hash.h)
* zval - the ZVALUE
* state - the state to hash or NULL
*
* returns:
* the new state
*/
HASH *
hash_zvalue(int type, ZVALUE zval, HASH *state)
{
#if CALC_BYTE_ORDER == BIG_ENDIAN && BASEB == 16
int full_lim; /* HALFs in whole chunks in zval */
int chunkhalf; /* size of half buffer in HALFs */
int i;
int j;
#endif
#if BASEB == 16
HALF half[MAX_CHUNKSIZE]; /* For endian reversal */
#endif
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* setup for the ZVALUE hash
*/
(state->chkpt)(state);
state->bytes = false; /* data to be read as words */
/*
* catch the zero numeric value special case
*/
if (ziszero(zval)) {
/* note a zero numeric value and return */
(state->note)(HASH_ZERO(state->base), state);
return state;
}
/*
* prep for a ZVALUE hash
*/
(state->note)(HASH_ZVALUE(state->base), state);
/* note if we have a negative value */
if (zisneg(zval)) {
(state->note)(HASH_NEG(state->base), state);
}
#if CALC_BYTE_ORDER == BIG_ENDIAN && BASEB == 16
/*
* hash full chunks
*
* We need to convert the array of HALFs into canonical architectural
* independent form -- 32 bit arrays. Because we have 16 bit values
* in Big Endian form, we need to swap 16 bit values so that they
* appear as 32 bit Big Endian values.
*/
chunkhalf = state->chunksize/sizeof(HALF);
full_lim = (zval.len / chunkhalf) * chunkhalf;
for (i=0; i < full_lim; i += chunkhalf) {
/* HALF swap copy a chunk into a data buffer */
for (j=0; j < chunkhalf; j += 2) {
half[j] = zval.v[i+j+1];
half[j+1] = zval.v[i+j];
}
(state->update)(state, (USB8*) half, state->chunksize);
}
/*
* hash the final partial chunk (if any)
*
* We need to convert the array of HALFs into canonical architectural
* independent form -- 32 bit arrays. Because we have 16 bit values
* in Big Endian form, we need to swap 16 bit values so that they
* appear as 32 bit Big Endian values.
*/
if (zval.len > full_lim) {
for (j=0; j < zval.len-full_lim-1; j += 2) {
half[j] = zval.v[full_lim+j+1];
half[j+1] = zval.v[full_lim+j];
}
if (j < zval.len-full_lim) {
half[j] = (HALF)0;
half[j+1] = zval.v[zval.len-1];
--full_lim;
}
(state->update)(state, (USB8 *) half,
(zval.len-full_lim)*sizeof(HALF));
}
#else
/*
* hash the array of HALFs
*
* The array of HALFs is equivalent to the canonical architectural
* independent form. We either have 32 bit HALFs (in which case
* we do not case the byte order) or we have 16 bit HALFs in Little
* Endian order (which happens to be laid out in the same order as
* 32 bit values).
*/
(state->update)(state, (USB8 *)zval.v, zval.len*sizeof(HALF));
#if BASEB == 16
if (zval.len & 1) { /* padding to complete word */
half[0] = 0;
(state->update)(state, (USB8 *) half, 2);
}
#endif
#endif
/*
* all done
*/
return state;
}
/*
* hash_number - hash a NUMBER
*
* given:
* type - hash type (see hash.h)
* n - the NUMBER
* state - the state to hash or NULL
*
* returns:
* the new state
*/
HASH *
hash_number(int type, void *n, HASH *state)
{
NUMBER *number = (NUMBER *)n; /* n as a NUMBER pointer */
bool sign; /* sign of the denominator */
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* setup for the NUMBER hash
*/
(state->chkpt)(state);
state->bytes = false;
/*
* process the numerator
*/
state = hash_zvalue(type, number->num, state);
/*
* if the NUMBER is not an integer, process the denominator
*/
if (qisfrac(number)) {
/* note the division */
(state->note)(HASH_DIV(state->base), state);
/* hash denominator as positive -- just in case */
sign = number->den.sign;
number->den.sign = 0;
/* hash the denominator */
state = hash_zvalue(type, number->den, state);
/* restore the sign */
number->den.sign = sign;
}
/*
* all done
*/
return state;
}
/*
* hash_complex - hash a COMPLEX
*
* given:
* type - hash type (see hash.h)
* c - the COMPLEX
* state - the state to hash or NULL
*
* returns:
* the new state
*/
HASH *
hash_complex(int type, void *c, HASH *state)
{
COMPLEX *complex = (COMPLEX *)c; /* c as a COMPLEX pointer */
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* setup for the COMPLEX hash
*/
(state->chkpt)(state);
state->bytes = false;
/*
* catch the zero special case
*/
if (ciszero(complex)) {
/* note a zero numeric value and return */
(state->note)(HASH_ZERO(state->base), state);
return state;
}
/*
* process the real value if not pure imaginary
*
* We will ignore the real part if the value is of the form 0+xi.
*/
if (!qiszero(complex->real)) {
state = hash_number(type, complex->real, state);
}
/*
* if the NUMBER is not real, process the imaginary value
*
* We will ignore the imaginary part of the value is of the form x+0i.
*/
if (!cisreal(complex)) {
/* note the sqrt(-1) */
(state->note)(HASH_COMPLEX(state->base), state);
/* hash the imaginary value */
state = hash_number(type, complex->imag, state);
}
/*
* all done
*/
return state;
}
/*
* hash_str - hash a null-terminated string
*
* given:
* type - hash type (see hash.h)
* str - the string
* state - the state to hash or NULL
*
* returns:
* the new state
*/
HASH *
hash_str(int type, char *str, HASH *state)
{
size_t len; /* string length */
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* setup for the string hash
*/
if (!state->bytes) {
(state->chkpt)(state);
state->bytes = true;
}
len = strlen(str);
/*
* hash the string
*/
(state->update)(state, (USB8*)str, len);
/*
* all done
*/
return state;
}
/*
* hash_STR - hash a STRING
*
* given:
* type - hash type (see hash.h)
* str - the STRING
* state - the state to hash or NULL
*
* returns:
* the new state
*/
HASH *
hash_STR(int type, STRING *str, HASH *state)
{
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* setup for the string hash
*/
if (!state->bytes) {
(state->chkpt)(state);
state->bytes = true;
}
/*
* hash the string
*/
(state->update)(state, (USB8*) str->s_str, (USB32) str->s_len);
/*
* all done
*/
return state;
}
/*
* hash_usb8 - hash an array of USB8s
*
* given:
* type - hash type (see hash.h)
* byte - pointer to an array of USB8s
* len - number of USB8s to hash
* state - the state to hash or NULL
*
* returns:
* the new state
*/
HASH *
hash_usb8(int type, USB8 *byte, int len, HASH *state)
{
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* setup for the string hash
*/
if (!state->bytes) {
(state->chkpt)(state);
state->bytes = true;
}
/*
* hash the array of octets
*/
(state->update)(state, byte, (USB32)len);
/*
* all done
*/
return state;
}
/*
* hash_value - hash a value
*
* given:
* type - hash type (see hash.h)
* v - the value
* state - the state to hash or NULL
*
* returns:
* the new state
*/
HASH *
hash_value(int type, void *v, HASH *state)
{
LISTELEM *ep; /* list element pointer */
ASSOCELEM **assochead; /* association chain head */
ASSOCELEM *aep; /* current association value */
ASSOCELEM *nextaep; /* next association value */
VALUE *value = (VALUE *)v; /* v cast to a VALUE */
VALUE *vp; /* pointer to next OBJ table value */
ZVALUE fileval; /* size, position, dev, inode of a file */
int i;
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* process the value type
*/
switch (value->v_type) {
case V_NULL:
(state->chkpt)(state);
state->bytes = true;
break;
case V_INT:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
/* hash as if we have a 64 bit value */
state = hash_int(type, value->v_int, state);
break;
case V_NUM:
/* hash this type */
state = hash_number(type, value->v_num, state);
break;
case V_COM:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
/* hash this type */
state = hash_complex(type, value->v_com, state);
break;
case V_ADDR:
/* there is nothing to setup, simply hash what we point at */
state = hash_value(type, value->v_addr, state);
break;
case V_STR:
/* strings have no setup */
/* hash this type */
state = hash_STR(type, value->v_str, state);
break;
case V_MAT:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
state->bytes = true;
/* hash all the elements of the matrix */
for (i=0; i < value->v_mat->m_size; ++i) {
/* hash the next matrix value */
state = hash_value(type,
value->v_mat->m_table+i, state);
state->bytes = false; /* as if reading words */
}
break;
case V_LIST:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
/* hash all the elements of the list */
for (i=0, ep = value->v_list->l_first;
ep != NULL && i < value->v_list->l_count;
++i, ep = ep->e_next) {
/* hash the next list value */
state = hash_value(type, &ep->e_value, state);
state->bytes = false; /* as if reading words */
}
break;
case V_ASSOC:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
state->bytes = true;
/* hash the association */
assochead = value->v_assoc->a_table;
for (i = 0; i < value->v_assoc->a_size; i++) {
nextaep = *assochead;
while (nextaep) {
aep = nextaep;
nextaep = aep->e_next;
/* hash the next association value */
state = hash_value(type, &aep->e_value, state);
state->bytes = false; /* as if reading words */
}
assochead++;
}
break;
case V_OBJ:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
state->bytes = true; /* reading bytes */
/* hash the object name and then the element values */
state = hash_str(type, objtypename(
value->v_obj->o_actions->oa_index), state);
(state->chkpt)(state);
for (i=value->v_obj->o_actions->oa_count,
vp=value->v_obj->o_table;
i-- > 0;
vp++) {
/* hash the next object value */
state = hash_value(type, vp, state);
state->bytes = false; /* as if reading words */
}
break;
case V_FILE:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
/* hash file length if possible */
if (getsize(value->v_file, &fileval) == 0) {
state = hash_zvalue(type, fileval, state);
zfree(fileval);
} else {
/* hash -1 for invalid length */
state = hash_long(type, (long)-1, state);
}
/* hash the file position if possible */
if (getloc(value->v_file, &fileval) == 0) {
state = hash_zvalue(type, fileval, state);
zfree(fileval);
} else {
/* hash -1 for invalid location */
state = hash_long(type, (long)-1, state);
}
/* hash the file device if possible */
if (get_device(value->v_file, &fileval) == 0) {
state = hash_zvalue(type, fileval, state);
zfree(fileval);
} else {
/* hash -1 for invalid device */
state = hash_long(type, (long)-1, state);
}
/* hash the file inode if possible */
if (get_inode(value->v_file, &fileval) == 0) {
state = hash_zvalue(type, fileval, state);
zfree(fileval);
} else {
/* hash -1 for invalid inode */
state = hash_long(type, (long)-1, state);
}
break;
case V_RAND:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
/* hash the RAND state */
state = hash_int(type, value->v_rand->seeded, state);
state = hash_int(type, value->v_rand->bits, state);
(state->update)(state,
(USB8 *)value->v_rand->buffer, SLEN*FULL_BITS/8);
state = hash_int(type, value->v_rand->j, state);
state = hash_int(type, value->v_rand->k, state);
state = hash_int(type, value->v_rand->need_to_skip, state);
(state->update)(state,
(USB8 *)value->v_rand->slot, SCNT*FULL_BITS/8);
(state->update)(state,
(USB8*)value->v_rand->shuf, SHUFLEN*FULL_BITS/8);
state->bytes = false; /* as if reading words */
break;
case V_RANDOM:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
/* hash the RANDOM state */
state = hash_int(type, value->v_random->seeded, state);
state = hash_int(type, value->v_random->bits, state);
(state->update)(state,
(USB8 *)&(value->v_random->buffer), BASEB/8);
state = hash_zvalue(type, value->v_random->r, state);
state = hash_zvalue(type, value->v_random->n, state);
state->bytes = false; /* as if reading words */
break;
case V_CONFIG:
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
/* hash the CONFIG state */
state = hash_int(type, value->v_config->outmode, state);
state = hash_int(type, value->v_config->outmode2, state);
state = hash_long(type,(long)value->v_config->outdigits, state);
state = hash_number(type, value->v_config->epsilon, state);
state = hash_long(type,
(long)value->v_config->epsilonprec, state);
state = hash_flag(type, value->v_config->traceflags, state);
state = hash_long(type, (long)value->v_config->maxprint, state);
state = hash_len(type, value->v_config->mul2, state);
state = hash_len(type, value->v_config->sq2, state);
state = hash_len(type, value->v_config->pow2, state);
state = hash_len(type, value->v_config->redc2, state);
state = hash_bool(type, value->v_config->tilde_ok, state);
state = hash_bool(type, value->v_config->tilde_space, state);
state = hash_bool(type, value->v_config->tab_ok, state);
state = hash_long(type, (long)value->v_config->quomod, state);
state = hash_long(type, (long)value->v_config->quo, state);
state = hash_long(type, (long)value->v_config->mod, state);
state = hash_long(type, (long)value->v_config->sqrt, state);
state = hash_long(type, (long)value->v_config->appr, state);
state = hash_long(type, (long)value->v_config->cfappr, state);
state = hash_long(type, (long)value->v_config->cfsim, state);
state = hash_long(type, (long)value->v_config->outround, state);
state = hash_long(type, (long)value->v_config->round, state);
state = hash_long(type, (long)value->v_config->triground, state);
state = hash_bool(type, value->v_config->leadzero, state);
state = hash_bool(type, value->v_config->fullzero, state);
state = hash_long(type,
(long)value->v_config->maxscancount, state);
state = hash_str(type, value->v_config->prompt1, state);
state->bytes = false; /* as if just read words */
state = hash_str(type, value->v_config->prompt2, state);
state->bytes = false; /* as if just read words */
state = hash_int(type, value->v_config->blkmaxprint, state);
state = hash_bool(type, value->v_config->blkverbose, state);
state = hash_int(type, value->v_config->blkbase, state);
state = hash_int(type, value->v_config->blkfmt, state);
state = hash_long(type,
(long)value->v_config->resource_debug, state);
state = hash_long(type,
(long)value->v_config->calc_debug, state);
state = hash_long(type,
(long)value->v_config->user_debug, state);
state = hash_bool(type, value->v_config->verbose_quit, state);
state = hash_int(type, value->v_config->ctrl_d, state);
state = hash_str(type, value->v_config->program, state);
state = hash_str(type, value->v_config->base_name, state);
state = hash_bool(type, value->v_config->windows, state);
state = hash_bool(type, value->v_config->cygwin, state);
state = hash_bool(type, value->v_config->compile_custom, state);
if (value->v_config->allow_custom != NULL &&
*(value->v_config->allow_custom)) {
state = hash_bool(type, true, state);
} else {
state = hash_bool(type, false, state);