summary refs log tree commit diff stats
path: root/test/test.py
Commit message (Collapse)AuthorAgeFilesLines
* added copyright info to config files and test caseshut2010-03-081-0/+15
|
* updated / added testshut2009-12-131-0/+5
ary/Implementation/HTUtils.h?id=e087f6d44e87f489fcb3056e86319ebba4218156'>e087f6d4
08fc6e5c ^
a2a1ab1e ^
08fc6e5c ^
e087f6d4

f7c3c4ca ^


08fc6e5c ^
e087f6d4


e4409c40 ^

50f9f94b ^






















97d3287a ^
d3f9d547 ^

d31fb3c4 ^
e4409c40 ^
10f6c5df ^

9a7862a6 ^
533c7482 ^
f61041c1 ^
10f6c5df ^

d3f9d547 ^

86b4d41a ^

e4409c40 ^


a735f5ad ^


1d80538b ^

d3f9d547 ^
327b7c16 ^
a735f5ad ^
e4409c40 ^

a2a1ab1e ^
8da648ea ^
10f6c5df ^
8da648ea ^
d4a8ec3c ^

244b955f ^



2b52e9e6 ^
e4409c40 ^
2b52e9e6 ^


e4409c40 ^
















945e8eb6 ^
e4409c40 ^


945e8eb6 ^



e4409c40 ^








e4409c40 ^
10f6c5df ^
e4409c40 ^






d1349dd6 ^

affaa4f7 ^







d31fb3c4 ^







d3f9d547 ^

02f28514 ^

2b52e9e6 ^



86b4d41a ^



ab1d1ae5 ^




45f1aadc ^




a2a1ab1e ^

2b52e9e6 ^
50f9f94b ^
c8a4110f ^



50f9f94b ^
a2a1ab1e ^



e087f6d4
9a7862a6 ^
e4409c40 ^
9a7862a6 ^
a2a1ab1e ^

e4409c40 ^

a2a1ab1e ^




e4409c40 ^
08fc6e5c ^
9c512bba ^




03413d1c ^
4bb52da7 ^
e087f6d4

d1349dd6 ^



0cb11571 ^




b9e930ec ^
0cb11571 ^





e087f6d4


08fc6e5c ^
e087f6d4
08fc6e5c ^
e087f6d4
08fc6e5c ^
e087f6d4







244b955f ^
e087f6d4
244b955f ^














e087f6d4












e087f6d4




e087f6d4



e087f6d4
e087f6d4

















a2a1ab1e ^
e087f6d4




















































08fc6e5c ^

e087f6d4





f6e997b7 ^

0cb11571 ^
4525eb4b ^

ab1d1ae5 ^


4525eb4b ^

ab1d1ae5 ^
f6e997b7 ^


e087f6d4

c7bfda90 ^


a2a1ab1e ^
c7bfda90 ^






e087f6d4








03413d1c ^
e087f6d4





08fc6e5c ^
e087f6d4
08fc6e5c ^
e087f6d4



03413d1c ^
e087f6d4




c3ec4181 ^

e087f6d4







5b288495 ^
e087f6d4
aa7067e1 ^


5b288495 ^
e087f6d4


aa7067e1 ^
e087f6d4
87434eaa ^


e087f6d4

87434eaa ^

3aee60ca ^
e087f6d4



fbcb509d ^

d3f9d547 ^
87434eaa ^
08fc6e5c ^

87434eaa ^



50f9f94b ^


8ce6b560 ^
08fc6e5c ^
e087f6d4

e087f6d4
6cb04c09 ^
d4a8ec3c ^





2a256611 ^

6cb04c09 ^
2a256611 ^
2a256611 ^
d3f9d547 ^
e087f6d4
2a256611 ^




6cb04c09 ^
0cb11571 ^
2a256611 ^


e087f6d4
6cb04c09 ^
e087f6d4
2a256611 ^

e087f6d4









af9be28b ^
e087f6d4
d3f9d547 ^
e087f6d4
e087f6d4
50f9f94b ^






e087f6d4




50f9f94b ^












