Fossil SCM

Part one of src/ file relocations discussed in /chat. This step moves the various code generators and translators from src/ to tools/.

stephan 2021-12-25 12:06 trunk
Commit a13ab011f40894d26e9284d8b851322b4e883a182419b75e869051e624588f13
--- Makefile.in
+++ Makefile.in
@@ -7,10 +7,11 @@
77
#### The toplevel directory of the source tree. Fossil can be built
88
# in a directory that is separate from the source tree. Just change
99
# the following to point from the build directory to the src/ folder.
1010
#
1111
SRCDIR = @srcdir@/src
12
+SRCDIR.tools = @srcdir@/tools
1213
1314
#### The directory into which object code files should be written.
1415
# Having a "./" prefix in the value of this variable breaks our use of the
1516
# "makeheaders" tool when running make on the MinGW platform, apparently
1617
# due to some command line argument manipulation performed automatically
1718
1819
DELETED src/codecheck1.c
--- Makefile.in
+++ Makefile.in
@@ -7,10 +7,11 @@
7 #### The toplevel directory of the source tree. Fossil can be built
8 # in a directory that is separate from the source tree. Just change
9 # the following to point from the build directory to the src/ folder.
10 #
11 SRCDIR = @srcdir@/src
 
12
13 #### The directory into which object code files should be written.
14 # Having a "./" prefix in the value of this variable breaks our use of the
15 # "makeheaders" tool when running make on the MinGW platform, apparently
16 # due to some command line argument manipulation performed automatically
17
18 ELETED src/codecheck1.c
--- Makefile.in
+++ Makefile.in
@@ -7,10 +7,11 @@
7 #### The toplevel directory of the source tree. Fossil can be built
8 # in a directory that is separate from the source tree. Just change
9 # the following to point from the build directory to the src/ folder.
10 #
11 SRCDIR = @srcdir@/src
12 SRCDIR.tools = @srcdir@/tools
13
14 #### The directory into which object code files should be written.
15 # Having a "./" prefix in the value of this variable breaks our use of the
16 # "makeheaders" tool when running make on the MinGW platform, apparently
17 # due to some command line argument manipulation performed automatically
18
19 ELETED src/codecheck1.c
D src/codecheck1.c
-596
--- a/src/codecheck1.c
+++ b/src/codecheck1.c
@@ -1,596 +0,0 @@
1
-/*
2
-** Copyright (c) 2014 D. Richard Hipp
3
-**
4
-** This program is free software; you can redistribute it and/or
5
-** modify it under the terms of the Simplified BSD License (also
6
-** known as the "2-Clause License" or "FreeBSD License".)
7
-**
8
-** This program is distributed in the hope that it will be useful,
9
-** but without any warranty; without even the implied warranty of
10
-** merchantability or fitness for a particular purpose.
11
-**
12
-** Author contact information:
13
-** [email protected]
14
-** http://www.hwaci.com/drh/
15
-**
16
-*******************************************************************************
17
-**
18
-** This program reads Fossil source code files and tries to verify that
19
-** printf-style format strings are correct.
20
-**
21
-** This program implements a compile-time validation step on the Fossil
22
-** source code. Running this program is entirely optional. Its role is
23
-** similar to the -Wall compiler switch on gcc, or the scan-build utility
24
-** of clang, or other static analyzers. The purpose is to try to identify
25
-** problems in the source code at compile-time. The difference is that this
26
-** static checker is specifically designed for the particular printf formatter
27
-** implementation used by Fossil.
28
-**
29
-** Checks include:
30
-**
31
-** * Verify that vararg formatting routines like blob_printf() or
32
-** db_multi_exec() have the correct number of arguments for their
33
-** format string.
34
-**
35
-** * For routines designed to generate SQL, warn about the use of %s
36
-** which might allow SQL injection possible injection attacks.
37
-*/
38
-#include <stdio.h>
39
-#include <stdlib.h>
40
-#include <ctype.h>
41
-#include <string.h>
42
-#include <assert.h>
43
-
44
-/*
45
-** Debugging switch
46
-*/
47
-static int eVerbose = 0;
48
-
49
-/*
50
-** Malloc, aborting if it fails.
51
-*/
52
-void *safe_malloc(int nByte){
53
- void *x = malloc(nByte);
54
- if( x==0 ){
55
- fprintf(stderr, "failed to allocate %d bytes\n", nByte);
56
- exit(1);
57
- }
58
- return x;
59
-}
60
-void *safe_realloc(void *pOld, int nByte){
61
- void *x = realloc(pOld, nByte);
62
- if( x==0 ){
63
- fprintf(stderr, "failed to allocate %d bytes\n", nByte);
64
- exit(1);
65
- }
66
- return x;
67
-}
68
-
69
-/*
70
-** Read the entire content of the file named zFilename into memory obtained
71
-** from malloc(). Add a zero-terminator to the end.
72
-** Return a pointer to that memory.
73
-*/
74
-static char *read_file(const char *zFilename){
75
- FILE *in;
76
- char *z;
77
- int nByte;
78
- int got;
79
- in = fopen(zFilename, "rb");
80
- if( in==0 ){
81
- return 0;
82
- }
83
- fseek(in, 0, SEEK_END);
84
- nByte = ftell(in);
85
- fseek(in, 0, SEEK_SET);
86
- z = safe_malloc( nByte+1 );
87
- got = fread(z, 1, nByte, in);
88
- z[got] = 0;
89
- fclose(in);
90
- return z;
91
-}
92
-
93
-/*
94
-** When parsing the input file, the following token types are recognized.
95
-*/
96
-#define TK_SPACE 1 /* Whitespace or comments */
97
-#define TK_ID 2 /* An identifier */
98
-#define TK_STR 3 /* A string literal in double-quotes */
99
-#define TK_OTHER 4 /* Any other token */
100
-#define TK_EOF 99 /* End of file */
101
-
102
-/*
103
-** Determine the length and type of the token beginning at z[0]
104
-*/
105
-static int token_length(const char *z, int *pType, int *pLN){
106
- int i;
107
- if( z[0]==0 ){
108
- *pType = TK_EOF;
109
- return 0;
110
- }
111
- if( z[0]=='"' || z[0]=='\'' ){
112
- for(i=1; z[i] && z[i]!=z[0]; i++){
113
- if( z[i]=='\\' && z[i+1]!=0 ){
114
- if( z[i+1]=='\n' ) (*pLN)++;
115
- i++;
116
- }
117
- }
118
- if( z[i]!=0 ) i++;
119
- *pType = z[0]=='"' ? TK_STR : TK_OTHER;
120
- return i;
121
- }
122
- if( isalnum(z[0]) || z[0]=='_' ){
123
- for(i=1; isalnum(z[i]) || z[i]=='_'; i++){}
124
- *pType = isalpha(z[0]) || z[0]=='_' ? TK_ID : TK_OTHER;
125
- return i;
126
- }
127
- if( isspace(z[0]) ){
128
- if( z[0]=='\n' ) (*pLN)++;
129
- for(i=1; isspace(z[i]); i++){
130
- if( z[i]=='\n' ) (*pLN)++;
131
- }
132
- *pType = TK_SPACE;
133
- return i;
134
- }
135
- if( z[0]=='/' && z[1]=='*' ){
136
- for(i=2; z[i] && (z[i]!='*' || z[i+1]!='/'); i++){
137
- if( z[i]=='\n' ) (*pLN)++;
138
- }
139
- if( z[i] ) i += 2;
140
- *pType = TK_SPACE;
141
- return i;
142
- }
143
- if( z[0]=='/' && z[1]=='/' ){
144
- for(i=2; z[i] && z[i]!='\n'; i++){}
145
- if( z[i] ){
146
- (*pLN)++;
147
- i++;
148
- }
149
- *pType = TK_SPACE;
150
- return i;
151
- }
152
- if( z[0]=='\\' && (z[1]=='\n' || (z[1]=='\r' && z[2]=='\n')) ){
153
- *pType = TK_SPACE;
154
- return 1;
155
- }
156
- *pType = TK_OTHER;
157
- return 1;
158
-}
159
-
160
-/*
161
-** Return the next non-whitespace token
162
-*/
163
-const char *next_non_whitespace(const char *z, int *pLen, int *pType){
164
- int len;
165
- int eType;
166
- int ln = 0;
167
- while( (len = token_length(z, &eType, &ln))>0 && eType==TK_SPACE ){
168
- z += len;
169
- }
170
- *pLen = len;
171
- *pType = eType;
172
- return z;
173
-}
174
-
175
-/*
176
-** Return index into z[] for the first balanced TK_OTHER token with
177
-** value cValue.
178
-*/
179
-static int distance_to(const char *z, char cVal){
180
- int len;
181
- int dist = 0;
182
- int eType;
183
- int nNest = 0;
184
- int ln = 0;
185
- while( z[0] && (len = token_length(z, &eType, &ln))>0 ){
186
- if( eType==TK_OTHER ){
187
- if( z[0]==cVal && nNest==0 ){
188
- break;
189
- }else if( z[0]=='(' ){
190
- nNest++;
191
- }else if( z[0]==')' ){
192
- nNest--;
193
- }
194
- }
195
- dist += len;
196
- z += len;
197
- }
198
- return dist;
199
-}
200
-
201
-/*
202
-** Return the first non-whitespace characters in z[]
203
-*/
204
-static const char *skip_space(const char *z){
205
- while( isspace(z[0]) ){ z++; }
206
- return z;
207
-}
208
-
209
-/*
210
-** Remove excess whitespace and nested "()" from string z.
211
-*/
212
-static char *simplify_expr(char *z){
213
- int n = (int)strlen(z);
214
- while( n>0 ){
215
- if( isspace(z[0]) ){
216
- z++;
217
- n--;
218
- continue;
219
- }
220
- if( z[0]=='(' && z[n-1]==')' ){
221
- z++;
222
- n -= 2;
223
- continue;
224
- }
225
- break;
226
- }
227
- z[n] = 0;
228
- return z;
229
-}
230
-
231
-/*
232
-** Return true if the input is a string literal.
233
-*/
234
-static int is_string_lit(const char *z){
235
- int nu1, nu2;
236
- z = next_non_whitespace(z, &nu1, &nu2);
237
- if( strcmp(z, "NULL")==0 ) return 1;
238
- return z[0]=='"';
239
-}
240
-
241
-/*
242
-** Return true if the input is an expression of string literals:
243
-**
244
-** EXPR ? "..." : "..."
245
-*/
246
-static int is_string_expr(const char *z){
247
- int len = 0, eType;
248
- const char *zOrig = z;
249
- len = distance_to(z, '?');
250
- if( z[len]==0 && skip_space(z)[0]=='(' ){
251
- z = skip_space(z) + 1;
252
- len = distance_to(z, '?');
253
- }
254
- z += len;
255
- if( z[0]=='?' ){
256
- z++;
257
- z = next_non_whitespace(z, &len, &eType);
258
- if( eType==TK_STR ){
259
- z += len;
260
- z = next_non_whitespace(z, &len, &eType);
261
- /*
262
-** Retuan redistribute i/*
263
-** Copyright (c) 2014 D. Richard Hipp
264
-**
265
-** This program is free software; you can redistribute it and/or
266
-** modify it under the terms of the Simplified BSD License (also
267
-** known as the "2-Clause License" or "FreeBSD License".)
268
-**
269
-** This program is distributed in the hope that it will be useful,
270
-** but without any warranty; without even the implied warranty of
271
-** merchantability or fitness for a particular purpose.
272
-**
273
-** Author contact information:
274
-** [email protected]
275
-** http://www.hwaci.com/drh/
276
-**
277
-******SAFE printf("%s:%d: Argu a query parameter\1, lnFCall, i+fmtArg, szFName, zFCall);
278
- nErr++;
279
-
280
- 20},
281
- { "( (fmtFlags & FMT_SQL)!=0 && !is_sql_safe(zExpr) ){
282
- printf("%s:%d: Argument %d to %.*s() not safe for SQL\n",
283
- zFilename, lnFCall, i+fmtArg, szFName, zFCall);
284
- nErr++;
285
- }
286
- }
287
- }
288
- }
289
- }
290
- if( nErr ){
291
- for(i=0; i<nArg; i++){
292
- printf(" arg[%d]: %s\n", i, azArg[i]);
293
- }
294
- }else if( eVerbose>1 ){
295
- printf("%s:%d: %.*s() ok for e, zFCall, nArg);
296
- }
297
- free((char*)azArg);
298
- free(zCopy);
299
- return nErr;
300
-}
301
-
302
-
303
-/*
304
-** Do a design-ruings for the file named zName
305
-** with content zContent. Write errors on standard output. Return
306
-** the number of errors.
307
-*/
308
-static int scan_file(const char *zName, const char *zContent){
309
- const char *z;
310
- int ln = 0;
311
- int szToken;
312
- int eToken;
313
- const char *zPrev = 0;
314
- int ePrev = 0;
315
- int szPrev = 0;
316
- int lnPrev = 0;
317
- int nCurly = 0;
318
- int x;
319
- unsigned fmtFlags = 0;
320
- int nErr = 0;
321
-
322
- if( zContent==0 ){
323
- printf("cannot read file: %s\n", zName);
324
- return 1;
325
- }
326
- for(z=zContent; z[0]; z += szToken){
327
- szToken = token_length(z, &eToken, &ln);
328
- if( eToken==TK_SPACE ) continue;
329
- if( eToken==TK_OTHER ){
330
- if( z[0]=='{' ){
331
- nCurly++;
332
- }else if( z[0]=='}' ){
333
- nCurly--;
334
- }else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
335
- && (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
336
- nErr += checkFormatFunc(zName, zPrev, lnPrev, x, fmtFlags);
337
- }
338
- }
339
- zPrev = z;
340
- ePrev = eToken;
341
- szPrev = szToken;
342
- lnPrev = ln;
343
- }
344
- return nErr;
345
-}
346
-
347
-/*
348
-** Check for format-string design rule violations on all files listed
349
-** on the command-line.
350
-**
351
-** The eVerbose global variable is incremented with each "-v" argument.
352
-*/
353
-int main(int argc, char **argv){
354
- int i;
355
- int nErr = 0;
356
- qsort(aFmtFunc, sizeof(aFmtFunc)/sizeof(aFmtFunc[0]),
357
- sizeof(aFmtFunc[0]), fmtfunc_cmp);
358
- for(i=1; i<argc; i++){
359
- char *zFile;
360
- if( strcmp(argv[i],"-v")==0 ){
361
- eVerbose++;
362
- continue;
363
- }
364
- if( eVerbose>0 ) printf("Processing %s...\n", argv[i]);
365
- zFile = read_file(argv[i]);
366
- nErr += scan_file(argv[i], zFile);
367
- free(zFile);
368
- }
369
- return nErr;
370
-}
371
-_htmln_whitespace(z, &len, &e input is a string literal.
372
-*/
373
-static int is_string_lit(const char *z){
374
- int nu1, nu2;
375
-distance_to(z, '?');
376
- if( z[len]==0 && skip_space(z)[0]=='(' ){
377
- z = skip_space(z) + 1;
378
- len = distance_to(z, '?');
379
- }
380
- z += len;
381
- if( z[0]=='?' ){
382
- z++;
383
- z = next_non_whitespace(z, &len, &eType);
384
- if( eType==TK_STR ){
385
- z += len;
386
- int nErr = 0;
387
-
388
- if( zContent==0 ){
389
- printf("cannot read file: %s\n", zName);
390
- return 1;
391
- }
392
- for(z=zContent; z[0]; z += szToken){
393
- szToken = token_length(z, &eToken, &ln);
394
- if( eToken==TK_SPACE ) continue;
395
- if( eToken==TK_OTHER ){
396
- if( z[0]=='{' ){
397
- nCurly++;
398
- }else if( z[0]=='}' ){
399
- nCurly--;
400
- }else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
401
- && (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
402
- nErr += checkFormatFunc(zName, zPrev, lnPrev, x, fmtFlags);
403
- }
404
- }
405
- zPrev = z;
406
- ePrev = eToken;
407
- szPrev = szTokeheck for format-string design rule violations on all files listed
408
-** on the command-line.
409
-**
410
-** The eVerbose global variable is incremented with each "-v" argument.
411
-*/
412
-int main(int argc, char **argv){
413
- int i;
414
- int nErr = 0;
415
- qsort(aFmtFunc, sizeof(aFmtFunc)/sizeof(aFmtFunc[0]),
416
- sizeof(aFmtFunc[0]), fmtfunc_cmp);
417
- for(i /* Index of format argument. Leftmost is 1. */
418
- unsigned fmtFlags; /* Processing flags */
419
-} aFmtFunc[] = {
420
- { "admin_log", 1, FMT_SAFE },
421
- { "ajax_route_error", 2, FMT_SAFE },
422
- { "audit_append", 3, FMT_SAFE },
423
- { "backofficeTrace", 1, FMT_SAFE },
424
- { "backoffice_log", 1, FMT_SAFE },
425
- { "blob_append_sql", 2, FMT_SQL },
426
- { "blob_appendf", 2, FMT_SAFE },
427
- { "cgi_debug", 1, FMT_SAFE },
428
- { "cgi_panic", 1, FTP },
429
- { "cgi_printf_TP },
430
- { "cgi_redirectf", 1, FMT_URL },
431
- { "chref", 2, FMT_URL },
432
- { "CX", 1, FMT_HTTP },
433
- { "db_blob", 2, FMT_SQL },
434
- { "db_debug", 1, FMT_SQL },
435
- { "db_double", 2, FMT_SQL },
436
- { "db_err", 1, FMT_SAFE },
437
- { "db_exists", 1, FMT_SQL },
438
- { "db_get_mprintf", 2, FMT_SAFE },
439
- { "db_int", 2, FMT_SQL },
440
- { "db_int64", 2, FMT_SQL },
441
- { "db_lset", 1, FMT_LIT },
442
- { "db_lset_int", 1, FMT_LIT },
443
- { "db_multi_exec", 1, FMT_SQL },
444
- { "db_optional_sql", 2, FMT_SQL },
445
- { "db_prepare", 2, FMT_SQL },
446
- { "db_prepare_ignore_error", 2, FMT_SQL },
447
- { "db_set", 1, FMT_LIT },
448
- { "db_set_int", 1, FMT_LIT },
449
- { "db_set_mprintf", 3, FMT_PX },
450
- { "db_static_prepare", 2, FMT_SQL },
451
- { "db_text", 2, FMT_SQL },
452
- { "db_unset", 1, FMT_LIT },
453
- { "db_unset_mprintf", 2, FMT_PX },
454
- { "emailerError", 2, FMT_SAFE },
455
- { "entry_attribute", 4, FMT_LIT },
456
- { "fileedit_ajax_error", 2, FMT_SAFE },
457
- { "form_begin", 2, FMT_URL },
458
- { "fossil_error", 2, FMT_SAFE },
459
- { "fossil_errorlog", 1, FMT_SAFE },
460
- n nErr++;
461
- }
462
- HTML)!=0 && !is_htmags & FMT_SQL)!=0 && !is_sql_safe(zExpr) ){
463
- printf("%s:%d: ArgumentHTML\n",
464
- zFilename, lnFCall, i+fmtArg, szFName, zFCall);
465
- nErr++;
466
-, FMT_HTML}
467
-FMT_HTMLErr++;
468
- }
469
- }
470
- }
471
- }
472
- }
473
- if( nErr ){
474
- for(i=0; i<nArg; i++){
475
- printf(" arg[%d]: %s\n", i, azArg[i]);
476
- }
477
- }else if( eVerbose>1 ){
478
- printf("%s:%d: %.*s() ok for %d arguments\n",
479
- zFilename, lnFCall, szFName, zFCall, nArg);
480
- }
481
- free((char*)azArg);
482
- free(zCopy);
483
- return nErr;
484
-}
485
-
486
-
487
-/*
488
-** Do a design-rule check of format strings for the file named zName
489
-** with content zContent. Write errors on standard output. Return
490
-** the number of errors.
491
-*/
492
-static int scan_file(const char *zName, const char *zContent){
493
- const char *z;
494
- int ln = 0;
495
- int szToken;
496
- int eToken;
497
- const char *zPrev = 0;
498
- int ePrev = 0;
499
- int szPrev = 0;
500
- int lnPrev = 0;
501
- int nCurly = 0;
502
- int x;
503
- unsigned fmtFlags = 0;
504
- int nErr = 0;
505
-
506
- if( zContent==0 ){
507
- printf("cannot read file: %s\n", zName);
508
- return 1;
509
- }
510
- for(z=zContent; z[0]; z += szToken){
511
- szToken = token_length(z, &eToken, &ln);
512
- if( eToken==TK_SPACE ) continue;
513
- if( eToken==TK_OTHER ){
514
- if( z[0]=='{' ){
515
- nCurly++;
516
- }else if( z[0]=='}' ){
517
- nCurly--;
518
- }else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
519
- && (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
520
- nErr += checkFormatFunc(zName, zPrev, lnelse if( eVerbose>=3 ){
521
- printf("TOKEN: [%.*s]\n", szToken, z)e <stdlib.h>
522
-#includ = azArg[fmtArg+i];
523
- if( never_safe(zExpr) ){
524
- printf("%s:%d: Argument %d to %.*s() is not safe for"
525
- " a query parameter\n",
526
- zFilename, lnFCall, i+fmtArg, szFName, zFCal_space(z)[0]=='(' ){
527
- z \n", i, azArg[i]);
528
- }
529
- }else if( eVerbose>1 ){
530
- printf("%s:%d: %.*s() ok for %d arguments\n",
531
- zFilename, lnFCall, szFName, zFCall, nArg);
532
- }
533
- free((char*)azArg);
534
- free(zCopy);
535
- return nErr;
536
-}
537
-
538
-
539
-/*
540
-** Do a design-rule check of format strings for the file named zName
541
-** with content zContent. Write errors on standard output. Return
542
-** the number of errors.
543
-*/
544
-static int scan_file(const char *zName, const char *zContent){
545
- const char *z;
546
- int ln = 0;
547
- int szToken;
548
- int eToken;
549
- const char *zPrev = 0;
550
- int ePrev = 0;
551
- int szPrev = 0;
552
- int lnPrev = 0;
553
- int nCurly = 0;
554
- int x;
555
- unsigned fmtFlags = 0;
556
- int nErr = 0;
557
-
558
- if( zContent==0 ){
559
- printf("cannot read file: %s\n", zName);
560
- return 1;
561
- }
562
- for(z=zContent; z[0]; z += szToken){
563
- szToken = token_length(z, &eToken, &ln);
564
- if( eToken==TK_SPACE ) continue;
565
- if( eToken==TK_OTHER ){
566
- if( z[0]=='{' ){
567
- nCurly++;
568
- }else if( z[0]=='}' ){
569
- nCurly--;
570
- }else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
571
- && (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
572
- nErr += checkFormatFunc(zName, zPrev, lnelse if( eVerbose>=3 ){
573
- printf("TOKEN: [%.*s]\n", szToken, z)e <stdlib.h>
574
-#includ = azArg[ printf("%s:%d: Argument %d to %.*s() is not safe for"
575
- " a query parameter\n",
576
- zFilename, lnFCall, i+fmtArg, szFName, zFCall);
577
- nErr++;
578
-
579
- }else if( (fmtFlags & FMT_SQL)!=0 && !is_sql_safe(zExpr) ){
580
- printf("%s:%d:
581
- nErr += checkForK_OTHER ){
582
- d to %.*s() not safe for SQL\n",
583
- zFilename, lnFCall, i+fmtArg, szFName, zFCall);
584
- nErr++;
585
- }
586
- }
587
- }
588
- }
589
- }
590
- if( nErr ){
591
- for(i=0; i<nArg; i++){
592
- printf(" arg[%d]: %s\n", i, azArg[i]);
593
- }
594
- }else if( eVerbose>1 ){
595
- printf("%s:%d: %.*s() ok for %d arguments\n",
596
- zFilename, lnFCall, s
--- a/src/codecheck1.c
+++ b/src/codecheck1.c
@@ -1,596 +0,0 @@
1 /*
2 ** Copyright (c) 2014 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
6 ** known as the "2-Clause License" or "FreeBSD License".)
7 **
8 ** This program is distributed in the hope that it will be useful,
9 ** but without any warranty; without even the implied warranty of
10 ** merchantability or fitness for a particular purpose.
11 **
12 ** Author contact information:
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** This program reads Fossil source code files and tries to verify that
19 ** printf-style format strings are correct.
20 **
21 ** This program implements a compile-time validation step on the Fossil
22 ** source code. Running this program is entirely optional. Its role is
23 ** similar to the -Wall compiler switch on gcc, or the scan-build utility
24 ** of clang, or other static analyzers. The purpose is to try to identify
25 ** problems in the source code at compile-time. The difference is that this
26 ** static checker is specifically designed for the particular printf formatter
27 ** implementation used by Fossil.
28 **
29 ** Checks include:
30 **
31 ** * Verify that vararg formatting routines like blob_printf() or
32 ** db_multi_exec() have the correct number of arguments for their
33 ** format string.
34 **
35 ** * For routines designed to generate SQL, warn about the use of %s
36 ** which might allow SQL injection possible injection attacks.
37 */
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <ctype.h>
41 #include <string.h>
42 #include <assert.h>
43
44 /*
45 ** Debugging switch
46 */
47 static int eVerbose = 0;
48
49 /*
50 ** Malloc, aborting if it fails.
51 */
52 void *safe_malloc(int nByte){
53 void *x = malloc(nByte);
54 if( x==0 ){
55 fprintf(stderr, "failed to allocate %d bytes\n", nByte);
56 exit(1);
57 }
58 return x;
59 }
60 void *safe_realloc(void *pOld, int nByte){
61 void *x = realloc(pOld, nByte);
62 if( x==0 ){
63 fprintf(stderr, "failed to allocate %d bytes\n", nByte);
64 exit(1);
65 }
66 return x;
67 }
68
69 /*
70 ** Read the entire content of the file named zFilename into memory obtained
71 ** from malloc(). Add a zero-terminator to the end.
72 ** Return a pointer to that memory.
73 */
74 static char *read_file(const char *zFilename){
75 FILE *in;
76 char *z;
77 int nByte;
78 int got;
79 in = fopen(zFilename, "rb");
80 if( in==0 ){
81 return 0;
82 }
83 fseek(in, 0, SEEK_END);
84 nByte = ftell(in);
85 fseek(in, 0, SEEK_SET);
86 z = safe_malloc( nByte+1 );
87 got = fread(z, 1, nByte, in);
88 z[got] = 0;
89 fclose(in);
90 return z;
91 }
92
93 /*
94 ** When parsing the input file, the following token types are recognized.
95 */
96 #define TK_SPACE 1 /* Whitespace or comments */
97 #define TK_ID 2 /* An identifier */
98 #define TK_STR 3 /* A string literal in double-quotes */
99 #define TK_OTHER 4 /* Any other token */
100 #define TK_EOF 99 /* End of file */
101
102 /*
103 ** Determine the length and type of the token beginning at z[0]
104 */
105 static int token_length(const char *z, int *pType, int *pLN){
106 int i;
107 if( z[0]==0 ){
108 *pType = TK_EOF;
109 return 0;
110 }
111 if( z[0]=='"' || z[0]=='\'' ){
112 for(i=1; z[i] && z[i]!=z[0]; i++){
113 if( z[i]=='\\' && z[i+1]!=0 ){
114 if( z[i+1]=='\n' ) (*pLN)++;
115 i++;
116 }
117 }
118 if( z[i]!=0 ) i++;
119 *pType = z[0]=='"' ? TK_STR : TK_OTHER;
120 return i;
121 }
122 if( isalnum(z[0]) || z[0]=='_' ){
123 for(i=1; isalnum(z[i]) || z[i]=='_'; i++){}
124 *pType = isalpha(z[0]) || z[0]=='_' ? TK_ID : TK_OTHER;
125 return i;
126 }
127 if( isspace(z[0]) ){
128 if( z[0]=='\n' ) (*pLN)++;
129 for(i=1; isspace(z[i]); i++){
130 if( z[i]=='\n' ) (*pLN)++;
131 }
132 *pType = TK_SPACE;
133 return i;
134 }
135 if( z[0]=='/' && z[1]=='*' ){
136 for(i=2; z[i] && (z[i]!='*' || z[i+1]!='/'); i++){
137 if( z[i]=='\n' ) (*pLN)++;
138 }
139 if( z[i] ) i += 2;
140 *pType = TK_SPACE;
141 return i;
142 }
143 if( z[0]=='/' && z[1]=='/' ){
144 for(i=2; z[i] && z[i]!='\n'; i++){}
145 if( z[i] ){
146 (*pLN)++;
147 i++;
148 }
149 *pType = TK_SPACE;
150 return i;
151 }
152 if( z[0]=='\\' && (z[1]=='\n' || (z[1]=='\r' && z[2]=='\n')) ){
153 *pType = TK_SPACE;
154 return 1;
155 }
156 *pType = TK_OTHER;
157 return 1;
158 }
159
160 /*
161 ** Return the next non-whitespace token
162 */
163 const char *next_non_whitespace(const char *z, int *pLen, int *pType){
164 int len;
165 int eType;
166 int ln = 0;
167 while( (len = token_length(z, &eType, &ln))>0 && eType==TK_SPACE ){
168 z += len;
169 }
170 *pLen = len;
171 *pType = eType;
172 return z;
173 }
174
175 /*
176 ** Return index into z[] for the first balanced TK_OTHER token with
177 ** value cValue.
178 */
179 static int distance_to(const char *z, char cVal){
180 int len;
181 int dist = 0;
182 int eType;
183 int nNest = 0;
184 int ln = 0;
185 while( z[0] && (len = token_length(z, &eType, &ln))>0 ){
186 if( eType==TK_OTHER ){
187 if( z[0]==cVal && nNest==0 ){
188 break;
189 }else if( z[0]=='(' ){
190 nNest++;
191 }else if( z[0]==')' ){
192 nNest--;
193 }
194 }
195 dist += len;
196 z += len;
197 }
198 return dist;
199 }
200
201 /*
202 ** Return the first non-whitespace characters in z[]
203 */
204 static const char *skip_space(const char *z){
205 while( isspace(z[0]) ){ z++; }
206 return z;
207 }
208
209 /*
210 ** Remove excess whitespace and nested "()" from string z.
211 */
212 static char *simplify_expr(char *z){
213 int n = (int)strlen(z);
214 while( n>0 ){
215 if( isspace(z[0]) ){
216 z++;
217 n--;
218 continue;
219 }
220 if( z[0]=='(' && z[n-1]==')' ){
221 z++;
222 n -= 2;
223 continue;
224 }
225 break;
226 }
227 z[n] = 0;
228 return z;
229 }
230
231 /*
232 ** Return true if the input is a string literal.
233 */
234 static int is_string_lit(const char *z){
235 int nu1, nu2;
236 z = next_non_whitespace(z, &nu1, &nu2);
237 if( strcmp(z, "NULL")==0 ) return 1;
238 return z[0]=='"';
239 }
240
241 /*
242 ** Return true if the input is an expression of string literals:
243 **
244 ** EXPR ? "..." : "..."
245 */
246 static int is_string_expr(const char *z){
247 int len = 0, eType;
248 const char *zOrig = z;
249 len = distance_to(z, '?');
250 if( z[len]==0 && skip_space(z)[0]=='(' ){
251 z = skip_space(z) + 1;
252 len = distance_to(z, '?');
253 }
254 z += len;
255 if( z[0]=='?' ){
256 z++;
257 z = next_non_whitespace(z, &len, &eType);
258 if( eType==TK_STR ){
259 z += len;
260 z = next_non_whitespace(z, &len, &eType);
261 /*
262 ** Retuan redistribute i/*
263 ** Copyright (c) 2014 D. Richard Hipp
264 **
265 ** This program is free software; you can redistribute it and/or
266 ** modify it under the terms of the Simplified BSD License (also
267 ** known as the "2-Clause License" or "FreeBSD License".)
268 **
269 ** This program is distributed in the hope that it will be useful,
270 ** but without any warranty; without even the implied warranty of
271 ** merchantability or fitness for a particular purpose.
272 **
273 ** Author contact information:
274 ** [email protected]
275 ** http://www.hwaci.com/drh/
276 **
277 ******SAFE printf("%s:%d: Argu a query parameter\1, lnFCall, i+fmtArg, szFName, zFCall);
278 nErr++;
279
280 20},
281 { "( (fmtFlags & FMT_SQL)!=0 && !is_sql_safe(zExpr) ){
282 printf("%s:%d: Argument %d to %.*s() not safe for SQL\n",
283 zFilename, lnFCall, i+fmtArg, szFName, zFCall);
284 nErr++;
285 }
286 }
287 }
288 }
289 }
290 if( nErr ){
291 for(i=0; i<nArg; i++){
292 printf(" arg[%d]: %s\n", i, azArg[i]);
293 }
294 }else if( eVerbose>1 ){
295 printf("%s:%d: %.*s() ok for e, zFCall, nArg);
296 }
297 free((char*)azArg);
298 free(zCopy);
299 return nErr;
300 }
301
302
303 /*
304 ** Do a design-ruings for the file named zName
305 ** with content zContent. Write errors on standard output. Return
306 ** the number of errors.
307 */
308 static int scan_file(const char *zName, const char *zContent){
309 const char *z;
310 int ln = 0;
311 int szToken;
312 int eToken;
313 const char *zPrev = 0;
314 int ePrev = 0;
315 int szPrev = 0;
316 int lnPrev = 0;
317 int nCurly = 0;
318 int x;
319 unsigned fmtFlags = 0;
320 int nErr = 0;
321
322 if( zContent==0 ){
323 printf("cannot read file: %s\n", zName);
324 return 1;
325 }
326 for(z=zContent; z[0]; z += szToken){
327 szToken = token_length(z, &eToken, &ln);
328 if( eToken==TK_SPACE ) continue;
329 if( eToken==TK_OTHER ){
330 if( z[0]=='{' ){
331 nCurly++;
332 }else if( z[0]=='}' ){
333 nCurly--;
334 }else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
335 && (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
336 nErr += checkFormatFunc(zName, zPrev, lnPrev, x, fmtFlags);
337 }
338 }
339 zPrev = z;
340 ePrev = eToken;
341 szPrev = szToken;
342 lnPrev = ln;
343 }
344 return nErr;
345 }
346
347 /*
348 ** Check for format-string design rule violations on all files listed
349 ** on the command-line.
350 **
351 ** The eVerbose global variable is incremented with each "-v" argument.
352 */
353 int main(int argc, char **argv){
354 int i;
355 int nErr = 0;
356 qsort(aFmtFunc, sizeof(aFmtFunc)/sizeof(aFmtFunc[0]),
357 sizeof(aFmtFunc[0]), fmtfunc_cmp);
358 for(i=1; i<argc; i++){
359 char *zFile;
360 if( strcmp(argv[i],"-v")==0 ){
361 eVerbose++;
362 continue;
363 }
364 if( eVerbose>0 ) printf("Processing %s...\n", argv[i]);
365 zFile = read_file(argv[i]);
366 nErr += scan_file(argv[i], zFile);
367 free(zFile);
368 }
369 return nErr;
370 }
371 _htmln_whitespace(z, &len, &e input is a string literal.
372 */
373 static int is_string_lit(const char *z){
374 int nu1, nu2;
375 distance_to(z, '?');
376 if( z[len]==0 && skip_space(z)[0]=='(' ){
377 z = skip_space(z) + 1;
378 len = distance_to(z, '?');
379 }
380 z += len;
381 if( z[0]=='?' ){
382 z++;
383 z = next_non_whitespace(z, &len, &eType);
384 if( eType==TK_STR ){
385 z += len;
386 int nErr = 0;
387
388 if( zContent==0 ){
389 printf("cannot read file: %s\n", zName);
390 return 1;
391 }
392 for(z=zContent; z[0]; z += szToken){
393 szToken = token_length(z, &eToken, &ln);
394 if( eToken==TK_SPACE ) continue;
395 if( eToken==TK_OTHER ){
396 if( z[0]=='{' ){
397 nCurly++;
398 }else if( z[0]=='}' ){
399 nCurly--;
400 }else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
401 && (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
402 nErr += checkFormatFunc(zName, zPrev, lnPrev, x, fmtFlags);
403 }
404 }
405 zPrev = z;
406 ePrev = eToken;
407 szPrev = szTokeheck for format-string design rule violations on all files listed
408 ** on the command-line.
409 **
410 ** The eVerbose global variable is incremented with each "-v" argument.
411 */
412 int main(int argc, char **argv){
413 int i;
414 int nErr = 0;
415 qsort(aFmtFunc, sizeof(aFmtFunc)/sizeof(aFmtFunc[0]),
416 sizeof(aFmtFunc[0]), fmtfunc_cmp);
417 for(i /* Index of format argument. Leftmost is 1. */
418 unsigned fmtFlags; /* Processing flags */
419 } aFmtFunc[] = {
420 { "admin_log", 1, FMT_SAFE },
421 { "ajax_route_error", 2, FMT_SAFE },
422 { "audit_append", 3, FMT_SAFE },
423 { "backofficeTrace", 1, FMT_SAFE },
424 { "backoffice_log", 1, FMT_SAFE },
425 { "blob_append_sql", 2, FMT_SQL },
426 { "blob_appendf", 2, FMT_SAFE },
427 { "cgi_debug", 1, FMT_SAFE },
428 { "cgi_panic", 1, FTP },
429 { "cgi_printf_TP },
430 { "cgi_redirectf", 1, FMT_URL },
431 { "chref", 2, FMT_URL },
432 { "CX", 1, FMT_HTTP },
433 { "db_blob", 2, FMT_SQL },
434 { "db_debug", 1, FMT_SQL },
435 { "db_double", 2, FMT_SQL },
436 { "db_err", 1, FMT_SAFE },
437 { "db_exists", 1, FMT_SQL },
438 { "db_get_mprintf", 2, FMT_SAFE },
439 { "db_int", 2, FMT_SQL },
440 { "db_int64", 2, FMT_SQL },
441 { "db_lset", 1, FMT_LIT },
442 { "db_lset_int", 1, FMT_LIT },
443 { "db_multi_exec", 1, FMT_SQL },
444 { "db_optional_sql", 2, FMT_SQL },
445 { "db_prepare", 2, FMT_SQL },
446 { "db_prepare_ignore_error", 2, FMT_SQL },
447 { "db_set", 1, FMT_LIT },
448 { "db_set_int", 1, FMT_LIT },
449 { "db_set_mprintf", 3, FMT_PX },
450 { "db_static_prepare", 2, FMT_SQL },
451 { "db_text", 2, FMT_SQL },
452 { "db_unset", 1, FMT_LIT },
453 { "db_unset_mprintf", 2, FMT_PX },
454 { "emailerError", 2, FMT_SAFE },
455 { "entry_attribute", 4, FMT_LIT },
456 { "fileedit_ajax_error", 2, FMT_SAFE },
457 { "form_begin", 2, FMT_URL },
458 { "fossil_error", 2, FMT_SAFE },
459 { "fossil_errorlog", 1, FMT_SAFE },
460 n nErr++;
461 }
462 HTML)!=0 && !is_htmags & FMT_SQL)!=0 && !is_sql_safe(zExpr) ){
463 printf("%s:%d: ArgumentHTML\n",
464 zFilename, lnFCall, i+fmtArg, szFName, zFCall);
465 nErr++;
466 , FMT_HTML}
467 FMT_HTMLErr++;
468 }
469 }
470 }
471 }
472 }
473 if( nErr ){
474 for(i=0; i<nArg; i++){
475 printf(" arg[%d]: %s\n", i, azArg[i]);
476 }
477 }else if( eVerbose>1 ){
478 printf("%s:%d: %.*s() ok for %d arguments\n",
479 zFilename, lnFCall, szFName, zFCall, nArg);
480 }
481 free((char*)azArg);
482 free(zCopy);
483 return nErr;
484 }
485
486
487 /*
488 ** Do a design-rule check of format strings for the file named zName
489 ** with content zContent. Write errors on standard output. Return
490 ** the number of errors.
491 */
492 static int scan_file(const char *zName, const char *zContent){
493 const char *z;
494 int ln = 0;
495 int szToken;
496 int eToken;
497 const char *zPrev = 0;
498 int ePrev = 0;
499 int szPrev = 0;
500 int lnPrev = 0;
501 int nCurly = 0;
502 int x;
503 unsigned fmtFlags = 0;
504 int nErr = 0;
505
506 if( zContent==0 ){
507 printf("cannot read file: %s\n", zName);
508 return 1;
509 }
510 for(z=zContent; z[0]; z += szToken){
511 szToken = token_length(z, &eToken, &ln);
512 if( eToken==TK_SPACE ) continue;
513 if( eToken==TK_OTHER ){
514 if( z[0]=='{' ){
515 nCurly++;
516 }else if( z[0]=='}' ){
517 nCurly--;
518 }else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
519 && (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
520 nErr += checkFormatFunc(zName, zPrev, lnelse if( eVerbose>=3 ){
521 printf("TOKEN: [%.*s]\n", szToken, z)e <stdlib.h>
522 #includ = azArg[fmtArg+i];
523 if( never_safe(zExpr) ){
524 printf("%s:%d: Argument %d to %.*s() is not safe for"
525 " a query parameter\n",
526 zFilename, lnFCall, i+fmtArg, szFName, zFCal_space(z)[0]=='(' ){
527 z \n", i, azArg[i]);
528 }
529 }else if( eVerbose>1 ){
530 printf("%s:%d: %.*s() ok for %d arguments\n",
531 zFilename, lnFCall, szFName, zFCall, nArg);
532 }
533 free((char*)azArg);
534 free(zCopy);
535 return nErr;
536 }
537
538
539 /*
540 ** Do a design-rule check of format strings for the file named zName
541 ** with content zContent. Write errors on standard output. Return
542 ** the number of errors.
543 */
544 static int scan_file(const char *zName, const char *zContent){
545 const char *z;
546 int ln = 0;
547 int szToken;
548 int eToken;
549 const char *zPrev = 0;
550 int ePrev = 0;
551 int szPrev = 0;
552 int lnPrev = 0;
553 int nCurly = 0;
554 int x;
555 unsigned fmtFlags = 0;
556 int nErr = 0;
557
558 if( zContent==0 ){
559 printf("cannot read file: %s\n", zName);
560 return 1;
561 }
562 for(z=zContent; z[0]; z += szToken){
563 szToken = token_length(z, &eToken, &ln);
564 if( eToken==TK_SPACE ) continue;
565 if( eToken==TK_OTHER ){
566 if( z[0]=='{' ){
567 nCurly++;
568 }else if( z[0]=='}' ){
569 nCurly--;
570 }else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
571 && (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
572 nErr += checkFormatFunc(zName, zPrev, lnelse if( eVerbose>=3 ){
573 printf("TOKEN: [%.*s]\n", szToken, z)e <stdlib.h>
574 #includ = azArg[ printf("%s:%d: Argument %d to %.*s() is not safe for"
575 " a query parameter\n",
576 zFilename, lnFCall, i+fmtArg, szFName, zFCall);
577 nErr++;
578
579 }else if( (fmtFlags & FMT_SQL)!=0 && !is_sql_safe(zExpr) ){
580 printf("%s:%d:
581 nErr += checkForK_OTHER ){
582 d to %.*s() not safe for SQL\n",
583 zFilename, lnFCall, i+fmtArg, szFName, zFCall);
584 nErr++;
585 }
586 }
587 }
588 }
589 }
590 if( nErr ){
591 for(i=0; i<nArg; i++){
592 printf(" arg[%d]: %s\n", i, azArg[i]);
593 }
594 }else if( eVerbose>1 ){
595 printf("%s:%d: %.*s() ok for %d arguments\n",
596 zFilename, lnFCall, s
--- a/src/codecheck1.c
+++ b/src/codecheck1.c
@@ -1,596 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
+22 -82
--- src/main.mk
+++ src/main.mk
@@ -1,8 +1,8 @@
11
#
22
##############################################################################
3
-# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
3
+# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
44
##############################################################################
55
#
66
# This file is automatically generated. Instead of editing this
77
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
88
# to regenerate this file.
@@ -208,73 +208,11 @@
208208
$(SRCDIR)/../skins/plain_gray/footer.txt \
209209
$(SRCDIR)/../skins/plain_gray/header.txt \
210210
$(SRCDIR)/../skins/xekri/css.txt \
211211
$(SRCDIR)/../skins/xekri/details.txt \
212212
$(SRCDIR)/../skins/xekri/footer.txt \
213
- $(SRCDIR)/../skins/xekri/header.txt \
214
- $(SRCDIR)/accordion.js \
215
- $(SRCDIR)/alerts/bflat2.wav \
216
- $(SRCDIR)/alerts/bflat3.wav \
217
- $(SRCDIR)/alerts/bloop.wav \
218
- $(SRCDIR)/alerts/plunk.wav \
219
- $(SRCDIR)/ci_edit.js \
220
- $(SRCDIR)/copybtn.js \
221
- $(SRCDIR)/default.css \
222
- $(SRCDIR)/diff.js \
223
- $(SRCDIR)/diff.tcl \
224
- $(SRCDIR)/forum.js \
225
- $(SRCDIR)/fossil.bootstrap.js \
226
- $(SRCDIR)/fossil.confirmer.js \
227
- $(SRCDIR)/fossil.copybutton.js \
228
- $(SRCDIR)/fossil.diff.js \
229
- $(SRCDIR)/fossil.dom.js \
230
- $(SRCDIR)/fossil.fetch.js \
231
- $(SRCDIR)/fossil.numbered-lines.js \
232
- $(SRCDIR)/fossil.page.brlist.js \
233
- $(SRCDIR)/fossil.page.chat.js \
234
- $(SRCDIR)/fossil.page.fileedit.js \
235
- $(SRCDIR)/fossil.page.forumpost.js \
236
- $(SRCDIR)/fossil.page.pikchrshow.js \
237
- $(SRCDIR)/fossil.page.whistory.js \
238
- $(SRCDIR)/fossil.page.wikiedit.js \
239
- $(SRCDIR)/fossil.pikchr.js \
240
- $(SRCDIR)/fossil.popupwidget.js \
241
- $(SRCDIR)/fossil.storage.js \
242
- $(SRCDIR)/fossil.tabs.js \
243
- $(SRCDIR)/fossil.wikiedit-wysiwyg.js \
244
- $(SRCDIR)/graph.js \
245
- $(SRCDIR)/hbmenu.js \
246
- $(SRCDIR)/href.js \
247
- $(SRCDIR)/login.js \
248
- $(SRCDIR)/markdown.md \
249
- $(SRCDIR)/menu.js \
250
- $(SRCDIR)/scroll.js \
251
- $(SRCDIR)/skin.js \
252
- $(SRCDIR)/sorttable.js \
253
- $(SRCDIR)/sounds/0.wav \
254
- $(SRCDIR)/sounds/1.wav \
255
- $(SRCDIR)/sounds/2.wav \
256
- $(SRCDIR)/sounds/3.wav \
257
- $(SRCDIR)/sounds/4.wav \
258
- $(SRCDIR)/sounds/5.wav \
259
- $(SRCDIR)/sounds/6.wav \
260
- $(SRCDIR)/sounds/7.wav \
261
- $(SRCDIR)/sounds/8.wav \
262
- $(SRCDIR)/sounds/9.wav \
263
- $(SRCDIR)/sounds/a.wav \
264
- $(SRCDIR)/sounds/b.wav \
265
- $(SRCDIR)/sounds/c.wav \
266
- $(SRCDIR)/sounds/d.wav \
267
- $(SRCDIR)/sounds/e.wav \
268
- $(SRCDIR)/sounds/f.wav \
269
- $(SRCDIR)/style.admin_log.css \
270
- $(SRCDIR)/style.chat.css \
271
- $(SRCDIR)/style.fileedit.css \
272
- $(SRCDIR)/style.wikiedit.css \
273
- $(SRCDIR)/tree.js \
274
- $(SRCDIR)/useredit.js \
275
- $(SRCDIR)/wiki.wiki
213
+ $(SRCDIR)/../skins/xekri/header.txt
276214
277215
TRANS_SRC = \
278216
$(OBJDIR)/add_.c \
279217
$(OBJDIR)/ajax_.c \
280218
$(OBJDIR)/alerts_.c \
@@ -583,27 +521,27 @@
583521
$(OBJDIR)/codecheck1 $(TRANS_SRC)
584522
585523
$(OBJDIR):
586524
-mkdir $(OBJDIR)
587525
588
-$(OBJDIR)/translate: $(SRCDIR)/translate.c
589
- $(XBCC) -o $(OBJDIR)/translate $(SRCDIR)/translate.c
590
-
591
-$(OBJDIR)/makeheaders: $(SRCDIR)/makeheaders.c
592
- $(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR)/makeheaders.c
593
-
594
-$(OBJDIR)/mkindex: $(SRCDIR)/mkindex.c
595
- $(XBCC) -o $(OBJDIR)/mkindex $(SRCDIR)/mkindex.c
596
-
597
-$(OBJDIR)/mkbuiltin: $(SRCDIR)/mkbuiltin.c
598
- $(XBCC) -o $(OBJDIR)/mkbuiltin $(SRCDIR)/mkbuiltin.c
599
-
600
-$(OBJDIR)/mkversion: $(SRCDIR)/mkversion.c
601
- $(XBCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
602
-
603
-$(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
604
- $(XBCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
526
+$(OBJDIR)/translate: $(SRCDIR.tools)/translate.c
527
+ $(XBCC) -o $(OBJDIR)/translate $(SRCDIR.tools)/translate.c
528
+
529
+$(OBJDIR)/makeheaders: $(SRCDIR.tools)/makeheaders.c
530
+ $(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR.tools)/makeheaders.c
531
+
532
+$(OBJDIR)/mkindex: $(SRCDIR.tools)/mkindex.c
533
+ $(XBCC) -o $(OBJDIR)/mkindex $(SRCDIR.tools)/mkindex.c
534
+
535
+$(OBJDIR)/mkbuiltin: $(SRCDIR.tools)/mkbuiltin.c
536
+ $(XBCC) -o $(OBJDIR)/mkbuiltin $(SRCDIR.tools)/mkbuiltin.c
537
+
538
+$(OBJDIR)/mkversion: $(SRCDIR.tools)/mkversion.c
539
+ $(XBCC) -o $(OBJDIR)/mkversion $(SRCDIR.tools)/mkversion.c
540
+
541
+$(OBJDIR)/codecheck1: $(SRCDIR.tools)/codecheck1.c
542
+ $(XBCC) -o $(OBJDIR)/codecheck1 $(SRCDIR.tools)/codecheck1.c
605543
606544
# Run the test suite.
607545
# Other flags that can be included in TESTFLAGS are:
608546
#
609547
# -halt Stop testing after the first failed test
@@ -618,11 +556,13 @@
618556
#
619557
test: $(OBJDIR) $(APPNAME)
620558
$(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) $(TESTFLAGS)
621559
622560
$(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion $(OBJDIR)/phony.h
623
- $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
561
+ $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid \
562
+ $(SRCDIR)/../manifest \
563
+ $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
624564
625565
$(OBJDIR)/phony.h:
626566
# Force rebuild of VERSION.h every time we run "make"
627567
628568
# Setup the options used to compile the included SQLite library.
629569
630570
DELETED src/makeheaders.c
631571
DELETED src/makeheaders.html
632572
DELETED src/makemake.tcl
633573
DELETED src/mkbuiltin.c
634574
DELETED src/mkindex.c
635575
DELETED src/mkversion.c
636576
DELETED src/translate.c
637577
ADDED tools/codecheck1.c
638578
ADDED tools/makeheaders.c
639579
ADDED tools/makeheaders.html
640580
ADDED tools/makemake.tcl
641581
ADDED tools/mkbuiltin.c
642582
ADDED tools/mkindex.c
643583
ADDED tools/mkversion.c
644584
ADDED tools/translate.c
--- src/main.mk
+++ src/main.mk
@@ -1,8 +1,8 @@
1 #
2 ##############################################################################
3 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
4 ##############################################################################
5 #
6 # This file is automatically generated. Instead of editing this
7 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
8 # to regenerate this file.
@@ -208,73 +208,11 @@
208 $(SRCDIR)/../skins/plain_gray/footer.txt \
209 $(SRCDIR)/../skins/plain_gray/header.txt \
210 $(SRCDIR)/../skins/xekri/css.txt \
211 $(SRCDIR)/../skins/xekri/details.txt \
212 $(SRCDIR)/../skins/xekri/footer.txt \
213 $(SRCDIR)/../skins/xekri/header.txt \
214 $(SRCDIR)/accordion.js \
215 $(SRCDIR)/alerts/bflat2.wav \
216 $(SRCDIR)/alerts/bflat3.wav \
217 $(SRCDIR)/alerts/bloop.wav \
218 $(SRCDIR)/alerts/plunk.wav \
219 $(SRCDIR)/ci_edit.js \
220 $(SRCDIR)/copybtn.js \
221 $(SRCDIR)/default.css \
222 $(SRCDIR)/diff.js \
223 $(SRCDIR)/diff.tcl \
224 $(SRCDIR)/forum.js \
225 $(SRCDIR)/fossil.bootstrap.js \
226 $(SRCDIR)/fossil.confirmer.js \
227 $(SRCDIR)/fossil.copybutton.js \
228 $(SRCDIR)/fossil.diff.js \
229 $(SRCDIR)/fossil.dom.js \
230 $(SRCDIR)/fossil.fetch.js \
231 $(SRCDIR)/fossil.numbered-lines.js \
232 $(SRCDIR)/fossil.page.brlist.js \
233 $(SRCDIR)/fossil.page.chat.js \
234 $(SRCDIR)/fossil.page.fileedit.js \
235 $(SRCDIR)/fossil.page.forumpost.js \
236 $(SRCDIR)/fossil.page.pikchrshow.js \
237 $(SRCDIR)/fossil.page.whistory.js \
238 $(SRCDIR)/fossil.page.wikiedit.js \
239 $(SRCDIR)/fossil.pikchr.js \
240 $(SRCDIR)/fossil.popupwidget.js \
241 $(SRCDIR)/fossil.storage.js \
242 $(SRCDIR)/fossil.tabs.js \
243 $(SRCDIR)/fossil.wikiedit-wysiwyg.js \
244 $(SRCDIR)/graph.js \
245 $(SRCDIR)/hbmenu.js \
246 $(SRCDIR)/href.js \
247 $(SRCDIR)/login.js \
248 $(SRCDIR)/markdown.md \
249 $(SRCDIR)/menu.js \
250 $(SRCDIR)/scroll.js \
251 $(SRCDIR)/skin.js \
252 $(SRCDIR)/sorttable.js \
253 $(SRCDIR)/sounds/0.wav \
254 $(SRCDIR)/sounds/1.wav \
255 $(SRCDIR)/sounds/2.wav \
256 $(SRCDIR)/sounds/3.wav \
257 $(SRCDIR)/sounds/4.wav \
258 $(SRCDIR)/sounds/5.wav \
259 $(SRCDIR)/sounds/6.wav \
260 $(SRCDIR)/sounds/7.wav \
261 $(SRCDIR)/sounds/8.wav \
262 $(SRCDIR)/sounds/9.wav \
263 $(SRCDIR)/sounds/a.wav \
264 $(SRCDIR)/sounds/b.wav \
265 $(SRCDIR)/sounds/c.wav \
266 $(SRCDIR)/sounds/d.wav \
267 $(SRCDIR)/sounds/e.wav \
268 $(SRCDIR)/sounds/f.wav \
269 $(SRCDIR)/style.admin_log.css \
270 $(SRCDIR)/style.chat.css \
271 $(SRCDIR)/style.fileedit.css \
272 $(SRCDIR)/style.wikiedit.css \
273 $(SRCDIR)/tree.js \
274 $(SRCDIR)/useredit.js \
275 $(SRCDIR)/wiki.wiki
276
277 TRANS_SRC = \
278 $(OBJDIR)/add_.c \
279 $(OBJDIR)/ajax_.c \
280 $(OBJDIR)/alerts_.c \
@@ -583,27 +521,27 @@
583 $(OBJDIR)/codecheck1 $(TRANS_SRC)
584
585 $(OBJDIR):
586 -mkdir $(OBJDIR)
587
588 $(OBJDIR)/translate: $(SRCDIR)/translate.c
589 $(XBCC) -o $(OBJDIR)/translate $(SRCDIR)/translate.c
590
591 $(OBJDIR)/makeheaders: $(SRCDIR)/makeheaders.c
592 $(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR)/makeheaders.c
593
594 $(OBJDIR)/mkindex: $(SRCDIR)/mkindex.c
595 $(XBCC) -o $(OBJDIR)/mkindex $(SRCDIR)/mkindex.c
596
597 $(OBJDIR)/mkbuiltin: $(SRCDIR)/mkbuiltin.c
598 $(XBCC) -o $(OBJDIR)/mkbuiltin $(SRCDIR)/mkbuiltin.c
599
600 $(OBJDIR)/mkversion: $(SRCDIR)/mkversion.c
601 $(XBCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
602
603 $(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
604 $(XBCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
605
606 # Run the test suite.
607 # Other flags that can be included in TESTFLAGS are:
608 #
609 # -halt Stop testing after the first failed test
@@ -618,11 +556,13 @@
618 #
619 test: $(OBJDIR) $(APPNAME)
620 $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) $(TESTFLAGS)
621
622 $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion $(OBJDIR)/phony.h
623 $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
 
 
624
625 $(OBJDIR)/phony.h:
626 # Force rebuild of VERSION.h every time we run "make"
627
628 # Setup the options used to compile the included SQLite library.
629
630 ELETED src/makeheaders.c
631 ELETED src/makeheaders.html
632 ELETED src/makemake.tcl
633 ELETED src/mkbuiltin.c
634 ELETED src/mkindex.c
635 ELETED src/mkversion.c
636 ELETED src/translate.c
637 DDED tools/codecheck1.c
638 DDED tools/makeheaders.c
639 DDED tools/makeheaders.html
640 DDED tools/makemake.tcl
641 DDED tools/mkbuiltin.c
642 DDED tools/mkindex.c
643 DDED tools/mkversion.c
644 DDED tools/translate.c
--- src/main.mk
+++ src/main.mk
@@ -1,8 +1,8 @@
1 #
2 ##############################################################################
3 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
4 ##############################################################################
5 #
6 # This file is automatically generated. Instead of editing this
7 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
8 # to regenerate this file.
@@ -208,73 +208,11 @@
208 $(SRCDIR)/../skins/plain_gray/footer.txt \
209 $(SRCDIR)/../skins/plain_gray/header.txt \
210 $(SRCDIR)/../skins/xekri/css.txt \
211 $(SRCDIR)/../skins/xekri/details.txt \
212 $(SRCDIR)/../skins/xekri/footer.txt \
213 $(SRCDIR)/../skins/xekri/header.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
215 TRANS_SRC = \
216 $(OBJDIR)/add_.c \
217 $(OBJDIR)/ajax_.c \
218 $(OBJDIR)/alerts_.c \
@@ -583,27 +521,27 @@
521 $(OBJDIR)/codecheck1 $(TRANS_SRC)
522
523 $(OBJDIR):
524 -mkdir $(OBJDIR)
525
526 $(OBJDIR)/translate: $(SRCDIR.tools)/translate.c
527 $(XBCC) -o $(OBJDIR)/translate $(SRCDIR.tools)/translate.c
528
529 $(OBJDIR)/makeheaders: $(SRCDIR.tools)/makeheaders.c
530 $(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR.tools)/makeheaders.c
531
532 $(OBJDIR)/mkindex: $(SRCDIR.tools)/mkindex.c
533 $(XBCC) -o $(OBJDIR)/mkindex $(SRCDIR.tools)/mkindex.c
534
535 $(OBJDIR)/mkbuiltin: $(SRCDIR.tools)/mkbuiltin.c
536 $(XBCC) -o $(OBJDIR)/mkbuiltin $(SRCDIR.tools)/mkbuiltin.c
537
538 $(OBJDIR)/mkversion: $(SRCDIR.tools)/mkversion.c
539 $(XBCC) -o $(OBJDIR)/mkversion $(SRCDIR.tools)/mkversion.c
540
541 $(OBJDIR)/codecheck1: $(SRCDIR.tools)/codecheck1.c
542 $(XBCC) -o $(OBJDIR)/codecheck1 $(SRCDIR.tools)/codecheck1.c
543
544 # Run the test suite.
545 # Other flags that can be included in TESTFLAGS are:
546 #
547 # -halt Stop testing after the first failed test
@@ -618,11 +556,13 @@
556 #
557 test: $(OBJDIR) $(APPNAME)
558 $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) $(TESTFLAGS)
559
560 $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion $(OBJDIR)/phony.h
561 $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid \
562 $(SRCDIR)/../manifest \
563 $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
564
565 $(OBJDIR)/phony.h:
566 # Force rebuild of VERSION.h every time we run "make"
567
568 # Setup the options used to compile the included SQLite library.
569
570 ELETED src/makeheaders.c
571 ELETED src/makeheaders.html
572 ELETED src/makemake.tcl
573 ELETED src/mkbuiltin.c
574 ELETED src/mkindex.c
575 ELETED src/mkversion.c
576 ELETED src/translate.c
577 DDED tools/codecheck1.c
578 DDED tools/makeheaders.c
579 DDED tools/makeheaders.html
580 DDED tools/makemake.tcl
581 DDED tools/mkbuiltin.c
582 DDED tools/mkindex.c
583 DDED tools/mkversion.c
584 DDED tools/translate.c
D src/makeheaders.c
-2762
--- a/src/makeheaders.c
+++ b/src/makeheaders.c
@@ -1,2762 +0,0 @@
1
-/*
2
-** This program is free software; you can redistribute it and/or
3
-** modify it under the terms of the Simplified BSD License (also
4
-** known as the "2-Clause License" or "FreeBSD License".)
5
-**
6
-** Copyright 1993 D. Richard Hipp. All rights reserved.
7
-**
8
-** Redistribution and use in source and binary forms, with or
9
-** without modification, are permitted provided that the following
10
-** conditions are met:
11
-**
12
-** 1. Redistributions of source code must retain the above copyright
13
-** notice, this list of conditions and the following disclaimer.
14
-**
15
-** 2. Redistributions in binary form must reproduce the above copyright
16
-** notice, this list of conditions and the following disclaimer in
17
-** the documentation and/or other materials provided with the
18
-** distribution.
19
-**
20
-** This software is provided "as is" and any express or implied warranties,
21
-** including, but not limited to, the implied warranties of merchantability
22
-** and fitness for a particular purpose are disclaimed. In no event shall
23
-** the author or contributors be liable for any direct, indirect, incidental,
24
-** special, exemplary, or consequential damages (including, but not limited
25
-** to, procurement of substitute goods or services; loss of use, data or
26
-** profits; or business interruption) however caused and on any theory of
27
-** liability, whether in contract, strict liability, or tort (including
28
-** negligence or otherwise) arising in any way out of the use of this
29
-** software, even if advised of the possibility of such damage.
30
-**
31
-** This program is distributed in the hope that it will be useful,
32
-** but without any warranty; without even the implied warranty of
33
-** merchantability or fitness for a particular purpose.
34
-*/
35
-#include <stdio.h>
36
-#include <stdlib.h>
37
-#include <ctype.h>
38
-#include <memory.h>
39
-#include <sys/stat.h>
40
-#include <assert.h>
41
-#include <string.h>
42
-
43
-#if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
44
-# ifndef WIN32
45
-# define WIN32
46
-# endif
47
-#else
48
-# include <unistd.h>
49
-#endif
50
-
51
-/*
52
-** Macros for debugging.
53
-*/
54
-#ifdef DEBUG
55
-static int debugMask = 0;
56
-# define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
57
-# define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
58
-# define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
59
-# define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
60
-# define PARSER 0x00000001
61
-# define DECL_DUMP 0x00000002
62
-# define TOKENIZER 0x00000004
63
-#else
64
-# define debug0(Flags, Format)
65
-# define debug1(Flags, Format, A)
66
-# define debug2(Flags, Format, A, B)
67
-# define debug3(Flags, Format, A, B, C)
68
-#endif
69
-
70
-/*
71
-** The following macros are purely for the purpose of testing this
72
-** program on itself. They don't really contribute to the code.
73
-*/
74
-#define INTERFACE 1
75
-#define EXPORT_INTERFACE 1
76
-#define EXPORT
77
-
78
-/*
79
-** Each token in a source file is represented by an instance of
80
-** the following structure. Tokens are collected onto a list.
81
-*/
82
-typedef struct Token Token;
83
-struct Token {
84
- const char *zText; /* The text of the token */
85
- int nText; /* Number of characters in the token's text */
86
- int eType; /* The type of this token */
87
- int nLine; /* The line number on which the token starts */
88
- Token *pComment; /* Most recent block comment before this token */
89
- Token *pNext; /* Next token on the list */
90
- Token *pPrev; /* Previous token on the list */
91
-};
92
-
93
-/*
94
-** During tokenization, information about the state of the input
95
-** stream is held in an instance of the following structure
96
-*/
97
-typedef struct InStream InStream;
98
-struct InStream {
99
- const char *z; /* Complete text of the input */
100
- int i; /* Next character to read from the input */
101
- int nLine; /* The line number for character z[i] */
102
-};
103
-
104
-/*
105
-** Each declaration in the C or C++ source files is parsed out and stored as
106
-** an instance of the following structure.
107
-**
108
-** A "forward declaration" is a declaration that an object exists that
109
-** doesn't tell about the objects structure. A typical forward declaration
110
-** is:
111
-**
112
-** struct Xyzzy;
113
-**
114
-** Not every object has a forward declaration. If it does, thought, the
115
-** forward declaration will be contained in the zFwd field for C and
116
-** the zFwdCpp for C++. The zDecl field contains the complete
117
-** declaration text.
118
-*/
119
-typedef struct Decl Decl;
120
-struct Decl {
121
- char *zName; /* Name of the object being declared. The appearance
122
- ** of this name is a source file triggers the declaration
123
- ** to be added to the header for that file. */
124
- const char *zFile; /* File from which extracted. */
125
- char *zIf; /* Surround the declaration with this #if */
126
- char *zFwd; /* A forward declaration. NULL if there is none. */
127
- char *zFwdCpp; /* Use this forward declaration for C++. */
128
- char *zDecl; /* A full declaration of this object */
129
- char *zExtra; /* Extra declaration text inserted into class objects */
130
- int extraType; /* Last public:, protected: or private: in zExtraDecl */
131
- struct Include *pInclude; /* #includes that come before this declaration */
132
- int flags; /* See the "Properties" below */
133
- Token *pComment; /* A block comment associated with this declaration */
134
- Token tokenCode; /* Implementation of functions and procedures */
135
- Decl *pSameName; /* Next declaration with the same "zName" */
136
- Decl *pSameHash; /* Next declaration with same hash but different zName */
137
- Decl *pNext; /* Next declaration with a different name */
138
-};
139
-
140
-/*
141
-** Properties associated with declarations.
142
-**
143
-** DP_Forward and DP_Declared are used during the generation of a single
144
-** header file in order to prevent duplicate declarations and definitions.
145
-** DP_Forward is set after the object has been given a forward declaration
146
-** and DP_Declared is set after the object gets a full declarations.
147
-** (Example: A forward declaration is "typedef struct Abc Abc;" and the
148
-** full declaration is "struct Abc { int a; float b; };".)
149
-**
150
-** The DP_Export and DP_Local flags are more permanent. They mark objects
151
-** that have EXPORT scope and LOCAL scope respectively. If both of these
152
-** marks are missing, then the object has library scope. The meanings of
153
-** the scopes are as follows:
154
-**
155
-** LOCAL scope The object is only usable within the file in
156
-** which it is declared.
157
-**
158
-** library scope The object is visible and usable within other
159
-** files in the same project. By if the project is
160
-** a library, then the object is not visible to users
161
-** of the library. (i.e. the object does not appear
162
-** in the output when using the -H option.)
163
-**
164
-** EXPORT scope The object is visible and usable everywhere.
165
-**
166
-** The DP_Flag is a temporary use flag that is used during processing to
167
-** prevent an infinite loop. It's use is localized.
168
-**
169
-** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
170
-** and are used to specify what type of declaration the object requires.
171
-*/
172
-#define DP_Forward 0x001 /* Has a forward declaration in this file */
173
-#define DP_Declared 0x002 /* Has a full declaration in this file */
174
-#define DP_Export 0x004 /* Export this declaration */
175
-#define DP_Local 0x008 /* Declare in its home file only */
176
-#define DP_Flag 0x010 /* Use to mark a subset of a Decl list
177
- ** for special processing */
178
-#define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
179
- ** C header file */
180
-#define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
181
- ** Prepend nothing in a C header */
182
-#define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
183
- ** DP_Cplusplus is not also set. If DP_Cplusplus
184
- ** is set or this is a C header then
185
- ** prepend 'extern' */
186
-
187
-/*
188
-** Convenience macros for dealing with declaration properties
189
-*/
190
-#define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
191
-#define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
192
-#define DeclSetProperty(D,P) (D)->flags |= (P)
193
-#define DeclClearProperty(D,P) (D)->flags &= ~(P)
194
-
195
-/*
196
-** These are state properties of the parser. Each of the values is
197
-** distinct from the DP_ values above so that both can be used in
198
-** the same "flags" field.
199
-**
200
-** Be careful not to confuse PS_Export with DP_Export or
201
-** PS_Local with DP_Local. Their names are similar, but the meanings
202
-** of these flags are very different.
203
-*/
204
-#define PS_Extern 0x000800 /* "extern" has been seen */
205
-#define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
206
- ** and "#endif" */
207
-#define PS_Export2 0x002000 /* If "EXPORT" seen */
208
-#define PS_Typedef 0x004000 /* If "typedef" has been seen */
209
-#define PS_Static 0x008000 /* If "static" has been seen */
210
-#define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
211
-#define PS_Method 0x020000 /* If "::" token has been seen */
212
-#define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
213
-#define PS_Local2 0x080000 /* If "LOCAL" seen. */
214
-#define PS_Public 0x100000 /* If "PUBLIC" seen. */
215
-#define PS_Protected 0x200000 /* If "PROTECTED" seen. */
216
-#define PS_Private 0x400000 /* If "PRIVATE" seen. */
217
-#define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
218
-
219
-/*
220
-** The following set of flags are ORed into the "flags" field of
221
-** a Decl in order to identify what type of object is being
222
-** declared.
223
-*/
224
-#define TY_Class 0x00100000
225
-#define TY_Subroutine 0x00200000
226
-#define TY_Macro 0x00400000
227
-#define TY_Typedef 0x00800000
228
-#define TY_Variable 0x01000000
229
-#define TY_Structure 0x02000000
230
-#define TY_Union 0x04000000
231
-#define TY_Enumeration 0x08000000
232
-#define TY_Defunct 0x10000000 /* Used to erase a declaration */
233
-
234
-/*
235
-** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
236
-** instances of the following structure.
237
-*/
238
-typedef struct Ifmacro Ifmacro;
239
-struct Ifmacro {
240
- int nLine; /* Line number where this macro occurs */
241
- char *zCondition; /* Text of the condition for this macro */
242
- Ifmacro *pNext; /* Next down in the stack */
243
- int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
244
-};
245
-
246
-/*
247
-** When parsing a file, we need to keep track of what other files have
248
-** be #include-ed. For each #include found, we create an instance of
249
-** the following structure.
250
-*/
251
-typedef struct Include Include;
252
-struct Include {
253
- char *zFile; /* The name of file include. Includes "" or <> */
254
- char *zIf; /* If not NULL, #include should be enclosed in #if */
255
- char *zLabel; /* A unique label used to test if this #include has
256
- * appeared already in a file or not */
257
- Include *pNext; /* Previous include file, or NULL if this is the first */
258
-};
259
-
260
-/*
261
-** Identifiers found in a source file that might be used later to provoke
262
-** the copying of a declaration into the corresponding header file are
263
-** stored in a hash table as instances of the following structure.
264
-*/
265
-typedef struct Ident Ident;
266
-struct Ident {
267
- char *zName; /* The text of this identifier */
268
- Ident *pCollide; /* Next identifier with the same hash */
269
- Ident *pNext; /* Next identifier in a list of them all */
270
-};
271
-
272
-/*
273
-** A complete table of identifiers is stored in an instance of
274
-** the next structure.
275
-*/
276
-#define IDENT_HASH_SIZE 2237
277
-typedef struct IdentTable IdentTable;
278
-struct IdentTable {
279
- Ident *pList; /* List of all identifiers in this table */
280
- Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
281
-};
282
-
283
-/*
284
-** The following structure holds all information for a single
285
-** source file named on the command line of this program.
286
-*/
287
-typedef struct InFile InFile;
288
-struct InFile {
289
- char *zSrc; /* Name of input file */
290
- char *zHdr; /* Name of the generated .h file for this input.
291
- ** Will be NULL if input is to be scanned only */
292
- int flags; /* One or more DP_, PS_ and/or TY_ flags */
293
- InFile *pNext; /* Next input file in the list of them all */
294
- IdentTable idTable; /* All identifiers in this input file */
295
-};
296
-
297
-/*
298
-** An unbounded string is able to grow without limit. We use these
299
-** to construct large in-memory strings from lots of smaller components.
300
-*/
301
-typedef struct String String;
302
-struct String {
303
- int nAlloc; /* Number of bytes allocated */
304
- int nUsed; /* Number of bytes used (not counting nul terminator) */
305
- char *zText; /* Text of the string */
306
-};
307
-
308
-/*
309
-** The following structure contains a lot of state information used
310
-** while generating a .h file. We put the information in this structure
311
-** and pass around a pointer to this structure, rather than pass around
312
-** all of the information separately. This helps reduce the number of
313
-** arguments to generator functions.
314
-*/
315
-typedef struct GenState GenState;
316
-struct GenState {
317
- String *pStr; /* Write output to this string */
318
- IdentTable *pTable; /* A table holding the zLabel of every #include that
319
- * has already been generated. Used to avoid
320
- * generating duplicate #includes. */
321
- const char *zIf; /* If not NULL, then we are within a #if with
322
- * this argument. */
323
- int nErr; /* Number of errors */
324
- const char *zFilename; /* Name of the source file being scanned */
325
- int flags; /* Various flags (DP_ and PS_ flags above) */
326
-};
327
-
328
-/*
329
-** The following text line appears at the top of every file generated
330
-** by this program. By recognizing this line, the program can be sure
331
-** never to read a file that it generated itself.
332
-**
333
-** The "#undef INTERFACE" part is a hack to work around a name collision
334
-** in MSVC 2008.
335
-*/
336
-const char zTopLine[] =
337
- "/* \aThis file was automatically generated. Do not edit! */\n"
338
- "#undef INTERFACE\n";
339
-#define nTopLine (sizeof(zTopLine)-1)
340
-
341
-/*
342
-** The name of the file currently being parsed.
343
-*/
344
-static const char *zFilename;
345
-
346
-/*
347
-** The stack of #if macros for the file currently being parsed.
348
-*/
349
-static Ifmacro *ifStack = 0;
350
-
351
-/*
352
-** A list of all files that have been #included so far in a file being
353
-** parsed.
354
-*/
355
-static Include *includeList = 0;
356
-
357
-/*
358
-** The last block comment seen.
359
-*/
360
-static Token *blockComment = 0;
361
-
362
-/*
363
-** The following flag is set if the -doc flag appears on the
364
-** command line.
365
-*/
366
-static int doc_flag = 0;
367
-
368
-/*
369
-** If the following flag is set, then makeheaders will attempt to
370
-** generate prototypes for static functions and procedures.
371
-*/
372
-static int proto_static = 0;
373
-
374
-/*
375
-** A list of all declarations. The list is held together using the
376
-** pNext field of the Decl structure.
377
-*/
378
-static Decl *pDeclFirst; /* First on the list */
379
-static Decl *pDeclLast; /* Last on the list */
380
-
381
-/*
382
-** A hash table of all declarations
383
-*/
384
-#define DECL_HASH_SIZE 3371
385
-static Decl *apTable[DECL_HASH_SIZE];
386
-
387
-/*
388
-** The TEST macro must be defined to something. Make sure this is the
389
-** case.
390
-*/
391
-#ifndef TEST
392
-# define TEST 0
393
-#endif
394
-
395
-#ifdef NOT_USED
396
-/*
397
-** We do our own assertion macro so that we can have more control
398
-** over debugging.
399
-*/
400
-#define Assert(X) if(!(X)){ CantHappen(__LINE__); }
401
-#define CANT_HAPPEN CantHappen(__LINE__)
402
-static void CantHappen(int iLine){
403
- fprintf(stderr,"Assertion failed on line %d\n",iLine);
404
- *(char*)1 = 0; /* Force a core-dump */
405
-}
406
-#endif
407
-
408
-/*
409
-** Memory allocation functions that are guaranteed never to return NULL.
410
-*/
411
-static void *SafeMalloc(int nByte){
412
- void *p = malloc( nByte );
413
- if( p==0 ){
414
- fprintf(stderr,"Out of memory. Can't allocate %d bytes.\n",nByte);
415
- exit(1);
416
- }
417
- return p;
418
-}
419
-static void SafeFree(void *pOld){
420
- if( pOld ){
421
- free(pOld);
422
- }
423
-}
424
-static void *SafeRealloc(void *pOld, int nByte){
425
- void *p;
426
- if( pOld==0 ){
427
- p = SafeMalloc(nByte);
428
- }else{
429
- p = realloc(pOld, nByte);
430
- if( p==0 ){
431
- fprintf(stderr,
432
- "Out of memory. Can't enlarge an allocation to %d bytes\n",nByte);
433
- exit(1);
434
- }
435
- }
436
- return p;
437
-}
438
-static char *StrDup(const char *zSrc, int nByte){
439
- char *zDest;
440
- if( nByte<=0 ){
441
- nByte = strlen(zSrc);
442
- }
443
- zDest = SafeMalloc( nByte + 1 );
444
- strncpy(zDest,zSrc,nByte);
445
- zDest[nByte] = 0;
446
- return zDest;
447
-}
448
-
449
-/*
450
-** Return TRUE if the character X can be part of an identifier
451
-*/
452
-#define ISALNUM(X) ((X)=='_' || isalnum(X))
453
-
454
-/*
455
-** Routines for dealing with unbounded strings.
456
-*/
457
-static void StringInit(String *pStr){
458
- pStr->nAlloc = 0;
459
- pStr->nUsed = 0;
460
- pStr->zText = 0;
461
-}
462
-static void StringReset(String *pStr){
463
- SafeFree(pStr->zText);
464
- StringInit(pStr);
465
-}
466
-static void StringAppend(String *pStr, const char *zText, int nByte){
467
- if( nByte<=0 ){
468
- nByte = strlen(zText);
469
- }
470
- if( pStr->nUsed + nByte >= pStr->nAlloc ){
471
- if( pStr->nAlloc==0 ){
472
- pStr->nAlloc = nByte + 100;
473
- pStr->zText = SafeMalloc( pStr->nAlloc );
474
- }else{
475
- pStr->nAlloc = pStr->nAlloc*2 + nByte;
476
- pStr->zText = SafeRealloc(pStr->zText, pStr->nAlloc);
477
- }
478
- }
479
- strncpy(&pStr->zText[pStr->nUsed],zText,nByte);
480
- pStr->nUsed += nByte;
481
- pStr->zText[pStr->nUsed] = 0;
482
-}
483
-#define StringGet(S) ((S)->zText?(S)->zText:"")
484
-
485
-/*
486
-** Compute a hash on a string. The number returned is a non-negative
487
-** value between 0 and 2**31 - 1
488
-*/
489
-static int Hash(const char *z, int n){
490
- int h = 0;
491
- if( n<=0 ){
492
- n = strlen(z);
493
- }
494
- while( n-- ){
495
- h = h ^ (h & 0x7fffffff; free software; are; you can redistribute it and/or
496
-** modify it under the terms of the Simplified BSD License (also
497
-** known as the "2-Clause License" or "FreeBSD License".)
498
-**
499
-** Copyright 1993 D. Richard Hipp. All rights reserved.
500
-**
501
-** Redistribution and use in source and binary forms, with or
502
-** without modification, are permitted provided that the following
503
-** conditions are met:
504
-**
505
-** 1. Redistributions of source code must retain the above copyright
506
-** notice, this list of conditions and the following disclaimer.
507
-**
508
-** 2. Redistributions in binary form must reproduce the above copyright
509
-** notice, thisprintf(pDecl/*
510
-** This program is free software; you can redistribute it and/or
511
-** modify it under the terms of the Simplified BSD License (also
512
-** known as the "2-Clause License" or "FreeBSD License".)
513
-**
514
-** Copyright 1993 D. Richard Hipp. All rights reserved.
515
-**
516
-** Redistribution and use in source and binary forms, with or
517
-** without modification, are permitted provided that the following
518
-** conditions are met:
519
-**
520
-** 1. Redistributions of source code must retain the above copyright
521
-** notice, this list of conditions and the following disclaimer.
522
-**
523
-** 2. Redistributions in binary form must reproduce the above copyright
524
-** notice, this list of conditions and the following disclaimer in
525
-** the documentation and/or other materials provided with the
526
-** distribution.
527
-**
528
-** This software is provided "as is" and any express or implied warranties,
529
-** including, but not limited to, the implied warranties of merchantability
530
-** and fitness for a particular purpose are disclaimed. In no event shall
531
-** the author or contributors be liable for any direct, indirect, incidental,
532
-** special, exemplary, or consequential damages (including, but not limited
533
-** to, procurement of substitute goods or services; loss of use, data or
534
-** profits; or business interruption) however caused and on any theory of
535
-** liability, whether in contract, strict liability, or tort (including
536
-** negligence or otherwise) arising in any way out of the use of this
537
-** software, even if advised of the possibility of such damage.
538
-**
539
-** This program is distributed in the hope that it will be useful,
540
-** but without any warranty; without even the implied warranty of
541
-** merchantability or fitness for a particular purpose.
542
-*/
543
-#include <stdio.h>
544
-#include <stdlib.h>
545
-#include <ctype.h>
546
-#include <memory.h>
547
-#include <sys/stat.h>
548
-#include <assert.h>
549
-#include <string.h>
550
-
551
-#if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
552
-# ifndef WIN32
553
-# define WIN32
554
-# endif
555
-#else
556
-# include <unistd.h>
557
-#endif
558
-
559
-/*
560
-** Macros for debugging.
561
-*/
562
-#ifdef DEBUG
563
-static int debugMask = 0;
564
-# define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
565
-# define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
566
-# define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
567
-# define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
568
-# define PARSER 0x00000001
569
-# define DECL_DUMP 0x00000002
570
-# define TOKENIZER 0x00000004
571
-#else
572
-# define debug0(Flags, Format)
573
-# define debug1(Flags, Format, A)
574
-# define debug2(Flags, Format, A, B)
575
-# define debug3(Flags, Format, A, B, C)
576
-#endif
577
-
578
-/*
579
-** The following macros are purely for the purpose of testing this
580
-** program on itself. They don't really contribute to the code.
581
-*/
582
-#define INTERFACE 1
583
-#define EXPORT_INTERFACE 1
584
-#define EXPORT
585
-
586
-/*
587
-** Each token in a source file is represented by an instance of
588
-** the following structure. Tokens are collected onto a list.
589
-*/
590
-typedef struct Token Token;
591
-struct Token {
592
- const char *zText; /* The text of the token */
593
- int nText; /* Number of characters in the token's text */
594
- int eType; /* The type of this token */
595
- int nLine; /* The line number on which the token starts */
596
- Token *pComment; /* Most recent block comment before this token */
597
- Token *pNext; /* Next token on the list */
598
- Token *pPrev; /* Previous token on the list */
599
-};
600
-
601
-/*
602
-** During tokenization, information about the state of the input
603
-** stream is held in an instance of the following structure
604
-*/
605
-typedef struct InStream InStream;
606
-struct InStream {
607
- const char *z; /* Complete text of the input */
608
- int i; /* Next character to read from the input */
609
- int nLine; /* The line number for character z[i] */
610
-};
611
-
612
-/*
613
-** Each declaration in the C or C++ source files is parsed out and stored as
614
-** an instance of the following structure.
615
-**
616
-** A "forward declaration" is a declaration that an object exists that
617
-** doesn't tell about the objects structure. A typical forward declaration
618
-** is:
619
-**
620
-** struct Xyzzy;
621
-**
622
-** Not every object has a forward declaration. If it does, thought, the
623
-** forward declaration will be contained in the zFwd field for C and
624
-** the zFwdCpp for C++. The zDecl field contains the complete
625
-** declaration text.
626
-*/
627
-typedef struct Decl Decl;
628
-struct Decl {
629
- char *zName; /* Name of the object being declared. The appearance
630
- ** of this name is a source file triggers the declaration
631
- ** to be added to the header for that file. */
632
- const char *zFile; /* File from which extracted. */
633
- char *zIf; /* Surround the declaration with this #if */
634
- char *zFwd; /* A forward declaration. NULL if there is none. */
635
- char *zFwdCpp; /* Use this forward declaration for C++. */
636
- char *zDecl; /* A full declaration of this object */
637
- char *zExtra; /* Extra declaration text inserted into class objects */
638
- int extraType; /* Last public:, protected: or private: in zExtraDecl */
639
- struct Include *pInclude; /* #includes that come before this declaration */
640
- int flags; /* See the "Properties" below */
641
- Token *pComment; /* A block comment associated with this declaration */
642
- Token tokenCode; /* Implementation of functions and procedures */
643
- Decl *pSameName; /* Next declaration with the same "zName" */
644
- Decl *pSameHash; /* Next declaration with same hash but different zName */
645
- Decl *pNext; /* Next declaration with a different name */
646
-};
647
-
648
-/*
649
-** Properties associated with declarations.
650
-**
651
-** DP_Forward and DP_Declared are used during the generation of a single
652
-** header file in order to prevent duplicate declarations and definitions.
653
-** DP_Forward is set after the object has been given a forward declaration
654
-** and DP_Declared is set after the object gets a full declarations.
655
-** (Example: A forward declaration is "typedef struct Abc Abc;" and the
656
-** full declaration is "struct Abc { int a; float b; };".)
657
-**
658
-** The DP_Export and DP_Local flags are more permanent. They mark objects
659
-** that have EXPORT scope and LOCAL scope respectively. If both of these
660
-** marks are missing, then the object has library scope. The meanings of
661
-** the scopes are as follows:
662
-**
663
-** LOCAL scope The object is only usable within the file in
664
-** which it is declared.
665
-**
666
-** library scope The object is visible and usable within other
667
-** files in the same project. By if the project is
668
-** a library, then the object is not visible to users
669
-** of the library. (i.e. the object does not appear
670
-** in the output when using the -H option.)
671
-**
672
-** EXPORT scope The object is visible and usable everywhere.
673
-**
674
-** The DP_Flag is a temporary use flag that is used during processing to
675
-** prevent an infinite loop. It's use is localized.
676
-**
677
-** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
678
-** and are used to specify what type of declaration the object requires.
679
-*/
680
-#define DP_Forward 0x001 /* Has a forward declaration in this file */
681
-#define DP_Declared 0x002 /* Has a full declaration in this file */
682
-#define DP_Export 0x004 /* Export this declaration */
683
-#define DP_Local 0x008 /* Declare in its home file only */
684
-#define DP_Flag 0x010 /* Use to mark a subset of a Decl list
685
- ** for special processing */
686
-#define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
687
- ** C header file */
688
-#define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
689
- ** Prepend nothing in a C header */
690
-#define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
691
- ** DP_Cplusplus is not also set. If DP_Cplusplus
692
- ** is set or this is a C header then
693
- ** prepend 'extern' */
694
-
695
-/*
696
-** Convenience macros for dealing with declaration properties
697
-*/
698
-#define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
699
-#define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
700
-#define DeclSetProperty(D,P) (D)->flags |= (P)
701
-#define DeclClearProperty(D,P) (D)->flags &= ~(P)
702
-
703
-/*
704
-** These are state properties of the parser. Each of the values is
705
-** distinct from the DP_ values above so that both can be used in
706
-** the same "flags" field.
707
-**
708
-** Be careful not to confuse PS_Export with DP_Export or
709
-** PS_Local with DP_Local. Their names are similar, but the meanings
710
-** of these flags are very different.
711
-*/
712
-#define PS_Extern 0x000800 /* "extern" has been seen */
713
-#define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
714
- ** and "#endif" */
715
-#define PS_Export2 0x002000 /* If "EXPORT" seen */
716
-#define PS_Typedef 0x004000 /* If "typedef" has been seen */
717
-#define PS_Static 0x008000 /* If "static" has been seen */
718
-#define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
719
-#define PS_Method 0x020000 /* If "::" token has been seen */
720
-#define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
721
-#define PS_Local2 0x080000 /* If "LOCAL" seen. */
722
-#define PS_Public 0x100000 /* If "PUBLIC" seen. */
723
-#define PS_Protected 0x200000 /* If "PROTECTED" seen. */
724
-#define PS_Private 0x400000 /* If "PRIVATE" seen. */
725
-#define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
726
-
727
-/*
728
-** The following set of flags are ORed into the "flags" field of
729
-** a Decl in order to identify what type of object is being
730
-** declared.
731
-*/
732
-#define TY_Class 0x00100000
733
-#define TY_Subroutine 0x00200000
734
-#define TY_Macro 0x00400000
735
-#define TY_Typedef 0x00800000
736
-#define TY_Variable 0x01000000
737
-#define TY_Structure 0x02000000
738
-#define TY_Union 0x04000000
739
-#define TY_Enumeration 0x08000000
740
-#define TY_Defunct 0x10000000 /* Used to erase a declaration */
741
-
742
-/*
743
-** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
744
-** instances of the following structure.
745
-*/
746
-typedef struct Ifmacro Ifmacro;
747
-struct Ifmacro {
748
- int nLine; /* Line number where this macro occurs */
749
- char *zCondition; /* Text of the condition for this macro */
750
- Ifmacro *pNext; /* Next down in the stack */
751
- int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
752
-};
753
-
754
-/*
755
-** When parsing a file, we need to keep track of what other files have
756
-** be #include-ed. For each #include found, we create an instance of
757
-** the following structure.
758
-*/
759
-typedef struct Include Include;
760
-struct Include {
761
- char *zFile; /* The name of file include. Includes "" or <> */
762
- char *zIf; /* If not NULL, #include should be enclosed in #if */
763
- char *zLabel; /* A unique label used to test if this #include has
764
- * appeared already in a file or not */
765
- Include *pNext; /* Previous include file, or NULL if this is the first */
766
-};
767
-
768
-/*
769
-** Identifiers found in a source file that might be used later to provoke
770
-** the copying of a declaration into the corresponding header file are
771
-** stored in a hash table as instances of the following structure.
772
-*/
773
-typedef struct Ident Ident;
774
-struct Ident {
775
- char *zName; /* The text of this identifier */
776
- Ident *pCollide; /* Next identifier with the same hash */
777
- Ident *pNext; /* Next identifier in a list of them all */
778
-};
779
-
780
-/*
781
-** A complete table of identifiers is stored in an instance of
782
-** the next structure.
783
-*/
784
-#define IDENT_HASH_SIZE 2237
785
-typedef struct IdentTable IdentTable;
786
-struct IdentTable {
787
- Ident *pList; /* List of all identifiers in this table */
788
- Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
789
-};
790
-
791
-/*
792
-** The following structure holds all information for a single
793
-** source file named on the command line of this program.
794
-*/
795
-typedef struct InFile InFile;
796
-struct InFile {
797
- char *zSrc; /* Name of input file */
798
- char *zHdr; /* Name of the generated .h file for this input.
799
- ** Will be NULL if input is to be scanned only */
800
- int flags; /* One or more DP_, PS_ and/or TY_ flags */
801
- InFile *pNext; /* Next input file in the list of them all */
802
- IdentTable idTable; /* All identifiers in this input file */
803
-};
804
-
805
-/*
806
-** An unbounded string is able to grow without limit. We use these
807
-** to construct large in-memory strings from lots of smaller components.
808
-*/
809
-typedef struct String String;
810
-struct String {
811
- int nAlloc; /* Number of bytes allocated */
812
- int nUsed; /* Number of bytes used (not counting nul terminator) */
813
- char *zText; /* Text of the string */
814
-};
815
-
816
-/*
817
-** The following structure contains a lot of state information used
818
-** while generating a .h file. We put the information in this structure
819
-** and pass around a pointer to this structure, rather than pass around
820
-** all of the information separately. This helps reduce the number of
821
-** arguments to generator functions.
822
-*/
823
-typedef struct GenState GenState;
824
-struct GenState {
825
- String *pStr; /* Write output to this string */
826
- IdentTable *pTable; /* A table holding the zLabel of every #include that
827
- * has already been generated. Used to avoid
828
- * generating duplicate #includes. */
829
- const char *zIf; /* If not NULL, then we are within a #if with
830
- * this argument. */
831
- int nErr; /* Number of errors */
832
- const char *zFilename; /* Name of the source file being scanned */
833
- int flags; /* Various flags (DP_ and PS_ flags above) */
834
-};
835
-
836
-/*
837
-** The following text line appears at the top of every file generated
838
-** by this program. By recognizing this line, the program can be sure
839
-** never to read a file that it generated itself.
840
-**
841
-** The "#undef INTERFACE" part is a hack to work around a name collision
842
-** in MSVC 2008.
843
-*/
844
-const char zTopLine[] =
845
- "/* \aThis file was automatically generated. Do not edit! */\n"
846
- "#undef INTERFACE\n";
847
-#define nTopLine (sizeof(zTopLine)-1)
848
-
849
-/*
850
-** The name of the file currently being parsed.
851
-*/
852
-static const char *zFilename;
853
-
854
-/*
855
-** The stack of #if macros for the file currently being parsed.
856
-*/
857
-static Ifmacro *ifStack = 0;
858
-
859
-/*
860
-** A list of all files that have been #included so far in a file being
861
-** parsed.
862
-*/
863
-static Include *includeList = 0;
864
-
865
-/*
866
-** The last block comment seen.
867
-*/
868
-static Token *blockComment = 0;
869
-
870
-/*
871
-** The following flag is set if the -doc flag appears on the
872
-** command line.
873
-*/
874
-static int doc_flag = 0;
875
-
876
-/*
877
-** If the following flag is set, then makeheaders will attempt to
878
-** generate prototypes for static functions and procedures.
879
-*/
880
-static int proto_static = 0;
881
-
882
-/*
883
-** A list of all declarations. The list is held together using the
884
-** pNext field of the Decl structure.
885
-*/
886
-static Decl *pDeclFirst; /* First on the list */
887
-static Decl *pDeclLast; /* Last on the list */
888
-
889
-/*
890
-** A hash table of all declarations
891
-*/
892
-#define DECL_HASH_SIZE 3371
893
-static Decl *apTable[DECL_HASH_SIZE];
894
-
895
-/*
896
-** The TEST macro must be defined to something. Make sure this is the
897
-** case.
898
-*/
899
-#ifndef TEST
900
-# define TEST 0
901
-#endif
902
-
903
-#ifdef NOT_USED
904
-/*
905
-** We do our own assertion macro so that we can have more control
906
-** over debugging.
907
-*/
908
-#define Assert(X) if(!(X)){ CantHappen(__LINE__); }
909
-#define CANT_HAPPEN CantHappen(__LINE__)
910
-static void CantHappen(int iLine){
911
- fprintf(stderr,"Assertion failed on line %d\n",iLine);
912
- *(char*)1 = 0; /* Force a core-dump */
913
-}
914
-#endif
915
-
916
-/*
917
-** Memory allocation functions that are guaranteed never to return NULL.
918
-*/
919
-static void *SafeMalloc(int nByte){
920
- void *p = malloc( nByte );
921
- if( p==0 ){
922
- fprintf(stderr,"Out of memory. Can't allocate %d bytes.\n",nByte);
923
- exit(1);
924
- }
925
- return p;
926
-}
927
-static void SafeFree(void *pOld){
928
- if( pOld ){
929
- free(pOld);
930
- }
931
-}
932
-static void *SafeRealloc(void *pOld, int nByte){
933
- void *p;
934
- if( pOld==0 ){
935
- p = SafeMalloc(nByte);
936
- }else{
937
- p = realloc(pOld, nByte);
938
- if( p==0 ){
939
- fprintf(stderr,
940
- "Out of memory. Can't enlarge an allocation to %d bytes\n",nByte);
941
- exit(1);
942
- }
943
- }
944
- return p;
945
-}
946
-static char *StrDup(const char *zSrc, int nByte){
947
- char *zDest;
948
- if( nByte<=0 ){
949
- nByte = strlen(zSrc);
950
- }
951
- zDest = SafeMalloc( nByte + 1 );
952
- strncpy(zDest,zSrc,nByte);
953
- zDest[nByte] = 0;
954
- return zDest;
955
-}
956
-
957
-/*
958
-** Return TRUE if the character X can be part of an identifier
959
-*/
960
-#define ISALNUM(X) ((X)=='_' || isalnum(X))
961
-
962
-/*
963
-** Routines for dealing with unbounded strings.
964
-*/
965
-static void StringInit(String *pStr){
966
- pStr->nAlloc = 0;
967
- pStr->nUsed = 0;
968
- pStr->zText = 0;
969
-}
970
-static void StringReset(String *pStr){
971
- SafeFree(pStr->zText);
972
- StringInit(pStr);
973
-}
974
-static void StringAppend(String *pStr, const char *zText, int nByte){
975
- if( nByte<=0 ){
976
- nByte = strlen(zText);
977
- }
978
- if( pStr->nUsed + nByte >= pStr->nAlloc ){
979
- if( pStr->nAlloc==0 ){
980
- pStr->nAlloc = nByte + 100;
981
- pStr->zText = SafeMalloc( pStr->nAlloc );
982
- }else{
983
- pStr->nAlloc = pStr->nAlloc*2 + nByte;
984
- pStr->zText = SafeRealloc(pStr->zText, pStr->nAlloc);
985
- }
986
- }
987
- strncpy(&pStr->zText[pStr->nUsed],zText,nByte);
988
- pStr->nUsed += nByte;
989
- pStr->zText[pStr->nUsed] = 0;
990
-}
991
-#define StringGet(S) ((S)->zText?(S)->zText:"")
992
-
993
-/*
994
-** Compute a hash on a string. The number returned is a non-negative
995
-** value between 0 and 2**31 - 1
996
-*/
997
-static int Hash(const char *z, int n){
998
- int h = 0;
999
- if( n<=0 ){
1000
- n = strlen(z);
1001
- }
1002
- while( n-- ){
1003
- h = h ^ (h & 0x7fffffff; free software; are; you can redistribute it and/or
1004
-** modify it under the terms of the Simplified BSD License (also
1005
-** known as the "2-Clause License" or "FreeBSD License".)
1006
-**
1007
-** Copyright 1993 D. Richard Hipp. All rights reserved.
1008
-**
1009
-** Redistribution and use in source and binary forms, with or
1010
-** without modification, are permitted provided that the following
1011
-** conditions are met:
1012
-**
1013
-** 1. Redistributions of source code must retain the above copyright
1014
-** notice, this list of conditions and the following disclaimer.
1015
-**
1016
-** 2. Redistributions in binary form must reproduce the above copyright
1017
-** notice, this list of conditions and the following disclaimer in
1018
-** the documentation and/or other materials provided with the
1019
-** distribution.
1020
-**
1021
-** This software is provided "as is" and any express or implied warranties,
1022
-** including, but not limited to, the implied warranties of merchantability
1023
-** and fitness for a particular purpose are disclaimed. In no event shall
1024
-** the author or contributors be liable for any direct, indirect, incidental,
1025
-** special, exemplary, or consequential damages (including, but not limited
1026
-** to, procurement of substitute goods or services; loss of use, data or
1027
-** profits; or business interruption) however caused and on any theory of
1028
-** liability, whether in contract, strict liability, or tort (including
1029
-** negligence or otherwise) arising in any way out of the use of this
1030
-** software, even if advised of the possibility of such damage.
1031
-**
1032
-** This program is distributed in the hope that it will be useful,
1033
-** but without any warranty; without even the implied warranty of
1034
-** merchantability or fitness for a particular purpose.
1035
-*/
1036
-#include <stdio.h>
1037
-#include <stdlib.h>
1038
-#include <ctype.h>
1039
-#include <memory.h>
1040
-#include <sys/stat.h>
1041
-#include <assert.h>
1042
-#include <string.h>
1043
-
1044
-#if defined( __MINGW32__) || defined(__DMC__) || \
1045
- defined(_MSC_VER) || defined(__POCC__)
1046
-# ifndef WIN32
1047
-# define WIN32
1048
-# endif
1049
-#else
1050
-# include <unistd.h>
1051
-#endif
1052
-
1053
-/*
1054
-** Macros for debugging.
1055
-*/
1056
-#ifdef DEBUG
1057
-static int debugMask = 0;
1058
-# define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
1059
-# define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
1060
-# define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
1061
-# define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
1062
-# define PARSER 0x00000001
1063
-# define DECL_DUMP 0x00000002
1064
-# define TOKENIZER 0x00000004
1065
-#else
1066
-# define debug0(Flags, Format)
1067
-# define debug1(Flags, Format, A)
1068
-# define debug2(Flags, Format, A, B)
1069
-# define debug3(Flags, Format, A, B, C)
1070
-#endif
1071
-
1072
-/*
1073
-** The following macros are purely for the purpose of testing this
1074
-** program on itself. They don't really contribute to the code.
1075
-*/
1076
-#define INTERFACE 1
1077
-#define EXPORT_INTERFACE 1
1078
-#define EXPORT
1079
-
1080
-/*
1081
-** Each token in a source file is represented by an instance of
1082
-** the following structure. Tokens are collected onto a list.
1083
-*/
1084
-typedef struct Token Token;
1085
-struct Token {
1086
- const char *zText; /* The text of the token */
1087
- int nText; /* Number of characters in the token's text */
1088
- int eType; /* The type of this token */
1089
- int nLine; /* The line number on which the token starts */
1090
- Token *pComment; /* Most recent block comment before this token */
1091
- Token *pNext; /* Next token on the list */
1092
- Token *pPrev; /* Previous token on the list */
1093
-};
1094
-
1095
-/*
1096
-** During tokenization, information about the state of the input
1097
-** stream is held in an instance of the following structure
1098
-*/
1099
-typedef struct InStream InStream;
1100
-struct InStream {
1101
- const char *z; /* Complete text of the input */
1102
- int i; /* Next character to read from the input */
1103
- int nLine; /* The line number for character z[i] */
1104
-};
1105
-
1106
-/*
1107
-** Each declaration in the C or C++ source files is parsed out and stored as
1108
-** an instance of the following structure.
1109
-**
1110
-** A "forward declaration" is a declaration that an object exists that
1111
-** doesn't tell about the objects structure. A typical forward declaration
1112
-** is:
1113
-**
1114
-** struct Xyzzy;
1115
-**
1116
-** Not every object has a forward declaration. If it does, thought, the
1117
-** forward declaration will be contained in the zFwd field for C and
1118
-** the zFwdCpp for C++. The zDecl field contains the complete
1119
-** declaration text.
1120
-*/
1121
-typedef struct Decl Decl;
1122
-struct Decl {
1123
- char *zName; /* Name of the object being declared. The appearance
1124
- ** of this name is a source file triggers the declaration
1125
- ** to be added to the header for that file. */
1126
- const char *zFile; /* File from which extracted. */
1127
- char *zIf; /* Surround the declaration with this #if */
1128
- char *zFwd; /* A forward declaration. NULL if there is none. */
1129
- char *zFwdCpp; /* Use this forward declaration for C++. */
1130
- char *zDecl; /* A full declaration of this object */
1131
- char *zExtra; /* Extra declaration text inserted into class objects */
1132
- int extraType; /* Last public:, protected: or private: in zExtraDecl */
1133
- struct Include *pInclude; /* #includes that come before this declaration */
1134
- int flags; /* See the "Properties" below */
1135
- Token *pComment; /* A block comment associated with this declaration */
1136
- Token tokenCode; /* Implementation of functions and procedures */
1137
- Decl *pSameName; /* Next declaration with the same "zName" */
1138
- Decl *pSameHash; /* Next declaration with same hash but different zName */
1139
- Decl *pNext; /* Next declaration with a different name */
1140
-};
1141
-
1142
-/*
1143
-** Properties associated with declarations.
1144
-**
1145
-** DP_Forward and DP_Declared are used during the generation of a single
1146
-** header file in order to prevent duplicate declarations and definitions.
1147
-** DP_Forward is set after the object has been given a forward declaration
1148
-** and DP_Declared is set after the object gets a full declarations.
1149
-** (Example: A forward declaration is "typedef struct Abc Abc;" and the
1150
-** full declaration is "struct Abc { int a; float b; };".)
1151
-**
1152
-** The DP_Export and DP_Local flags are more permanent. They mark objects
1153
-** that have EXPORT scope and LOCAL scope respectively. If both of these
1154
-** marks are missing, then the object has library scope. The meanings of
1155
-** the scopes are as follows:
1156
-**
1157
-** LOCAL scope The object is only usable within the file in
1158
-** which it is declared.
1159
-**
1160
-** library scope The object is visible and usable within other
1161
-** files in the same project. By if the project is
1162
-** a library, then the object is not visible to users
1163
-** of the library. (i.e. the object does not appear
1164
-** in the output when using the -H option.)
1165
-**
1166
-** EXPORT scope The object is visible and usable everywhere.
1167
-**
1168
-** The DP_Flag is a temporary use flag that is used during processing to
1169
-** prevent an infinite loop. It's use is localized.
1170
-**
1171
-** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
1172
-** and are used to specify what type of declaration the object requires.
1173
-*/
1174
-#define DP_Forward 0x001 /* Has a forward declaration in this file */
1175
-#define DP_Declared 0x002 /* Has a full declaration in this file */
1176
-#define DP_Export 0x004 /* Export this declaration */
1177
-#define DP_Local 0x008 /* Declare in its home file only */
1178
-#define DP_Flag 0x010 /* Use to mark a subset of a Decl list
1179
- ** for special processing */
1180
-#define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
1181
- ** C header file */
1182
-#define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
1183
- ** Prepend nothing in a C header */
1184
-#define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
1185
- ** DP_Cplusplus is not also set. If DP_Cplusplus
1186
- ** is set or this is a C header then
1187
- ** prepend 'extern' */
1188
-
1189
-/*
1190
-** Convenience macros for dealing with declaration properties
1191
-*/
1192
-#define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
1193
-#define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
1194
-#define DeclSetProperty(D,P) (D)->flags |= (P)
1195
-#define DeclClearProperty(D,P) (D)->flags &= ~(P)
1196
-
1197
-/*
1198
-** These are state properties of the parser. Each of the values is
1199
-** distinct from the DP_ values above so that both can be used in
1200
-** the same "flags" field.
1201
-**
1202
-** Be careful not to confuse PS_Export with DP_Export or
1203
-** PS_Local with DP_Local. Their names are similar, but the meanings
1204
-** of these flags are very different.
1205
-*/
1206
-#define PS_Extern 0x000800 /* "extern" has been seen */
1207
-#define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
1208
- ** and "#endif" */
1209
-#define PS_Export2 0x002000 /* If "EXPORT" seen */
1210
-#define PS_Typedef 0x004000 /* If "typedef" has been seen */
1211
-#define PS_Static 0x008000 /* If "static" has been seen */
1212
-#define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
1213
-#define PS_Method 0x020000 /* If "::" token has been seen */
1214
-#define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
1215
-#define PS_Local2 0x080000 /* If "LOCAL" seen. */
1216
-#define PS_Public 0x100000 /* If "PUBLIC" seen. */
1217
-#define PS_Protected 0x200000 /* If "PROTECTED" seen. */
1218
-#define PS_Private 0x400000 /* If "PRIVATE" seen. */
1219
-#define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
1220
-
1221
-/*
1222
-** The following set of flags are ORed into the "flags" field of
1223
-** a Decl in order to identify what type of object is being
1224
-** declared.
1225
-*/
1226
-#define TY_Class 0x00100000
1227
-#define TY_Subroutine 0x00200000
1228
-#define TY_Macro 0x00400000
1229
-#define TY_Typedef 0x00800000
1230
-#define TY_Variable 0x01000000
1231
-#define TY_Structure 0x02000000
1232
-#define TY_Union 0x04000000
1233
-#define TY_Enumeration 0x08000000
1234
-#define TY_Defunct 0x10000000 /* Used to erase a declaration */
1235
-
1236
-/*
1237
-** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
1238
-** instances of the following structure.
1239
-*/
1240
-typedef struct Ifmacro Ifmacro;
1241
-struct Ifmacro {
1242
- int nLine; /* Line number where this macro occurs */
1243
- char *zCondition; /* Text of the condition for this macro */
1244
- Ifmacro *pNext; /* Next down in the stack */
1245
- int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
1246
-};
1247
-
1248
-/*
1249
-** When parsing a file, we need to keep track of what other files have
1250
-** be #include-ed. For each #include found, we create an instance of
1251
-** the following structure.
1252
-*/
1253
-typedef struct Include Include;
1254
-struct Include {
1255
- char *zFile; /* The name of file include. Includes "" or <> */
1256
- char *zIf; /* If not NULL, #include should be enclosed in #if */
1257
- char *zLabel; /* A unique label used to test if this #include has
1258
- * appeared already in a file or not */
1259
- Include *pNext; /* Previous include file, or NULL if this is the first */
1260
-};
1261
-
1262
-/*
1263
-** Identifiers found in a source file that might be used later to provoke
1264
-** the copying of a declaration into the corresponding header file are
1265
-** stored in a hash table as instances of the following structure.
1266
-*/
1267
-typedef struct Ident Ident;
1268
-struct Ident {
1269
- char *zName; /* The text of this identifier */
1270
- Ident *pCollide; /* Next identifier with the same hash */
1271
- Ident *pNext; /* Next identifier in a list of them all */
1272
-};
1273
-
1274
-/*
1275
-** A complete table of identifiers is stored in an instance of
1276
-** the next structure.
1277
-*/
1278
-#define IDENT_HASH_SIZE 2237
1279
-typedef struct IdentTable IdentTable;
1280
-struct IdentTable {
1281
- Ident *pList; /* List of all identifiers in this table */
1282
- Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
1283
-};
1284
-
1285
-/*
1286
-** The following structure holds all information for a single
1287
-** source file named on the command line of this program.
1288
-*/
1289
-typedef struct InFile InFile;
1290
-struct InFile {
1291
- char *zSrc; /* Name of input file */
1292
- char *zHdr; /* Name of the generated .h file for this input.
1293
- ** Will be NULL if input is to be scanned only */
1294
- int flags; /* One or more DP_, PS_ and/or TY_ flags */
1295
- InFile *pNext; /* Next input file in the list of them all */
1296
- IdentTable idTable; /* All identifiers in this input file */
1297
-};
1298
-
1299
-/*
1300
-** An unbounded string is able to grow without limit. We use these
1301
-** to construct large in-memory strings from lots of smaller components.
1302
-*/
1303
-typedef struct String String;
1304
-struct String {
1305
- int nAlloc; /* Number of bytes allocated */
1306
- int nUsed; /* Number of bytes used (not counting nul terminator) */
1307
- char *zText; /* Text of the string */
1308
-};
1309
-
1310
-/*
1311
-** The following structure contains a lot of state information used
1312
-** while generating a .h file. We put the information in this structure
1313
-** and pass around a pointer to this structure, rather than pass around
1314
-** all of the information separately. This helps reduce the number of
1315
-** arguments to generator functions.
1316
-*/
1317
-typedef struct GenState GenState;
1318
-struct GenState {
1319
- String *pStr; /* Write output to this string */
1320
- IdentTable *pTable; /* A table holding the zLabel of every #include that
1321
- * has already been generated. Used to avoid
1322
- * generating duplicate #includes. */
1323
- const char *zIf; /* If not NULL, then we are within a #if with
1324
- * this argument. */
1325
- int nErr; /* Number of errors */
1326
- const char *zFilename; /* Name of the source file being scanned */
1327
- int flags; /* Various flags (DP_ and PS_ flags above) */
1328
-};
1329
-
1330
-/*
1331
-** The following text line appears at the top of every file generated
1332
-** by this program. By recognizing this line, the program can be sure
1333
-** never to read a file that it generated itself.
1334
-**
1335
-** The "#undef INTERFACE" part is a hack to work around a name collision
1336
-** in MSVC 2008.
1337
-*/
1338
-const char zTopLine[] =
1339
- "/* \aThis file was automatically generated. Do not edit! */\n"
1340
- "#undef INTERFACE\n";
1341
-#define nTopLine (sizeof(zTopLine)-1)
1342
-
1343
-/*
1344
-** The name of the file currently being parsed.
1345
-*/
1346
-static const char *zFilename;
1347
-
1348
-/*
1349
-** The stack of #if macros for the file currently being parsed.
1350
-*/
1351
-static Ifmacro *ifStack = 0;
1352
-
1353
-/*
1354
-** A list of all files that have been #included so far in a file being
1355
-** parsed.
1356
-*/
1357
-static Include *includeList = 0;
1358
-
1359
-/*
1360
-** The last block comment seen.
1361
-*/
1362
-static Token *blockComment = 0;
1363
-
1364
-/*
1365
-** The following flag is set if the -doc flag appears on the
1366
-** command line.
1367
-*/
1368
-static int doc_flag = 0;
1369
-
1370
-/*
1371
-** If the following flag is set, then makeheaders will attempt to
1372
-** generate prototypes for static functions and procedures.
1373
-*/
1374
-static int proto_static = 0;
1375
-
1376
-/*
1377
-** A list of all declarations. The list is held together using the
1378
-** pNext field of the Decl structure.
1379
-*/
1380
-static Decl *pDeclFirst; /* First on the list */
1381
-static Decl *pDeclLast; /* Last on the list */
1382
-
1383
-/*
1384
-** A hash table of all declarations
1385
-*/
1386
-#define DECL_HASH_SIZE 3371
1387
-static Decl *apTable[DECL_HASH_SIZE];
1388
-
1389
-/*
1390
-** The TEST macro must be defined to something. Make sure this is the
1391
-** case.
1392
-*/
1393
-#ifndef TEST
1394
-# define TEST 0
1395
-#endif
1396
-
1397
-#ifdef NOT_USED
1398
-/*
1399
-** We do our own assertion macro so that we can have more control
1400
-** over debugging.
1401
-*/
1402
-#define Assert(X) if(!(X)){ CantHappen(__LINE__); }
1403
-#define CANT_HAPPEN CantHappen(__LINE__)
1404
-static void CantHappen(int iLine){
1405
- fprintf(stderr,"Assertion failed on line %d\n",iLine);
1406
- *(char*)1 = 0; /* Force a core-dump */
1407
-}
1408
-#endif
1409
-
1410
-/*
1411
-** Memory allocation functions that are guaranteed never to return NULL.
1412
-*/
1413
-static void *SafeMalloc(int nByte){
1414
- void *p = malloc( nByte );
1415
- if( p==0 ){
1416
- fprintf(stderr,"Out of memory. Can't allocate %d bytes.\n",nByte);
1417
- exit(1);
1418
- }
1419
- return p;
1420
-}
1421
-static void SafeFree(void *pOld){
1422
- if( pOld ){
1423
- free(pOld);
1424
- }
1425
-}
1426
-static void *SafeRealloc(void *pOld, int nByte){
1427
- void *p;
1428
- if( pOld==0 ){
1429
- p = SafeMalloc(nByte);
1430
- }else{
1431
- p = realloc(pOld, nByte);
1432
- if( p==0 ){
1433
- fprintf(stderr,
1434
- "Out of memory. Can't enlarge an allocation to %d bytes\n",nByte);
1435
- exit(1);
1436
- }
1437
- }
1438
- return p;
1439
-}
1440
-static char *StrDup(const char *zSrc, int nByte){
1441
- char *zDest;
1442
- if( nByte<=0 ){
1443
- nByte = strlen(zSrc);
1444
- }
1445
- zDest = SafeMalloc( nByte + 1 );
1446
- strncpy(zDest,zSrc,nByte);
1447
- zDest[nByte] = 0;
1448
- return zDest;
1449
-}
1450
-
1451
-/*
1452
-** Return TRUE if the character X can be part of an identifier
1453
-*/
1454
-#define ISALNUM(X) ((X)=='_' || isalnum(X))
1455
-
1456
-/*
1457
-** Routines for dealing with unbounded strings.
1458
-*/
1459
-static void StringInit(String *pStr){
1460
- pStr->nAlloc = 0;
1461
- pStr->nUsed = 0;
1462
- pStr->zText = 0;
1463
-}
1464
-static void StringReset(String *pStr){
1465
- SafeFree(pStr->zText);
1466
- StringInit(pStr);
1467
-}
1468
-static void StringAppend(String *pStr, const char *zText, int nByte){
1469
- if( nByte<=0 ){
1470
- nByte = strlen(zText);
1471
- }
1472
- if( pStr->nUsed + nByte >= pStr->nAlloc ){
1473
- if( pStr->nAlloc==0 ){
1474
- pStr->nAlloc = nByte + 100;
1475
- pStr->zText = SafeMalloc( pStr->nAlloc );
1476
- }else{
1477
- pStr->nAlloc = pStr->nAlloc*2 + nByte;
1478
- pStr->zText = SafeRealloc(pStr->zText, pStr->nAlloc);
1479
- }
1480
- }
1481
- strncpy(&pStr->zText[pStr->nUsed],zText,nByte);
1482
- pStr->nUsed += nByte;
1483
- pStr->zText[pStr->nUsed] = 0;
1484
-}
1485
-#define StringGet(S) ((S)->zText?(S)->zText:"")
1486
-
1487
-/*
1488
-** Compute a hash on a string. The number returned is a non-negative
1489
-** value between 0 and 2**31 - 1
1490
-*/
1491
-static int Hash(const char *z, int n){
1492
- unsigned int h = 0;
1493
- if( n<=0 ){
1494
- n = strlen(z);
1495
- }
1496
- while( n-- ){
1497
- h = h ^ (h<<5) ^ *z++;
1498
- }
1499
- return (int)(h & 0x7fffffff);
1500
-}
1501
-
1502
-/*
1503
-** Given an identifier name, try to find a declaration for that
1504
-** identifier in the hash table. If found, return a pointer to
1505
-** the Decl structure. If not found, return 0.
1506
-*/
1507
-static Decl *FindDecl(const char *zName, int len){
1508
- int h;
1509
- Decl *p;
1510
-
1511
- if( len<=0 ){
1512
- len = strlen(zName);
1513
- }
1514
- h = Hash(zName,len) % DECL_HASH_SIZE;
1515
- p = apTable[h];
1516
- while( p && (strncmp(p->zName,zName,len)!=0 || p->zName[len]!=0) ){
1517
- p = p->pSameHash;
1518
- }
1519
- return p;
1520
-}
1521
-
1522
-/*
1523
-** Install the given declaration both in the hash table and on
1524
-** the list of all declarations.
1525
-*/
1526
-static void InstallDecl(Decl *pDecl){
1527
- int h;
1528
- Decl *pOther;
1529
-
1530
- h = Hash(pDecl->zName,0) % DECL_HASH_SIZE;
1531
- pOther = apTable[h];
1532
- while( pOther && strcmp(pDecl->zName,pOther->zName)!=0 ){
1533
- pOther = pOther->pSameHash;
1534
- }
1535
- if( pOther ){
1536
- pDecl->pSameName = pOther->pSameName;
1537
- pOther->pSameName = pDecl;
1538
- }else{
1539
- pDecl->pSameName = 0;
1540
- pDecl->pSameHash = apTable[h];
1541
- apTable[h] = pDecl;
1542
- }
1543
- pDecl->pNext = 0;
1544
- if( pDeclFirst==0 ){
1545
- pDeclFirst = pDeclLast = pDecl;
1546
- }else{
1547
- pDeclLast->pNext = pDecl;
1548
- pDeclLast = pDecl;
1549
- }
1550
-}
1551
-
1552
-/*
1553
-** Look at the current ifStack. If anything declared at the current
1554
-** position must be surrounded with
1555
-**
1556
-** #if STUFF
1557
-** #endif
1558
-**
1559
-** Then this routine computes STUFF and returns a pointer to it. Memory
1560
-** to hold the value returned is obtained from malloc().
1561
-*/
1562
-static char *GetIfString(void){
1563
- Ifmacro *pIf;
1564
- char *zResult = 0;
1565
- int hasIf = 0;
1566
- String str;
1567
-
1568
- for(pIf = ifStack; pIf; pIf=pIf->pNext){
1569
- if( pIf->zCondition==0 || *pIf->zCondition==0 ) continue;
1570
- if( !hasIf ){
1571
- hasIf = 1;
1572
- StringInit(&str);
1573
- }else{
1574
- StringAppend(&str," && ",4);
1575
- }
1576
- StringAppend(&str,pIf->zCondition,0);
1577
- }
1578
- if( hasIf ){
1579
- zResult = StrDup(StringGet(&str),0);
1580
- StringReset(&str);
1581
- }else{
1582
- zResult = 0;
1583
- }
1584
- return zResult;
1585
-}
1586
-
1587
-/*
1588
-** Create a new declaration and put it in the hash table. Also
1589
-** return a pointer to it so that we can fill in the zFwd and zDecl
1590
-** fields, and so forth.
1591
-*/
1592
-static Decl *CreateDecl(
1593
- const char *zName, /* Name of the object being declared. */
1594
- int nName /* Length of the name */
1595
-){
1596
- Decl *pDecl;
1597
-
1598
- pDecl = SafeMalloc( sizeof(Decl) + nName + 1);
1599
- memset(pDecl,0,sizeof(Decl));
1600
- pDecl->zName = (char*)&pDecl[1];
1601
- memcpy(pDecl->zName, zName, nName);
1602
- pDecl->zName[nName] = 0;
1603
- pDecl->zFile = zFilename;
1604
- pDecl->pInclude = includeList;
1605
- pDecl->zIf = GetIfString();
1606
- InstallDecl(pDecl);
1607
- return pDecl;
1608
-}
1609
-
1610
-/*
1611
-** Insert a new identifier into an table of identifiers. Return TRUE if
1612
-** a new identifier was inserted and return FALSE if the identifier was
1613
-** already in the table.
1614
-*/
1615
-static int IdentTableInsert(
1616
- IdentTable *pTable, /* The table into which we will insert */
1617
- const char *zId, /* Name of the identifiers */
1618
- int nId /* Length of the identifier name */
1619
-){
1620
- int h;
1621
- Ident *pId;
1622
-
1623
- if( nId<=0 ){
1624
- nId = strlen(zId);
1625
- }
1626
- h = Hash(zId,nId) % IDENT_HASH_SIZE;
1627
- for(pId = pTable->apTable[h]; pId; pId=pId->pCollide){
1628
- if( strncmp(zId,pId->zName,nId)==0 && pId->zName[nId]==0 ){
1629
- /* printf("Already in table: %.*s\n",nId,zId); */
1630
- return 0;
1631
- }
1632
- }
1633
- pId = SafeMalloc( sizeof(Ident) + nId + 1 );
1634
- pId->zName = (char*)&pId[1];
1635
- memcpy(pId->zName, zId, nId);
1636
- pId->zName[nId] = 0;
1637
- pId->pNext = pTable->pList;
1638
- pTable->pList = pId;
1639
- pId->pCollide = pTable->apTable[h];
1640
- pTable->apTable[h] = pId;
1641
- /* printf("Add to table: %.*s\n",nId,zId); */
1642
- return 1;
1643
-}
1644
-
1645
-/*
1646
-** Check to see if the given value is in the given IdentTable. Return
1647
-** true if it is and false if it is not.
1648
-*/
1649
-static int IdentTableTest(
1650
- IdentTable *pTable, /* The table in which to search */
1651
- const char *zId, /* Name of the identifiers */
1652
- int nId /* Length of the identifier name */
1653
-){
1654
- int h;
1655
- Ident *pId;
1656
-
1657
- if( nId<=0 ){
1658
- nId = strlen(zId);
1659
- }
1660
- h = Hash(zId,nId) % IDENT_HASH_SIZE;
1661
- for(pId = pTable->apTable[h]; pId; pId=pId->pCollide){
1662
- if( strncmp(zId,pId->zName,nId)==0 && pId->zName[nId]==0 ){
1663
- return 1;
1664
- }
1665
- }
1666
- return 0;
1667
-}
1668
-
1669
-/*
1670
-** Remove every identifier from the given table. Reset the table to
1671
-** its initial state.
1672
-*/
1673
-static void IdentTableReset(IdentTable *pTable){
1674
- Ident *pId, *pNext;
1675
-
1676
- for(pId = pTable->pList; pId; pId = pNext){
1677
- pNext = pId->pNext;
1678
- SafeFree(pId);
1679
- }
1680
- memset(pTable,0,sizeof(IdentTable));
1681
-}
1682
-
1683
-#ifdef DEBUG
1684
-/*
1685
-** Print the name of every identifier in the given table, one per line
1686
-*/
1687
-static void IdentTablePrint(IdentTable *pTable, FILE *pOut){
1688
- Ident *pId;
1689
-
1690
- for(pId = pTable->pList; pId; pId = pId->pNext){
1691
- fprintf(pOut,"%s\n",pId->zName);
1692
- }
1693
-}
1694
-#endif
1695
-
1696
-/*
1697
-** Read an entire file into memory. Return a pointer to the memory.
1698
-**
1699
-** The memory is obtained from SafeMalloc and must be freed by the
1700
-** calling function.
1701
-**
1702
-** If the read fails for any reason, 0 is returned.
1703
-*/
1704
-static char *ReadFile(const char *zFilename){
1705
- struct stat sStat;
1706
- FILE *pIn;
1707
- char *zBuf;
1708
- int n;
1709
-
1710
- if( stat(zFilename,&sStat)!=0
1711
-#ifndef WIN32
1712
- || !S_ISREG(sStat.st_mode)
1713
-#endif
1714
- ){
1715
- return 0;
1716
- }
1717
- pIn = fopen(zFilename,"r");
1718
- if( pIn==0 ){
1719
- return 0;
1720
- }
1721
- zBuf = SafeMalloc( sStat.st_size + 1 );
1722
- n = fread(zBuf,1,sStat.st_size,pIn);
1723
- zBuf[n] = 0;
1724
- fclose(pIn);
1725
- return zBuf;
1726
-}
1727
-
1728
-/*
1729
-** Write the contents of a string into a file. Return the number of
1730
-** errors
1731
-*/
1732
-static int WriteFile(const char *zFilename, const char *zOutput){
1733
- FILE *pOut;
1734
- pOut = fopen(zFilename,"w");
1735
- if( pOut==0 ){
1736
- return 1;
1737
- }
1738
- fwrite(zOutput,1,strlen(zOutput),pOut);
1739
- fclose(pOut);
1740
- return 0;
1741
-}
1742
-
1743
-/*
1744
-** Major token types
1745
-*/
1746
-#define TT_Space 1 /* Contiguous white space */
1747
-#define TT_Id 2 /* An identifier */
1748
-#define TT_Preprocessor 3 /* Any C preprocessor directive */
1749
-#define TT_Comment 4 /* Either C or C++ style comment */
1750
-#define TT_Number 5 /* Any numeric constant */
1751
-#define TT_String 6 /* String or character constants. ".." or '.' */
1752
-#define TT_Braces 7 /* All text between { and a matching } */
1753
-#define TT_EOF 8 /* End of file */
1754
-#define TT_Error 9 /* An error condition */
1755
-#define TT_BlockComment 10 /* A C-Style comment at the left margin that
1756
- * spans multiple lines */
1757
-#define TT_Other 0 /* None of the above */
1758
-
1759
-/*
1760
-** Get a single low-level token from the input file. Update the
1761
-** file pointer so that it points to the first character beyond the
1762
-** token.
1763
-**
1764
-** A "low-level token" is any token except TT_Braces. A TT_Braces token
1765
-** consists of many smaller tokens and is assembled by a routine that
1766
-** calls this one.
1767
-**
1768
-** The function returns the number of errors. An error is an
1769
-** unterminated string or character literal or an unterminated
1770
-** comment.
1771
-**
1772
-** Profiling shows that this routine consumes about half the
1773
-** CPU time on a typical run of makeheaders.
1774
-*/
1775
-static int GetToken(InStream *pIn, Token *pToken){
1776
- int i;
1777
- const char *z;
1778
- int cStart;
1779
- int c;
1780
- int startLine; /* Line on which a structure begins */
1781
- int nlisc = 0; /* True if there is a new-line in a ".." or '..' */
1782
- int nErr = 0; /* Number of errors seen */
1783
-
1784
- z = pIn->z;
1785
- i = pIn->i;
1786
- pToken->nLine = pIn->nLine;
1787
- pToken->zText = &z[i];
1788
- switch( z[i] ){
1789
- case 0:
1790
- pToken->eType = TT_EOF;
1791
- pToken->nText = 0;
1792
- break;
1793
-
1794
- case '#':
1795
- if( i==0 || z[i-1]=='\n' || (i>1 && z[i-1]=='\r' && z[i-2]=='\n')){
1796
- /* We found a preprocessor statement */
1797
- pToken->eType = TT_Preprocessor;
1798
- i++;
1799
- while( z[i]!=0 && z[i]!='\n' ){
1800
- if( z[i]=='\\' ){
1801
- i++;
1802
- if( z[i]=='\n' ) pIn->nLine++;
1803
- }
1804
- i++;
1805
- }
1806
- pToken->nText = i - pIn->i;
1807
- }else{
1808
- /* Just an operator */
1809
- pToken->eType = TT_Other;
1810
- pToken->nText = 1;
1811
- }
1812
- break;
1813
-
1814
- case ' ':
1815
- case '\t':
1816
- case '\r':
1817
- case '\f':
1818
- case '\n':
1819
- while( isspace(z[i]) ){
1820
- if( z[i]=='\n' ) pIn->nLine++;
1821
- i++;
1822
- }
1823
- pToken->eType = TT_Space;
1824
- pToken->nText = i - pIn->i;
1825
- break;
1826
-
1827
- case '\\':
1828
- pToken->nText = 2;
1829
- pToken->eType = TT_Other;
1830
- if( z[i+1]=='\n' ){
1831
- pIn->nLine++;
1832
- pToken->eType = TT_Space;
1833
- }else if( z[i+1]==0 ){
1834
- pToken->nText = 1;
1835
- }
1836
- break;
1837
-
1838
- case '\'':
1839
- case '\"':
1840
- cStart = z[i];
1841
- startLine = pIn->nLine;
1842
- do{
1843
- i++;
1844
- c = z[i];
1845
- if( c=='\n' ){
1846
- if( !nlisc ){
1847
- fprintf(stderr,
1848
- "%s:%d: (warning) Newline in string or character literal.\n",
1849
- zFilename, pIn->nLine);
1850
- nlisc = 1;
1851
- }
1852
- pIn->nLine++;
1853
- }
1854
- if( c=='\\' ){
1855
- i++;
1856
- nLine++;
1857
- }
1858
- }else if( c==cStart ){
1859
- i++;
1860
- c = 0;
1861
- }else if( c==0 ){
1862
- fprintf(stderr, "%s:%d: Unterminated string or character literal.\n",
1863
- zFilename, startLine);
1864
- nErr++;
1865
- }
1866
- }while( c );
1867
- pToken->eType = TT_String;
1868
- pToken->nText = i - pIn->i;
1869
- break;
1870
-
1871
- case '/':
1872
- if( z[i+1]=='/' ){
1873
- /* C++ style comment */
1874
- while( z[i] && z[i]!='\n' ){ i++; }
1875
- pToken->eType = TT_Comment;
1876
- pToken->nText = i - pIn->i;
1877
- }else if( z[i+1]=='*' ){
1878
- /* C style comment */
1879
- int isBlockComment = i==0 || z[i-1]=='\n';
1880
- i += 2;
1881
- startLine = pIn->nLine;
1882
- while( z[i] && (z[i]!='*' || z[i+1]!='/') ){
1883
- if( z[i]=='\n' ){
1884
- pIn->nLine++;
1885
- if( isBlockComment ){
1886
- if( z[i+1]=='*' || z[i+2]=='*' ){
1887
- isBlockComment = 2;
1888
- }else{
1889
- isBlockComment = 0;
1890
- }
1891
- }
1892
- }
1893
- i++;
1894
- }
1895
- if( z[i] ){
1896
- i += 2;
1897
- }else{
1898
- isBlockComment = 0;
1899
- fprintf(stderr,"%s:%d: Unterminated comment\n",
1900
- zFilename, startLine);
1901
- nErr++;
1902
- }
1903
- pToken->eType = isBlockComment==2 ? TT_BlockComment : TT_Comment;
1904
- pToken->nText = i - pIn->i;
1905
- }else{
1906
- /* A divide operator */
1907
- pToken->eType = TT_Other;
1908
- pToken->nText = 1 + (z[i+1]=='+');
1909
- }
1910
- break;
1911
-
1912
- case '0':
1913
- if( z[i+1]=='x' || z[i+1]=='X' ){
1914
- /* A hex constant */
1915
- i += 2;
1916
- while( isxdigit(z[i]) ){ i++; }
1917
- }else{
1918
- /* An octal constant */
1919
- while( isdigit(z[i]) ){ i++; }
1920
- }
1921
- pToken->eType = TT_Number;
1922
- pToken->nText = i - pIn->i;
1923
- break;
1924
-
1925
- case '1': case '2': case '3': case '4':
1926
- case '5': case '6': case '7': case '8': case '9':
1927
- while( isdigit(z[i]) ){ i++; }
1928
- if( (c=z[i])=='.' ){
1929
- i++;
1930
- while( isdigit(z[i]) ){ i++; }
1931
- c = z[i];
1932
- if( c=='e' || c=='E' ){
1933
- i++;
1934
- if( ((c=z[i])=='+' || c=='-') && isdigit(z[i+1]) ){ i++; }
1935
- while( isdigit(z[i]) ){ i++; }
1936
- c = z[i];
1937
- }
1938
- if( c=='f' || c=='F' || c=='l' || c=='L' ){ i++; }
1939
- }else if( c=='e' || c=='E' ){
1940
- i++;
1941
- if( ((c=z[i])=='+' || c=='-') && isdigit(z[i+1]) ){ i++; }
1942
- while( isdigit(z[i]) ){ i++; }
1943
- }else if( c=='L' || c=='l' ){
1944
- i++;
1945
- c = z[i];
1946
- if( ){
1947
- i++;
1948
- c = z[i];
1949
- if( c=='l' || c=='L' ){ i++; }
1950
- }
1951
- pToken->eType = TT_Number;
1952
- pToken->nText = i - pIn->i;
1953
- break;
1954
-
1955
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
1956
- case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
1957
- case 'o': case 'p': case 'r contributors be liable for any direct, indirect, incidental,
1958
-** special, exemplary, or consequential damages (including, but not limited
1959
-** to, procurement of substitute goods or services; loss of use, data or
1960
-** profits; or business interruption) however caused and on any theory of
1961
-** liability, whether in contract, strict liability, or tort (including
1962
-** negligence or otherwise) arising in any way out of the use of this
1963
-** software, even if advised of the possibility of such damage.
1964
-**
1965
-** This program is distributed in the hope that it will be useful,
1966
-** but without any warranty; without even the implied warranty of
1967
-** merchantability or fitness for a particular purpose.
1968
-*/
1969
-#include <stdio.h>
1970
-#include <stdlib.h>
1971
-#include <ctype.h>
1972
-#include <memory.h>
1973
-#include <sys/stat.h>
1974
-#include <assert.h>
1975
-#include <string.h>
1976
-
1977
-#if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
1978
-# ifndef WIN32
1979
-# define WIN32
1980
-# endif
1981
-#else
1982
-# include <unistd.h>
1983
-#endif
1984
-
1985
-/*
1986
-** Macros for debugging.
1987
-*/
1988
-#ifdef DEBUG
1989
-static int debugMask = 0;
1990
-# define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
1991
-# define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
1992
-# define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
1993
-# define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
1994
-# define PARSER 0x00000001
1995
-# define DECL_DUMP 0x00000002
1996
-# define TOKENIZER 0x00000004
1997
-#else
1998
-# define debug0(Flags, Format)
1999
-# define debug1(Flags, Format, A)
2000
-# define debug2(Flags, Format, A, B)
2001
-# define debug3(Flags, Format, A, B, C)
2002
-#endif
2003
-
2004
-/*
2005
-** The following macros are purely for the purpose of testing this
2006
-** program on itself. They don't really contribute to the code.
2007
-*/
2008
-#define INTERFACE 1
2009
-#define EXPORT_INTERFACE 1
2010
-#define EXPORT
2011
-
2012
-/*
2013
-** Each token in a source file is represented by an instance of
2014
-** the following structure. Tokens are collected onto a list.
2015
-*/
2016
-typedef struct Token Token;
2017
-struct Token {
2018
- const char *zText; /* The text of the token */
2019
- int nText; /* Number of characters in the token's text */
2020
- int eType; /* The type of this token */
2021
- int nLine; /* The line number on which the token starts */
2022
- Token *pComment; /* Most recent block comment before this token */
2023
- Token *pNext; /* Next token on the list */
2024
- Token *pPrev; /* Previous token on the list */
2025
-};
2026
-
2027
-/*
2028
-** During tokenization, information about the state of the input
2029
-** stream is held in an instance of the following structure
2030
-*/
2031
-typedef struct InStream InStream;
2032
-struct InStream {
2033
- const char *z; /* Complete text of the input */
2034
- int i; /* Next character to read from the input */
2035
- int nLine; /* The line number for character z[i] */
2036
-};
2037
-
2038
-/*
2039
-** Each declaration in the C or C++ source files is parsed out and stored as
2040
-** an instance of the following structure.
2041
-**
2042
-** A "forward declaration" is a declaration that an object exists that
2043
-** doesn't tell about the objects structure. A typical forward declaration
2044
-** is:
2045
-**
2046
-** struct Xyzzy;
2047
-**
2048
-** Not every object has a forward declaration. If it does, thought, the
2049
-** forward declaration will be contained in the zFwd field for C and
2050
-** the zFwdCpp for C++. The zDecl field contains the complete
2051
-** declaration text.
2052
-*/
2053
-typedef struct Decl Decl;
2054
-struct Decl {
2055
- char *zName; /* Name of the object being declared. The appearance
2056
- ** of this name is a source file triggers the declaration
2057
- ** to be added to the header for that file. */
2058
- const char *zFile; /* File from which extracted. */
2059
- char *zIf; /* Surround the declaration with this #if */
2060
- char *zFwd; /* A forward declaration. NULL if there is none. */
2061
- char *zFwdCpp; /* Use this forward declaration for C++. */
2062
- char *zDecl; /* A full declaration of this object */
2063
- char *zExtra; /* Extra declaration text inserted into class objects */
2064
- int extraType; /* Last public:, protected: or private: in zExtraDecl */
2065
- struct Include *pInclude; /* #includes that come before this declaration */
2066
- int flags; /* See the "Properties" below */
2067
- Token *pComment; /* A block comment associated with this declaration */
2068
- Token tokenCode; /* Implementation of functions and procedures */
2069
- Decl *pSameName; /* Next declaration with the same "zName" */
2070
- Decl *pSameHash; /* Next declaration with same hash but different zName */
2071
- Decl *pNext; /* Next declaration with a different name */
2072
-};
2073
-
2074
-/*
2075
-** Properties associated with declarations.
2076
-**
2077
-** DP_Forward and DP_Declared are used during the generation of a single
2078
-** header file in order to prevent duplicate declarations and definitions.
2079
-** DP_Forward is set after the object has been given a forward declaration
2080
-** and DP_Declared is set after the object gets a full declarations.
2081
-** (Example: A forward declaration is "typedef struct Abc Abc;" and the
2082
-** full declaration is "struct Abc { int a; float b; };".)
2083
-**
2084
-** The DP_Export and DP_Local flags are more permanent. They mark objects
2085
-** that have EXPORT scope and LOCAL scope respectively. If both of these
2086
-** marks are missing, then the object has library scope. The meanings of
2087
-** the scopes are as follows:
2088
-**
2089
-** LOCAL scope The object is only usable within the file in
2090
-** which it is declared.
2091
-**
2092
-** library scope The object is visible and usable within other
2093
-** files in the same project. By if the project is
2094
-** a library, then the object is not visible to users
2095
-** of the library. (i.e. the object does not appear
2096
-** in the output when using the -H option.)
2097
-**
2098
-** EXPORT scope The object is visible and usable everywhere.
2099
-**
2100
-** The DP_Flag is a temporary use flag that is used during processing to
2101
-** prevent an infinite loop. It's use is localized.
2102
-**
2103
-** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
2104
-** and are used to specify what type of declaration the object requires.
2105
-*/
2106
-#define DP_Forward 0x001 /* Has a forward declaration in this file */
2107
-#define DP_Declared 0x002 /* Has a full declaration in this file */
2108
-#define DP_Export 0x004 /* Export this declaration */
2109
-#define DP_Local 0x008 /* Declare in its home file only */
2110
-#define DP_Flag 0x010 /* Use to mark a subset of a Decl list
2111
- ** for special processing */
2112
-#define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
2113
- ** C header file */
2114
-#define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
2115
- ** Prepend nothing in a C header */
2116
-#define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
2117
- ** DP_Cplusplus is not also set. If DP_Cplusplus
2118
- ** is set or this is a C header then
2119
- ** prepend 'extern' */
2120
-
2121
-/*
2122
-** Convenience macros for dealing with declaration properties
2123
-*/
2124
-#define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
2125
-#define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
2126
-#define DeclSetProperty(D,P) (D)->flags |= (P)
2127
-#define DeclClearProperty(D,P) (D)->flags &= ~(P)
2128
-
2129
-/*
2130
-** These are state properties of the parser. Each of the values is
2131
-** distinct from the DP_ values above so that both can be used in
2132
-** the same "flags" field.
2133
-**
2134
-** Be careful not to confuse PS_Export with DP_Export or
2135
-** PS_Local with DP_Local. Their names are similar, but the meanings
2136
-** of these flags are very different.
2137
-*/
2138
-#define PS_Extern 0x000800 /* "extern" has been seen */
2139
-#define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
2140
- ** and "#endif" */
2141
-#define PS_Export2 0x002000 /* If "EXPORT" seen */
2142
-#define PS_Typedef 0x004000 /* If "typedef" has been seen */
2143
-#define PS_Static 0x008000 /* If "static" has been seen */
2144
-#define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
2145
-#define PS_Method 0x020000 /* If "::" token has been seen */
2146
-#define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
2147
-#define PS_Local2 0x080000 /* If "LOCAL" seen. */
2148
-#define PS_Public 0x100000 /* If "PUBLIC" seen. */
2149
-#define PS_Protected 0x200000 /* If "PROTECTED" seen. */
2150
-#define PS_Private 0x400000 /* If "PRIVATE" seen. */
2151
-#define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
2152
-
2153
-/*
2154
-** The following set of flags are ORed into the "flags" field of
2155
-** a Decl in order to identify what type of object is being
2156
-** declared.
2157
-*/
2158
-#define TY_Class 0x00100000
2159
-#define TY_Subroutine 0x00200000
2160
-#define TY_Macro 0x00400000
2161
-#define TY_Typedef 0x00800000
2162
-#define TY_Variable 0x01000000
2163
-#define TY_Structure 0x02000000
2164
-#define TY_Union 0x04000000
2165
-#define TY_Enumeration 0x08000000
2166
-#define TY_Defunct 0x10000000 /* Used to erase a declaration */
2167
-
2168
-/*
2169
-** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
2170
-** instances of the following structure.
2171
-*/
2172
-typedef struct Ifmacro Ifmacro;
2173
-struct Ifmacro {
2174
- int nLine; /* Line number where this macro occurs */
2175
- char *zCondition; /* Text of the condition for this macro */
2176
- Ifmacro *pNext; /* Next down in the stack */
2177
- int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
2178
-};
2179
-
2180
-/*
2181
-** When parsing a file, we need to keep track of what other files have
2182
-** be #include-ed. For each #include found, we create an instance of
2183
-** the following structure.
2184
-*/
2185
-typedef struct Include Include;
2186
-struct Include {
2187
- char *zFile; /* The name of file include. Includes "" or <> */
2188
- char *zIf; /* If not NULL, #include should be enclosed in #if */
2189
- char *zLabel; /* A unique label used to test if this #include has
2190
- * appeared already in a file or not */
2191
- Include *pNext; /* Previous include file, or NULL if this is the first */
2192
-};
2193
-
2194
-/*
2195
-** Identifiers found in a source file that might be used later to provoke
2196
-** the copying of a declaration into the corresponding header file are
2197
-** stored in a hash table as instances of the following structure.
2198
-*/
2199
-typedef struct Ident Ident;
2200
-struct Ident {
2201
- char *zName; /* The text of this identifier */
2202
- Ident *pCollide; /* Next identifier with the same hash */
2203
- Ident *pNext; /* Next identifier in a list of them all */
2204
-};
2205
-
2206
-/*
2207
-** A complete table of identifiers is stored in an instance of
2208
-** the next structure.
2209
-*/
2210
-#define IDENT_HASH_SIZE 2237
2211
-typedef struct IdentTable IdentTable;
2212
-struct IdentTable {
2213
- Ident *pList; /* List of all identifiers in this table */
2214
- Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
2215
-};
2216
-
2217
-/*
2218
-** The following structure holds all information for a single
2219
-** source file named on the command line of this program.
2220
-*/
2221
-typedef struct InFile InFile;
2222
-struct InFile {
2223
- char *zSrc; /* Name of input file */
2224
- char *zHdr; /* Name of the generated .h file for this input.
2225
- ** Will be NULL if input is to be scanned only */
2226
- int flags; /* One or more DP_, PS_ and/or TY_ flags */
2227
- InFile *pNext; /* Next input file in the list of them all */
2228
- IdentTable idTable; /* All identifiers in this input file */
2229
-};
2230
-
2231
-/*
2232
-** An unbounded string is able to grow without limit. We use these
2233
-** to construct large in-memory strings from lots of smaller components.
2234
-*/
2235
-typedef struct String String;
2236
-struct String {
2237
- int nAlloc; /* Number of bytes allocated */
2238
- int nUsed; /* Number of bytes used (not counting nul terminator) */
2239
- char *zText; /* Text of the string */
2240
-};
2241
-
2242
-/*
2243
-** The following structure contains a lot of state information used
2244
-** while generating a .h file. We put the information in this structure
2245
-** and pass around a pointer to this structure, rather than pass around
2246
-** all of the information separately. This helps reduce the number of
2247
-** arguments to generator functions.
2248
-*/
2249
-typedef struct GenState GenState;
2250
-struct GenState {
2251
- String *pStr; /* Write output to this string */
2252
- IdentTable *pTable; /* A table holding the zLabel of every #include that
2253
- * has already been generated. Used to avoid
2254
- * generating duplicate #includes. */
2255
- const char *zIf; /* If not NULL, then we are within a #if with
2256
- * this argument. */
2257
- int nErr; /* Number of errors */
2258
- const char *zFilename; /* Name of the source file being scanned */
2259
- int flags; /* Various flags (DP_ and PS_ flags above) */
2260
-};
2261
-
2262
-/*
2263
-** The following text line appears at the top of every file generated
2264
-** by this program. By recognizing this line, the program can be sure
2265
-** never to read a file that it generated itself.
2266
-**
2267
-** The "#undef INTERFACE" part is a hack to work around a name collision
2268
-** in MSVC 2008.
2269
-*/
2270
-const char zTopLine[] =
2271
- "/* \aThis file was automatically generated. Do not edit! */\n"
2272
- "#undef INTERFACE\n";
2273
-#define nTopLine (sizeof(zTopLine)-1)
2274
-
2275
-/*
2276
-** The name of the file currently being parsed.
2277
-*/
2278
-static const char *zFilename;
2279
-
2280
-/*
2281
-** The stack of #if macros for the file currently being parsed.
2282
-*/
2283
-static Ifmacro *ifStack = 0;
2284
-
2285
-/*
2286
-** A list of all files that have been #included so far in a file being
2287
-** parsed.
2288
-*/
2289
-static Include *includeList = 0;
2290
-
2291
-/*
2292
-** The last block comment seen.
2293
-*/
2294
-static Token *blockComment = 0;
2295
-
2296
-/*
2297
-** The following flag is set if the -doc flag appears on the
2298
-** command line.
2299
-*/
2300
-static int doc_flag = 0;
2301
-
2302
-/*
2303
-** If the following flag is set, then makeheaders will attempt to
2304
-** generate prototypes for static functions and procedures.
2305
-*/
2306
-static int proto_static = 0;
2307
-
2308
-/*
2309
-** A list of all declarations. The list is held together using the
2310
-** pNext field of the Decl structure.
2311
-*/
2312
-static Decl *pDeclFirst; /* First on the list */
2313
-static Decl *pDeclLast; /* Last on the list */
2314
-
2315
-/*
2316
-** A hash table of all declarations
2317
-*/
2318
-#define DECL_HASH_SIZE 3371
2319
-static Decl *apTable[DECL_HASH_SIZE];
2320
-
2321
-/*
2322
-** The TEST macro must be defined to something. Make sure this is the
2323
-** case.
2324
-*/
2325
-#ifndef TEST
2326
-# define TEST 0
2327
-#endif
2328
-
2329
-#ifdef NOT_USED
2330
-/*
2331
-** We do our own assertion macro so that we can have more control
2332
-** over debugging.
2333
-*/
2334
-#define Assert(X) if(!(X)){ CantHappen(__LINE__); }
2335
-#define CANT_HAPPEN CantHappen(__LINE__)
2336
-static void CantHappen(int iLine){
2337
- fprintf(stderr,"Assertion failed on line %d\n",iLine);
2338
- *(char*)1 = 0; /* Force a core-dump */
2339
-}
2340
-#endif
2341
-
2342
-/*
2343
-** Memory allocation functions that are guaranteed never to return NULL.
2344
-*/
2345
-static void *SafeMalloc(int nByte){
2346
- void *p = malloc( nByte );
2347
- if( p==0 ){
2348
- fprintf(stderr,"Out of memory. Can't allocate %d bytes.\n",nByte);
2349
- exit(1);
2350
- }
2351
- return p;
2352
-}
2353
-static void SafeFree(void *pOld){
2354
- if( pOld ){
2355
- free(pOld);
2356
- }
2357
-}
2358
-static void *SafeRealloc(void *pOld, int nByte){
2359
- void *p;
2360
- if( pOld==0 ){
2361
- p = SafeMalloc(nByte);
2362
- }else{
2363
- p = realloc(pOld, nByte);
2364
- if( p==0 ){
2365
- fprintf(stderr,
2366
- "Out of memory. Can't enlarge an allocation to %d bytes\n",nByte);
2367
- exit(1);
2368
- }
2369
- }
2370
- return p;
2371
-}
2372
-static char *StrDup(const char *zSrc, int nByte){
2373
- char *zDest;
2374
- if( nByte<=0 ){
2375
- nByte = strlen(zSrc);
2376
- }
2377
- zDest = SafeMalloc( nByte + 1 );
2378
- strncpy(zDest,zSrc,nByte);
2379
- zDest[nByte] = 0;
2380
- return zDest;
2381
-}
2382
-
2383
-/*
2384
-** Return TRUE if the character X can be part of an identifier
2385
-*/
2386
-#define ISALNUM(X) ((X)=='_' || isalnum(X))
2387
-
2388
-/*
2389
-** Routines for dealing with unbounded strings.
2390
-*/
2391
-static void StringInit(String *pStr){
2392
- pStr->nAlloc = 0;
2393
- pStr->nUsed = 0;
2394
- pStr->zText = 0;
2395
-}
2396
-static void StringReset(String *pStr){
2397
- SafeFree(pStr->zText);
2398
- StringInit(pStr);
2399
-}
2400
-static void StringAppend(String *pStr, const char *zText, int nByte){
2401
- if( nByte<=0 ){
2402
- nByte = strlen(zText);
2403
- }
2404
- if( pStr->nUsed + nByte >= pStr->nAlloc ){
2405
- if( pStr->nAlloc==0 ){
2406
- pStr->nAlloc = nByte + 100;
2407
- pStr->zText = SafeMalloc( pStr->nAlloc );
2408
- }else{
2409
- pStr->nAlloc = pStr->nAlloc*2 + nByte;
2410
- pStr->zText = SafeRealloc(pStr->zText, pStr->nAlloc);
2411
- }
2412
- }
2413
- strncpy(&pStr->zText[pStr->nUsed],zText,nByte);
2414
- pStr->nUsed += nByte;
2415
- pStr->zText[pStr->nUsed] = 0;
2416
-}
2417
-#define StringGet(S) ((S)->zText?(S)->zText:"")
2418
-
2419
-/*
2420
-** Compute a hash on a string. The number returned is a non-negative
2421
-** value between 0 and 2**31 - 1
2422
-*/
2423
-static int Hash(const char *z, int n){
2424
- int h = 0;
2425
- if( n<=0 ){
2426
- n = strlen(z);
2427
- }
2428
- while( n-- ){
2429
- h = h ^ (h & 0x7fffffff; free software; are; you can redistribute it and/or
2430
-** modify it under the terms of the Simplified BSD License (also
2431
-** known as the "2-Clause License" or "FreeBSD License".)
2432
-**
2433
-** Copyright 1993 D. Richard Hipp. All rights reserved.
2434
-**
2435
-** Redistribution and use in source and binary forms, with or
2436
-** without modification, are permitted provided that the following
2437
-** conditions are met:
2438
-**
2439
-** 1. Redistributions of source code must retain the above copyright
2440
-** notice, this list of conditions and the following disclaimer.
2441
-**
2442
-** 2. Redistributions in binary form must reproduce the above copyright
2443
-** notice, thisprintf(pDecl/*
2444
-** This program is free software; you can redistribute it and/or
2445
-** modify it under the terms of the Simplified BSD License (also
2446
-** known as the "2-Clause License" or "FreeBSD License".)
2447
-**
2448
-** Copyright 1993 D. Richard Hipp. All rights reserved.
2449
-**
2450
-** Redistribution and use in source and binary forms, with or
2451
-** without modification, are permitted provided that the following
2452
-** conditions are met:
2453
-**
2454
-** 1. Redistributions of source code must retain the above copyright
2455
-** notice, this list of conditions and the following disclaimer.
2456
-**
2457
-** 2. Redistributions in binary form must reproduce the above copyright
2458
-** notice, this list of conditions and the following disclaimer in
2459
-** the documentation and/or other materials provided with the
2460
-** distribution.
2461
-**
2462
-** This software is provided "as is" and any express or implied warranties,
2463
-** including, but not limited to, the implied warranties of merchantability
2464
-** and fitness for a particular purpose are disclaimed. In no event shall
2465
-** the author or contributors be liable for any direct, indirect, incidental,
2466
-** special, exemplary, or consequential damages (including, but not limited
2467
-** to, procurement of substitute goods or services; loss of use, data or
2468
-** profits; or business interruption) however caused and on any theory of
2469
-** liability, whether in contract, strict liability, or tort (including
2470
-** negligence or otherwise) arising in any way out of the use of this
2471
-** software, even if advised of the possibility of such damage.
2472
-**
2473
-** This program is distributed in the hope that it will be useful,
2474
-** but without any warranty; without even the implied warranty of
2475
-** merchantability or fitness for a particular purpose.
2476
-*/
2477
-#include <stdio.h>
2478
-#include <stdlib.h>
2479
-#include <ctype.h>
2480
-#include <memory.h>
2481
-#include <sys/stat.h>
2482
-#include <assert.h>
2483
-#include <string.h>
2484
-
2485
-#if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
2486
-# ifndef WIN32
2487
-# define WIN32
2488
-# endif
2489
-#else
2490
-# include <unistd.h>
2491
-#endif
2492
-
2493
-/*
2494
-** Macros for debugging.
2495
-*/
2496
-#ifdef DEBUG
2497
-static int debugMask = 0;
2498
-# define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
2499
-# define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
2500
-# define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
2501
-# define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
2502
-# define PARSER 0x00000001
2503
-# define DECL_DUMP 0x00000002
2504
-# define TOKENIZER 0x00000004
2505
-#else
2506
-# define debug0(Flags, Format)
2507
-# define debug1(Flags, Format, A)
2508
-# define debug2(Flags, Format, A, B)
2509
-# define debug3(Flags, Format, A, B, C)
2510
-#endif
2511
-
2512
-/*
2513
-** The following macros are purely for the purpose of testing this
2514
-** program on itself. They don't really contribute to the code.
2515
-*/
2516
-#define INTERFACE 1
2517
-#define EXPORT_INTERFACE 1
2518
-#define EXPORT
2519
-
2520
-/*
2521
-** Each token in a source file is represented by an instance of
2522
-** the following structure. Tokens are collected onto a list.
2523
-*/
2524
-typedef struct Token Token;
2525
-struct Token {
2526
- const char *zText; /* The text of the token */
2527
- int nText; /* Number of characters in the token's text */
2528
- int eType; /* The type of this token */
2529
- int nLine; /* The line number on which the token starts */
2530
- Token *pComment; /* Most recent block comment before this token */
2531
- Token *pNext; /* Next token on the list */
2532
- Token *pPrev; /* Previous token on the list */
2533
-};
2534
-
2535
-/*
2536
-** During tokenization, information about the state of the input
2537
-** stream is held in an instance of the following structure
2538
-*/
2539
-typedef struct InStream InStream;
2540
-struct InStream {
2541
- const char *z; /* Complete text of the input */
2542
- int i; /* Next character to read from the input */
2543
- int nLine; /* The line number for character z[i] */
2544
-};
2545
-
2546
-/*
2547
-** Each declaration in the C or C++ source files is parsed out and stored as
2548
-** an instance of the following structure.
2549
-**
2550
-** A "forward declaration" is a declaration that an object exists that
2551
-** doesn't tell about the objects structure. A typical forward declaration
2552
-** is:
2553
-**
2554
-** struct Xyzzy;
2555
-**
2556
-** Not every object has a forward declaration. If it does, thought, the
2557
-** forward declaration will be contained in the zFwd field for C and
2558
-** the zFwdCpp for C++. The zDecl field contains the complete
2559
-** declaration text.
2560
-*/
2561
-typedef struct Decl Decl;
2562
-struct Decl {
2563
- char *zName; /* Name of the object being declared. The appearance
2564
- ** of this name is a source file triggers the declaration
2565
- ** to be added to the header for that file. */
2566
- const char *zFile; /* File from which extracted. */
2567
- char *zIf; /* Surround the declaration with this #if */
2568
- char *zFwd; /* A forward declaration. NULL if there is none. */
2569
- char *zFwdCpp; /* Use this forward declaration for C++. */
2570
- char *zDecl; /* A full declaration of this object */
2571
- char *zExtra; /* Extra declaration text inserted into class objects */
2572
- int extraType; /* Last public:, protected: or private: in zExtraDecl */
2573
- struct Include *pInclude; /* #includes that come before this declaration */
2574
- int flags; /* See the "Properties" below */
2575
- Token *pComment; /* A block comment associated with this declaration */
2576
- Token tokenCode; /* Implementation of functions and procedures */
2577
- Decl *pSameName; /* Next declaration with the same "zName" */
2578
- Decl *pSameHash; /* Next declaration with same hash but different zName */
2579
- Decl *pNext; /* Next declaration with a different name */
2580
-};
2581
-
2582
-/*
2583
-** Properties associated with declarations.
2584
-**
2585
-** DP_Forward and DP_Declared are used during the generation of a single
2586
-** header file in order to prevent duplicate declarations and definitions.
2587
-** DP_Forward is set after the object has been given a forward declaration
2588
-** and DP_Declared is set after the object gets a full declarations.
2589
-** (Example: A forward declaration is "typedef struct Abc Abc;" and the
2590
-** full declaration is "struct Abc { int a; float b; };".)
2591
-**
2592
-** The DP_Export and DP_Local flags are more permanent. They mark objects
2593
-** that have EXPORT scope and LOCAL scope respectively. If both of these
2594
-** marks are missing, then the object has library scope. The meanings of
2595
-** the scopes are as follows:
2596
-**
2597
-** LOCAL scope The object is only usable within the file in
2598
-** which it is declared.
2599
-**
2600
-** library scope The object is visible and usable within other
2601
-** files in the same project. By if the project is
2602
-** a library, then the object is not visible to users
2603
-** of the library. (i.e. the object does not appear
2604
-** in the output when using the -H option.)
2605
-**
2606
-** EXPORT scope The object is visible and usable everywhere.
2607
-**
2608
-** The DP_Flag is a temporary use flag that is used during processing to
2609
-** prevent an infinite loop. It's use is localized.
2610
-**
2611
-** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
2612
-** and are used to specify what type of declaration the object requires.
2613
-*/
2614
-#define DP_Forward 0x001 /* Has a forward declaration in this file */
2615
-#define DP_Declared 0x002 /* Has a full declaration in this file */
2616
-#define DP_Export 0x004 /* Export this declaration */
2617
-#define DP_Local 0x008 /* Declare in its home file only */
2618
-#define DP_Flag 0x010 /* Use to mark a subset of a Decl list
2619
- ** for special processing */
2620
-#define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
2621
- ** C header file */
2622
-#define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
2623
- ** Prepend nothing in a C header */
2624
-#define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
2625
- ** DP_Cplusplus is not also set. If DP_Cplusplus
2626
- ** is set or this is a C header then
2627
- ** prepend 'extern' */
2628
-
2629
-/*
2630
-** Convenience macros for dealing with declaration properties
2631
-*/
2632
-#define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
2633
-#define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
2634
-#define DeclSetProperty(D,P) (D)->flags |= (P)
2635
-#define DeclClearProperty(D,P) (D)->flags &= ~(P)
2636
-
2637
-/*
2638
-** These are state properties of the parser. Each of the values is
2639
-** distinct from the DP_ values above so that both can be used in
2640
-** the same "flags" field.
2641
-**
2642
-** Be careful not to confuse PS_Export with DP_Export or
2643
-** PS_Local with DP_Local. Their names are similar, but the meanings
2644
-** of these flags are very different.
2645
-*/
2646
-#define PS_Extern 0x000800 /* "extern" has been seen */
2647
-#define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
2648
- ** and "#endif" */
2649
-#define PS_Export2 0x002000 /* If "EXPORT" seen */
2650
-#define PS_Typedef 0x004000 /* If "typedef" has been seen */
2651
-#define PS_Static 0x008000 /* If "static" has been seen */
2652
-#define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
2653
-#define PS_Method 0x020000 /* If "::" token has been seen */
2654
-#define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
2655
-#define PS_Local2 0x080000 /* If "LOCAL" seen. */
2656
-#define PS_Public 0x100000 /* If "PUBLIC" seen. */
2657
-#define PS_Protected 0x200000 /* If "PROTECTED" seen. */
2658
-#define PS_Private 0x400000 /* If "PRIVATE" seen. */
2659
-#define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
2660
-
2661
-/*
2662
-** The following set of flags are ORed into the "flags" field of
2663
-** a Decl in order to identify what type of object is being
2664
-** declared.
2665
-*/
2666
-#define TY_Class 0x00100000
2667
-#define TY_Subroutine 0x00200000
2668
-#define TY_Macro 0x00400000
2669
-#define TY_Typedef 0x00800000
2670
-#define TY_Variable 0x01000000
2671
-#define TY_Structure 0x02000000
2672
-#define TY_Union 0x04000000
2673
-#define TY_Enumeration 0x08000000
2674
-#define TY_Defunct 0x10000000 /* Used to erase a declaration */
2675
-
2676
-/*
2677
-** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
2678
-** instances of the following structure.
2679
-*/
2680
-typedef struct Ifmacro Ifmacro;
2681
-struct Ifmacro {
2682
- int nLine; /* Line number where this macro occurs */
2683
- char *zCondition; /* Text of the condition for this macro */
2684
- Ifmacro *pNext; /* Next down in the stack */
2685
- int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
2686
-};
2687
-
2688
-/*
2689
-** When parsing a file, we need to keep track of what other files have
2690
-** be #include-ed. For each #include found, we create an instance of
2691
-** the following structure.
2692
-*/
2693
-typedef struct Include Include;
2694
-struct Include {
2695
- char *zFile; /* The name of file include. Includes "" or <> */
2696
- char *zIf; /* If not NULL, #include should be enclosed in #if */
2697
- char *zLabel; /* A unique label used to test if this #include has
2698
- * appeared already in a file or not */
2699
- Include *pNext; /* Previous include file, or NULL if this is the first */
2700
-};
2701
-
2702
-/*
2703
-** Identifiers found in a source file that might be used later to provoke
2704
-** the copying of a declaration into the corresponding header file are
2705
-** stored in a hash table as instances of the following structure.
2706
-*/
2707
-typedef struct Ident Ident;
2708
-struct Ident {
2709
- char *zName; /* The text of this identifier */
2710
- Ident *pCollide; /* Next identifier with the same hash */
2711
- Ident *pNext; /* Next identifier in a list of them all */
2712
-};
2713
-
2714
-/*
2715
-** A complete table of identifiers is stored in an instance of
2716
-** the next structure.
2717
-*/
2718
-#define IDENT_HASH_SIZE 2237
2719
-typedef struct IdentTable IdentTable;
2720
-struct IdentTable {
2721
- Ident *pList; /* List of all identifiers in this table */
2722
- Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
2723
-};
2724
-
2725
-/*
2726
-** The following structure holds all information for a single
2727
-** source file named on the command line of this program.
2728
-*/
2729
-typedef struct InFile InFile;
2730
-struct InFile {
2731
- char *zSrc; /* Name of input file */
2732
- char *zHdr; /* Name of the generated .h file for this input.
2733
- ** Will be NULL if input is to be scanned only */
2734
- int flags; /* One or more DP_, PS_ and/or TY_ flags */
2735
- InFile *pNext; /* Next input file in the list of them all */
2736
- IdentTable idTable; /* All identifiers in this input file */
2737
-};
2738
-
2739
-/*
2740
-** An unbounded string is able to grow without limit. We use these
2741
-** to construct large in-memory strings from lots of smaller components.
2742
-*/
2743
-typedef struct String String;
2744
-struct String {
2745
- int nAlloc; /* Number of bytes allocated */
2746
- int nUsed; /* Number of bytes used (not counting nul terminator) */
2747
- char *zText; /* Text of the string */
2748
-};
2749
-
2750
-/*
2751
-** The following structure contains a lot of state information used
2752
-** while generating a .h file. We put the information in this structure
2753
-** and pass around a pointer to this structure, rather than pass around
2754
-** all of the information separately. This helps reduce the number of
2755
-** arguments to generator functions.
2756
-*/
2757
-typedef struct GenState GenState;
2758
-struct GenState {
2759
- String *pStr; /* Write output to this string */
2760
- IdentTable *pTable; /* A table holding the zLabel of every #include that
2761
- * has already been generated. Used to avoid
2762
-
--- a/src/makeheaders.c
+++ b/src/makeheaders.c
@@ -1,2762 +0,0 @@
1 /*
2 ** This program is free software; you can redistribute it and/or
3 ** modify it under the terms of the Simplified BSD License (also
4 ** known as the "2-Clause License" or "FreeBSD License".)
5 **
6 ** Copyright 1993 D. Richard Hipp. All rights reserved.
7 **
8 ** Redistribution and use in source and binary forms, with or
9 ** without modification, are permitted provided that the following
10 ** conditions are met:
11 **
12 ** 1. Redistributions of source code must retain the above copyright
13 ** notice, this list of conditions and the following disclaimer.
14 **
15 ** 2. Redistributions in binary form must reproduce the above copyright
16 ** notice, this list of conditions and the following disclaimer in
17 ** the documentation and/or other materials provided with the
18 ** distribution.
19 **
20 ** This software is provided "as is" and any express or implied warranties,
21 ** including, but not limited to, the implied warranties of merchantability
22 ** and fitness for a particular purpose are disclaimed. In no event shall
23 ** the author or contributors be liable for any direct, indirect, incidental,
24 ** special, exemplary, or consequential damages (including, but not limited
25 ** to, procurement of substitute goods or services; loss of use, data or
26 ** profits; or business interruption) however caused and on any theory of
27 ** liability, whether in contract, strict liability, or tort (including
28 ** negligence or otherwise) arising in any way out of the use of this
29 ** software, even if advised of the possibility of such damage.
30 **
31 ** This program is distributed in the hope that it will be useful,
32 ** but without any warranty; without even the implied warranty of
33 ** merchantability or fitness for a particular purpose.
34 */
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <ctype.h>
38 #include <memory.h>
39 #include <sys/stat.h>
40 #include <assert.h>
41 #include <string.h>
42
43 #if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
44 # ifndef WIN32
45 # define WIN32
46 # endif
47 #else
48 # include <unistd.h>
49 #endif
50
51 /*
52 ** Macros for debugging.
53 */
54 #ifdef DEBUG
55 static int debugMask = 0;
56 # define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
57 # define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
58 # define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
59 # define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
60 # define PARSER 0x00000001
61 # define DECL_DUMP 0x00000002
62 # define TOKENIZER 0x00000004
63 #else
64 # define debug0(Flags, Format)
65 # define debug1(Flags, Format, A)
66 # define debug2(Flags, Format, A, B)
67 # define debug3(Flags, Format, A, B, C)
68 #endif
69
70 /*
71 ** The following macros are purely for the purpose of testing this
72 ** program on itself. They don't really contribute to the code.
73 */
74 #define INTERFACE 1
75 #define EXPORT_INTERFACE 1
76 #define EXPORT
77
78 /*
79 ** Each token in a source file is represented by an instance of
80 ** the following structure. Tokens are collected onto a list.
81 */
82 typedef struct Token Token;
83 struct Token {
84 const char *zText; /* The text of the token */
85 int nText; /* Number of characters in the token's text */
86 int eType; /* The type of this token */
87 int nLine; /* The line number on which the token starts */
88 Token *pComment; /* Most recent block comment before this token */
89 Token *pNext; /* Next token on the list */
90 Token *pPrev; /* Previous token on the list */
91 };
92
93 /*
94 ** During tokenization, information about the state of the input
95 ** stream is held in an instance of the following structure
96 */
97 typedef struct InStream InStream;
98 struct InStream {
99 const char *z; /* Complete text of the input */
100 int i; /* Next character to read from the input */
101 int nLine; /* The line number for character z[i] */
102 };
103
104 /*
105 ** Each declaration in the C or C++ source files is parsed out and stored as
106 ** an instance of the following structure.
107 **
108 ** A "forward declaration" is a declaration that an object exists that
109 ** doesn't tell about the objects structure. A typical forward declaration
110 ** is:
111 **
112 ** struct Xyzzy;
113 **
114 ** Not every object has a forward declaration. If it does, thought, the
115 ** forward declaration will be contained in the zFwd field for C and
116 ** the zFwdCpp for C++. The zDecl field contains the complete
117 ** declaration text.
118 */
119 typedef struct Decl Decl;
120 struct Decl {
121 char *zName; /* Name of the object being declared. The appearance
122 ** of this name is a source file triggers the declaration
123 ** to be added to the header for that file. */
124 const char *zFile; /* File from which extracted. */
125 char *zIf; /* Surround the declaration with this #if */
126 char *zFwd; /* A forward declaration. NULL if there is none. */
127 char *zFwdCpp; /* Use this forward declaration for C++. */
128 char *zDecl; /* A full declaration of this object */
129 char *zExtra; /* Extra declaration text inserted into class objects */
130 int extraType; /* Last public:, protected: or private: in zExtraDecl */
131 struct Include *pInclude; /* #includes that come before this declaration */
132 int flags; /* See the "Properties" below */
133 Token *pComment; /* A block comment associated with this declaration */
134 Token tokenCode; /* Implementation of functions and procedures */
135 Decl *pSameName; /* Next declaration with the same "zName" */
136 Decl *pSameHash; /* Next declaration with same hash but different zName */
137 Decl *pNext; /* Next declaration with a different name */
138 };
139
140 /*
141 ** Properties associated with declarations.
142 **
143 ** DP_Forward and DP_Declared are used during the generation of a single
144 ** header file in order to prevent duplicate declarations and definitions.
145 ** DP_Forward is set after the object has been given a forward declaration
146 ** and DP_Declared is set after the object gets a full declarations.
147 ** (Example: A forward declaration is "typedef struct Abc Abc;" and the
148 ** full declaration is "struct Abc { int a; float b; };".)
149 **
150 ** The DP_Export and DP_Local flags are more permanent. They mark objects
151 ** that have EXPORT scope and LOCAL scope respectively. If both of these
152 ** marks are missing, then the object has library scope. The meanings of
153 ** the scopes are as follows:
154 **
155 ** LOCAL scope The object is only usable within the file in
156 ** which it is declared.
157 **
158 ** library scope The object is visible and usable within other
159 ** files in the same project. By if the project is
160 ** a library, then the object is not visible to users
161 ** of the library. (i.e. the object does not appear
162 ** in the output when using the -H option.)
163 **
164 ** EXPORT scope The object is visible and usable everywhere.
165 **
166 ** The DP_Flag is a temporary use flag that is used during processing to
167 ** prevent an infinite loop. It's use is localized.
168 **
169 ** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
170 ** and are used to specify what type of declaration the object requires.
171 */
172 #define DP_Forward 0x001 /* Has a forward declaration in this file */
173 #define DP_Declared 0x002 /* Has a full declaration in this file */
174 #define DP_Export 0x004 /* Export this declaration */
175 #define DP_Local 0x008 /* Declare in its home file only */
176 #define DP_Flag 0x010 /* Use to mark a subset of a Decl list
177 ** for special processing */
178 #define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
179 ** C header file */
180 #define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
181 ** Prepend nothing in a C header */
182 #define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
183 ** DP_Cplusplus is not also set. If DP_Cplusplus
184 ** is set or this is a C header then
185 ** prepend 'extern' */
186
187 /*
188 ** Convenience macros for dealing with declaration properties
189 */
190 #define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
191 #define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
192 #define DeclSetProperty(D,P) (D)->flags |= (P)
193 #define DeclClearProperty(D,P) (D)->flags &= ~(P)
194
195 /*
196 ** These are state properties of the parser. Each of the values is
197 ** distinct from the DP_ values above so that both can be used in
198 ** the same "flags" field.
199 **
200 ** Be careful not to confuse PS_Export with DP_Export or
201 ** PS_Local with DP_Local. Their names are similar, but the meanings
202 ** of these flags are very different.
203 */
204 #define PS_Extern 0x000800 /* "extern" has been seen */
205 #define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
206 ** and "#endif" */
207 #define PS_Export2 0x002000 /* If "EXPORT" seen */
208 #define PS_Typedef 0x004000 /* If "typedef" has been seen */
209 #define PS_Static 0x008000 /* If "static" has been seen */
210 #define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
211 #define PS_Method 0x020000 /* If "::" token has been seen */
212 #define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
213 #define PS_Local2 0x080000 /* If "LOCAL" seen. */
214 #define PS_Public 0x100000 /* If "PUBLIC" seen. */
215 #define PS_Protected 0x200000 /* If "PROTECTED" seen. */
216 #define PS_Private 0x400000 /* If "PRIVATE" seen. */
217 #define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
218
219 /*
220 ** The following set of flags are ORed into the "flags" field of
221 ** a Decl in order to identify what type of object is being
222 ** declared.
223 */
224 #define TY_Class 0x00100000
225 #define TY_Subroutine 0x00200000
226 #define TY_Macro 0x00400000
227 #define TY_Typedef 0x00800000
228 #define TY_Variable 0x01000000
229 #define TY_Structure 0x02000000
230 #define TY_Union 0x04000000
231 #define TY_Enumeration 0x08000000
232 #define TY_Defunct 0x10000000 /* Used to erase a declaration */
233
234 /*
235 ** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
236 ** instances of the following structure.
237 */
238 typedef struct Ifmacro Ifmacro;
239 struct Ifmacro {
240 int nLine; /* Line number where this macro occurs */
241 char *zCondition; /* Text of the condition for this macro */
242 Ifmacro *pNext; /* Next down in the stack */
243 int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
244 };
245
246 /*
247 ** When parsing a file, we need to keep track of what other files have
248 ** be #include-ed. For each #include found, we create an instance of
249 ** the following structure.
250 */
251 typedef struct Include Include;
252 struct Include {
253 char *zFile; /* The name of file include. Includes "" or <> */
254 char *zIf; /* If not NULL, #include should be enclosed in #if */
255 char *zLabel; /* A unique label used to test if this #include has
256 * appeared already in a file or not */
257 Include *pNext; /* Previous include file, or NULL if this is the first */
258 };
259
260 /*
261 ** Identifiers found in a source file that might be used later to provoke
262 ** the copying of a declaration into the corresponding header file are
263 ** stored in a hash table as instances of the following structure.
264 */
265 typedef struct Ident Ident;
266 struct Ident {
267 char *zName; /* The text of this identifier */
268 Ident *pCollide; /* Next identifier with the same hash */
269 Ident *pNext; /* Next identifier in a list of them all */
270 };
271
272 /*
273 ** A complete table of identifiers is stored in an instance of
274 ** the next structure.
275 */
276 #define IDENT_HASH_SIZE 2237
277 typedef struct IdentTable IdentTable;
278 struct IdentTable {
279 Ident *pList; /* List of all identifiers in this table */
280 Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
281 };
282
283 /*
284 ** The following structure holds all information for a single
285 ** source file named on the command line of this program.
286 */
287 typedef struct InFile InFile;
288 struct InFile {
289 char *zSrc; /* Name of input file */
290 char *zHdr; /* Name of the generated .h file for this input.
291 ** Will be NULL if input is to be scanned only */
292 int flags; /* One or more DP_, PS_ and/or TY_ flags */
293 InFile *pNext; /* Next input file in the list of them all */
294 IdentTable idTable; /* All identifiers in this input file */
295 };
296
297 /*
298 ** An unbounded string is able to grow without limit. We use these
299 ** to construct large in-memory strings from lots of smaller components.
300 */
301 typedef struct String String;
302 struct String {
303 int nAlloc; /* Number of bytes allocated */
304 int nUsed; /* Number of bytes used (not counting nul terminator) */
305 char *zText; /* Text of the string */
306 };
307
308 /*
309 ** The following structure contains a lot of state information used
310 ** while generating a .h file. We put the information in this structure
311 ** and pass around a pointer to this structure, rather than pass around
312 ** all of the information separately. This helps reduce the number of
313 ** arguments to generator functions.
314 */
315 typedef struct GenState GenState;
316 struct GenState {
317 String *pStr; /* Write output to this string */
318 IdentTable *pTable; /* A table holding the zLabel of every #include that
319 * has already been generated. Used to avoid
320 * generating duplicate #includes. */
321 const char *zIf; /* If not NULL, then we are within a #if with
322 * this argument. */
323 int nErr; /* Number of errors */
324 const char *zFilename; /* Name of the source file being scanned */
325 int flags; /* Various flags (DP_ and PS_ flags above) */
326 };
327
328 /*
329 ** The following text line appears at the top of every file generated
330 ** by this program. By recognizing this line, the program can be sure
331 ** never to read a file that it generated itself.
332 **
333 ** The "#undef INTERFACE" part is a hack to work around a name collision
334 ** in MSVC 2008.
335 */
336 const char zTopLine[] =
337 "/* \aThis file was automatically generated. Do not edit! */\n"
338 "#undef INTERFACE\n";
339 #define nTopLine (sizeof(zTopLine)-1)
340
341 /*
342 ** The name of the file currently being parsed.
343 */
344 static const char *zFilename;
345
346 /*
347 ** The stack of #if macros for the file currently being parsed.
348 */
349 static Ifmacro *ifStack = 0;
350
351 /*
352 ** A list of all files that have been #included so far in a file being
353 ** parsed.
354 */
355 static Include *includeList = 0;
356
357 /*
358 ** The last block comment seen.
359 */
360 static Token *blockComment = 0;
361
362 /*
363 ** The following flag is set if the -doc flag appears on the
364 ** command line.
365 */
366 static int doc_flag = 0;
367
368 /*
369 ** If the following flag is set, then makeheaders will attempt to
370 ** generate prototypes for static functions and procedures.
371 */
372 static int proto_static = 0;
373
374 /*
375 ** A list of all declarations. The list is held together using the
376 ** pNext field of the Decl structure.
377 */
378 static Decl *pDeclFirst; /* First on the list */
379 static Decl *pDeclLast; /* Last on the list */
380
381 /*
382 ** A hash table of all declarations
383 */
384 #define DECL_HASH_SIZE 3371
385 static Decl *apTable[DECL_HASH_SIZE];
386
387 /*
388 ** The TEST macro must be defined to something. Make sure this is the
389 ** case.
390 */
391 #ifndef TEST
392 # define TEST 0
393 #endif
394
395 #ifdef NOT_USED
396 /*
397 ** We do our own assertion macro so that we can have more control
398 ** over debugging.
399 */
400 #define Assert(X) if(!(X)){ CantHappen(__LINE__); }
401 #define CANT_HAPPEN CantHappen(__LINE__)
402 static void CantHappen(int iLine){
403 fprintf(stderr,"Assertion failed on line %d\n",iLine);
404 *(char*)1 = 0; /* Force a core-dump */
405 }
406 #endif
407
408 /*
409 ** Memory allocation functions that are guaranteed never to return NULL.
410 */
411 static void *SafeMalloc(int nByte){
412 void *p = malloc( nByte );
413 if( p==0 ){
414 fprintf(stderr,"Out of memory. Can't allocate %d bytes.\n",nByte);
415 exit(1);
416 }
417 return p;
418 }
419 static void SafeFree(void *pOld){
420 if( pOld ){
421 free(pOld);
422 }
423 }
424 static void *SafeRealloc(void *pOld, int nByte){
425 void *p;
426 if( pOld==0 ){
427 p = SafeMalloc(nByte);
428 }else{
429 p = realloc(pOld, nByte);
430 if( p==0 ){
431 fprintf(stderr,
432 "Out of memory. Can't enlarge an allocation to %d bytes\n",nByte);
433 exit(1);
434 }
435 }
436 return p;
437 }
438 static char *StrDup(const char *zSrc, int nByte){
439 char *zDest;
440 if( nByte<=0 ){
441 nByte = strlen(zSrc);
442 }
443 zDest = SafeMalloc( nByte + 1 );
444 strncpy(zDest,zSrc,nByte);
445 zDest[nByte] = 0;
446 return zDest;
447 }
448
449 /*
450 ** Return TRUE if the character X can be part of an identifier
451 */
452 #define ISALNUM(X) ((X)=='_' || isalnum(X))
453
454 /*
455 ** Routines for dealing with unbounded strings.
456 */
457 static void StringInit(String *pStr){
458 pStr->nAlloc = 0;
459 pStr->nUsed = 0;
460 pStr->zText = 0;
461 }
462 static void StringReset(String *pStr){
463 SafeFree(pStr->zText);
464 StringInit(pStr);
465 }
466 static void StringAppend(String *pStr, const char *zText, int nByte){
467 if( nByte<=0 ){
468 nByte = strlen(zText);
469 }
470 if( pStr->nUsed + nByte >= pStr->nAlloc ){
471 if( pStr->nAlloc==0 ){
472 pStr->nAlloc = nByte + 100;
473 pStr->zText = SafeMalloc( pStr->nAlloc );
474 }else{
475 pStr->nAlloc = pStr->nAlloc*2 + nByte;
476 pStr->zText = SafeRealloc(pStr->zText, pStr->nAlloc);
477 }
478 }
479 strncpy(&pStr->zText[pStr->nUsed],zText,nByte);
480 pStr->nUsed += nByte;
481 pStr->zText[pStr->nUsed] = 0;
482 }
483 #define StringGet(S) ((S)->zText?(S)->zText:"")
484
485 /*
486 ** Compute a hash on a string. The number returned is a non-negative
487 ** value between 0 and 2**31 - 1
488 */
489 static int Hash(const char *z, int n){
490 int h = 0;
491 if( n<=0 ){
492 n = strlen(z);
493 }
494 while( n-- ){
495 h = h ^ (h & 0x7fffffff; free software; are; you can redistribute it and/or
496 ** modify it under the terms of the Simplified BSD License (also
497 ** known as the "2-Clause License" or "FreeBSD License".)
498 **
499 ** Copyright 1993 D. Richard Hipp. All rights reserved.
500 **
501 ** Redistribution and use in source and binary forms, with or
502 ** without modification, are permitted provided that the following
503 ** conditions are met:
504 **
505 ** 1. Redistributions of source code must retain the above copyright
506 ** notice, this list of conditions and the following disclaimer.
507 **
508 ** 2. Redistributions in binary form must reproduce the above copyright
509 ** notice, thisprintf(pDecl/*
510 ** This program is free software; you can redistribute it and/or
511 ** modify it under the terms of the Simplified BSD License (also
512 ** known as the "2-Clause License" or "FreeBSD License".)
513 **
514 ** Copyright 1993 D. Richard Hipp. All rights reserved.
515 **
516 ** Redistribution and use in source and binary forms, with or
517 ** without modification, are permitted provided that the following
518 ** conditions are met:
519 **
520 ** 1. Redistributions of source code must retain the above copyright
521 ** notice, this list of conditions and the following disclaimer.
522 **
523 ** 2. Redistributions in binary form must reproduce the above copyright
524 ** notice, this list of conditions and the following disclaimer in
525 ** the documentation and/or other materials provided with the
526 ** distribution.
527 **
528 ** This software is provided "as is" and any express or implied warranties,
529 ** including, but not limited to, the implied warranties of merchantability
530 ** and fitness for a particular purpose are disclaimed. In no event shall
531 ** the author or contributors be liable for any direct, indirect, incidental,
532 ** special, exemplary, or consequential damages (including, but not limited
533 ** to, procurement of substitute goods or services; loss of use, data or
534 ** profits; or business interruption) however caused and on any theory of
535 ** liability, whether in contract, strict liability, or tort (including
536 ** negligence or otherwise) arising in any way out of the use of this
537 ** software, even if advised of the possibility of such damage.
538 **
539 ** This program is distributed in the hope that it will be useful,
540 ** but without any warranty; without even the implied warranty of
541 ** merchantability or fitness for a particular purpose.
542 */
543 #include <stdio.h>
544 #include <stdlib.h>
545 #include <ctype.h>
546 #include <memory.h>
547 #include <sys/stat.h>
548 #include <assert.h>
549 #include <string.h>
550
551 #if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
552 # ifndef WIN32
553 # define WIN32
554 # endif
555 #else
556 # include <unistd.h>
557 #endif
558
559 /*
560 ** Macros for debugging.
561 */
562 #ifdef DEBUG
563 static int debugMask = 0;
564 # define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
565 # define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
566 # define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
567 # define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
568 # define PARSER 0x00000001
569 # define DECL_DUMP 0x00000002
570 # define TOKENIZER 0x00000004
571 #else
572 # define debug0(Flags, Format)
573 # define debug1(Flags, Format, A)
574 # define debug2(Flags, Format, A, B)
575 # define debug3(Flags, Format, A, B, C)
576 #endif
577
578 /*
579 ** The following macros are purely for the purpose of testing this
580 ** program on itself. They don't really contribute to the code.
581 */
582 #define INTERFACE 1
583 #define EXPORT_INTERFACE 1
584 #define EXPORT
585
586 /*
587 ** Each token in a source file is represented by an instance of
588 ** the following structure. Tokens are collected onto a list.
589 */
590 typedef struct Token Token;
591 struct Token {
592 const char *zText; /* The text of the token */
593 int nText; /* Number of characters in the token's text */
594 int eType; /* The type of this token */
595 int nLine; /* The line number on which the token starts */
596 Token *pComment; /* Most recent block comment before this token */
597 Token *pNext; /* Next token on the list */
598 Token *pPrev; /* Previous token on the list */
599 };
600
601 /*
602 ** During tokenization, information about the state of the input
603 ** stream is held in an instance of the following structure
604 */
605 typedef struct InStream InStream;
606 struct InStream {
607 const char *z; /* Complete text of the input */
608 int i; /* Next character to read from the input */
609 int nLine; /* The line number for character z[i] */
610 };
611
612 /*
613 ** Each declaration in the C or C++ source files is parsed out and stored as
614 ** an instance of the following structure.
615 **
616 ** A "forward declaration" is a declaration that an object exists that
617 ** doesn't tell about the objects structure. A typical forward declaration
618 ** is:
619 **
620 ** struct Xyzzy;
621 **
622 ** Not every object has a forward declaration. If it does, thought, the
623 ** forward declaration will be contained in the zFwd field for C and
624 ** the zFwdCpp for C++. The zDecl field contains the complete
625 ** declaration text.
626 */
627 typedef struct Decl Decl;
628 struct Decl {
629 char *zName; /* Name of the object being declared. The appearance
630 ** of this name is a source file triggers the declaration
631 ** to be added to the header for that file. */
632 const char *zFile; /* File from which extracted. */
633 char *zIf; /* Surround the declaration with this #if */
634 char *zFwd; /* A forward declaration. NULL if there is none. */
635 char *zFwdCpp; /* Use this forward declaration for C++. */
636 char *zDecl; /* A full declaration of this object */
637 char *zExtra; /* Extra declaration text inserted into class objects */
638 int extraType; /* Last public:, protected: or private: in zExtraDecl */
639 struct Include *pInclude; /* #includes that come before this declaration */
640 int flags; /* See the "Properties" below */
641 Token *pComment; /* A block comment associated with this declaration */
642 Token tokenCode; /* Implementation of functions and procedures */
643 Decl *pSameName; /* Next declaration with the same "zName" */
644 Decl *pSameHash; /* Next declaration with same hash but different zName */
645 Decl *pNext; /* Next declaration with a different name */
646 };
647
648 /*
649 ** Properties associated with declarations.
650 **
651 ** DP_Forward and DP_Declared are used during the generation of a single
652 ** header file in order to prevent duplicate declarations and definitions.
653 ** DP_Forward is set after the object has been given a forward declaration
654 ** and DP_Declared is set after the object gets a full declarations.
655 ** (Example: A forward declaration is "typedef struct Abc Abc;" and the
656 ** full declaration is "struct Abc { int a; float b; };".)
657 **
658 ** The DP_Export and DP_Local flags are more permanent. They mark objects
659 ** that have EXPORT scope and LOCAL scope respectively. If both of these
660 ** marks are missing, then the object has library scope. The meanings of
661 ** the scopes are as follows:
662 **
663 ** LOCAL scope The object is only usable within the file in
664 ** which it is declared.
665 **
666 ** library scope The object is visible and usable within other
667 ** files in the same project. By if the project is
668 ** a library, then the object is not visible to users
669 ** of the library. (i.e. the object does not appear
670 ** in the output when using the -H option.)
671 **
672 ** EXPORT scope The object is visible and usable everywhere.
673 **
674 ** The DP_Flag is a temporary use flag that is used during processing to
675 ** prevent an infinite loop. It's use is localized.
676 **
677 ** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
678 ** and are used to specify what type of declaration the object requires.
679 */
680 #define DP_Forward 0x001 /* Has a forward declaration in this file */
681 #define DP_Declared 0x002 /* Has a full declaration in this file */
682 #define DP_Export 0x004 /* Export this declaration */
683 #define DP_Local 0x008 /* Declare in its home file only */
684 #define DP_Flag 0x010 /* Use to mark a subset of a Decl list
685 ** for special processing */
686 #define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
687 ** C header file */
688 #define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
689 ** Prepend nothing in a C header */
690 #define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
691 ** DP_Cplusplus is not also set. If DP_Cplusplus
692 ** is set or this is a C header then
693 ** prepend 'extern' */
694
695 /*
696 ** Convenience macros for dealing with declaration properties
697 */
698 #define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
699 #define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
700 #define DeclSetProperty(D,P) (D)->flags |= (P)
701 #define DeclClearProperty(D,P) (D)->flags &= ~(P)
702
703 /*
704 ** These are state properties of the parser. Each of the values is
705 ** distinct from the DP_ values above so that both can be used in
706 ** the same "flags" field.
707 **
708 ** Be careful not to confuse PS_Export with DP_Export or
709 ** PS_Local with DP_Local. Their names are similar, but the meanings
710 ** of these flags are very different.
711 */
712 #define PS_Extern 0x000800 /* "extern" has been seen */
713 #define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
714 ** and "#endif" */
715 #define PS_Export2 0x002000 /* If "EXPORT" seen */
716 #define PS_Typedef 0x004000 /* If "typedef" has been seen */
717 #define PS_Static 0x008000 /* If "static" has been seen */
718 #define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
719 #define PS_Method 0x020000 /* If "::" token has been seen */
720 #define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
721 #define PS_Local2 0x080000 /* If "LOCAL" seen. */
722 #define PS_Public 0x100000 /* If "PUBLIC" seen. */
723 #define PS_Protected 0x200000 /* If "PROTECTED" seen. */
724 #define PS_Private 0x400000 /* If "PRIVATE" seen. */
725 #define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
726
727 /*
728 ** The following set of flags are ORed into the "flags" field of
729 ** a Decl in order to identify what type of object is being
730 ** declared.
731 */
732 #define TY_Class 0x00100000
733 #define TY_Subroutine 0x00200000
734 #define TY_Macro 0x00400000
735 #define TY_Typedef 0x00800000
736 #define TY_Variable 0x01000000
737 #define TY_Structure 0x02000000
738 #define TY_Union 0x04000000
739 #define TY_Enumeration 0x08000000
740 #define TY_Defunct 0x10000000 /* Used to erase a declaration */
741
742 /*
743 ** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
744 ** instances of the following structure.
745 */
746 typedef struct Ifmacro Ifmacro;
747 struct Ifmacro {
748 int nLine; /* Line number where this macro occurs */
749 char *zCondition; /* Text of the condition for this macro */
750 Ifmacro *pNext; /* Next down in the stack */
751 int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
752 };
753
754 /*
755 ** When parsing a file, we need to keep track of what other files have
756 ** be #include-ed. For each #include found, we create an instance of
757 ** the following structure.
758 */
759 typedef struct Include Include;
760 struct Include {
761 char *zFile; /* The name of file include. Includes "" or <> */
762 char *zIf; /* If not NULL, #include should be enclosed in #if */
763 char *zLabel; /* A unique label used to test if this #include has
764 * appeared already in a file or not */
765 Include *pNext; /* Previous include file, or NULL if this is the first */
766 };
767
768 /*
769 ** Identifiers found in a source file that might be used later to provoke
770 ** the copying of a declaration into the corresponding header file are
771 ** stored in a hash table as instances of the following structure.
772 */
773 typedef struct Ident Ident;
774 struct Ident {
775 char *zName; /* The text of this identifier */
776 Ident *pCollide; /* Next identifier with the same hash */
777 Ident *pNext; /* Next identifier in a list of them all */
778 };
779
780 /*
781 ** A complete table of identifiers is stored in an instance of
782 ** the next structure.
783 */
784 #define IDENT_HASH_SIZE 2237
785 typedef struct IdentTable IdentTable;
786 struct IdentTable {
787 Ident *pList; /* List of all identifiers in this table */
788 Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
789 };
790
791 /*
792 ** The following structure holds all information for a single
793 ** source file named on the command line of this program.
794 */
795 typedef struct InFile InFile;
796 struct InFile {
797 char *zSrc; /* Name of input file */
798 char *zHdr; /* Name of the generated .h file for this input.
799 ** Will be NULL if input is to be scanned only */
800 int flags; /* One or more DP_, PS_ and/or TY_ flags */
801 InFile *pNext; /* Next input file in the list of them all */
802 IdentTable idTable; /* All identifiers in this input file */
803 };
804
805 /*
806 ** An unbounded string is able to grow without limit. We use these
807 ** to construct large in-memory strings from lots of smaller components.
808 */
809 typedef struct String String;
810 struct String {
811 int nAlloc; /* Number of bytes allocated */
812 int nUsed; /* Number of bytes used (not counting nul terminator) */
813 char *zText; /* Text of the string */
814 };
815
816 /*
817 ** The following structure contains a lot of state information used
818 ** while generating a .h file. We put the information in this structure
819 ** and pass around a pointer to this structure, rather than pass around
820 ** all of the information separately. This helps reduce the number of
821 ** arguments to generator functions.
822 */
823 typedef struct GenState GenState;
824 struct GenState {
825 String *pStr; /* Write output to this string */
826 IdentTable *pTable; /* A table holding the zLabel of every #include that
827 * has already been generated. Used to avoid
828 * generating duplicate #includes. */
829 const char *zIf; /* If not NULL, then we are within a #if with
830 * this argument. */
831 int nErr; /* Number of errors */
832 const char *zFilename; /* Name of the source file being scanned */
833 int flags; /* Various flags (DP_ and PS_ flags above) */
834 };
835
836 /*
837 ** The following text line appears at the top of every file generated
838 ** by this program. By recognizing this line, the program can be sure
839 ** never to read a file that it generated itself.
840 **
841 ** The "#undef INTERFACE" part is a hack to work around a name collision
842 ** in MSVC 2008.
843 */
844 const char zTopLine[] =
845 "/* \aThis file was automatically generated. Do not edit! */\n"
846 "#undef INTERFACE\n";
847 #define nTopLine (sizeof(zTopLine)-1)
848
849 /*
850 ** The name of the file currently being parsed.
851 */
852 static const char *zFilename;
853
854 /*
855 ** The stack of #if macros for the file currently being parsed.
856 */
857 static Ifmacro *ifStack = 0;
858
859 /*
860 ** A list of all files that have been #included so far in a file being
861 ** parsed.
862 */
863 static Include *includeList = 0;
864
865 /*
866 ** The last block comment seen.
867 */
868 static Token *blockComment = 0;
869
870 /*
871 ** The following flag is set if the -doc flag appears on the
872 ** command line.
873 */
874 static int doc_flag = 0;
875
876 /*
877 ** If the following flag is set, then makeheaders will attempt to
878 ** generate prototypes for static functions and procedures.
879 */
880 static int proto_static = 0;
881
882 /*
883 ** A list of all declarations. The list is held together using the
884 ** pNext field of the Decl structure.
885 */
886 static Decl *pDeclFirst; /* First on the list */
887 static Decl *pDeclLast; /* Last on the list */
888
889 /*
890 ** A hash table of all declarations
891 */
892 #define DECL_HASH_SIZE 3371
893 static Decl *apTable[DECL_HASH_SIZE];
894
895 /*
896 ** The TEST macro must be defined to something. Make sure this is the
897 ** case.
898 */
899 #ifndef TEST
900 # define TEST 0
901 #endif
902
903 #ifdef NOT_USED
904 /*
905 ** We do our own assertion macro so that we can have more control
906 ** over debugging.
907 */
908 #define Assert(X) if(!(X)){ CantHappen(__LINE__); }
909 #define CANT_HAPPEN CantHappen(__LINE__)
910 static void CantHappen(int iLine){
911 fprintf(stderr,"Assertion failed on line %d\n",iLine);
912 *(char*)1 = 0; /* Force a core-dump */
913 }
914 #endif
915
916 /*
917 ** Memory allocation functions that are guaranteed never to return NULL.
918 */
919 static void *SafeMalloc(int nByte){
920 void *p = malloc( nByte );
921 if( p==0 ){
922 fprintf(stderr,"Out of memory. Can't allocate %d bytes.\n",nByte);
923 exit(1);
924 }
925 return p;
926 }
927 static void SafeFree(void *pOld){
928 if( pOld ){
929 free(pOld);
930 }
931 }
932 static void *SafeRealloc(void *pOld, int nByte){
933 void *p;
934 if( pOld==0 ){
935 p = SafeMalloc(nByte);
936 }else{
937 p = realloc(pOld, nByte);
938 if( p==0 ){
939 fprintf(stderr,
940 "Out of memory. Can't enlarge an allocation to %d bytes\n",nByte);
941 exit(1);
942 }
943 }
944 return p;
945 }
946 static char *StrDup(const char *zSrc, int nByte){
947 char *zDest;
948 if( nByte<=0 ){
949 nByte = strlen(zSrc);
950 }
951 zDest = SafeMalloc( nByte + 1 );
952 strncpy(zDest,zSrc,nByte);
953 zDest[nByte] = 0;
954 return zDest;
955 }
956
957 /*
958 ** Return TRUE if the character X can be part of an identifier
959 */
960 #define ISALNUM(X) ((X)=='_' || isalnum(X))
961
962 /*
963 ** Routines for dealing with unbounded strings.
964 */
965 static void StringInit(String *pStr){
966 pStr->nAlloc = 0;
967 pStr->nUsed = 0;
968 pStr->zText = 0;
969 }
970 static void StringReset(String *pStr){
971 SafeFree(pStr->zText);
972 StringInit(pStr);
973 }
974 static void StringAppend(String *pStr, const char *zText, int nByte){
975 if( nByte<=0 ){
976 nByte = strlen(zText);
977 }
978 if( pStr->nUsed + nByte >= pStr->nAlloc ){
979 if( pStr->nAlloc==0 ){
980 pStr->nAlloc = nByte + 100;
981 pStr->zText = SafeMalloc( pStr->nAlloc );
982 }else{
983 pStr->nAlloc = pStr->nAlloc*2 + nByte;
984 pStr->zText = SafeRealloc(pStr->zText, pStr->nAlloc);
985 }
986 }
987 strncpy(&pStr->zText[pStr->nUsed],zText,nByte);
988 pStr->nUsed += nByte;
989 pStr->zText[pStr->nUsed] = 0;
990 }
991 #define StringGet(S) ((S)->zText?(S)->zText:"")
992
993 /*
994 ** Compute a hash on a string. The number returned is a non-negative
995 ** value between 0 and 2**31 - 1
996 */
997 static int Hash(const char *z, int n){
998 int h = 0;
999 if( n<=0 ){
1000 n = strlen(z);
1001 }
1002 while( n-- ){
1003 h = h ^ (h & 0x7fffffff; free software; are; you can redistribute it and/or
1004 ** modify it under the terms of the Simplified BSD License (also
1005 ** known as the "2-Clause License" or "FreeBSD License".)
1006 **
1007 ** Copyright 1993 D. Richard Hipp. All rights reserved.
1008 **
1009 ** Redistribution and use in source and binary forms, with or
1010 ** without modification, are permitted provided that the following
1011 ** conditions are met:
1012 **
1013 ** 1. Redistributions of source code must retain the above copyright
1014 ** notice, this list of conditions and the following disclaimer.
1015 **
1016 ** 2. Redistributions in binary form must reproduce the above copyright
1017 ** notice, this list of conditions and the following disclaimer in
1018 ** the documentation and/or other materials provided with the
1019 ** distribution.
1020 **
1021 ** This software is provided "as is" and any express or implied warranties,
1022 ** including, but not limited to, the implied warranties of merchantability
1023 ** and fitness for a particular purpose are disclaimed. In no event shall
1024 ** the author or contributors be liable for any direct, indirect, incidental,
1025 ** special, exemplary, or consequential damages (including, but not limited
1026 ** to, procurement of substitute goods or services; loss of use, data or
1027 ** profits; or business interruption) however caused and on any theory of
1028 ** liability, whether in contract, strict liability, or tort (including
1029 ** negligence or otherwise) arising in any way out of the use of this
1030 ** software, even if advised of the possibility of such damage.
1031 **
1032 ** This program is distributed in the hope that it will be useful,
1033 ** but without any warranty; without even the implied warranty of
1034 ** merchantability or fitness for a particular purpose.
1035 */
1036 #include <stdio.h>
1037 #include <stdlib.h>
1038 #include <ctype.h>
1039 #include <memory.h>
1040 #include <sys/stat.h>
1041 #include <assert.h>
1042 #include <string.h>
1043
1044 #if defined( __MINGW32__) || defined(__DMC__) || \
1045 defined(_MSC_VER) || defined(__POCC__)
1046 # ifndef WIN32
1047 # define WIN32
1048 # endif
1049 #else
1050 # include <unistd.h>
1051 #endif
1052
1053 /*
1054 ** Macros for debugging.
1055 */
1056 #ifdef DEBUG
1057 static int debugMask = 0;
1058 # define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
1059 # define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
1060 # define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
1061 # define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
1062 # define PARSER 0x00000001
1063 # define DECL_DUMP 0x00000002
1064 # define TOKENIZER 0x00000004
1065 #else
1066 # define debug0(Flags, Format)
1067 # define debug1(Flags, Format, A)
1068 # define debug2(Flags, Format, A, B)
1069 # define debug3(Flags, Format, A, B, C)
1070 #endif
1071
1072 /*
1073 ** The following macros are purely for the purpose of testing this
1074 ** program on itself. They don't really contribute to the code.
1075 */
1076 #define INTERFACE 1
1077 #define EXPORT_INTERFACE 1
1078 #define EXPORT
1079
1080 /*
1081 ** Each token in a source file is represented by an instance of
1082 ** the following structure. Tokens are collected onto a list.
1083 */
1084 typedef struct Token Token;
1085 struct Token {
1086 const char *zText; /* The text of the token */
1087 int nText; /* Number of characters in the token's text */
1088 int eType; /* The type of this token */
1089 int nLine; /* The line number on which the token starts */
1090 Token *pComment; /* Most recent block comment before this token */
1091 Token *pNext; /* Next token on the list */
1092 Token *pPrev; /* Previous token on the list */
1093 };
1094
1095 /*
1096 ** During tokenization, information about the state of the input
1097 ** stream is held in an instance of the following structure
1098 */
1099 typedef struct InStream InStream;
1100 struct InStream {
1101 const char *z; /* Complete text of the input */
1102 int i; /* Next character to read from the input */
1103 int nLine; /* The line number for character z[i] */
1104 };
1105
1106 /*
1107 ** Each declaration in the C or C++ source files is parsed out and stored as
1108 ** an instance of the following structure.
1109 **
1110 ** A "forward declaration" is a declaration that an object exists that
1111 ** doesn't tell about the objects structure. A typical forward declaration
1112 ** is:
1113 **
1114 ** struct Xyzzy;
1115 **
1116 ** Not every object has a forward declaration. If it does, thought, the
1117 ** forward declaration will be contained in the zFwd field for C and
1118 ** the zFwdCpp for C++. The zDecl field contains the complete
1119 ** declaration text.
1120 */
1121 typedef struct Decl Decl;
1122 struct Decl {
1123 char *zName; /* Name of the object being declared. The appearance
1124 ** of this name is a source file triggers the declaration
1125 ** to be added to the header for that file. */
1126 const char *zFile; /* File from which extracted. */
1127 char *zIf; /* Surround the declaration with this #if */
1128 char *zFwd; /* A forward declaration. NULL if there is none. */
1129 char *zFwdCpp; /* Use this forward declaration for C++. */
1130 char *zDecl; /* A full declaration of this object */
1131 char *zExtra; /* Extra declaration text inserted into class objects */
1132 int extraType; /* Last public:, protected: or private: in zExtraDecl */
1133 struct Include *pInclude; /* #includes that come before this declaration */
1134 int flags; /* See the "Properties" below */
1135 Token *pComment; /* A block comment associated with this declaration */
1136 Token tokenCode; /* Implementation of functions and procedures */
1137 Decl *pSameName; /* Next declaration with the same "zName" */
1138 Decl *pSameHash; /* Next declaration with same hash but different zName */
1139 Decl *pNext; /* Next declaration with a different name */
1140 };
1141
1142 /*
1143 ** Properties associated with declarations.
1144 **
1145 ** DP_Forward and DP_Declared are used during the generation of a single
1146 ** header file in order to prevent duplicate declarations and definitions.
1147 ** DP_Forward is set after the object has been given a forward declaration
1148 ** and DP_Declared is set after the object gets a full declarations.
1149 ** (Example: A forward declaration is "typedef struct Abc Abc;" and the
1150 ** full declaration is "struct Abc { int a; float b; };".)
1151 **
1152 ** The DP_Export and DP_Local flags are more permanent. They mark objects
1153 ** that have EXPORT scope and LOCAL scope respectively. If both of these
1154 ** marks are missing, then the object has library scope. The meanings of
1155 ** the scopes are as follows:
1156 **
1157 ** LOCAL scope The object is only usable within the file in
1158 ** which it is declared.
1159 **
1160 ** library scope The object is visible and usable within other
1161 ** files in the same project. By if the project is
1162 ** a library, then the object is not visible to users
1163 ** of the library. (i.e. the object does not appear
1164 ** in the output when using the -H option.)
1165 **
1166 ** EXPORT scope The object is visible and usable everywhere.
1167 **
1168 ** The DP_Flag is a temporary use flag that is used during processing to
1169 ** prevent an infinite loop. It's use is localized.
1170 **
1171 ** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
1172 ** and are used to specify what type of declaration the object requires.
1173 */
1174 #define DP_Forward 0x001 /* Has a forward declaration in this file */
1175 #define DP_Declared 0x002 /* Has a full declaration in this file */
1176 #define DP_Export 0x004 /* Export this declaration */
1177 #define DP_Local 0x008 /* Declare in its home file only */
1178 #define DP_Flag 0x010 /* Use to mark a subset of a Decl list
1179 ** for special processing */
1180 #define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
1181 ** C header file */
1182 #define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
1183 ** Prepend nothing in a C header */
1184 #define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
1185 ** DP_Cplusplus is not also set. If DP_Cplusplus
1186 ** is set or this is a C header then
1187 ** prepend 'extern' */
1188
1189 /*
1190 ** Convenience macros for dealing with declaration properties
1191 */
1192 #define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
1193 #define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
1194 #define DeclSetProperty(D,P) (D)->flags |= (P)
1195 #define DeclClearProperty(D,P) (D)->flags &= ~(P)
1196
1197 /*
1198 ** These are state properties of the parser. Each of the values is
1199 ** distinct from the DP_ values above so that both can be used in
1200 ** the same "flags" field.
1201 **
1202 ** Be careful not to confuse PS_Export with DP_Export or
1203 ** PS_Local with DP_Local. Their names are similar, but the meanings
1204 ** of these flags are very different.
1205 */
1206 #define PS_Extern 0x000800 /* "extern" has been seen */
1207 #define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
1208 ** and "#endif" */
1209 #define PS_Export2 0x002000 /* If "EXPORT" seen */
1210 #define PS_Typedef 0x004000 /* If "typedef" has been seen */
1211 #define PS_Static 0x008000 /* If "static" has been seen */
1212 #define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
1213 #define PS_Method 0x020000 /* If "::" token has been seen */
1214 #define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
1215 #define PS_Local2 0x080000 /* If "LOCAL" seen. */
1216 #define PS_Public 0x100000 /* If "PUBLIC" seen. */
1217 #define PS_Protected 0x200000 /* If "PROTECTED" seen. */
1218 #define PS_Private 0x400000 /* If "PRIVATE" seen. */
1219 #define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
1220
1221 /*
1222 ** The following set of flags are ORed into the "flags" field of
1223 ** a Decl in order to identify what type of object is being
1224 ** declared.
1225 */
1226 #define TY_Class 0x00100000
1227 #define TY_Subroutine 0x00200000
1228 #define TY_Macro 0x00400000
1229 #define TY_Typedef 0x00800000
1230 #define TY_Variable 0x01000000
1231 #define TY_Structure 0x02000000
1232 #define TY_Union 0x04000000
1233 #define TY_Enumeration 0x08000000
1234 #define TY_Defunct 0x10000000 /* Used to erase a declaration */
1235
1236 /*
1237 ** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
1238 ** instances of the following structure.
1239 */
1240 typedef struct Ifmacro Ifmacro;
1241 struct Ifmacro {
1242 int nLine; /* Line number where this macro occurs */
1243 char *zCondition; /* Text of the condition for this macro */
1244 Ifmacro *pNext; /* Next down in the stack */
1245 int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
1246 };
1247
1248 /*
1249 ** When parsing a file, we need to keep track of what other files have
1250 ** be #include-ed. For each #include found, we create an instance of
1251 ** the following structure.
1252 */
1253 typedef struct Include Include;
1254 struct Include {
1255 char *zFile; /* The name of file include. Includes "" or <> */
1256 char *zIf; /* If not NULL, #include should be enclosed in #if */
1257 char *zLabel; /* A unique label used to test if this #include has
1258 * appeared already in a file or not */
1259 Include *pNext; /* Previous include file, or NULL if this is the first */
1260 };
1261
1262 /*
1263 ** Identifiers found in a source file that might be used later to provoke
1264 ** the copying of a declaration into the corresponding header file are
1265 ** stored in a hash table as instances of the following structure.
1266 */
1267 typedef struct Ident Ident;
1268 struct Ident {
1269 char *zName; /* The text of this identifier */
1270 Ident *pCollide; /* Next identifier with the same hash */
1271 Ident *pNext; /* Next identifier in a list of them all */
1272 };
1273
1274 /*
1275 ** A complete table of identifiers is stored in an instance of
1276 ** the next structure.
1277 */
1278 #define IDENT_HASH_SIZE 2237
1279 typedef struct IdentTable IdentTable;
1280 struct IdentTable {
1281 Ident *pList; /* List of all identifiers in this table */
1282 Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
1283 };
1284
1285 /*
1286 ** The following structure holds all information for a single
1287 ** source file named on the command line of this program.
1288 */
1289 typedef struct InFile InFile;
1290 struct InFile {
1291 char *zSrc; /* Name of input file */
1292 char *zHdr; /* Name of the generated .h file for this input.
1293 ** Will be NULL if input is to be scanned only */
1294 int flags; /* One or more DP_, PS_ and/or TY_ flags */
1295 InFile *pNext; /* Next input file in the list of them all */
1296 IdentTable idTable; /* All identifiers in this input file */
1297 };
1298
1299 /*
1300 ** An unbounded string is able to grow without limit. We use these
1301 ** to construct large in-memory strings from lots of smaller components.
1302 */
1303 typedef struct String String;
1304 struct String {
1305 int nAlloc; /* Number of bytes allocated */
1306 int nUsed; /* Number of bytes used (not counting nul terminator) */
1307 char *zText; /* Text of the string */
1308 };
1309
1310 /*
1311 ** The following structure contains a lot of state information used
1312 ** while generating a .h file. We put the information in this structure
1313 ** and pass around a pointer to this structure, rather than pass around
1314 ** all of the information separately. This helps reduce the number of
1315 ** arguments to generator functions.
1316 */
1317 typedef struct GenState GenState;
1318 struct GenState {
1319 String *pStr; /* Write output to this string */
1320 IdentTable *pTable; /* A table holding the zLabel of every #include that
1321 * has already been generated. Used to avoid
1322 * generating duplicate #includes. */
1323 const char *zIf; /* If not NULL, then we are within a #if with
1324 * this argument. */
1325 int nErr; /* Number of errors */
1326 const char *zFilename; /* Name of the source file being scanned */
1327 int flags; /* Various flags (DP_ and PS_ flags above) */
1328 };
1329
1330 /*
1331 ** The following text line appears at the top of every file generated
1332 ** by this program. By recognizing this line, the program can be sure
1333 ** never to read a file that it generated itself.
1334 **
1335 ** The "#undef INTERFACE" part is a hack to work around a name collision
1336 ** in MSVC 2008.
1337 */
1338 const char zTopLine[] =
1339 "/* \aThis file was automatically generated. Do not edit! */\n"
1340 "#undef INTERFACE\n";
1341 #define nTopLine (sizeof(zTopLine)-1)
1342
1343 /*
1344 ** The name of the file currently being parsed.
1345 */
1346 static const char *zFilename;
1347
1348 /*
1349 ** The stack of #if macros for the file currently being parsed.
1350 */
1351 static Ifmacro *ifStack = 0;
1352
1353 /*
1354 ** A list of all files that have been #included so far in a file being
1355 ** parsed.
1356 */
1357 static Include *includeList = 0;
1358
1359 /*
1360 ** The last block comment seen.
1361 */
1362 static Token *blockComment = 0;
1363
1364 /*
1365 ** The following flag is set if the -doc flag appears on the
1366 ** command line.
1367 */
1368 static int doc_flag = 0;
1369
1370 /*
1371 ** If the following flag is set, then makeheaders will attempt to
1372 ** generate prototypes for static functions and procedures.
1373 */
1374 static int proto_static = 0;
1375
1376 /*
1377 ** A list of all declarations. The list is held together using the
1378 ** pNext field of the Decl structure.
1379 */
1380 static Decl *pDeclFirst; /* First on the list */
1381 static Decl *pDeclLast; /* Last on the list */
1382
1383 /*
1384 ** A hash table of all declarations
1385 */
1386 #define DECL_HASH_SIZE 3371
1387 static Decl *apTable[DECL_HASH_SIZE];
1388
1389 /*
1390 ** The TEST macro must be defined to something. Make sure this is the
1391 ** case.
1392 */
1393 #ifndef TEST
1394 # define TEST 0
1395 #endif
1396
1397 #ifdef NOT_USED
1398 /*
1399 ** We do our own assertion macro so that we can have more control
1400 ** over debugging.
1401 */
1402 #define Assert(X) if(!(X)){ CantHappen(__LINE__); }
1403 #define CANT_HAPPEN CantHappen(__LINE__)
1404 static void CantHappen(int iLine){
1405 fprintf(stderr,"Assertion failed on line %d\n",iLine);
1406 *(char*)1 = 0; /* Force a core-dump */
1407 }
1408 #endif
1409
1410 /*
1411 ** Memory allocation functions that are guaranteed never to return NULL.
1412 */
1413 static void *SafeMalloc(int nByte){
1414 void *p = malloc( nByte );
1415 if( p==0 ){
1416 fprintf(stderr,"Out of memory. Can't allocate %d bytes.\n",nByte);
1417 exit(1);
1418 }
1419 return p;
1420 }
1421 static void SafeFree(void *pOld){
1422 if( pOld ){
1423 free(pOld);
1424 }
1425 }
1426 static void *SafeRealloc(void *pOld, int nByte){
1427 void *p;
1428 if( pOld==0 ){
1429 p = SafeMalloc(nByte);
1430 }else{
1431 p = realloc(pOld, nByte);
1432 if( p==0 ){
1433 fprintf(stderr,
1434 "Out of memory. Can't enlarge an allocation to %d bytes\n",nByte);
1435 exit(1);
1436 }
1437 }
1438 return p;
1439 }
1440 static char *StrDup(const char *zSrc, int nByte){
1441 char *zDest;
1442 if( nByte<=0 ){
1443 nByte = strlen(zSrc);
1444 }
1445 zDest = SafeMalloc( nByte + 1 );
1446 strncpy(zDest,zSrc,nByte);
1447 zDest[nByte] = 0;
1448 return zDest;
1449 }
1450
1451 /*
1452 ** Return TRUE if the character X can be part of an identifier
1453 */
1454 #define ISALNUM(X) ((X)=='_' || isalnum(X))
1455
1456 /*
1457 ** Routines for dealing with unbounded strings.
1458 */
1459 static void StringInit(String *pStr){
1460 pStr->nAlloc = 0;
1461 pStr->nUsed = 0;
1462 pStr->zText = 0;
1463 }
1464 static void StringReset(String *pStr){
1465 SafeFree(pStr->zText);
1466 StringInit(pStr);
1467 }
1468 static void StringAppend(String *pStr, const char *zText, int nByte){
1469 if( nByte<=0 ){
1470 nByte = strlen(zText);
1471 }
1472 if( pStr->nUsed + nByte >= pStr->nAlloc ){
1473 if( pStr->nAlloc==0 ){
1474 pStr->nAlloc = nByte + 100;
1475 pStr->zText = SafeMalloc( pStr->nAlloc );
1476 }else{
1477 pStr->nAlloc = pStr->nAlloc*2 + nByte;
1478 pStr->zText = SafeRealloc(pStr->zText, pStr->nAlloc);
1479 }
1480 }
1481 strncpy(&pStr->zText[pStr->nUsed],zText,nByte);
1482 pStr->nUsed += nByte;
1483 pStr->zText[pStr->nUsed] = 0;
1484 }
1485 #define StringGet(S) ((S)->zText?(S)->zText:"")
1486
1487 /*
1488 ** Compute a hash on a string. The number returned is a non-negative
1489 ** value between 0 and 2**31 - 1
1490 */
1491 static int Hash(const char *z, int n){
1492 unsigned int h = 0;
1493 if( n<=0 ){
1494 n = strlen(z);
1495 }
1496 while( n-- ){
1497 h = h ^ (h<<5) ^ *z++;
1498 }
1499 return (int)(h & 0x7fffffff);
1500 }
1501
1502 /*
1503 ** Given an identifier name, try to find a declaration for that
1504 ** identifier in the hash table. If found, return a pointer to
1505 ** the Decl structure. If not found, return 0.
1506 */
1507 static Decl *FindDecl(const char *zName, int len){
1508 int h;
1509 Decl *p;
1510
1511 if( len<=0 ){
1512 len = strlen(zName);
1513 }
1514 h = Hash(zName,len) % DECL_HASH_SIZE;
1515 p = apTable[h];
1516 while( p && (strncmp(p->zName,zName,len)!=0 || p->zName[len]!=0) ){
1517 p = p->pSameHash;
1518 }
1519 return p;
1520 }
1521
1522 /*
1523 ** Install the given declaration both in the hash table and on
1524 ** the list of all declarations.
1525 */
1526 static void InstallDecl(Decl *pDecl){
1527 int h;
1528 Decl *pOther;
1529
1530 h = Hash(pDecl->zName,0) % DECL_HASH_SIZE;
1531 pOther = apTable[h];
1532 while( pOther && strcmp(pDecl->zName,pOther->zName)!=0 ){
1533 pOther = pOther->pSameHash;
1534 }
1535 if( pOther ){
1536 pDecl->pSameName = pOther->pSameName;
1537 pOther->pSameName = pDecl;
1538 }else{
1539 pDecl->pSameName = 0;
1540 pDecl->pSameHash = apTable[h];
1541 apTable[h] = pDecl;
1542 }
1543 pDecl->pNext = 0;
1544 if( pDeclFirst==0 ){
1545 pDeclFirst = pDeclLast = pDecl;
1546 }else{
1547 pDeclLast->pNext = pDecl;
1548 pDeclLast = pDecl;
1549 }
1550 }
1551
1552 /*
1553 ** Look at the current ifStack. If anything declared at the current
1554 ** position must be surrounded with
1555 **
1556 ** #if STUFF
1557 ** #endif
1558 **
1559 ** Then this routine computes STUFF and returns a pointer to it. Memory
1560 ** to hold the value returned is obtained from malloc().
1561 */
1562 static char *GetIfString(void){
1563 Ifmacro *pIf;
1564 char *zResult = 0;
1565 int hasIf = 0;
1566 String str;
1567
1568 for(pIf = ifStack; pIf; pIf=pIf->pNext){
1569 if( pIf->zCondition==0 || *pIf->zCondition==0 ) continue;
1570 if( !hasIf ){
1571 hasIf = 1;
1572 StringInit(&str);
1573 }else{
1574 StringAppend(&str," && ",4);
1575 }
1576 StringAppend(&str,pIf->zCondition,0);
1577 }
1578 if( hasIf ){
1579 zResult = StrDup(StringGet(&str),0);
1580 StringReset(&str);
1581 }else{
1582 zResult = 0;
1583 }
1584 return zResult;
1585 }
1586
1587 /*
1588 ** Create a new declaration and put it in the hash table. Also
1589 ** return a pointer to it so that we can fill in the zFwd and zDecl
1590 ** fields, and so forth.
1591 */
1592 static Decl *CreateDecl(
1593 const char *zName, /* Name of the object being declared. */
1594 int nName /* Length of the name */
1595 ){
1596 Decl *pDecl;
1597
1598 pDecl = SafeMalloc( sizeof(Decl) + nName + 1);
1599 memset(pDecl,0,sizeof(Decl));
1600 pDecl->zName = (char*)&pDecl[1];
1601 memcpy(pDecl->zName, zName, nName);
1602 pDecl->zName[nName] = 0;
1603 pDecl->zFile = zFilename;
1604 pDecl->pInclude = includeList;
1605 pDecl->zIf = GetIfString();
1606 InstallDecl(pDecl);
1607 return pDecl;
1608 }
1609
1610 /*
1611 ** Insert a new identifier into an table of identifiers. Return TRUE if
1612 ** a new identifier was inserted and return FALSE if the identifier was
1613 ** already in the table.
1614 */
1615 static int IdentTableInsert(
1616 IdentTable *pTable, /* The table into which we will insert */
1617 const char *zId, /* Name of the identifiers */
1618 int nId /* Length of the identifier name */
1619 ){
1620 int h;
1621 Ident *pId;
1622
1623 if( nId<=0 ){
1624 nId = strlen(zId);
1625 }
1626 h = Hash(zId,nId) % IDENT_HASH_SIZE;
1627 for(pId = pTable->apTable[h]; pId; pId=pId->pCollide){
1628 if( strncmp(zId,pId->zName,nId)==0 && pId->zName[nId]==0 ){
1629 /* printf("Already in table: %.*s\n",nId,zId); */
1630 return 0;
1631 }
1632 }
1633 pId = SafeMalloc( sizeof(Ident) + nId + 1 );
1634 pId->zName = (char*)&pId[1];
1635 memcpy(pId->zName, zId, nId);
1636 pId->zName[nId] = 0;
1637 pId->pNext = pTable->pList;
1638 pTable->pList = pId;
1639 pId->pCollide = pTable->apTable[h];
1640 pTable->apTable[h] = pId;
1641 /* printf("Add to table: %.*s\n",nId,zId); */
1642 return 1;
1643 }
1644
1645 /*
1646 ** Check to see if the given value is in the given IdentTable. Return
1647 ** true if it is and false if it is not.
1648 */
1649 static int IdentTableTest(
1650 IdentTable *pTable, /* The table in which to search */
1651 const char *zId, /* Name of the identifiers */
1652 int nId /* Length of the identifier name */
1653 ){
1654 int h;
1655 Ident *pId;
1656
1657 if( nId<=0 ){
1658 nId = strlen(zId);
1659 }
1660 h = Hash(zId,nId) % IDENT_HASH_SIZE;
1661 for(pId = pTable->apTable[h]; pId; pId=pId->pCollide){
1662 if( strncmp(zId,pId->zName,nId)==0 && pId->zName[nId]==0 ){
1663 return 1;
1664 }
1665 }
1666 return 0;
1667 }
1668
1669 /*
1670 ** Remove every identifier from the given table. Reset the table to
1671 ** its initial state.
1672 */
1673 static void IdentTableReset(IdentTable *pTable){
1674 Ident *pId, *pNext;
1675
1676 for(pId = pTable->pList; pId; pId = pNext){
1677 pNext = pId->pNext;
1678 SafeFree(pId);
1679 }
1680 memset(pTable,0,sizeof(IdentTable));
1681 }
1682
1683 #ifdef DEBUG
1684 /*
1685 ** Print the name of every identifier in the given table, one per line
1686 */
1687 static void IdentTablePrint(IdentTable *pTable, FILE *pOut){
1688 Ident *pId;
1689
1690 for(pId = pTable->pList; pId; pId = pId->pNext){
1691 fprintf(pOut,"%s\n",pId->zName);
1692 }
1693 }
1694 #endif
1695
1696 /*
1697 ** Read an entire file into memory. Return a pointer to the memory.
1698 **
1699 ** The memory is obtained from SafeMalloc and must be freed by the
1700 ** calling function.
1701 **
1702 ** If the read fails for any reason, 0 is returned.
1703 */
1704 static char *ReadFile(const char *zFilename){
1705 struct stat sStat;
1706 FILE *pIn;
1707 char *zBuf;
1708 int n;
1709
1710 if( stat(zFilename,&sStat)!=0
1711 #ifndef WIN32
1712 || !S_ISREG(sStat.st_mode)
1713 #endif
1714 ){
1715 return 0;
1716 }
1717 pIn = fopen(zFilename,"r");
1718 if( pIn==0 ){
1719 return 0;
1720 }
1721 zBuf = SafeMalloc( sStat.st_size + 1 );
1722 n = fread(zBuf,1,sStat.st_size,pIn);
1723 zBuf[n] = 0;
1724 fclose(pIn);
1725 return zBuf;
1726 }
1727
1728 /*
1729 ** Write the contents of a string into a file. Return the number of
1730 ** errors
1731 */
1732 static int WriteFile(const char *zFilename, const char *zOutput){
1733 FILE *pOut;
1734 pOut = fopen(zFilename,"w");
1735 if( pOut==0 ){
1736 return 1;
1737 }
1738 fwrite(zOutput,1,strlen(zOutput),pOut);
1739 fclose(pOut);
1740 return 0;
1741 }
1742
1743 /*
1744 ** Major token types
1745 */
1746 #define TT_Space 1 /* Contiguous white space */
1747 #define TT_Id 2 /* An identifier */
1748 #define TT_Preprocessor 3 /* Any C preprocessor directive */
1749 #define TT_Comment 4 /* Either C or C++ style comment */
1750 #define TT_Number 5 /* Any numeric constant */
1751 #define TT_String 6 /* String or character constants. ".." or '.' */
1752 #define TT_Braces 7 /* All text between { and a matching } */
1753 #define TT_EOF 8 /* End of file */
1754 #define TT_Error 9 /* An error condition */
1755 #define TT_BlockComment 10 /* A C-Style comment at the left margin that
1756 * spans multiple lines */
1757 #define TT_Other 0 /* None of the above */
1758
1759 /*
1760 ** Get a single low-level token from the input file. Update the
1761 ** file pointer so that it points to the first character beyond the
1762 ** token.
1763 **
1764 ** A "low-level token" is any token except TT_Braces. A TT_Braces token
1765 ** consists of many smaller tokens and is assembled by a routine that
1766 ** calls this one.
1767 **
1768 ** The function returns the number of errors. An error is an
1769 ** unterminated string or character literal or an unterminated
1770 ** comment.
1771 **
1772 ** Profiling shows that this routine consumes about half the
1773 ** CPU time on a typical run of makeheaders.
1774 */
1775 static int GetToken(InStream *pIn, Token *pToken){
1776 int i;
1777 const char *z;
1778 int cStart;
1779 int c;
1780 int startLine; /* Line on which a structure begins */
1781 int nlisc = 0; /* True if there is a new-line in a ".." or '..' */
1782 int nErr = 0; /* Number of errors seen */
1783
1784 z = pIn->z;
1785 i = pIn->i;
1786 pToken->nLine = pIn->nLine;
1787 pToken->zText = &z[i];
1788 switch( z[i] ){
1789 case 0:
1790 pToken->eType = TT_EOF;
1791 pToken->nText = 0;
1792 break;
1793
1794 case '#':
1795 if( i==0 || z[i-1]=='\n' || (i>1 && z[i-1]=='\r' && z[i-2]=='\n')){
1796 /* We found a preprocessor statement */
1797 pToken->eType = TT_Preprocessor;
1798 i++;
1799 while( z[i]!=0 && z[i]!='\n' ){
1800 if( z[i]=='\\' ){
1801 i++;
1802 if( z[i]=='\n' ) pIn->nLine++;
1803 }
1804 i++;
1805 }
1806 pToken->nText = i - pIn->i;
1807 }else{
1808 /* Just an operator */
1809 pToken->eType = TT_Other;
1810 pToken->nText = 1;
1811 }
1812 break;
1813
1814 case ' ':
1815 case '\t':
1816 case '\r':
1817 case '\f':
1818 case '\n':
1819 while( isspace(z[i]) ){
1820 if( z[i]=='\n' ) pIn->nLine++;
1821 i++;
1822 }
1823 pToken->eType = TT_Space;
1824 pToken->nText = i - pIn->i;
1825 break;
1826
1827 case '\\':
1828 pToken->nText = 2;
1829 pToken->eType = TT_Other;
1830 if( z[i+1]=='\n' ){
1831 pIn->nLine++;
1832 pToken->eType = TT_Space;
1833 }else if( z[i+1]==0 ){
1834 pToken->nText = 1;
1835 }
1836 break;
1837
1838 case '\'':
1839 case '\"':
1840 cStart = z[i];
1841 startLine = pIn->nLine;
1842 do{
1843 i++;
1844 c = z[i];
1845 if( c=='\n' ){
1846 if( !nlisc ){
1847 fprintf(stderr,
1848 "%s:%d: (warning) Newline in string or character literal.\n",
1849 zFilename, pIn->nLine);
1850 nlisc = 1;
1851 }
1852 pIn->nLine++;
1853 }
1854 if( c=='\\' ){
1855 i++;
1856 nLine++;
1857 }
1858 }else if( c==cStart ){
1859 i++;
1860 c = 0;
1861 }else if( c==0 ){
1862 fprintf(stderr, "%s:%d: Unterminated string or character literal.\n",
1863 zFilename, startLine);
1864 nErr++;
1865 }
1866 }while( c );
1867 pToken->eType = TT_String;
1868 pToken->nText = i - pIn->i;
1869 break;
1870
1871 case '/':
1872 if( z[i+1]=='/' ){
1873 /* C++ style comment */
1874 while( z[i] && z[i]!='\n' ){ i++; }
1875 pToken->eType = TT_Comment;
1876 pToken->nText = i - pIn->i;
1877 }else if( z[i+1]=='*' ){
1878 /* C style comment */
1879 int isBlockComment = i==0 || z[i-1]=='\n';
1880 i += 2;
1881 startLine = pIn->nLine;
1882 while( z[i] && (z[i]!='*' || z[i+1]!='/') ){
1883 if( z[i]=='\n' ){
1884 pIn->nLine++;
1885 if( isBlockComment ){
1886 if( z[i+1]=='*' || z[i+2]=='*' ){
1887 isBlockComment = 2;
1888 }else{
1889 isBlockComment = 0;
1890 }
1891 }
1892 }
1893 i++;
1894 }
1895 if( z[i] ){
1896 i += 2;
1897 }else{
1898 isBlockComment = 0;
1899 fprintf(stderr,"%s:%d: Unterminated comment\n",
1900 zFilename, startLine);
1901 nErr++;
1902 }
1903 pToken->eType = isBlockComment==2 ? TT_BlockComment : TT_Comment;
1904 pToken->nText = i - pIn->i;
1905 }else{
1906 /* A divide operator */
1907 pToken->eType = TT_Other;
1908 pToken->nText = 1 + (z[i+1]=='+');
1909 }
1910 break;
1911
1912 case '0':
1913 if( z[i+1]=='x' || z[i+1]=='X' ){
1914 /* A hex constant */
1915 i += 2;
1916 while( isxdigit(z[i]) ){ i++; }
1917 }else{
1918 /* An octal constant */
1919 while( isdigit(z[i]) ){ i++; }
1920 }
1921 pToken->eType = TT_Number;
1922 pToken->nText = i - pIn->i;
1923 break;
1924
1925 case '1': case '2': case '3': case '4':
1926 case '5': case '6': case '7': case '8': case '9':
1927 while( isdigit(z[i]) ){ i++; }
1928 if( (c=z[i])=='.' ){
1929 i++;
1930 while( isdigit(z[i]) ){ i++; }
1931 c = z[i];
1932 if( c=='e' || c=='E' ){
1933 i++;
1934 if( ((c=z[i])=='+' || c=='-') && isdigit(z[i+1]) ){ i++; }
1935 while( isdigit(z[i]) ){ i++; }
1936 c = z[i];
1937 }
1938 if( c=='f' || c=='F' || c=='l' || c=='L' ){ i++; }
1939 }else if( c=='e' || c=='E' ){
1940 i++;
1941 if( ((c=z[i])=='+' || c=='-') && isdigit(z[i+1]) ){ i++; }
1942 while( isdigit(z[i]) ){ i++; }
1943 }else if( c=='L' || c=='l' ){
1944 i++;
1945 c = z[i];
1946 if( ){
1947 i++;
1948 c = z[i];
1949 if( c=='l' || c=='L' ){ i++; }
1950 }
1951 pToken->eType = TT_Number;
1952 pToken->nText = i - pIn->i;
1953 break;
1954
1955 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
1956 case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
1957 case 'o': case 'p': case 'r contributors be liable for any direct, indirect, incidental,
1958 ** special, exemplary, or consequential damages (including, but not limited
1959 ** to, procurement of substitute goods or services; loss of use, data or
1960 ** profits; or business interruption) however caused and on any theory of
1961 ** liability, whether in contract, strict liability, or tort (including
1962 ** negligence or otherwise) arising in any way out of the use of this
1963 ** software, even if advised of the possibility of such damage.
1964 **
1965 ** This program is distributed in the hope that it will be useful,
1966 ** but without any warranty; without even the implied warranty of
1967 ** merchantability or fitness for a particular purpose.
1968 */
1969 #include <stdio.h>
1970 #include <stdlib.h>
1971 #include <ctype.h>
1972 #include <memory.h>
1973 #include <sys/stat.h>
1974 #include <assert.h>
1975 #include <string.h>
1976
1977 #if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
1978 # ifndef WIN32
1979 # define WIN32
1980 # endif
1981 #else
1982 # include <unistd.h>
1983 #endif
1984
1985 /*
1986 ** Macros for debugging.
1987 */
1988 #ifdef DEBUG
1989 static int debugMask = 0;
1990 # define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
1991 # define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
1992 # define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
1993 # define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
1994 # define PARSER 0x00000001
1995 # define DECL_DUMP 0x00000002
1996 # define TOKENIZER 0x00000004
1997 #else
1998 # define debug0(Flags, Format)
1999 # define debug1(Flags, Format, A)
2000 # define debug2(Flags, Format, A, B)
2001 # define debug3(Flags, Format, A, B, C)
2002 #endif
2003
2004 /*
2005 ** The following macros are purely for the purpose of testing this
2006 ** program on itself. They don't really contribute to the code.
2007 */
2008 #define INTERFACE 1
2009 #define EXPORT_INTERFACE 1
2010 #define EXPORT
2011
2012 /*
2013 ** Each token in a source file is represented by an instance of
2014 ** the following structure. Tokens are collected onto a list.
2015 */
2016 typedef struct Token Token;
2017 struct Token {
2018 const char *zText; /* The text of the token */
2019 int nText; /* Number of characters in the token's text */
2020 int eType; /* The type of this token */
2021 int nLine; /* The line number on which the token starts */
2022 Token *pComment; /* Most recent block comment before this token */
2023 Token *pNext; /* Next token on the list */
2024 Token *pPrev; /* Previous token on the list */
2025 };
2026
2027 /*
2028 ** During tokenization, information about the state of the input
2029 ** stream is held in an instance of the following structure
2030 */
2031 typedef struct InStream InStream;
2032 struct InStream {
2033 const char *z; /* Complete text of the input */
2034 int i; /* Next character to read from the input */
2035 int nLine; /* The line number for character z[i] */
2036 };
2037
2038 /*
2039 ** Each declaration in the C or C++ source files is parsed out and stored as
2040 ** an instance of the following structure.
2041 **
2042 ** A "forward declaration" is a declaration that an object exists that
2043 ** doesn't tell about the objects structure. A typical forward declaration
2044 ** is:
2045 **
2046 ** struct Xyzzy;
2047 **
2048 ** Not every object has a forward declaration. If it does, thought, the
2049 ** forward declaration will be contained in the zFwd field for C and
2050 ** the zFwdCpp for C++. The zDecl field contains the complete
2051 ** declaration text.
2052 */
2053 typedef struct Decl Decl;
2054 struct Decl {
2055 char *zName; /* Name of the object being declared. The appearance
2056 ** of this name is a source file triggers the declaration
2057 ** to be added to the header for that file. */
2058 const char *zFile; /* File from which extracted. */
2059 char *zIf; /* Surround the declaration with this #if */
2060 char *zFwd; /* A forward declaration. NULL if there is none. */
2061 char *zFwdCpp; /* Use this forward declaration for C++. */
2062 char *zDecl; /* A full declaration of this object */
2063 char *zExtra; /* Extra declaration text inserted into class objects */
2064 int extraType; /* Last public:, protected: or private: in zExtraDecl */
2065 struct Include *pInclude; /* #includes that come before this declaration */
2066 int flags; /* See the "Properties" below */
2067 Token *pComment; /* A block comment associated with this declaration */
2068 Token tokenCode; /* Implementation of functions and procedures */
2069 Decl *pSameName; /* Next declaration with the same "zName" */
2070 Decl *pSameHash; /* Next declaration with same hash but different zName */
2071 Decl *pNext; /* Next declaration with a different name */
2072 };
2073
2074 /*
2075 ** Properties associated with declarations.
2076 **
2077 ** DP_Forward and DP_Declared are used during the generation of a single
2078 ** header file in order to prevent duplicate declarations and definitions.
2079 ** DP_Forward is set after the object has been given a forward declaration
2080 ** and DP_Declared is set after the object gets a full declarations.
2081 ** (Example: A forward declaration is "typedef struct Abc Abc;" and the
2082 ** full declaration is "struct Abc { int a; float b; };".)
2083 **
2084 ** The DP_Export and DP_Local flags are more permanent. They mark objects
2085 ** that have EXPORT scope and LOCAL scope respectively. If both of these
2086 ** marks are missing, then the object has library scope. The meanings of
2087 ** the scopes are as follows:
2088 **
2089 ** LOCAL scope The object is only usable within the file in
2090 ** which it is declared.
2091 **
2092 ** library scope The object is visible and usable within other
2093 ** files in the same project. By if the project is
2094 ** a library, then the object is not visible to users
2095 ** of the library. (i.e. the object does not appear
2096 ** in the output when using the -H option.)
2097 **
2098 ** EXPORT scope The object is visible and usable everywhere.
2099 **
2100 ** The DP_Flag is a temporary use flag that is used during processing to
2101 ** prevent an infinite loop. It's use is localized.
2102 **
2103 ** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
2104 ** and are used to specify what type of declaration the object requires.
2105 */
2106 #define DP_Forward 0x001 /* Has a forward declaration in this file */
2107 #define DP_Declared 0x002 /* Has a full declaration in this file */
2108 #define DP_Export 0x004 /* Export this declaration */
2109 #define DP_Local 0x008 /* Declare in its home file only */
2110 #define DP_Flag 0x010 /* Use to mark a subset of a Decl list
2111 ** for special processing */
2112 #define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
2113 ** C header file */
2114 #define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
2115 ** Prepend nothing in a C header */
2116 #define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
2117 ** DP_Cplusplus is not also set. If DP_Cplusplus
2118 ** is set or this is a C header then
2119 ** prepend 'extern' */
2120
2121 /*
2122 ** Convenience macros for dealing with declaration properties
2123 */
2124 #define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
2125 #define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
2126 #define DeclSetProperty(D,P) (D)->flags |= (P)
2127 #define DeclClearProperty(D,P) (D)->flags &= ~(P)
2128
2129 /*
2130 ** These are state properties of the parser. Each of the values is
2131 ** distinct from the DP_ values above so that both can be used in
2132 ** the same "flags" field.
2133 **
2134 ** Be careful not to confuse PS_Export with DP_Export or
2135 ** PS_Local with DP_Local. Their names are similar, but the meanings
2136 ** of these flags are very different.
2137 */
2138 #define PS_Extern 0x000800 /* "extern" has been seen */
2139 #define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
2140 ** and "#endif" */
2141 #define PS_Export2 0x002000 /* If "EXPORT" seen */
2142 #define PS_Typedef 0x004000 /* If "typedef" has been seen */
2143 #define PS_Static 0x008000 /* If "static" has been seen */
2144 #define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
2145 #define PS_Method 0x020000 /* If "::" token has been seen */
2146 #define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
2147 #define PS_Local2 0x080000 /* If "LOCAL" seen. */
2148 #define PS_Public 0x100000 /* If "PUBLIC" seen. */
2149 #define PS_Protected 0x200000 /* If "PROTECTED" seen. */
2150 #define PS_Private 0x400000 /* If "PRIVATE" seen. */
2151 #define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
2152
2153 /*
2154 ** The following set of flags are ORed into the "flags" field of
2155 ** a Decl in order to identify what type of object is being
2156 ** declared.
2157 */
2158 #define TY_Class 0x00100000
2159 #define TY_Subroutine 0x00200000
2160 #define TY_Macro 0x00400000
2161 #define TY_Typedef 0x00800000
2162 #define TY_Variable 0x01000000
2163 #define TY_Structure 0x02000000
2164 #define TY_Union 0x04000000
2165 #define TY_Enumeration 0x08000000
2166 #define TY_Defunct 0x10000000 /* Used to erase a declaration */
2167
2168 /*
2169 ** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
2170 ** instances of the following structure.
2171 */
2172 typedef struct Ifmacro Ifmacro;
2173 struct Ifmacro {
2174 int nLine; /* Line number where this macro occurs */
2175 char *zCondition; /* Text of the condition for this macro */
2176 Ifmacro *pNext; /* Next down in the stack */
2177 int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
2178 };
2179
2180 /*
2181 ** When parsing a file, we need to keep track of what other files have
2182 ** be #include-ed. For each #include found, we create an instance of
2183 ** the following structure.
2184 */
2185 typedef struct Include Include;
2186 struct Include {
2187 char *zFile; /* The name of file include. Includes "" or <> */
2188 char *zIf; /* If not NULL, #include should be enclosed in #if */
2189 char *zLabel; /* A unique label used to test if this #include has
2190 * appeared already in a file or not */
2191 Include *pNext; /* Previous include file, or NULL if this is the first */
2192 };
2193
2194 /*
2195 ** Identifiers found in a source file that might be used later to provoke
2196 ** the copying of a declaration into the corresponding header file are
2197 ** stored in a hash table as instances of the following structure.
2198 */
2199 typedef struct Ident Ident;
2200 struct Ident {
2201 char *zName; /* The text of this identifier */
2202 Ident *pCollide; /* Next identifier with the same hash */
2203 Ident *pNext; /* Next identifier in a list of them all */
2204 };
2205
2206 /*
2207 ** A complete table of identifiers is stored in an instance of
2208 ** the next structure.
2209 */
2210 #define IDENT_HASH_SIZE 2237
2211 typedef struct IdentTable IdentTable;
2212 struct IdentTable {
2213 Ident *pList; /* List of all identifiers in this table */
2214 Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
2215 };
2216
2217 /*
2218 ** The following structure holds all information for a single
2219 ** source file named on the command line of this program.
2220 */
2221 typedef struct InFile InFile;
2222 struct InFile {
2223 char *zSrc; /* Name of input file */
2224 char *zHdr; /* Name of the generated .h file for this input.
2225 ** Will be NULL if input is to be scanned only */
2226 int flags; /* One or more DP_, PS_ and/or TY_ flags */
2227 InFile *pNext; /* Next input file in the list of them all */
2228 IdentTable idTable; /* All identifiers in this input file */
2229 };
2230
2231 /*
2232 ** An unbounded string is able to grow without limit. We use these
2233 ** to construct large in-memory strings from lots of smaller components.
2234 */
2235 typedef struct String String;
2236 struct String {
2237 int nAlloc; /* Number of bytes allocated */
2238 int nUsed; /* Number of bytes used (not counting nul terminator) */
2239 char *zText; /* Text of the string */
2240 };
2241
2242 /*
2243 ** The following structure contains a lot of state information used
2244 ** while generating a .h file. We put the information in this structure
2245 ** and pass around a pointer to this structure, rather than pass around
2246 ** all of the information separately. This helps reduce the number of
2247 ** arguments to generator functions.
2248 */
2249 typedef struct GenState GenState;
2250 struct GenState {
2251 String *pStr; /* Write output to this string */
2252 IdentTable *pTable; /* A table holding the zLabel of every #include that
2253 * has already been generated. Used to avoid
2254 * generating duplicate #includes. */
2255 const char *zIf; /* If not NULL, then we are within a #if with
2256 * this argument. */
2257 int nErr; /* Number of errors */
2258 const char *zFilename; /* Name of the source file being scanned */
2259 int flags; /* Various flags (DP_ and PS_ flags above) */
2260 };
2261
2262 /*
2263 ** The following text line appears at the top of every file generated
2264 ** by this program. By recognizing this line, the program can be sure
2265 ** never to read a file that it generated itself.
2266 **
2267 ** The "#undef INTERFACE" part is a hack to work around a name collision
2268 ** in MSVC 2008.
2269 */
2270 const char zTopLine[] =
2271 "/* \aThis file was automatically generated. Do not edit! */\n"
2272 "#undef INTERFACE\n";
2273 #define nTopLine (sizeof(zTopLine)-1)
2274
2275 /*
2276 ** The name of the file currently being parsed.
2277 */
2278 static const char *zFilename;
2279
2280 /*
2281 ** The stack of #if macros for the file currently being parsed.
2282 */
2283 static Ifmacro *ifStack = 0;
2284
2285 /*
2286 ** A list of all files that have been #included so far in a file being
2287 ** parsed.
2288 */
2289 static Include *includeList = 0;
2290
2291 /*
2292 ** The last block comment seen.
2293 */
2294 static Token *blockComment = 0;
2295
2296 /*
2297 ** The following flag is set if the -doc flag appears on the
2298 ** command line.
2299 */
2300 static int doc_flag = 0;
2301
2302 /*
2303 ** If the following flag is set, then makeheaders will attempt to
2304 ** generate prototypes for static functions and procedures.
2305 */
2306 static int proto_static = 0;
2307
2308 /*
2309 ** A list of all declarations. The list is held together using the
2310 ** pNext field of the Decl structure.
2311 */
2312 static Decl *pDeclFirst; /* First on the list */
2313 static Decl *pDeclLast; /* Last on the list */
2314
2315 /*
2316 ** A hash table of all declarations
2317 */
2318 #define DECL_HASH_SIZE 3371
2319 static Decl *apTable[DECL_HASH_SIZE];
2320
2321 /*
2322 ** The TEST macro must be defined to something. Make sure this is the
2323 ** case.
2324 */
2325 #ifndef TEST
2326 # define TEST 0
2327 #endif
2328
2329 #ifdef NOT_USED
2330 /*
2331 ** We do our own assertion macro so that we can have more control
2332 ** over debugging.
2333 */
2334 #define Assert(X) if(!(X)){ CantHappen(__LINE__); }
2335 #define CANT_HAPPEN CantHappen(__LINE__)
2336 static void CantHappen(int iLine){
2337 fprintf(stderr,"Assertion failed on line %d\n",iLine);
2338 *(char*)1 = 0; /* Force a core-dump */
2339 }
2340 #endif
2341
2342 /*
2343 ** Memory allocation functions that are guaranteed never to return NULL.
2344 */
2345 static void *SafeMalloc(int nByte){
2346 void *p = malloc( nByte );
2347 if( p==0 ){
2348 fprintf(stderr,"Out of memory. Can't allocate %d bytes.\n",nByte);
2349 exit(1);
2350 }
2351 return p;
2352 }
2353 static void SafeFree(void *pOld){
2354 if( pOld ){
2355 free(pOld);
2356 }
2357 }
2358 static void *SafeRealloc(void *pOld, int nByte){
2359 void *p;
2360 if( pOld==0 ){
2361 p = SafeMalloc(nByte);
2362 }else{
2363 p = realloc(pOld, nByte);
2364 if( p==0 ){
2365 fprintf(stderr,
2366 "Out of memory. Can't enlarge an allocation to %d bytes\n",nByte);
2367 exit(1);
2368 }
2369 }
2370 return p;
2371 }
2372 static char *StrDup(const char *zSrc, int nByte){
2373 char *zDest;
2374 if( nByte<=0 ){
2375 nByte = strlen(zSrc);
2376 }
2377 zDest = SafeMalloc( nByte + 1 );
2378 strncpy(zDest,zSrc,nByte);
2379 zDest[nByte] = 0;
2380 return zDest;
2381 }
2382
2383 /*
2384 ** Return TRUE if the character X can be part of an identifier
2385 */
2386 #define ISALNUM(X) ((X)=='_' || isalnum(X))
2387
2388 /*
2389 ** Routines for dealing with unbounded strings.
2390 */
2391 static void StringInit(String *pStr){
2392 pStr->nAlloc = 0;
2393 pStr->nUsed = 0;
2394 pStr->zText = 0;
2395 }
2396 static void StringReset(String *pStr){
2397 SafeFree(pStr->zText);
2398 StringInit(pStr);
2399 }
2400 static void StringAppend(String *pStr, const char *zText, int nByte){
2401 if( nByte<=0 ){
2402 nByte = strlen(zText);
2403 }
2404 if( pStr->nUsed + nByte >= pStr->nAlloc ){
2405 if( pStr->nAlloc==0 ){
2406 pStr->nAlloc = nByte + 100;
2407 pStr->zText = SafeMalloc( pStr->nAlloc );
2408 }else{
2409 pStr->nAlloc = pStr->nAlloc*2 + nByte;
2410 pStr->zText = SafeRealloc(pStr->zText, pStr->nAlloc);
2411 }
2412 }
2413 strncpy(&pStr->zText[pStr->nUsed],zText,nByte);
2414 pStr->nUsed += nByte;
2415 pStr->zText[pStr->nUsed] = 0;
2416 }
2417 #define StringGet(S) ((S)->zText?(S)->zText:"")
2418
2419 /*
2420 ** Compute a hash on a string. The number returned is a non-negative
2421 ** value between 0 and 2**31 - 1
2422 */
2423 static int Hash(const char *z, int n){
2424 int h = 0;
2425 if( n<=0 ){
2426 n = strlen(z);
2427 }
2428 while( n-- ){
2429 h = h ^ (h & 0x7fffffff; free software; are; you can redistribute it and/or
2430 ** modify it under the terms of the Simplified BSD License (also
2431 ** known as the "2-Clause License" or "FreeBSD License".)
2432 **
2433 ** Copyright 1993 D. Richard Hipp. All rights reserved.
2434 **
2435 ** Redistribution and use in source and binary forms, with or
2436 ** without modification, are permitted provided that the following
2437 ** conditions are met:
2438 **
2439 ** 1. Redistributions of source code must retain the above copyright
2440 ** notice, this list of conditions and the following disclaimer.
2441 **
2442 ** 2. Redistributions in binary form must reproduce the above copyright
2443 ** notice, thisprintf(pDecl/*
2444 ** This program is free software; you can redistribute it and/or
2445 ** modify it under the terms of the Simplified BSD License (also
2446 ** known as the "2-Clause License" or "FreeBSD License".)
2447 **
2448 ** Copyright 1993 D. Richard Hipp. All rights reserved.
2449 **
2450 ** Redistribution and use in source and binary forms, with or
2451 ** without modification, are permitted provided that the following
2452 ** conditions are met:
2453 **
2454 ** 1. Redistributions of source code must retain the above copyright
2455 ** notice, this list of conditions and the following disclaimer.
2456 **
2457 ** 2. Redistributions in binary form must reproduce the above copyright
2458 ** notice, this list of conditions and the following disclaimer in
2459 ** the documentation and/or other materials provided with the
2460 ** distribution.
2461 **
2462 ** This software is provided "as is" and any express or implied warranties,
2463 ** including, but not limited to, the implied warranties of merchantability
2464 ** and fitness for a particular purpose are disclaimed. In no event shall
2465 ** the author or contributors be liable for any direct, indirect, incidental,
2466 ** special, exemplary, or consequential damages (including, but not limited
2467 ** to, procurement of substitute goods or services; loss of use, data or
2468 ** profits; or business interruption) however caused and on any theory of
2469 ** liability, whether in contract, strict liability, or tort (including
2470 ** negligence or otherwise) arising in any way out of the use of this
2471 ** software, even if advised of the possibility of such damage.
2472 **
2473 ** This program is distributed in the hope that it will be useful,
2474 ** but without any warranty; without even the implied warranty of
2475 ** merchantability or fitness for a particular purpose.
2476 */
2477 #include <stdio.h>
2478 #include <stdlib.h>
2479 #include <ctype.h>
2480 #include <memory.h>
2481 #include <sys/stat.h>
2482 #include <assert.h>
2483 #include <string.h>
2484
2485 #if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__)
2486 # ifndef WIN32
2487 # define WIN32
2488 # endif
2489 #else
2490 # include <unistd.h>
2491 #endif
2492
2493 /*
2494 ** Macros for debugging.
2495 */
2496 #ifdef DEBUG
2497 static int debugMask = 0;
2498 # define debug0(F,M) if( (F)&debugMask ){ fprintf(stderr,M); }
2499 # define debug1(F,M,A) if( (F)&debugMask ){ fprintf(stderr,M,A); }
2500 # define debug2(F,M,A,B) if( (F)&debugMask ){ fprintf(stderr,M,A,B); }
2501 # define debug3(F,M,A,B,C) if( (F)&debugMask ){ fprintf(stderr,M,A,B,C); }
2502 # define PARSER 0x00000001
2503 # define DECL_DUMP 0x00000002
2504 # define TOKENIZER 0x00000004
2505 #else
2506 # define debug0(Flags, Format)
2507 # define debug1(Flags, Format, A)
2508 # define debug2(Flags, Format, A, B)
2509 # define debug3(Flags, Format, A, B, C)
2510 #endif
2511
2512 /*
2513 ** The following macros are purely for the purpose of testing this
2514 ** program on itself. They don't really contribute to the code.
2515 */
2516 #define INTERFACE 1
2517 #define EXPORT_INTERFACE 1
2518 #define EXPORT
2519
2520 /*
2521 ** Each token in a source file is represented by an instance of
2522 ** the following structure. Tokens are collected onto a list.
2523 */
2524 typedef struct Token Token;
2525 struct Token {
2526 const char *zText; /* The text of the token */
2527 int nText; /* Number of characters in the token's text */
2528 int eType; /* The type of this token */
2529 int nLine; /* The line number on which the token starts */
2530 Token *pComment; /* Most recent block comment before this token */
2531 Token *pNext; /* Next token on the list */
2532 Token *pPrev; /* Previous token on the list */
2533 };
2534
2535 /*
2536 ** During tokenization, information about the state of the input
2537 ** stream is held in an instance of the following structure
2538 */
2539 typedef struct InStream InStream;
2540 struct InStream {
2541 const char *z; /* Complete text of the input */
2542 int i; /* Next character to read from the input */
2543 int nLine; /* The line number for character z[i] */
2544 };
2545
2546 /*
2547 ** Each declaration in the C or C++ source files is parsed out and stored as
2548 ** an instance of the following structure.
2549 **
2550 ** A "forward declaration" is a declaration that an object exists that
2551 ** doesn't tell about the objects structure. A typical forward declaration
2552 ** is:
2553 **
2554 ** struct Xyzzy;
2555 **
2556 ** Not every object has a forward declaration. If it does, thought, the
2557 ** forward declaration will be contained in the zFwd field for C and
2558 ** the zFwdCpp for C++. The zDecl field contains the complete
2559 ** declaration text.
2560 */
2561 typedef struct Decl Decl;
2562 struct Decl {
2563 char *zName; /* Name of the object being declared. The appearance
2564 ** of this name is a source file triggers the declaration
2565 ** to be added to the header for that file. */
2566 const char *zFile; /* File from which extracted. */
2567 char *zIf; /* Surround the declaration with this #if */
2568 char *zFwd; /* A forward declaration. NULL if there is none. */
2569 char *zFwdCpp; /* Use this forward declaration for C++. */
2570 char *zDecl; /* A full declaration of this object */
2571 char *zExtra; /* Extra declaration text inserted into class objects */
2572 int extraType; /* Last public:, protected: or private: in zExtraDecl */
2573 struct Include *pInclude; /* #includes that come before this declaration */
2574 int flags; /* See the "Properties" below */
2575 Token *pComment; /* A block comment associated with this declaration */
2576 Token tokenCode; /* Implementation of functions and procedures */
2577 Decl *pSameName; /* Next declaration with the same "zName" */
2578 Decl *pSameHash; /* Next declaration with same hash but different zName */
2579 Decl *pNext; /* Next declaration with a different name */
2580 };
2581
2582 /*
2583 ** Properties associated with declarations.
2584 **
2585 ** DP_Forward and DP_Declared are used during the generation of a single
2586 ** header file in order to prevent duplicate declarations and definitions.
2587 ** DP_Forward is set after the object has been given a forward declaration
2588 ** and DP_Declared is set after the object gets a full declarations.
2589 ** (Example: A forward declaration is "typedef struct Abc Abc;" and the
2590 ** full declaration is "struct Abc { int a; float b; };".)
2591 **
2592 ** The DP_Export and DP_Local flags are more permanent. They mark objects
2593 ** that have EXPORT scope and LOCAL scope respectively. If both of these
2594 ** marks are missing, then the object has library scope. The meanings of
2595 ** the scopes are as follows:
2596 **
2597 ** LOCAL scope The object is only usable within the file in
2598 ** which it is declared.
2599 **
2600 ** library scope The object is visible and usable within other
2601 ** files in the same project. By if the project is
2602 ** a library, then the object is not visible to users
2603 ** of the library. (i.e. the object does not appear
2604 ** in the output when using the -H option.)
2605 **
2606 ** EXPORT scope The object is visible and usable everywhere.
2607 **
2608 ** The DP_Flag is a temporary use flag that is used during processing to
2609 ** prevent an infinite loop. It's use is localized.
2610 **
2611 ** The DP_Cplusplus, DP_ExternCReqd and DP_ExternReqd flags are permanent
2612 ** and are used to specify what type of declaration the object requires.
2613 */
2614 #define DP_Forward 0x001 /* Has a forward declaration in this file */
2615 #define DP_Declared 0x002 /* Has a full declaration in this file */
2616 #define DP_Export 0x004 /* Export this declaration */
2617 #define DP_Local 0x008 /* Declare in its home file only */
2618 #define DP_Flag 0x010 /* Use to mark a subset of a Decl list
2619 ** for special processing */
2620 #define DP_Cplusplus 0x020 /* Has C++ linkage and cannot appear in a
2621 ** C header file */
2622 #define DP_ExternCReqd 0x040 /* Prepend 'extern "C"' in a C++ header.
2623 ** Prepend nothing in a C header */
2624 #define DP_ExternReqd 0x080 /* Prepend 'extern "C"' in a C++ header if
2625 ** DP_Cplusplus is not also set. If DP_Cplusplus
2626 ** is set or this is a C header then
2627 ** prepend 'extern' */
2628
2629 /*
2630 ** Convenience macros for dealing with declaration properties
2631 */
2632 #define DeclHasProperty(D,P) (((D)->flags&(P))==(P))
2633 #define DeclHasAnyProperty(D,P) (((D)->flags&(P))!=0)
2634 #define DeclSetProperty(D,P) (D)->flags |= (P)
2635 #define DeclClearProperty(D,P) (D)->flags &= ~(P)
2636
2637 /*
2638 ** These are state properties of the parser. Each of the values is
2639 ** distinct from the DP_ values above so that both can be used in
2640 ** the same "flags" field.
2641 **
2642 ** Be careful not to confuse PS_Export with DP_Export or
2643 ** PS_Local with DP_Local. Their names are similar, but the meanings
2644 ** of these flags are very different.
2645 */
2646 #define PS_Extern 0x000800 /* "extern" has been seen */
2647 #define PS_Export 0x001000 /* If between "#if EXPORT_INTERFACE"
2648 ** and "#endif" */
2649 #define PS_Export2 0x002000 /* If "EXPORT" seen */
2650 #define PS_Typedef 0x004000 /* If "typedef" has been seen */
2651 #define PS_Static 0x008000 /* If "static" has been seen */
2652 #define PS_Interface 0x010000 /* If within #if INTERFACE..#endif */
2653 #define PS_Method 0x020000 /* If "::" token has been seen */
2654 #define PS_Local 0x040000 /* If within #if LOCAL_INTERFACE..#endif */
2655 #define PS_Local2 0x080000 /* If "LOCAL" seen. */
2656 #define PS_Public 0x100000 /* If "PUBLIC" seen. */
2657 #define PS_Protected 0x200000 /* If "PROTECTED" seen. */
2658 #define PS_Private 0x400000 /* If "PRIVATE" seen. */
2659 #define PS_PPP 0x700000 /* If any of PUBLIC, PRIVATE, PROTECTED */
2660
2661 /*
2662 ** The following set of flags are ORed into the "flags" field of
2663 ** a Decl in order to identify what type of object is being
2664 ** declared.
2665 */
2666 #define TY_Class 0x00100000
2667 #define TY_Subroutine 0x00200000
2668 #define TY_Macro 0x00400000
2669 #define TY_Typedef 0x00800000
2670 #define TY_Variable 0x01000000
2671 #define TY_Structure 0x02000000
2672 #define TY_Union 0x04000000
2673 #define TY_Enumeration 0x08000000
2674 #define TY_Defunct 0x10000000 /* Used to erase a declaration */
2675
2676 /*
2677 ** Each nested #if (or #ifdef or #ifndef) is stored in a stack of
2678 ** instances of the following structure.
2679 */
2680 typedef struct Ifmacro Ifmacro;
2681 struct Ifmacro {
2682 int nLine; /* Line number where this macro occurs */
2683 char *zCondition; /* Text of the condition for this macro */
2684 Ifmacro *pNext; /* Next down in the stack */
2685 int flags; /* Can hold PS_Export, PS_Interface or PS_Local flags */
2686 };
2687
2688 /*
2689 ** When parsing a file, we need to keep track of what other files have
2690 ** be #include-ed. For each #include found, we create an instance of
2691 ** the following structure.
2692 */
2693 typedef struct Include Include;
2694 struct Include {
2695 char *zFile; /* The name of file include. Includes "" or <> */
2696 char *zIf; /* If not NULL, #include should be enclosed in #if */
2697 char *zLabel; /* A unique label used to test if this #include has
2698 * appeared already in a file or not */
2699 Include *pNext; /* Previous include file, or NULL if this is the first */
2700 };
2701
2702 /*
2703 ** Identifiers found in a source file that might be used later to provoke
2704 ** the copying of a declaration into the corresponding header file are
2705 ** stored in a hash table as instances of the following structure.
2706 */
2707 typedef struct Ident Ident;
2708 struct Ident {
2709 char *zName; /* The text of this identifier */
2710 Ident *pCollide; /* Next identifier with the same hash */
2711 Ident *pNext; /* Next identifier in a list of them all */
2712 };
2713
2714 /*
2715 ** A complete table of identifiers is stored in an instance of
2716 ** the next structure.
2717 */
2718 #define IDENT_HASH_SIZE 2237
2719 typedef struct IdentTable IdentTable;
2720 struct IdentTable {
2721 Ident *pList; /* List of all identifiers in this table */
2722 Ident *apTable[IDENT_HASH_SIZE]; /* The hash table */
2723 };
2724
2725 /*
2726 ** The following structure holds all information for a single
2727 ** source file named on the command line of this program.
2728 */
2729 typedef struct InFile InFile;
2730 struct InFile {
2731 char *zSrc; /* Name of input file */
2732 char *zHdr; /* Name of the generated .h file for this input.
2733 ** Will be NULL if input is to be scanned only */
2734 int flags; /* One or more DP_, PS_ and/or TY_ flags */
2735 InFile *pNext; /* Next input file in the list of them all */
2736 IdentTable idTable; /* All identifiers in this input file */
2737 };
2738
2739 /*
2740 ** An unbounded string is able to grow without limit. We use these
2741 ** to construct large in-memory strings from lots of smaller components.
2742 */
2743 typedef struct String String;
2744 struct String {
2745 int nAlloc; /* Number of bytes allocated */
2746 int nUsed; /* Number of bytes used (not counting nul terminator) */
2747 char *zText; /* Text of the string */
2748 };
2749
2750 /*
2751 ** The following structure contains a lot of state information used
2752 ** while generating a .h file. We put the information in this structure
2753 ** and pass around a pointer to this structure, rather than pass around
2754 ** all of the information separately. This helps reduce the number of
2755 ** arguments to generator functions.
2756 */
2757 typedef struct GenState GenState;
2758 struct GenState {
2759 String *pStr; /* Write output to this string */
2760 IdentTable *pTable; /* A table holding the zLabel of every #include that
2761 * has already been generated. Used to avoid
2762
--- a/src/makeheaders.c
+++ b/src/makeheaders.c
@@ -1,2762 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D src/makeheaders.html
-1056
--- a/src/makeheaders.html
+++ b/src/makeheaders.html
@@ -1,1056 +0,0 @@
1
-<html>
2
-<head><title>The Makeheaders Program</title></head>
3
-<body bgcolor=white>
4
-<h1 align=center>The Makeheaders Program</h1>
5
-
6
-
7
-<p>
8
-This document describes <em>makeheaders</em>,
9
-a tool that automatically generates &#8220;<code>.h</code>&#8221;
10
-files for a C or C++ programming project.
11
-</p>
12
-
13
-
14
-<h2>Table Of Contents</h2>
15
-
16
-<ul>
17
-<li><a href="#H0002">1,0 Background</a>
18
-<ul>
19
-<li><a href="#H0003">1.1 Problems With The Traditional Approach</a>
20
-
21
-<li><a href="#H0004">1.2 The Makeheaders Solution</a>
22
-</ul>
23
-<li><a href="#H0005">2.0 Running The Makeheaders Program</a>
24
-
25
-<li><a href="#H0006">3.0 Preparing Source Files For Use With Makeheaders</a>
26
-<ul>
27
-<li><a href="#H0007">3.1 The Basic Setup</a>
28
-
29
-<li><a href="#H0008">3.2 What Declarations Get Copied</a>
30
-
31
-<li><a href="#H0009">3.3 How To Avoid Having To Write Any Header Files</a>
32
-
33
-<li><a href="#H0010">3.4 Designating Declarations For Export</a>
34
-
35
-<li><a href="#H0011">3.5 Local declarations processed by makeheaders</a>
36
-
37
-<li><a href="#H0012">3.6 Using Makeheaders With C++ Code</a>
38
-
39
-<li><a href="#H0013">3.7 Conditional Compilation</a>
40
-
41
-<li><a href="#H0014">3.8 Caveats</a>
42
-</ul>
43
-<li><a href="#H0015">4.0 Using Makeheaders To Generate Documentation</a>
44
-
45
-<li><a href="#H0016">5.0 Compiling The Makeheaders Program</a>
46
-
47
-<li><a href="#H0017">6.0 History</a>
48
-
49
-<li><a href="#H0018">7.0 Summary And Conclusion</a>
50
-</ul><a name="H0002"></a>
51
-<h2>1.0 Background</h2>
52
-
53
-<p>
54
-A piece of C source code can be one of two things:
55
-a <em>declaration</em> or a <em>definition</em>.
56
-A declaration is source text that gives information to the
57
-compiler but doesn't directly result in any code being generated.
58
-A definition is source text that results in executable machine
59
-instructions or initialization data.
60
-(These two terms are sometimes used inconsistently by other authors.
61
-In particular, many people reverse the meanings of these words when
62
-discussing Pascal or Ada code.
63
-The meanings described here are the same as used in the ANSI-C
64
-standards document.)
65
-</p>
66
-
67
-<p>
68
-Declarations in C include things such as the following:
69
-<ul>
70
-<li> Typedefs.
71
-<li> Structure, union and enumeration declarations.
72
-<li> Function and procedure prototypes.
73
-<li> Preprocessor macros and #defines.
74
-<li> &#8220;<code>extern</code>&#8221; variable declarations.
75
-</ul>
76
-</p>
77
-
78
-<p>
79
-Definitions in C, on the other hand, include these kinds of things:
80
-<ul>
81
-<li> Variable definitions.
82
-<li> The bodies of functions and procedures.
83
-<li> Initialization data.
84
-</ul>
85
-</p>
86
-
87
-<p>
88
-The distinction between a declaration and a definition is common in
89
-modern software engineering.
90
-Another way of looking at the difference is that the declaration
91
-is the <em>interface</em> and the definition is the <em>implementation</em>.
92
-</p>
93
-
94
-<p>
95
-In C programs, it has always been the tradition that declarations are
96
-put in files with the &#8220;<code>.h</code>&#8221; suffix and definitions are
97
-placed in &#8220;<code>.c</code>&#8221; files.
98
-The .c files contain &#8220;<code>#include</code>&#8221; preprocessor statements
99
-that cause the contents of .h files to be included as part of the
100
-source code when the .c file is compiled.
101
-In this way, the .h files define the interface to a subsystem and
102
-the .c files define how the subsystem is implemented.
103
-</p>
104
-
105
-<a name="H0003"></a>
106
-<h3>1.1 Problems With The Traditional Approach</h3>
107
-
108
-<p>
109
-As the art of computer programming continues to advance, and the size
110
-and complexity of programs continues to swell, the traditional C
111
-approach of placing declarations and definitions in separate files begins
112
-to present the programmer with logistics and
113
-maintenance problems.
114
-To wit:
115
-</p>
116
-
117
-<p>
118
-<ol>
119
-<p><li>
120
-In large codes with many source files, it becomes difficult to determine
121
-which .h files should be included in which .c files.
122
-<p><li>
123
-It is typically the case that a .h file will be forced to include
124
-another .h files, which in turn might include other .h files,
125
-and so forth.
126
-The .c file must be recompiled when any of the .h files in this chain
127
-are altered, but it can be difficult to determine what .h files are found
128
-in the include chain.
129
-A frequent Makefile error is to omit some .h files from a dependency
130
-list even though those files are on the include file chain.
131
-<p><li>
132
-Some information is common to both the declaration and the definition of
133
-an object in C, and so must be repeated in both the .h and the .c files
134
-for that object.
135
-In a large project, it can become increasingly difficult to keep the two
136
-files in sync.
137
-<p><li>
138
-When a .c file includes a .h file and the .h files changes, the .c file
139
-must be recompiled, even if the part of the .h file that changed is not
140
-actually used by the .c file.
141
-In a large program, it is generally the case that almost every .c file ends up
142
-depending on one or two of the more important .h files, and so when those .h
143
-files change, the entire program must be recompiled.
144
-It also happens that those important .h files tend to be the ones that
145
-change most frequently.
146
-This means that the entire program must be recompiled frequently,
147
-leading to a lengthy modify-compile-test cycle and a corresponding
148
-decrease in programmer productivity.
149
-<p><li>
150
-The C programming language requires that declarations depending upon
151
-each other must occur in a particular order.
152
-In a program with complex, interwoven data structures, the correct
153
-declaration order can become very difficult to determine manually,
154
-especially when the declarations involved are spread out over several
155
-files.
156
-</ol>
157
-</p>
158
-
159
-<a name="H0004"></a>
160
-<h3>1.2 The Makeheaders Solution</h3>
161
-
162
-<p>
163
-The makeheaders program is designed to ameliorate the problems associated
164
-with the traditional C programming model by automatically generating
165
-the interface information in the .h files from
166
-interface information contained in other .h files and
167
-from implementation information in the .c files.
168
-When the makeheaders program is run, it scans the source
169
-files for a project,
170
-then generates a series of new .h files, one for each .c file.
171
-The generated .h files contain exactly those declarations required by the
172
-corresponding .c files, no more and no less.
173
-</p>
174
-
175
-<p>
176
-The makeheaders programming model overcomes all of the objections to the
177
-traditional C programming model.
178
-<ol>
179
-<p><li>
180
-Because all declarations needed by a .c file are contained in a
181
-single .h file, there is never any question about what .h files
182
-a .c will need to include. If the .c file is named
183
-<code>alpha.c</code> then it must include only the single .h file
184
-named <code>alpha.h</code>.
185
-(The .c file might also use some include files from the standard
186
-library, such as <code>&lt;stdio.h&gt</code>, but that is another matter.)
187
-<p><li>
188
-The generated .h files do not include other .h files, and so there
189
-are no include chains to worry about.
190
-The file <code>alpha.c</code> depends on <code>alpha.h</code> and
191
-nothing more.
192
-<p><li>
193
-There is still duplication in the .h and the .c file, but because
194
-the duplicate information is automatically generated, it is no longer
195
-a problem.
196
-Simply rerun makeheaders to resynchronize everything.
197
-<p><li>
198
-The generated .h file contains the minimal set of declarations needed
199
-by the .c file.
200
-This means that when something changes, a minimal amount of recompilation
201
-is required to produce an updated executable.
202
-Experience has shown that this gives a dramatic improvement
203
-in programmer productivity by facilitating a rapid modify-compile-test
204
-cycle during development.
205
-<p><li>
206
-The makeheaders program automatically sorts declarations into the
207
-correct order, completely eliminating the wearisome and error-prone
208
-task of sorting declarations by hand.
209
-</ol>
210
-<p>
211
-
212
-<p>
213
-In addition, the makeheaders program is fast and unintrusive.
214
-It is a simple matter to incorporate makeheaders into a Makefile
215
-so that makeheaders will be run automatically whenever the project
216
-is rebuilt.
217
-And the burden of running makeheaders is light.
218
-It will easily process tens of thousands of lines of source
219
-code per second.
220
-</p>
221
-
222
-<a name="H0005"></a>
223
-<h2>2.0 Running The Makeheaders Program</h2>
224
-
225
-<p>
226
-The makeheaders program is very easy to run.
227
-If you have a collection of C source code and include files in the working
228
-directory, then you can run makeheaders to generate appropriate .h
229
-files using the following command:
230
-<pre>
231
- makeheaders *.[ch]
232
-</pre>
233
-That's really all there is to it!
234
-This command will generate one .h file for every .c file.
235
-Any .h files that were generated by a prior run of makeheaders
236
-are ignored,
237
-but manually entered .h files
238
-that contain structure declarations and so forth will be scanned and
239
-the declarations will be copied into the generated .h files as
240
-appropriate.
241
-But if makeheaders sees that the .h file that it has generated is no
242
-different from the .h file it generated last time, it doesn't update
243
-the file.
244
-This prevents the corresponding .c files from having to
245
-be needlessly recompiled.
246
-</p>
247
-
248
-<p>
249
-There are several options to the makeheaders program that can
250
-be used to alter its behavior.
251
-The default behavior is to write a single .h file for each .c file and
252
-to give the .h file the same base name as the .c file.
253
-Instead of generating a whole mess of .h files, you can, if you choose,
254
-generate a single big .h file that contains all declarations needed
255
-by all the .c files. Do this using the -h option to makeheaders.
256
-As follows:
257
-<pre>
258
- makeheaders -h *.[ch] >common.h
259
-</pre>
260
-With the -h option, the .h file is not actually written to a disk file but
261
-instead appears on standard output, where you are free to redirect it
262
-into the file of your choice.
263
-</p>
264
-
265
-<p>
266
-A similar option is -H. Like the lower-case -h option, big -H
267
-generates a single include file on standard output. But unlike
268
-small -h, the big -H only emits prototypes and declarations that
269
-have been designated as &#8220;exportable&#8221;.
270
-The idea is that -H will generate an include file that defines
271
-the interface to a library.
272
-More will be said about this in section 3.4.
273
-</p>
274
-
275
-<p>
276
-Sometimes you want the base name of the .c file and the .h file to
277
-be different.
278
-For example, suppose you want the include file for <code>alpha.c</code>
279
-to be called <code>beta.h</code>.
280
-In this case, you would invoke makeheaders as follows:
281
-<pre>
282
- makeheaders alpha.c:beta.h
283
-</pre>
284
-Any time a filename argument contains a colon, the name before the
285
-colon is taken to be the name of the .c file and the name after the
286
-colon is taken to be the name of the .h file.
287
-You can't use the shell's wildcard mechanism with this approach, but that
288
-normally isn't a problem in Makefiles, which is where this stuff
289
-comes in handy.
290
-</p>
291
-
292
-<p>
293
-If you want a particular file to be scanned by makeheaders but you
294
-don't want makeheaders to generate a header file for that file,
295
-then you can supply an empty header filename, like this:
296
-<pre>
297
- makeheaders alpha.c beta.c gamma.c:
298
-</pre>
299
-In this example, makeheaders will scan the three files named
300
-&#8220;<code>alpha.c</code>&#8221;,
301
-&#8220;<code>beta.c</code>&#8221; and
302
-&#8220;<code>gamma.c</code>&#8221;
303
-but because of the colon on the end of third filename
304
-it will only generate headers for the first two files.
305
-Unfortunately,
306
-it is not possible to get makeheaders to process any file whose
307
-name contains a colon.
308
-</p>
309
-
310
-<p>
311
-In a large project, the length of the command line for makeheaders
312
-can become very long.
313
-If the operating system doesn't support long command lines
314
-(example: DOS and Win32) you may not be able to list all of the
315
-input files in the space available.
316
-In that case, you can use the &#8220;<code>-f</code>&#8221; option followed
317
-by the name of a file to cause makeheaders to read command line
318
-options and filename from the file instead of from the command line.
319
-For example, you might prepare a file named &#8220;<code>mkhdr.dat</code>&#8221;
320
-that contains text like this:
321
-<pre>
322
- src/alpha.c:hdr/alpha.h
323
- src/beta.c:hdr/beta.h
324
- src/gamma.c:hdr/gamma.h
325
- ...
326
-</pre>
327
-Then invoke makeheaders as follows:
328
-<pre>
329
- makeheaders -f mkhdr.dat
330
-</pre>
331
-</p>
332
-
333
-<p>
334
-The &#8220;<code>-local</code>&#8221; option causes makeheaders to
335
-generate of prototypes for &#8220;<code>static</code>&#8221; functions and
336
-procedures.
337
-Such prototypes are normally omitted.
338
-</p>
339
-
340
-<p>
341
-Finally, makeheaders also includes a &#8220;<code>-doc</code>&#8221; option.
342
-This command line option prevents makeheaders from generating any
343
-headers at all.
344
-Instead, makeheaders will write to standard output
345
-information about every definition and declaration that it encounters
346
-in its scan of source files.
347
-The information output includes the type of the definition or
348
-declaration and any comment that precedes the definition or
349
-declaration.
350
-The output is in a format that can be easily parsed, and is
351
-intended to be read by another program that will generate
352
-documentation about the program.
353
-We'll talk more about this feature later.
354
-</p>
355
-
356
-<p>
357
-If you forget what command line options are available, or forget
358
-their exact name, you can invoke makeheaders using an unknown
359
-command line option (like &#8220;<code>--help</code>&#8221; or
360
-&#8220;<code>-?</code>&#8221;)
361
-and it will print a summary of the available options on standard
362
-error.
363
-If you need to process a file whose name begins with
364
-&#8220;<code>-</code>&#8221;,
365
-you can prepend a &#8220;<code>./</code>&#8221; to its name in order to get it
366
-accepted by the command line parser.
367
-Or, you can insert the special option &#8220;<code>--</code>&#8221; on the
368
-command line to cause all subsequent command line arguments to be treated as
369
-filenames even if their names begin with &#8220;<code>-</code>&#8221;.
370
-</p>
371
-
372
-<a name="H0006"></a>
373
-<h2>3.0 Preparing Source Files For Use With Makeheaders</h2>
374
-
375
-<p>
376
-Very little has to be done to prepare source files for use with
377
-makeheaders since makeheaders will read and understand ordinary
378
-C code.
379
-But it is important that you structure your files in a way that
380
-makes sense in the makeheaders context.
381
-This section will describe several typical uses of makeheaders.
382
-</p>
383
-
384
-<a name="H0007"></a>
385
-<h3>3.1 The Basic Setup</h3>
386
-
387
-<p>
388
-The simplest way to use makeheaders is to put all definitions in
389
-one or more .c files and all structure and type declarations in
390
-separate .h files.
391
-The only restriction is that you should take care to chose basenames
392
-for your .h files that are different from the basenames for your
393
-.c files.
394
-Recall that if your .c file is named (for example)
395
-&#8220;<code>alpha.c</code>&#8221;
396
-makeheaders will attempt to generate a corresponding header file
397
-named &#8220;<code>alpha.h</code>&#8221;.
398
-For that reason, you don't want to use that name for
399
-any of the .h files you write since that will prevent makeheaders
400
-from generating the .h file automatically.
401
-</p>
402
-
403
-<p>
404
-The structure of a .c file intended for use with makeheaders is very
405
-simple.
406
-All you have to do is add a single &#8220;<code>#include</code>&#8221; to the
407
-top of the file that sources the header file that makeheaders will generate.
408
-Hence, the beginning of a source file named &#8220;<code>alpha.c</code>&#8221;
409
-might look something like this:
410
-</p>
411
-
412
-<pre>
413
- /*
414
- * Introductory comment...
415
- */
416
- #include "alpha.h"
417
-
418
- /* The rest of your code... */
419
-</pre>
420
-
421
-<p>
422
-Your manually generated header files require no special attention at all.
423
-Code them as you normally would.
424
-However, makeheaders will work better if you omit the
425
-&#8220;<code>#if</code>&#8221; statements people often put around the outside of
426
-header files that prevent the files from being included more than once.
427
-For example, to create a header file named &#8220;<code>beta.h</code>&#8221;,
428
-many people will habitually write the following:
429
-
430
-<pre>
431
- #ifndef BETA_H
432
- #define BETA_H
433
-
434
- /* declarations for beta.h go here */
435
-
436
- #endif
437
-</pre>
438
-
439
-You can forego this cleverness with makeheaders.
440
-Remember that the header files you write will never really be
441
-included by any C code.
442
-Instead, makeheaders will scan your header files to extract only
443
-those declarations that are needed by individual .c files and then
444
-copy those declarations to the .h files corresponding to the .c files.
445
-Hence, the &#8220;<code>#if</code>&#8221; wrapper serves no useful purpose.
446
-But it does make makeheaders work harder, forcing it to put
447
-the statements
448
-
449
-<pre>
450
- #if !defined(BETA_H)
451
- #endif
452
-</pre>
453
-
454
-around every declaration that it copies out of your header file.
455
-No ill effect should come of this, but neither is there any benefit.
456
-</p>
457
-
458
-<p>
459
-Having prepared your .c and .h files as described above, you can
460
-cause makeheaders to generate its .h files using the following simple
461
-command:
462
-
463
-<pre>
464
- makeheaders *.[ch]
465
-</pre>
466
-
467
-The makeheaders program will scan all of the .c files and all of the
468
-manually written .h files and then automatically generate .h files
469
-corresponding to all .c files.
470
-</p>
471
-
472
-<p>
473
-Note that
474
-the wildcard expression used in the above example,
475
-&#8220;<code>*.[ch]</code>&#8221;,
476
-will expand to include all .h files in the current directory, both
477
-those entered manually be the programmer and others generated automatically
478
-by a prior run of makeheaders.
479
-But that is not a problem.
480
-The makeheaders program will recognize and ignore any files it
481
-has previously generated that show up on its input list.
482
-</p>
483
-
484
-<a name="H0008"></a>
485
-<h3>3.2 What Declarations Get Copied</h3>
486
-
487
-<p>
488
-The following list details all of the code constructs that makeheaders
489
-will extract and place in
490
-the automatically generated .h files:
491
-</p>
492
-
493
-<ul>
494
-<p><li>
495
-When a function is defined in any .c file, a prototype of that function
496
-is placed in the generated .h file of every .c file that
497
-calls the function.</p>
498
-
499
-<P>If the &#8220;<code>static</code>&#8221; keyword of C appears at the
500
-beginning of the function definition, the prototype is suppressed.
501
-If you use the &#8220;<code>LOCAL</code>&#8221; keyword where you would normally
502
-say &#8220;<code>static</code>&#8221;, then a prototype is generated, but it
503
-will only appear in the single header file that corresponds to the
504
-source file containing the function. For example, if the file
505
-<code>alpha.c</code> contains the following:
506
-<pre>
507
- LOCAL int testFunc(void){
508
- return 0;
509
- }
510
-</pre>
511
-Then the header file <code>alpha.h</code> will contain
512
-<pre>
513
- #define LOCAL static
514
- LOCAL int testFunc(void);
515
-</pre>
516
-However, no other generated header files will contain a prototype for
517
-<code>testFunc()</code> since the function has only file scope.</p>
518
-
519
-<p>When the &#8220;<code>LOCAL</code>&#8221; keyword is used, makeheaders will
520
-also generate a #define for LOCAL, like this:
521
-<pre>
522
- #define LOCAL static
523
-</pre>
524
-so that the C compiler will know what it means.</p>
525
-
526
-<p>If you invoke makeheaders with a &#8220;<code>-local</code>&#8221;
527
-command-line option, then it treats the&#8220;<code>static</code>&#8221;
528
-keyword like &#8220;<code>LOCAL</code>&#8221; and generates prototypes in the
529
-header file that corresponds to the source file containing the function
530
-definition.</p>
531
-
532
-<p><li>
533
-When a global variable is defined in a .c file, an
534
-&#8220;<code>extern</code>&#8221;
535
-declaration of that variable is placed in the header of every
536
-.c file that uses the variable.
537
-</p>
538
-
539
-<p><li>
540
-When a structure, union or enumeration declaration or a
541
-function prototype or a C++ class declaration appears in a
542
-manually produced .h file, that declaration is copied into the
543
-automatically generated
544
-.h files of all .c files that use the structure, union, enumeration,
545
-function or class.
546
-But declarations that appear in a
547
-.c file are considered private to that .c file and are not copied into
548
-any automatically generated files.
549
-</p>
550
-
551
-<p><li>
552
-All #defines and typedefs that appear in manually produced .h files
553
-are copied into automatically generated .h files as needed.
554
-Similar constructs that appear in .c files are considered private to
555
-those files and are not copied.
556
-</p>
557
-
558
-<p><li>
559
-When a structure, union or enumeration declaration appears in a .h
560
-file, makeheaders will automatically
561
-generate a typedef that allows the declaration to be referenced without
562
-the &#8220;<code>struct</code>&#8221;, &#8220;<code>union</code>&#8221; or
563
-&#8220;<code>enum</code>&#8221; qualifier.
564
-In other words, if makeheaders sees the code:
565
-<pre>
566
- struct Examp { /* ... */ };
567
-</pre>
568
-it will automatically generate a corresponding typedef like this:
569
-<pre>
570
- typedef struct Examp Examp;
571
-</pre>
572
-</p>
573
-
574
-<p><li>
575
-Makeheaders generates an error message if it encounters a function or
576
-variable definition within a .h file.
577
-The .h files are supposed to contain only interface, not implementation.
578
-C compilers will not enforce this convention, but makeheaders does.
579
-</ul>
580
-
581
-<p>
582
-As a final note, we observe that automatically generated declarations
583
-are ordered as required by the ANSI-C programming language.
584
-If the declaration of some structure &#8220;<code>X</code>&#8221; requires a
585
-prior declaration of another structure &#8220;<code>Y</code>&#8221;, then Y will
586
-appear first in the generated headers.
587
-</p>
588
-
589
-<a name="H0009"></a>
590
-<h3>3.3 How To Avoid Having To Write Any Header Files</h3>
591
-
592
-<p>
593
-In my experience, large projects work better if all of the manually
594
-written code is placed in .c files and all .h files are generated
595
-automatically.
596
-This is slightly different from the traditional C method of placing
597
-the interface in .h files and the implementation in .c files, but
598
-it is a refreshing change that brings a noticeable improvement to the
599
-coding experience.
600
-Others, I believe, share this view since I've
601
-noticed recent languages (ex: java, tcl, perl, awk) tend to
602
-support the one-file approach to coding as the only option.
603
-</p>
604
-
605
-<p>
606
-The makeheaders program supports putting both
607
-interface and implementation into the same source file.
608
-But you do have to tell makeheaders which part of the source file is the
609
-interface and which part is the implementation.
610
-Makeheaders has to know this in order to be able to figure out whether or
611
-not structures declarations, typedefs, #defines and so forth should
612
-be copied into the generated headers of other source files.
613
-</p>
614
-
615
-<p>
616
-You can instruct makeheaders to treat any part of a .c file as if
617
-it were a .h file by enclosing that part of the .c file within:
618
-<pre>
619
- #if INTERFACE
620
- #endif
621
-</pre>
622
-Thus any structure definitions that appear after the
623
-&#8220;<code>#if INTERFACE</code>&#8221; but before the corresponding
624
-&#8220;<code>#endif</code>&#8221; are eligible to be copied into the
625
-automatically generated
626
-.h files of other .c files.
627
-</p>
628
-
629
-<p>
630
-If you use the &#8220;<code>#if INTERFACE</code>&#8221; mechanism in a .c file,
631
-then the generated header for that .c file will contain a line
632
-like this:
633
-<pre>
634
- #define INTERFACE 0
635
-</pre>
636
-In other words, the C compiler will never see any of the text that
637
-defines the interface.
638
-But makeheaders will copy all necessary definitions and declarations
639
-into the .h file it generates, so .c files will compile as if the
640
-declarations were really there.
641
-This approach has the advantage that you don't have to worry with
642
-putting the declarations in the correct ANSI-C order -- makeheaders
643
-will do that for you automatically.
644
-</p>
645
-
646
-<p>
647
-Note that you don't have to use this approach exclusively.
648
-You can put some declarations in .h files and others within the
649
-&#8220;<code>#if INTERFACE</code>&#8221; regions of .c files.
650
-Makeheaders treats all declarations alike, no matter where they
651
-come from.
652
-You should also note that a single .c file can contain as many
653
-&#8220;<code>#if INTERFACE</code>&#8221; regions as desired.
654
-</p>
655
-
656
-<a name="H0010"></a>
657
-<h3>3.4 Designating Declarations For Export</h3>
658
-
659
-<p>
660
-In a large project, one will often construct a hierarchy of
661
-interfaces.
662
-For example, you may have a group of 20 or so files that form
663
-a library used in several other parts of the system.
664
-Each file in this library will present two interfaces.
665
-One interface will be the routines and data structures it is
666
-willing to share with other files in the same library, and the
667
-second interface is those routines and data structures it wishes
668
-to make available to other subsystems.
669
-(The second interface is normally a subset of the first.)
670
-Ordinary C does not provide support for a tiered interface
671
-like this, but makeheaders does.
672
-</p>
673
-
674
-<p>
675
-Using makeheaders, it is possible to designate routines and data
676
-structures as being for &#8220;<code>export</code>&#8221;.
677
-Exported objects are visible not only to other files within the
678
-same library or subassembly but also to other
679
-libraries and subassemblies in the larger program.
680
-By default, makeheaders only makes objects visible to other members
681
-of the same library.
682
-</p>
683
-
684
-<p>
685
-That isn't the complete truth, actually.
686
-The semantics of C are such that once an object becomes visible
687
-outside of a single source file, it is also visible to any user
688
-of the library that is made from the source file.
689
-Makeheaders can not prevent outsiders from using non-exported resources,
690
-but it can discourage the practice by refusing to provide prototypes
691
-and declarations for the services it does not want to export.
692
-Thus the only real effect of the making an object exportable is
693
-to include it in the output makeheaders generates when it is run
694
-using the -H command line option.
695
-This is not a perfect solution, but it works well in practice.
696
-</p>
697
-
698
-<p>
699
-But trouble quickly arises when we attempt to devise a mechanism for
700
-telling makeheaders which prototypes it should export and which it should
701
-keep local.
702
-The built-in &#8220;<code>static</code>&#8221; keyword of C works well for
703
-prohibiting prototypes from leaving a single source file, but because C doesn't
704
-support a linkage hierarchy, there is nothing in the C language to help us.
705
-We'll have to invite our own keyword: &#8220;<code>EXPORT</code>&#8221;
706
-</p>
707
-
708
-<p>
709
-Makeheaders allows the EXPORT keyword to precede any function or
710
-procedure definition.
711
-The routine following the EXPORT keyword is then eligable to appear
712
-in the header file generated using the -H command line option.
713
-Note that if a .c file contains the EXPORT keyword, makeheaders will
714
-put the macro
715
-<pre>
716
- #define EXPORT
717
-</pre>
718
-in the header file it generates for the .c file so that the EXPORT keyword
719
-will never be seen by the C compiler.
720
-</p>
721
-
722
-<p>
723
-But the EXPORT keyword only works for function and procedure definitions.
724
-For structure, union and enum definitions, typedefs, #defines and
725
-class declarations, a second mechanism is used.
726
-Just as any declarations or definition contained within
727
-<pre>
728
- #if INTERFACE
729
- #endif
730
-</pre>
731
-are visible to all files within the library, any declarations
732
-or definitions within
733
-<pre>
734
- #if EXPORT_INTERFACE
735
- #endif
736
-</pre>
737
-will become part of the exported interface.
738
-The &#8220;<code>#if EXPORT_INTERFACE</code>&#8221; mechanism can be used in
739
-either .c or .h files.
740
-(The &#8220;<code>#if INTERFACE</code>&#8221; can also be used in both .h and
741
-.c files, but since it's use in a .h file would be redundant, we haven't
742
-mentioned it before.)
743
-</p>
744
-
745
-<a name="H0011"></a>
746
-<h3>3.5 Local declarations processed by makeheaders</h3>
747
-
748
-<p>
749
-Structure declarations and typedefs that appear in .c files are normally
750
-ignored by makeheaders.
751
-Such declarations are only intended for use by the source file in which
752
-they appear and so makeheaders doesn't need to copy them into any
753
-generated header files.
754
-We call such declarations &#8220;<code>private</code>&#8221;.
755
-</p>
756
-
757
-<p>
758
-Sometimes it is convenient to have makeheaders sort a sequence
759
-of private declarations into the correct order for us automatically.
760
-Or, we could have static functions and procedures for which we would like
761
-makeheaders to generate prototypes, but the arguments to these
762
-functions and procedures uses private declarations.
763
-In both of these cases, we want makeheaders to be aware of the
764
-private declarations and copy them into the local header file,
765
-but we don't want makeheaders to propagate the
766
-declarations outside of the file in which they are declared.
767
-</p>
768
-
769
-<p>
770
-When this situation arises, enclose the private declarations
771
-within
772
-<pre>
773
- #if LOCAL_INTERFACE
774
- #endif
775
-</pre>
776
-A &#8220;<code>LOCAL_INTERFACE</code>&#8221; block works very much like the
777
-&#8220;<code>INTERFACE</code>&#8221; and
778
-&#8220;<code>EXPORT_INTERFACE</code>&#8221;
779
-blocks described above, except that makeheaders insures that the
780
-objects declared in a LOCAL_INTERFACE are only visible to the
781
-file containing the LOCAL_INTERFACE.
782
-</p>
783
-
784
-<a name="H0012"></a>
785
-<h3>3.6 Using Makeheaders With C++ Code</h3>
786
-
787
-<p>
788
-You can use makeheaders to generate header files for C++ code, in
789
-addition to C.
790
-Makeheaders will recognize and copy both &#8220;<code>class</code>&#8221;
791
-declarations
792
-and inline function definitions, and it knows not to try to generate
793
-prototypes for methods.
794
-</p>
795
-
796
-<p>
797
-In fact, makeheaders is smart enough to be used in projects that employ
798
-a mixture of C and C++.
799
-For example, if a C function is called from within a C++ code module,
800
-makeheaders will know to prepend the text
801
-<pre>
802
- extern "C"
803
-</pre>
804
-to the prototype for that function in the C++ header file.
805
-Going the other way,
806
-if you try to call a C++ function from within C, an
807
-appropriate error message is issued, since C++ routines can not
808
-normally be called by C code (due to fact that most C++ compilers
809
-use name mangling to facilitate type-safe linkage.)
810
-</p>
811
-
812
-<p>
813
-No special command-line options are required to use makeheaders with
814
-C++ input. Makeheaders will recognize that its source code is C++
815
-by the suffix on the source code filename. Simple ".c" or ".h" suffixes
816
-are assumed to be ANSI-C. Anything else, including ".cc", ".C" and
817
-".cpp" is assumed to be C++.
818
-The name of the header file generated by makeheaders is derived from
819
-the name of the source file by converting every "c" to "h" and
820
-every "C" to "H" in the suffix of the filename.
821
-Thus the C++ source
822
-file &#8220;<code>alpha.cpp</code>&#8221; will induce makeheaders to
823
-generate a header file named &#8220;<code>alpha.hpp</code>&#8221;.
824
-</p>
825
-
826
-<p>
827
-Makeheaders augments class definitions by inserting prototypes to
828
-methods where appropriate. If a method definition begins with one
829
-of the special keywords <b>PUBLIC</b>, <b>PROTECTED</b>, or
830
-<b>PRIVATE</b> (in upper-case to distinguish them from the regular
831
-C++ keywords with the same meaning) then a prototype for that
832
-method will be inserted into the class definition. If none of
833
-these keywords appear, then the prototype is not inserted. For
834
-example, in the following code, the constructor is not explicitly
835
-declared in the class definition but makeheaders will add it there
836
-because of the PUBLIC keyword that appears before the constructor
837
-definition.
838
-</p>
839
-
840
-<blockquote><pre>
841
-#if INTERFACE
842
-class Example1 {
843
-private:
844
- int v1;
845
-};
846
-#endif
847
-PUBLIC Example1::Example1(){
848
- v1 = 0;
849
-}
850
-</pre></blockquote>
851
-
852
-<p>
853
-The code above is equivalent to the following:
854
-</p>
855
-
856
-<blockquote><pre>
857
-#if INTERFACE
858
-class Example1 {
859
-private:
860
- int v1;
861
-public:
862
- Example1();
863
-};
864
-#endif
865
-Example1::Example1(){
866
- v1 = 0;
867
-}
868
-</pre></blockquote>
869
-
870
-<p>
871
-The first form is preferred because only a single declaration of
872
-the constructor is required. The second form requires two declarations,
873
-one in the class definition and one on the definition of the constructor.
874
-</p>
875
-
876
-<h4>3.6.1 C++ Limitations</h4>
877
-
878
-<p>
879
-Makeheaders does not understand more recent
880
-C++ syntax such as templates and namespaces.
881
-Perhaps these issues will be addressed in future revisions.
882
-</p>
883
-
884
-<a name="H0013"></a>
885
-<h3>3.7 Conditional Compilation</h3>
886
-
887
-<p>
888
-The makeheaders program understands and tracks the conditional
889
-compilation constructs in the source code files it scans.
890
-Hence, if the following code appears in a source file
891
-<pre>
892
- #ifdef UNIX
893
- # define WORKS_WELL 1
894
- #else
895
- # define WORKS_WELL 0
896
- #endif
897
-</pre>
898
-then the next patch of code will appear in the generated header for
899
-every .c file that uses the WORKS_WELL constant:
900
-<pre>
901
- #if defined(UNIX)
902
- # define WORKS_WELL 1
903
- #endif
904
- #if !defined(UNIX)
905
- # define WORKS_WELL 0
906
- #endif
907
-</pre>
908
-The conditional compilation constructs can be nested to any depth.
909
-Makeheaders also recognizes the special case of
910
-<pre>
911
- #if 0
912
- #endif
913
-</pre>
914
-and treats the enclosed text as a comment.
915
-</p>
916
-
917
-<a name="H0014"></a>
918
-<h3>3.8 Caveats</h3>
919
-
920
-<p>
921
-The makeheaders system is designed to be robust
922
-but it is possible for a devious programmer to fool the system,
923
-usually with unhelpful consequences.
924
-This subsection is a guide to helping you avoid trouble.
925
-</p>
926
-
927
-<p>
928
-Makeheaders does not understand the old K&amp;R style of function
929
-and procedure definitions.
930
-It only understands the modern ANSI-C style, and will probably
931
-become very confused if it encounters an old K&amp;R function.
932
-Therefore you should take care to avoid putting K&amp;R function definitions
933
-in your code.
934
-</p>
935
-
936
-<p>
937
-Makeheaders does not understand when you define more than one
938
-global variable with the same type separated by a comma.
939
-In other words, makeheaders does not understand this:
940
-<pre>
941
- int a = 4, b = 5;
942
-</pre>
943
-The makeheaders program wants every variable to have its own
944
-definition. Like this:
945
-<pre>
946
- int a = 4;
947
- int b = 5;
948
-</pre>
949
-Notice that this applies to global variables only, not to variables
950
-you declare inside your functions.
951
-Since global variables ought to be exceedingly rare, and since it is
952
-good style to declare them separately anyhow, this restriction is
953
-not seen as a terrible hardship.
954
-</p>
955
-
956
-<p>
957
-Makeheaders does not support defining an enumerated or aggregate type in
958
-the same statement as a variable declaration. None of the following
959
-statements work completely:
960
-<pre>
961
-struct {int field;} a;
962
-struct Tag {int field;} b;
963
-struct Tag c;
964
-</pre>
965
-Instead, define types separately from variables:
966
-<pre>
967
-#if INTERFACE
968
-struct Tag {int field;};
969
-#endif
970
-Tag a;
971
-Tag b; /* No more than one variable per declaration. */
972
-Tag c; /* So must put each on its own line. */
973
-</pre>
974
-See <a href="#H0008">3.2 What Declarations Get Copied</a> for details,
975
-including on the automatic typedef.
976
-</p>
977
-
978
-<p>
979
-The makeheaders program processes its source file prior to sending
980
-those files through the C preprocessor.
981
-Hence, if you hide important structure information in preprocessor defines,
982
-makeheaders might not be able to successfully extract the information
983
-it needs from variables, functions and procedure definitions.
984
-For example, if you write this:
985
-<pre>
986
- #define BEGIN {
987
- #define END }
988
-</pre>
989
-at the beginning of your source file, and then try to create a function
990
-definition like this:
991
-<pre>
992
- char *StrDup(const char *zSrc)
993
- BEGIN
994
- /* Code here */
995
- END
996
-</pre>
997
-then makeheaders won't be able to find the end of the function definition
998
-and bad things are likely to happen.
999
-</p>
1000
-
1001
-<p>
1002
-For most projects the code constructs that makeheaders cannot
1003
-handle are very rare.
1004
-As long as you avoid excessive cleverness, makeheaders will
1005
-probably be able to figure out what you want and will do the right
1006
-thing.
1007
-</p>
1008
-
1009
-<p>
1010
-Makeheaders has limited understanding of enums. In particular, it does
1011
-not realize the significance of enumerated values, so the enum is not
1012
-emitted in the header files when its enumerated values are used unless
1013
-the name associated with the enum is also used. Moreover, enums can be
1014
-completely anonymous, e.g. &#8220;<code>enum {X, Y, Z};</code>&#8221;.
1015
-Makeheaders ignores such enums so they can at least be used within a
1016
-single source file. Makeheaders expects you to use #define constants
1017
-instead. If you want enum features that #define lacks, and you need the
1018
-enum in the interface, bypass makeheaders and write a header file by
1019
-hand, or teach makeheaders to emit the enum definition when any of the
1020
-enumerated values are used, rather than only when the top-level name (if
1021
-any) is used.
1022
-</p>
1023
-
1024
-<a name="H0015"></a>
1025
-<h2>4.0 Using Makeheaders To Generate Documentation</h2>
1026
-
1027
-<p>
1028
-Many people have observed the advantages of generating program
1029
-documentation directly from the source code:
1030
-<ul>
1031
-<li> Less effort is involved. It is easier to write a program than
1032
- it is to write a program and a document.
1033
-<li> The documentation is more likely to agree with the code.
1034
- When documentation is derived directly from the code, or is
1035
- contained in comments immediately adjacent to the code, it is much
1036
- more likely to be correct than if it is contained in a separate
1037
- unrelated file in a different part of the source tree.
1038
-<li> Information is kept in only one place. When a change occurs
1039
- in the code, it is not necessary to make a corresponding change
1040
- in a separate document. Just rerun the documentation generator.
1041
-</ul>
1042
-The makeheaders program does not generate program documentation itself.
1043
-But you can use makeheaders to parse the program source code, extract
1044
-the information that is relevant to the documentation and to pass this
1045
-information to another tool to do the actual documentation preparation.
1046
-</p>
1047
-
1048
-<p>
1049
-When makeheaders is run with the &#8220;<code>-doc</code>&#8221; option, it
1050
-emits no header files at all.
1051
-Instead, it does a complete dump of its internal tables to standard
1052
-output in a form that is easily parsed.
1053
-This output can then be used by another program (the implementation
1054
-of which is left as an exercise to the reader) that will use the
1055
-information to prepare suitable documentation.
1056
-</p>
--- a/src/makeheaders.html
+++ b/src/makeheaders.html
@@ -1,1056 +0,0 @@
1 <html>
2 <head><title>The Makeheaders Program</title></head>
3 <body bgcolor=white>
4 <h1 align=center>The Makeheaders Program</h1>
5
6
7 <p>
8 This document describes <em>makeheaders</em>,
9 a tool that automatically generates &#8220;<code>.h</code>&#8221;
10 files for a C or C++ programming project.
11 </p>
12
13
14 <h2>Table Of Contents</h2>
15
16 <ul>
17 <li><a href="#H0002">1,0 Background</a>
18 <ul>
19 <li><a href="#H0003">1.1 Problems With The Traditional Approach</a>
20
21 <li><a href="#H0004">1.2 The Makeheaders Solution</a>
22 </ul>
23 <li><a href="#H0005">2.0 Running The Makeheaders Program</a>
24
25 <li><a href="#H0006">3.0 Preparing Source Files For Use With Makeheaders</a>
26 <ul>
27 <li><a href="#H0007">3.1 The Basic Setup</a>
28
29 <li><a href="#H0008">3.2 What Declarations Get Copied</a>
30
31 <li><a href="#H0009">3.3 How To Avoid Having To Write Any Header Files</a>
32
33 <li><a href="#H0010">3.4 Designating Declarations For Export</a>
34
35 <li><a href="#H0011">3.5 Local declarations processed by makeheaders</a>
36
37 <li><a href="#H0012">3.6 Using Makeheaders With C++ Code</a>
38
39 <li><a href="#H0013">3.7 Conditional Compilation</a>
40
41 <li><a href="#H0014">3.8 Caveats</a>
42 </ul>
43 <li><a href="#H0015">4.0 Using Makeheaders To Generate Documentation</a>
44
45 <li><a href="#H0016">5.0 Compiling The Makeheaders Program</a>
46
47 <li><a href="#H0017">6.0 History</a>
48
49 <li><a href="#H0018">7.0 Summary And Conclusion</a>
50 </ul><a name="H0002"></a>
51 <h2>1.0 Background</h2>
52
53 <p>
54 A piece of C source code can be one of two things:
55 a <em>declaration</em> or a <em>definition</em>.
56 A declaration is source text that gives information to the
57 compiler but doesn't directly result in any code being generated.
58 A definition is source text that results in executable machine
59 instructions or initialization data.
60 (These two terms are sometimes used inconsistently by other authors.
61 In particular, many people reverse the meanings of these words when
62 discussing Pascal or Ada code.
63 The meanings described here are the same as used in the ANSI-C
64 standards document.)
65 </p>
66
67 <p>
68 Declarations in C include things such as the following:
69 <ul>
70 <li> Typedefs.
71 <li> Structure, union and enumeration declarations.
72 <li> Function and procedure prototypes.
73 <li> Preprocessor macros and #defines.
74 <li> &#8220;<code>extern</code>&#8221; variable declarations.
75 </ul>
76 </p>
77
78 <p>
79 Definitions in C, on the other hand, include these kinds of things:
80 <ul>
81 <li> Variable definitions.
82 <li> The bodies of functions and procedures.
83 <li> Initialization data.
84 </ul>
85 </p>
86
87 <p>
88 The distinction between a declaration and a definition is common in
89 modern software engineering.
90 Another way of looking at the difference is that the declaration
91 is the <em>interface</em> and the definition is the <em>implementation</em>.
92 </p>
93
94 <p>
95 In C programs, it has always been the tradition that declarations are
96 put in files with the &#8220;<code>.h</code>&#8221; suffix and definitions are
97 placed in &#8220;<code>.c</code>&#8221; files.
98 The .c files contain &#8220;<code>#include</code>&#8221; preprocessor statements
99 that cause the contents of .h files to be included as part of the
100 source code when the .c file is compiled.
101 In this way, the .h files define the interface to a subsystem and
102 the .c files define how the subsystem is implemented.
103 </p>
104
105 <a name="H0003"></a>
106 <h3>1.1 Problems With The Traditional Approach</h3>
107
108 <p>
109 As the art of computer programming continues to advance, and the size
110 and complexity of programs continues to swell, the traditional C
111 approach of placing declarations and definitions in separate files begins
112 to present the programmer with logistics and
113 maintenance problems.
114 To wit:
115 </p>
116
117 <p>
118 <ol>
119 <p><li>
120 In large codes with many source files, it becomes difficult to determine
121 which .h files should be included in which .c files.
122 <p><li>
123 It is typically the case that a .h file will be forced to include
124 another .h files, which in turn might include other .h files,
125 and so forth.
126 The .c file must be recompiled when any of the .h files in this chain
127 are altered, but it can be difficult to determine what .h files are found
128 in the include chain.
129 A frequent Makefile error is to omit some .h files from a dependency
130 list even though those files are on the include file chain.
131 <p><li>
132 Some information is common to both the declaration and the definition of
133 an object in C, and so must be repeated in both the .h and the .c files
134 for that object.
135 In a large project, it can become increasingly difficult to keep the two
136 files in sync.
137 <p><li>
138 When a .c file includes a .h file and the .h files changes, the .c file
139 must be recompiled, even if the part of the .h file that changed is not
140 actually used by the .c file.
141 In a large program, it is generally the case that almost every .c file ends up
142 depending on one or two of the more important .h files, and so when those .h
143 files change, the entire program must be recompiled.
144 It also happens that those important .h files tend to be the ones that
145 change most frequently.
146 This means that the entire program must be recompiled frequently,
147 leading to a lengthy modify-compile-test cycle and a corresponding
148 decrease in programmer productivity.
149 <p><li>
150 The C programming language requires that declarations depending upon
151 each other must occur in a particular order.
152 In a program with complex, interwoven data structures, the correct
153 declaration order can become very difficult to determine manually,
154 especially when the declarations involved are spread out over several
155 files.
156 </ol>
157 </p>
158
159 <a name="H0004"></a>
160 <h3>1.2 The Makeheaders Solution</h3>
161
162 <p>
163 The makeheaders program is designed to ameliorate the problems associated
164 with the traditional C programming model by automatically generating
165 the interface information in the .h files from
166 interface information contained in other .h files and
167 from implementation information in the .c files.
168 When the makeheaders program is run, it scans the source
169 files for a project,
170 then generates a series of new .h files, one for each .c file.
171 The generated .h files contain exactly those declarations required by the
172 corresponding .c files, no more and no less.
173 </p>
174
175 <p>
176 The makeheaders programming model overcomes all of the objections to the
177 traditional C programming model.
178 <ol>
179 <p><li>
180 Because all declarations needed by a .c file are contained in a
181 single .h file, there is never any question about what .h files
182 a .c will need to include. If the .c file is named
183 <code>alpha.c</code> then it must include only the single .h file
184 named <code>alpha.h</code>.
185 (The .c file might also use some include files from the standard
186 library, such as <code>&lt;stdio.h&gt</code>, but that is another matter.)
187 <p><li>
188 The generated .h files do not include other .h files, and so there
189 are no include chains to worry about.
190 The file <code>alpha.c</code> depends on <code>alpha.h</code> and
191 nothing more.
192 <p><li>
193 There is still duplication in the .h and the .c file, but because
194 the duplicate information is automatically generated, it is no longer
195 a problem.
196 Simply rerun makeheaders to resynchronize everything.
197 <p><li>
198 The generated .h file contains the minimal set of declarations needed
199 by the .c file.
200 This means that when something changes, a minimal amount of recompilation
201 is required to produce an updated executable.
202 Experience has shown that this gives a dramatic improvement
203 in programmer productivity by facilitating a rapid modify-compile-test
204 cycle during development.
205 <p><li>
206 The makeheaders program automatically sorts declarations into the
207 correct order, completely eliminating the wearisome and error-prone
208 task of sorting declarations by hand.
209 </ol>
210 <p>
211
212 <p>
213 In addition, the makeheaders program is fast and unintrusive.
214 It is a simple matter to incorporate makeheaders into a Makefile
215 so that makeheaders will be run automatically whenever the project
216 is rebuilt.
217 And the burden of running makeheaders is light.
218 It will easily process tens of thousands of lines of source
219 code per second.
220 </p>
221
222 <a name="H0005"></a>
223 <h2>2.0 Running The Makeheaders Program</h2>
224
225 <p>
226 The makeheaders program is very easy to run.
227 If you have a collection of C source code and include files in the working
228 directory, then you can run makeheaders to generate appropriate .h
229 files using the following command:
230 <pre>
231 makeheaders *.[ch]
232 </pre>
233 That's really all there is to it!
234 This command will generate one .h file for every .c file.
235 Any .h files that were generated by a prior run of makeheaders
236 are ignored,
237 but manually entered .h files
238 that contain structure declarations and so forth will be scanned and
239 the declarations will be copied into the generated .h files as
240 appropriate.
241 But if makeheaders sees that the .h file that it has generated is no
242 different from the .h file it generated last time, it doesn't update
243 the file.
244 This prevents the corresponding .c files from having to
245 be needlessly recompiled.
246 </p>
247
248 <p>
249 There are several options to the makeheaders program that can
250 be used to alter its behavior.
251 The default behavior is to write a single .h file for each .c file and
252 to give the .h file the same base name as the .c file.
253 Instead of generating a whole mess of .h files, you can, if you choose,
254 generate a single big .h file that contains all declarations needed
255 by all the .c files. Do this using the -h option to makeheaders.
256 As follows:
257 <pre>
258 makeheaders -h *.[ch] >common.h
259 </pre>
260 With the -h option, the .h file is not actually written to a disk file but
261 instead appears on standard output, where you are free to redirect it
262 into the file of your choice.
263 </p>
264
265 <p>
266 A similar option is -H. Like the lower-case -h option, big -H
267 generates a single include file on standard output. But unlike
268 small -h, the big -H only emits prototypes and declarations that
269 have been designated as &#8220;exportable&#8221;.
270 The idea is that -H will generate an include file that defines
271 the interface to a library.
272 More will be said about this in section 3.4.
273 </p>
274
275 <p>
276 Sometimes you want the base name of the .c file and the .h file to
277 be different.
278 For example, suppose you want the include file for <code>alpha.c</code>
279 to be called <code>beta.h</code>.
280 In this case, you would invoke makeheaders as follows:
281 <pre>
282 makeheaders alpha.c:beta.h
283 </pre>
284 Any time a filename argument contains a colon, the name before the
285 colon is taken to be the name of the .c file and the name after the
286 colon is taken to be the name of the .h file.
287 You can't use the shell's wildcard mechanism with this approach, but that
288 normally isn't a problem in Makefiles, which is where this stuff
289 comes in handy.
290 </p>
291
292 <p>
293 If you want a particular file to be scanned by makeheaders but you
294 don't want makeheaders to generate a header file for that file,
295 then you can supply an empty header filename, like this:
296 <pre>
297 makeheaders alpha.c beta.c gamma.c:
298 </pre>
299 In this example, makeheaders will scan the three files named
300 &#8220;<code>alpha.c</code>&#8221;,
301 &#8220;<code>beta.c</code>&#8221; and
302 &#8220;<code>gamma.c</code>&#8221;
303 but because of the colon on the end of third filename
304 it will only generate headers for the first two files.
305 Unfortunately,
306 it is not possible to get makeheaders to process any file whose
307 name contains a colon.
308 </p>
309
310 <p>
311 In a large project, the length of the command line for makeheaders
312 can become very long.
313 If the operating system doesn't support long command lines
314 (example: DOS and Win32) you may not be able to list all of the
315 input files in the space available.
316 In that case, you can use the &#8220;<code>-f</code>&#8221; option followed
317 by the name of a file to cause makeheaders to read command line
318 options and filename from the file instead of from the command line.
319 For example, you might prepare a file named &#8220;<code>mkhdr.dat</code>&#8221;
320 that contains text like this:
321 <pre>
322 src/alpha.c:hdr/alpha.h
323 src/beta.c:hdr/beta.h
324 src/gamma.c:hdr/gamma.h
325 ...
326 </pre>
327 Then invoke makeheaders as follows:
328 <pre>
329 makeheaders -f mkhdr.dat
330 </pre>
331 </p>
332
333 <p>
334 The &#8220;<code>-local</code>&#8221; option causes makeheaders to
335 generate of prototypes for &#8220;<code>static</code>&#8221; functions and
336 procedures.
337 Such prototypes are normally omitted.
338 </p>
339
340 <p>
341 Finally, makeheaders also includes a &#8220;<code>-doc</code>&#8221; option.
342 This command line option prevents makeheaders from generating any
343 headers at all.
344 Instead, makeheaders will write to standard output
345 information about every definition and declaration that it encounters
346 in its scan of source files.
347 The information output includes the type of the definition or
348 declaration and any comment that precedes the definition or
349 declaration.
350 The output is in a format that can be easily parsed, and is
351 intended to be read by another program that will generate
352 documentation about the program.
353 We'll talk more about this feature later.
354 </p>
355
356 <p>
357 If you forget what command line options are available, or forget
358 their exact name, you can invoke makeheaders using an unknown
359 command line option (like &#8220;<code>--help</code>&#8221; or
360 &#8220;<code>-?</code>&#8221;)
361 and it will print a summary of the available options on standard
362 error.
363 If you need to process a file whose name begins with
364 &#8220;<code>-</code>&#8221;,
365 you can prepend a &#8220;<code>./</code>&#8221; to its name in order to get it
366 accepted by the command line parser.
367 Or, you can insert the special option &#8220;<code>--</code>&#8221; on the
368 command line to cause all subsequent command line arguments to be treated as
369 filenames even if their names begin with &#8220;<code>-</code>&#8221;.
370 </p>
371
372 <a name="H0006"></a>
373 <h2>3.0 Preparing Source Files For Use With Makeheaders</h2>
374
375 <p>
376 Very little has to be done to prepare source files for use with
377 makeheaders since makeheaders will read and understand ordinary
378 C code.
379 But it is important that you structure your files in a way that
380 makes sense in the makeheaders context.
381 This section will describe several typical uses of makeheaders.
382 </p>
383
384 <a name="H0007"></a>
385 <h3>3.1 The Basic Setup</h3>
386
387 <p>
388 The simplest way to use makeheaders is to put all definitions in
389 one or more .c files and all structure and type declarations in
390 separate .h files.
391 The only restriction is that you should take care to chose basenames
392 for your .h files that are different from the basenames for your
393 .c files.
394 Recall that if your .c file is named (for example)
395 &#8220;<code>alpha.c</code>&#8221;
396 makeheaders will attempt to generate a corresponding header file
397 named &#8220;<code>alpha.h</code>&#8221;.
398 For that reason, you don't want to use that name for
399 any of the .h files you write since that will prevent makeheaders
400 from generating the .h file automatically.
401 </p>
402
403 <p>
404 The structure of a .c file intended for use with makeheaders is very
405 simple.
406 All you have to do is add a single &#8220;<code>#include</code>&#8221; to the
407 top of the file that sources the header file that makeheaders will generate.
408 Hence, the beginning of a source file named &#8220;<code>alpha.c</code>&#8221;
409 might look something like this:
410 </p>
411
412 <pre>
413 /*
414 * Introductory comment...
415 */
416 #include "alpha.h"
417
418 /* The rest of your code... */
419 </pre>
420
421 <p>
422 Your manually generated header files require no special attention at all.
423 Code them as you normally would.
424 However, makeheaders will work better if you omit the
425 &#8220;<code>#if</code>&#8221; statements people often put around the outside of
426 header files that prevent the files from being included more than once.
427 For example, to create a header file named &#8220;<code>beta.h</code>&#8221;,
428 many people will habitually write the following:
429
430 <pre>
431 #ifndef BETA_H
432 #define BETA_H
433
434 /* declarations for beta.h go here */
435
436 #endif
437 </pre>
438
439 You can forego this cleverness with makeheaders.
440 Remember that the header files you write will never really be
441 included by any C code.
442 Instead, makeheaders will scan your header files to extract only
443 those declarations that are needed by individual .c files and then
444 copy those declarations to the .h files corresponding to the .c files.
445 Hence, the &#8220;<code>#if</code>&#8221; wrapper serves no useful purpose.
446 But it does make makeheaders work harder, forcing it to put
447 the statements
448
449 <pre>
450 #if !defined(BETA_H)
451 #endif
452 </pre>
453
454 around every declaration that it copies out of your header file.
455 No ill effect should come of this, but neither is there any benefit.
456 </p>
457
458 <p>
459 Having prepared your .c and .h files as described above, you can
460 cause makeheaders to generate its .h files using the following simple
461 command:
462
463 <pre>
464 makeheaders *.[ch]
465 </pre>
466
467 The makeheaders program will scan all of the .c files and all of the
468 manually written .h files and then automatically generate .h files
469 corresponding to all .c files.
470 </p>
471
472 <p>
473 Note that
474 the wildcard expression used in the above example,
475 &#8220;<code>*.[ch]</code>&#8221;,
476 will expand to include all .h files in the current directory, both
477 those entered manually be the programmer and others generated automatically
478 by a prior run of makeheaders.
479 But that is not a problem.
480 The makeheaders program will recognize and ignore any files it
481 has previously generated that show up on its input list.
482 </p>
483
484 <a name="H0008"></a>
485 <h3>3.2 What Declarations Get Copied</h3>
486
487 <p>
488 The following list details all of the code constructs that makeheaders
489 will extract and place in
490 the automatically generated .h files:
491 </p>
492
493 <ul>
494 <p><li>
495 When a function is defined in any .c file, a prototype of that function
496 is placed in the generated .h file of every .c file that
497 calls the function.</p>
498
499 <P>If the &#8220;<code>static</code>&#8221; keyword of C appears at the
500 beginning of the function definition, the prototype is suppressed.
501 If you use the &#8220;<code>LOCAL</code>&#8221; keyword where you would normally
502 say &#8220;<code>static</code>&#8221;, then a prototype is generated, but it
503 will only appear in the single header file that corresponds to the
504 source file containing the function. For example, if the file
505 <code>alpha.c</code> contains the following:
506 <pre>
507 LOCAL int testFunc(void){
508 return 0;
509 }
510 </pre>
511 Then the header file <code>alpha.h</code> will contain
512 <pre>
513 #define LOCAL static
514 LOCAL int testFunc(void);
515 </pre>
516 However, no other generated header files will contain a prototype for
517 <code>testFunc()</code> since the function has only file scope.</p>
518
519 <p>When the &#8220;<code>LOCAL</code>&#8221; keyword is used, makeheaders will
520 also generate a #define for LOCAL, like this:
521 <pre>
522 #define LOCAL static
523 </pre>
524 so that the C compiler will know what it means.</p>
525
526 <p>If you invoke makeheaders with a &#8220;<code>-local</code>&#8221;
527 command-line option, then it treats the&#8220;<code>static</code>&#8221;
528 keyword like &#8220;<code>LOCAL</code>&#8221; and generates prototypes in the
529 header file that corresponds to the source file containing the function
530 definition.</p>
531
532 <p><li>
533 When a global variable is defined in a .c file, an
534 &#8220;<code>extern</code>&#8221;
535 declaration of that variable is placed in the header of every
536 .c file that uses the variable.
537 </p>
538
539 <p><li>
540 When a structure, union or enumeration declaration or a
541 function prototype or a C++ class declaration appears in a
542 manually produced .h file, that declaration is copied into the
543 automatically generated
544 .h files of all .c files that use the structure, union, enumeration,
545 function or class.
546 But declarations that appear in a
547 .c file are considered private to that .c file and are not copied into
548 any automatically generated files.
549 </p>
550
551 <p><li>
552 All #defines and typedefs that appear in manually produced .h files
553 are copied into automatically generated .h files as needed.
554 Similar constructs that appear in .c files are considered private to
555 those files and are not copied.
556 </p>
557
558 <p><li>
559 When a structure, union or enumeration declaration appears in a .h
560 file, makeheaders will automatically
561 generate a typedef that allows the declaration to be referenced without
562 the &#8220;<code>struct</code>&#8221;, &#8220;<code>union</code>&#8221; or
563 &#8220;<code>enum</code>&#8221; qualifier.
564 In other words, if makeheaders sees the code:
565 <pre>
566 struct Examp { /* ... */ };
567 </pre>
568 it will automatically generate a corresponding typedef like this:
569 <pre>
570 typedef struct Examp Examp;
571 </pre>
572 </p>
573
574 <p><li>
575 Makeheaders generates an error message if it encounters a function or
576 variable definition within a .h file.
577 The .h files are supposed to contain only interface, not implementation.
578 C compilers will not enforce this convention, but makeheaders does.
579 </ul>
580
581 <p>
582 As a final note, we observe that automatically generated declarations
583 are ordered as required by the ANSI-C programming language.
584 If the declaration of some structure &#8220;<code>X</code>&#8221; requires a
585 prior declaration of another structure &#8220;<code>Y</code>&#8221;, then Y will
586 appear first in the generated headers.
587 </p>
588
589 <a name="H0009"></a>
590 <h3>3.3 How To Avoid Having To Write Any Header Files</h3>
591
592 <p>
593 In my experience, large projects work better if all of the manually
594 written code is placed in .c files and all .h files are generated
595 automatically.
596 This is slightly different from the traditional C method of placing
597 the interface in .h files and the implementation in .c files, but
598 it is a refreshing change that brings a noticeable improvement to the
599 coding experience.
600 Others, I believe, share this view since I've
601 noticed recent languages (ex: java, tcl, perl, awk) tend to
602 support the one-file approach to coding as the only option.
603 </p>
604
605 <p>
606 The makeheaders program supports putting both
607 interface and implementation into the same source file.
608 But you do have to tell makeheaders which part of the source file is the
609 interface and which part is the implementation.
610 Makeheaders has to know this in order to be able to figure out whether or
611 not structures declarations, typedefs, #defines and so forth should
612 be copied into the generated headers of other source files.
613 </p>
614
615 <p>
616 You can instruct makeheaders to treat any part of a .c file as if
617 it were a .h file by enclosing that part of the .c file within:
618 <pre>
619 #if INTERFACE
620 #endif
621 </pre>
622 Thus any structure definitions that appear after the
623 &#8220;<code>#if INTERFACE</code>&#8221; but before the corresponding
624 &#8220;<code>#endif</code>&#8221; are eligible to be copied into the
625 automatically generated
626 .h files of other .c files.
627 </p>
628
629 <p>
630 If you use the &#8220;<code>#if INTERFACE</code>&#8221; mechanism in a .c file,
631 then the generated header for that .c file will contain a line
632 like this:
633 <pre>
634 #define INTERFACE 0
635 </pre>
636 In other words, the C compiler will never see any of the text that
637 defines the interface.
638 But makeheaders will copy all necessary definitions and declarations
639 into the .h file it generates, so .c files will compile as if the
640 declarations were really there.
641 This approach has the advantage that you don't have to worry with
642 putting the declarations in the correct ANSI-C order -- makeheaders
643 will do that for you automatically.
644 </p>
645
646 <p>
647 Note that you don't have to use this approach exclusively.
648 You can put some declarations in .h files and others within the
649 &#8220;<code>#if INTERFACE</code>&#8221; regions of .c files.
650 Makeheaders treats all declarations alike, no matter where they
651 come from.
652 You should also note that a single .c file can contain as many
653 &#8220;<code>#if INTERFACE</code>&#8221; regions as desired.
654 </p>
655
656 <a name="H0010"></a>
657 <h3>3.4 Designating Declarations For Export</h3>
658
659 <p>
660 In a large project, one will often construct a hierarchy of
661 interfaces.
662 For example, you may have a group of 20 or so files that form
663 a library used in several other parts of the system.
664 Each file in this library will present two interfaces.
665 One interface will be the routines and data structures it is
666 willing to share with other files in the same library, and the
667 second interface is those routines and data structures it wishes
668 to make available to other subsystems.
669 (The second interface is normally a subset of the first.)
670 Ordinary C does not provide support for a tiered interface
671 like this, but makeheaders does.
672 </p>
673
674 <p>
675 Using makeheaders, it is possible to designate routines and data
676 structures as being for &#8220;<code>export</code>&#8221;.
677 Exported objects are visible not only to other files within the
678 same library or subassembly but also to other
679 libraries and subassemblies in the larger program.
680 By default, makeheaders only makes objects visible to other members
681 of the same library.
682 </p>
683
684 <p>
685 That isn't the complete truth, actually.
686 The semantics of C are such that once an object becomes visible
687 outside of a single source file, it is also visible to any user
688 of the library that is made from the source file.
689 Makeheaders can not prevent outsiders from using non-exported resources,
690 but it can discourage the practice by refusing to provide prototypes
691 and declarations for the services it does not want to export.
692 Thus the only real effect of the making an object exportable is
693 to include it in the output makeheaders generates when it is run
694 using the -H command line option.
695 This is not a perfect solution, but it works well in practice.
696 </p>
697
698 <p>
699 But trouble quickly arises when we attempt to devise a mechanism for
700 telling makeheaders which prototypes it should export and which it should
701 keep local.
702 The built-in &#8220;<code>static</code>&#8221; keyword of C works well for
703 prohibiting prototypes from leaving a single source file, but because C doesn't
704 support a linkage hierarchy, there is nothing in the C language to help us.
705 We'll have to invite our own keyword: &#8220;<code>EXPORT</code>&#8221;
706 </p>
707
708 <p>
709 Makeheaders allows the EXPORT keyword to precede any function or
710 procedure definition.
711 The routine following the EXPORT keyword is then eligable to appear
712 in the header file generated using the -H command line option.
713 Note that if a .c file contains the EXPORT keyword, makeheaders will
714 put the macro
715 <pre>
716 #define EXPORT
717 </pre>
718 in the header file it generates for the .c file so that the EXPORT keyword
719 will never be seen by the C compiler.
720 </p>
721
722 <p>
723 But the EXPORT keyword only works for function and procedure definitions.
724 For structure, union and enum definitions, typedefs, #defines and
725 class declarations, a second mechanism is used.
726 Just as any declarations or definition contained within
727 <pre>
728 #if INTERFACE
729 #endif
730 </pre>
731 are visible to all files within the library, any declarations
732 or definitions within
733 <pre>
734 #if EXPORT_INTERFACE
735 #endif
736 </pre>
737 will become part of the exported interface.
738 The &#8220;<code>#if EXPORT_INTERFACE</code>&#8221; mechanism can be used in
739 either .c or .h files.
740 (The &#8220;<code>#if INTERFACE</code>&#8221; can also be used in both .h and
741 .c files, but since it's use in a .h file would be redundant, we haven't
742 mentioned it before.)
743 </p>
744
745 <a name="H0011"></a>
746 <h3>3.5 Local declarations processed by makeheaders</h3>
747
748 <p>
749 Structure declarations and typedefs that appear in .c files are normally
750 ignored by makeheaders.
751 Such declarations are only intended for use by the source file in which
752 they appear and so makeheaders doesn't need to copy them into any
753 generated header files.
754 We call such declarations &#8220;<code>private</code>&#8221;.
755 </p>
756
757 <p>
758 Sometimes it is convenient to have makeheaders sort a sequence
759 of private declarations into the correct order for us automatically.
760 Or, we could have static functions and procedures for which we would like
761 makeheaders to generate prototypes, but the arguments to these
762 functions and procedures uses private declarations.
763 In both of these cases, we want makeheaders to be aware of the
764 private declarations and copy them into the local header file,
765 but we don't want makeheaders to propagate the
766 declarations outside of the file in which they are declared.
767 </p>
768
769 <p>
770 When this situation arises, enclose the private declarations
771 within
772 <pre>
773 #if LOCAL_INTERFACE
774 #endif
775 </pre>
776 A &#8220;<code>LOCAL_INTERFACE</code>&#8221; block works very much like the
777 &#8220;<code>INTERFACE</code>&#8221; and
778 &#8220;<code>EXPORT_INTERFACE</code>&#8221;
779 blocks described above, except that makeheaders insures that the
780 objects declared in a LOCAL_INTERFACE are only visible to the
781 file containing the LOCAL_INTERFACE.
782 </p>
783
784 <a name="H0012"></a>
785 <h3>3.6 Using Makeheaders With C++ Code</h3>
786
787 <p>
788 You can use makeheaders to generate header files for C++ code, in
789 addition to C.
790 Makeheaders will recognize and copy both &#8220;<code>class</code>&#8221;
791 declarations
792 and inline function definitions, and it knows not to try to generate
793 prototypes for methods.
794 </p>
795
796 <p>
797 In fact, makeheaders is smart enough to be used in projects that employ
798 a mixture of C and C++.
799 For example, if a C function is called from within a C++ code module,
800 makeheaders will know to prepend the text
801 <pre>
802 extern "C"
803 </pre>
804 to the prototype for that function in the C++ header file.
805 Going the other way,
806 if you try to call a C++ function from within C, an
807 appropriate error message is issued, since C++ routines can not
808 normally be called by C code (due to fact that most C++ compilers
809 use name mangling to facilitate type-safe linkage.)
810 </p>
811
812 <p>
813 No special command-line options are required to use makeheaders with
814 C++ input. Makeheaders will recognize that its source code is C++
815 by the suffix on the source code filename. Simple ".c" or ".h" suffixes
816 are assumed to be ANSI-C. Anything else, including ".cc", ".C" and
817 ".cpp" is assumed to be C++.
818 The name of the header file generated by makeheaders is derived from
819 the name of the source file by converting every "c" to "h" and
820 every "C" to "H" in the suffix of the filename.
821 Thus the C++ source
822 file &#8220;<code>alpha.cpp</code>&#8221; will induce makeheaders to
823 generate a header file named &#8220;<code>alpha.hpp</code>&#8221;.
824 </p>
825
826 <p>
827 Makeheaders augments class definitions by inserting prototypes to
828 methods where appropriate. If a method definition begins with one
829 of the special keywords <b>PUBLIC</b>, <b>PROTECTED</b>, or
830 <b>PRIVATE</b> (in upper-case to distinguish them from the regular
831 C++ keywords with the same meaning) then a prototype for that
832 method will be inserted into the class definition. If none of
833 these keywords appear, then the prototype is not inserted. For
834 example, in the following code, the constructor is not explicitly
835 declared in the class definition but makeheaders will add it there
836 because of the PUBLIC keyword that appears before the constructor
837 definition.
838 </p>
839
840 <blockquote><pre>
841 #if INTERFACE
842 class Example1 {
843 private:
844 int v1;
845 };
846 #endif
847 PUBLIC Example1::Example1(){
848 v1 = 0;
849 }
850 </pre></blockquote>
851
852 <p>
853 The code above is equivalent to the following:
854 </p>
855
856 <blockquote><pre>
857 #if INTERFACE
858 class Example1 {
859 private:
860 int v1;
861 public:
862 Example1();
863 };
864 #endif
865 Example1::Example1(){
866 v1 = 0;
867 }
868 </pre></blockquote>
869
870 <p>
871 The first form is preferred because only a single declaration of
872 the constructor is required. The second form requires two declarations,
873 one in the class definition and one on the definition of the constructor.
874 </p>
875
876 <h4>3.6.1 C++ Limitations</h4>
877
878 <p>
879 Makeheaders does not understand more recent
880 C++ syntax such as templates and namespaces.
881 Perhaps these issues will be addressed in future revisions.
882 </p>
883
884 <a name="H0013"></a>
885 <h3>3.7 Conditional Compilation</h3>
886
887 <p>
888 The makeheaders program understands and tracks the conditional
889 compilation constructs in the source code files it scans.
890 Hence, if the following code appears in a source file
891 <pre>
892 #ifdef UNIX
893 # define WORKS_WELL 1
894 #else
895 # define WORKS_WELL 0
896 #endif
897 </pre>
898 then the next patch of code will appear in the generated header for
899 every .c file that uses the WORKS_WELL constant:
900 <pre>
901 #if defined(UNIX)
902 # define WORKS_WELL 1
903 #endif
904 #if !defined(UNIX)
905 # define WORKS_WELL 0
906 #endif
907 </pre>
908 The conditional compilation constructs can be nested to any depth.
909 Makeheaders also recognizes the special case of
910 <pre>
911 #if 0
912 #endif
913 </pre>
914 and treats the enclosed text as a comment.
915 </p>
916
917 <a name="H0014"></a>
918 <h3>3.8 Caveats</h3>
919
920 <p>
921 The makeheaders system is designed to be robust
922 but it is possible for a devious programmer to fool the system,
923 usually with unhelpful consequences.
924 This subsection is a guide to helping you avoid trouble.
925 </p>
926
927 <p>
928 Makeheaders does not understand the old K&amp;R style of function
929 and procedure definitions.
930 It only understands the modern ANSI-C style, and will probably
931 become very confused if it encounters an old K&amp;R function.
932 Therefore you should take care to avoid putting K&amp;R function definitions
933 in your code.
934 </p>
935
936 <p>
937 Makeheaders does not understand when you define more than one
938 global variable with the same type separated by a comma.
939 In other words, makeheaders does not understand this:
940 <pre>
941 int a = 4, b = 5;
942 </pre>
943 The makeheaders program wants every variable to have its own
944 definition. Like this:
945 <pre>
946 int a = 4;
947 int b = 5;
948 </pre>
949 Notice that this applies to global variables only, not to variables
950 you declare inside your functions.
951 Since global variables ought to be exceedingly rare, and since it is
952 good style to declare them separately anyhow, this restriction is
953 not seen as a terrible hardship.
954 </p>
955
956 <p>
957 Makeheaders does not support defining an enumerated or aggregate type in
958 the same statement as a variable declaration. None of the following
959 statements work completely:
960 <pre>
961 struct {int field;} a;
962 struct Tag {int field;} b;
963 struct Tag c;
964 </pre>
965 Instead, define types separately from variables:
966 <pre>
967 #if INTERFACE
968 struct Tag {int field;};
969 #endif
970 Tag a;
971 Tag b; /* No more than one variable per declaration. */
972 Tag c; /* So must put each on its own line. */
973 </pre>
974 See <a href="#H0008">3.2 What Declarations Get Copied</a> for details,
975 including on the automatic typedef.
976 </p>
977
978 <p>
979 The makeheaders program processes its source file prior to sending
980 those files through the C preprocessor.
981 Hence, if you hide important structure information in preprocessor defines,
982 makeheaders might not be able to successfully extract the information
983 it needs from variables, functions and procedure definitions.
984 For example, if you write this:
985 <pre>
986 #define BEGIN {
987 #define END }
988 </pre>
989 at the beginning of your source file, and then try to create a function
990 definition like this:
991 <pre>
992 char *StrDup(const char *zSrc)
993 BEGIN
994 /* Code here */
995 END
996 </pre>
997 then makeheaders won't be able to find the end of the function definition
998 and bad things are likely to happen.
999 </p>
1000
1001 <p>
1002 For most projects the code constructs that makeheaders cannot
1003 handle are very rare.
1004 As long as you avoid excessive cleverness, makeheaders will
1005 probably be able to figure out what you want and will do the right
1006 thing.
1007 </p>
1008
1009 <p>
1010 Makeheaders has limited understanding of enums. In particular, it does
1011 not realize the significance of enumerated values, so the enum is not
1012 emitted in the header files when its enumerated values are used unless
1013 the name associated with the enum is also used. Moreover, enums can be
1014 completely anonymous, e.g. &#8220;<code>enum {X, Y, Z};</code>&#8221;.
1015 Makeheaders ignores such enums so they can at least be used within a
1016 single source file. Makeheaders expects you to use #define constants
1017 instead. If you want enum features that #define lacks, and you need the
1018 enum in the interface, bypass makeheaders and write a header file by
1019 hand, or teach makeheaders to emit the enum definition when any of the
1020 enumerated values are used, rather than only when the top-level name (if
1021 any) is used.
1022 </p>
1023
1024 <a name="H0015"></a>
1025 <h2>4.0 Using Makeheaders To Generate Documentation</h2>
1026
1027 <p>
1028 Many people have observed the advantages of generating program
1029 documentation directly from the source code:
1030 <ul>
1031 <li> Less effort is involved. It is easier to write a program than
1032 it is to write a program and a document.
1033 <li> The documentation is more likely to agree with the code.
1034 When documentation is derived directly from the code, or is
1035 contained in comments immediately adjacent to the code, it is much
1036 more likely to be correct than if it is contained in a separate
1037 unrelated file in a different part of the source tree.
1038 <li> Information is kept in only one place. When a change occurs
1039 in the code, it is not necessary to make a corresponding change
1040 in a separate document. Just rerun the documentation generator.
1041 </ul>
1042 The makeheaders program does not generate program documentation itself.
1043 But you can use makeheaders to parse the program source code, extract
1044 the information that is relevant to the documentation and to pass this
1045 information to another tool to do the actual documentation preparation.
1046 </p>
1047
1048 <p>
1049 When makeheaders is run with the &#8220;<code>-doc</code>&#8221; option, it
1050 emits no header files at all.
1051 Instead, it does a complete dump of its internal tables to standard
1052 output in a form that is easily parsed.
1053 This output can then be used by another program (the implementation
1054 of which is left as an exercise to the reader) that will use the
1055 information to prepare suitable documentation.
1056 </p>
--- a/src/makeheaders.html
+++ b/src/makeheaders.html
@@ -1,1056 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D src/makemake.tcl
-194
--- a/src/makemake.tcl
+++ b/src/makemake.tcl
@@ -1,194 +0,0 @@
1
-RCDIR)/OBJDIR = .
2
-OX=$(B)/extsrcXXXXX..
3
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
4
-)/th.hh"
5
-.extsrc...........extsrc)\sheRCDIR)/src; BJDIR = .
6
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
7
-)%.c $(SRCDIR)%.h
8
-# 0, ordinary
9
-# the
10
-#.
11
-SQLITE3.1 = $(SRCDIR
12
-# 0, ordinary
13
-# the
14
-#.
15
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
16
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
17
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
18
-)/th.hh"
19
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
20
-OX)/minizRCDIR)/OBJDIR = .
21
-OX=$(B)/extsrcXXXXX..
22
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
23
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
24
-)/th.hh"
25
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
26
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
27
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
28
-)%.c $(SRCDIR)%.h
29
-# 0, ordinary
30
-# the
31
-#.
32
-SQLITE3.1 = $(SRCDIR
33
-# 0, ordinary
34
-# the
35
-#.
36
-SQLITE3.1 = $(SRCDIR../srcputs "building main.mkmain.mksrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
37
-)/th.hh"
38
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
39
-OX)/miniz..extsrc.extsrc.........RRCDIR)/OBJDIR = .
40
-OX=$(B)/extsrcXXXXX..
41
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
42
-)/th.hh"
43
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
44
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
45
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
46
-)%.c $(SRCDIR)%.h
47
-# 0, ordinary
48
-# the
49
-#.
50
-SQLITE3.1 = $(SRCDIR
51
-# 0, ordinary
52
-# the
53
-#.
54
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
55
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
56
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
57
-)/th.hh"
58
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
59
-OX)/minizRCDIR)/OBJDIR = .
60
-OX=$(B)/extsrcXXXXX..
61
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
62
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
63
-)/th.hh"
64
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR $(SRCDIR)/(OBJDIR)/mkindex $(SRCDIR(SRCDIR.....extRCDIR)/OBJDIR = .
65
-OX=$(B)/e $(SRCDIR)/codecheck1codecheck1 $(SRCDIRsrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
66
-)/th.hh"
67
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
68
-OX)/miniz..extsrc.extsrc.........RRCDIR)/OBJDIR = .
69
-OX=$(B)/extsrcXXXXX..
70
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
71
-)/th.hh"
72
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
73
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
74
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
75
-)%.c $(SRCDIR)%.h
76
-# 0, ordinary
77
-# the
78
-#.
79
-SQLITE3.1 = $(SRCDIR
80
-# 0, ordinary
81
-# the
82
-#.
83
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
84
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
85
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
86
-)/th.hh"
87
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
88
-OX)/minizRCDIR)/OBJDIR = .
89
-OX=$(B)/extsrcXXXXX..
90
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
91
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
92
-)/th.hh"
93
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
94
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
95
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
96
-)%.c $(SRCDIR)%.h
97
-# 0, ordinary
98
-# the
99
-#.
100
-SQLITE3.1 = $(SRCDIR
101
-# 0, ordinary
102
-# the
103
-#.
104
-SQLITE3.1 = $(SRCDIR../src)/src$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
105
-)/th.hh"
106
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
107
-OX)/miniz..extsrc.extsrc........RCDIR)/OBJDIR = .
108
-OX=$(B)/extsrcXXXXX..
109
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
110
-)/th.hh"
111
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
112
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
113
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
114
-)%.c $(SRCDIR)%.h
115
-# 0, ordinary
116
-# the
117
-#.
118
-SQLITE3.1 = $(SRCDIR
119
-# 0, ordinary
120
-# the
121
-#.
122
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
123
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
124
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
125
-)/th.hh"
126
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
127
-OX)/minizRCDIR)/OBJDIR = .
128
-OX=$(B)/extsrcXXXXX..
129
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
130
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
131
-)/th.hh"
132
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
133
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
134
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
135
-)%.c $(SRCDIR)%.h
136
-# 0, ordinary
137
-# the
138
-#.
139
-SQLITE3.1 = $(SRCDIR
140
-# 0, ordinary
141
-# the
142
-#.
143
-SQLITE3.1 = $(SRCDIR../src)\translatemakeheaders$E: $(SRCDIRsrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrcRCDIR)/OBJDIR = .
144
-OX=$(B)/extsrcXXXXX..
145
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..........src$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
146
-)/th.hh"
147
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
148
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
149
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
150
-)%.c $(SRCDIR)%.h
151
-# 0, ordinary
152
-# the
153
-#.
154
-SQLITE3.1 = $(SRCDIR
155
-# 0, ordinary
156
-# the
157
-#.
158
-SQLITE3.1 = $(SRCDIR../srcRCDIR)/OBJDIR = .
159
-OX=$(B)/extsrcXXXXX..
160
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
161
-)/th.hh"
162
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
163
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
164
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
165
-)%.c $(SRCDIR)%.h
166
-# 0, ordinary
167
-# the
168
-#.
169
-SQLITE3.1 = $(SRCDIR
170
-# 0, ordinary
171
-# the
172
-#.
173
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
174
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
175
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
176
-)/th.hh"
177
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
178
-OX)/minizRCDIR)/OBJDIR = .
179
-OX=$(B)/extsrcXXXXX..
180
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
181
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
182
-)/th.hh"
183
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
184
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
185
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
186
-)%.c $(SRCDIR)%.h
187
-# 0, ordinary
188
-# the
189
-#.
190
-SQLITE3.1 = $(SRCDIR
191
-# 0, ordinary
192
-# the
193
-#.
194
-SQLITE3.1 = $(SRCDIR../src
--- a/src/makemake.tcl
+++ b/src/makemake.tcl
@@ -1,194 +0,0 @@
1 RCDIR)/OBJDIR = .
2 OX=$(B)/extsrcXXXXX..
3 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
4 )/th.hh"
5 .extsrc...........extsrc)\sheRCDIR)/src; BJDIR = .
6 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
7 )%.c $(SRCDIR)%.h
8 # 0, ordinary
9 # the
10 #.
11 SQLITE3.1 = $(SRCDIR
12 # 0, ordinary
13 # the
14 #.
15 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
16 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
17 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
18 )/th.hh"
19 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
20 OX)/minizRCDIR)/OBJDIR = .
21 OX=$(B)/extsrcXXXXX..
22 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
23 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
24 )/th.hh"
25 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
26 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
27 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
28 )%.c $(SRCDIR)%.h
29 # 0, ordinary
30 # the
31 #.
32 SQLITE3.1 = $(SRCDIR
33 # 0, ordinary
34 # the
35 #.
36 SQLITE3.1 = $(SRCDIR../srcputs "building main.mkmain.mksrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
37 )/th.hh"
38 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
39 OX)/miniz..extsrc.extsrc.........RRCDIR)/OBJDIR = .
40 OX=$(B)/extsrcXXXXX..
41 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
42 )/th.hh"
43 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
44 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
45 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
46 )%.c $(SRCDIR)%.h
47 # 0, ordinary
48 # the
49 #.
50 SQLITE3.1 = $(SRCDIR
51 # 0, ordinary
52 # the
53 #.
54 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
55 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
56 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
57 )/th.hh"
58 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
59 OX)/minizRCDIR)/OBJDIR = .
60 OX=$(B)/extsrcXXXXX..
61 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
62 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
63 )/th.hh"
64 .extsrc...........extsrc)\sheRCDIR)/OBJDIR $(SRCDIR)/(OBJDIR)/mkindex $(SRCDIR(SRCDIR.....extRCDIR)/OBJDIR = .
65 OX=$(B)/e $(SRCDIR)/codecheck1codecheck1 $(SRCDIRsrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
66 )/th.hh"
67 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
68 OX)/miniz..extsrc.extsrc.........RRCDIR)/OBJDIR = .
69 OX=$(B)/extsrcXXXXX..
70 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
71 )/th.hh"
72 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
73 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
74 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
75 )%.c $(SRCDIR)%.h
76 # 0, ordinary
77 # the
78 #.
79 SQLITE3.1 = $(SRCDIR
80 # 0, ordinary
81 # the
82 #.
83 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
84 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
85 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
86 )/th.hh"
87 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
88 OX)/minizRCDIR)/OBJDIR = .
89 OX=$(B)/extsrcXXXXX..
90 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
91 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
92 )/th.hh"
93 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
94 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
95 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
96 )%.c $(SRCDIR)%.h
97 # 0, ordinary
98 # the
99 #.
100 SQLITE3.1 = $(SRCDIR
101 # 0, ordinary
102 # the
103 #.
104 SQLITE3.1 = $(SRCDIR../src)/src$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
105 )/th.hh"
106 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
107 OX)/miniz..extsrc.extsrc........RCDIR)/OBJDIR = .
108 OX=$(B)/extsrcXXXXX..
109 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
110 )/th.hh"
111 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
112 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
113 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
114 )%.c $(SRCDIR)%.h
115 # 0, ordinary
116 # the
117 #.
118 SQLITE3.1 = $(SRCDIR
119 # 0, ordinary
120 # the
121 #.
122 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
123 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
124 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
125 )/th.hh"
126 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
127 OX)/minizRCDIR)/OBJDIR = .
128 OX=$(B)/extsrcXXXXX..
129 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
130 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
131 )/th.hh"
132 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
133 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
134 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
135 )%.c $(SRCDIR)%.h
136 # 0, ordinary
137 # the
138 #.
139 SQLITE3.1 = $(SRCDIR
140 # 0, ordinary
141 # the
142 #.
143 SQLITE3.1 = $(SRCDIR../src)\translatemakeheaders$E: $(SRCDIRsrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrcRCDIR)/OBJDIR = .
144 OX=$(B)/extsrcXXXXX..
145 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..........src$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
146 )/th.hh"
147 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
148 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
149 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
150 )%.c $(SRCDIR)%.h
151 # 0, ordinary
152 # the
153 #.
154 SQLITE3.1 = $(SRCDIR
155 # 0, ordinary
156 # the
157 #.
158 SQLITE3.1 = $(SRCDIR../srcRCDIR)/OBJDIR = .
159 OX=$(B)/extsrcXXXXX..
160 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
161 )/th.hh"
162 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
163 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
164 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
165 )%.c $(SRCDIR)%.h
166 # 0, ordinary
167 # the
168 #.
169 SQLITE3.1 = $(SRCDIR
170 # 0, ordinary
171 # the
172 #.
173 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
174 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
175 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
176 )/th.hh"
177 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
178 OX)/minizRCDIR)/OBJDIR = .
179 OX=$(B)/extsrcXXXXX..
180 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
181 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
182 )/th.hh"
183 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
184 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
185 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
186 )%.c $(SRCDIR)%.h
187 # 0, ordinary
188 # the
189 #.
190 SQLITE3.1 = $(SRCDIR
191 # 0, ordinary
192 # the
193 #.
194 SQLITE3.1 = $(SRCDIR../src
--- a/src/makemake.tcl
+++ b/src/makemake.tcl
@@ -1,194 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D src/mkbuiltin.c
-126
--- a/src/mkbuiltin.c
+++ b/src/mkbuiltin.c
@@ -1,126 +0,0 @@
1
-/*
2
-** Copyright (c) 2014 D. Richard Hipp
3
-**
4
-** This program is free software; you can redistribute it and/or
5
-** modify it under the terms of the Simplified BSD License (also
6
-** known as the "2-Clause License" or "FreeBSD License".)
7
-**
8
-** This program is distributed in the hope that it will be useful,
9
-** but without any warranty; without even the implied warranty of
10
-** merchantability or fitness for a particular purpose.
11
-**
12
-** Author contact information:
13
-** [email protected]
14
-** http://www.hwaci.com/drh/
15
-**
16
-*******************************************************************************
17
-**
18
-** This is a stand-alone utility program that is part of the Fossil build
19
-** process. This program reads files named on the command line and converts
20
-** them into ANSI-C static char array variables. Output is written onto
21
-** standard output.
22
-**
23
-** Additionally, the input files may be listed in a separa tempo
24
-#ifndef FOSSIL_DEBUG
25
- /* Compress javascript source files */
26
- nName = (int)strlen(aRes[i].zName);
27
- if( (nName>3 && strcmp(&aRes[i].zName[nName-3],".js")==0)
28
- || (nName>7 && strcmp(&aRes[i].zName[nName-7], "/js.txt")==0)
29
- ){
30
- int x = sz-nSkip;
31
- compressJavascript(pData+nSkip, &x);
32
- sz = x + nSkip;
33
- }
34
-#endif
35
-
36
- aRes[i].nByte = sz - nSkip;
37
- aRes[i].idx = i;
38
- printf("/* Content of file %s */\n", aRes[i].zName);
39
- printf("static const unsigned char bidata%d[%d] = {\n ",
40
- i, sz+1-nSkip);
41
- for(j=nSkip, n=0; j<=sz; j++){
42
- printf("%3d", pData[j]);
43
- if( j==sz ){
44
- printf(" };\n");
45
- }else if( n==14 ){
46
- printf(",\n ");
47
- n = 0;
48
- }else{
49
- printf(", ");
50
- n++;
51
- }
52
- }
53
- free(pData);
54
- }
55
- printf("typedef struct BuiltinFileTable BuiltinFileTable;\n");
56
- printf("struct BuiltinFileTable {\n");
57
- printf(" const char *zName;\n");
58
- printf(" const unsigned char *pData;\n");
59
- printf(" int nByte;\n");
60
- printf("};\n");
61
- printf("static const BuiltinFileTable aBuiltinFiles[] = {\n");
62
- for(i=0; i<nRes; i++){
63
- char *z = aRes[i].zName;
64
- if( strlen(z)>=nPrefix ) z += nPrefix;
65
- while( z[0]=='.' || z[0]=='/' || z[0]=='\\' ){ z++; }
66
- aRes[i].zName = z;
67
- while( z[0] ){
68
- if( z[0]=='\\' ) z[0] = '/';
69
- z++;
70
- }
71
- }
72
- qsort(aRes, nRes, sizeof(aRes[0]), (QsortCompareFunc)compareResource);
73
- for(i=0; i<nRes; i++){
74
- printf(" { \"%s\", bidata%d, %d },\n",
75
- aRes[i].zName, aRes[i].idx, aRes[i].nByte);
76
- }
77
- printf("};\n");
78
- free_reslist(&resList);
79
- return nErr;
80
-}
81
- sz = x + nSkip;
82
- }
83
-#endif
84
-
85
- aRes[i].nByte = sz - nSkip;
86
- aRes[i].idx = i;
87
- printf("/* Content of file %s */\n", aRes[i].zName);
88
- printf("static const unsigned char bidata%d[%d] = {\n ",
89
- i, sz+1-nSkip);
90
- for(j=nSkip, n=0; j<=sz; j++){
91
- printf("%3d", pData[j]);
92
- if( j==sz ){
93
- printf(" };\n");
94
- }else if( n==14 ){
95
- printf(",\n ");
96
- n = 0;
97
- }else{
98
- printf(", ");
99
- n++;
100
- }
101
- }
102
- free(pData);
103
- }
104
- printf("typedef struct BuiltinFileTable BuiltinFileTable;\n");
105
- printf("struct BuiltinFileTable {\n");
106
- printf(" const char *zName;\n");
107
- printf(" const unsigned char *pData;\n");
108
- printf(" int nByte;\n");
109
- printf("};\n");
110
- printf("static const BuiltinFileTable aBuiltinFiles[] = {\n");
111
- for(i=0; i<nRes; i++){
112
- char *z = aRes[i].zName;
113
- if( strlen(z)>=nPrefix ) z += nPrefix;
114
- while( z[0]=='.' || z[0]=='/' || z[0]=='\\' ){ z++; }
115
- aRes[i].zName = z;
116
- while( z[0] ){
117
- if( z[0]=='\\' ) z[0] = '/';
118
- z++;
119
- }
120
- }
121
- qsort(aRes, nRes, sizeof(aRes[0]), (QsortCompareFunc)compareResource);
122
- for(i=0; i<nRes; i++){
123
- printf(" { \"%s\", bidata%d, %d },\n",
124
- aRes[i].zName, aRes[i].idx, aRes[i].nByte);
125
- }
126
- print
--- a/src/mkbuiltin.c
+++ b/src/mkbuiltin.c
@@ -1,126 +0,0 @@
1 /*
2 ** Copyright (c) 2014 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
6 ** known as the "2-Clause License" or "FreeBSD License".)
7 **
8 ** This program is distributed in the hope that it will be useful,
9 ** but without any warranty; without even the implied warranty of
10 ** merchantability or fitness for a particular purpose.
11 **
12 ** Author contact information:
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** This is a stand-alone utility program that is part of the Fossil build
19 ** process. This program reads files named on the command line and converts
20 ** them into ANSI-C static char array variables. Output is written onto
21 ** standard output.
22 **
23 ** Additionally, the input files may be listed in a separa tempo
24 #ifndef FOSSIL_DEBUG
25 /* Compress javascript source files */
26 nName = (int)strlen(aRes[i].zName);
27 if( (nName>3 && strcmp(&aRes[i].zName[nName-3],".js")==0)
28 || (nName>7 && strcmp(&aRes[i].zName[nName-7], "/js.txt")==0)
29 ){
30 int x = sz-nSkip;
31 compressJavascript(pData+nSkip, &x);
32 sz = x + nSkip;
33 }
34 #endif
35
36 aRes[i].nByte = sz - nSkip;
37 aRes[i].idx = i;
38 printf("/* Content of file %s */\n", aRes[i].zName);
39 printf("static const unsigned char bidata%d[%d] = {\n ",
40 i, sz+1-nSkip);
41 for(j=nSkip, n=0; j<=sz; j++){
42 printf("%3d", pData[j]);
43 if( j==sz ){
44 printf(" };\n");
45 }else if( n==14 ){
46 printf(",\n ");
47 n = 0;
48 }else{
49 printf(", ");
50 n++;
51 }
52 }
53 free(pData);
54 }
55 printf("typedef struct BuiltinFileTable BuiltinFileTable;\n");
56 printf("struct BuiltinFileTable {\n");
57 printf(" const char *zName;\n");
58 printf(" const unsigned char *pData;\n");
59 printf(" int nByte;\n");
60 printf("};\n");
61 printf("static const BuiltinFileTable aBuiltinFiles[] = {\n");
62 for(i=0; i<nRes; i++){
63 char *z = aRes[i].zName;
64 if( strlen(z)>=nPrefix ) z += nPrefix;
65 while( z[0]=='.' || z[0]=='/' || z[0]=='\\' ){ z++; }
66 aRes[i].zName = z;
67 while( z[0] ){
68 if( z[0]=='\\' ) z[0] = '/';
69 z++;
70 }
71 }
72 qsort(aRes, nRes, sizeof(aRes[0]), (QsortCompareFunc)compareResource);
73 for(i=0; i<nRes; i++){
74 printf(" { \"%s\", bidata%d, %d },\n",
75 aRes[i].zName, aRes[i].idx, aRes[i].nByte);
76 }
77 printf("};\n");
78 free_reslist(&resList);
79 return nErr;
80 }
81 sz = x + nSkip;
82 }
83 #endif
84
85 aRes[i].nByte = sz - nSkip;
86 aRes[i].idx = i;
87 printf("/* Content of file %s */\n", aRes[i].zName);
88 printf("static const unsigned char bidata%d[%d] = {\n ",
89 i, sz+1-nSkip);
90 for(j=nSkip, n=0; j<=sz; j++){
91 printf("%3d", pData[j]);
92 if( j==sz ){
93 printf(" };\n");
94 }else if( n==14 ){
95 printf(",\n ");
96 n = 0;
97 }else{
98 printf(", ");
99 n++;
100 }
101 }
102 free(pData);
103 }
104 printf("typedef struct BuiltinFileTable BuiltinFileTable;\n");
105 printf("struct BuiltinFileTable {\n");
106 printf(" const char *zName;\n");
107 printf(" const unsigned char *pData;\n");
108 printf(" int nByte;\n");
109 printf("};\n");
110 printf("static const BuiltinFileTable aBuiltinFiles[] = {\n");
111 for(i=0; i<nRes; i++){
112 char *z = aRes[i].zName;
113 if( strlen(z)>=nPrefix ) z += nPrefix;
114 while( z[0]=='.' || z[0]=='/' || z[0]=='\\' ){ z++; }
115 aRes[i].zName = z;
116 while( z[0] ){
117 if( z[0]=='\\' ) z[0] = '/';
118 z++;
119 }
120 }
121 qsort(aRes, nRes, sizeof(aRes[0]), (QsortCompareFunc)compareResource);
122 for(i=0; i<nRes; i++){
123 printf(" { \"%s\", bidata%d, %d },\n",
124 aRes[i].zName, aRes[i].idx, aRes[i].nByte);
125 }
126 print
--- a/src/mkbuiltin.c
+++ b/src/mkbuiltin.c
@@ -1,126 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D src/mkindex.c
-244
--- a/src/mkindex.c
+++ b/src/mkindex.c
@@ -1,244 +0,0 @@
1
-( strncmp(zLine, "** DEFAULT: ", 1f the Simplifi/*
2
-** Copyright (c) 2002 D. (c) pe |= CMDFLAG_BLOCKTEXT;
3
- }else if( j==10 && strncmp(&zLine[i], "keep-empty", j)==0 ){
4
- aEntry[nUsed].eType |= CMDFLAG_KEEPEMPTY;
5
- }else if( j==11 && strncmp(&zLine[i], "versionable", j)==0 ){
6
- aEntry[nUsed].eType |= CMDFLAG_VERSIONABLE;
7
- }else if( j==9 && strncmp(&zLine[i], "sensitive", j)==0 ){
8
- aEntry[nUsed].eType |= CMDFLAG_SENSITIVE;
9
- }else if( j>6 && strncmp(&zLine[i], "width=", 6)==0 ){
10
- aEntry[nUsed].iWidth = atoi(&zLine[i+6]);
11
- }else if( j>8 && strncmp(&zLine[i], "default=", 8)==0 ){
12
- aEntry[nUsed].zDflt = string_dup(&zLine[i+8], j-8);
13
- }else if( j>9 && strncmp(&zLine[i], "variable=", 9)==0 ){
14
- aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
15
- }else if( j==6 && strncmp(&zLine[i], "==14 && strncmp(&zLine[i], "loadavg-exempt", 14)==0 ){
16
- aEntry[nUsed].eType |= CMDFLAG_LDAVG_EXEMPT;
17
- }else if( (j==23 && strncmp(&zLine[i], "abbreviated-subcommands", 23)==0)
18
- || (j==12 && strncmp(&zLine[i], "abbrv-subcom", 12)==0) ){
19
- aEntry[nUsed].eType |= CMDFLAG_ABBREVSUBCMD;
20
- }else{
21
- fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
22
- zFile, nLine, j, &zLine[i]);
23
- nErr++;
24
- }
25
- }
26
-
27
- nUsed++;
28
- return;
29
-}
30
-
31
-/*
32
-** Check to see if the current line is an #if and if it is, add it to
33
-** the zIf[] string. If the current line is an #endif or #else or #elif
34
-** then cancel the current zIf[] string.
35
-*/
36
-void scan_for_if(const char *zLine){
37
- int i;
38
- int len;
39
- if( zLine0x0001 0x0002 ==0 ) return;
40
- len = strlen(&zLine[i]);
41
- if( strncmp(& DEFAULT: ..." l0x0004 mp(& DEFAULT: ..." line for a
42
-** SETTING definition. If so, reme0x0008 e defau const char *z0x0010 &zLine[i+6]);
43
- }els0x0020 ichard Hipp
44
-**
45
-** This0x0040 modify it under the terms of the S0x0080 ( strnccense".)
46
-**
47
-** This program is0x0200 ill be useful,
48
-** but without any warranty; without even the implied war0x0400 f
49
-** merchantability or fitness for a particular purpose.
50
-**
51
-** Au0x0800 strncmp(zLine, "** DEFAULT: ", 1f the Simplifi/*
52
-** Copyright (c) 2002 D. (c) pe |= CMDFLAG_BLOCKTEXT;
53
- }else if( j==10 && strncmp(&zLine[i], "keep-empty", j)==0 ){
54
- aEntry[nUsed].eType |= CMDFLAG_KEEPEMPTY;
55
- }else if( j==11 && strncmp(&zLine[i], "versionable", j)==0 ){
56
- aEntry[nUsed].eType |= CMDFLAG_VERSIONABLE;
57
- }else if( j==9 && strncmp(&zLine[i], "sensitive", j)==0 ){
58
- aEntry[nUsed].eType |= CMDFLAG_SENSITIVE;
59
- }else if( j>6 && strncmp(&zLine[i], "width=", 6)==0 ){
60
- aEntry[nUsed].iWidth = atoi(&zLine[i+6]);
61
- }else if( j>8 && strncmp(&zLine[i], "default=", 8)==0 ){
62
- aEntry[nUsed].zDflt = string_dup(&zLine[i+8], j-8);
63
- }else if( j>9 && strncmp(&zLine[i], "variable=", 9)==0 ){
64
- aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
65
- }else if( j==6 && strncmp(&zLine[i], "==14 && strncmp(&zLine[i], "loadavg-exempt", 14)==0 ){
66
- aEntry[nUsed].eType |= CMDFLAG_LDAVG_EXEMPT;
67
- }else if( (j==23 && strncmp(&zLine[i], "abbreviated-subcommands", 23)==0)
68
- || (j==12 && strncmp(&zLine[i], "abbrv-subcom", 12)==0) ){
69
- aEntry[nUsed].eType |= CMDFLAG_ABBREVSUBCMD;
70
- }else{
71
- fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
72
- zFile, nLine, j, &zLine[i]);
73
- nErr++;
74
- }
75
- }
76
-
77
- nUsed++;
78
- return;
79
-}
80
-
81
-/*
82
-** Check to see if the current line is an #if and if it is, add it to
83
-** the zIf[] string. If the current line is an #endif or #else or #elif
84
-** then cancel the current zIf[] string.
85
-*/
86
-void scan_for_if(const char *zLine){
87
- int i;
88
- int len;
89
- if( zLine[0]!='#' ) return;
90
- for(i=1; fossil_isspace(zLine[i]); i++){}
91
- if( zLine[i]==0 ) return;
92
- len = strlen(&zLine[i]);
93
- if( strncmp(& DEFAULT: ..." line for a
94
-** SETTING definition. If so, reme4 er the defau const char *z;
95
- i1/Entry[nUsed].iWidth = atoi(&zLine[i+6]);
96
- }else if( j>8 && strncmp(&zLi2002 D. Richard Hipp
97
-**
98
-** This program is free software; you can redistribute it and/or
99
-** modify it under the terms of the Simplified BSD License (also
100
-** known as the "2-Clause License" or "FreeBSD License".)
101
-**
102
-** This program is distributed in the hope that it will be useful,
103
-** but without any warranty; without even the implied warranty of
104
-** merchantability or fitness for a particular purpose.
105
-**
106
-** Author contact information:
107
-** [email protected]
108
-** http://www.hwaci.com/drh/
109
-**
110
-*******************************************************************************
111
-**
112
-** This utility program scans Fossil source text looking for specially
113
-** formatted comments and generates C source code for constant tables
114
-** that define the behavior of commands, webThe source code is scanned for comment lines of the form:
115
-**
116
-** WEBPAGE: /abc/xyz
117
-** COMMAND: cmdname
118
-** SETTING: access-log
119
-** TOPIC: help-topic
120
-**
121
-*ect is defined in db.c.
122
-*/
123
-#include <stdio.h>
124
-#include <stdlib.h>
125
-#include <assert.h>
126
-#include <string.h>
127
-
128
-/************************************************************************* 0x0000MDFLAG_TEST 0x000004 /* Commands for testing only */
129
-#define MDFLAG_WEBPAGE 0x000008CMDFLAG_COMMAND 0x000010CMDFLAG_SETTING 0x00002040 /* A versionable setting */
130
-#define CMDFLAG_BLOCKTEXT 0x000CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
131
-#defin CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
132
-#defin CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret webpage content */
133
-#defin redistribute it and/or
134
-** );r testing only */
135
-#define d BS/*
136
-** Copyright (c) 2002 D. Richard Hipp
137
-**
138
-** This program is free so1000 /* Exemp);r testing o*********************
139
-**j==4sionabl /* Enclose tesine[i], "keep-empty", j)=( strncmp(zLine, "** DEFA);r testing o_VERSIONABLE 0x000040 B1#define MX_HELP 250000
140
-
141
-* Do not interpret webpage content */
142
-#define CMDFLAG_SENSITIVE 0x000400 /* Security-sensitive setting */
143
-#define CMDFLAG_HIDDEN 0x000800 /* Elide from most listings */
144
-#define CMDFLAG_LDAVG_EXEMPT 0x001000 /* Exempt from load_control() */
145
-#define CMDFLAG_ALIAS 0x002000 /* Command aliases */
146
-#define CMDFLAG_KEEPEMPTY 0x004000 /* Do not unset empty settings */
147
-#define CMDFLAG_ABB1#define MX_HELP 250000
148
-
149
-versionabl /* Enclose in #iftry {
150
- int eType; /* CMDFLAG_* values */
151
- char *zIf; /* Enclose in #if */
152
- char *zFunc; /* Name of implementation */
153
- char *zPath; /* Webpage or command name */
154
- char *zHelp; /* Help text */
155
- char *zDflt; /* Default value for settings */
156
- char *zVar; /* config.name for settings, if different from zPath */
157
- int iHelp; /* Index of Help text */
158
- int iWidth; /* Display width for SETTING: values */
159
-} Entry;
160
-
161
-/*
162
-** Maximum number of entries
163
-*/
164
-#define N_ENTRY 5000
165
-
166
-/*
167
-** Maximum size of a help message
168
-*/
169
-#define MX_HELP 250000
170
-
171
-/*
172
-** Table of entries
173
-*/
174
-Entry aEntry[N_ENTRY];
175
-
176
-/*
177
-** Current help message accumulatoename and line number
178
-*/
179
-char *zFile;
180
-inAG_KEEPEMPTY 0x00400y {
181
- int eType; /* CMDFLAG_* values */
182
- char *zIf; /* Enclose in #if */
183
- char *zFunc; /* Name of implementation */
184
- char *zPath; /* Webpage or command name */
185
- char *zHelp; /* Help text */
186
- char *zDflt; /* Default value for settings */
187
- char *zVar; /* config.name for settings, ififferent from zPath */
188
- int iHelp; /* Index of Help text */
189
- int iWidth; /* Display width for SETTING: values */
190
-} Entry;
191
-
192
-/*
193
-** Maximum number of entries
194
-*/
195
-#define N_ENTRY 5000
196
-
197
-/*
198
-** Maximum size of a help message
199
-*/elset from load_control() */
200
-/***************** /* Multi-lPROPAGATESEBPA */
201
-#define CMDFLAG_COMMAND 0x000010 /* A c 0x000020 /* A setting */
202
-#define CMDFLAG_VERSIONABLE 0x000040 /* A vnAlias40 /* A #define CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
203
-#define CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
204
-#define CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret webpage content */
205
-#define C setting */
206
-#define CMDFLAG_HIDDEN 0x000800 /* Elide from most listings */
207
-#define CMDFLAG_LDAVG_EXEMPT 0x001000 /* Exempt from load_control() */
208
-#define CMDFLAG_ALIAS 0x002000 /* Command aliases */
209
-#define CMDFLAG_KEEPEMPTY 0x004000 /* Do not unset empty settings */
210
-#define CMDFLAG_ABBREVSUBCMD 0x008000 /* Abbreviated subcmd in help text */
211
-#define CMDFLAG_TOPIC 0x010000 /* A help topic */
212
-/**************************************************************************/
213
-
214
-/*
215
-** Each entry looks like this:
216
-*/
217
-typedef struct Entry {
218
- int eType; /* CMDFLAG_* values */
219
- char *zIf; /* Enclose in #if */
220
- char *zFunc; /* Name of implementation */
221
- char *zPath; /* Webpage or command name */
222
- char *zHelp; /* Help text */
223
- char *zDflt; /* Default value for settings */
224
- char *zVar; /* config.name for settings, ififferent from zPath */
225
- int iHelp; /* Index of Help text */
226
- int iWidth; /* Display width for SETTING: values */
227
-} Entry;
228
-
229
-/*
230
-** Maximum number of entries
231
-*/
232
-#define N_ENTRY 5000
233
-
234
-/*
235
-** Maximum size of a help message
236
-*/elset from load_control() */
237
-#defineALIAS)!=0 ){
238
- nAlias++8000 /* Abbreviated subcconfi/
239
-#define MDFLAG_WEBPAGE 0x00propagating", 110080 /* Multi-lPROPAGATESEBPAGE 0x000008 /* Web pages */
240
-#define CMDFLAG_COMMAND 0x000010 /* A c 0x000020 /* A setting */
241
-#define CMDFLAG_VERSIONABLE 0x000040 /* A versionable setting */
242
-#define CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
243
-#define CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
244
-#define CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret
--- a/src/mkindex.c
+++ b/src/mkindex.c
@@ -1,244 +0,0 @@
1 ( strncmp(zLine, "** DEFAULT: ", 1f the Simplifi/*
2 ** Copyright (c) 2002 D. (c) pe |= CMDFLAG_BLOCKTEXT;
3 }else if( j==10 && strncmp(&zLine[i], "keep-empty", j)==0 ){
4 aEntry[nUsed].eType |= CMDFLAG_KEEPEMPTY;
5 }else if( j==11 && strncmp(&zLine[i], "versionable", j)==0 ){
6 aEntry[nUsed].eType |= CMDFLAG_VERSIONABLE;
7 }else if( j==9 && strncmp(&zLine[i], "sensitive", j)==0 ){
8 aEntry[nUsed].eType |= CMDFLAG_SENSITIVE;
9 }else if( j>6 && strncmp(&zLine[i], "width=", 6)==0 ){
10 aEntry[nUsed].iWidth = atoi(&zLine[i+6]);
11 }else if( j>8 && strncmp(&zLine[i], "default=", 8)==0 ){
12 aEntry[nUsed].zDflt = string_dup(&zLine[i+8], j-8);
13 }else if( j>9 && strncmp(&zLine[i], "variable=", 9)==0 ){
14 aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
15 }else if( j==6 && strncmp(&zLine[i], "==14 && strncmp(&zLine[i], "loadavg-exempt", 14)==0 ){
16 aEntry[nUsed].eType |= CMDFLAG_LDAVG_EXEMPT;
17 }else if( (j==23 && strncmp(&zLine[i], "abbreviated-subcommands", 23)==0)
18 || (j==12 && strncmp(&zLine[i], "abbrv-subcom", 12)==0) ){
19 aEntry[nUsed].eType |= CMDFLAG_ABBREVSUBCMD;
20 }else{
21 fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
22 zFile, nLine, j, &zLine[i]);
23 nErr++;
24 }
25 }
26
27 nUsed++;
28 return;
29 }
30
31 /*
32 ** Check to see if the current line is an #if and if it is, add it to
33 ** the zIf[] string. If the current line is an #endif or #else or #elif
34 ** then cancel the current zIf[] string.
35 */
36 void scan_for_if(const char *zLine){
37 int i;
38 int len;
39 if( zLine0x0001 0x0002 ==0 ) return;
40 len = strlen(&zLine[i]);
41 if( strncmp(& DEFAULT: ..." l0x0004 mp(& DEFAULT: ..." line for a
42 ** SETTING definition. If so, reme0x0008 e defau const char *z0x0010 &zLine[i+6]);
43 }els0x0020 ichard Hipp
44 **
45 ** This0x0040 modify it under the terms of the S0x0080 ( strnccense".)
46 **
47 ** This program is0x0200 ill be useful,
48 ** but without any warranty; without even the implied war0x0400 f
49 ** merchantability or fitness for a particular purpose.
50 **
51 ** Au0x0800 strncmp(zLine, "** DEFAULT: ", 1f the Simplifi/*
52 ** Copyright (c) 2002 D. (c) pe |= CMDFLAG_BLOCKTEXT;
53 }else if( j==10 && strncmp(&zLine[i], "keep-empty", j)==0 ){
54 aEntry[nUsed].eType |= CMDFLAG_KEEPEMPTY;
55 }else if( j==11 && strncmp(&zLine[i], "versionable", j)==0 ){
56 aEntry[nUsed].eType |= CMDFLAG_VERSIONABLE;
57 }else if( j==9 && strncmp(&zLine[i], "sensitive", j)==0 ){
58 aEntry[nUsed].eType |= CMDFLAG_SENSITIVE;
59 }else if( j>6 && strncmp(&zLine[i], "width=", 6)==0 ){
60 aEntry[nUsed].iWidth = atoi(&zLine[i+6]);
61 }else if( j>8 && strncmp(&zLine[i], "default=", 8)==0 ){
62 aEntry[nUsed].zDflt = string_dup(&zLine[i+8], j-8);
63 }else if( j>9 && strncmp(&zLine[i], "variable=", 9)==0 ){
64 aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
65 }else if( j==6 && strncmp(&zLine[i], "==14 && strncmp(&zLine[i], "loadavg-exempt", 14)==0 ){
66 aEntry[nUsed].eType |= CMDFLAG_LDAVG_EXEMPT;
67 }else if( (j==23 && strncmp(&zLine[i], "abbreviated-subcommands", 23)==0)
68 || (j==12 && strncmp(&zLine[i], "abbrv-subcom", 12)==0) ){
69 aEntry[nUsed].eType |= CMDFLAG_ABBREVSUBCMD;
70 }else{
71 fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
72 zFile, nLine, j, &zLine[i]);
73 nErr++;
74 }
75 }
76
77 nUsed++;
78 return;
79 }
80
81 /*
82 ** Check to see if the current line is an #if and if it is, add it to
83 ** the zIf[] string. If the current line is an #endif or #else or #elif
84 ** then cancel the current zIf[] string.
85 */
86 void scan_for_if(const char *zLine){
87 int i;
88 int len;
89 if( zLine[0]!='#' ) return;
90 for(i=1; fossil_isspace(zLine[i]); i++){}
91 if( zLine[i]==0 ) return;
92 len = strlen(&zLine[i]);
93 if( strncmp(& DEFAULT: ..." line for a
94 ** SETTING definition. If so, reme4 er the defau const char *z;
95 i1/Entry[nUsed].iWidth = atoi(&zLine[i+6]);
96 }else if( j>8 && strncmp(&zLi2002 D. Richard Hipp
97 **
98 ** This program is free software; you can redistribute it and/or
99 ** modify it under the terms of the Simplified BSD License (also
100 ** known as the "2-Clause License" or "FreeBSD License".)
101 **
102 ** This program is distributed in the hope that it will be useful,
103 ** but without any warranty; without even the implied warranty of
104 ** merchantability or fitness for a particular purpose.
105 **
106 ** Author contact information:
107 ** [email protected]
108 ** http://www.hwaci.com/drh/
109 **
110 *******************************************************************************
111 **
112 ** This utility program scans Fossil source text looking for specially
113 ** formatted comments and generates C source code for constant tables
114 ** that define the behavior of commands, webThe source code is scanned for comment lines of the form:
115 **
116 ** WEBPAGE: /abc/xyz
117 ** COMMAND: cmdname
118 ** SETTING: access-log
119 ** TOPIC: help-topic
120 **
121 *ect is defined in db.c.
122 */
123 #include <stdio.h>
124 #include <stdlib.h>
125 #include <assert.h>
126 #include <string.h>
127
128 /************************************************************************* 0x0000MDFLAG_TEST 0x000004 /* Commands for testing only */
129 #define MDFLAG_WEBPAGE 0x000008CMDFLAG_COMMAND 0x000010CMDFLAG_SETTING 0x00002040 /* A versionable setting */
130 #define CMDFLAG_BLOCKTEXT 0x000CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
131 #defin CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
132 #defin CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret webpage content */
133 #defin redistribute it and/or
134 ** );r testing only */
135 #define d BS/*
136 ** Copyright (c) 2002 D. Richard Hipp
137 **
138 ** This program is free so1000 /* Exemp);r testing o*********************
139 **j==4sionabl /* Enclose tesine[i], "keep-empty", j)=( strncmp(zLine, "** DEFA);r testing o_VERSIONABLE 0x000040 B1#define MX_HELP 250000
140
141 * Do not interpret webpage content */
142 #define CMDFLAG_SENSITIVE 0x000400 /* Security-sensitive setting */
143 #define CMDFLAG_HIDDEN 0x000800 /* Elide from most listings */
144 #define CMDFLAG_LDAVG_EXEMPT 0x001000 /* Exempt from load_control() */
145 #define CMDFLAG_ALIAS 0x002000 /* Command aliases */
146 #define CMDFLAG_KEEPEMPTY 0x004000 /* Do not unset empty settings */
147 #define CMDFLAG_ABB1#define MX_HELP 250000
148
149 versionabl /* Enclose in #iftry {
150 int eType; /* CMDFLAG_* values */
151 char *zIf; /* Enclose in #if */
152 char *zFunc; /* Name of implementation */
153 char *zPath; /* Webpage or command name */
154 char *zHelp; /* Help text */
155 char *zDflt; /* Default value for settings */
156 char *zVar; /* config.name for settings, if different from zPath */
157 int iHelp; /* Index of Help text */
158 int iWidth; /* Display width for SETTING: values */
159 } Entry;
160
161 /*
162 ** Maximum number of entries
163 */
164 #define N_ENTRY 5000
165
166 /*
167 ** Maximum size of a help message
168 */
169 #define MX_HELP 250000
170
171 /*
172 ** Table of entries
173 */
174 Entry aEntry[N_ENTRY];
175
176 /*
177 ** Current help message accumulatoename and line number
178 */
179 char *zFile;
180 inAG_KEEPEMPTY 0x00400y {
181 int eType; /* CMDFLAG_* values */
182 char *zIf; /* Enclose in #if */
183 char *zFunc; /* Name of implementation */
184 char *zPath; /* Webpage or command name */
185 char *zHelp; /* Help text */
186 char *zDflt; /* Default value for settings */
187 char *zVar; /* config.name for settings, ififferent from zPath */
188 int iHelp; /* Index of Help text */
189 int iWidth; /* Display width for SETTING: values */
190 } Entry;
191
192 /*
193 ** Maximum number of entries
194 */
195 #define N_ENTRY 5000
196
197 /*
198 ** Maximum size of a help message
199 */elset from load_control() */
200 /***************** /* Multi-lPROPAGATESEBPA */
201 #define CMDFLAG_COMMAND 0x000010 /* A c 0x000020 /* A setting */
202 #define CMDFLAG_VERSIONABLE 0x000040 /* A vnAlias40 /* A #define CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
203 #define CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
204 #define CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret webpage content */
205 #define C setting */
206 #define CMDFLAG_HIDDEN 0x000800 /* Elide from most listings */
207 #define CMDFLAG_LDAVG_EXEMPT 0x001000 /* Exempt from load_control() */
208 #define CMDFLAG_ALIAS 0x002000 /* Command aliases */
209 #define CMDFLAG_KEEPEMPTY 0x004000 /* Do not unset empty settings */
210 #define CMDFLAG_ABBREVSUBCMD 0x008000 /* Abbreviated subcmd in help text */
211 #define CMDFLAG_TOPIC 0x010000 /* A help topic */
212 /**************************************************************************/
213
214 /*
215 ** Each entry looks like this:
216 */
217 typedef struct Entry {
218 int eType; /* CMDFLAG_* values */
219 char *zIf; /* Enclose in #if */
220 char *zFunc; /* Name of implementation */
221 char *zPath; /* Webpage or command name */
222 char *zHelp; /* Help text */
223 char *zDflt; /* Default value for settings */
224 char *zVar; /* config.name for settings, ififferent from zPath */
225 int iHelp; /* Index of Help text */
226 int iWidth; /* Display width for SETTING: values */
227 } Entry;
228
229 /*
230 ** Maximum number of entries
231 */
232 #define N_ENTRY 5000
233
234 /*
235 ** Maximum size of a help message
236 */elset from load_control() */
237 #defineALIAS)!=0 ){
238 nAlias++8000 /* Abbreviated subcconfi/
239 #define MDFLAG_WEBPAGE 0x00propagating", 110080 /* Multi-lPROPAGATESEBPAGE 0x000008 /* Web pages */
240 #define CMDFLAG_COMMAND 0x000010 /* A c 0x000020 /* A setting */
241 #define CMDFLAG_VERSIONABLE 0x000040 /* A versionable setting */
242 #define CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
243 #define CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
244 #define CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret
--- a/src/mkindex.c
+++ b/src/mkindex.c
@@ -1,244 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D src/mkversion.c
-1
--- a/src/mkversion.c
+++ b/src/mkversion.c
@@ -1 +0,0 @@
1
-/
--- a/src/mkversion.c
+++ b/src/mkversion.c
@@ -1 +0,0 @@
1 /
--- a/src/mkversion.c
+++ b/src/mkversion.c
@@ -1 +0,0 @@
 
D src/translate.c
-118
--- a/src/translate.c
+++ b/src/translate.c
@@ -1,118 +0,0 @@
1
-/*
2
-** Copyright (c) 2002 D. Richard Hipp
3
-**
4
-** This program is free software; you can redistribute it and/or
5
-** modify it under the terms of the Simplified BSD License (also
6
-** known as the "2-Clause License" or "FreeBSD License".)
7
-**
8
-** This program is distributed in the hope that it will be useful,
9
-** but without any warranty; without even the implied warranty of
10
-** merchantability or fitness for a particular purpose.
11
-**
12
-** Author contact information:
13
-** [email protected]
14
-** http://www.hwaci.com/drh/
15
-**
16
-*******************************************************************************
17
-**
18
-** SYNOPSIS:
19
-**
20
-** Input lines that begin with the "@" character are translated into
21
-** either cgi_printf() statements or string literals and the
22
-** translated code is written on standard output.
23
-**
24
-** The problem this program is attempt to solve is as follows: When
25
-** writing CGI programs in C, we typically want to output a lot of HTML
26
-** text to standard output. In pure C code, this invo punctuation.
27
-**
28
-** Enhancement #1:
29
-**
30
-** If the last non-whitespace character prior to the first "@" of a
31
-** @-block is "=" or "," then the @-block is a string literal initializer
32
-** rather than text that is to be output via cgi_printf(). Render it
33
-** as such.
34
-**
35
-** Enhancement #2:
36
-**
37
-** Comments of the form: "|* @-comment: CC" (where "|" is really "/")
38
-** cause CC to become a comment character for the @-substitution.
39
-** Typical values for CC are "--" (for SQL text) or "#" (for Tcl script)
40
-** or "//" (for C++ code). Lines of subsequent @-blocks that begin with
41
-** CC are omitted from the output.
42
-**
43
-** Enhancement #3:
44
-**
45
-** If a non-enhancement #1 line ends in backslash, the backslash and the
46
-** newline (\n) are not included in the argument to cgi_printf(). This
47
-** is used to split one lorce lines.
48
-*/
49
-#include <stdio.h>
50
-#include <ctype.h>
51
-#include <stdlib.h>
52
-#include <string.h>
53
-
54
-/*
55
-** Space to hold arguments at the end of the cgi_printf()
56
-*/
57
-#define MX_ARG_SP 10000
58
-static char zArg[MX_ARG_SP];
59
-static int nArg = 0;
60
-
61
-/*
62
-** True if we are currently in a cgi_printf()
63
-*/
64
-static int inPrint = 0;
65
-
66
-/*
67
-** True if we are cu while( i>0 && fossil_isspace(zLine[i-1]) ){ i--; }
68
- lastWasEq = i>0 && zLine[i-1]=='=';
69
- lastWasComma = i>0 && zLine[i-1]==',';
70
- }else if( lastWasEq || lastWasComma){
71
- /* If the last non-whitespace character before the first @ was
72
- ** an "="(var init/set) or a ","(const definition in list) then
73
- ** generate a string literal. But skip comments
74
- ** consisting of all text between c1 and c2 (default "--")
75
- ** and end of line.
76
- */
77
- int indent, omitline;
78
- char *zNewline = " char *zNewline = ){ i++; }
79
- indent = i - 2;
80
- if( indent<0 ) indent = 0;
81
- omitline = 0;
82
- for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
83
- if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
84
- omitline = 1; break;
85
- }
86
- if( zLine[i]=='\\' && (zLine[i+1]==0 || zLine[i+1]=='\r'
87
- || zLine[i+1]=='\n') ){
88
- zLine[i] = 0;
89
- zNewline = "";
90
- /* fprintf(stderr, "%s:%d: omit newline\n", zInFile, lineNo); */
91
- break;
92
- }
93
- if( zLine[i]=='\\' || zLine[i]=='"' ){ zOut[j++] = '\\'; }
94
- zOut[j++] = zLine[i];
95
- }
96
- if( z[0] ) while( j>0 && fossil_isspace(zOut[j-1]) ){ j--; }
97
- zOut[j] = 0;
98
- if( j<=0 && omitline ){
99
- fprintf(out,"\n");
100
- }else{
101
- fprintf(out,"%*s\"%s%s\"\n",indent, "", zOut, zNewline);
102
- }
103
- }else{
104
- /* Otherwise (if the last non-whitespace was not '=') then generate a
105
- ** cgi_printf() statement whose format is the text following the '@'.
106
- ** Substrings of the form "%C(...)" (where C is any sequence of characters
107
- ** other than \000 and '(') will put "%C" in the format and add the
108
- ** "(...)" as an argument to the cgi_printf call. Each '*' character
109
- ** present in C (max two) causes one more "(...)" sequence to be consumed.
110
- ** For example, "%*.*d(4)(2)(1)" converts to "%*.*d" with arguments "4",
111
- ** "2", and "1", which will be used as the field width, precision, and
112
- ** value, respectively, producing a final formatted result of " 01".
113
- */
114
- const char *zNewline = "\\n";
115
- int indent;
116
- int nC;
117
- int nParam;
118
- ch char *zNewl
--- a/src/translate.c
+++ b/src/translate.c
@@ -1,118 +0,0 @@
1 /*
2 ** Copyright (c) 2002 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
6 ** known as the "2-Clause License" or "FreeBSD License".)
7 **
8 ** This program is distributed in the hope that it will be useful,
9 ** but without any warranty; without even the implied warranty of
10 ** merchantability or fitness for a particular purpose.
11 **
12 ** Author contact information:
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** SYNOPSIS:
19 **
20 ** Input lines that begin with the "@" character are translated into
21 ** either cgi_printf() statements or string literals and the
22 ** translated code is written on standard output.
23 **
24 ** The problem this program is attempt to solve is as follows: When
25 ** writing CGI programs in C, we typically want to output a lot of HTML
26 ** text to standard output. In pure C code, this invo punctuation.
27 **
28 ** Enhancement #1:
29 **
30 ** If the last non-whitespace character prior to the first "@" of a
31 ** @-block is "=" or "," then the @-block is a string literal initializer
32 ** rather than text that is to be output via cgi_printf(). Render it
33 ** as such.
34 **
35 ** Enhancement #2:
36 **
37 ** Comments of the form: "|* @-comment: CC" (where "|" is really "/")
38 ** cause CC to become a comment character for the @-substitution.
39 ** Typical values for CC are "--" (for SQL text) or "#" (for Tcl script)
40 ** or "//" (for C++ code). Lines of subsequent @-blocks that begin with
41 ** CC are omitted from the output.
42 **
43 ** Enhancement #3:
44 **
45 ** If a non-enhancement #1 line ends in backslash, the backslash and the
46 ** newline (\n) are not included in the argument to cgi_printf(). This
47 ** is used to split one lorce lines.
48 */
49 #include <stdio.h>
50 #include <ctype.h>
51 #include <stdlib.h>
52 #include <string.h>
53
54 /*
55 ** Space to hold arguments at the end of the cgi_printf()
56 */
57 #define MX_ARG_SP 10000
58 static char zArg[MX_ARG_SP];
59 static int nArg = 0;
60
61 /*
62 ** True if we are currently in a cgi_printf()
63 */
64 static int inPrint = 0;
65
66 /*
67 ** True if we are cu while( i>0 && fossil_isspace(zLine[i-1]) ){ i--; }
68 lastWasEq = i>0 && zLine[i-1]=='=';
69 lastWasComma = i>0 && zLine[i-1]==',';
70 }else if( lastWasEq || lastWasComma){
71 /* If the last non-whitespace character before the first @ was
72 ** an "="(var init/set) or a ","(const definition in list) then
73 ** generate a string literal. But skip comments
74 ** consisting of all text between c1 and c2 (default "--")
75 ** and end of line.
76 */
77 int indent, omitline;
78 char *zNewline = " char *zNewline = ){ i++; }
79 indent = i - 2;
80 if( indent<0 ) indent = 0;
81 omitline = 0;
82 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
83 if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
84 omitline = 1; break;
85 }
86 if( zLine[i]=='\\' && (zLine[i+1]==0 || zLine[i+1]=='\r'
87 || zLine[i+1]=='\n') ){
88 zLine[i] = 0;
89 zNewline = "";
90 /* fprintf(stderr, "%s:%d: omit newline\n", zInFile, lineNo); */
91 break;
92 }
93 if( zLine[i]=='\\' || zLine[i]=='"' ){ zOut[j++] = '\\'; }
94 zOut[j++] = zLine[i];
95 }
96 if( z[0] ) while( j>0 && fossil_isspace(zOut[j-1]) ){ j--; }
97 zOut[j] = 0;
98 if( j<=0 && omitline ){
99 fprintf(out,"\n");
100 }else{
101 fprintf(out,"%*s\"%s%s\"\n",indent, "", zOut, zNewline);
102 }
103 }else{
104 /* Otherwise (if the last non-whitespace was not '=') then generate a
105 ** cgi_printf() statement whose format is the text following the '@'.
106 ** Substrings of the form "%C(...)" (where C is any sequence of characters
107 ** other than \000 and '(') will put "%C" in the format and add the
108 ** "(...)" as an argument to the cgi_printf call. Each '*' character
109 ** present in C (max two) causes one more "(...)" sequence to be consumed.
110 ** For example, "%*.*d(4)(2)(1)" converts to "%*.*d" with arguments "4",
111 ** "2", and "1", which will be used as the field width, precision, and
112 ** value, respectively, producing a final formatted result of " 01".
113 */
114 const char *zNewline = "\\n";
115 int indent;
116 int nC;
117 int nParam;
118 ch char *zNewl
--- a/src/translate.c
+++ b/src/translate.c
@@ -1,118 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

No diff available

No diff available

No diff available

--- a/tools/makemake.tcl
+++ b/tools/makemake.tcl
@@ -1,161 +1,4 @@
11
RCDIR)/OBJDIR = .
2
-OX=$(B)/extsrcXXXXX..
3
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
4
-)/th.hh"
5
-.extsrc...........extsrc)\sheRCDIR)/src; BJDIR = .
6
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
7
-)%.c $(SRCDIR)%.h
8
-# 0, ordinary
9
-# the
10
-#.
11
-SQLITE3.1 = $(SRCDIR
12
-# 0, ordinary
13
-# the
14
-#.
15
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
16
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
17
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
18
-)/th.hh"
19
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
20
-OX)/minizRCDIR)/OBJDIR = .
21
-OX=$(B)/extsrcXXXXX..
22
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
23
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
24
-)/th.hh"
25
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
26
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
27
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
28
-)%.c $(SRCDIR)%.h
29
-# 0, ordinary
30
-# the
31
-#.
32
-SQLITE3.1 = $(SRCDIR
33
-# 0, ordinary
34
-# the
35
-#.
36
-SQLITE3.1 = $(SRCDIR../srcputs "building main.mkmain.mksrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
37
-)/th.hh"
38
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
39
-OX)/miniz..extsrc.extsrc.........RRCDIR)/OBJDIR = .
40
-OX=$(B)/extsrcXXXXX..
41
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
42
-)/th.hh"
43
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
44
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
45
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
46
-)%.c $(SRCDIR)%.h
47
-# 0, ordinary
48
-# the
49
-#.
50
-SQLITE3.1 = $(SRCDIR
51
-# 0, ordinary
52
-# the
53
-#.
54
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
55
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
56
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
57
-)/th.hh"
58
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
59
-OX)/minizRCDIR)/OBJDIR = .
60
-OX=$(B)/extsrcXXXXX..
61
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
62
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
63
-)/th.hh"
64
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR $(SRCDIR)/(OBJDIR)/mkindex $(SRCDIR(SRCDIR.....extRCDIR)/OBJDIR = .
65
-OX=$(B)/e $(SRCDIR)/codecheck1codecheck1 $(SRCDIRsrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
66
-)/th.hh"
67
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
68
-OX)/miniz..extsrc.extsrc.........RRCDIR)/OBJDIR = .
69
-OX=$(B)/extsrcXXXXX..
70
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
71
-)/th.hh"
72
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
73
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
74
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
75
-)%.c $(SRCDIR)%.h
76
-# 0, ordinary
77
-# the
78
-#.
79
-SQLITE3.1 = $(SRCDIR
80
-# 0, ordinary
81
-# the
82
-#.
83
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
84
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
85
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
86
-)/th.hh"
87
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
88
-OX)/minizRCDIR)/OBJDIR = .
89
-OX=$(B)/extsrcXXXXX..
90
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
91
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
92
-)/th.hh"
93
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
94
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
95
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
96
-)%.c $(SRCDIR)%.h
97
-# 0, ordinary
98
-# the
99
-#.
100
-SQLITE3.1 = $(SRCDIR
101
-# 0, ordinary
102
-# the
103
-#.
104
-SQLITE3.1 = $(SRCDIR../src)/src$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
105
-)/th.hh"
106
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
107
-OX)/miniz..extsrc.extsrc........RCDIR)/OBJDIR = .
108
-OX=$(B)/extsrcXXXXX..
109
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
110
-)/th.hh"
111
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
112
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
113
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
114
-)%.c $(SRCDIR)%.h
115
-# 0, ordinary
116
-# the
117
-#.
118
-SQLITE3.1 = $(SRCDIR
119
-# 0, ordinary
120
-# the
121
-#.
122
-SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
123
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
124
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
125
-)/th.hh"
126
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
127
-OX)/minizRCDIR)/OBJDIR = .
128
-OX=$(B)/extsrcXXXXX..
129
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
130
-..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
131
-)/th.hh"
132
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
133
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
134
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
135
-)%.c $(SRCDIR)%.h
136
-# 0, ordinary
137
-# the
138
-#.
139
-SQLITE3.1 = $(SRCDIR
140
-# 0, ordinary
141
-# the
142
-#.
143
-SQLITE3.1 = $(SRCDIR../src)\translatemakeheaders$E: $(SRCDIRsrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrcRCDIR)/OBJDIR = .
144
-OX=$(B)/extsrcXXXXX..
145
-: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..........src$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
146
-)/th.hh"
147
-.extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
148
-OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
149
-OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
150
-)%.c $(SRCDIR)%.h
151
-# 0, ordinary
152
-# the
153
-#.
154
-SQLITE3.1 = $(SRCDIR
155
-# 0, ordinary
156
-# the
157
-#.
158
-SQLITE3.1 = $(SRCDIR../srcRCDIR)/OBJDIR = .
1592
OX=$(B)/extsrcXXXXX..
1603
: $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
1614
)/th.hh"
--- a/tools/makemake.tcl
+++ b/tools/makemake.tcl
@@ -1,161 +1,4 @@
1 RCDIR)/OBJDIR = .
2 OX=$(B)/extsrcXXXXX..
3 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
4 )/th.hh"
5 .extsrc...........extsrc)\sheRCDIR)/src; BJDIR = .
6 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
7 )%.c $(SRCDIR)%.h
8 # 0, ordinary
9 # the
10 #.
11 SQLITE3.1 = $(SRCDIR
12 # 0, ordinary
13 # the
14 #.
15 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
16 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
17 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
18 )/th.hh"
19 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
20 OX)/minizRCDIR)/OBJDIR = .
21 OX=$(B)/extsrcXXXXX..
22 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
23 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
24 )/th.hh"
25 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
26 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
27 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
28 )%.c $(SRCDIR)%.h
29 # 0, ordinary
30 # the
31 #.
32 SQLITE3.1 = $(SRCDIR
33 # 0, ordinary
34 # the
35 #.
36 SQLITE3.1 = $(SRCDIR../srcputs "building main.mkmain.mksrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
37 )/th.hh"
38 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
39 OX)/miniz..extsrc.extsrc.........RRCDIR)/OBJDIR = .
40 OX=$(B)/extsrcXXXXX..
41 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
42 )/th.hh"
43 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
44 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
45 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
46 )%.c $(SRCDIR)%.h
47 # 0, ordinary
48 # the
49 #.
50 SQLITE3.1 = $(SRCDIR
51 # 0, ordinary
52 # the
53 #.
54 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
55 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
56 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
57 )/th.hh"
58 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
59 OX)/minizRCDIR)/OBJDIR = .
60 OX=$(B)/extsrcXXXXX..
61 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
62 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
63 )/th.hh"
64 .extsrc...........extsrc)\sheRCDIR)/OBJDIR $(SRCDIR)/(OBJDIR)/mkindex $(SRCDIR(SRCDIR.....extRCDIR)/OBJDIR = .
65 OX=$(B)/e $(SRCDIR)/codecheck1codecheck1 $(SRCDIRsrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
66 )/th.hh"
67 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
68 OX)/miniz..extsrc.extsrc.........RRCDIR)/OBJDIR = .
69 OX=$(B)/extsrcXXXXX..
70 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
71 )/th.hh"
72 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
73 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
74 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
75 )%.c $(SRCDIR)%.h
76 # 0, ordinary
77 # the
78 #.
79 SQLITE3.1 = $(SRCDIR
80 # 0, ordinary
81 # the
82 #.
83 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
84 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
85 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
86 )/th.hh"
87 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
88 OX)/minizRCDIR)/OBJDIR = .
89 OX=$(B)/extsrcXXXXX..
90 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
91 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
92 )/th.hh"
93 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
94 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
95 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
96 )%.c $(SRCDIR)%.h
97 # 0, ordinary
98 # the
99 #.
100 SQLITE3.1 = $(SRCDIR
101 # 0, ordinary
102 # the
103 #.
104 SQLITE3.1 = $(SRCDIR../src)/src$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
105 )/th.hh"
106 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
107 OX)/miniz..extsrc.extsrc........RCDIR)/OBJDIR = .
108 OX=$(B)/extsrcXXXXX..
109 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
110 )/th.hh"
111 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
112 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
113 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
114 )%.c $(SRCDIR)%.h
115 # 0, ordinary
116 # the
117 #.
118 SQLITE3.1 = $(SRCDIR
119 # 0, ordinary
120 # the
121 #.
122 SQLITE3.1 = $(SRCDIRB)/extsrcXXXXX..
123 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
124 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
125 )/th.hh"
126 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
127 OX)/minizRCDIR)/OBJDIR = .
128 OX=$(B)/extsrcXXXXX..
129 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = $(SRCDIR...\$(SRCDIR..extsrch"
130 ..R......extsrc.extsrc.....@ $(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
131 )/th.hh"
132 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
133 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
134 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
135 )%.c $(SRCDIR)%.h
136 # 0, ordinary
137 # the
138 #.
139 SQLITE3.1 = $(SRCDIR
140 # 0, ordinary
141 # the
142 #.
143 SQLITE3.1 = $(SRCDIR../src)\translatemakeheaders$E: $(SRCDIRsrc$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrcRCDIR)/OBJDIR = .
144 OX=$(B)/extsrcXXXXX..
145 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..........src$(SRCDIR.MKINDEX): $(SRCDIR........1 = $(SRCDIR....1 = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
146 )/th.hh"
147 .extsrc...........extsrc)\sheRCDIR)/OBJDIR = .
148 OX)/miniz..extsrc.extsrc.........RCDIR)/OBJDIR = .
149 OX=$(B)/exts)/miniz)\shell)\])\)\miniz.)\\"$@"
150 )%.c $(SRCDIR)%.h
151 # 0, ordinary
152 # the
153 #.
154 SQLITE3.1 = $(SRCDIR
155 # 0, ordinary
156 # the
157 #.
158 SQLITE3.1 = $(SRCDIR../srcRCDIR)/OBJDIR = .
159 OX=$(B)/extsrcXXXXX..
160 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
161 )/th.hh"
--- a/tools/makemake.tcl
+++ b/tools/makemake.tcl
@@ -1,161 +1,4 @@
1 RCDIR)/OBJDIR = .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2 OX=$(B)/extsrcXXXXX..
3 : $(SRCDIR....... $(SRCDIR.....1 = $(SRCDIR....1 = = $(SRCDIR.....extsrc.extsrc...........extsrc)\shell..................sqlite3.h"
4 )/th.hh"

No diff available

No diff available

No diff available

No diff available

--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -1,8 +1,8 @@
11
#
22
##############################################################################
3
-# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
3
+# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
44
##############################################################################
55
#
66
# This file is automatically generated. Instead of editing this
77
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
88
# to regenerate this file.
@@ -129,11 +129,11 @@
129129
# compiling standard fossil utils
130130
$(UTILS_OBJ): %.obj: $(SRCDIR)%.c
131131
$(CC) $(CCFLAGS) $(INCLUDE) "$<" -Fo"$@"
132132
133133
# compile special windows utils
134
-version.obj: $(SRCDIR)mkversion.c
134
+version.obj: $(SRCDIR.tools)mkversion.c
135135
$(CC) $(CCFLAGS) $(INCLUDE) "$<" -Fo"$@"
136136
137137
# generate the translated c-source files
138138
$(TRANSLATEDSRC): %_.c: $(SRCDIR)%.c translate.exe
139139
translate.exe $< >$@
140140
--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -1,8 +1,8 @@
1 #
2 ##############################################################################
3 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
4 ##############################################################################
5 #
6 # This file is automatically generated. Instead of editing this
7 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
8 # to regenerate this file.
@@ -129,11 +129,11 @@
129 # compiling standard fossil utils
130 $(UTILS_OBJ): %.obj: $(SRCDIR)%.c
131 $(CC) $(CCFLAGS) $(INCLUDE) "$<" -Fo"$@"
132
133 # compile special windows utils
134 version.obj: $(SRCDIR)mkversion.c
135 $(CC) $(CCFLAGS) $(INCLUDE) "$<" -Fo"$@"
136
137 # generate the translated c-source files
138 $(TRANSLATEDSRC): %_.c: $(SRCDIR)%.c translate.exe
139 translate.exe $< >$@
140
--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -1,8 +1,8 @@
1 #
2 ##############################################################################
3 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
4 ##############################################################################
5 #
6 # This file is automatically generated. Instead of editing this
7 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
8 # to regenerate this file.
@@ -129,11 +129,11 @@
129 # compiling standard fossil utils
130 $(UTILS_OBJ): %.obj: $(SRCDIR)%.c
131 $(CC) $(CCFLAGS) $(INCLUDE) "$<" -Fo"$@"
132
133 # compile special windows utils
134 version.obj: $(SRCDIR.tools)mkversion.c
135 $(CC) $(CCFLAGS) $(INCLUDE) "$<" -Fo"$@"
136
137 # generate the translated c-source files
138 $(TRANSLATEDSRC): %_.c: $(SRCDIR)%.c translate.exe
139 translate.exe $< >$@
140
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -1,8 +1,8 @@
11
#
22
##############################################################################
3
-# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
3
+# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
44
##############################################################################
55
#
66
# This file is automatically generated. Instead of editing this
77
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
88
# to regenerate this file.
@@ -56,26 +56,26 @@
5656
+echo fossil >> $@
5757
+echo $(LIBS) >> $@
5858
+echo. >> $@
5959
+echo fossil >> $@
6060
61
-translate$E: $(SRCDIR)\translate.c
61
+translate$E: $(SRCDIR.tools)\translate.c
6262
$(BCC) -o$@ $**
6363
64
-makeheaders$E: $(SRCDIR)\makeheaders.c
64
+makeheaders$E: $(SRCDIR.tools)\makeheaders.c
6565
$(BCC) -o$@ $**
6666
67
-mkindex$E: $(SRCDIR)\mkindex.c
67
+mkindex$E: $(SRCDIR.tools)\mkindex.c
6868
$(BCC) -o$@ $**
6969
7070
mkbuiltin$E: $(SRCDIR)\mkbuiltin.c
7171
$(BCC) -o$@ $**
7272
73
-mkversion$E: $(SRCDIR)\mkversion.c
73
+mkversion$E: $(SRCDIR.tools)\mkversion.c
7474
$(BCC) -o$@ $**
7575
76
-codecheck1$E: $(SRCDIR)\codecheck1.c
76
+codecheck1$E: $(SRCDIR.tools)\codecheck1.c
7777
$(BCC) -o$@ $**
7878
7979
$(OBJDIR)\shell$O : $(SRCDIR)\shell.c
8080
$(TCC) -o$@ -c $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $**
8181
8282
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -1,8 +1,8 @@
1 #
2 ##############################################################################
3 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
4 ##############################################################################
5 #
6 # This file is automatically generated. Instead of editing this
7 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
8 # to regenerate this file.
@@ -56,26 +56,26 @@
56 +echo fossil >> $@
57 +echo $(LIBS) >> $@
58 +echo. >> $@
59 +echo fossil >> $@
60
61 translate$E: $(SRCDIR)\translate.c
62 $(BCC) -o$@ $**
63
64 makeheaders$E: $(SRCDIR)\makeheaders.c
65 $(BCC) -o$@ $**
66
67 mkindex$E: $(SRCDIR)\mkindex.c
68 $(BCC) -o$@ $**
69
70 mkbuiltin$E: $(SRCDIR)\mkbuiltin.c
71 $(BCC) -o$@ $**
72
73 mkversion$E: $(SRCDIR)\mkversion.c
74 $(BCC) -o$@ $**
75
76 codecheck1$E: $(SRCDIR)\codecheck1.c
77 $(BCC) -o$@ $**
78
79 $(OBJDIR)\shell$O : $(SRCDIR)\shell.c
80 $(TCC) -o$@ -c $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $**
81
82
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -1,8 +1,8 @@
1 #
2 ##############################################################################
3 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
4 ##############################################################################
5 #
6 # This file is automatically generated. Instead of editing this
7 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
8 # to regenerate this file.
@@ -56,26 +56,26 @@
56 +echo fossil >> $@
57 +echo $(LIBS) >> $@
58 +echo. >> $@
59 +echo fossil >> $@
60
61 translate$E: $(SRCDIR.tools)\translate.c
62 $(BCC) -o$@ $**
63
64 makeheaders$E: $(SRCDIR.tools)\makeheaders.c
65 $(BCC) -o$@ $**
66
67 mkindex$E: $(SRCDIR.tools)\mkindex.c
68 $(BCC) -o$@ $**
69
70 mkbuiltin$E: $(SRCDIR)\mkbuiltin.c
71 $(BCC) -o$@ $**
72
73 mkversion$E: $(SRCDIR.tools)\mkversion.c
74 $(BCC) -o$@ $**
75
76 codecheck1$E: $(SRCDIR.tools)\codecheck1.c
77 $(BCC) -o$@ $**
78
79 $(OBJDIR)\shell$O : $(SRCDIR)\shell.c
80 $(TCC) -o$@ -c $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $**
81
82
+14 -76
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -1,9 +1,9 @@
11
#!/usr/bin/make
22
#
33
##############################################################################
4
-# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
4
+# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
55
##############################################################################
66
#
77
# This file is automatically generated. Instead of editing this
88
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
99
# to regenerate this file.
@@ -617,73 +617,11 @@
617617
$(SRCDIR)/../skins/plain_gray/footer.txt \
618618
$(SRCDIR)/../skins/plain_gray/header.txt \
619619
$(SRCDIR)/../skins/xekri/css.txt \
620620
$(SRCDIR)/../skins/xekri/details.txt \
621621
$(SRCDIR)/../skins/xekri/footer.txt \
622
- $(SRCDIR)/../skins/xekri/header.txt \
623
- $(SRCDIR)/accordion.js \
624
- $(SRCDIR)/alerts/bflat2.wav \
625
- $(SRCDIR)/alerts/bflat3.wav \
626
- $(SRCDIR)/alerts/bloop.wav \
627
- $(SRCDIR)/alerts/plunk.wav \
628
- $(SRCDIR)/ci_edit.js \
629
- $(SRCDIR)/copybtn.js \
630
- $(SRCDIR)/default.css \
631
- $(SRCDIR)/diff.js \
632
- $(SRCDIR)/diff.tcl \
633
- $(SRCDIR)/forum.js \
634
- $(SRCDIR)/fossil.bootstrap.js \
635
- $(SRCDIR)/fossil.confirmer.js \
636
- $(SRCDIR)/fossil.copybutton.js \
637
- $(SRCDIR)/fossil.diff.js \
638
- $(SRCDIR)/fossil.dom.js \
639
- $(SRCDIR)/fossil.fetch.js \
640
- $(SRCDIR)/fossil.numbered-lines.js \
641
- $(SRCDIR)/fossil.page.brlist.js \
642
- $(SRCDIR)/fossil.page.chat.js \
643
- $(SRCDIR)/fossil.page.fileedit.js \
644
- $(SRCDIR)/fossil.page.forumpost.js \
645
- $(SRCDIR)/fossil.page.pikchrshow.js \
646
- $(SRCDIR)/fossil.page.whistory.js \
647
- $(SRCDIR)/fossil.page.wikiedit.js \
648
- $(SRCDIR)/fossil.pikchr.js \
649
- $(SRCDIR)/fossil.popupwidget.js \
650
- $(SRCDIR)/fossil.storage.js \
651
- $(SRCDIR)/fossil.tabs.js \
652
- $(SRCDIR)/fossil.wikiedit-wysiwyg.js \
653
- $(SRCDIR)/graph.js \
654
- $(SRCDIR)/hbmenu.js \
655
- $(SRCDIR)/href.js \
656
- $(SRCDIR)/login.js \
657
- $(SRCDIR)/markdown.md \
658
- $(SRCDIR)/menu.js \
659
- $(SRCDIR)/scroll.js \
660
- $(SRCDIR)/skin.js \
661
- $(SRCDIR)/sorttable.js \
662
- $(SRCDIR)/sounds/0.wav \
663
- $(SRCDIR)/sounds/1.wav \
664
- $(SRCDIR)/sounds/2.wav \
665
- $(SRCDIR)/sounds/3.wav \
666
- $(SRCDIR)/sounds/4.wav \
667
- $(SRCDIR)/sounds/5.wav \
668
- $(SRCDIR)/sounds/6.wav \
669
- $(SRCDIR)/sounds/7.wav \
670
- $(SRCDIR)/sounds/8.wav \
671
- $(SRCDIR)/sounds/9.wav \
672
- $(SRCDIR)/sounds/a.wav \
673
- $(SRCDIR)/sounds/b.wav \
674
- $(SRCDIR)/sounds/c.wav \
675
- $(SRCDIR)/sounds/d.wav \
676
- $(SRCDIR)/sounds/e.wav \
677
- $(SRCDIR)/sounds/f.wav \
678
- $(SRCDIR)/style.admin_log.css \
679
- $(SRCDIR)/style.chat.css \
680
- $(SRCDIR)/style.fileedit.css \
681
- $(SRCDIR)/style.wikiedit.css \
682
- $(SRCDIR)/tree.js \
683
- $(SRCDIR)/useredit.js \
684
- $(SRCDIR)/wiki.wiki
622
+ $(SRCDIR)/../skins/xekri/header.txt
685623
686624
TRANS_SRC = \
687625
$(OBJDIR)/add_.c \
688626
$(OBJDIR)/ajax_.c \
689627
$(OBJDIR)/alerts_.c \
@@ -1053,27 +991,27 @@
1053991
$(MKDIR) $(subst /,\,$(OBJDIR))
1054992
else
1055993
$(MKDIR) $(OBJDIR)
1056994
endif
1057995
1058
-$(TRANSLATE): $(SRCDIR)/translate.c
1059
- $(XBCC) -o $@ $(SRCDIR)/translate.c
1060
-
1061
-$(MAKEHEADERS): $(SRCDIR)/makeheaders.c
1062
- $(XBCC) -o $@ $(SRCDIR)/makeheaders.c
1063
-
1064
-$(MKINDEX): $(SRCDIR)/mkindex.c
1065
- $(XBCC) -o $@ $(SRCDIR)/mkindex.c
996
+$(TRANSLATE): $(SRCDIR.tools)/translate.c
997
+ $(XBCC) -o $@ $(SRCDIR.tools)/translate.c
998
+
999
+$(MAKEHEADERS): $(SRCDIR.tools)/makeheaders.c
1000
+ $(XBCC) -o $@ $(SRCDIR.tools)/makeheaders.c
1001
+
1002
+$(MKINDEX): $(SRCDIR.tools)/mkindex.c
1003
+ $(XBCC) -o $@ $(SRCDIR.tools)/mkindex.c
10661004
10671005
$(MKBUILTIN): $(SRCDIR)/mkbuiltin.c
10681006
$(XBCC) -o $@ $(SRCDIR)/mkbuiltin.c
10691007
1070
-$(MKVERSION): $(SRCDIR)/mkversion.c
1071
- $(XBCC) -o $@ $(SRCDIR)/mkversion.c
1008
+$(MKVERSION): $(SRCDIR.tools)/mkversion.c
1009
+ $(XBCC) -o $@ $(SRCDIR.tools)/mkversion.c
10721010
1073
-$(CODECHECK1): $(SRCDIR)/codecheck1.c
1074
- $(XBCC) -o $@ $(SRCDIR)/codecheck1.c
1011
+$(CODECHECK1): $(SRCDIR.tools)/codecheck1.c
1012
+ $(XBCC) -o $@ $(SRCDIR.tools)/codecheck1.c
10751013
10761014
# WARNING. DANGER. Running the test suite modifies the repository the
10771015
# build is done from, i.e. the checkout belongs to. Do not sync/push
10781016
# the repository after running the tests.
10791017
test: $(OBJDIR) $(APPNAME)
10801018
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -1,9 +1,9 @@
1 #!/usr/bin/make
2 #
3 ##############################################################################
4 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
5 ##############################################################################
6 #
7 # This file is automatically generated. Instead of editing this
8 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
9 # to regenerate this file.
@@ -617,73 +617,11 @@
617 $(SRCDIR)/../skins/plain_gray/footer.txt \
618 $(SRCDIR)/../skins/plain_gray/header.txt \
619 $(SRCDIR)/../skins/xekri/css.txt \
620 $(SRCDIR)/../skins/xekri/details.txt \
621 $(SRCDIR)/../skins/xekri/footer.txt \
622 $(SRCDIR)/../skins/xekri/header.txt \
623 $(SRCDIR)/accordion.js \
624 $(SRCDIR)/alerts/bflat2.wav \
625 $(SRCDIR)/alerts/bflat3.wav \
626 $(SRCDIR)/alerts/bloop.wav \
627 $(SRCDIR)/alerts/plunk.wav \
628 $(SRCDIR)/ci_edit.js \
629 $(SRCDIR)/copybtn.js \
630 $(SRCDIR)/default.css \
631 $(SRCDIR)/diff.js \
632 $(SRCDIR)/diff.tcl \
633 $(SRCDIR)/forum.js \
634 $(SRCDIR)/fossil.bootstrap.js \
635 $(SRCDIR)/fossil.confirmer.js \
636 $(SRCDIR)/fossil.copybutton.js \
637 $(SRCDIR)/fossil.diff.js \
638 $(SRCDIR)/fossil.dom.js \
639 $(SRCDIR)/fossil.fetch.js \
640 $(SRCDIR)/fossil.numbered-lines.js \
641 $(SRCDIR)/fossil.page.brlist.js \
642 $(SRCDIR)/fossil.page.chat.js \
643 $(SRCDIR)/fossil.page.fileedit.js \
644 $(SRCDIR)/fossil.page.forumpost.js \
645 $(SRCDIR)/fossil.page.pikchrshow.js \
646 $(SRCDIR)/fossil.page.whistory.js \
647 $(SRCDIR)/fossil.page.wikiedit.js \
648 $(SRCDIR)/fossil.pikchr.js \
649 $(SRCDIR)/fossil.popupwidget.js \
650 $(SRCDIR)/fossil.storage.js \
651 $(SRCDIR)/fossil.tabs.js \
652 $(SRCDIR)/fossil.wikiedit-wysiwyg.js \
653 $(SRCDIR)/graph.js \
654 $(SRCDIR)/hbmenu.js \
655 $(SRCDIR)/href.js \
656 $(SRCDIR)/login.js \
657 $(SRCDIR)/markdown.md \
658 $(SRCDIR)/menu.js \
659 $(SRCDIR)/scroll.js \
660 $(SRCDIR)/skin.js \
661 $(SRCDIR)/sorttable.js \
662 $(SRCDIR)/sounds/0.wav \
663 $(SRCDIR)/sounds/1.wav \
664 $(SRCDIR)/sounds/2.wav \
665 $(SRCDIR)/sounds/3.wav \
666 $(SRCDIR)/sounds/4.wav \
667 $(SRCDIR)/sounds/5.wav \
668 $(SRCDIR)/sounds/6.wav \
669 $(SRCDIR)/sounds/7.wav \
670 $(SRCDIR)/sounds/8.wav \
671 $(SRCDIR)/sounds/9.wav \
672 $(SRCDIR)/sounds/a.wav \
673 $(SRCDIR)/sounds/b.wav \
674 $(SRCDIR)/sounds/c.wav \
675 $(SRCDIR)/sounds/d.wav \
676 $(SRCDIR)/sounds/e.wav \
677 $(SRCDIR)/sounds/f.wav \
678 $(SRCDIR)/style.admin_log.css \
679 $(SRCDIR)/style.chat.css \
680 $(SRCDIR)/style.fileedit.css \
681 $(SRCDIR)/style.wikiedit.css \
682 $(SRCDIR)/tree.js \
683 $(SRCDIR)/useredit.js \
684 $(SRCDIR)/wiki.wiki
685
686 TRANS_SRC = \
687 $(OBJDIR)/add_.c \
688 $(OBJDIR)/ajax_.c \
689 $(OBJDIR)/alerts_.c \
@@ -1053,27 +991,27 @@
1053 $(MKDIR) $(subst /,\,$(OBJDIR))
1054 else
1055 $(MKDIR) $(OBJDIR)
1056 endif
1057
1058 $(TRANSLATE): $(SRCDIR)/translate.c
1059 $(XBCC) -o $@ $(SRCDIR)/translate.c
1060
1061 $(MAKEHEADERS): $(SRCDIR)/makeheaders.c
1062 $(XBCC) -o $@ $(SRCDIR)/makeheaders.c
1063
1064 $(MKINDEX): $(SRCDIR)/mkindex.c
1065 $(XBCC) -o $@ $(SRCDIR)/mkindex.c
1066
1067 $(MKBUILTIN): $(SRCDIR)/mkbuiltin.c
1068 $(XBCC) -o $@ $(SRCDIR)/mkbuiltin.c
1069
1070 $(MKVERSION): $(SRCDIR)/mkversion.c
1071 $(XBCC) -o $@ $(SRCDIR)/mkversion.c
1072
1073 $(CODECHECK1): $(SRCDIR)/codecheck1.c
1074 $(XBCC) -o $@ $(SRCDIR)/codecheck1.c
1075
1076 # WARNING. DANGER. Running the test suite modifies the repository the
1077 # build is done from, i.e. the checkout belongs to. Do not sync/push
1078 # the repository after running the tests.
1079 test: $(OBJDIR) $(APPNAME)
1080
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -1,9 +1,9 @@
1 #!/usr/bin/make
2 #
3 ##############################################################################
4 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
5 ##############################################################################
6 #
7 # This file is automatically generated. Instead of editing this
8 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
9 # to regenerate this file.
@@ -617,73 +617,11 @@
617 $(SRCDIR)/../skins/plain_gray/footer.txt \
618 $(SRCDIR)/../skins/plain_gray/header.txt \
619 $(SRCDIR)/../skins/xekri/css.txt \
620 $(SRCDIR)/../skins/xekri/details.txt \
621 $(SRCDIR)/../skins/xekri/footer.txt \
622 $(SRCDIR)/../skins/xekri/header.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
624 TRANS_SRC = \
625 $(OBJDIR)/add_.c \
626 $(OBJDIR)/ajax_.c \
627 $(OBJDIR)/alerts_.c \
@@ -1053,27 +991,27 @@
991 $(MKDIR) $(subst /,\,$(OBJDIR))
992 else
993 $(MKDIR) $(OBJDIR)
994 endif
995
996 $(TRANSLATE): $(SRCDIR.tools)/translate.c
997 $(XBCC) -o $@ $(SRCDIR.tools)/translate.c
998
999 $(MAKEHEADERS): $(SRCDIR.tools)/makeheaders.c
1000 $(XBCC) -o $@ $(SRCDIR.tools)/makeheaders.c
1001
1002 $(MKINDEX): $(SRCDIR.tools)/mkindex.c
1003 $(XBCC) -o $@ $(SRCDIR.tools)/mkindex.c
1004
1005 $(MKBUILTIN): $(SRCDIR)/mkbuiltin.c
1006 $(XBCC) -o $@ $(SRCDIR)/mkbuiltin.c
1007
1008 $(MKVERSION): $(SRCDIR.tools)/mkversion.c
1009 $(XBCC) -o $@ $(SRCDIR.tools)/mkversion.c
1010
1011 $(CODECHECK1): $(SRCDIR.tools)/codecheck1.c
1012 $(XBCC) -o $@ $(SRCDIR.tools)/codecheck1.c
1013
1014 # WARNING. DANGER. Running the test suite modifies the repository the
1015 # build is done from, i.e. the checkout belongs to. Do not sync/push
1016 # the repository after running the tests.
1017 test: $(OBJDIR) $(APPNAME)
1018
+7 -131
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -1,8 +1,8 @@
11
#
22
##############################################################################
3
-# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
3
+# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
44
##############################################################################
55
#
66
#
77
# This file is automatically generated. Instead of editing this
88
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
@@ -559,73 +559,11 @@
559559
"$(SRCDIR)\..\skins\plain_gray\footer.txt" \
560560
"$(SRCDIR)\..\skins\plain_gray\header.txt" \
561561
"$(SRCDIR)\..\skins\xekri\css.txt" \
562562
"$(SRCDIR)\..\skins\xekri\details.txt" \
563563
"$(SRCDIR)\..\skins\xekri\footer.txt" \
564
- "$(SRCDIR)\..\skins\xekri\header.txt" \
565
- "$(SRCDIR)\accordion.js" \
566
- "$(SRCDIR)\alerts\bflat2.wav" \
567
- "$(SRCDIR)\alerts\bflat3.wav" \
568
- "$(SRCDIR)\alerts\bloop.wav" \
569
- "$(SRCDIR)\alerts\plunk.wav" \
570
- "$(SRCDIR)\ci_edit.js" \
571
- "$(SRCDIR)\copybtn.js" \
572
- "$(SRCDIR)\default.css" \
573
- "$(SRCDIR)\diff.js" \
574
- "$(SRCDIR)\diff.tcl" \
575
- "$(SRCDIR)\forum.js" \
576
- "$(SRCDIR)\fossil.bootstrap.js" \
577
- "$(SRCDIR)\fossil.confirmer.js" \
578
- "$(SRCDIR)\fossil.copybutton.js" \
579
- "$(SRCDIR)\fossil.diff.js" \
580
- "$(SRCDIR)\fossil.dom.js" \
581
- "$(SRCDIR)\fossil.fetch.js" \
582
- "$(SRCDIR)\fossil.numbered-lines.js" \
583
- "$(SRCDIR)\fossil.page.brlist.js" \
584
- "$(SRCDIR)\fossil.page.chat.js" \
585
- "$(SRCDIR)\fossil.page.fileedit.js" \
586
- "$(SRCDIR)\fossil.page.forumpost.js" \
587
- "$(SRCDIR)\fossil.page.pikchrshow.js" \
588
- "$(SRCDIR)\fossil.page.whistory.js" \
589
- "$(SRCDIR)\fossil.page.wikiedit.js" \
590
- "$(SRCDIR)\fossil.pikchr.js" \
591
- "$(SRCDIR)\fossil.popupwidget.js" \
592
- "$(SRCDIR)\fossil.storage.js" \
593
- "$(SRCDIR)\fossil.tabs.js" \
594
- "$(SRCDIR)\fossil.wikiedit-wysiwyg.js" \
595
- "$(SRCDIR)\graph.js" \
596
- "$(SRCDIR)\hbmenu.js" \
597
- "$(SRCDIR)\href.js" \
598
- "$(SRCDIR)\login.js" \
599
- "$(SRCDIR)\markdown.md" \
600
- "$(SRCDIR)\menu.js" \
601
- "$(SRCDIR)\scroll.js" \
602
- "$(SRCDIR)\skin.js" \
603
- "$(SRCDIR)\sorttable.js" \
604
- "$(SRCDIR)\sounds\0.wav" \
605
- "$(SRCDIR)\sounds\1.wav" \
606
- "$(SRCDIR)\sounds\2.wav" \
607
- "$(SRCDIR)\sounds\3.wav" \
608
- "$(SRCDIR)\sounds\4.wav" \
609
- "$(SRCDIR)\sounds\5.wav" \
610
- "$(SRCDIR)\sounds\6.wav" \
611
- "$(SRCDIR)\sounds\7.wav" \
612
- "$(SRCDIR)\sounds\8.wav" \
613
- "$(SRCDIR)\sounds\9.wav" \
614
- "$(SRCDIR)\sounds\a.wav" \
615
- "$(SRCDIR)\sounds\b.wav" \
616
- "$(SRCDIR)\sounds\c.wav" \
617
- "$(SRCDIR)\sounds\d.wav" \
618
- "$(SRCDIR)\sounds\e.wav" \
619
- "$(SRCDIR)\sounds\f.wav" \
620
- "$(SRCDIR)\style.admin_log.css" \
621
- "$(SRCDIR)\style.chat.css" \
622
- "$(SRCDIR)\style.fileedit.css" \
623
- "$(SRCDIR)\style.wikiedit.css" \
624
- "$(SRCDIR)\tree.js" \
625
- "$(SRCDIR)\useredit.js" \
626
- "$(SRCDIR)\wiki.wiki"
564
+ "$(SRCDIR)\..\skins\xekri\header.txt"
627565
628566
OBJ = "$(OX)\add$O" \
629567
"$(OX)\ajax$O" \
630568
"$(OX)\alerts$O" \
631569
"$(OX)\allrepo$O" \
@@ -1013,26 +951,26 @@
1013951
!if $(FOSSIL_ENABLE_MINIZ)!=0
1014952
echo "$(OX)\miniz.obj" >> $@
1015953
!endif
1016954
echo $(LIBS) >> $@
1017955
1018
-"$(OBJDIR)\translate$E": "$(SRCDIR)\translate.c"
956
+"$(OBJDIR)\translate$E": "$(SRCDIR.tools)\translate.c"
1019957
$(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1020958
1021
-"$(OBJDIR)\makeheaders$E": "$(SRCDIR)\makeheaders.c"
959
+"$(OBJDIR)\makeheaders$E": "$(SRCDIR.tools)\makeheaders.c"
1022960
$(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1023961
1024
-"$(OBJDIR)\mkindex$E": "$(SRCDIR)\mkindex.c"
962
+"$(OBJDIR)\mkindex$E": "$(SRCDIR.tools)\mkindex.c"
1025963
$(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1026964
1027965
"$(OBJDIR)\mkbuiltin$E": "$(SRCDIR)\mkbuiltin.c"
1028966
$(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1029967
1030
-"$(OBJDIR)\mkversion$E": "$(SRCDIR)\mkversion.c"
968
+"$(OBJDIR)\mkversion$E": "$(SRCDIR.tools)\mkversion.c"
1031969
$(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1032970
1033
-"$(OBJDIR)\codecheck1$E": "$(SRCDIR)\codecheck1.c"
971
+"$(OBJDIR)\codecheck1$E": "$(SRCDIR.tools)\codecheck1.c"
1034972
$(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1035973
1036974
!if $(USE_SEE)!=0
1037975
SEE_FLAGS = /DSQLITE_HAS_CODEC=1 /DSQLITE_SHELL_DBKEY_PROC=fossil_key
1038976
SQLITE3_SHELL_SRC = $(SRCDIR)\shell-see.c
@@ -1169,72 +1107,10 @@
11691107
echo "$(SRCDIR)\../skins/plain_gray/header.txt" >> $@
11701108
echo "$(SRCDIR)\../skins/xekri/css.txt" >> $@
11711109
echo "$(SRCDIR)\../skins/xekri/details.txt" >> $@
11721110
echo "$(SRCDIR)\../skins/xekri/footer.txt" >> $@
11731111
echo "$(SRCDIR)\../skins/xekri/header.txt" >> $@
1174
- echo "$(SRCDIR)\accordion.js" >> $@
1175
- echo "$(SRCDIR)\alerts/bflat2.wav" >> $@
1176
- echo "$(SRCDIR)\alerts/bflat3.wav" >> $@
1177
- echo "$(SRCDIR)\alerts/bloop.wav" >> $@
1178
- echo "$(SRCDIR)\alerts/plunk.wav" >> $@
1179
- echo "$(SRCDIR)\ci_edit.js" >> $@
1180
- echo "$(SRCDIR)\copybtn.js" >> $@
1181
- echo "$(SRCDIR)\default.css" >> $@
1182
- echo "$(SRCDIR)\diff.js" >> $@
1183
- echo "$(SRCDIR)\diff.tcl" >> $@
1184
- echo "$(SRCDIR)\forum.js" >> $@
1185
- echo "$(SRCDIR)\fossil.bootstrap.js" >> $@
1186
- echo "$(SRCDIR)\fossil.confirmer.js" >> $@
1187
- echo "$(SRCDIR)\fossil.copybutton.js" >> $@
1188
- echo "$(SRCDIR)\fossil.diff.js" >> $@
1189
- echo "$(SRCDIR)\fossil.dom.js" >> $@
1190
- echo "$(SRCDIR)\fossil.fetch.js" >> $@
1191
- echo "$(SRCDIR)\fossil.numbered-lines.js" >> $@
1192
- echo "$(SRCDIR)\fossil.page.brlist.js" >> $@
1193
- echo "$(SRCDIR)\fossil.page.chat.js" >> $@
1194
- echo "$(SRCDIR)\fossil.page.fileedit.js" >> $@
1195
- echo "$(SRCDIR)\fossil.page.forumpost.js" >> $@
1196
- echo "$(SRCDIR)\fossil.page.pikchrshow.js" >> $@
1197
- echo "$(SRCDIR)\fossil.page.whistory.js" >> $@
1198
- echo "$(SRCDIR)\fossil.page.wikiedit.js" >> $@
1199
- echo "$(SRCDIR)\fossil.pikchr.js" >> $@
1200
- echo "$(SRCDIR)\fossil.popupwidget.js" >> $@
1201
- echo "$(SRCDIR)\fossil.storage.js" >> $@
1202
- echo "$(SRCDIR)\fossil.tabs.js" >> $@
1203
- echo "$(SRCDIR)\fossil.wikiedit-wysiwyg.js" >> $@
1204
- echo "$(SRCDIR)\graph.js" >> $@
1205
- echo "$(SRCDIR)\hbmenu.js" >> $@
1206
- echo "$(SRCDIR)\href.js" >> $@
1207
- echo "$(SRCDIR)\login.js" >> $@
1208
- echo "$(SRCDIR)\markdown.md" >> $@
1209
- echo "$(SRCDIR)\menu.js" >> $@
1210
- echo "$(SRCDIR)\scroll.js" >> $@
1211
- echo "$(SRCDIR)\skin.js" >> $@
1212
- echo "$(SRCDIR)\sorttable.js" >> $@
1213
- echo "$(SRCDIR)\sounds/0.wav" >> $@
1214
- echo "$(SRCDIR)\sounds/1.wav" >> $@
1215
- echo "$(SRCDIR)\sounds/2.wav" >> $@
1216
- echo "$(SRCDIR)\sounds/3.wav" >> $@
1217
- echo "$(SRCDIR)\sounds/4.wav" >> $@
1218
- echo "$(SRCDIR)\sounds/5.wav" >> $@
1219
- echo "$(SRCDIR)\sounds/6.wav" >> $@
1220
- echo "$(SRCDIR)\sounds/7.wav" >> $@
1221
- echo "$(SRCDIR)\sounds/8.wav" >> $@
1222
- echo "$(SRCDIR)\sounds/9.wav" >> $@
1223
- echo "$(SRCDIR)\sounds/a.wav" >> $@
1224
- echo "$(SRCDIR)\sounds/b.wav" >> $@
1225
- echo "$(SRCDIR)\sounds/c.wav" >> $@
1226
- echo "$(SRCDIR)\sounds/d.wav" >> $@
1227
- echo "$(SRCDIR)\sounds/e.wav" >> $@
1228
- echo "$(SRCDIR)\sounds/f.wav" >> $@
1229
- echo "$(SRCDIR)\style.admin_log.css" >> $@
1230
- echo "$(SRCDIR)\style.chat.css" >> $@
1231
- echo "$(SRCDIR)\style.fileedit.css" >> $@
1232
- echo "$(SRCDIR)\style.wikiedit.css" >> $@
1233
- echo "$(SRCDIR)\tree.js" >> $@
1234
- echo "$(SRCDIR)\useredit.js" >> $@
1235
- echo "$(SRCDIR)\wiki.wiki" >> $@
12361112
12371113
"$(OX)\add$O" : "$(OX)\add_.c" "$(OX)\add.h"
12381114
$(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\add_.c"
12391115
12401116
"$(OX)\add_.c" : "$(SRCDIR)\add.c"
12411117
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -1,8 +1,8 @@
1 #
2 ##############################################################################
3 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
4 ##############################################################################
5 #
6 #
7 # This file is automatically generated. Instead of editing this
8 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
@@ -559,73 +559,11 @@
559 "$(SRCDIR)\..\skins\plain_gray\footer.txt" \
560 "$(SRCDIR)\..\skins\plain_gray\header.txt" \
561 "$(SRCDIR)\..\skins\xekri\css.txt" \
562 "$(SRCDIR)\..\skins\xekri\details.txt" \
563 "$(SRCDIR)\..\skins\xekri\footer.txt" \
564 "$(SRCDIR)\..\skins\xekri\header.txt" \
565 "$(SRCDIR)\accordion.js" \
566 "$(SRCDIR)\alerts\bflat2.wav" \
567 "$(SRCDIR)\alerts\bflat3.wav" \
568 "$(SRCDIR)\alerts\bloop.wav" \
569 "$(SRCDIR)\alerts\plunk.wav" \
570 "$(SRCDIR)\ci_edit.js" \
571 "$(SRCDIR)\copybtn.js" \
572 "$(SRCDIR)\default.css" \
573 "$(SRCDIR)\diff.js" \
574 "$(SRCDIR)\diff.tcl" \
575 "$(SRCDIR)\forum.js" \
576 "$(SRCDIR)\fossil.bootstrap.js" \
577 "$(SRCDIR)\fossil.confirmer.js" \
578 "$(SRCDIR)\fossil.copybutton.js" \
579 "$(SRCDIR)\fossil.diff.js" \
580 "$(SRCDIR)\fossil.dom.js" \
581 "$(SRCDIR)\fossil.fetch.js" \
582 "$(SRCDIR)\fossil.numbered-lines.js" \
583 "$(SRCDIR)\fossil.page.brlist.js" \
584 "$(SRCDIR)\fossil.page.chat.js" \
585 "$(SRCDIR)\fossil.page.fileedit.js" \
586 "$(SRCDIR)\fossil.page.forumpost.js" \
587 "$(SRCDIR)\fossil.page.pikchrshow.js" \
588 "$(SRCDIR)\fossil.page.whistory.js" \
589 "$(SRCDIR)\fossil.page.wikiedit.js" \
590 "$(SRCDIR)\fossil.pikchr.js" \
591 "$(SRCDIR)\fossil.popupwidget.js" \
592 "$(SRCDIR)\fossil.storage.js" \
593 "$(SRCDIR)\fossil.tabs.js" \
594 "$(SRCDIR)\fossil.wikiedit-wysiwyg.js" \
595 "$(SRCDIR)\graph.js" \
596 "$(SRCDIR)\hbmenu.js" \
597 "$(SRCDIR)\href.js" \
598 "$(SRCDIR)\login.js" \
599 "$(SRCDIR)\markdown.md" \
600 "$(SRCDIR)\menu.js" \
601 "$(SRCDIR)\scroll.js" \
602 "$(SRCDIR)\skin.js" \
603 "$(SRCDIR)\sorttable.js" \
604 "$(SRCDIR)\sounds\0.wav" \
605 "$(SRCDIR)\sounds\1.wav" \
606 "$(SRCDIR)\sounds\2.wav" \
607 "$(SRCDIR)\sounds\3.wav" \
608 "$(SRCDIR)\sounds\4.wav" \
609 "$(SRCDIR)\sounds\5.wav" \
610 "$(SRCDIR)\sounds\6.wav" \
611 "$(SRCDIR)\sounds\7.wav" \
612 "$(SRCDIR)\sounds\8.wav" \
613 "$(SRCDIR)\sounds\9.wav" \
614 "$(SRCDIR)\sounds\a.wav" \
615 "$(SRCDIR)\sounds\b.wav" \
616 "$(SRCDIR)\sounds\c.wav" \
617 "$(SRCDIR)\sounds\d.wav" \
618 "$(SRCDIR)\sounds\e.wav" \
619 "$(SRCDIR)\sounds\f.wav" \
620 "$(SRCDIR)\style.admin_log.css" \
621 "$(SRCDIR)\style.chat.css" \
622 "$(SRCDIR)\style.fileedit.css" \
623 "$(SRCDIR)\style.wikiedit.css" \
624 "$(SRCDIR)\tree.js" \
625 "$(SRCDIR)\useredit.js" \
626 "$(SRCDIR)\wiki.wiki"
627
628 OBJ = "$(OX)\add$O" \
629 "$(OX)\ajax$O" \
630 "$(OX)\alerts$O" \
631 "$(OX)\allrepo$O" \
@@ -1013,26 +951,26 @@
1013 !if $(FOSSIL_ENABLE_MINIZ)!=0
1014 echo "$(OX)\miniz.obj" >> $@
1015 !endif
1016 echo $(LIBS) >> $@
1017
1018 "$(OBJDIR)\translate$E": "$(SRCDIR)\translate.c"
1019 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1020
1021 "$(OBJDIR)\makeheaders$E": "$(SRCDIR)\makeheaders.c"
1022 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1023
1024 "$(OBJDIR)\mkindex$E": "$(SRCDIR)\mkindex.c"
1025 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1026
1027 "$(OBJDIR)\mkbuiltin$E": "$(SRCDIR)\mkbuiltin.c"
1028 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1029
1030 "$(OBJDIR)\mkversion$E": "$(SRCDIR)\mkversion.c"
1031 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1032
1033 "$(OBJDIR)\codecheck1$E": "$(SRCDIR)\codecheck1.c"
1034 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
1035
1036 !if $(USE_SEE)!=0
1037 SEE_FLAGS = /DSQLITE_HAS_CODEC=1 /DSQLITE_SHELL_DBKEY_PROC=fossil_key
1038 SQLITE3_SHELL_SRC = $(SRCDIR)\shell-see.c
@@ -1169,72 +1107,10 @@
1169 echo "$(SRCDIR)\../skins/plain_gray/header.txt" >> $@
1170 echo "$(SRCDIR)\../skins/xekri/css.txt" >> $@
1171 echo "$(SRCDIR)\../skins/xekri/details.txt" >> $@
1172 echo "$(SRCDIR)\../skins/xekri/footer.txt" >> $@
1173 echo "$(SRCDIR)\../skins/xekri/header.txt" >> $@
1174 echo "$(SRCDIR)\accordion.js" >> $@
1175 echo "$(SRCDIR)\alerts/bflat2.wav" >> $@
1176 echo "$(SRCDIR)\alerts/bflat3.wav" >> $@
1177 echo "$(SRCDIR)\alerts/bloop.wav" >> $@
1178 echo "$(SRCDIR)\alerts/plunk.wav" >> $@
1179 echo "$(SRCDIR)\ci_edit.js" >> $@
1180 echo "$(SRCDIR)\copybtn.js" >> $@
1181 echo "$(SRCDIR)\default.css" >> $@
1182 echo "$(SRCDIR)\diff.js" >> $@
1183 echo "$(SRCDIR)\diff.tcl" >> $@
1184 echo "$(SRCDIR)\forum.js" >> $@
1185 echo "$(SRCDIR)\fossil.bootstrap.js" >> $@
1186 echo "$(SRCDIR)\fossil.confirmer.js" >> $@
1187 echo "$(SRCDIR)\fossil.copybutton.js" >> $@
1188 echo "$(SRCDIR)\fossil.diff.js" >> $@
1189 echo "$(SRCDIR)\fossil.dom.js" >> $@
1190 echo "$(SRCDIR)\fossil.fetch.js" >> $@
1191 echo "$(SRCDIR)\fossil.numbered-lines.js" >> $@
1192 echo "$(SRCDIR)\fossil.page.brlist.js" >> $@
1193 echo "$(SRCDIR)\fossil.page.chat.js" >> $@
1194 echo "$(SRCDIR)\fossil.page.fileedit.js" >> $@
1195 echo "$(SRCDIR)\fossil.page.forumpost.js" >> $@
1196 echo "$(SRCDIR)\fossil.page.pikchrshow.js" >> $@
1197 echo "$(SRCDIR)\fossil.page.whistory.js" >> $@
1198 echo "$(SRCDIR)\fossil.page.wikiedit.js" >> $@
1199 echo "$(SRCDIR)\fossil.pikchr.js" >> $@
1200 echo "$(SRCDIR)\fossil.popupwidget.js" >> $@
1201 echo "$(SRCDIR)\fossil.storage.js" >> $@
1202 echo "$(SRCDIR)\fossil.tabs.js" >> $@
1203 echo "$(SRCDIR)\fossil.wikiedit-wysiwyg.js" >> $@
1204 echo "$(SRCDIR)\graph.js" >> $@
1205 echo "$(SRCDIR)\hbmenu.js" >> $@
1206 echo "$(SRCDIR)\href.js" >> $@
1207 echo "$(SRCDIR)\login.js" >> $@
1208 echo "$(SRCDIR)\markdown.md" >> $@
1209 echo "$(SRCDIR)\menu.js" >> $@
1210 echo "$(SRCDIR)\scroll.js" >> $@
1211 echo "$(SRCDIR)\skin.js" >> $@
1212 echo "$(SRCDIR)\sorttable.js" >> $@
1213 echo "$(SRCDIR)\sounds/0.wav" >> $@
1214 echo "$(SRCDIR)\sounds/1.wav" >> $@
1215 echo "$(SRCDIR)\sounds/2.wav" >> $@
1216 echo "$(SRCDIR)\sounds/3.wav" >> $@
1217 echo "$(SRCDIR)\sounds/4.wav" >> $@
1218 echo "$(SRCDIR)\sounds/5.wav" >> $@
1219 echo "$(SRCDIR)\sounds/6.wav" >> $@
1220 echo "$(SRCDIR)\sounds/7.wav" >> $@
1221 echo "$(SRCDIR)\sounds/8.wav" >> $@
1222 echo "$(SRCDIR)\sounds/9.wav" >> $@
1223 echo "$(SRCDIR)\sounds/a.wav" >> $@
1224 echo "$(SRCDIR)\sounds/b.wav" >> $@
1225 echo "$(SRCDIR)\sounds/c.wav" >> $@
1226 echo "$(SRCDIR)\sounds/d.wav" >> $@
1227 echo "$(SRCDIR)\sounds/e.wav" >> $@
1228 echo "$(SRCDIR)\sounds/f.wav" >> $@
1229 echo "$(SRCDIR)\style.admin_log.css" >> $@
1230 echo "$(SRCDIR)\style.chat.css" >> $@
1231 echo "$(SRCDIR)\style.fileedit.css" >> $@
1232 echo "$(SRCDIR)\style.wikiedit.css" >> $@
1233 echo "$(SRCDIR)\tree.js" >> $@
1234 echo "$(SRCDIR)\useredit.js" >> $@
1235 echo "$(SRCDIR)\wiki.wiki" >> $@
1236
1237 "$(OX)\add$O" : "$(OX)\add_.c" "$(OX)\add.h"
1238 $(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\add_.c"
1239
1240 "$(OX)\add_.c" : "$(SRCDIR)\add.c"
1241
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -1,8 +1,8 @@
1 #
2 ##############################################################################
3 # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "tools/makemake.tcl")
4 ##############################################################################
5 #
6 #
7 # This file is automatically generated. Instead of editing this
8 # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
@@ -559,73 +559,11 @@
559 "$(SRCDIR)\..\skins\plain_gray\footer.txt" \
560 "$(SRCDIR)\..\skins\plain_gray\header.txt" \
561 "$(SRCDIR)\..\skins\xekri\css.txt" \
562 "$(SRCDIR)\..\skins\xekri\details.txt" \
563 "$(SRCDIR)\..\skins\xekri\footer.txt" \
564 "$(SRCDIR)\..\skins\xekri\header.txt"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
566 OBJ = "$(OX)\add$O" \
567 "$(OX)\ajax$O" \
568 "$(OX)\alerts$O" \
569 "$(OX)\allrepo$O" \
@@ -1013,26 +951,26 @@
951 !if $(FOSSIL_ENABLE_MINIZ)!=0
952 echo "$(OX)\miniz.obj" >> $@
953 !endif
954 echo $(LIBS) >> $@
955
956 "$(OBJDIR)\translate$E": "$(SRCDIR.tools)\translate.c"
957 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
958
959 "$(OBJDIR)\makeheaders$E": "$(SRCDIR.tools)\makeheaders.c"
960 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
961
962 "$(OBJDIR)\mkindex$E": "$(SRCDIR.tools)\mkindex.c"
963 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
964
965 "$(OBJDIR)\mkbuiltin$E": "$(SRCDIR)\mkbuiltin.c"
966 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
967
968 "$(OBJDIR)\mkversion$E": "$(SRCDIR.tools)\mkversion.c"
969 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
970
971 "$(OBJDIR)\codecheck1$E": "$(SRCDIR.tools)\codecheck1.c"
972 $(BCC) /Fe$@ /Fo$(@D)\ /Fd$(@D)\ $**
973
974 !if $(USE_SEE)!=0
975 SEE_FLAGS = /DSQLITE_HAS_CODEC=1 /DSQLITE_SHELL_DBKEY_PROC=fossil_key
976 SQLITE3_SHELL_SRC = $(SRCDIR)\shell-see.c
@@ -1169,72 +1107,10 @@
1107 echo "$(SRCDIR)\../skins/plain_gray/header.txt" >> $@
1108 echo "$(SRCDIR)\../skins/xekri/css.txt" >> $@
1109 echo "$(SRCDIR)\../skins/xekri/details.txt" >> $@
1110 echo "$(SRCDIR)\../skins/xekri/footer.txt" >> $@
1111 echo "$(SRCDIR)\../skins/xekri/header.txt" >> $@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1112
1113 "$(OX)\add$O" : "$(OX)\add_.c" "$(OX)\add.h"
1114 $(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\add_.c"
1115
1116 "$(OX)\add_.c" : "$(SRCDIR)\add.c"
1117

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button