Unnamed Fossil Project

Check-in [1c2ae75e99]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1c2ae75e99155e6cbd1eb5e60b84d2c12206b633
User & Date: monster 2012-09-01 16:12:43
Context
2012-09-24
08:39
updated version Leaf check-in: 0015af0883 user: monster tags: trunk
2012-09-01
16:12
fixes check-in: 1c2ae75e99 user: monster tags: trunk
2012-08-22
11:14
updated check-in: f23cfce1ab user: monster tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to buffer.hc.

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
    
    E = p + len;
    
    while ( p != E )
      {
        do 
          { 
            if ( *p < 30 || *p == '\\' || *p == brk || *p == '"' || *p == '\'' ) 

              break; 
            ++p; 
          } 
        while ( p != E );
        
        if ( q != p )
          Buffer_Append(bf,q,p-q);
................................................................................
        
        if ( p != E )
          {
            if ( *p == '\n' ) Buffer_Append(bf,"\\n",2);
            else if ( *p == '\t' ) Buffer_Append(bf,"\\t",2);
            else if ( *p == '\r' ) Buffer_Append(bf,"\\r",2);
            else if ( *p == '\\' ) Buffer_Append(bf,"\\\\",2);
            else if ( *p == brk )  
              { 
                Buffer_Fill_Append(bf,'\\',1);
                Buffer_Fill_Append(bf,brk,1);
              }
            else if ( *p == '"' ) 
              Buffer_Append(bf,"\\\"",2);
            else if ( *p == '\'' ) 
              Buffer_Append(bf,"\\'",2);
            else if ( *p < 30 ) 
              {
                Buffer_Append(bf,"\\x",2);
                Buffer_Hex_Append(bf,p,1);
              }
          







|
>







 







|




|

|







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
    
    E = p + len;
    
    while ( p != E )
      {
        do 
          { 
            if ( *p < 30 || *p == '\\' 
              || (brk ? *p == brk : ( *p == '"' || *p == '\'' )) ) 
              break; 
            ++p; 
          } 
        while ( p != E );
        
        if ( q != p )
          Buffer_Append(bf,q,p-q);
................................................................................
        
        if ( p != E )
          {
            if ( *p == '\n' ) Buffer_Append(bf,"\\n",2);
            else if ( *p == '\t' ) Buffer_Append(bf,"\\t",2);
            else if ( *p == '\r' ) Buffer_Append(bf,"\\r",2);
            else if ( *p == '\\' ) Buffer_Append(bf,"\\\\",2);
            else if ( brk && *p == brk )  
              { 
                Buffer_Fill_Append(bf,'\\',1);
                Buffer_Fill_Append(bf,brk,1);
              }
            else if ( !brk && *p == '"' ) 
              Buffer_Append(bf,"\\\"",2);
            else if ( !brk && *p == '\'' ) 
              Buffer_Append(bf,"\\'",2);
            else if ( *p < 30 ) 
              {
                Buffer_Append(bf,"\\x",2);
                Buffer_Hex_Append(bf,p,1);
              }
          

Changes to crc.hc.

56
57
58
59
60
61
62




63
64
65
66
67




















68
69
70
71
72
73
74
# define _YO_CRC_BUILTIN_CODE(Code) Code
# define _YO_CRC_EXTERN 
#else
# define _YO_CRC_BUILTIN_CODE(Code)
# define _YO_CRC_EXTERN extern 
#endif





_YO_CRC_EXTERN char Oj_Digest_Update_OjMID[] _YO_CRC_BUILTIN_CODE( = "digest-update/@*i"); 
void Oj_Digest_Update(void *dgst,void *buf,int L) _YO_CRC_BUILTIN_CODE(
  { ((void(*)(void*,void*,int))Yo_Find_Method_Of(&dgst,Oj_Digest_Update_OjMID,YO_RAISE_ERROR))
        (dgst,buf,L); });





















uint_t    Crc_32(uint_t crc, void *, int len);
ushort_t  Crc_16(ushort_t crc, void *, int len);
byte_t    Crc_8(byte_t crc, void *, int len);
byte_t    Crc_8_Of_Cstr(char *S);
uint_t    Adler_32(uint_t adler, void *, int len);

#define Digest_Crc_32(Data,Len) Crc_32(0,Data,Len)







>
>
>
>

|
|
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
# define _YO_CRC_BUILTIN_CODE(Code) Code
# define _YO_CRC_EXTERN 
#else
# define _YO_CRC_BUILTIN_CODE(Code)
# define _YO_CRC_EXTERN extern 
#endif

_YO_CRC_EXTERN char Oj_Digest_Size_OjCID[] _YO_CRC_BUILTIN_CODE( = "#digest-size/i"); 
int Oj_Digest_Size(void *hash) _YO_CRC_BUILTIN_CODE(
  { return Yo_Find_Constant_Of(hash,Oj_Digest_Size_OjCID,YO_RAISE_ERROR,0); });
  
_YO_CRC_EXTERN char Oj_Digest_Update_OjMID[] _YO_CRC_BUILTIN_CODE( = "digest-update/@*i"); 
void Oj_Digest_Update(void *hash,void *buf,int L) _YO_CRC_BUILTIN_CODE(
  { ((void(*)(void*,void*,int))Yo_Find_Method_Of(&hash,Oj_Digest_Update_OjMID,YO_RAISE_ERROR))
        (hash,buf,L); });

_YO_CRC_EXTERN char Oj_Digest_Start_OjMID[] _YO_CRC_BUILTIN_CODE( = "digest-start/@"); 
void Oj_Digest_Start(void *hash) _YO_CRC_BUILTIN_CODE(
  { ((void(*)(void*))Yo_Find_Method_Of(&hash,Oj_Digest_Start_OjMID,YO_RAISE_ERROR))
        (hash); });

_YO_CRC_EXTERN char Oj_Digest_Finish_OjMID[] _YO_CRC_BUILTIN_CODE( = "digest-finish/@*"); 
void *Oj_Digest_Finish(void *hash, void *out) _YO_CRC_BUILTIN_CODE(
  { return ((void*(*)(void*,void*))Yo_Find_Method_Of(&hash,Oj_Digest_Finish_OjMID,YO_RAISE_ERROR))
        (hash,out); });

char *Oj_Digest_Hex_Finish(void *hash)
#ifdef _YO_CRC_BUILTIN
  { 
    int dgst_size = Oj_Digest_Size(hash);
    byte_t *dgst = alloca(dgst_size);
    return Str_Hex_Encode(Oj_Digest_Finish(hash,dgst),dgst_size);
  }
#endif
  ;
  
uint_t    Crc_32(uint_t crc, void *, int len);
ushort_t  Crc_16(ushort_t crc, void *, int len);
byte_t    Crc_8(byte_t crc, void *, int len);
byte_t    Crc_8_Of_Cstr(char *S);
uint_t    Adler_32(uint_t adler, void *, int len);

#define Digest_Crc_32(Data,Len) Crc_32(0,Data,Len)

Changes to dicto.hc.

172
173
174
175
176
177
178


179
180
181
182
183
184
185
186
...
206
207
208
209
210
211
212


213
214
215
216
217
218
219
220
...
247
248
249
250
251
252
253
254


255
256
257
258
259
260
261
...
263
264
265
266
267
268
269
270

271
272
273
274
275
276
277
...
371
372
373
374
375
376
377

378

379
380
381
382
383
384
385
...
429
430
431
432
433
434
435

436

437
438
439
440
441
442
443
      {
        byte_t hashcode = Dicto_Hash_1(key);
        YO_DICTO_REC **Q = Dicto_Backet(o,hashcode,key);
        if ( *Q )
          {
            YO_DICTO_REC *p = *Q;
            void *self = o;


            void (*destructor)(void*) = Yo_Find_Method_Of(&self,Oj_Destruct_Element_OjMID,0);
            if ( destructor )
              (*destructor)(p->ptr);
            p->ptr = val;
            key = (*Q)->key;
          }
        else
          {
................................................................................
      {
        byte_t hashcode = Dicto_Hash_1(key);
        YO_DICTO_REC **Q = Dicto_Backet(o,hashcode,key);
        if ( *Q )
          {
            YO_DICTO_REC *p = *Q;
            void *self = o;


            void (*destructor)(void*) = Yo_Find_Method_Of(&self,Oj_Destruct_Element_OjMID,0);
            if ( destructor )
              (*destructor)(p->ptr);
            *Q = (*Q)->next;
            free(p);
            STRICT_REQUIRE ( o->count >= 1 );
            --o->count;
          }
................................................................................
#endif
  ;

void *Dicto_Take(YO_DICTO *o, char *key)
#ifdef _YO_ARRAY_BUILTIN
  {
    void *self = o;
    void (*destruct)(void *) = Yo_Find_Method_Of(&self,Oj_Destruct_Element_OjMID,YO_RAISE_ERROR);


    void *Q = Dicto_Take_Npl(o,key);
    
    if ( Q )
      Yo_Pool_Ptr(Q,destruct);
      
    return Q;
  }
................................................................................
  ;

void Dicto_Clear(YO_DICTO *o)
#ifdef _YO_DICTO_BUILTIN  
  {
    int i;
    void *self = o;
    void (*destructor)(void*) = Yo_Find_Method_Of(&self,Oj_Destruct_Element_OjMID,0);

    
    if ( o->table )
      for ( i = 0; i < o->width; ++i )
        while ( o->table[i] )
          {
            YO_DICTO_REC *Q = o->table[i];
            o->table[i] = Q->next;
................................................................................
    return dicto;
  }
#endif
  ;

typedef void (*dicto_apply_filter_t)(char *,void *,void *);


void Dicto_Apply(YO_DICTO *o, /*dicto_apply_filter_t*/ void *_filter, void *state)  

#ifdef _YO_DICTO_BUILTIN  
  {
    int i;
    YO_DICTO_REC *nrec;
    dicto_apply_filter_t filter = _filter;
    if ( o && o->table ) 
      for ( i = 0; i < o->width; ++i )
................................................................................
    return a;
  }
#endif
  ;
  
typedef void (*dicto_format_printer_t)(YO_BUFFER *bf,void *S);


char *Dicto_Format(YO_DICTO *o, /*dicto_format_printer_t*/ void *_print, YO_BUFFER *_bf, int pretty)

#ifdef _YO_DICTO_BUILTIN  
  {
    int start = 0, i, j=0;
    YO_BUFFER *bf = _bf;
    YO_DICTO_REC *nrec;
    dicto_format_printer_t print = _print;








>
>
|







 







>
>
|







 







|
>
>







 







|
>







 







>
|
>







 







>
|
>







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
...
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
...
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
      {
        byte_t hashcode = Dicto_Hash_1(key);
        YO_DICTO_REC **Q = Dicto_Backet(o,hashcode,key);
        if ( *Q )
          {
            YO_DICTO_REC *p = *Q;
            void *self = o;
            void (*destructor)(void*) = 
                               Yo_Find_Method_Of(&self
                                                ,Oj_Destruct_Element_OjMID,0);
            if ( destructor )
              (*destructor)(p->ptr);
            p->ptr = val;
            key = (*Q)->key;
          }
        else
          {
................................................................................
      {
        byte_t hashcode = Dicto_Hash_1(key);
        YO_DICTO_REC **Q = Dicto_Backet(o,hashcode,key);
        if ( *Q )
          {
            YO_DICTO_REC *p = *Q;
            void *self = o;
            void (*destructor)(void*) = 
                               Yo_Find_Method_Of(&self
                                                ,Oj_Destruct_Element_OjMID,0);
            if ( destructor )
              (*destructor)(p->ptr);
            *Q = (*Q)->next;
            free(p);
            STRICT_REQUIRE ( o->count >= 1 );
            --o->count;
          }
................................................................................
#endif
  ;

void *Dicto_Take(YO_DICTO *o, char *key)
#ifdef _YO_ARRAY_BUILTIN
  {
    void *self = o;
    void (*destruct)(void *) = Yo_Find_Method_Of(&self
                                                ,Oj_Destruct_Element_OjMID
                                                ,YO_RAISE_ERROR);
    void *Q = Dicto_Take_Npl(o,key);
    
    if ( Q )
      Yo_Pool_Ptr(Q,destruct);
      
    return Q;
  }
................................................................................
  ;

void Dicto_Clear(YO_DICTO *o)
#ifdef _YO_DICTO_BUILTIN  
  {
    int i;
    void *self = o;
    void (*destructor)(void*) = Yo_Find_Method_Of(&self
                                                 ,Oj_Destruct_Element_OjMID,0);
    
    if ( o->table )
      for ( i = 0; i < o->width; ++i )
        while ( o->table[i] )
          {
            YO_DICTO_REC *Q = o->table[i];
            o->table[i] = Q->next;
................................................................................
    return dicto;
  }
#endif
  ;

typedef void (*dicto_apply_filter_t)(char *,void *,void *);

void Dicto_Apply(YO_DICTO *o
                , /*dicto_apply_filter_t*/ void *_filter
                , void *state)  
#ifdef _YO_DICTO_BUILTIN  
  {
    int i;
    YO_DICTO_REC *nrec;
    dicto_apply_filter_t filter = _filter;
    if ( o && o->table ) 
      for ( i = 0; i < o->width; ++i )
................................................................................
    return a;
  }
#endif
  ;
  
typedef void (*dicto_format_printer_t)(YO_BUFFER *bf,void *S);

char *Dicto_Format(YO_DICTO *o
                  , /*dicto_format_printer_t*/ void *_print
                  , YO_BUFFER *_bf, int pretty)
#ifdef _YO_DICTO_BUILTIN  
  {
    int start = 0, i, j=0;
    YO_BUFFER *bf = _bf;
    YO_DICTO_REC *nrec;
    dicto_format_printer_t print = _print;

Changes to md5.hc.

51
52
53
54
55
56
57



58
59
60
61
62
63
64
..
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
...
162
163
164
165
166
167
168
169

170

171

172

173
174
175
176
177
178
179
...
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

#ifdef _LIBYOYO
#define _YO_MD5_BUILTIN
#endif

#include "yoyo.hc"
#include "crc.hc"




typedef struct _YO_MD5
  {
    uint_t state[4];   /* state (ABCD) */
    uint_t count[2];   /* number of bits, modulo 2^64 (lsb first) */
    int    finished;
    byte_t buffer[64];
................................................................................
void *Md5_Finish(YO_MD5 *md5, void *digest);

void *Md5_Init()
#ifdef _YO_MD5_BUILTIN
  {
    static YO_FUNCTABLE funcs[] = 
      { {0},

        {Oj_Clone_OjMID, Md5_Clone },
        {Oj_Digest_Update_OjMID, Md5_Update },


        {0}};
    
    YO_MD5 *md5 = __Object(sizeof(YO_MD5),funcs);
    return Md5_Start(md5);
  }
#endif
  ;


#define YO_MD5_INITIALIZER {{0x67452301,0xefcdab89,0x98badcfe,0x10325476},{0},0,{0}}




















void *Md5_Digest(void *data, int len, void *digest)
#ifdef _YO_MD5_BUILTIN
  {
    YO_MD5 md5 = YO_MD5_INITIALIZER;
    Md5_Update(&md5,data,len);
    return Md5_Finish(&md5,digest);
................................................................................
  }
#endif
  ;

void *Md5_Digest_Digest(void *data, int len, void *digest)
#ifdef _YO_MD5_BUILTIN
  {
    byte_t tmp[16];
    YO_MD5 md5 = YO_MD5_INITIALIZER;
    Md5_Digest(data,len,tmp);
    Md5_Update(&md5,tmp,16);
    Md5_Update(&md5,data,len);
    return Md5_Finish(&md5,digest);
  }
#endif
  ;

#define Md5_Digest_Of(Data,Len) Md5_Digest(Data,Len,0)
................................................................................
  #endif

  #define ROTATE_LEFT(x,n) (((x) << (n)) | ((x) >> (32-(n))))
  #define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
  #define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
  #define H(x, y, z) ((x) ^ (y) ^ (z))
  #define I(x, y, z) ((y) ^ ((x) | ~(z)))
  #define FF(a, b, c, d, x, s, ac) (a) += F((b), (c), (d)) + (x) + (ac); (a) = ROTATE_LEFT((a), (s)) + (b)

  #define GG(a, b, c, d, x, s, ac) (a) += G((b), (c), (d)) + (x) + (ac); (a) = ROTATE_LEFT((a), (s)) + (b)

  #define HH(a, b, c, d, x, s, ac) (a) += H((b), (c), (d)) + (x) + (ac); (a) = ROTATE_LEFT((a), (s)) + (b)

  #define II(a, b, c, d, x, s, ac) (a) += I((b), (c), (d)) + (x) + (ac); (a) = ROTATE_LEFT((a), (s)) + (b)


  void Md5_Internal_Transform(YO_MD5 *md5, void *block)
    {
      enum _S_constants
        {
          S11 = 7,
          S12 = 12,
................................................................................
  }
#endif
  ;

void *Hmac_Md5_Finish(YO_HMAC_MD5 *hmac, void *digest)
#ifdef _YO_MD5_BUILTIN
  {
    byte_t tmpb[16];
    Md5_Finish(&hmac->md5,tmpb);
    Md5_Start(&hmac->md5);
    Md5_Update(&hmac->md5,&hmac->opad,64);
    Md5_Update(&hmac->md5,tmpb,16);
    memset(tmpb,0,16);
    return Md5_Finish(&hmac->md5,digest);
  }









#endif
  ;

void *Hmac_Md5_Digest(void *data, int len, void *key, int key_len, void *digest)
#ifdef _YO_MD5_BUILTIN
  {
    YO_HMAC_MD5 hmac5;
    Hmac_Md5_Start(&hmac5,key,key_len);
    Md5_Update(&hmac5.md5,data,len);
    return Hmac_Md5_Finish(&hmac5,digest);
  }
#endif
  ;












void *Hmac_Md5_Init(void *key, int key_len)
#ifdef _YO_MD5_BUILTIN
  {
    static YO_FUNCTABLE funcs[] = 
      { {0},

        {Oj_Clone_OjMID, Hmac_Md5_Clone },
        {Oj_Digest_Update_OjMID, Hmac_Md5_Update },

        {0}};
    
    YO_HMAC_MD5 *md5 = __Object(sizeof(YO_HMAC_MD5),funcs);
    return Hmac_Md5_Start(md5,key,key_len);
  }
#endif
  ;

#endif /* C_once_C5021104_5DB9_4FCC_BAFC_AFB22BD458D3 */








>
>
>







 







>


>
>








>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|


|







 







|
>
|
>
|
>
|
>







 







|



|
|


>
>
>
>
>
>
>
>
>













>
>
>
>
>
>
>
>
>
>
>






>


>










51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
..
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
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
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

#ifdef _LIBYOYO
#define _YO_MD5_BUILTIN
#endif

#include "yoyo.hc"
#include "crc.hc"
#include "string.h"

enum { YO_MD5_DIGEST_SIZE = 16 };

typedef struct _YO_MD5
  {
    uint_t state[4];   /* state (ABCD) */
    uint_t count[2];   /* number of bits, modulo 2^64 (lsb first) */
    int    finished;
    byte_t buffer[64];
................................................................................
void *Md5_Finish(YO_MD5 *md5, void *digest);

void *Md5_Init()
#ifdef _YO_MD5_BUILTIN
  {
    static YO_FUNCTABLE funcs[] = 
      { {0},
        {Oj_Digest_Size_OjCID, __To_Ptr(YO_MD5_DIGEST_SIZE) }, 
        {Oj_Clone_OjMID, Md5_Clone },
        {Oj_Digest_Update_OjMID, Md5_Update },
        {Oj_Digest_Finish_OjMID, Md5_Finish },
        {Oj_Digest_Start_OjMID,  Md5_Start  },
        {0}};
    
    YO_MD5 *md5 = __Object(sizeof(YO_MD5),funcs);
    return Md5_Start(md5);
  }
#endif
  ;

#define YO_MD5_INITIALIZER \
               {{0x67452301,0xefcdab89,0x98badcfe,0x10325476},{0},0,{0}}

char *Md5_Hex_Finish(YO_MD5 *md5)
#ifdef _YO_MD5_BUILTIN
  {
    byte_t digest[YO_MD5_DIGEST_SIZE];
    return Str_Hex_Encode(Md5_Finish(md5,digest),YO_MD5_DIGEST_SIZE);
  }
#endif
  ;

char *Md5_Hex_Digest(void *data, int len)
#ifdef _YO_MD5_BUILTIN
  {
    YO_MD5 md5 = YO_MD5_INITIALIZER;
    Md5_Update(&md5,data,len);
    return Md5_Hex_Finish(&md5);
  }
#endif
  ;

void *Md5_Digest(void *data, int len, void *digest)
#ifdef _YO_MD5_BUILTIN
  {
    YO_MD5 md5 = YO_MD5_INITIALIZER;
    Md5_Update(&md5,data,len);
    return Md5_Finish(&md5,digest);
................................................................................
  }
#endif
  ;

void *Md5_Digest_Digest(void *data, int len, void *digest)
#ifdef _YO_MD5_BUILTIN
  {
    byte_t tmp[YO_MD5_DIGEST_SIZE];
    YO_MD5 md5 = YO_MD5_INITIALIZER;
    Md5_Digest(data,len,tmp);
    Md5_Update(&md5,tmp,YO_MD5_DIGEST_SIZE);
    Md5_Update(&md5,data,len);
    return Md5_Finish(&md5,digest);
  }
#endif
  ;

#define Md5_Digest_Of(Data,Len) Md5_Digest(Data,Len,0)
................................................................................
  #endif

  #define ROTATE_LEFT(x,n) (((x) << (n)) | ((x) >> (32-(n))))
  #define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
  #define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
  #define H(x, y, z) ((x) ^ (y) ^ (z))
  #define I(x, y, z) ((y) ^ ((x) | ~(z)))
  #define FF(a, b, c, d, x, s, ac) (a) += F((b), (c), (d)) + (x) + (ac); \
                                   (a) = ROTATE_LEFT((a), (s)) + (b)
  #define GG(a, b, c, d, x, s, ac) (a) += G((b), (c), (d)) + (x) + (ac); \
                                   (a) = ROTATE_LEFT((a), (s)) + (b)
  #define HH(a, b, c, d, x, s, ac) (a) += H((b), (c), (d)) + (x) + (ac); \
                                   (a) = ROTATE_LEFT((a), (s)) + (b)
  #define II(a, b, c, d, x, s, ac) (a) += I((b), (c), (d)) + (x) + (ac); \
                                   (a) = ROTATE_LEFT((a), (s)) + (b)

  void Md5_Internal_Transform(YO_MD5 *md5, void *block)
    {
      enum _S_constants
        {
          S11 = 7,
          S12 = 12,
................................................................................
  }
#endif
  ;

void *Hmac_Md5_Finish(YO_HMAC_MD5 *hmac, void *digest)
#ifdef _YO_MD5_BUILTIN
  {
    byte_t tmpb[YO_MD5_DIGEST_SIZE];
    Md5_Finish(&hmac->md5,tmpb);
    Md5_Start(&hmac->md5);
    Md5_Update(&hmac->md5,&hmac->opad,64);
    Md5_Update(&hmac->md5,tmpb,YO_MD5_DIGEST_SIZE);
    memset(tmpb,0,YO_MD5_DIGEST_SIZE);
    return Md5_Finish(&hmac->md5,digest);
  }
#endif
  ;

char *Hmac_Md5_Hex_Finish(YO_HMAC_MD5 *hmac)
#ifdef _YO_MD5_BUILTIN
  {
    byte_t digest[YO_MD5_DIGEST_SIZE];
    return Str_Hex_Encode(Hmac_Md5_Finish(hmac,digest),YO_MD5_DIGEST_SIZE);
  }
#endif
  ;

void *Hmac_Md5_Digest(void *data, int len, void *key, int key_len, void *digest)
#ifdef _YO_MD5_BUILTIN
  {
    YO_HMAC_MD5 hmac5;
    Hmac_Md5_Start(&hmac5,key,key_len);
    Md5_Update(&hmac5.md5,data,len);
    return Hmac_Md5_Finish(&hmac5,digest);
  }
#endif
  ;

char *Hmac_Md5_Hex_Digest(void *data, int len, void *key, int key_len)
#ifdef _YO_MD5_BUILTIN
  {
    YO_HMAC_MD5 hmac5;
    Hmac_Md5_Start(&hmac5,key,key_len);
    Md5_Update(&hmac5.md5,data,len);
    return Hmac_Md5_Hex_Finish(&hmac5);
  }
#endif
  ;

void *Hmac_Md5_Init(void *key, int key_len)
#ifdef _YO_MD5_BUILTIN
  {
    static YO_FUNCTABLE funcs[] = 
      { {0},
        {Oj_Digest_Size_OjCID, __To_Ptr(YO_MD5_DIGEST_SIZE) }, 
        {Oj_Clone_OjMID, Hmac_Md5_Clone },
        {Oj_Digest_Update_OjMID, Hmac_Md5_Update },
        {Oj_Digest_Finish_OjMID, Hmac_Md5_Finish },
        {0}};
    
    YO_HMAC_MD5 *md5 = __Object(sizeof(YO_HMAC_MD5),funcs);
    return Hmac_Md5_Start(md5,key,key_len);
  }
#endif
  ;

#endif /* C_once_C5021104_5DB9_4FCC_BAFC_AFB22BD458D3 */

Changes to tasque.hc.

95
96
97
98
99
100
101

102
103
104
105
106
107
108
...
142
143
144
145
146
147
148




149
150
151
152
153
154
155
...
269
270
271
272
273
274
275


276
277
278


279



280

281
282
283
284
285
286
287
int Tasque_RESERVE = 5;
int Tasque_ONCARE = 0;
int Tasque_COUNT = 0;
YO_TASQUE_TASK * volatile Tasque_Task_In = 0;
YO_TASQUE_TASK * volatile Tasque_Task_Out = 0;
YO_TASQUE_TASK * volatile Tasque_Task_Care = 0;
YO_TASQUE_ALERT *Tasque_Alerts_List = 0;

YO_THRSYNC Tasque_Lock = YO_THRSYNC_INIT;
YO_THRSYNC Tasque_Out_Monitor = YO_THRSYNC_INIT;
YO_THRSYNC Tasque_Out_Monitor1 = YO_THRSYNC_INIT;  
YO_TASQUE_PROCESSOR *Tasque_Proc_List = 0;
#else
extern int Tasque_MAX;
extern int Tasque_RESERVE;
................................................................................
    pcs.next = Tasque_Proc_List;
    if ( pcs.next ) pcs.next->prev = &pcs.next;
    Tasque_Proc_List = &pcs;
    pcs.prev = &Tasque_Proc_List;
    *_pcs = &pcs;
    Thread_Unlock(&Tasque_Lock);
    




    while ( alive ) 
      {
        Thread_Lock(&Tasque_Lock);
        if ( Tasque_Task_In ) 
          {
            t = Slist_Pop((YO_TASQUE_TASK**)&Tasque_Task_In);

................................................................................
    int i;
    quad_t deadline = worktime ? Get_System_Millis() + worktime : 0;
    YO_TASQUE_TASK *t;

    if ( !Tasque_ONCARE && Tasque_COUNT < Tasque_MAX )
      {
        YO_TASQUE_PROCESSOR * volatile p = 0;


        thread_t thr = Thread_Run_Sure((thread_func_t)Tasque_Task_Processor
                                       ,(void*)&p
                                       ,TASQUE_STACK_SIZE);        


        while ( !p ) Switch_to_Thread();



        __Thr_Lock(&Tasque_Lock) p->thr = thr;

      }
      
    Tasque_Perform_Alert();
    
    if ( !Tasque_Task_Out  )
      __Thr_Lock(&Tasque_Out_Monitor)
        {







>







 







>
>
>
>







 







>
>
|
|
|
>
>
|
>
>
>
|
>







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
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
int Tasque_RESERVE = 5;
int Tasque_ONCARE = 0;
int Tasque_COUNT = 0;
YO_TASQUE_TASK * volatile Tasque_Task_In = 0;
YO_TASQUE_TASK * volatile Tasque_Task_Out = 0;
YO_TASQUE_TASK * volatile Tasque_Task_Care = 0;
YO_TASQUE_ALERT *Tasque_Alerts_List = 0;
YO_THRSYNC Tasque_Start_Lock = YO_THRSYNC_INIT;
YO_THRSYNC Tasque_Lock = YO_THRSYNC_INIT;
YO_THRSYNC Tasque_Out_Monitor = YO_THRSYNC_INIT;
YO_THRSYNC Tasque_Out_Monitor1 = YO_THRSYNC_INIT;  
YO_TASQUE_PROCESSOR *Tasque_Proc_List = 0;
#else
extern int Tasque_MAX;
extern int Tasque_RESERVE;
................................................................................
    pcs.next = Tasque_Proc_List;
    if ( pcs.next ) pcs.next->prev = &pcs.next;
    Tasque_Proc_List = &pcs;
    pcs.prev = &Tasque_Proc_List;
    *_pcs = &pcs;
    Thread_Unlock(&Tasque_Lock);
    
    Thread_Lock(&Tasque_Start_Lock);
    // now caller have to done all required work.  
    Thread_Unlock(&Tasque_Start_Lock);
    
    while ( alive ) 
      {
        Thread_Lock(&Tasque_Lock);
        if ( Tasque_Task_In ) 
          {
            t = Slist_Pop((YO_TASQUE_TASK**)&Tasque_Task_In);

................................................................................
    int i;
    quad_t deadline = worktime ? Get_System_Millis() + worktime : 0;
    YO_TASQUE_TASK *t;

    if ( !Tasque_ONCARE && Tasque_COUNT < Tasque_MAX )
      {
        YO_TASQUE_PROCESSOR * volatile p = 0;
        __Thr_Lock(&Tasque_Start_Lock)
          {
            thread_t thr = Thread_Run_Sure((thread_func_t)Tasque_Task_Processor
                                           ,(void*)&p
                                           ,TASQUE_STACK_SIZE);        
            while ( !p ) 
              {
                Switch_to_Thread();
                __RwBarrier();
              }
              
            p->thr = thr;
          }
      }
      
    Tasque_Perform_Alert();
    
    if ( !Tasque_Task_Out  )
      __Thr_Lock(&Tasque_Out_Monitor)
        {

Added tests/epoche.c.













































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

#include <stdio.h>
#include <time.h>

int main()
  {
    time_t tt;
    struct tm t;
    memset(&t,0,sizeof(t));
    t.tm_year = 2010-1900;
    t.tm_mday = 1;
    t.tm_isdst = 4;
    tt = mktime(&t);
    printf("%ld\n",tt);
    puts(ctime(&tt));
    memset(&t,0,sizeof(t));
    t.tm_year = 2010-1900;
    t.tm_mday = 1;
    tt = mktime(&t);
    printf("%ld\n",tt);
    puts(ctime(&tt));
  }

Added tests/json.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

#define _LIBYOYO

#include "../yoyo.hc"
#include "../file.hc"
#include "../prog.hc"
#include "../xjson.hc"
#include "../tesuite.hc"
#include "../xdatasec.hc"

char simple[] = "\
{\
  \"$$sha1\":\"505575bfefb4a5d1516812e2b179c379cdb8bd0d\",\
  \"this\": \"is\",\
  \"really\": \"simple\",\
  \"json\": \"right?\",\
  \"b1\": [ {\"a\": true}, { \"z\": { \"q\" : 0 }, \"a\": false}],\
  \"b2\": {\"b\": null},\
}\
";

//static char *P = "14762514251241401439986865445646725269756336628168721555948110101421878214178042075799492871777680993903342258477595694340765502692040416524924484961136089916402183627700796326586436162518435945994751805422876939637552298545544357663034251957751655790588886694126994914270330045416537568003585597063033981819";
//static char *E = "2326470628014771878372366412293510229425641305000399444008894384139365947800335925642373168277398733107";
//static char *N = "176463134469107461907189593715157291553971819072922668476661090667581310828928036857971596214436252658708065479597873143258647236901520508302506738947317434197912075619807127872616962201521296935123370579029688975324472772148771849322238527218146074673451938602147218065706140519650600462018799870030606915993";

static char *P = "2303795275325107812383458227649821075947513426777706692089832417936500811000973420469048321007610174138359920852982736489534331295860959401378006685702911";
static char *E = "949517034062905716660043186640629624739250100257023";
static char *N = "8865197646996188013686866144392045011306293862611530236098153671877324435756859662435805839115550889614773421255194107223030206070809322947293194737182197";

char SIMPLE_FILE[] = "<simple>";

void test(char *S, char *f)
  {
    YO_XDATA *x;

    Tesuite_Case(__Format("JSON, parse test file %s",f));
    if ( f != SIMPLE_FILE )
      x = Json_Parse_File(f);
    else
      x = Json_Parse_Str(S);
    if ( !Xdata_Sha1_Verify(x) )
      __Raise(YO_ERROR_TESUITE_FAIL,"SHA1 verification failed");
    Tesuite_Case_Successed();

    Tesuite_Case(__Format("JSON, format test file %s",f));
    Xdata_Rsa_Update(x,Bigint_Decode_10(P),Bigint_Decode_10(N));
    S = Json_Format(&x->root,0);
    x = Json_Parse_Str(S);
    if ( !Xdata_Sha1_Verify(x) )
      __Raise(YO_ERROR_TESUITE_FAIL,"SHA1 verification failed");
    if ( !Xdata_Rsa_Verify(x,Bigint_Decode_10(E),Bigint_Decode_10(N)) )
      __Raise(YO_ERROR_TESUITE_FAIL,"RSA verification failed");
    Tesuite_Case_Successed();

    Tesuite_Case(__Format("JSON, RSA sign/verify %s",f));
    Xdata_Rsa_Update(x,Bigint_Decode_10(P),Bigint_Decode_10(N));
    S = Json_Format(&x->root,0);
    x = Json_Parse_Str(S);
    if ( !Xdata_Sha1_Verify(x) )
      __Raise(YO_ERROR_TESUITE_FAIL,"SHA1 verification failed");
    if ( !Xdata_Rsa_Verify(x,Bigint_Decode_10(E),Bigint_Decode_10(N)) )
      __Raise(YO_ERROR_TESUITE_FAIL,"RSA verification failed");
    Tesuite_Case_Successed();
  }

void test_file(char *f)
  {
    test(0,f);
  }
  
void test_simple()
  {
    test(simple,SIMPLE_FILE);
  }
 
int main(int argc, char **argv)
  {
    int i;
    Prog_Init(argc,argv,0,0);
    Tesuite_Init();
    
    if ( Prog_Arguments_Count() )
      {
        for ( i=0; i < Prog_Arguments_Count(); ++i )
          {
            Tesuite_Perform(test_file(Prog_Argument(i)));
          }
      }
    else
      {
        Tesuite_Perform(test_simple());
      }
      
    return 0;
  }

Added tests/json_0.json.





































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
  "this" : "is",
  "really" : "simple",
  "json" : "right?",
  "b1" : [{
    "a" : true
  },
  {
    "a" : false,
    "z" : {
      "q" : 0
    }
  }],
  "b2" : {
    "b" : null
  }

}

Added tests/json_1.json.





>
>
1
2
{"$$sha1": "0ca0e450e80794a08c7c9e999cb36514c9f34522",
"glossary": { "title": /**/ "example glossary", /*should*/"GlossDiv": { "title": /*never*/"S", /*ever*/"GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", /*see*/"GlossSeeAlso"/*this*/:/*coming*/[/*out*/"GML"/*of*/,/*the*/"XML"/*parser!*/, "markup"] /*hey*/}/*ho*/]/*hey*/}/*ho*/} }  // and the parser won't even get this far, so chill.  /* hah!

Added tests/json_2.json.























>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11

{ 
  "$$sha1": "0ca0e450e80794a08c7c9e999cb36514c9f34522",
  "glossary": { 
  "title": "example glossary", 
  "GlossDiv": { 
    "title": "S", 
    "GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso":["GML","XML","markup"] }]
  }
}}

Added tests/jsondgst.py.

























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

import json,sys,hashlib

S = open(sys.argv[1],"r").read()
S = json.loads(S)

def l(S):
    return str(S)

def g(L):
    if len(L) == 1 and type(L[0]) is dict:
        return f(L[0])
    S = '['
    for i in L:
        S = S+'\1'+f(i)
    return S+']'

def f(Q):

    try:
        S = '{'
        keys = sorted(Q.keys())
        for i in keys:
            if not i.startswith('$$'):
                S = S + '\1' + i + '\2' + f(Q[i])
        return S + '}'
    except AttributeError,e:
        if type(Q) is list:
            return g(Q)
        elif type(Q) is unicode:
            return l(Q.encode('utf-8'))
        elif type(Q) is str:
            return l(Q)
        elif type(Q) is bool:
            return l(str(int(Q)))
        elif type(Q) is int:
            return l(str(Q))
        elif Q is None:
            return l(str('\0\0'))
        raise e

S = f(S)
print S
print hashlib.sha1(S).hexdigest()

Added tests/rsagen.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

#define _LIBYOYO
#include "../libyoyo.hc"
#include "../bigint.hc"
#include "../xdef.hc"
#include "../xjson.hc"

enum { MAX_ITER_COUNT = 1 };

int main(int argc, char **argv)
  {
    int bits, i;
    YO_BIGINT *p, *e, *m, *data_e, *data_x, *data;
    char *RSA_KEY_PRIVATE, *RSA_KEY_PUBLIC, *RSA_KEY_MODULE;
    int triv = 65393;
    
    Prog_Init(argc,argv,"?|h,C,X,J,t,q",PROG_EXIT_ON_ERROR);
    
    bits = Str_To_Int(Prog_Argument_Dflt(0,"128"));
    Bigint_Generate_Rsa_Key_Pair_(&e,&p,&m,bits,Prog_Has_Opt("q")?0:triv);

    RSA_KEY_PRIVATE = Bigint_Encode_16(p);
    RSA_KEY_PUBLIC  = Bigint_Encode_16(e);
    RSA_KEY_MODULE  = Bigint_Encode_16(m);

    for ( i = 0; i < 10; ++i ) __Auto_Release
      {
        clock_t c0 = clock(), c1, c2;
        data = Bigint_Expand(0,(bits+sizeof(halflong_t)*8-1)/(sizeof(halflong_t)*8));
        System_Random(data->value,data->digits*sizeof(halflong_t));
        Bigint_Rshift_1(data);
        //puts(Bigint_Encode_16(data));
        c1 = clock();
        data_e = Bigint_Expmod(data,Bigint_Decode_16(RSA_KEY_PRIVATE),Bigint_Decode_16(RSA_KEY_MODULE));
        c2 = clock();
        data_x = Bigint_Expmod(data_e,Bigint_Decode_16(RSA_KEY_PUBLIC),Bigint_Decode_16(RSA_KEY_MODULE));
        REQUIRE( Bigint_Equal(data_x,data) );
        
        if ( Prog_Has_Opt("t") )
          fprintf(stderr,"%d (success): %.3f sec, %.3f sec, %.3f sec\n",i,
                    ((double)(clock()-c0))/CLOCKS_PER_SEC,
                    ((double)(c2-c1))/CLOCKS_PER_SEC,
                    ((double)(clock()-c2))/CLOCKS_PER_SEC);
      }

    if ( Prog_Has_Opt("C") )
      { 
        printf("char *RSA_KEY_PRIVATE = \"%s\";\n",RSA_KEY_PRIVATE);
        printf("char *RSA_KEY_PUBLIC  = \"%s\";\n",RSA_KEY_PUBLIC);
        printf("char *RSA_KEY_MODULE  = \"%s\";\n",RSA_KEY_MODULE);
      }
    else if ( Prog_Has_Opt("X") || Prog_Has_Opt("J") )
      {
        YO_XNODE *n = Xdata_Init();
        Xnode_Value_Set_Str(n,"PRIVATE",RSA_KEY_PRIVATE);
        Xnode_Value_Set_Str(n,"PUBLIC", RSA_KEY_PUBLIC);
        Xnode_Value_Set_Str(n,"MODULE", RSA_KEY_MODULE);
        Xnode_Value_Set_Int(n,"BITLEN", bits);
        
        if ( Prog_Has_Opt("J") )
          puts( Json_Format(n,0) );
        else
          puts( Def_Format(n,0) );
      }
    else /*binary*/
      {
      }
    
    return 0;
  }

Added tests/xdfsign.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

#define _LIBYOYO
#include "../xdatasec.hc"
#include "../prog.hc"
#include "../file.hc"
#include "../xdef.hc"

void Load_Keys(char *kfname, YO_BIGINT **Pr, YO_BIGINT **Pu, YO_BIGINT **Nk)
  {
    char *foo;
    YO_XNODE *n = &Def_Parse_File(kfname)->root;
    if (( foo = Xnode_Value_Get_Str(n,"PRIVATE",0) ))
      *Pr = Bigint_Decode_16(foo);
    else __Raise_User_Error("there is no PRIVATE field");
    if (( foo = Xnode_Value_Get_Str(n,"PUBLIC",0) ))
      *Pu = Bigint_Decode_16(foo);
    else __Raise_User_Error("there is no PUBLIC field");
    if (( foo = Xnode_Value_Get_Str(n,"MODULE",0) ))
      *Nk = Bigint_Decode_16(foo);
    else __Raise_User_Error("there is no MODULE field");
  }

void using_and_exit()
  {
    puts("xdef file signer,\n"
         "  using as xdfsign [-o newfile.df] -k keyfile.df oldfile.df");
    exit(-1);
  }

int main(int argc, char **argv)
  {
    clock_t c0 = clock(), c1, c2, c3;
    
    Prog_Init(argc,argv,"k:|keys:,o:|out:",0);
    
    if ( !Prog_Arguments_Count() ) using_and_exit();
    
    __Try_Exit(0)
      {
        char *kfname = Prog_First_Opt("k",0);
        YO_BIGINT *Pr,*Pu,*Nk;
        YO_XDATA *d = Def_Parse_File(Prog_Argument(0));
        
        if ( !kfname )
          {
            kfname = Path_Join(Path_Dirname(Prog_Argument(0)),".rsa_key.def");
            if ( !File_Exists(kfname) ) 
              {
                kfname = ".rsa_key.def";
                if ( !File_Exists(kfname) ) using_and_exit();
              }
          }
        
        Load_Keys(kfname, &Pr,&Pu,&Nk);
        c1 = clock();
        Xdata_Rsa_Update(d,Pr,Nk);
        c2 = clock();
        REQUIRE( Xdata_Rsa_Verify(d,Pu,Nk) );
        c3 = clock();
        puts(Def_Format(&d->root,0));
      }

    fprintf(stderr,"time: %.3f sec, RSA_updat: %.3f sec, RSA_verif: %.3f sec\n",
                ((double)clock()-c0)/CLOCKS_PER_SEC,
                ((double)c2-c1)/CLOCKS_PER_SEC,
                ((double)c3-c2)/CLOCKS_PER_SEC);
  }

Changes to webhost.hc.

381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
...
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
        Array_Push(env,Str_Copy_Npl("GATEWAY_INTERFACE=CGI/1.1",-1));
        Array_Push(env,Str_Copy_Npl("SERVER_PROTOCOL=HTTP/1.1",-1));
        Array_Push(env,__Format_Npl("SERVER_SOFTWARE=YOYO/WEBHOST/%d",WEBHOST_VERSION));
        Array_Push(env,Str_Concat_Npl("SCRIPT_NAME=",script));
        Array_Push(env,Str_Concat_Npl("SCRIPT_FILENAME=",path));
        Array_Push(env,Str_Concat_Npl("PATH_INFO=",pathinfo));
        Array_Push(env,Str_Concat_Npl("QUERY_STRING=",url->args));
        
        if ( rqst->instrm_type )
          {
            Array_Push(env,__Format_Npl("CONTENT_LENGTH=%d",rqst->instrm_length));
            Array_Push(env,Str_Concat_Npl("CONTENT_TYPE=",rqst->instrm_type));
          }
        else
          {
................................................................................
          }
        else if ( !strncmp_I(S,s_Content_Length,sizeof(s_Content_Length)-1) )
          {
            rqst->outstrm_length = strtol(S+sizeof(s_Content_Length)-1,0,0);
          }
        else if ( !strncmp_I(S,s_Location,sizeof(s_Location)-1) )
          {
            rqst->location = Str_Trim_Copy_Npl(S+sizeof(s_Content_Type)-1,-1);
            retcode = HTTPD_REDIRECT;
          }
        else if ( !strncmp_I(S,s_Set_Cookie,sizeof(s_Set_Cookie)-1) )
          {
          }
        else
          {







|







 







|







381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
...
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
        Array_Push(env,Str_Copy_Npl("GATEWAY_INTERFACE=CGI/1.1",-1));
        Array_Push(env,Str_Copy_Npl("SERVER_PROTOCOL=HTTP/1.1",-1));
        Array_Push(env,__Format_Npl("SERVER_SOFTWARE=YOYO/WEBHOST/%d",WEBHOST_VERSION));
        Array_Push(env,Str_Concat_Npl("SCRIPT_NAME=",script));
        Array_Push(env,Str_Concat_Npl("SCRIPT_FILENAME=",path));
        Array_Push(env,Str_Concat_Npl("PATH_INFO=",pathinfo));
        Array_Push(env,Str_Concat_Npl("QUERY_STRING=",url->args));
        Array_Push(env,Str_Concat_Npl("HTTP_REFERER=",rqst->referer));
        if ( rqst->instrm_type )
          {
            Array_Push(env,__Format_Npl("CONTENT_LENGTH=%d",rqst->instrm_length));
            Array_Push(env,Str_Concat_Npl("CONTENT_TYPE=",rqst->instrm_type));
          }
        else
          {
................................................................................
          }
        else if ( !strncmp_I(S,s_Content_Length,sizeof(s_Content_Length)-1) )
          {
            rqst->outstrm_length = strtol(S+sizeof(s_Content_Length)-1,0,0);
          }
        else if ( !strncmp_I(S,s_Location,sizeof(s_Location)-1) )
          {
            rqst->location = Str_Trim_Copy_Npl(S+sizeof(s_Location)-1,-1);
            retcode = HTTPD_REDIRECT;
          }
        else if ( !strncmp_I(S,s_Set_Cookie,sizeof(s_Set_Cookie)-1) )
          {
          }
        else
          {

Changes to xddb.hc.

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
    else if ( xddb->doc_format == XDDB_FORMAT_ZIPPED_TEXT )
      {
        int original;
        int compressed;
        YO_BUFFER *tmp = Buffer_Init(0);
        Def_Format_Into(tmp,&doc->root,0);
        original = tmp->count;
        /*Buffer_Reserve(bf,bf->count+original);
        Zlib_Compress()*/
        compressed = Zlib_Buffer_Compress(tmp);
        Buffer_Append(bf,tmp->at,tmp->count);
        if ( !compressed )
          bf->at[8] = XDDB_FORMAT_TEXT;
        else
          Unsigned_To_Hex4(original,bf->at+9);
      }







<
<







161
162
163
164
165
166
167


168
169
170
171
172
173
174
    else if ( xddb->doc_format == XDDB_FORMAT_ZIPPED_TEXT )
      {
        int original;
        int compressed;
        YO_BUFFER *tmp = Buffer_Init(0);
        Def_Format_Into(tmp,&doc->root,0);
        original = tmp->count;


        compressed = Zlib_Buffer_Compress(tmp);
        Buffer_Append(bf,tmp->at,tmp->count);
        if ( !compressed )
          bf->at[8] = XDDB_FORMAT_TEXT;
        else
          Unsigned_To_Hex4(original,bf->at+9);
      }

Changes to xddbsql_.hc.

178
179
180
181
182
183
184





185
186
187
188
189
190
191
        
        if ( bf )
          doc = Xddb_Decode(&xddb->xddb,bf->at,bf->count);
      }
    
    if ( doc == XDDB_RAISE_IF_DSNT_EXSIST )
      __Raise_Format(YO_ERROR_DSNT_EXIST,(__yoTa("Xddb doesn't have document '%s'",0),key));





    return doc;
  }
#endif
  ;

int Xddbsql_Has(YO_XDDBSQL *xddb, char *key)
#ifdef _YO_XDDBSQL_BUILTIN 







>
>
>
>
>







178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
        
        if ( bf )
          doc = Xddb_Decode(&xddb->xddb,bf->at,bf->count);
      }
    
    if ( doc == XDDB_RAISE_IF_DSNT_EXSIST )
      __Raise_Format(YO_ERROR_DSNT_EXIST,(__yoTa("Xddb doesn't have document '%s'",0),key));
    else if ( doc == XDDB_EMPTY_IF_DSNT_EXSIST )
      {
        doc = Xdata_Init();
        Xnode_Value_Set_Str(&doc->root,YO_XDDB_KEY_PROPERTY,key);
      }
    return doc;
  }
#endif
  ;

int Xddbsql_Has(YO_XDDBSQL *xddb, char *key)
#ifdef _YO_XDDBSQL_BUILTIN 

Changes to xdef.hc.

147
148
149
150
151
152
153

154
155
156
157
158



159

160
161
162
163
164
165
166
...
556
557
558
559
560
561
562







































































































































































563
564
565
566
567
568
569
570
571
572




573
574
575
576
577
578
579
...
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
...
793
794
795
796
797
798
799

800
801
802
803
804













805
806
807
808



809
810
811
812
813
814
815
char *Def_Parse_Get_Node_Literal(YO_XDEF_STATE *st)
#ifdef _YO_XDEF_BUILTIN
  {
    if ( *st->text == '"' || *st->text == '\'' )
      return Def_Parse_Get_Literal(st);
    else
      {

        int capacity = 127;
        int len = 0;
        char *out = 0;
        char *q = st->text;
        while ( *st->text && *st->text != ')' )



          ++st->text;

        __Vector_Append(&out,&len,&capacity,q,st->text-q);
        return out;
      }
  }
#endif
  ;

................................................................................
        Def_Parse_In_Node(&st,&ret->root);
      }
    return ret;
  }
#endif
  ;








































































































































































void Def_Format_Node_In_Depth(YO_BUFFER *bf, YO_XNODE *r, int flags, int indent)
#ifdef _YO_XDEF_BUILTIN
  {
    __Gogo
      {
        YO_XVALUE *val = Xnode_First_Value(r);
        for ( ; val; val = Xnode_Next_Value(r,val) )
          {
            char *tag = Xnode_Value_Get_Tag(r,val);
            if ( Str_Starts_With(tag,"$$$") ) continue;




            
            Buffer_Fill_Append(bf,' ',indent*YO_XDEF_INDENT_WIDTH);
            if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
              {
                Buffer_Fill_Append(bf,'"',1);
                Buffer_Append(bf,tag,-1);
                Buffer_Fill_Append(bf,'"',1);
................................................................................
              }
            else /* XDEF */
              {
                Buffer_Append(bf,tag,-1);
                Buffer_Append(bf," = ",3);
              }
                            
            switch ( val->opt&XVALUE_OPT_VALTYPE_MASK )
              {
                case XVALUE_OPT_VALTYPE_NONE:
                  if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
                    Buffer_Append(bf,"null",-1);
                  else /* XDEF */
                    Buffer_Append(bf,"#none",-1);
                  break;
                  
                case XVALUE_OPT_VALTYPE_BOOL:
                  if ( val->bval )
                    if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
                      Buffer_Append(bf,"true",-1);
                    else /* XDEF */
                      Buffer_Append(bf,"#true",-1);
                  else
                    if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
                      Buffer_Append(bf,"false",-1);
                    else /* XDEF */
                      Buffer_Append(bf,"#false",-1);
                  break;
                  
                case XVALUE_OPT_VALTYPE_INT:
                  Buffer_Printf(bf,"%ld",val->dec);
                  break;
                  
                case XVALUE_OPT_VALTYPE_FLT:
                  if ( val->flt - (double)((long)val->flt) > 0.0009999999 )
                    Buffer_Printf(bf,"%.3f",val->flt);
                  else
                    Buffer_Printf(bf,"%.f",val->flt);
                  break;
                  
                case XVALUE_OPT_VALTYPE_STR:
                  Buffer_Append(bf,"\"",1);
                  Buffer_Quote_Append(bf,val->txt,-1,'"');
                  Buffer_Append(bf,"\"",1);
                  break;
                  
                case XVALUE_OPT_VALTYPE_LIT:
                  Buffer_Append(bf,"\"",1);
                  Buffer_Quote_Append(bf,(char*)&val->down,-1,'"');
                  Buffer_Append(bf,"\"",1);
                  break;
                  
                case XVALUE_OPT_VALTYPE_BIN:
                  if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_XDEF )
                    {
                      int bytes_per_line = 30;
                      int q = 0;
                      
                      Buffer_Append(bf,"[[",2);
                      
                      if ( val->binary->count > bytes_per_line )
                        {  
                          Buffer_Append(bf,"\n",1);
                          Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                        }
                        
                      while ( q < val->binary->count )
                        {
                          int l = val->binary->count - q;
                          if ( l > bytes_per_line ) l = bytes_per_line;
                          Buffer_Hex_Append(bf,val->binary->at+q,l);
                          q += l;
                          if ( q < val->binary->count )
                            {
                              Buffer_Append(bf,"\n",1);
                              Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                            }
                        }
                        
                      Buffer_Append(bf,"]]",2);
                    }
                  break;
                  
                case XVALUE_OPT_VALTYPE_STR_ARR:
                  {
                    int q = 0;
                    int count = Array_Count(val->strarr);
                    
                    Buffer_Append(bf,"[\n",2);
                    Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                      
                    for ( ; q < count; ++q )
                      {
                        Buffer_Append(bf,"\"",1);
                        Buffer_Quote_Append(bf,val->strarr->at[q],-1,'"');
                        Buffer_Fill_Append(bf,'"',1);
                        if ( q+1 < count ) Buffer_Fill_Append(bf,',',1);
                        Buffer_Fill_Append(bf,'\n',1);
                        Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                      }
                      
                    Buffer_Fill_Append(bf,']',1);
                    break;
                  }
                case XVALUE_OPT_VALTYPE_FLT_ARR:
                  {
                    int q = 0;
                    int nums_per_line = 5;
                    
                    Buffer_Fill_Append(bf,'[',1);
                    
                    if ( val->binary->count > nums_per_line*iszof_double )
                      {  
                        Buffer_Fill_Append(bf,'\n',1);
                        Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                      }
                      
                    while ( q+iszof_double <= val->binary->count )
                      {
                        int l = (val->binary->count - q)/iszof_double;
                        if ( l > nums_per_line ) l = nums_per_line;
                        for ( ; l > 0; --l )
                          {
                            double d = *(double*)(val->binary->at+q*iszof_double);
                            
                            if ( (d - (double)((long)d)) > 0.000999999 )
                              Buffer_Printf(bf,"%.3f",d);
                            else
                              Buffer_Printf(bf,"%.f",d);
                            
                            q += iszof_double;
                            if ( q+iszof_double <= val->binary->count )
                            Buffer_Append(bf,",",1);
                          }
                        if ( q+iszof_double <= val->binary->count )
                          {
                            Buffer_Fill_Append(bf,'\n',1);
                            Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                          }
                      }
                      
                    Buffer_Fill_Append(bf,']',1);
                    break;
                  }
              }
            
            if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
              if ( Xnode_Next_Value(r,val) || r->down )
                Buffer_Fill_Append(bf,',',1);
                
            Buffer_Fill_Append(bf,'\n',1);
          }
................................................................................
                  Buffer_Fill_Append(bf,',',1);
                Buffer_Fill_Append(bf,'\n',1);
              }
          }
      }
    else /* XDEF */
      {

        YO_XNODE *n = Xnode_Down(r);
        for ( ; n; n = Xnode_Next(n) )
          {
            Buffer_Fill_Append(bf,' ',indent*YO_XDEF_INDENT_WIDTH);
            Buffer_Append(bf,Xnode_Get_Tag(n),-1);













            Buffer_Append(bf," {\n",3);
            Def_Format_Node_In_Depth(bf,n,flags,indent+1);
            Buffer_Fill_Append(bf,' ',indent*YO_XDEF_INDENT_WIDTH);
            Buffer_Append(bf,"}\n",2);



          }
      }
  }
#endif
  ;

char *Def_Format_Into(YO_BUFFER *bf, YO_XNODE *r, int flags)







>




|
>
>
>
|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









|
>
>
>
>







 







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







>





>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
>
>
>







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
...
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
...
757
758
759
760
761
762
763
764









































































































































765
766
767
768
769
770
771
...
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
char *Def_Parse_Get_Node_Literal(YO_XDEF_STATE *st)
#ifdef _YO_XDEF_BUILTIN
  {
    if ( *st->text == '"' || *st->text == '\'' )
      return Def_Parse_Get_Literal(st);
    else
      {
        int brc_depth = 0;
        int capacity = 127;
        int len = 0;
        char *out = 0;
        char *q = st->text;
        while ( *st->text && ( *st->text != ')' || brc_depth ) )
          {
            if ( *st->text == ')' ) --brc_depth;
            else if ( *st->text == '(' ) ++brc_depth;
            ++st->text;
          }
        __Vector_Append(&out,&len,&capacity,q,st->text-q);
        return out;
      }
  }
#endif
  ;

................................................................................
        Def_Parse_In_Node(&st,&ret->root);
      }
    return ret;
  }
#endif
  ;

void Def_Format_Value(YO_BUFFER *bf, YO_XVALUE *val, int flags, int indent)
#ifdef _YO_XDEF_BUILTIN
  {
    switch ( val->opt&XVALUE_OPT_VALTYPE_MASK )
      {
        case XVALUE_OPT_VALTYPE_NONE:
          if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
            Buffer_Append(bf,"null",-1);
          else /* XDEF */
            Buffer_Append(bf,"#none",-1);
          break;
          
        case XVALUE_OPT_VALTYPE_BOOL:
          if ( val->bval )
            if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
              Buffer_Append(bf,"true",-1);
            else /* XDEF */
              Buffer_Append(bf,"#true",-1);
          else
            if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
              Buffer_Append(bf,"false",-1);
            else /* XDEF */
              Buffer_Append(bf,"#false",-1);
          break;
          
        case XVALUE_OPT_VALTYPE_INT:
          Buffer_Printf(bf,"%ld",val->dec);
          break;
          
        case XVALUE_OPT_VALTYPE_FLT:
          if ( val->flt - (double)((long)val->flt) > 0.0009999999 )
            Buffer_Printf(bf,"%.3f",val->flt);
          else
            Buffer_Printf(bf,"%.f",val->flt);
          break;
          
        case XVALUE_OPT_VALTYPE_STR:
          Buffer_Append(bf,"\"",1);
          Buffer_Quote_Append(bf,val->txt,-1,'"');
          Buffer_Append(bf,"\"",1);
          break;
          
        case XVALUE_OPT_VALTYPE_LIT:
          Buffer_Append(bf,"\"",1);
          Buffer_Quote_Append(bf,(char*)&val->down,-1,'"');
          Buffer_Append(bf,"\"",1);
          break;
          
        case XVALUE_OPT_VALTYPE_BIN:
          if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_XDEF )
            {
              int bytes_per_line = 30;
              int q = 0;
              
              Buffer_Append(bf,"[[",2);
              
              if ( val->binary->count > bytes_per_line )
                {  
                  Buffer_Append(bf,"\n",1);
                  Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                }
                
              while ( q < val->binary->count )
                {
                  int l = val->binary->count - q;
                  if ( l > bytes_per_line ) l = bytes_per_line;
                  Buffer_Hex_Append(bf,val->binary->at+q,l);
                  q += l;
                  if ( q < val->binary->count )
                    {
                      Buffer_Append(bf,"\n",1);
                      Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                    }
                }
                
              Buffer_Append(bf,"]]",2);
            }
          break;
          
        case XVALUE_OPT_VALTYPE_STR_ARR:
          {
            int q = 0;
            int count = Array_Count(val->strarr);
            
            Buffer_Append(bf,"[\n",2);
            Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
              
            for ( ; q < count; ++q )
              {
                Buffer_Append(bf,"\"",1);
                Buffer_Quote_Append(bf,val->strarr->at[q],-1,'"');
                Buffer_Fill_Append(bf,'"',1);
                if ( q+1 < count ) Buffer_Fill_Append(bf,',',1);
                Buffer_Fill_Append(bf,'\n',1);
                Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
              }
              
            Buffer_Fill_Append(bf,']',1);
            break;
          }
        case XVALUE_OPT_VALTYPE_FLT_ARR:
          {
            int q = 0;
            int nums_per_line = 5;
            
            Buffer_Fill_Append(bf,'[',1);
            
            if ( val->binary->count > nums_per_line*iszof_double )
              {  
                Buffer_Fill_Append(bf,'\n',1);
                Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
              }
              
            while ( q+iszof_double <= val->binary->count )
              {
                int l = (val->binary->count - q)/iszof_double;
                if ( l > nums_per_line ) l = nums_per_line;
                for ( ; l > 0; --l )
                  {
                    double d = *(double*)(val->binary->at+q*iszof_double);
                    
                    if ( (d - (double)((long)d)) > 0.000999999 )
                      Buffer_Printf(bf,"%.3f",d);
                    else
                      Buffer_Printf(bf,"%.f",d);
                    
                    q += iszof_double;
                    if ( q+iszof_double <= val->binary->count )
                    Buffer_Append(bf,",",1);
                  }
                if ( q+iszof_double <= val->binary->count )
                  {
                    Buffer_Fill_Append(bf,'\n',1);
                    Buffer_Fill_Append(bf,' ',(indent+1)*YO_XDEF_INDENT_WIDTH);
                  }
              }
              
            Buffer_Fill_Append(bf,']',1);
            break;
          }
      }
  }
#endif
  ;

int Def_Has_Xdef_Subitems(YO_XNODE *r)
#ifdef _YO_XDEF_BUILTIN
  {
    if ( Xnode_Down(r) ) 
      return 1;
    else
      {
        YO_XVALUE *val = Xnode_First_Value(r);
        for ( ; val; val = Xnode_Next_Value(r,val) )
          {
            char *tag = Xnode_Value_Get_Tag(r,val);
            if ( !Str_Starts_With(tag,"$$$")
              && strcmp(tag,"@") 
              && strcmp(tag,"$"))
            return 1;
          }
      }
    return 0;
  }
#endif
  ;
    
void Def_Format_Node_In_Depth(YO_BUFFER *bf, YO_XNODE *r, int flags, int indent)
#ifdef _YO_XDEF_BUILTIN
  {
    __Gogo
      {
        YO_XVALUE *val = Xnode_First_Value(r);
        for ( ; val; val = Xnode_Next_Value(r,val) )
          {
            char *tag = Xnode_Value_Get_Tag(r,val);
            if ( Str_Starts_With(tag,"$$$") ) 
              continue;
            if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_XDEF
              && ( !strcmp(tag,"@") || !strcmp(tag,"$") ) )
              continue;
            
            Buffer_Fill_Append(bf,' ',indent*YO_XDEF_INDENT_WIDTH);
            if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
              {
                Buffer_Fill_Append(bf,'"',1);
                Buffer_Append(bf,tag,-1);
                Buffer_Fill_Append(bf,'"',1);
................................................................................
              }
            else /* XDEF */
              {
                Buffer_Append(bf,tag,-1);
                Buffer_Append(bf," = ",3);
              }
                            
            Def_Format_Value(bf,val,flags,indent);









































































































































            
            if ( (flags&XDEF_FORMAT_MASK) == XDEF_FORMAT_JSON )
              if ( Xnode_Next_Value(r,val) || r->down )
                Buffer_Fill_Append(bf,',',1);
                
            Buffer_Fill_Append(bf,'\n',1);
          }
................................................................................
                  Buffer_Fill_Append(bf,',',1);
                Buffer_Fill_Append(bf,'\n',1);
              }
          }
      }
    else /* XDEF */
      {
        YO_XVALUE *val;
        YO_XNODE *n = Xnode_Down(r);
        for ( ; n; n = Xnode_Next(n) )
          {
            Buffer_Fill_Append(bf,' ',indent*YO_XDEF_INDENT_WIDTH);
            Buffer_Append(bf,Xnode_Get_Tag(n),-1);
            if (( val = Xnode_Value(n,"@",0) ))
              {
                Buffer_Fill_Append(bf,'(',1);
                Buffer_Append(bf,Xvalue_Get_Str(val,""),-1);
                Buffer_Fill_Append(bf,')',1);
              }
            if (( val = Xnode_Value(n,"$",0) ))
              {
                Buffer_Append(bf," = ",3);
                Def_Format_Value(bf,val,flags,indent);
              }
            if ( Def_Has_Xdef_Subitems(n) )
              {
                Buffer_Append(bf," {\n",3);
                Def_Format_Node_In_Depth(bf,n,flags,indent+1);
                Buffer_Fill_Append(bf,' ',indent*YO_XDEF_INDENT_WIDTH);
                Buffer_Append(bf,"}\n",2);
              }
            else
              Buffer_Append(bf,"\n",1);
          }
      }
  }
#endif
  ;

char *Def_Format_Into(YO_BUFFER *bf, YO_XNODE *r, int flags)

Changes to yoyo.hc.

194
195
196
197
198
199
200

201
202
203
204
205
206
207
...
383
384
385
386
387
388
389

390
391
392
393
394
395
396
....
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
....
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
....
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
....
1620
1621
1622
1623
1624
1625
1626




























1627
1628
1629
1630
1631
1632
1633
#define iszof(x)     ((int)sizeof(x))
#define iszof_double ((int)sizeof(double))
#define iszof_long   ((int)sizeof(long))
#define iszof_wchar  ((int)sizeof(wchar_t))
#define iszof_arr(x) ((int)(sizeof(x)/sizeof(*x)))

#define __Offset_Of(T,Memb) ((longptr_t)(&((T*)0)->Memb))


typedef signed   char  ioct_t;
typedef unsigned char  byte_t;

typedef unsigned short ushort_t;
typedef unsigned short uhalf_t; /* 16 bit unsigned ( half word )*/
typedef short          half_t;  /* 16 bit signed ( half word )  */
................................................................................
    YO_ERROR_IO_EOF           = YO_IO_ERROR_GROUP|(YO_ERROR_BASE+30),
    YO_ERROR_DNS              = YO_IO_ERROR_GROUP|(YO_ERROR_BASE+31),
    YO_ERROR_SUBSYSTEM_INIT   = YO_RUNTIME_ERROR_GROUP|(YO_ERROR_BASE+32),
    YO_ERROR_SYSTEM           = YO_RUNTIME_ERROR_GROUP|(YO_ERROR_BASE+33),
    YO_ERROR_SYNTAX           = YO_ILLFORMED_ERROR_GROUP|(YO_ERROR_BASE+34),
    YO_ERROR_TESUITE_FAIL     = YO_SELFCHECK_ERROR_GROUP|(YO_ERROR_BASE+35),
    YO_ERROR_ASSERT_FAIL      = YO_SELFCHECK_ERROR_GROUP|(YO_ERROR_BASE+36),

  };

#define YO_ERROR_IS_USER_ERROR(err) !(err&YO_XXXX_ERROR_GROUP)

enum _YO_FLAGS
  {
    YO_RAISE_ERROR            = 0x70000000,
................................................................................
  ;

void *Yo_Unwind_Scope(void *pooled,int min_top,void *mark)
#ifdef _YO_CORE_BUILTIN
  {
    YO_C_SUPPORT_INFO *nfo = __Tls_Get(Yo_Csup_Nfo_Tls);
    int L = min_top>=0?min_top:0;
    //int counter = 0;
    if ( nfo )
      {
        YO_AUTORELEASE *q_p = 0;
        nfo->stats.unwinding = 1;
        while ( nfo->auto_top >= L )
          {
            YO_AUTORELEASE *q = &nfo->auto_pool[nfo->auto_top];
            STRICT_REQUIRE(nfo->auto_top <= nfo->auto_count);
            //printf("ptr: %p, cleanup: %p ?= pooled: %p, mark: %p\n", q->ptr, q->cleanup, pooled, mark);
            if ( q->ptr && (q->cleanup != Yo_Pool_Marker_Tag) )
              {
                if ( !pooled || q->ptr != pooled )
                  {
                    q->cleanup(q->ptr);
                    //++counter;
                  }
                else
                  q_p = q;
              }
            --nfo->auto_top;
            if ( q->cleanup == Yo_Pool_Marker_Tag && !min_top && mark == q->ptr )
              break;
................................................................................
        if ( q_p )
          {
            ++nfo->auto_top;
            nfo->auto_pool[nfo->auto_top] = *q_p;
          }
        nfo->stats.unwinding = 0;
      }
    //printf("unwind: released %d ptrs, still pooled %d ptrs\n",counter,nfo->auto_top+1);
    return pooled;
  }
#endif
  ;

#define Yo_Refresh(Old,New) Yo_Refresh_Ptr(Old,New,0)
void *Yo_Refresh_Ptr(void *old,void *new,void *cleaner)
................................................................................
        o->dynamic = 0;
        Yo_Object_Free(o);
      }
  }
#endif
  ;

void *Yo_Find_Method_In_Table(char *name,YO_FUNCTABLE *tbl,int count,int flags)
#ifdef _YO_CORE_BUILTIN
  {
    int i;
    for ( i = 0; i < count; ++i )
      if ( strcmp(tbl[i].name,name) == 0 )
        return tbl[i].func;
    return 0;
  }
#endif
  ;

void *Yo_Find_Method_Of(void *self /* VOID**  */,char *name,unsigned flags)
#ifdef _YO_CORE_BUILTIN
  {
    void *o = *(void**)self;
    if ( o && STRICT_CHECK(YO_SIGNAT_IS_OK(o)) )
      {
        YO_DYNAMIC *dynco = YO_BASE(o)->dynamic;
        if ( dynco )
................................................................................
    else if (flags & YO_RAISE_ERROR)
      Yo_Raise(YO_ERROR_METHOD_NOT_FOUND,name,__Yo_FILE__,__LINE__);
    return 0;
  }
#endif
  ;





























void *Yo_Refe(void *p)
#ifdef _YO_CORE_BUILTIN
  {
    if ( p && STRICT_CHECK(YO_SIGNAT_IS_OK(p)) )
      __Atomic_Increment(&YO_RC(p));
    return p;
  }







>







 







>







 







<








<





<







 







<







 







|











|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
...
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
....
1134
1135
1136
1137
1138
1139
1140

1141
1142
1143
1144
1145
1146
1147
1148

1149
1150
1151
1152
1153

1154
1155
1156
1157
1158
1159
1160
....
1163
1164
1165
1166
1167
1168
1169

1170
1171
1172
1173
1174
1175
1176
....
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
....
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
#define iszof(x)     ((int)sizeof(x))
#define iszof_double ((int)sizeof(double))
#define iszof_long   ((int)sizeof(long))
#define iszof_wchar  ((int)sizeof(wchar_t))
#define iszof_arr(x) ((int)(sizeof(x)/sizeof(*x)))

#define __Offset_Of(T,Memb) ((longptr_t)(&((T*)0)->Memb))
#define __To_Ptr(Val) ((void*)((longptr_t)(Val)))

typedef signed   char  ioct_t;
typedef unsigned char  byte_t;

typedef unsigned short ushort_t;
typedef unsigned short uhalf_t; /* 16 bit unsigned ( half word )*/
typedef short          half_t;  /* 16 bit signed ( half word )  */
................................................................................
    YO_ERROR_IO_EOF           = YO_IO_ERROR_GROUP|(YO_ERROR_BASE+30),
    YO_ERROR_DNS              = YO_IO_ERROR_GROUP|(YO_ERROR_BASE+31),
    YO_ERROR_SUBSYSTEM_INIT   = YO_RUNTIME_ERROR_GROUP|(YO_ERROR_BASE+32),
    YO_ERROR_SYSTEM           = YO_RUNTIME_ERROR_GROUP|(YO_ERROR_BASE+33),
    YO_ERROR_SYNTAX           = YO_ILLFORMED_ERROR_GROUP|(YO_ERROR_BASE+34),
    YO_ERROR_TESUITE_FAIL     = YO_SELFCHECK_ERROR_GROUP|(YO_ERROR_BASE+35),
    YO_ERROR_ASSERT_FAIL      = YO_SELFCHECK_ERROR_GROUP|(YO_ERROR_BASE+36),
    YO_ERROR_CONSTANT_NOT_FOUND = YO_RUNTIME_ERROR_GROUP|(YO_ERROR_BASE+37),
  };

#define YO_ERROR_IS_USER_ERROR(err) !(err&YO_XXXX_ERROR_GROUP)

enum _YO_FLAGS
  {
    YO_RAISE_ERROR            = 0x70000000,
................................................................................
  ;

void *Yo_Unwind_Scope(void *pooled,int min_top,void *mark)
#ifdef _YO_CORE_BUILTIN
  {
    YO_C_SUPPORT_INFO *nfo = __Tls_Get(Yo_Csup_Nfo_Tls);
    int L = min_top>=0?min_top:0;

    if ( nfo )
      {
        YO_AUTORELEASE *q_p = 0;
        nfo->stats.unwinding = 1;
        while ( nfo->auto_top >= L )
          {
            YO_AUTORELEASE *q = &nfo->auto_pool[nfo->auto_top];
            STRICT_REQUIRE(nfo->auto_top <= nfo->auto_count);

            if ( q->ptr && (q->cleanup != Yo_Pool_Marker_Tag) )
              {
                if ( !pooled || q->ptr != pooled )
                  {
                    q->cleanup(q->ptr);

                  }
                else
                  q_p = q;
              }
            --nfo->auto_top;
            if ( q->cleanup == Yo_Pool_Marker_Tag && !min_top && mark == q->ptr )
              break;
................................................................................
        if ( q_p )
          {
            ++nfo->auto_top;
            nfo->auto_pool[nfo->auto_top] = *q_p;
          }
        nfo->stats.unwinding = 0;
      }

    return pooled;
  }
#endif
  ;

#define Yo_Refresh(Old,New) Yo_Refresh_Ptr(Old,New,0)
void *Yo_Refresh_Ptr(void *old,void *new,void *cleaner)
................................................................................
        o->dynamic = 0;
        Yo_Object_Free(o);
      }
  }
#endif
  ;

void *Yo_Find_Method_In_Table(char *name, YO_FUNCTABLE *tbl, int count, int flags)
#ifdef _YO_CORE_BUILTIN
  {
    int i;
    for ( i = 0; i < count; ++i )
      if ( strcmp(tbl[i].name,name) == 0 )
        return tbl[i].func;
    return 0;
  }
#endif
  ;

void *Yo_Find_Method_Of(void *self /* VOID**  */, char *name, unsigned flags)
#ifdef _YO_CORE_BUILTIN
  {
    void *o = *(void**)self;
    if ( o && STRICT_CHECK(YO_SIGNAT_IS_OK(o)) )
      {
        YO_DYNAMIC *dynco = YO_BASE(o)->dynamic;
        if ( dynco )
................................................................................
    else if (flags & YO_RAISE_ERROR)
      Yo_Raise(YO_ERROR_METHOD_NOT_FOUND,name,__Yo_FILE__,__LINE__);
    return 0;
  }
#endif
  ;

longptr_t Yo_Find_Constant_Of(void *o, char *name, unsigned flags, longptr_t dflt)
#ifdef _YO_CORE_BUILTIN
  {
    if ( o && STRICT_CHECK(YO_SIGNAT_IS_OK(o)) )
      {
        YO_DYNAMIC *dynco = YO_BASE(o)->dynamic;
        if ( dynco )
          {
            if ( 1 && STRICT_CHECK((dynco->contsig>>8) == YO_DYNCO_ATS || (dynco->contsig>>8) == YO_DYNCO_NYD) )
              {
                void *f = Yo_Find_Method_In_Table(name,dynco->funcs,(dynco->contsig&0x0ff),flags);
                if ( !f && (flags & YO_RAISE_ERROR) )
                  Yo_Raise(YO_ERROR_CONSTANT_NOT_FOUND,name,__Yo_FILE__,__LINE__);
                return (longptr_t)f;
              }
            else
              Yo_Fatal(YO_ERROR_DYNCO_CORRUPTED,o,__Yo_FILE__,__LINE__);
          }
        else if (flags & YO_RAISE_ERROR)
          Yo_Raise(YO_ERROR_CONSTANT_NOT_FOUND,name,__Yo_FILE__,__LINE__);
      }
    else if (flags & YO_RAISE_ERROR)
      Yo_Raise(YO_ERROR_CONSTANT_NOT_FOUND,name,__Yo_FILE__,__LINE__);
    return dflt;
  }
#endif
  ;
    
void *Yo_Refe(void *p)
#ifdef _YO_CORE_BUILTIN
  {
    if ( p && STRICT_CHECK(YO_SIGNAT_IS_OK(p)) )
      __Atomic_Increment(&YO_RC(p));
    return p;
  }

Changes to zlib.hc.

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#endif
  ;
  
int Zlib_Buffer_Compress(YO_BUFFER *bf)
#ifdef _YO_ZLIB_BUILTIN
  {
    int succeded = 0;
    __Auto_Release 
      {
        ulong_t tmp_len = bf->count;
        YO_BUFFER *tmp = Buffer_Init(bf->count); 
        int zOk = compress(tmp->at,&tmp_len,bf->at,bf->count);
        if ( zOk != ZLIB_OK && zOk != ZLIB_BUF_ERROR )
          __Raise_Format(YO_ERROR_INCONSISTENT,("Zlib failed to compress buffer: %s", Zlib_Error(zOk)) );
        if ( zOk == ZLIB_OK )
................................................................................
  }
#endif
  ;
  
void Zlib_Buffer_Uncompress(YO_BUFFER *bf, int final_size)
#ifdef _YO_ZLIB_BUILTIN
  {
    __Auto_Release 
      {
        int zOk;
        ulong_t tmp_len;
        YO_BUFFER *tmp = Buffer_Init(final_size?final_size:bf->count*3); 
     repeat:
        tmp_len = tmp->count;
        zOk = uncompress(tmp->at,&tmp_len,bf->at,bf->count);







|







 







|







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#endif
  ;
  
int Zlib_Buffer_Compress(YO_BUFFER *bf)
#ifdef _YO_ZLIB_BUILTIN
  {
    int succeded = 0;
    if ( bf->count ) __Auto_Release 
      {
        ulong_t tmp_len = bf->count;
        YO_BUFFER *tmp = Buffer_Init(bf->count); 
        int zOk = compress(tmp->at,&tmp_len,bf->at,bf->count);
        if ( zOk != ZLIB_OK && zOk != ZLIB_BUF_ERROR )
          __Raise_Format(YO_ERROR_INCONSISTENT,("Zlib failed to compress buffer: %s", Zlib_Error(zOk)) );
        if ( zOk == ZLIB_OK )
................................................................................
  }
#endif
  ;
  
void Zlib_Buffer_Uncompress(YO_BUFFER *bf, int final_size)
#ifdef _YO_ZLIB_BUILTIN
  {
    if ( bf->count ) __Auto_Release 
      {
        int zOk;
        ulong_t tmp_len;
        YO_BUFFER *tmp = Buffer_Init(final_size?final_size:bf->count*3); 
     repeat:
        tmp_len = tmp->count;
        zOk = uncompress(tmp->at,&tmp_len,bf->at,bf->count);