5b288495 ^

50f9f94b ^



86b4d41a ^
e087f6d4
533c7482 ^
d3f9d547 ^
e087f6d4




08fc6e5c ^
e087f6d4
08fc6e5c ^
e087f6d4



4bb52da7 ^





8c68f693 ^
4bb52da7 ^

d1349dd6 ^
4bb52da7 ^



17f50de9 ^
4bb52da7 ^

f78e2771 ^
03413d1c ^
4bb52da7 ^
8c68f693 ^
d1349dd6 ^
8c68f693 ^



d1349dd6 ^

d3f9d547 ^

4bb52da7 ^
d3f9d547 ^


a2a1ab1e ^
0eae931d ^

d3f9d547 ^







0eae931d ^
d3f9d547 ^
08fc6e5c ^
d3f9d547 ^










d31fb3c4 ^




















d3f9d547 ^



d31fb3c4 ^

03413d1c ^
d31fb3c4 ^




03413d1c ^
d31fb3c4 ^
03413d1c ^











d31fb3c4 ^




03413d1c ^

d31fb3c4 ^







0cb11571 ^
d83d4af1 ^

d83d4af1 ^

0cb11571 ^
d83d4af1 ^

d83d4af1 ^





0654c702 ^

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

   


                                                                 
 


                 

                                                                      






















                                                       
                      

                  
                          
 

                                                                           
                       
                     
                   

                  

                  

                                   


                               


                                                               

                 
                  
               
                                          

      
                                                          
                      
                    
                       

      



                                     
                                                             
 


                          
















                          
                 


                     



                      








                         
                   
                     






                       

                          







                        







                 

                      

      



                                  



                                




                                                                        




                                                               

                                                         
                                                                                 
                                                           



                           
                                                          



                                                         
                       
                                                               
                
      

                                                               

                      




                              
                     
 




                                     
                                                               
                           

      



                                                                        




                                                                        
                                                                                                                  





                                                             


            
 
                                                                                        
                                                                                     
                                                
 







                                                                                   
                    
                   














                                                                  












                                            




                   



                    
                    

















                                                                        
                                                                   




















































                                                                               

 





                            

                                            
                                        

                                              


                                                

                                                                           
 


                                                                           

  


                         
 






                                           








                                                                                
                                                   





                          
                               
                       
                       



                    
 




                      

                                                               







                                                                           
                                          
 


                                                                          
                                            


  
                                    
 


                                                                       

   

                                                                 
                                                             



                                                            

                                                             
                              
 

                                                                                  



                                                                  


                                                                                
 
                                                                           

                                                           
              
                                                    





                       

      
                         
                                                 
     
                                          
      




                                                                               
                      
                                                                       


                                                                       
      
      
 

                                              









                                           
                   
 
                                                                   
 
  






                                                                           




                   












                                        

                                                               



                                    
                    
 
                                                             
 




                                                                              
                                                                                       
               
 



                                                                              





                         
                         

                             
                         



                                                                  
                                      

                                      
                                      
                                      
 
                         
                                                                        



                                  

                                                                         

                                                                      
                                                


                              
                    

  







                                                                            
 
  
                                                                        










                                                  




















                                                                         



                                                                

                            
 




                           
 
     











                                                                         




                   

                             







                                                      
                      

                                                   

      
                       

                                                    





                                     

                     
                      
/*                                       Utility macros for the W3 code library
                                  MACROS FOR GENERAL USE

   See also: the system dependent file "www_tcp.h", which is included here.

 */

#ifndef NO_LYNX_TRACE
#define DEBUG   /* Turns on trace; turn off for smaller binary */
#endif

#ifndef HTUTILS_H
#define HTUTILS_H

#ifdef HAVE_CONFIG_H
#include <lynx_cfg.h>	/* generated by autoconf 'configure' script */

/* see AC_FUNC_ALLOCA macro */
#ifdef __GNUC__
# define alloca __builtin_alloca
#else
# ifdef _MSC_VER
#  include <malloc.h>
#  define alloca _alloca
# else
#  if HAVE_ALLOCA_H
#   include <alloca.h>
#  else
#   ifdef _AIX
 #pragma alloca
