dtksh/sfio: resolved a naming collision on FreeBSD 11
[oweals/cde.git] / cde / programs / dtksh / ksh93 / ship / shipproto.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: shipproto.c /main/5 1995/11/01 16:03:47 rswiston $ */
24 /***************************************************************
25 *                                                              *
26 *                      AT&T - PROPRIETARY                      *
27 *                                                              *
28 *         THIS IS PROPRIETARY SOURCE CODE LICENSED BY          *
29 *                          AT&T CORP.                          *
30 *                                                              *
31 *                Copyright (c) 1995 AT&T Corp.                 *
32 *                     All Rights Reserved                      *
33 *                                                              *
34 *           This software is licensed by AT&T Corp.            *
35 *       under the terms and conditions of the license in       *
36 *       http://www.research.att.com/orgs/ssr/book/reuse        *
37 *                                                              *
38 *               This software was created by the               *
39 *           Software Engineering Research Department           *
40 *                    AT&T Bell Laboratories                    *
41 *                                                              *
42 *               For further information contact                *
43 *                     gsf@research.att.com                     *
44 *                                                              *
45 ***************************************************************/
46
47 /* : : generated by proto : : */
48
49 #if !defined(__PROTO__)
50 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
51 #if defined(__cplusplus)
52 #define __MANGLE__      "C"
53 #else
54 #define __MANGLE__
55 #endif
56 #define __STDARG__
57 #define __PROTO__(x)    x
58 #define __OTORP__(x)
59 #define __PARAM__(n,o)  n
60 #if !defined(__STDC__) && !defined(__cplusplus)
61 #if !defined(c_plusplus)
62 #define const
63 #endif
64 #define signed
65 #define void            int
66 #define volatile
67 #define __V_            char
68 #else
69 #define __V_            void
70 #endif
71 #else
72 #define __PROTO__(x)    ()
73 #define __OTORP__(x)    x
74 #define __PARAM__(n,o)  o
75 #define __MANGLE__
76 #define __V_            char
77 #define const
78 #define signed
79 #define void            int
80 #define volatile
81 #endif
82 #if defined(__cplusplus) || defined(c_plusplus)
83 #define __VARARG__      ...
84 #else
85 #define __VARARG__
86 #endif
87 #if defined(__STDARG__)
88 #define __VA_START__(p,a)       va_start(p,a)
89 #else
90 #define __VA_START__(p,a)       va_start(p)
91 #endif
92 #endif
93 #line 1 "/home/gsf/src/cmd/proto/proto.c"
94
95  
96
97 #line 27
98
99
100
101
102
103 # define ctime          _huh_ctime
104 # include <stdlib.h>
105 # include <sys/types.h>
106 # include <sys/stat.h>
107 # include <string.h>
108
109 # undef ctime
110
111 # ifndef _WIN32
112 # define remove(x)      unlink(x)
113 # define rename(x,y)    ((link(x,y)||remove(x))?-1:0)
114 # endif
115
116
117
118  
119
120
121
122
123 int
124 replace __PARAM__((const char* newfile, const char* oldfile, int preserve), (newfile, oldfile, preserve)) __OTORP__(const char* newfile; const char* oldfile; int preserve;){
125         struct stat     st;
126         time_t          ut[2];
127
128         if (preserve && stat(oldfile, &st) || remove(oldfile) || rename(newfile, oldfile))
129                 return(-1);
130         if (preserve)
131         {
132                 ut[0] = st.st_atime;
133                 ut[1] = st.st_mtime;
134                 preserve = utime(oldfile, ut);
135         }
136         return(preserve);
137 }
138
139 #line 1 "../../lib/libpp/ppproto.c"
140
141  
142
143
144
145
146
147
148
149
150
151
152 static const char id[] = "\n@(#)proto (AT&T Bell Laboratories) 05/09/95\000\n";
153
154
155
156 #line 1 "../../lib/libpp/ppfsm.c"
157
158  
159
160
161
162
163
164
165
166 #line 1 "../../lib/libpp/pplib.h"
167
168  
169
170
171
172
173
174
175
176
177
178  
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215  
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265 struct ppsymbol;
266 struct ppindex;
267
268 typedef char*   (*PPBUILTIN) __PROTO__((char*, const char*, const char*));
269 typedef void    (*PPCOMMENT) __PROTO__((const char*, const char*, const char*, int));
270 typedef void    (*PPINCREF) __PROTO__((const char*, const char*, int, int));
271 typedef void    (*PPLINESYNC) __PROTO__((int, const char*));
272 typedef void    (*PPMACREF) __PROTO__((struct ppsymbol*, const char*, int, int, unsigned long));
273 typedef int     (*PPOPTARG) __PROTO__((int, int, const char*));
274 typedef void    (*PPPRAGMA) __PROTO__((const char*, const char*, const char*, const char*, int));
275
276 struct ppinstk                           
277 {
278         char*           nextchr;         
279         struct ppinstk* next;            
280         struct ppinstk* prev;            
281         long*           control;         
282         char*           buffer;          
283         char*           file;            
284         char*           prefix;          
285         struct ppsymbol* symbol;         
286
287         struct ppindex* index;           
288         int             buflen;          
289
290         int             line;            
291         short           fd;              
292         short           hide;            
293         short           flags;           
294         char            type;            
295 };
296
297
298
299
300
301
302
303
304
305 struct pplist                            
306 {
307         char*           value;           
308         struct pplist*  next;            
309 };
310
311 struct oplist                            
312 {
313         int             op;              
314         char*           value;           
315         struct oplist*  next;            
316 };
317
318 struct pphide                            
319 {
320         struct ppmacro* macro;           
321         unsigned long   flags;           
322         int             level;           
323 };
324
325 struct ppmacstk                          
326 {
327         struct ppmacstk* next;           
328         struct ppmacstk* prev;           
329         int             line;            
330         char*           arg[1];          
331 };
332
333 struct ppmember                          
334 {
335         struct ppdirs*  archive;         
336         unsigned long   offset;          
337         unsigned long   size;            
338 };
339
340 struct counter                           
341 {
342         int             candidate;       
343         int             function;        
344         int             macro;           
345         int             pplex;           
346         int             push;            
347         int             terminal;        
348         int             token;           
349 };
350
351
352
353 #line 228
354
355
356 #line 273
357
358
359
360
361 #line 287
362
363
364
365
366
367
368
369 #line 304
370
371
372
373
374
375
376
377
378 #line 1 "../../lib/libpp/pp.h"
379
380  
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566  
567
568
569
570
571
572
573
574
575
576
577
578
579
580  
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604  
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624  
625
626
627
628
629
630
631  
632
633
634
635
636
637
638
639
640
641  
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669  
670
671
672
673
674
675
676
677  
678
679
680
681
682
683
684
685  
686
687
688
689
690
691 struct ppdirs                            
692 {
693         char*           name;            
694         struct ppdirs*  next;            
695
696
697         unsigned char c; unsigned char hosted; unsigned char index; unsigned char type; union { char* buffer; char* sp; struct ppdirs* subdir; } info;
698
699
700 };
701
702 struct ppkeyword                         
703 {
704         char*           name;            
705         int             value;           
706 };
707
708 struct ppmacro                           
709 {
710         int             arity;           
711         char*           value;           
712
713
714         int size; char* formals;
715
716
717 };
718
719 struct ppsymbol                          
720 {
721         int hash_header;                         
722         unsigned long   flags;           
723         struct ppmacro* macro;           
724         __V_*           value;           
725
726
727         struct pphide* hidden;
728
729
730 };
731
732
733
734
735
736
737
738
739
740 struct ppglobals                         
741 {
742         const char*     version;         
743         char*           lineid;          
744         char*           outfile;         
745         char*           pass;            
746         char*           token;           
747         struct ppsymbol* symbol;         
748
749  
750
751         char*           outbuf;          
752         char*           outp;            
753         unsigned long   offset;          
754
755
756         struct ppdirs* lcldirs; struct ppdirs* stddirs; int flags; char* symtab;                 
757
758
759
760         struct ppcontext* context; long state; long mode; long option; long test; char* filedeps; struct ppdirs* firstdir; struct ppdirs* lastdir; int hide; int column; int pending; char* firstfile; char* lastfile; char* ignore; char* probe; char* filtab; char* prdtab; char* date; char* time; char* maps; long ro_state; long ro_mode; long ro_option; char* cdir; char* hostdir; char* ppdefault; struct ppindex* firstindex; struct ppindex* lastindex; struct oplist* firstop; struct oplist* lastop; struct oplist* firsttx; struct oplist* lasttx; unsigned char arg_file; unsigned char arg_mode; unsigned char arg_style; unsigned char c; unsigned char hosted; unsigned char ignoresrc; unsigned char initialized; unsigned char standalone; unsigned char spare_1;             
761
762
763
764         char* checkpoint; int constack; struct ppinstk* in; char* addp; char* args; char* addbuf; char* catbuf; char* path; char* tmpbuf; char* valbuf; char* include; char* prefix; struct ppmember* member; int hidden; int hiding; int level; struct { int input; int output; } pool; int truncate; struct ppmacstk* macp; char* maxmac; char* mactop; char* toknxt; long* control; long* maxcon; struct oplist* chop; struct ppfile* insert; struct ppfile* original; char* dirtab; char* strtab; PPBUILTIN builtin; PPCOMMENT comment; PPINCREF incref; PPLINESYNC linesync; PPLINESYNC olinesync; PPMACREF macref; PPOPTARG optarg; PPPRAGMA pragma; struct counter counter;               
765
766
767 };
768
769  
770
771
772
773
774
775 extern __MANGLE__ struct ppglobals      pp;
776 extern __MANGLE__ char          _pp_ctype[];
777
778 extern __MANGLE__ int           ppargs __PROTO__((char**, int));
779 extern __MANGLE__ void          ppcpp __PROTO__((void));
780 extern __MANGLE__ void          ppcomment __PROTO__((char*, char*, char*, int));
781 extern __MANGLE__ __V_*         ppcontext __PROTO__((__V_*, int));
782 extern __MANGLE__ void          pperror __PROTO__((int, ...));
783 extern __MANGLE__ void          ppincref __PROTO__((char*, char*, int, int));
784 extern __MANGLE__ void          ppinput __PROTO__((char*, char*, int));
785 extern __MANGLE__ int           pplex __PROTO__((void));
786 extern __MANGLE__ void          ppline __PROTO__((int, char*));
787 extern __MANGLE__ void          ppmacref __PROTO__((struct ppsymbol*, char*, int, int));
788 extern __MANGLE__ void          ppop __PROTO__((int, ...));
789 extern __MANGLE__ void          pppragma __PROTO__((char*, char*, char*, char*, int));
790 extern __MANGLE__ int           ppprintf __PROTO__((char*, ...));
791
792
793 #line 313 "../../lib/libpp/pplib.h"
794
795 #line 1 "../../lib/libpp/ppdef.h"
796  
797
798 #line 14
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963 #line 314 "../../lib/libpp/pplib.h"
964
965 #line 1 "../../lib/libpp/ppkey.h"
966
967  
968
969
970
971
972
973
974
975
976
977
978
979
980  
981
982
983
984
985
986  
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018  
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028  
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063  
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074  
1075
1076
1077
1078
1079
1080  
1081
1082
1083
1084 extern __MANGLE__ struct ppkeyword      ppkey[];
1085
1086
1087 #line 315 "../../lib/libpp/pplib.h"
1088
1089
1090
1091  
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123  
1124
1125
1126
1127
1128
1129 #line 367
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232 #line 481
1233
1234
1235
1236
1237
1238 #line 496
1239
1240
1241 #line 510
1242
1243
1244
1245
1246
1247
1248
1249
1250 #line 529
1251
1252
1253 #line 551
1254
1255
1256 #line 563
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288 struct ppcontext                         
1289 {
1290         struct ppdirs* lcldirs; struct ppdirs* stddirs; int flags; char* symtab;
1291         struct ppcontext* context; long state; long mode; long option; long test; char* filedeps; struct ppdirs* firstdir; struct ppdirs* lastdir; int hide; int column; int pending; char* firstfile; char* lastfile; char* ignore; char* probe; char* filtab; char* prdtab; char* date; char* time; char* maps; long ro_state; long ro_mode; long ro_option; char* cdir; char* hostdir; char* ppdefault; struct ppindex* firstindex; struct ppindex* lastindex; struct oplist* firstop; struct oplist* lastop; struct oplist* firsttx; struct oplist* lasttx; unsigned char arg_file; unsigned char arg_mode; unsigned char arg_style; unsigned char c; unsigned char hosted; unsigned char ignoresrc; unsigned char initialized; unsigned char standalone; unsigned char spare_1;
1292 };
1293
1294 struct ppfile 
1295 {
1296         int hash_header;                         
1297         struct ppsymbol* guard;          
1298         struct ppfile*  bound[3];        
1299         int             flags;           
1300 };
1301
1302
1303
1304 struct ppindex                           
1305 {
1306         struct ppindex* next;            
1307         struct ppfile*  file;            
1308         unsigned long   begin;           
1309         unsigned long   end;             
1310 };
1311
1312
1313
1314 struct ppsymkey                          
1315 {
1316         struct ppsymbol sym;             
1317         int             lex;             
1318 };
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334 extern __MANGLE__ int           access __PROTO__((const char*, int));
1335 extern __MANGLE__ __V_*         calloc __PROTO__((size_t, size_t));
1336 extern __MANGLE__ int           close __PROTO__((int));
1337 extern __MANGLE__ int           creat __PROTO__((const char*, int));
1338 extern __MANGLE__ char*         ctime __PROTO__((time_t*));
1339 extern __MANGLE__ void          exit __PROTO__((int));
1340 extern __MANGLE__ void          free __PROTO__((__V_*));
1341 extern __MANGLE__ int           link __PROTO__((const char*, const char*));
1342 extern __MANGLE__ int           open __PROTO__((const char*, int, ...));
1343 extern __MANGLE__ int           read __PROTO__((int, __V_*, int));
1344 extern __MANGLE__ int           strncmp __PROTO__((const char*, const char*, size_t));
1345 extern __MANGLE__ time_t                time __PROTO__((time_t*));
1346 extern __MANGLE__ int           unlink __PROTO__((const char*));
1347 extern __MANGLE__ int           write __PROTO__((int, const __V_*, int));
1348
1349
1350
1351
1352
1353
1354
1355 #line 691
1356
1357
1358 extern __MANGLE__ void          ppassert __PROTO__((int, char*, char*));
1359 extern __MANGLE__ void          ppbuiltin __PROTO__((void));
1360 extern __MANGLE__ int           ppcall __PROTO__((struct ppsymbol*, int));
1361 extern __MANGLE__ int           ppcontrol __PROTO__((void));
1362 extern __MANGLE__ void          ppdump __PROTO__((void));
1363 extern __MANGLE__ char*         ppexpand __PROTO__((char*));
1364 extern __MANGLE__ long          ppexpr __PROTO__((int*));
1365 extern __MANGLE__ void          ppfsm __PROTO__((int, char*));
1366 extern __MANGLE__ char*         ppinstr __PROTO__((struct ppinstk*));
1367 extern __MANGLE__ char*         ppkeyname __PROTO__((int, int));
1368 extern __MANGLE__ char*         pplexstr __PROTO__((int));
1369 extern __MANGLE__ void          ppload __PROTO__((char*));
1370 extern __MANGLE__ char*         ppmodestr __PROTO__((long));
1371 extern __MANGLE__ int           ppmultiple __PROTO__((struct ppfile*, struct ppsymbol*));
1372 extern __MANGLE__ void          ppnest __PROTO__((void));
1373 extern __MANGLE__ int           ppoption __PROTO__((char*));
1374 extern __MANGLE__ char*         ppoptionstr __PROTO__((long));
1375 extern __MANGLE__ void          pppclose __PROTO__((char*));
1376 extern __MANGLE__ int           pppdrop __PROTO__((char*));
1377 extern __MANGLE__ char*         pppopen __PROTO__((char*, int, char*, int));
1378 extern __MANGLE__ int           pppread __PROTO__((char*));
1379 extern __MANGLE__ int           pppredargs __PROTO__((void));
1380 extern __MANGLE__ void          pppush __PROTO__((int, char*, char*, int));
1381 extern __MANGLE__ struct ppsymbol*      pprefmac __PROTO__((char*, int));
1382 extern __MANGLE__ int           ppsearch __PROTO__((char*, int, int));
1383 extern __MANGLE__ char*         ppstatestr __PROTO__((long));
1384 extern __MANGLE__ char*         pptokstr __PROTO__((char*, int));
1385 extern __MANGLE__ void          pptrace __PROTO__((int));
1386
1387
1388 #line 11 "../../lib/libpp/ppfsm.c"
1389
1390 #line 1 "../../lib/libpp/ppfsm.h"
1391
1392  
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425  
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442  
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483 #line 106
1484
1485
1486
1487
1488 #line 143
1489
1490
1491
1492
1493  
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509  
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521  
1522
1523
1524
1525
1526
1527  
1528
1529
1530
1531
1532
1533  
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548 #line 220
1549
1550
1551
1552
1553
1554
1555
1556  
1557
1558
1559
1560
1561
1562
1563
1564  
1565
1566
1567
1568
1569 extern __MANGLE__ short         _pp_fsmtab[(0+26)+1][255+1];
1570
1571  
1572
1573
1574
1575 extern __MANGLE__ char          _pp_trigraph[255+1];
1576
1577 extern __MANGLE__ void          _pp_refill __PROTO__((int));
1578
1579
1580 #line 12 "../../lib/libpp/ppfsm.c"
1581
1582  
1583
1584 #line 49
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598 struct fsminit                           
1599 {
1600         int             state;           
1601         unsigned char   ch[4];           
1602         int             nextstate;       
1603 };
1604
1605 static struct fsminit   fsminit[] =
1606 {
1607  
1608         {       0,      { 6 },          ((0+26)+11),                    },
1609         {       0,      { 5 },          (0),                    },
1610         {       0,      { 2 },          (0+21),                 },
1611         {       0,      { '.' },                (0+23),                 },
1612         {       0,      { 1 },          (0+17),                 },
1613         {       0,      { 'L' },                (0+18),                 },
1614         {       0,      { 'd', 'e', 'f', 'i' }, (0+1),                  },
1615         {       0,      { 'r', 't', 'v', 'w' }, (0+1),                  },
1616         {       0,      { '"', '\'' },          ((0+26)+3),             },
1617         {       0,      { '/' },                (0+10),                 },
1618         {       0,      { '\n' },               ((0+26)+7),                     },
1619         {       0,      { ' ','\t','\f','\013' },       (0+25),                 },
1620
1621  
1622         {       (0+1),  { 6 },          ((0+26)+6),             },
1623         {       (0+1),  { 1, 2 },       (0+17),                 },
1624         {       (0+1),  { 'a' },                (0+2),                  },
1625         {       (0+1),  { 'e' },                (0+3),                  },
1626         {       (0+1),  { 'f' },                (0+4),                  },
1627         {       (0+1),  { 'h' },                (0+5),                  },
1628         {       (0+1),  { 'l' },                (0+6),                  },
1629         {       (0+1),  { 'o' },                (0+7),                  },
1630         {       (0+1),  { 'x' },                (0+8),                  },
1631         {       (0+1),  { 'y' },                (0+9),                  },
1632
1633  
1634         {       (0+2),  { 6 },          (((0+26)+12)),          },
1635         {       (0+2),  { 1, 2 },       (0+17),                 },
1636         {       (0+2),  { '_','s','t','a' },    (0+2),                  },
1637         {       (0+2),  { 'r' },                (0+2),                  },
1638
1639  
1640         {       (0+3),  { 6 },          (((0+26)+12)),          },
1641         {       (0+3),  { 1, 2 },       (0+17),                 },
1642         {       (0+3),  { 't','u','r','n' },    (0+3),                  },
1643
1644  
1645         {       (0+4),  { 6 },          (((0+26)+12)),          },
1646         {       (0+4),  { 1, 2 },       (0+17),                 },
1647
1648  
1649         {       (0+5),  { 6 },          (((0+26)+12)),          },
1650         {       (0+5),  { 1, 2 },       (0+17),                 },
1651         {       (0+5),  { 'i','l','e' },        (0+5),                  },
1652
1653  
1654         {       (0+6),  { 6 },          (((0+26)+12)),          },
1655         {       (0+6),  { 1, 2 },       (0+17),                 },
1656         {       (0+6),  { 's','e' },            (0+6),                  },
1657
1658  
1659         {       (0+7),  { 6 },          (((0+26)+12)),          },
1660         {       (0+7),  { 1, 2 },       (0+17),                 },
1661         {       (0+7),  { 'r', 'i','d' },       (0+7),                  },
1662
1663  
1664         {       (0+8),  { 6 },          (((0+26)+12)),          },
1665         {       (0+8),  { 1, 2 },       (0+17),                 },
1666         {       (0+8),  { 't','e','r','n' },    (0+8),                  },
1667
1668  
1669         {       (0+9),  { 6 },          (((0+26)+12)),          },
1670         {       (0+9),  { 1, 2 },       (0+17),                 },
1671         {       (0+9),  { 'p','e','d','f' },    (0+9),                  },
1672
1673  
1674         {       (0+10), { 6 },          ((0+26)+0),                     },
1675         {       (0+10), { '*' },                (0+11),                 },
1676
1677         {       (0+10), { '/' },                (0+14),                 },
1678
1679
1680  
1681         {       (0+11), { 6 },          (0+11),                 },
1682         {       (0+11), { '\n', 5 },    ((0+26)+1),             },
1683         {       (0+11), { '/' },                (0+13),                 },
1684         {       (0+11), { '*' },                (0+12),                 },
1685         {       (0+11), { '#', ';', ')' },      ((( (0+11))<<(7+1))|(((0+26)+8))),              },
1686
1687  
1688         {       (0+12), { 6 },          (0+11),                 },
1689         {       (0+12), { '\n', 5 },    ((0+26)+1),             },
1690         {       (0+12), { '#', ';', ')' },      ((( (0+11))<<(7+1))|(((0+26)+8))),              },
1691         {       (0+12), { '*' },                (0+12),                 },
1692         {       (0+12), { '/' },                ((0+26)+1),             },
1693
1694  
1695         {       (0+13), { 6 },          (0+11),                 },
1696         {       (0+13), { '*', '\n', 5 },       ((0+26)+1),             },
1697         {       (0+13), { '/' },                (0+13),                 },
1698
1699  
1700         {       (0+14), { 6 },          (0+14),                 },
1701         {       (0+14), { '\n', 5 },    ((0+26)+1),             },
1702         {       (0+14), { '/' },                (0+15),                 },
1703         {       (0+14), { '*' },                (0+16),                 },
1704
1705  
1706         {       (0+15), { 6 },          (0+14),                 },
1707         {       (0+15), { '*', '\n', 5 },       ((0+26)+1),             },
1708         {       (0+15), { '/' },                (0+15),                 },
1709
1710  
1711         {       (0+16), { 6 },          (0+14),                 },
1712         {       (0+16), { '\n', 5 },    ((0+26)+1),             },
1713         {       (0+16), { '*' },                (0+16),                 },
1714         {       (0+16), { '/' },                ((0+26)+1),             },
1715
1716  
1717         {       (0+17), { 6 },          ((0+26)+6),             },
1718         {       (0+17), { 1, 2 },       (0+17),                 },
1719
1720  
1721         {       (0+23), { 6 },          ((0+26)+0),                     },
1722         {       (0+23), { '.' },                (0+24),                 },
1723         {       (0+23), { 2 },          (0+21),                 },
1724
1725  
1726         {       (0+24), { 6 },          (((( (0401+1))-0401)<<(7+1))|( ((0+26)+14))),   },
1727         {       (0+24), { '.' },                (((( (0401+29))-0401)<<(7+1))|( ((0+26)+13))),  },
1728
1729  
1730         {       (0+18), { 6 },          ((0+26)+6),             },
1731         {       (0+18), { 1, 2 },       (0+17),                 },
1732         {       (0+18), { '"', '\'' },          ((( (0+19))<<(7+1))|(((0+26)+8))),              },
1733
1734  
1735         {       (0+19), { 6 },          (0+19),                 },
1736         {       (0+19), { '"', '\'' },          ((0+26)+4),             },
1737         {       (0+19), { '\n', 5 },    ((0+26)+4),             },
1738         {       (0+19), { '\\' },               (0+20),                 },
1739
1740  
1741         {       (0+20), { 6 },          ((0+26)+5),             },
1742         {       (0+20), { '\n', 5 },    ((0+26)+4),             },
1743
1744  
1745         {       (0+21), { 6 },          (((( (0401+1))-0401)<<(7+1))|( ((0+26)+14))),   },
1746         {       (0+21), { 1, 2, '.' },  (0+21),                 },
1747         {       (0+21), { 'e', 'E' },           (0+22),                 },
1748
1749  
1750         {       (0+22), { 6 },          (((( (0401+1))-0401)<<(7+1))|( ((0+26)+14))),   },
1751         {       (0+22), { 1, 2, '.' },  (0+21),                 },
1752         {       (0+22), { '+', '-' },           (0+21),                 },
1753
1754  
1755         {       (0+25), { 6 },          ((0+26)+15),                    },
1756         {       (0+25), { ' ', '\t' },          (0+25),                 },
1757         {       (0+25), { '\f', '\013' },               ((0+26)+10),                    },
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014  
2015         {       (-1),   { 0 },                  0,                      }
2016 };
2017
2018 short           _pp_fsmtab[(0+26)+1][255+1];
2019
2020 char            _pp_trigraph[255+1];
2021
2022
2023 static char     spl[] = { '\\', '\r', 0 };
2024 static char     aln[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$@";
2025
2026
2027
2028
2029 static char*    let = &aln[10];
2030 static char     hex[] = "fedcbaFEDCBA9876543210";
2031 static char*    dec = &hex[12];
2032 static char*    oct = &hex[14];
2033
2034  
2035
2036
2037
2038
2039 void
2040 ppfsm __PARAM__((int op, register char* s), (op, s)) __OTORP__(int op; register char* s;){
2041         register int                    c;
2042         register int                    n;
2043         register int                    i;
2044         register short*                 rp;
2045         register struct fsminit*        fp;
2046
2047
2048
2049
2050         switch (op)
2051         {
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081         case 4:
2082                 for (fp = fsminit;; fp++)
2083                 {
2084                         if ((n = fp->nextstate) >= (0+26)) n = ~n;
2085                         if (fp->state == (-1))
2086                         {
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100                                 break;
2101                         }
2102                         rp = _pp_fsmtab[fp->state];
2103                         for (i = 0; i < sizeof(fp->ch) && (c = fp->ch[i]); i++)
2104                         {
2105                                 switch (c)
2106                                 {
2107                                 case 6:
2108                                         for (c = 0; c <= 255; c++)
2109                                                 rp[c] = n;
2110  
2111
2112                                 case 5:
2113                                         _pp_fsmtab[(0+26)][fp->state+1] = n < 0 ? ~n : n;
2114                                         continue;
2115
2116                                 case 1:
2117                                         s = let;
2118                                         break;
2119
2120                                 case 3:
2121                                         s = hex;
2122                                         break;
2123
2124                                 case 2:
2125                                         s = dec;
2126                                         break;
2127
2128                                 case 4:
2129                                         s = oct;
2130                                         break;
2131
2132                                 default:
2133                                         rp[c] = n;
2134                                         continue;
2135                                 }
2136                                 while (c = *s++)
2137                                         rp[c] = n;
2138                         }
2139                 }
2140
2141  
2142
2143
2144
2145
2146                 for (i = 0; i < (0+26); i++)
2147                 {
2148                         rp = _pp_fsmtab[i];
2149                         s = spl;
2150                         while (c = *s++)
2151                                 if (c != '@' || !(( rp)>=_pp_fsmtab[(0+11)]&&( rp)<=_pp_fsmtab[(0+13)]||(( rp)>=_pp_fsmtab[(0+14)]&&( rp)<=_pp_fsmtab[(0+16)])))
2152                                 {
2153                                         if (rp[c] >= 0) rp[c] = ~rp[c];
2154                                         rp[c] &= ~(1<<7);
2155                                 }
2156                         rp[0] = ~((0+26)+2);
2157                         for (c = 0; c <= 255; c++)
2158                                 if (rp[c] == i)
2159                                         rp[c] = 0;
2160                 }
2161                 _pp_fsmtab[(0+26)][0] = ~((0+26)+2);
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193                 break;
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343         }
2344 }
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409 #line 18 "../../lib/libpp/ppproto.c"
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425 struct proto 
2426 {
2427         int             brace;           
2428         int             fd;              
2429         char*           file;            
2430         long            flags;           
2431         int             line;            
2432         int             test;            
2433
2434         char*           tp;              
2435
2436         int             iz;              
2437         char*           ib;              
2438         char*           ip;              
2439
2440         int             oz;              
2441         char*           ob;              
2442         char*           op;              
2443
2444         char            pushback[4];     
2445
2446         char            variadic[256];   
2447
2448  
2449  
2450  
2451 };
2452
2453  
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543 static int              errors;
2544
2545  
2546
2547
2548
2549
2550
2551
2552
2553
2554  
2555
2556
2557
2558 static int
2559 sstrlen __PARAM__((register char* s), (s)) __OTORP__(register char* s;){
2560         register char*  b;
2561
2562         for (b = s; *s; s++);
2563         return(s - b);
2564 }
2565
2566  
2567
2568
2569
2570 static int
2571 sstrncmp __PARAM__((register char* s, register char* t, register int n), (s, t, n)) __OTORP__(register char* s; register char* t; register int n;){
2572         register char*  e = s + n;
2573
2574         while (s < e)
2575         {
2576                 if (*s != *t || !*s) return(*s - *t);
2577                 s++;
2578                 t++;
2579         }
2580         return(0);
2581 }
2582
2583  
2584
2585
2586
2587 static char*
2588 memcopy __PARAM__((register char* s, register char* t, int n), (s, t, n)) __OTORP__(register char* s; register char* t; int n;){
2589         register char*  e = t + n;
2590
2591         while (t < e) *s++ = *t++;
2592         return(s);
2593 }
2594
2595  
2596
2597
2598
2599 static char*
2600 strcopy __PARAM__((register char* s, register char* t), (s, t)) __OTORP__(register char* s; register char* t;){
2601         while (*s++ = *t++);
2602         return(s - 1);
2603 }
2604
2605  
2606
2607
2608
2609
2610
2611
2612
2613
2614 static char*
2615 comment __PARAM__((register char* p, register char* s, register int n, int u), (p, s, n, u)) __OTORP__(register char* p; register char* s; register int n; int u;){
2616         register char*  e;
2617         char*           m;
2618
2619         if (!s)
2620         {
2621                 if (n)
2622                 {
2623                         *p++ = (n > 0) ? '/' : '*';
2624                         e = p + 62;
2625                         while (p < e) *p++ = '*';
2626                         *p++ = (n > 0) ? '*' : '/';
2627                 }
2628                 else s = "";
2629         }
2630         if (s)
2631         {
2632                 if (n > 62) n = 62;
2633                 *p++ = '*';
2634                 e = p + (62 - n) / 2;
2635                 m = p + 62;
2636                 while (p < e) *p++ = ' ';
2637                 e = p + n;
2638                 while (p < e)
2639                 {
2640                         n = *s++;
2641                         if (u && n >= 'a' && n <= 'z') n = n - 'a' + 'A';
2642                         *p++ = n;
2643                 }
2644                 e = m;
2645                 while (p < e) *p++ = ' ';
2646                 *p++ = '*';
2647         }
2648         *p++ = '\n';
2649         return(p);
2650 }
2651
2652  
2653
2654 #line 285
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665 typedef struct
2666 {
2667         char*           data;
2668         int             size;
2669 } Item_t;
2670
2671 typedef struct
2672 {
2673         int             type;
2674         Item_t          item[5];
2675 } Notice_t;
2676
2677 static char*
2678 copyright __PARAM__((register char* p, register char* s), (p, s)) __OTORP__(register char* p; register char* s;){
2679         register char*  v;
2680         register char*  x;
2681         register int    c;
2682         int             i;
2683         int             n;
2684         unsigned long   h;
2685         time_t          clock;
2686         char            buf[(62+4)];
2687         Notice_t        notice;
2688
2689         notice.type = 2;
2690         for (i = 0; i < 5; i++)
2691                 notice.item[i].data = 0;
2692         i = 0;
2693         while (c = *s)
2694         {
2695                 while (c == ' ' || c == '\t' || c == '\n' || c == '\r')
2696                         c = *++s;
2697                 x = s;
2698                 n = 0;
2699                 h = 0;
2700                 while (c && c != '=' && c != ' ' && c != '\t' && c != '\n' && c != '\r')
2701                 {
2702                         if (n++ < 6)
2703                                 h = (h << 5) + c - 'a';
2704                         c = *++s;
2705                 }
2706                 if (c == '=')
2707                 {
2708                         n = (*++s == '"' || *s == '\'') ? *s++ : 0;
2709                         v = s;
2710                         while ((c = *s) && (n && c != n || !n && c != ' ' && c != '\t' && c != '\n' && c != '\r'))
2711                                 s++;
2712                         switch (h)
2713                         {
2714                         case   ((('c'-'a')<<25)|(('o'-'a')<<20)|(('m'-'a')<<15)|(('p'-'a')<<10)|(('a'-'a')<<5)|('n'-'a')):
2715                                 c = 0;
2716                                 break;
2717                         case   ((('c'-'a')<<25)|(('o'-'a')<<20)|(('n'-'a')<<15)|(('t'-'a')<<10)|(('a'-'a')<<5)|('c'-'a')):
2718                                 c = 2;
2719                                 break;
2720                         case   ((('c'-'a')<<25)|(('o'-'a')<<20)|(('r'-'a')<<15)|(('p'-'a')<<10)|(('o'-'a')<<5)|('r'-'a')):
2721                                 c = 3;
2722                                 break;
2723                         case   ((('l'-'a')<<25)|(('i'-'a')<<20)|(('c'-'a')<<15)|(('e'-'a')<<10)|(('n'-'a')<<5)|('s'-'a')):
2724                                 c = 4;
2725                                 break;
2726                         case   ((('o'-'a')<<25)|(('r'-'a')<<20)|(('g'-'a')<<15)|(('a'-'a')<<10)|(('n'-'a')<<5)|('i'-'a')):
2727                                 c = 1;
2728                                 break;
2729                         case   ((('t'-'a')<<15)|(('y'-'a')<<10)|(('p'-'a')<<5)|('e'-'a')):
2730                                 if (!sstrncmp( v, "proprietary", 11))
2731                                         notice.type = 2;
2732                                 else if (!sstrncmp( v, "nonexclusive", 11))
2733                                         notice.type = 1;
2734  
2735                         default:
2736                                 c = -1;
2737                                 break;
2738                         }
2739                         if (c >= 0 && (notice.item[c].size = s - v))
2740                                 notice.item[c].data = v;
2741                 }
2742                 else
2743                 {
2744                         while (c && c != '\n')
2745                                 c = *++s;
2746                         if (notice.item[i].size = s - x)
2747                         {
2748                                 notice.item[i].data = x;
2749                                 if (i == 0)
2750                                 {
2751                                         notice.item[3].data = v = x;
2752                                         while ((c = *x) && c != '\n' && c != ' ' && (c < 'a' || c > 'z'))
2753                                                 x++;
2754                                         if ((c = (x - v)) >= 3)
2755                                         {
2756                                                 notice.item[3].size = c++;
2757                                                 notice.item[0].data += c;
2758                                                 notice.item[0].size -= c;
2759                                         }
2760                                         else notice.item[3].data = 0;
2761                                 }
2762                         }
2763                         if (i++ >= 2)
2764                                 break;
2765                 }
2766                 if (*s) s++;
2767         }
2768         p = comment(p, ((char*)0), 1, 0);
2769         p = comment(p, ((char*)0), 0, 0);
2770         s = buf;
2771         if (notice.type == 2)
2772         {
2773                 if ((x = notice.item[i = 3].data) || (x = notice.item[i = 0].data))
2774                 {
2775                         s = memcopy(s, x, notice.item[i].size);
2776                         *s++ = ' ';
2777                         *s++ = '-';
2778                         *s++ = ' ';
2779                 }
2780                 s = strcopy(s, "Proprietary");
2781                 p = comment(p, buf, s - buf, 1);
2782                 p = comment(p, ((char*)0), 0, 0);
2783                 if (notice.item[4].data)
2784                 {
2785                         s = strcopy(buf, "This is proprietary source code");
2786                         if (notice.item[3].data || notice.item[0].data)
2787                                 s = strcopy(s, " licensed by");
2788                         p = comment(p, buf, s - buf, 1);
2789                         if (x = notice.item[3].data)
2790                         {
2791                                 s = memcopy(buf, x, notice.item[3].size);
2792                                 s = strcopy(s, " Corp.");
2793                                 p = comment(p, buf, s - buf, 1);
2794                         }
2795                         else if (x = notice.item[0].data)
2796                                 p = comment(p, x, notice.item[0].size, 1);
2797                 }
2798                 else
2799                 {
2800                         s = strcopy(buf, "This is unpublished proprietary source code");
2801                         if (x) s = strcopy(s, " of");
2802                         p = comment(p, buf, s - buf, 1);
2803                         s = buf;
2804                         if (x = notice.item[3].data)
2805                                 s = memcopy(s, x, notice.item[3].size);
2806                         if (x = notice.item[0].data)
2807                         {
2808                                 if (s > buf)
2809                                         *s++ = ' ';
2810                                 s = memcopy(s, x, notice.item[0].size);
2811                         }
2812                         if (s > buf)
2813                                 p = comment(p, buf, s - buf, 1);
2814                         p = comment( p, "and is not to be disclosed or used except in",sizeof( "and is not to be disclosed or used except in")-1, 1);
2815                         p = comment( p, "accordance with applicable agreements",sizeof( "accordance with applicable agreements")-1, 1);
2816                 }
2817                 p = comment(p, ((char*)0), 0, 0);
2818         }
2819         else if (notice.type == 1)
2820         {
2821                 p = comment( p, "For nonexclusive individual use",sizeof( "For nonexclusive individual use")-1, 1);
2822                 p = comment(p, ((char*)0), 0, 0);
2823         }
2824         s = strcopy(buf, "Copyright (c) ");
2825         time(&clock);
2826         s = memcopy(s, ctime(&clock) + 20, 4);
2827         if (x = notice.item[3].data)
2828         {
2829                 *s++ = ' ';
2830                 s = memcopy(s, x, notice.item[3].size);
2831                 *s++ = ' ';
2832                 s = strcopy(s, "Corp.");
2833         }
2834         else if (x = notice.item[0].data)
2835         {
2836                 *s++ = ' ';
2837                 s = memcopy(s, x, notice.item[0].size);
2838         }
2839         p = comment(p, buf, s - buf, 0);
2840         if (notice.type == 2)
2841         {
2842                 if (!notice.item[4].data)
2843                         p = comment( p, "Unpublished & Not for Publication",sizeof( "Unpublished & Not for Publication")-1, 0);
2844                 p = comment( p, "All Rights Reserved",sizeof( "All Rights Reserved")-1, 0);
2845         }
2846         p = comment(p, ((char*)0), 0, 0);
2847         if (notice.item[4].data)
2848         {
2849                 s = strcopy(buf, "This software is licensed");
2850                 if (x = notice.item[3].data)
2851                 {
2852                         s = strcopy(s, " by ");
2853                         s = memcopy(s, x, notice.item[3].size);
2854                         *s++ = ' ';
2855                         s = strcopy(s, "Corp.");
2856                 }
2857                 else if (x = notice.item[0].data)
2858                 {
2859                         s = strcopy(s, " by ");
2860                         s = memcopy(s, x, notice.item[0].size);
2861                 }
2862                 p = comment(p, buf, s - buf, 0);
2863                 p = comment( p, "under the terms and conditions of the license in",sizeof( "under the terms and conditions of the license in")-1, 0);
2864                 p = comment(p, notice.item[4].data, notice.item[4].size, 0);
2865                 p = comment(p, ((char*)0), 0, 0);
2866         }
2867         else if (notice.type == 2)
2868         {
2869                 p = comment( p, "The copyright notice above does not evidence any",sizeof( "The copyright notice above does not evidence any")-1, 0);
2870                 p = comment( p, "actual or intended publication of such source code",sizeof( "actual or intended publication of such source code")-1, 0);
2871                 p = comment(p, ((char*)0), 0, 0);
2872         }
2873         if (x = notice.item[1].data)
2874         {
2875                 p = comment( p, "This software was created by the",sizeof( "This software was created by the")-1, 0);
2876                 p = comment(p, x, notice.item[1].size, 0);
2877                 s = buf;
2878                 if (x = notice.item[3].data)
2879                         s = memcopy(s, x, notice.item[3].size);
2880                 if (x = notice.item[0].data)
2881                 {
2882                         if (s > buf)
2883                                 *s++ = ' ';
2884                         s = memcopy(s, x, notice.item[0].size);
2885                 }
2886                 if (s > buf)
2887                         p = comment(p, buf, s - buf, 0);
2888                 p = comment(p, ((char*)0), 0, 0);
2889         }
2890         if (x = notice.item[2].data)
2891         {
2892                 p = comment( p, "For further information contact",sizeof( "For further information contact")-1, 0);
2893                 p = comment(p, x, notice.item[2].size, 0);
2894                 p = comment(p, ((char*)0), 0, 0);
2895         }
2896         p = comment(p, ((char*)0), -1, 0);
2897         return(p);
2898 }
2899
2900
2901
2902
2903
2904
2905
2906  
2907
2908
2909
2910
2911 static char*
2912 number __PARAM__((register char* p, register long n), (p, n)) __OTORP__(register char* p; register long n;){
2913         register long   d;
2914
2915         for (d = 1000000; d > 1; d /= 10)
2916                 if (n >= d) *p++ = '0' + (n / d) % 10;
2917         *p++ = '0' + n % 10;
2918         return(p);
2919 }
2920
2921
2922
2923
2924
2925
2926 static void
2927 proto_error __PARAM__((char* iob, int level, char* msg, char* arg), (iob, level, msg, arg)) __OTORP__(char* iob; int level; char* msg; char* arg;){
2928         register char*  p;
2929         char            buf[1024];
2930
2931         p = strcopy(buf, "proto: ");
2932         if (iob)
2933         {
2934                 register struct proto*  proto = (struct proto*)(iob - sizeof(struct proto));
2935
2936                 if (proto->line)
2937                 {
2938                         if (proto->file)
2939                         {
2940                                 *p++ = '"';
2941                                 p = strcopy(p, proto->file);
2942                                 *p++ = '"';
2943                                 *p++ = ',';
2944                                 *p++ = ' ';
2945                         }
2946                         p = strcopy(p, "line ");
2947                         p = number(p, proto->line);
2948                 }
2949                 else if (proto->file) p = strcopy(p, proto->file);
2950         }
2951         else
2952         {
2953                 p = strcopy(p, msg);
2954                 msg = arg;
2955                 arg = 0;
2956         }
2957         *p++ = ':';
2958         *p++ = ' ';
2959         if (level == 1) p = strcopy(p, "warning: ");
2960         p = strcopy(p, msg);
2961         if (arg)
2962         {
2963                 *p++ = ' ';
2964                 p = strcopy(p, arg);
2965         }
2966         *p++ = '\n';
2967         write(2, buf, p - buf);
2968         if (level >= 3) exit(level - 2);
2969         if (level >= 2) errors++;
2970 }
2971
2972
2973
2974  
2975
2976
2977
2978
2979 static char*
2980 linesync __PARAM__((register struct proto* proto, register char* p, register long n), (proto, p, n)) __OTORP__(register struct proto* proto; register char* p; register long n;){
2981
2982         if (proto->flags & (1L<<12))
2983
2984         {
2985                 p = strcopy(p, "\n#line ");
2986
2987
2988
2989
2990                 p = number(p, n);
2991                 *p++ = '\n';
2992         }
2993         return(p);
2994 }
2995
2996  
2997
2998
2999
3000
3001 static char*
3002 init __PARAM__((char* op, int flags), (op, flags)) __OTORP__(char* op; int flags;){
3003         if (flags & (1L<<9)) op = strcopy(op, "\
3004 \n\
3005 #if !defined(__PROTO__)\n\
3006 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)\n\
3007 #if defined(__cplusplus)\n\
3008 #define __MANGLE__      \"C\"\n\
3009 #else\n\
3010 #define __MANGLE__\n\
3011 #endif\n\
3012 #define __STDARG__\n\
3013 #define __PROTO__(x)    x\n\
3014 #define __OTORP__(x)\n\
3015 #define __PARAM__(n,o)  n\n\
3016 #if !defined(__STDC__) && !defined(__cplusplus)\n\
3017 #if !defined(c_plusplus)\n\
3018 #define const\n\
3019 #endif\n\
3020 #define signed\n\
3021 #define void            int\n\
3022 #define volatile\n\
3023 #define __V_            char\n\
3024 #else\n\
3025 #define __V_            void\n\
3026 #endif\n\
3027 #else\n\
3028 #define __PROTO__(x)    ()\n\
3029 #define __OTORP__(x)    x\n\
3030 #define __PARAM__(n,o)  o\n\
3031 #define __MANGLE__\n\
3032 #define __V_            char\n\
3033 #define const\n\
3034 #define signed\n\
3035 #define void            int\n\
3036 #define volatile\n\
3037 #endif\n\
3038 #if defined(__cplusplus) || defined(c_plusplus)\n\
3039 #define __VARARG__      ...\n\
3040 #else\n\
3041 #define __VARARG__\n\
3042 #endif\n\
3043 #if defined(__STDARG__)\n\
3044 #define __VA_START__(p,a)       va_start(p,a)\n\
3045 #else\n\
3046 #define __VA_START__(p,a)       va_start(p)\n\
3047 #endif\n\
3048 #endif\n\
3049 ");
3050                 else op = strcopy(op, "\
3051 \n\
3052 #if !defined(__PROTO__)\n\
3053 #include <prototyped.h>\n\
3054 #endif\n\
3055 ");
3056         return(op);
3057 }
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073  
3074
3075
3076
3077
3078
3079 static int
3080 lex __PARAM__((register struct proto* proto, register long flags), (proto, flags)) __OTORP__(register struct proto* proto; register long flags;){
3081         register char*          ip;
3082         register char*          op;
3083         register int            c;
3084         register int            state;
3085         register short*         rp;
3086         char*                   m;
3087         char*                   e;
3088         char*                   t;
3089         char*                   bp;
3090         char*                   v;
3091         char*                   im;
3092         char*                   ko;
3093         char*                   aom;
3094         int                     n;
3095         int                     line;
3096         int                     quot;
3097         int                     x;
3098         int                     vc;
3099
3100         char*                   ie = 0;
3101         char*                   om = 0;
3102         char*                   aim = 0;
3103         char*                   aie = 0;
3104         int                     call = 0;
3105         int                     group = 0;
3106         int                     last = 0;
3107         int                     paren = 0;
3108
3109         char*                   qe = 0;
3110         int                     qn = 0;
3111         int                     args = 0;
3112
3113
3114         ((ip=proto->ip),(op=proto->op));
3115
3116         if (flags & (1L<<5)) (ko=op);
3117
3118  fsm_start:
3119         proto->tp = ip;
3120         state = 0;
3121         bp = ip;
3122         do
3123         {
3124                 rp = _pp_fsmtab[state];
3125  fsm_get:
3126                 while (!(state = rp[c = (*(unsigned char*)ip++)]));
3127  fsm_next:
3128                 ;
3129         } while (state > 0);
3130         if ((n = ip - bp - 1) > 0)
3131         {
3132                 ip = bp;
3133                 do switch( n) { default : memcpy( op, ip, n); op += n; ip += n; break; case 7 : * op++ = * ip++; case 6 : * op++ = * ip++; case 5 : * op++ = * ip++; case 4 : * op++ = * ip++; case 3 : * op++ = * ip++; case 2 : * op++ = * ip++; case 1 : * op++ = * ip++; case 0 : break; } while (0);
3134                 ip++;
3135         }
3136         state = ~state;
3137  fsm_terminal:
3138         switch ((( state)&((1<<(7+1))-1)))
3139         {
3140         case ((0+26)+11):
3141                 if (op > proto->ob && *(op - 1) == '=' && (op == proto->ob + 1 || *(op - 2) != '=')) switch (c)
3142                 {
3143                 case '+':
3144                 case '-':
3145                 case '*':
3146                 case '&':
3147                         (*op++=( ' '));
3148                         break;
3149                 }
3150                 (*op++=( c));
3151                 break;
3152
3153         case ((0+26)+0):
3154                 (ip--);
3155                 c = (*(op-1));
3156                 break;
3157
3158         case ((0+26)+1):
3159                 switch (c)
3160                 {
3161                 case '\n':
3162                         if ((( rp)>=_pp_fsmtab[(0+14)]&&( rp)<=_pp_fsmtab[(0+16)])) goto fsm_newline;
3163                         (*op++=( c));
3164                         proto->line++;
3165                         rp = _pp_fsmtab[(0+11)];
3166                         break;
3167                 case '/':
3168
3169                         if ((flags & ((1L<<5)|(1L<<14))) == (1L<<5)) (op=ko);
3170                         else
3171
3172                         (*op++=( c));
3173                         if ((( rp)>=_pp_fsmtab[(0+14)]&&( rp)<=_pp_fsmtab[(0+16)]))
3174                         {
3175                                 rp = _pp_fsmtab[(0+14)];
3176                                 break;
3177                         }
3178                         goto fsm_start;
3179                 case (255+1):
3180                         break;
3181                 default:
3182
3183                         if ((flags & ((1L<<5)|(1L<<14))) == (1L<<5)) (op=ko);
3184                         else
3185
3186                         (*op++=( c));
3187                         rp = _pp_fsmtab[(( rp)>=_pp_fsmtab[(0+14)]&&( rp)<=_pp_fsmtab[(0+16)]) ? (0+14) : (0+12)];
3188                         break;
3189                 }
3190                 bp = ip;
3191                 goto fsm_get;
3192
3193         case ((0+26)+2):
3194                 if (c)
3195                 {
3196                         if (state = _pp_fsmtab[(0+26)][((( rp)-_pp_fsmtab[0])/(255+1))+1])
3197                                 goto fsm_terminal;
3198                         do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
3199                         return(0);
3200                 }
3201                 (ip--);
3202  fsm_eob:
3203                 if ((flags & ((1L<<1)|((1L<<15))|(1L<<20))) == ((1L<<15)) && (proto->flags & (1L<<15)))
3204                 {
3205
3206                         if (!(flags & (1L<<5)))  
3207
3208                         flags |= (1L<<24);
3209                         c = ip - proto->ib;
3210                         if (!(flags & (1L<<14))) im = proto->tp;
3211                         n = ip - im;
3212                         if (ip - n < proto->ib)
3213                                 proto->flags |= (1L<<4);
3214                         memcopy(proto->ib - n, ip - n, n);
3215                         ip = proto->ib;
3216                         proto->tp -= c;
3217                         if (flags & (1L<<14))
3218                         {
3219                                 im -= c;
3220                                 ie -= c;
3221                         }
3222                         if (aim) aim -= c;
3223                         if (aie) aie -= c;
3224                         if ((n = read(proto->fd, ip, proto->iz)) > 0)
3225                         {
3226                                 if ((proto->flags & (1L<<21)) && n < proto->iz)
3227                                 {
3228                                         proto->flags &= ~(1L<<15);
3229                                         close(proto->fd);
3230                                 }
3231                                 *(ip + n) = 0;
3232                                 if (state & (1<<7)) goto fsm_splice;
3233                                 bp = ip;
3234                                 goto fsm_get;
3235                         }
3236                         *ip = 0;
3237                         proto->flags &= ~(1L<<15);
3238                         close(proto->fd);
3239                 }
3240                 if (state & (1<<7)) goto fsm_splice;
3241  
3242                 if (!(flags & (1L<<20)) && (state = rp[c = (255+1)]))
3243                 {
3244                         bp = ip;
3245                         goto fsm_next;
3246                 }
3247                 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
3248                 return(0);
3249
3250         case ((0+26)+3):
3251                 quot = c;
3252
3253                 if (c == '"' && qe)
3254                 {
3255                         for (n = 0, t = qe + 1; t < op && (*t == ' ' || *t == '\t' || *t == '\n' && ++n); t++);
3256                         if (t == op)
3257                         {
3258                                 op = qe;
3259                                 qe = 0;
3260                                 qn = n;
3261                         }
3262                         else (*op++=( c));
3263                 }
3264                 else
3265
3266                 (*op++=( c));
3267                 rp = _pp_fsmtab[(0+19)];
3268                 bp = ip;
3269                 goto fsm_get;
3270
3271         case ((0+26)+4):
3272                 if (c == quot)
3273                 {
3274
3275                         if (!(flags & (1L<<3)))
3276                                 qe = (c == '"') ? op : (char*)0;
3277
3278                         (*op++=( c));
3279
3280                         while (qn > 0)
3281                         {
3282                                 qn--;
3283                                 (*op++=( '\n'));
3284                         }
3285
3286                 }
3287                 else if (c != '\n' && c != (255+1))
3288                 {
3289                         (*op++=( c));
3290                         bp = ip;
3291                         goto fsm_get;
3292                 }
3293                 else
3294                 {
3295
3296                         while (qn > 0)
3297                         {
3298                                 qn--;
3299                                 (*op++=( '\n'));
3300                         }
3301
3302                         (ip--);
3303                 }
3304                 c = (0401+1);
3305                 break;
3306
3307         case ((0+26)+5):
3308
3309                 if (flags & (1L<<0)) (*op++=( c));
3310                 else
3311
3312                 switch (c)
3313                 {
3314                 case 'a':
3315                         (*op++=( '0'));
3316                         (*op++=( '0'));
3317                         (*op++=( '7'));
3318                         break;
3319                 case 'v':
3320                         (*op++=( '0'));
3321                         (*op++=( '1'));
3322                         (*op++=( '3'));
3323                         break;
3324                 case 'x':
3325                         do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
3326                         lex(proto, (flags & ((1L<<15))) | (1L<<20));
3327                         for (n = x = 0; (c = (*(unsigned char*)ip++)), x < 3; x++) switch (c)
3328                         {
3329                         case '0': case '1': case '2': case '3':
3330                         case '4': case '5': case '6': case '7':
3331                         case '8': case '9':
3332                                 n = (n << 4) + c - '0';
3333                                 break;
3334                         case 'a': case 'b': case 'c': case 'd':
3335                         case 'e': case 'f':
3336                                 n = (n << 4) + c - 'a' + 10;
3337                                 break;
3338                         case 'A': case 'B': case 'C': case 'D':
3339                         case 'E': case 'F':
3340                                 n = (n << 4) + c - 'A' + 10;
3341                                 break;
3342                         default:
3343                                 goto fsm_hex;
3344                         }
3345  fsm_hex:
3346                         (ip--);
3347                         (*op++=( ((n >> 6) & 07) + '0'));
3348                         (*op++=( ((n >> 3) & 07) + '0'));
3349                         (*op++=( (n & 07) + '0'));
3350                         break;
3351                 default:
3352                         (*op++=( c));
3353                         break;
3354                 }
3355                 rp = _pp_fsmtab[(0+19)];
3356                 bp = ip;
3357                 goto fsm_get;
3358
3359         case ((0+26)+6):
3360                 (ip--);
3361
3362                 if ((flags & (1L<<5)) && *proto->tp == 's' && !sstrncmp( proto->tp, "static", 6))
3363                 {
3364                         c = ((0500+4)+9);
3365                         break;
3366                 }
3367
3368                 if (*proto->tp == '_' && !sstrncmp( proto->tp, "__STDPP__directive", 6)) c = '#';
3369                 else c = (0401+0);
3370
3371                 break;
3372
3373         case ((0+26)+7):
3374  fsm_newline:
3375                 proto->line++;
3376
3377                 if (flags & (1L<<5))
3378                 {
3379                         if (op != proto->ob && (*(op-1)) != ' ' && (*(op-1)) != '\n')
3380                                 (*op++=( ' '));
3381                 }
3382                 else
3383
3384                 (*op++=( c));
3385                 if (flags & (1L<<3))
3386                 {
3387
3388                         if (flags & (1L<<0))
3389                         {
3390                                 if (flags & (1L<<5)) (op=ko);
3391                                 if (flags & (1L<<11))
3392                                 {
3393                                         *(ip - 1) = 0;
3394                                         op = strcopy(om, "/* ");
3395                                         op = strcopy(op, im);
3396                                         op = strcopy(op, " */\n");
3397                                 }
3398                                 flags &= ~((1L<<2)|(1L<<3)|(1L<<6)|(1L<<7)|(1L<<11)|(1L<<14)|(1L<<22)|(1L<<26));
3399                         }
3400                         else
3401
3402                         {
3403                                 if ((flags & ((1L<<2)|(1L<<22))) == ((1L<<2)|(1L<<22)))
3404                                 {
3405                                         *(ip - 1) = 0;
3406                                         op = strcopy(om, "#if defined(__STDC__) || defined(__STDPP__)\n");
3407                                         op = strcopy(op, im);
3408                                         op = strcopy(op, "\n#else\n");
3409                                         bp = ip;
3410                                         ip = im;
3411                                         *op++ = *ip++;
3412                                         while (*op = *ip++)
3413                                                 if (*op++ == '#' && *ip != '(')
3414                                                 {
3415                                                         op--;
3416                                                         while (*--op == ' ' || *op == '\t');
3417                                                         if (*ip == '#')
3418                                                         {
3419                                                                 op = strcopy(op + 1, "/**/");
3420                                                                 while (*++ip == ' ' || *ip == '\t');
3421                                                         }
3422                                                         else
3423                                                         {
3424                                                                 if (*op != '"') *++op = '"';
3425                                                                 op++;
3426                                                                 while (*ip == ' ' || *ip == '\t') ip++;
3427                                                                 while ((c = *ip) >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '_') *op++ = *ip++;
3428                                                                 while (*ip == ' ' || *ip == '\t') ip++;
3429                                                                 if (*ip == '"') ip++;
3430                                                                 else *op++ = '"';
3431                                                         }
3432                                                 }
3433                                         ip = bp;
3434                                         op = strcopy(op, "\n#endif\n");
3435                                         op = linesync(proto, op, proto->line);
3436                                 }
3437                                 flags &= ~((1L<<2)|(1L<<3)|(1L<<6)|(1L<<7)|(1L<<14)|(1L<<16)|(1L<<22)|(1L<<23)|(1L<<26));
3438                         }
3439                         call = 0;
3440                         group = 0;
3441                         paren = 0;
3442                         last = '\n';
3443                 }
3444                 if (paren == 0 && (flags & ((1L<<14)|(1L<<20)|(1L<<23)|(1L<<24))) == (1L<<24))
3445                 {
3446
3447                         if (flags & (1L<<5)) (op=ko);
3448
3449                         do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
3450                         return(0);
3451                 }
3452                 goto fsm_start;
3453
3454         case ((0+26)+8):
3455                 (*op++=( c));
3456                 rp = _pp_fsmtab[((( state)>>(7+1))&((1<<7)-1))];
3457                 bp = ip;
3458                 goto fsm_get;
3459
3460         case ((0+26)+13):
3461                 (*op++=( c));
3462                 c = (((( state)>>(7+1))&((1<<7)-1))+0401);
3463                 break;
3464
3465         case ((0+26)+14):
3466                 (ip--);
3467                 c = (((( state)>>(7+1))&((1<<7)-1))+0401);
3468                 break;
3469
3470         case (((0+26)+12)):
3471                 (ip--);
3472                 c = (0401+0);
3473                 if (!(flags & (1L<<1))) switch (((((long)( *proto->tp))<<16)|(((long)( *(ip - 1)))<<8)|((long)( ip - proto->tp))))
3474                 {
3475                 case ((((long)( 'd'))<<16)|(((long)( 'o'))<<8)|((long)( 2))):
3476                         c = ((0500+4)+6);
3477                         break;
3478                 case ((((long)( 'e'))<<16)|(((long)( 'e'))<<8)|((long)( 4))):
3479                         if (!(flags & (1L<<20)) && !sstrncmp( proto->tp, "else", 4))
3480                         {
3481                                 c = ((0500+4)+8);
3482                                 goto fsm_id;
3483                         }
3484                         break;
3485                 case ((((long)( 'e'))<<16)|(((long)( 'n'))<<8)|((long)( 6))):
3486                         if (!sstrncmp( proto->tp, "extern", 6))
3487                                 c = ((0500+4)+9);
3488                         break;
3489                 case ((((long)( 'f'))<<16)|(((long)( 'r'))<<8)|((long)( 3))):
3490                         if (!(flags & (1L<<20)) && !sstrncmp( proto->tp, "for", 3))
3491                         {
3492                                 c = ((0500+4)+11);
3493                                 goto fsm_id;
3494                         }
3495                         break;
3496                 case ((((long)( 'i'))<<16)|(((long)( 'f'))<<8)|((long)( 2))):
3497                         c = ((0500+4)+13);
3498                         break;
3499                 case ((((long)( 'r'))<<16)|(((long)( 'n'))<<8)|((long)( 6))):
3500                         if (!(flags & (1L<<20)) && !sstrncmp( proto->tp, "return", 6))
3501                         {
3502                                 c = ((0500+4)+17);
3503                                 goto fsm_id;
3504                         }
3505                         break;
3506                 case ((((long)( 't'))<<16)|(((long)( 'f'))<<8)|((long)( 7))):
3507                         if (!(flags & (1L<<20)) && !sstrncmp( proto->tp, "typedef", 7))
3508                         {
3509                                 flags |= (1L<<26);
3510                                 c = ((0500+4)+9);
3511                         }
3512                         break;
3513                 case ((((long)( 'v'))<<16)|(((long)( 't'))<<8)|((long)( 8))):
3514                         if (*ip == '(' && !sstrncmp( proto->tp, "va_start", 8)) c = (0500+1);
3515                         break;
3516                 case ((((long)( 'v'))<<16)|(((long)( 'd'))<<8)|((long)( 4))):
3517                         if (!sstrncmp( proto->tp, "void", 4))
3518                         {
3519                                 if (flags & ((1L<<0)|(1L<<18)|(1L<<9)|(1L<<10))) c = ((0500+4)+30);
3520                                 else
3521                                 {
3522                                         do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
3523                                         line = proto->line;
3524                                         if (lex(proto, (flags & ((1L<<15))) | (1L<<20)) == '*')
3525                                         {
3526                                                 memcopy(op - 4, "__V_", 4);
3527                                                 memcopy(ip - 4, "__V_", 4);
3528                                         }
3529                                         else c = ((0500+4)+30);
3530                                         proto->line = line;
3531                                         do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
3532                                         bp = ip;
3533                                 }
3534                         }
3535                         break;
3536                 case ((((long)( 'w'))<<16)|(((long)( 'e'))<<8)|((long)( 5))):
3537                         if (!(flags & (1L<<20)) && !sstrncmp( proto->tp, "while", 5))
3538                         {
3539                                 c = ((0500+4)+26);
3540                                 goto fsm_id;
3541                         }
3542                         break;
3543                 }
3544
3545                 if ((flags & (1L<<0)) && c != ((0500+4)+9))
3546                         c = (0401+0);
3547
3548                 break;
3549
3550         case ((0+26)+10):
3551                 goto fsm_start;
3552
3553         case ((0+26)+15):
3554                 (ip--);
3555
3556                 if ((flags & ((1L<<5)|(1L<<14))) == (1L<<5))
3557                 {
3558                         while (op > proto->ob && (*(op - 1) == ' ' || *(op - 1) == '\t'))
3559                                 op--;
3560                         if (op > proto->ob && *(op - 1) != '\n') *op++ = ' ';
3561                 }
3562
3563                 goto fsm_start;
3564
3565         default:
3566                 if (c == '\\' && (state & (1<<7)))
3567                 {
3568                         if (!(n = (*(unsigned char*)ip++)))
3569                         {
3570                                 goto fsm_eob;
3571  fsm_splice:
3572                                 c = '\\';
3573                                 n = (*(unsigned char*)ip++);
3574                         }
3575                         if (n == '\n')
3576                         {
3577                                 proto->line++;
3578                                 (*op++=( '\\'));
3579                                 (*op++=( '\n'));
3580                                 bp = ip;
3581                                 goto fsm_get;
3582                         }
3583                         (ip--);
3584                         state &= ~(1<<7);
3585                         if (state >= (0+26)) goto fsm_terminal;
3586                         rp = _pp_fsmtab[state];
3587                 }
3588                 (*op++=( c));
3589                 bp = ip;
3590                 goto fsm_get;
3591         }
3592         if (!(flags & ((1L<<9)|(1L<<10)|(1L<<20))))
3593         {
3594                 if (!(flags & (1L<<3))) switch (c)
3595                 {
3596                 case '(':
3597
3598                         if (!(flags & (1L<<0)) || proto->brace == 0)
3599
3600                         {
3601                                 if (paren++ == 0)
3602                                 {
3603
3604                                         if (!(flags & (1L<<0)) || group <= 1)
3605
3606                                         {
3607
3608                                                 args = 0;
3609
3610                                                 if (group++ == 0) group++;
3611                                                 else if (flags & (1L<<7)) call++;
3612                                                 flags |= (1L<<14);
3613                                                 im = ip - 1;
3614                                                 om = op - 1;
3615                                         }
3616                                 }
3617                                 else if (paren == 2 && !aim)
3618                                 {
3619                                         if (flags & (1L<<7))
3620                                         {
3621                                                 aim = ip - 1;
3622                                                 aom = op - 1;
3623                                         }
3624                                         else if ((flags & ((1L<<14)|(1L<<25))) == (1L<<14))
3625                                         {
3626                                                 for (m = ip - 2; m > im && (*m == ' ' || *m == '\t'); m--);
3627                                                 if (m == im)
3628                                                 {
3629                                                         flags &= ~(1L<<14);
3630                                                         om = 0;
3631                                                 }
3632                                         }
3633                                 }
3634                                 flags &= ~(1L<<25);
3635                         }
3636                         break;
3637                 case ')':
3638
3639                         if (!(flags & (1L<<0)) || proto->brace == 0)
3640
3641                         if (--paren == 0)
3642                         {
3643
3644                                 if (flags & (1L<<0))
3645                                 {
3646                                         if (group != 2)
3647                                         {
3648                                                 c = (0401+0);
3649                                                 break;
3650                                         }
3651                                         group++;
3652                                 }
3653
3654                                 ie = ip;
3655                         }
3656                         else if (paren == 1 && (flags & (1L<<7)) && !aie)
3657                                 aie = ip;
3658                         break;
3659                 case '*':
3660                         if (last == '(' && group == 2)
3661                         {
3662                                 group--;
3663                                 if (paren == 1)
3664                                 {
3665                                         flags |= (1L<<7);
3666                                         aim = aie = 0;
3667                                 }
3668                         }
3669                         break;
3670                 case '#':
3671  fsm_directive:
3672                         if (!(flags & ((1L<<1)|(1L<<3))))
3673                         {
3674                                 flags |= (1L<<3);
3675                                 if (!(flags & (1L<<18)))
3676                                 {
3677                                         bp = ip;
3678                                         while (*ip == ' ' || *ip == '\t') ip++;
3679                                         if (*ip == 'l' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e')
3680                                         {
3681                                                 if (*++ip == ' ' || *ip == '\t')
3682                                                 {
3683                                                         proto->line = 0;
3684                                                         while (*++ip >= '0' && *ip <= '9')
3685                                                                 proto->line = proto->line * 10 + *ip - '0';
3686                                                         proto->line--;
3687                                                 }
3688                                         }
3689
3690                                         else if ((flags & ((1L<<0)|(1L<<5))) == (1L<<0))
3691                                         {
3692                                                 n = 0;
3693                                                 t = ip + 6;
3694                                                 while (ip < t && *ip >= 'a' && *ip <= 'z') n = (n << 5) | (*ip++ - 'a');
3695                                                 switch (n)
3696                                                 {
3697                                                 case   ((('e'-'a')<<15)|(('l'-'a')<<10)|(('s'-'a')<<5)|('e'-'a')):
3698                                                 case   ((('e'-'a')<<20)|(('n'-'a')<<15)|(('d'-'a')<<10)|(('i'-'a')<<5)|('f'-'a')):
3699                                                         while (*ip == ' ' || *ip == '\t') ip++;
3700                                                         if (*ip != '\n' && *ip != '/' && *(ip + 1) != '*')
3701                                                         {
3702                                                                 flags |= (1L<<11)|(1L<<14);
3703                                                                 im = ip;
3704                                                                 om = op + (ip - bp);
3705                                                         }
3706                                                         break;
3707                                                 case   ((('e'-'a')<<15)|(('l'-'a')<<10)|(('i'-'a')<<5)|('f'-'a')):
3708                                                 case   ((('e'-'a')<<20)|(('r'-'a')<<15)|(('r'-'a')<<10)|(('o'-'a')<<5)|('r'-'a')):
3709                                                 case   ((('i'-'a')<<5)|('f'-'a')):
3710                                                 case   ((('i'-'a')<<20)|(('f'-'a')<<15)|(('d'-'a')<<10)|(('e'-'a')<<5)|('f'-'a')):
3711                                                 case   ((('i'-'a')<<25)|(('f'-'a')<<20)|(('n'-'a')<<15)|(('d'-'a')<<10)|(('e'-'a')<<5)|('f'-'a')):
3712                                                 case   ((('u'-'a')<<20)|(('n'-'a')<<15)|(('d'-'a')<<10)|(('e'-'a')<<5)|('f'-'a')):
3713                                                         break;
3714                                                 case   ((('i'-'a')<<25)|(('n'-'a')<<20)|(('c'-'a')<<15)|(('l'-'a')<<10)|(('u'-'a')<<5)|('d'-'a')):
3715                                                         if (*ip == 'e') ip++;
3716  
3717                                                 case   ((('d'-'a')<<25)|(('e'-'a')<<20)|(('f'-'a')<<15)|(('i'-'a')<<10)|(('n'-'a')<<5)|('e'-'a')):
3718                                                 case   ((('p'-'a')<<25)|(('r'-'a')<<20)|(('a'-'a')<<15)|(('g'-'a')<<10)|(('m'-'a')<<5)|('a'-'a')):
3719                                                         if (*ip < 'a' || *ip > 'z') break;
3720  
3721                                                 default:
3722                                                         flags |= (1L<<11)|(1L<<14);
3723                                                         im = bp - 1;
3724                                                         om = op - 1;
3725                                                         break;
3726                                                 }
3727                                         }
3728                                         else
3729
3730                                         {
3731                                                 if (*ip == 'i' && *++ip == 'n' && *++ip == 'c' && *++ip == 'l' && *++ip == 'u' && *++ip == 'd' && *++ip == 'e')
3732                                                 {
3733                                                         while (*++ip == ' ' || *ip == '\t');
3734                                                         if (*ip++ == '<' && *ip++ == 's' && *ip++ == 't' && *ip++ == 'd' && *ip++ == 'a' && *ip++ == 'r' && *ip++ == 'g' && *ip++ == '.' && *ip++ == 'h' && *ip++ == '>')
3735                                                         {
3736                                                                 op = strcopy(op, "\
3737 if !defined(va_start)\n\
3738 #if defined(__STDARG__)\n\
3739 #include <stdarg.h>\n\
3740 #else\n\
3741 #include <varargs.h>\n\
3742 #endif\n\
3743 #endif\n\
3744 ");
3745                                                                 op = linesync(proto, op, proto->line);
3746                                                                 break;
3747                                                         }
3748                                                 }
3749                                                 else if (*ip == 'd' && *++ip == 'e' && *++ ip == 'f' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e' && (*++ip == ' ' || *ip == '\t'))
3750                                                 {
3751                                                         flags |= (1L<<2)|(1L<<14);
3752                                                         im = bp - 1;
3753                                                         om = op - 1;
3754                                                 }
3755                                         }
3756                                         ip = bp;
3757                                 }
3758                         }
3759                         break;
3760                 case '{':
3761                         if (proto->brace++ == 0 && paren == 0)
3762                         {
3763                                 if (last == '=') flags |= (1L<<8);
3764
3765                                 else if (flags & (1L<<0))
3766                                 {
3767                                         if ((flags & ((1L<<14)|(1L<<16)|(1L<<23))) == (1L<<14))
3768                                         {
3769                                                 if (args)
3770                                                 {
3771                                                         v = number(op, args < 0 ? -args : args);
3772                                                         v = strcopy(v, " argument actual/formal mismatch");
3773                                                         *v++ = ' ';
3774                                                         v = memcopy(v, im, ie - im);
3775                                                         *v = 0;
3776                                                         proto_error((char*)proto + sizeof(struct proto), 2, op, ((char*)0));
3777                                                 }
3778                                                 ip--;
3779  
3780         v = ie;
3781         while (ie < ip)
3782                 if (*ie++ == '/' && *ie == '*')
3783                 {
3784                         e = ie - 1;
3785                         while (++ie < ip)
3786                         {
3787                                 if (*ie == '*')
3788                                 {
3789                                         while (ie < ip && *ie == '*') ie++;
3790                                         if (ie < ip && *ie == '/')
3791                                         {
3792                                                 while (++ie < ip && (*ie == ' ' || *ie == '\t'));
3793                                                 while (e > v && (*(e - 1) == ' ' || *(e - 1) == '\t')) e--;
3794                                                 if (e > v && *e != '\n') *e++ = ' ';
3795                                                 t = ie;
3796                                                 while (--e >= v)
3797                                                         *--t = *e;
3798                                                 v = t;
3799                                                 break;
3800                                         }
3801                                 }
3802                         }
3803                 }
3804         ie = v;
3805  
3806                                                 op = om++;
3807                                                 if (flags & (1L<<5))
3808                                                 {
3809                                                         v = op;
3810                                                         while (v > ko && *--v != ' ');
3811                                                         if (*v != ' ')
3812                                                         {
3813                                                                 om = (v = (op += 4)) + 1;
3814                                                                 while (v >= ko + 4)
3815                                                                 {
3816                                                                         *v = *(v - 4);
3817                                                                         v--;
3818                                                                 }
3819                                                                 memcopy(ko, "int ", 4);
3820                                                         }
3821                                                         if (*v == ' ')
3822                                                         {
3823                                                                 while (*(v + 1) == '*')
3824                                                                         *v++ = '*';
3825                                                                 *v = '\t';
3826                                                                 if ((v - ko) <= 8)
3827                                                                 {
3828                                                                         om = (e = ++op) + 1;
3829                                                                         while (e > v)
3830                                                                         {
3831                                                                                 *e = *(e - 1);
3832                                                                                 e--;
3833                                                                         }
3834                                                                 }
3835                                                         }
3836                                                         om = (v = (op += 7)) + 1;
3837                                                         while (v >= ko + 7)
3838                                                         {
3839                                                                 *v = *(v - 7);
3840                                                                 v--;
3841                                                         }
3842                                                         memcopy(ko, "extern ", 7);
3843                                                 }
3844                                                 (*op++=( '('));
3845                                                 t = op;
3846                                                 e = 0;
3847  
3848         while (ie < ip)
3849         {
3850                 if ((c = *ie) == ' ' || c == '\t' || c == '\n')
3851                 {
3852                         while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
3853                         if (ie >= ip) break;
3854                         if (c != '*' && op > om) (*op++=( ' '));
3855                 }
3856                 if ((n = ((c = *ie) == ',')) || c == ';')
3857                 {
3858                         if (flags & (1L<<5))
3859                         {
3860                                 m = op;
3861                                 while (op > om && ((c = *(op - 1)) == '(' || c == ')' || c == '[' || c == ']'))
3862                                         op--;
3863                                 v = op;
3864                                 while (op > om && (c = *(op - 1)) != ' ' && c != '*')
3865                                         op--;
3866                                 while (*(op - 1) == ' ')
3867                                         op--;
3868                                 if (!e)
3869                                 {
3870                                         e = op;
3871                                         while (e > om && *(e - 1) == '*')
3872                                                 e--;
3873                                 }
3874
3875
3876
3877
3878                                 if (op <= om)
3879                                         op = strcopy(op, "int");
3880                                 else if (*(op - 1) == ',')
3881                                         op = strcopy(op, " int");
3882
3883                                 while (v < m)
3884                                         (*op++=( *v++));
3885                         }
3886                         (*op++=( ','));
3887                         if (n)
3888                         {
3889                                 if (x = !e) e = op - 1;
3890                                 (*op++=( ' '));
3891                                 m = t;
3892                                 while (m < e)
3893                                         (*op++=( *m++));
3894                                 if (x)
3895                                 {
3896                                         m = e;
3897                                         while (*--e != ' ');
3898                                         while (*(e - 1) == '*') e--;
3899                                         op -= m - e;
3900                                 }
3901                         }
3902                         while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
3903                         if (ie >= ip) (op--);
3904                         else (*op++=( ' '));
3905                         if (!n)
3906                         {
3907                                 t = op;
3908                                 e = 0;
3909                         }
3910                 }
3911                 else if (*ie == '*')
3912                 {
3913                         if (op > om && (c = *(op - 1)) == ' ') op--;
3914                         while (*ie == '*') (*op++=( *ie++));
3915                         while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3916                         if (c != '(') (*op++=( ' '));
3917                 }
3918                 else if (*ie == '(')
3919                 {
3920                         if (op > om && *(op - 1) == ' ') op--;
3921                         (*op++=( *ie++));
3922                         while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3923                 }
3924                 else if (*ie == ')')
3925                 {
3926                         if (op > om && *(op - 1) == '(')
3927                                 proto_error((char*)proto + sizeof(struct proto), 1, "function pointer argument prototype omitted", ((char*)0));
3928                         (*op++=( *ie++));
3929                         while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3930                 }
3931                 else if ((flags & (1L<<5)) && (op == om || *(op - 1) == ' ') && *ie == 'r' && !sstrncmp( ie, "register", 8) && (*(ie + 8) == ' ' || *(ie + 8) == '\t' || *(ie + 8) == '\n'))
3932                 {
3933                         ie += 8;
3934                         if (op > om) (op--);
3935                 }
3936                 else (*op++=( *ie++));
3937         }
3938  
3939                                                 if (op <= om) op = strcopy(op, "void");
3940                                                 (*op++=( ')'));
3941                                                 if (flags & (1L<<5))
3942                                                 {
3943                                                         (*op++=( ';'));
3944                                                         (*op++=( '\n'));
3945                                                         (proto->op=op);
3946                                                         (ko=op);
3947                                                 }
3948                                                 else
3949                                                 {
3950                                                         (*op++=( '\n'));
3951                                                         (*op++=( *ip));
3952                                                 }
3953                                                 ip++;
3954                                                 flags &= ~((1L<<14)|(1L<<23));
3955                                         }
3956                                 }
3957
3958                                 else if ((flags & ((1L<<14)|(1L<<18)|(1L<<23)|(1L<<25))) == ((1L<<14)|(1L<<25)))
3959                                 {
3960                                         line = proto->line;
3961                                         op = strcopy(om, " __PARAM__(");
3962                                         op = memcopy(op, im, ie - im);
3963                                         (*op++=( ','));
3964                                         (*op++=( ' '));
3965                                         (*op++=( '('));
3966                                         flags &= ~((1L<<14)|(1L<<23));
3967                                         if (flags & (1L<<27))
3968                                         {
3969                                                 if ((vc = ie - im + 1) > sizeof(proto->variadic)) vc = sizeof(proto->variadic);
3970                                                 memcopy(proto->variadic, im, vc);
3971                                                 op = strcopy(op, "va_alist)) __OTORP__(va_dcl)\n{");
3972                                         }
3973                                         else
3974                                         {
3975                                                 flags |= (1L<<23);
3976                                                 proto->ip = im;
3977                                                 proto->op = op;
3978                                                 group = 0;
3979                                                 for (;;)
3980                                                 {
3981                                                         switch (lex(proto, (flags & ((1L<<15))) | (1L<<20)))
3982                                                         {
3983                                                         case '(':
3984                                                                 if (paren++) group++;
3985                                                                 continue;
3986                                                         case ')':
3987                                                                 if (--paren == 0)
3988                                                                 {
3989                                                                         group = 0;
3990                                                                         if (flags & (1L<<14))
3991                                                                         {
3992                                                                                 flags &= ~((1L<<14)|(1L<<23));
3993                                                                                 op = memcopy(op, m, e - m);
3994                                                                         }
3995                                                                         break;
3996                                                                 }
3997                                                                 continue;
3998                                                         case ',':
3999                                                                 if (paren == 1)
4000                                                                 {
4001                                                                         group = 0;
4002                                                                         if (flags & (1L<<14))
4003                                                                         {
4004                                                                                 flags &= ~((1L<<14)|(1L<<23));
4005                                                                                 op = memcopy(op, m, e - m);
4006                                                                         }
4007                                                                         (*op++=( ','));
4008                                                                         (*op++=( ' '));
4009                                                                         proto->op = op;
4010                                                                 }
4011                                                                 continue;
4012                                                         case (0401+0):
4013                                                                 if (group <= 1)
4014                                                                 {
4015                                                                         flags |= (1L<<14);
4016                                                                         m = proto->tp;
4017                                                                         e = proto->ip;
4018                                                                 }
4019                                                                 continue;
4020                                                         default:
4021                                                                 continue;
4022                                                         }
4023                                                         break;
4024                                                 }
4025                                                 (*op++=( ')'));
4026                                                 (*op++=( ')'));
4027                                         }
4028                                         if (!(flags & (1L<<23)))
4029                                         {
4030                                                 flags |= (1L<<23);
4031                                                 proto->op = strcopy(op, " __OTORP__(");
4032                                                 proto->ip = im + 1;
4033                                                 n = *(ie - 1);
4034                                                 *(ie - 1) = ';';
4035                                                 c = *ie;
4036                                                 *ie = 0;
4037                                                 lex(proto, (flags & ((1L<<15))) | (1L<<1));
4038                                                 *(ie - 1) = n;
4039                                                 *ie = c;
4040                                                 proto->ip = ie;
4041                                                 op = proto->op;
4042                                                 (*op++=( ')'));
4043                                         }
4044                                         op = linesync(proto, op, proto->line = line);
4045                                         if (!(flags & (1L<<27))) (*op++=( '{'));
4046                                 }
4047                         }
4048                         flags &= ~((1L<<6)|(1L<<7)|(1L<<14)|(1L<<16)|(1L<<23));
4049                         call = 0;
4050                         group = 0;
4051                         break;
4052                 case '}':
4053                         flags &= ~((1L<<6)|(1L<<7)|(1L<<14)|(1L<<16)|(1L<<23)|(1L<<25));
4054                         if (--proto->brace == 0)
4055                         {
4056                                 flags &= ~((1L<<8)|(1L<<27)|(1L<<28));
4057
4058                                 if (flags & (1L<<5)) (op=ko);
4059
4060                         }
4061                         call = 0;
4062                         group = 0;
4063                         paren = 0;
4064                         break;
4065                 case '=':
4066                         if (last == '?') flags |= (1L<<3);
4067                         else if (paren == 0 && (flags & ((1L<<8)|(1L<<14)|(1L<<23))) == (1L<<14)) goto fsm_statement;
4068                         goto fsm_other;
4069                 case ',':
4070
4071                         if (flags & (1L<<0))
4072                         {
4073                                 if (paren == 1) args++;
4074                                 else
4075                                 {
4076                                         args--;
4077                                         flags &= ~(1L<<14);
4078                                 }
4079                                 break;
4080                         }
4081
4082                         if (paren == 0 && (flags & (1L<<1))) *(op - 1) = c = ';';
4083  
4084                 case ';':
4085  fsm_statement:
4086                         if (flags & (1L<<8))  ;
4087
4088                         else if (flags & (1L<<0))
4089                         {
4090                                 if (paren == 0)
4091                                 {
4092                                         if ((flags & (1L<<14)) && last == ')')
4093                                                 flags &= ~(1L<<14);
4094                                         if (!(flags & (1L<<14)))
4095                                         {
4096                                                 call = 0;
4097                                                 group = 0;
4098                                                 flags &= ~(1L<<23);
4099                                                 if (flags & (1L<<5)) (op=ko);
4100                                                 if (flags & (1L<<24))
4101                                                 {
4102                                                         do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
4103                                                         return(0);
4104                                                 }
4105                                         }
4106                                         else
4107                                         {
4108                                                 args--;
4109                                                 if ((flags & ((1L<<5)|(1L<<23))) == ((1L<<5)|(1L<<23)))
4110                                                         (op=ko);
4111                                         }
4112                                 }
4113                         }
4114
4115                         else if (paren == 0)
4116                         {
4117                                 if ((flags & ((1L<<14)|(1L<<16)|(1L<<23))) == (1L<<14) && call > 1)
4118                                 {
4119                                         if ((flags & ((1L<<1)|(1L<<7))) == (1L<<7) && aim && aie < im)
4120                                         {
4121                                                 while (aie < ip && (*aie == ' ' || *aie == '\t' || *aie == '\n')) aie++;
4122                                                 v = aim;
4123                                                 while (v < aie)
4124                                                         if (*v++ == ')') break;
4125                                                 while (v < aie && (*v == ' ' || *v == '\t' || *v == '\n')) v++;
4126                                                 if (v == aie || !(flags & (1L<<19)))
4127                                                 {
4128                                                         if (flags & (1L<<19)) n = 3;
4129                                                         else if (v == aie && *v == '(') n = 10;
4130                                                         else n = 11;
4131                                                         ko = op;
4132                                                         om += n;
4133                                                         v = op += n;
4134                                                         while (v >= ko + n)
4135                                                         {
4136                                                                 *v = *(v - n);
4137                                                                 v--;
4138                                                         }
4139                                                         if (flags & (1L<<19)) memcopy(aom, "(...))", 6);
4140                                                         else if (n == 10) memcopy(aom, "(__VARARG__))", 13);
4141                                                         else
4142                                                         {
4143                                                                 ko = strcopy(aom, " __PROTO__(");
4144                                                                 ko = memcopy(ko, aim, aie - aim);
4145                                                                 *ko = ')';
4146                                                                 if (++ko >= om)
4147                                                                 {
4148                                                                         *ko++ = ')';
4149                                                                         om = ko;
4150                                                                 }
4151                                                         }
4152                                                 }
4153                                         }
4154                                         else if (flags & (1L<<26))
4155                                         {
4156                                                 op = om;
4157                                                 while (*--op == ' ' || *op == '\t' || *op == '\n');
4158                                                 if (*op != ')')
4159                                                 {
4160                                                         op = om += 14;
4161                                                         *--op = ')';
4162                                                         while ((x = *(op - 14)) >= 'A' && x <= 'Z' || x >= 'a' && x <= 'z' || x >= '0' && x <= '9' || x == '_')
4163                                                                 *--op = x;
4164                                                         memcopy(op - 13, "(__OTORP__(*)", 13);
4165                                                 }
4166                                         }
4167                                         if (flags & (1L<<19))
4168                                         {
4169                                                 if (!(flags & (1L<<25)))
4170                                                 {
4171                                                         op = strcopy(om, "(...)");
4172                                                         (*op++=( c));
4173                                                 }
4174                                         }
4175                                         else
4176                                         {
4177                                                 if (flags & (1L<<1)) op = strcopy(om, "()");
4178                                                 else if (!(flags & (1L<<25))) op = strcopy(om, "(__VARARG__)");
4179                                                 else
4180                                                 {
4181                                                         op = strcopy(om, " __PROTO__(");
4182                                                         op = memcopy(op, im, ie - im);
4183                                                         (*op++=( ')'));
4184                                                 }
4185                                                 (*op++=( c));
4186                                         }
4187                                         flags &= ~((1L<<14)|(1L<<27)|(1L<<28));
4188                                         if (c == ',' && !(flags & (1L<<7)))
4189                                         {
4190                                                 call = 1;
4191                                                 group = 0;
4192                                                 break;
4193                                         }
4194                                 }
4195                                 else if (flags & ((1L<<16)|(1L<<23))) call = 0;
4196                                 if (c == ';')
4197                                 {
4198                                         flags &= ~((1L<<13)|(1L<<26));
4199                                         if (flags & (1L<<24))
4200                                         {
4201                                                 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
4202                                                 return(0);
4203                                         }
4204                                         call = 0;
4205                                 }
4206                                 else call = call > 1 && c == ',';
4207                                 group = 0;
4208                                 flags &= ~((1L<<6)|(1L<<7)|(1L<<14)|(1L<<16)|(1L<<23));
4209                         }
4210                         else if (paren == 1 && group == 1 && !(flags & ((1L<<6)|(1L<<13)))) flags |= (1L<<25)|(1L<<16);
4211                         break;
4212                 case ((0500+4)+6):
4213                 case ((0500+4)+13):
4214                         flags |= (1L<<25)|(1L<<23);
4215                         break;
4216                 case ((0500+4)+9):
4217
4218                         if (flags & (1L<<0))
4219                         {
4220                                 if (proto->brace == 0)
4221                                         flags |= (1L<<23);
4222                         }
4223                         else
4224
4225                         if (paren == 0 && !(flags & (1L<<26)))
4226                         {
4227                                 flags |= (1L<<13);
4228                                 if (!(flags & (1L<<18)))
4229                                         op = strcopy(op, " __MANGLE__");
4230                         }
4231                         break;
4232                 case (0401+29):
4233                         if (paren == 0 && (flags & ((1L<<1)|(1L<<27))) == (1L<<1))
4234                         {
4235                                 op -= 3;
4236                                 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
4237                                 return(c);
4238                         }
4239                         if (paren == 1 && !(flags & (1L<<23)))
4240                                 flags |= (1L<<27);
4241                         flags |= (1L<<25);
4242                         break;
4243                 case ((0500+4)+30):
4244                         goto fsm_id;
4245                 case (0500+1):
4246                         if ((flags & ((1L<<18)|(1L<<27))) == (1L<<27))
4247                         {
4248                                 flags &= ~(1L<<14);
4249                                 line = proto->line;
4250                                 op = strcopy(op - 8, "__VA_START__");
4251                                 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
4252                                 for (;;)
4253                                 {
4254                                         switch (lex(proto, (flags & ((1L<<15))) | (1L<<20)))
4255                                         {
4256                                         case 0:
4257                                         case ';':
4258                                                 break;
4259                                         case (0401+0):
4260                                                 if (!(flags & (1L<<14)))
4261                                                 {
4262                                                         flags |= (1L<<14);
4263                                                         m = proto->tp;
4264                                                         e = proto->ip;
4265                                                 }
4266                                                 continue;
4267                                         default:
4268                                                 continue;
4269                                         }
4270                                         break;
4271                                 }
4272                                 ((ip=proto->ip),(op=proto->op));
4273                                 if (flags & (1L<<14))
4274                                 {
4275                                         v = m;
4276                                         n = e - m;
4277                                 }
4278                                 else
4279                                 {
4280                                         v = "ap";
4281                                         n = 2;
4282                                 }
4283                                 op = strcopy(op, " __OTORP__(");
4284                                 proto->ip = proto->variadic;
4285                                 proto->op = op;
4286                                 flags &= ~(1L<<14);
4287                                 group = 0;
4288                                 bp = proto->ip + 1;
4289                                 if (*bp == 'r' && !sstrncmp( bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
4290                                 for (;;)
4291                                 {
4292                                         switch (lex(proto, (flags & ((1L<<15))) | (1L<<20)))
4293                                         {
4294                                         case '(':
4295                                                 if (paren++) group++;
4296                                                 continue;
4297                                         case ')':
4298                                                 if (--paren == 0)
4299                                                 {
4300                                                         if (flags & (1L<<14))
4301                                                         {
4302                                                                 flags &= ~(1L<<14);
4303                                                                 if (!(flags & (1L<<28)))
4304                                                                 {
4305                                                                         op = memcopy(op, m, e - m);
4306                                                                         op = strcopy(op, " = ");
4307                                                                 }
4308                                                                 op = strcopy(op, "va_arg(");
4309                                                                 op = memcopy(op, v, n);
4310                                                                 (*op++=( ','));
4311                                                                 (*op++=( ' '));
4312                                                                 if (m > bp) op = memcopy(op, bp, m - bp);
4313                                                                 else op = strcopy(op, "int ");
4314                                                                 if (group > 1) op = strcopy(op, ")()");
4315                                                                 else op = memcopy(op, e, proto->ip - e - 1);
4316                                                                 (*op++=( ')'));
4317                                                                 (*op++=( ';'));
4318                                                         }
4319                                                         group = 0;
4320                                                         break;
4321                                                 }
4322                                                 continue;
4323                                         case ',':
4324                                                 if (paren == 1)
4325                                                 {
4326                                                         if (flags & (1L<<14))
4327                                                         {
4328                                                                 flags &= ~(1L<<14);
4329                                                                 if (!(flags & (1L<<28)))
4330                                                                 {
4331                                                                         op = memcopy(op, m, e - m);
4332                                                                         op = strcopy(op, " = ");
4333                                                                 }
4334                                                                 op = strcopy(op, "va_arg(");
4335                                                                 op = memcopy(op, v, n);
4336                                                                 (*op++=( ','));
4337                                                                 (*op++=( ' '));
4338                                                                 if (m > bp) op = memcopy(op, bp, m - bp);
4339                                                                 else op = strcopy(op, "int ");
4340                                                                 if (group > 1) op = strcopy(op, ")()");
4341                                                                 else op = memcopy(op, e, proto->ip - e - 1);
4342                                                                 (*op++=( ')'));
4343                                                                 (*op++=( ';'));
4344                                                                 bp = proto->ip + 1;
4345                                                                 if (*bp == 'r' && !sstrncmp( bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
4346                                                         }
4347                                                         group = 0;
4348                                                         proto->op = op;
4349                                                 }
4350                                                 continue;
4351                                         case (0401+0):
4352                                                 if (group <= 1)
4353                                                 {
4354                                                         flags |= (1L<<14);
4355                                                         m = proto->tp;
4356                                                         e = proto->ip;
4357                                                 }
4358                                                 continue;
4359                                         default:
4360                                                 continue;
4361                                         }
4362                                         break;
4363                                 }
4364                                 op = strcopy(op, ")");
4365                                 flags |= (1L<<28);
4366                                 proto->line = line;
4367                                 call = 0;
4368                                 break;
4369                         }
4370  
4371                 case (0401+0):
4372  fsm_id:
4373
4374                         if (flags & (1L<<0))
4375                         {
4376                                 if (!args && paren == 1) args++;
4377                                 break;
4378                         }
4379
4380                         if (paren == 0)
4381                         {
4382                                 if (last == ')')
4383                                 {
4384                                         if (proto->brace == 0 && !(flags & (1L<<1))) flags |= (1L<<23);
4385                                         call = !call;
4386                                 }
4387                                 else if ((flags & (1L<<23)) || c == (0401+0) || c == ((0500+4)+30)) call++;
4388                                 else flags |= (1L<<23);
4389                                 if (last == (0401+0)) flags |= (1L<<6);
4390                         }
4391                         c = (0401+0);
4392                         flags |= (1L<<25);
4393                         break;
4394                 case (0401+1):
4395                         if (*proto->tp >= '0' && *proto->tp <= '9')
4396                                 switch (*(op - 1))
4397                                 {
4398                                 case 'l':
4399                                 case 'L':
4400                                         switch (*(op - 2))
4401                                         {
4402                                         case 'l':
4403                                         case 'L':
4404                                         case 'u':
4405                                         case 'U':
4406                                                 *(op - 2) = *(op - 1);
4407                                                 op--;
4408                                                 break;
4409                                         }
4410                                         break;
4411                                 case 'u':
4412                                 case 'U':
4413                                         op--;
4414                                         break;
4415                                 }
4416                         goto fsm_other;
4417
4418                 case '[':
4419                         if ((flags & (1L<<0)) && paren == 0 && group <= 2) flags |= (1L<<23);
4420  
4421
4422                 default:
4423  fsm_other:
4424
4425                         if (flags & (1L<<0)) break;
4426
4427                         flags |= (1L<<25);
4428                         if (paren == 0) flags |= (1L<<16);
4429                         break;
4430                 }
4431                 else if (c == '#' && *ip != '(') flags |= (1L<<22);
4432                 last = c;
4433
4434                 if ((flags & ((1L<<5)|(1L<<14))) == ((1L<<5)|(1L<<14)) && ((flags & ((1L<<3)|(1L<<23))) || proto->brace || c != '(' && c != ')' && c != '*' && c != (0401+0)))
4435                         (op=proto->op);
4436                 else
4437
4438                 (proto->op=op);
4439                 goto fsm_start;
4440         }
4441         else if (flags & ((1L<<9)|(1L<<10)))
4442         {
4443
4444                 if ((flags & (1L<<29)) && c == '%' && *ip == '{') t = 0;
4445                 else
4446
4447                 {
4448                         if (c == '#') for (t = ip; *t == ' ' || *t == '\t'; t++);
4449                         else t = "";
4450                         if (*t++ == 'i' && *t++ == 'f' && *t++ == 'n' && *t++ == 'd' && *t++ == 'e' && *t++ == 'f')
4451                         {
4452
4453
4454
4455
4456                                         t = 0;
4457                         }
4458                 }
4459                 if (t)
4460                 {
4461                         ip = bp;
4462                         op = proto->op;
4463                 }
4464                 else while (*ip != '\n') *op++ = *ip++;
4465                 op = init(op, flags);
4466                 op = linesync(proto, op, proto->line);
4467                 flags &= ~((1L<<9)|(1L<<10));
4468                 proto->flags &= ~((1L<<9)|(1L<<10));
4469                 goto fsm_start;
4470         }
4471         do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<8)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<8)|(1L<<27)|(1L<<28));}while(0);
4472         return(c);
4473 }
4474
4475  
4476
4477
4478
4479 void
4480 pppclose __PARAM__((char* iob), (iob)) __OTORP__(char* iob;){
4481         register struct proto*  proto = (struct proto*)(iob - sizeof(struct proto));
4482
4483         if (proto->flags & (1L<<15)) close(proto->fd);
4484         free((char*)proto);  
4485 }
4486
4487  
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497 char*
4498 pppopen __PARAM__((char* file, int fd, char* notice, int flags), (file, fd, notice, flags)) __OTORP__(char* file; int fd; char* notice; int flags;){
4499         register struct proto*  proto;
4500         register char*          iob;
4501         register long           n;
4502         register char*          s;
4503         int                     pragma;
4504         char*                   b;
4505
4506         int                     comlen;
4507         char                    com[(62+4)];
4508
4509         int                     m = 0;
4510
4511         static int              retain;
4512
4513  
4514
4515
4516
4517
4518         if (flags & (1<<0)) flags &= ~(1<<4);
4519
4520         if (flags & (1<<10)) flags &= ~retain;
4521         else retain &= (1<<5);
4522         if (file && (fd = open(file, 0)) < 0) return(0);
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545         {
4546  
4547
4548
4549
4550                 n = (4*1024);
4551                 if (!(proto = (( 0)?( struct proto*)realloc((char*)( 0),sizeof( struct proto)*( 1)+( 5 * n + 2)):( struct proto*)calloc(1,sizeof( struct proto)*( 1)+( 5 * n + 2)))))
4552                         return(0);
4553                 proto->iz = n;
4554                 proto->oz = 3 * n;
4555                 proto->flags |= (1L<<15);
4556         }
4557         proto->fd = fd;
4558         iob = (char*)proto + sizeof(struct proto);
4559         proto->op = proto->ob = iob;
4560         proto->ip = proto->ib = iob + proto->oz + n;
4561         if (m) proto->flags |= (1L<<21);
4562
4563  
4564
4565
4566
4567         n = read(fd, proto->ip, proto->iz);
4568         if (!(proto->flags & (1L<<15)))
4569                 close(fd);
4570         if (n < 0)
4571         {
4572                 pppclose(iob);
4573                 return(0);
4574         }
4575         *(proto->ip + n) = 0;
4576
4577  
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589         if (notice)
4590         {
4591                 s = comment(com, ((char*)0), 0, 0);
4592                 comlen = s - com;
4593         }
4594         else *com = 0;
4595
4596         pragma = -1;
4597         s = proto->ip;
4598         m = 64;
4599         while (m-- > 0 && *s)
4600         {
4601                 while (*s == ' ' || *s == '\t') s++;
4602                 if (*s == '#')
4603                 {
4604                         b = s++;
4605                         while (*s == ' ' || *s == '\t') s++;
4606                         if (!sstrncmp( s, "pragma", sizeof("pragma") - 1) && (*(s += sizeof("pragma") - 1) == ' ' || *s == '\t'))
4607                         {
4608                                 while (*s == ' ' || *s == '\t') s++;
4609                                 if (*s == 'n' && *(s + 1) == 'o')
4610                                 {
4611                                         s += 2;
4612                                         pragma = -2;
4613                                 }
4614                                 if (!sstrncmp( s, "prototyped", sizeof("prototyped") - 1) && (*(s += sizeof("prototyped") - 1) == ' ' || *s == '\t' || *s == '\n' || *s == '\r'))
4615                                 {
4616                                         while (*s)
4617                                                 if (*s++ == '\n')
4618                                                 {
4619                                                         pragma += 2;
4620
4621                                                         if (!(flags & (1<<1)) || (flags & (1<<7)))
4622
4623                                                         for (s--; b < s; *b++ = ' ');
4624                                                         goto magic;
4625                                                 }
4626                                 }
4627                                 pragma = -1;
4628                         }
4629                 }
4630                 else if (*s == '/' && !sstrncmp( s, "/* : : generated by proto : : */\n", sizeof("/* : : generated by proto : : */\n") - 1))
4631                 {
4632                         pragma = 0;
4633                         break;
4634                 }
4635
4636                 else if (*s == '%' && *(s + 1) == '{') proto->flags |= (1L<<29);
4637                 else if (notice)
4638                 {
4639                         if (*s == *com && !sstrncmp( s, com, comlen)) notice = 0;
4640                         else
4641                         {
4642                                 while (*s)
4643                                 {
4644                                         if (*s == *"Copyright"&& !sstrncmp( s, "Copyright", sizeof("Copyright") - 1))
4645                                         {
4646                                                 s += sizeof("Copyright") - 1;
4647                                                 while (*s == ' ' || *s == '\t') s++;
4648                                                 if (*s == '(' && (*(s + 1) == 'c' || *(s + 1) == 'C') && *(s + 2) == ')')
4649                                                         notice = 0;
4650                                         }
4651                                         else if (*s++ == '\n') break;
4652                                 }
4653                                 continue;
4654                         }
4655                 }
4656
4657                 while (*s && *s++ != '\n');
4658         }
4659  magic:
4660         if (flags & (1<<9)) proto->flags |= (1L<<19);
4661         if (flags & (1<<11)) proto->test = 1;
4662
4663         if (flags & (1<<0)) pragma = -pragma;
4664         if (flags & (1<<1)) pragma = 0;
4665         if (flags & (1<<6)) proto->flags |= (1L<<12);
4666         if (!(proto->flags & (1L<<29)) && file && (m = sstrlen( file)) > 2 && file[--m] == 'y' && file[--m] == '.')
4667                 proto->flags |= (1L<<29);
4668
4669         if (pragma <= 0)
4670         {
4671                 if (flags & (1<<9))
4672                 {
4673                         flags &= ~((1<<3)|(1<<4));
4674                         proto->flags |= (1L<<18);
4675                 }
4676                 else if (!(flags & ((1<<2)|(1<<8))))
4677                 {
4678                         pppclose(iob);
4679                         return(0);
4680                 }
4681                 else if ((flags & (1<<8)) || !pragma)
4682                 {
4683                         proto->flags |= (1L<<17);
4684                         if (proto->flags & (1L<<15)) proto->oz += proto->iz;
4685                         proto->iz = n;
4686                         if (notice)
4687                         {
4688
4689                                 proto->op = copyright(proto->op, notice);
4690                                 if (!(flags & (1<<0)) && !(proto->flags & (1L<<29)))
4691
4692                                 proto->op = linesync(proto, proto->op, 1);
4693                                 proto->iz += proto->op - proto->ob;
4694                         }
4695                         memcopy(proto->op, proto->ip, n);
4696                         return(iob);
4697                 }
4698         }
4699
4700         if (!(retain & (1<<5)))
4701         {
4702                 retain |= (1<<5);
4703                 ppfsm(4, ((char*)0));
4704         }
4705
4706         proto->line = 1;
4707
4708         if (notice || (flags & ((1<<3)|(1<<4))))
4709         {
4710
4711                 if (notice) proto->op = copyright(proto->op, notice);
4712
4713                 if (flags & (1<<4))
4714                 {
4715                         proto->flags |= (1L<<10);
4716                         if (flags & (1<<10))
4717                                 retain |= (1<<4);
4718                 }
4719                 else if (flags & (1<<3))
4720                 {
4721                         if (flags & (1<<10)) retain |= (1<<3);
4722
4723                         if (flags & (1<<0))
4724                         {
4725                                 *proto->op++ = '#';
4726                                 proto->op = strcopy(proto->op, "pragma");
4727                                 *proto->op++ = ' ';
4728                                 proto->op = strcopy(proto->op, "prototyped");
4729                                 *proto->op++ = '\n';
4730                         }
4731                         else
4732
4733                         proto->flags |= (1L<<9);
4734                 }
4735
4736                 if (!(flags & (1<<0)))
4737                 {
4738                         if (proto->flags & (1L<<29))
4739                         {
4740                                 proto->op = strcopy(proto->op, "\n%{\n"+ !notice);
4741                                 proto->op = strcopy(proto->op, "/* : : generated by proto : : */\n");
4742                                 proto->op = strcopy(proto->op, "%}\n");
4743                         }
4744                         else
4745                         {
4746                                 if (n || notice) *proto->op++ = '\n';
4747                                 proto->op = strcopy(proto->op, "/* : : generated by proto : : */\n");
4748                                 if (n) proto->op = linesync(proto, proto->op, proto->line);
4749                                 else if (proto->flags & ((1L<<9)|(1L<<10)))
4750                                         proto->op = init(proto->op, proto->flags);
4751                         }
4752                 }
4753
4754         }
4755
4756
4757         proto->file = file;
4758         if (flags & (1<<0))
4759         {
4760                 proto->flags |= (1L<<0);
4761                 if (!(flags & (1<<3))) proto->flags |= (1L<<5);
4762         }
4763
4764         return(iob);
4765 }
4766
4767  
4768
4769
4770
4771
4772 int
4773 pppread __PARAM__((char* iob), (iob)) __OTORP__(char* iob;){
4774         register struct proto*  proto = (struct proto*)(iob - sizeof(struct proto));
4775         register int            n;
4776
4777         if (proto->flags & (1L<<17))
4778         {
4779                 if (proto->iz)
4780                 {
4781                         n = proto->iz;
4782                         proto->iz = 0;
4783                 }
4784                 else if (!(proto->flags & (1L<<15))) n = 0;
4785                 else if ((n = read(proto->fd, proto->ob, proto->oz)) <= 0 || (proto->flags & (1L<<21)) && n < proto->oz)
4786                 {
4787                         proto->flags &= ~(1L<<15);
4788                         close(proto->fd);
4789                 }
4790         }
4791         else
4792         {
4793                 if (proto->op == proto->ob)
4794                 {
4795                         if (proto->flags & (1L<<4)) return(-1);
4796
4797                         if (proto->flags & (1L<<29))
4798                         {
4799                                 register char*  ip = proto->ip;
4800                                 register char*  op = proto->ob;
4801                                 register char*  ep = proto->ob + proto->oz - 2;
4802
4803                                 if (!*ip)
4804                                 {
4805                                         ip = proto->ip = proto->ib;
4806                                         if (!(proto->flags & (1L<<15))) n = 0;
4807                                         else if ((n = read(proto->fd, ip, proto->iz)) <= 0 || (proto->flags & (1L<<21)) && n < proto->iz)
4808                                         {
4809                                                 if (n < 0) n = 0;
4810                                                 proto->flags &= ~(1L<<15);
4811                                                 close(proto->fd);
4812                                         }
4813                                         ip[n] = 0;
4814                                 }
4815                                 if (proto->flags & (1L<<30))
4816                                 {
4817                                         proto->flags &= ~(1L<<30);
4818                                         if (*ip == '%')
4819                                         {
4820                                                 *op++ = *ip++;
4821                                                 if (proto->flags & (1L<<31)) proto->flags &= ~(1L<<29);
4822                                                 else proto->flags |= (1L<<31);
4823                                         }
4824                                 }
4825                                 if (proto->flags & (1L<<29))
4826                                         while (op < ep && (n = *op++ = *ip))
4827                                         {
4828                                                 ip++;
4829                                                 if (n == '%')
4830                                                 {
4831                                                         if (*ip == '%' && (ip == proto->ip + 1 || *(ip - 2) == '\n'))
4832                                                         {
4833                                                                 *op++ = *ip++;
4834                                                                 if (proto->flags & (1L<<31)) proto->flags &= ~(1L<<29);
4835                                                                 else proto->flags |= (1L<<31);
4836                                                                 break;
4837                                                         }
4838                                                         if (!*ip)
4839                                                         {
4840                                                                 *op++ = '%';
4841                                                                 proto->flags |= (1L<<30);
4842                                                                 break;
4843                                                         }
4844                                                 }
4845                                                 else if (n == '\n') proto->line++;
4846                                         }
4847                                 proto->op = memcopy(proto->ob, proto->ip, ip - proto->ip);
4848                                 proto->ip = ip;
4849                         }
4850                         else
4851
4852                         lex(proto, proto->flags);
4853                         if ((proto->flags & ((1L<<4)|(1L<<15))) == (1L<<4))
4854                                 proto->op = strcopy(proto->op, "/* NOTE: some constructs may not have been converted */\n");
4855                 }
4856                 n = proto->op - proto->ob;
4857                 proto->op = proto->ob;
4858         }
4859         return(n);
4860 }
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884 #line 69 "/home/gsf/src/cmd/proto/proto.c"
4885
4886
4887
4888
4889 static int
4890 proto __PARAM__((char* file, char* notice, int flags), (file, notice, flags)) __OTORP__(char* file; char* notice; int flags;){
4891         char*           b;
4892         char*           e;
4893         int             n;
4894         int             x;
4895         int             fd;
4896
4897         if (file && access(file, 4)) proto_error(((char*)0), 2, file, "not found");
4898         else if (b = pppopen(file, 0, notice, flags))
4899         {
4900                 if (file)
4901                 {
4902                         e = file + sstrlen( file) - 1;
4903                         x = *e;
4904                         *e = '_';
4905                         if ((fd = (flags & ((1<<13)<<1)) ? creat(file, 0666) : 1) < 0)
4906                         {
4907                                 proto_error(b, 2, "cannot create temporary file", ((char*)0));
4908                                 return(flags);
4909                         }
4910                         *e = x;
4911                 }
4912                 else fd = 1;
4913                 while ((n = pppread(b)) > 0)
4914                         if (write(fd, b, n) != n)
4915                         {
4916                                 proto_error(b, 2, "write error", ((char*)0));
4917                                 flags |= ((1<<13)<<0);
4918                                 break;
4919                         }
4920                 if (file && (flags & ((1<<13)<<1)))
4921                 {
4922                         close(fd);
4923                         *e = '_';
4924                         strcpy(b, file);
4925                         *e = x;
4926                         if (replace(b, file, !(flags & (1<<0))))
4927                                 proto_error(b, 2, "cannot rename to", file);
4928                 }
4929                 pppclose(b);
4930         }
4931         return(flags);
4932 }
4933
4934 int
4935 main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
4936         char*           b;
4937         char*           file;
4938         int             fd;
4939         char*           list = 0;
4940         char*           notice = 0;
4941         int             flags = (1<<3);
4942         char            buf[1024];
4943
4944         ;
4945         while ((file = *++argv) && *file == '-' && *(file + 1))
4946         {
4947                 for (;;)
4948                 {
4949                         switch (*++file)
4950                         {
4951                         case 0:
4952                                 break;
4953                         case 'c':
4954                                 if (!*(notice = ++file) && !(notice = *++argv))
4955                                 {
4956                                         file = "??";
4957                                         continue;
4958                                 }
4959                                 break;
4960                         case 'd':
4961                                 flags |= (1<<1);
4962                                 continue;
4963                         case 'f':
4964                                 flags |= (1<<2);
4965                                 continue;
4966                         case 'h':
4967                                 flags &= ~(1<<3);
4968                                 continue;
4969                         case 'i':
4970                                 flags |= (1<<0);
4971                                 continue;
4972                         case 'l':
4973                                 if (!*(list = ++file) && !(list = *++argv))
4974                                 {
4975                                         file = "??";
4976                                         continue;
4977                                 }
4978                                 break;
4979                         case 'n':
4980                                 flags |= (1<<6);
4981                                 continue;
4982                         case 'p':
4983                                 flags |= (1<<8);
4984                                 continue;
4985                         case 'r':
4986                                 flags |= ((1<<13)<<1);
4987                                 continue;
4988                         case 's':
4989                                 flags |= (1<<4);
4990                                 continue;
4991                         case 't':
4992                                 flags |= (1<<11);
4993                                 continue;
4994                         case 'z':
4995                                 flags |= (1<<1)|(1<<7);
4996                                 continue;
4997                         case '+':
4998                                 flags |= (1<<9);
4999                                 continue;
5000                         default:
5001                                 proto_error(((char*)0), 2, file, "unknown option");
5002  
5003                         case '?':
5004                                 b = "Usage: proto [-dfhinprst+] [-c \"name='value' ...\"] [-l list] file ...\n";
5005                                 write(2, b, sstrlen( b));
5006                                 exit(2);
5007                         }
5008                         break;
5009                 }
5010         }
5011         if (list)
5012         {
5013                 if (*list == '-' && !*(list + 1)) fd = 0;
5014                 else if ((fd = open(list, 0)) < 0) proto_error(((char*)0), 3, list, "not found");
5015                 for (;;)
5016                 {
5017                         b = buf;
5018                         while (read(0, b, 1) == 1 && *b != '\n' && b < &buf[sizeof(buf) - 1]) b++;
5019                         if (b == buf) break;
5020                         *b = 0;
5021                         flags = proto(buf, notice, flags);
5022                 }
5023         }
5024         if (file) do flags = proto(file, notice, flags); while (file = *++argv);
5025         else if (!list) flags = proto(file, notice, flags);
5026         exit(errors ? 1 : (flags & ((1<<13)<<0)) ? 2 : 0);
5027 }