#   else
#    ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
#    endif
#   endif
#  endif
# endif
#endif

#include <sys/types.h>
#include <stdio.h>

#else  /* HAVE_CONFIG_H */

#ifdef DJGPP
#include <sys/config.h>	/* pseudo-autoconf values for DJGPP libc/headers */
#define HAVE_TRUNCATE 1
#define HAVE_ALLOCA 1
#include <limits.h>
#endif /* DJGPP */

#include <stdio.h>

#define DONT_TRACK_INTERNAL_LINKS 1

/* Explicit system-configure */
#ifdef VMS
#define NO_SIZECHANGE
#if defined(VAXC) && !defined(__DECC)
#define NO_UNISTD_H	/* DEC C has unistd.h, but not VAX C */
#endif
#define NO_KEYPAD
#define NO_UTMP
#define NO_FILIO_H
#define NOUSERS
#define DISP_PARTIAL	/* experimental */
#endif

#if defined(__STDC__) || defined(VMS) || defined(_WINDOWS)
#define ANSI_VARARGS 1
#undef HAVE_STDARG_H
#define HAVE_STDARG_H 1
#endif

#if defined(VMS) || defined(_WINDOWS)
#define HAVE_STDLIB_H 1
#endif

/* Accommodate non-autoconf'd Makefile's (VMS, DJGPP, etc) */

#ifndef NO_ARPA_INET_H
#define HAVE_ARPA_INET_H 1
#endif

#ifndef NO_CBREAK
#define HAVE_CBREAK 1
#endif

#ifndef NO_CUSERID
#define HAVE_CUSERID 1
#endif

#ifndef NO_FILIO_H
#define HAVE_SYS_FILIO_H 1
#endif

#ifndef NO_GETCWD
#define HAVE_GETCWD 1
#endif

#ifndef USE_SLANG
#ifndef NO_KEYPAD
#define HAVE_KEYPAD 1
#endif
#ifndef NO_TTYTYPE
#define HAVE_TTYTYPE 1
#endif
#endif /* USE_SLANG */

#ifndef NO_PUTENV
#define HAVE_PUTENV 1
#endif

#ifndef NO_SIZECHANGE
#define HAVE_SIZECHANGE 1
#endif

#ifndef NO_UNISTD_H
#undef  HAVE_UNISTD_H
#define HAVE_UNISTD_H 1
#endif

#ifndef NO_UTMP
#define HAVE_UTMP 1
#endif

#endif /* HAVE_CONFIG_H */

#ifndef lynx_srand
#define lynx_srand srand
#endif

#ifndef lynx_rand
#define lynx_rand rand
#endif

#if '0' != 48
#define NOT_ASCII
#endif

#if '0' == 240
#define EBCDIC
#endif

#ifndef LY_MAXPATH
#define LY_MAXPATH 256
#endif

#ifndef	GCC_NORETURN
#define	GCC_NORETURN /* nothing */
#endif

#ifndef	GCC_UNUSED
#define	GCC_UNUSED /* nothing */
#endif

/* FIXME: need a configure-test */
#if defined(__STDC__) || defined(__DECC) || defined(_WINDOWS) || _WIN_CC
#define ANSI_PREPRO 1
#endif

#if defined(__CYGWIN32__) && ! defined(__CYGWIN__)
#define __CYGWIN__ 1
#endif

#if defined(__CYGWIN__)		/* 1998/12/31 (Thu) 16:13:46 */
#include <windows.h>		/* #include "windef.h" */
#define BOOLEAN_DEFINED
#undef HAVE_POPEN		/* FIXME: does this not work, or is it missing */
#undef small			/* see <w32api/rpcndr.h> */
#endif

/* cygwin, mingw32, etc. */
#ifdef FILE_DOES_NOT_EXIST
#undef FILE_DOES_NOT_EXIST	/* see <w32api/winnt.h> */
#endif

#if defined(_WINDOWS) && !defined(__CYGWIN__)	/* SCW */
#include <windows.h>		/* #include "windef.h" */
#define BOOLEAN_DEFINED
#if !_WIN_CC			/* 1999/09/29 (Wed) 22:00:53 */
#include <dos.h>
#endif
#undef sleep			/* 1998/06/23 (Tue) 16:54:53 */
extern void sleep(unsigned __seconds);
#define popen _popen
#define pclose _pclose

#if defined(_MSC_VER)
typedef unsigned short mode_t;
#endif

#endif /* _WINDOWS */

#ifndef USE_COLOR_STYLE
    /* it's useless for such setup */
#  define NO_EMPTY_HREFLESS_A
#endif

#if  defined(__EMX__) || defined(WIN_EX) || defined(HAVE_POPEN)
#  define CAN_CUT_AND_PASTE
#endif

#if defined(USE_SLANG) || (defined(USE_COLOR_STYLE) && defined(__EMX__))
#  define USE_BLINK
#endif

#if defined(DOSPATH) || defined(__EMX__)
#  define USE_DOS_DRIVES	/* we allow things like "c:" in paths */
#endif

#if defined(UNIX)
#  if (defined(__BEOS__) || defined(__CYGWIN__) || defined(__DJGPP__) || defined(__EMX__) || defined(__MINGW32__))
#    define SINGLE_USER_UNIX	/* well, at least they try */
#  else
#    define MULTI_USER_UNIX
#  endif
#endif

/*

  ERROR TYPE

   This is passed back when streams are aborted. It might be nice to have some structure
   of error messages, numbers, and recursive pointers to reasons.  Curently this is a
   placeholder for something more sophisticated.

 */
typedef void * HTError;                 /* Unused at present -- best definition? */

/*

Standard C library for malloc() etc

 */
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif

#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif

#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif

#ifdef __EMX__
#include <unistd.h> /* should be re-include protected under EMX */
#define getcwd _getcwd2
#define chdir _chdir2
#endif

#ifdef vax
#ifdef unix
#define ultrix  /* Assume vax+unix=ultrix */
#endif /* unix */
#endif /* vax */

#ifndef VMS
#ifndef ultrix

#ifdef NeXT
#include <libc.h>       /* NeXT */
#endif /* NeXT */

#else /* ultrix: */

#include <malloc.h>
#include <memory.h>

#endif /* !ultrix */
#else   /* VMS: */

#include <unixlib.h>
#if defined(VAXC) && !defined(__DECC)
#define malloc	VAXC$MALLOC_OPT
#define calloc	VAXC$CALLOC_OPT
#define free	VAXC$FREE_OPT
#define cfree	VAXC$CFREE_OPT
#define realloc	VAXC$REALLOC_OPT
#endif /* VAXC && !__DECC */

#endif /* !VMS */

/*

Macros for declarations

 */
#define PUBLIC                  /* Accessible outside this module     */
#define PRIVATE static          /* Accessible only within this module */

#if defined(__STDC__) || defined(__BORLANDC__) || defined(_MSC_VER)
#define CONST const             /* "const" only exists in STDC */
#define NOPARAMS (void)
#define PARAMS(parameter_list) parameter_list
#define NOARGS (void)
#define ARGS1(t,a) \
                (t a)
#define ARGS2(t,a,u,b) \
                (t a, u b)
#define ARGS3(t,a,u,b,v,c) \
                (t a, u b, v c)
#define ARGS4(t,a,u,b,v,c,w,d) \
                (t a, u b, v c, w d)
#define ARGS5(t,a,u,b,v,c,w,d,x,e) \
                (t a, u b, v c, w d, x e)
#define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \
                (t a, u b, v c, w d, x e, y f)
#define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \
                (t a, u b, v c, w d, x e, y f, z g)
#define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \
                (t a, u b, v c, w d, x e, y f, z g, s h)
#define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \
                (t a, u b, v c, w d, x e, y f, z g, s h, r i)
#define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \
                (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j)

#else  /* not ANSI */

#ifndef _WINDOWS
#define CONST
#endif
#define NOPARAMS ()
#define PARAMS(parameter_list) ()
#define NOARGS ()
#define ARGS1(t,a) (a) \
                t a;
#define ARGS2(t,a,u,b) (a,b) \
                t a; u b;
#define ARGS3(t,a,u,b,v,c) (a,b,c) \
                t a; u b; v c;
#define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \
                t a; u b; v c; w d;
#define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \
                t a; u b; v c; w d; x e;
#define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \
                t a; u b; v c; w d; x e; y f;
#define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \
                t a; u b; v c; w d; x e; y f; z g;
#define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) (a,b,c,d,e,f,g,h) \
                t a; u b; v c; w d; x e; y f; z g; s h;
#define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) (a,b,c,d,e,f,g,h,i) \
                t a; u b; v c; w d; x e; y f; z g; s h; r i;
#define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) (a,b,c,d,e,f,g,h,i,j) \
                t a; u b; v c; w d; x e; y f; z g; s h; r i; q j;


#endif /* __STDC__ (ANSI) */

#ifndef NULL
#define NULL ((void *)0)
#endif

#define isEmpty(s)   ((s) == 0 || *(s) == 0)

#define NonNull(s) (((s) != 0) ? s : "")
#define NONNULL(s) (((s) != 0) ? s : "(null)")

/* array/table size */
#define	TABLESIZE(v)	(sizeof(v)/sizeof(v[0]))

#define	typecalloc(cast)		(cast *)calloc(1,sizeof(cast))
#define	typecallocn(cast,ntypes)	(cast *)calloc(ntypes,sizeof(cast))

#define typeMalloc(cast)                (cast *)malloc(sizeof(cast))
#define typeMallocn(cast,ntypes)        (cast *)malloc(ntypes*sizeof(cast))

/*

OFTEN USED INTEGER MACROS

  Min and Max functions

 */
#ifndef HTMIN
#define HTMIN(a,b) ((a) <= (b) ? (a) : (b))
#define HTMAX(a,b) ((a) >= (b) ? (a) : (b))
#endif
/*

Booleans

 */
/* Note: GOOD and BAD are already defined (differently) on RS6000 aix */
/* #define GOOD(status) ((status)38;1)   VMS style status: test bit 0         */
/* #define BAD(status)  (!GOOD(status))  Bit 0 set if OK, otherwise clear   */

#ifndef _WINDOWS
#ifndef BOOLEAN_DEFINED
    typedef char    BOOLEAN;	/* Logical value */
#ifndef CURSES
#ifndef TRUE
#define TRUE    (BOOLEAN)1
#define FALSE   (BOOLEAN)0
#endif
#endif   /*  CURSES  */
#endif	 /*  BOOLEAN_DEFINED */
#define BOOLEAN_DEFINED
#endif   /* _WINDOWS */

#ifndef BOOL
#define BOOL BOOLEAN
#endif

#ifndef YES
#define YES (BOOLEAN)1
#define NO (BOOLEAN)0
#endif

extern BOOL LYOutOfMemory;	/* Declared in LYexit.c - FM */

#define TCP_PORT 80     /* Allocated to http by Jon Postel/ISI 24-Jan-92 */
#define OLD_TCP_PORT 2784       /* Try the old one if no answer on 80 */
#define DNP_OBJ 80      /* This one doesn't look busy, but we must check */
                        /* That one was for decnet */

/*      Inline Function WHITE: Is character c white space? */
/*      For speed, include all control characters */

#define WHITE(c) ((UCH(TOASCII(c))) <= 32)

/*     Inline Function LYIsASCII: Is character c a traditional ASCII
**     character (i.e. <128) after converting from host character set.  */

#define LYIsASCII(c) (TOASCII(UCH(c)) < 128)

/*

Success (>=0) and failure (<0) codes

Some of the values are chosen to be HTTP-like, but status return values
are generally not the response status from any specific protocol.

 */

#define HT_REDIRECTING 399
#define HT_LOADED 200                   /* Instead of a socket */
#define HT_PARTIAL_CONTENT      206     /* Partial Content */
#define HT_INTERRUPTED -29998
#define HT_NOT_LOADED -29999
#define HT_OK           0               /* Generic success*/

#define HT_ERROR                -1      /* Generic failure */

#define HT_CANNOT_TRANSLATE -4

#define HT_NO_DATA		-204	/* OK but no data was loaded - */
					/* possibly other app started or forked */
#define HT_NO_ACCESS            -401    /* Access not available */
#define HT_FORBIDDEN            -403    /* Access forbidden */
#define HT_NOT_ACCEPTABLE       -406    /* Not Acceptable */

#define HT_PARSER_REOPEN_ELT     700    /* tells SGML parser to keep tag open */
#define HT_PARSER_OTHER_CONTENT  701    /* tells SGML to change content model */
#define HT_H_ERRNO_VALID        -800    /* see h_errno for resolver error */

#define HT_INTERNAL             -900    /* Weird -- should never happen. */
#define HT_BAD_EOF      -12             /* Premature EOF */

#ifndef va_arg
# if defined(HAVE_STDARG_H) && defined(ANSI_VARARGS)
#  include <stdarg.h>
# else
#  if HAVE_VARARGS_H
#   include <varargs.h>
#  endif
# endif
#endif

#if defined(ANSI_VARARGS)
#define LYva_start(ap,format) va_start(ap,format)
#else
#define LYva_start(ap,format) va_start(ap)
#endif

/*
 * GCC can be told that some functions are like printf (and do type-checking on
 * their parameters).
 */
#ifndef GCC_PRINTFLIKE
#if defined(GCC_PRINTF) && !defined(printf) && !defined(HAVE_LIBUTF8_H)
#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
#else
#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
#endif
#endif

#include <HTString.h>   /* String utilities */

/*

Out Of Memory checking for malloc() return:

 */
#ifndef __FILE__
#define __FILE__ ""
#define __LINE__ ""
#endif

#include <LYexit.h>

extern void outofmem PARAMS((CONST char *fname, CONST char *func));

/*
 * Upper- and Lowercase macros
 *
 * The problem here is that toupper(x) is not defined officially unless
 * isupper(x) is.  These macros are CERTAINLY needed on #if defined(pyr) ||
 * define(mips) or BDSI platforms.  For safefy, we make them mandatory.
 *
 * Note: Pyramid and Mips can't uppercase non-alpha.
 */
#include <ctype.h>
#include <string.h>

#ifndef TOLOWER

#ifdef EXP_ASCII_CTYPES

#define TOLOWER(c) ascii_tolower(UCH(c))
#define TOUPPER(c) ascii_toupper(UCH(c))
#define ISUPPER(c) ascii_isupper(UCH(c))

extern int ascii_toupper PARAMS((int));
extern int ascii_tolower PARAMS((int));
extern int ascii_isupper PARAMS((int));

#else

#define TOLOWER(c) (isupper(UCH(c)) ? tolower(UCH(c)) : UCH(c))
#define TOUPPER(c) (islower(UCH(c)) ? toupper(UCH(c)) : UCH(c))
#define ISUPPER(c) (isupper(UCH(c)))

#endif

#endif /* TOLOWER */

#define FREE(x)    {if (x != 0) {free((char *)x); x = NULL;}}

/*

The local equivalents of CR and LF

   We can check for these after net ascii text has been converted to the local
   representation.  Similarly, we include them in strings to be sent as net ascii after
   translation.

 */
#define LF   FROMASCII('\012')  /* ASCII line feed LOCAL EQUIVALENT */
#define CR   FROMASCII('\015')  /* Will be converted to ^M for transmission */

/*
 * Debug message control.
 */
#ifdef NO_LYNX_TRACE
#define WWW_TraceFlag   0
#define WWW_TraceMask   0
#define LYTraceLogFP    0
#else
extern BOOLEAN WWW_TraceFlag;
extern int WWW_TraceMask;
#endif

#define TRACE           (WWW_TraceFlag)
#define TRACE_bit(n)    (TRACE && (WWW_TraceMask & (1 << n)) != 0)
#define TRACE_SGML      (TRACE_bit(0))
#define TRACE_STYLE     (TRACE_bit(1))
#define TRACE_TRST      (TRACE_bit(2))
#define TRACE_CFG       (TRACE_bit(3))
#define TRACE_BSTRING   (TRACE_bit(4))

#if defined(LY_TRACELINE)
#define LY_SHOWWHERE fprintf( tfp, "%s: %d: ", __FILE__, LY_TRACELINE ),
#else
#define LY_SHOWWHERE /* nothing */
#endif

#define CTRACE(p)         ((void)((TRACE) && ( LY_SHOWWHERE fprintf p )))
#define CTRACE2(m,p)      ((void)((m)     && ( LY_SHOWWHERE fprintf p )))
#define tfp TraceFP()
#define CTRACE_SLEEP(secs) if (TRACE && LYTraceLogFP == 0) sleep(secs)
#define CTRACE_FLUSH(fp)   if (TRACE) fflush(fp)

extern FILE *TraceFP NOPARAMS;

#include <www_tcp.h>

/*
 * We force this include-ordering since socks.h contains redefinitions of
 * functions that probably are prototyped via other includes.  The socks.h
 * definitions have to be included everywhere, since they're making wrappers
 * for the stdio functions as well as the network functions.
 */
#if defined(USE_SOCKS5) && !defined(DONT_USE_SOCKS5)
#define SOCKS4TO5	/* turn on the Rxxxx definitions used in Lynx */
#include <socks.h>

/*
 * The AIX- and SOCKS4-specific definitions in socks.h are inconsistent.
 * Repair them so they're consistent (and usable).
 */
#if defined(_AIX) && !defined(USE_SOCKS4_PREFIX)
#undef  Raccept
#define Raccept       accept
#undef  Rgetsockname
#define Rgetsockname  getsockname
#undef  Rgetpeername
#define Rgetpeername  getpeername
#endif

/*
 * Workaround for order-of-evaluation problem with gcc and socks5 headers
 * which breaks the Rxxxx names by attaching the prefix twice:
 */
#ifdef INCLUDE_PROTOTYPES
#undef  Raccept
#undef  Rbind
#undef  Rconnect
#undef  Rlisten
#undef  Rselect
#undef  Rgetpeername
#undef  Rgetsockname
#define Raccept       accept
#define Rbind         bind
#define Rconnect      connect
#define Rgetpeername  getpeername
#define Rgetsockname  getsockname
#define Rlisten       listen
#define Rselect       select
#endif

#endif /* USE_SOCKS5 */

#define SHORTENED_RBIND	/* FIXME: do this in configure-script */

#ifdef USE_SSL
#define free_func free__func

#ifdef USE_OPENSSL_INCL
#include <openssl/ssl.h>
#include <openssl/crypto.h>
#include <openssl/rand.h>
#include <openssl/err.h>

#else

#ifdef USE_GNUTLS_INCL
#include <gnutls/openssl.h>
/*
 * GNUTLS's implementation of OpenSSL is very incomplete and rudimentary.
 * For a start, let's make it compile (TD - 2003/4/13).
 */
#ifndef SSL_VERIFY_PEER
#define SSL_VERIFY_PEER			0x01
#endif

#else	/* assume SSLeay */
#include <ssl.h>
#include <crypto.h>
#include <rand.h>
#include <err.h>
#endif
#endif /* USE_OPENSSL_INCL */

#undef free_func

extern SSL * HTGetSSLHandle NOPARAMS;
extern void HTSSLInitPRNG NOPARAMS;
extern char HTGetSSLCharacter PARAMS((void * handle));

#endif /* USE_SSL */

#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>    /* Gray Watson's library */
#define show_alloc() dmalloc_log_unfreed()
#endif

#ifdef HAVE_LIBDBMALLOC
#include <dbmalloc.h>   /* Conor Cahill's library */
#define show_alloc() malloc_dump(fileno(stderr))
#endif

#ifndef show_alloc
#define show_alloc()	/* nothing */
#endif

#include <userdefs.h>

#endif /* HTUTILS_H */