-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdatcom.flex
684 lines (622 loc) · 21.2 KB
/
datcom.flex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
/*
*=============================================================================
* flex based parser for DATCOM input cards.
*
* Copyright (C) 2009 Anders Gidenstam (anders(at)gidenstam.org)
* Copyright (C) 2009 Ronald Jensen (ron(at)jentronics.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*=============================================================================
*/
%{
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "datcom-parser.h"
extern int verbose;
/* Internal global variables. */
static AIRCRAFT* current_aircraft;
static int current_namelist;
#define NL_NONE 0
#define NL_UNKNOWN 1
#define NL_SYNTHS 2
#define NL_BODY 3
#define NL_WGPLNF 4
#define NL_HTPLNF 5
#define NL_VTPLNF 6
#define NL_VFPLNF 7
#define NL_WGSCHR 8
#define NL_HTSCHR 9
#define NL_VTSCHR 10
#define NL_VFSCHR 11
#define NL_PROPWR 12
#define NL_SYMFLP 13
#define NL_ASYFLP 14
#define NL_OPTINS 15
#define NL_MAX 16 /* Keep this entry last! */
static int line_number;
/* For variables and array variables. */
static double* next_double;
static int num_doubles;
static int* next_int;
static int* next_bool;
static const char* NL_NAME[] = {
"",
"",
"$SYNTHS",
"$BODY",
"$WGPLNF",
"$HTPLNF",
"$VTPLNF",
"$VFPLNF",
"$WGSCHR",
"$HTSCHR",
"$VTSCHR",
"$VFSCHR",
"$PROPWR",
"$SYMFLP",
"$ASYFLP",
"$OPTINS",
};
/* Internal functions. */
static void InitializeParser(AIRCRAFT* aircraft);
static void Fail();
static void BeginNameList(char* name);
static void EndNameList();
static void ReadVariable(char* var);
static void ReadNumber(char* str); /* Reads a double or an int */
static void OPTINSReadVariable(char* var);
static void SYNTHSReadVariable(char* var);
static void BODYReadVariable(char* var);
static void PLNFReadVariable(char* var, struct WGPLNF* surface);
static void SCHRReadVariable(char* var, DATCOM_AIRFOIL* airfoil);
static void PROPWRReadVariable(char* var);
static void NACARead(char* str);
/* Added by Bill Galbraith 10-13-10 */
static void ClearLineRead();
static void AppendToLineRead(char* str);
char LineRead[300];
%}
/* This tells flex to read only one input file */
%option noyywrap
/* Parser conditions/"states" */
%s namelist
DIGIT [0-9]
ALPHA [a-zA-Z]
ALPHANUM [A-Za-z0-9]
ID [A-Z][A-Z0-9]*
WS [ \t]
EOL "\n"|"\n\r"|"\r\n"
NEOL [^\n\r]
/* Bill Galbraith 10-12-10
Redefined what a DOUBLE was, to :
digit(s), a decimal point, and digit(s)
digit(s) and a decimal point
a decimal point and digit(s)
and of which may or may not have a leading minus sign and
trailing exponent, which is made up of an optional minus sign
and digit(s)
* IMPORTANT NOTE * The DOUBLE is also defined as ending with a comma.
Old definition
DOUBLE "-"?{DIGIT}*"."{DIGIT}*("E""-"?{DIGIT}+)? */
/* This works, except it doesn't account for not having
the numbers separated by commas. If you fix this, also have BOOLEAN
separated by commas.
*/
DOUBLE ("-"?{DIGIT}+"."{DIGIT}+("E""-"?{DIGIT}+)?|"-"?{DIGIT}+"."("E""-"?{DIGIT}+)?|"-"?"."{DIGIT}+("E""-"?{DIGIT}+)?)
BOOL \.TRUE\.|\.FALSE\.
COMMAND ^(PART|DERIV|DUMP|DAMP|SAVE|NEXT|CASEID|BUILD|PLOT|TRIM)
DIMENSION ^(DIM)
NAMELIST "$"{ID}
VAR {ID}({WS}*"=")
ARRVAR {ID}"(1)"{WS}*"="
NACAAIRFOIL ^"NACA"({WS}|"-"){NEOL}*{LENDCOMMENT}?
LINECOMMENT ^("*"|"#"){NEOL}*
LENDCOMMENT "!"{NEOL}*
/*******************************************************************************
* Rules
*/
%%
<namelist>{DOUBLE} {
if (verbose > 2) fprintf(stderr,"datcom-parser: DOUBLE: %s = %g\n", yytext, atof(yytext));
/* Bill Galbraith 10-13-10 This is a more accurate output */
/* Ron Jensen 10-13-10 The conversion is done with atof() so perhaps both are interesting */
//fprintf(stderr," DOUBLE: %s\n", yytext);
ReadNumber(yytext);
AppendToLineRead(yytext);
}
<namelist>{BOOL} {
if (verbose > 2) fprintf(stderr,"datcom-parser: BOOL: %s\n", yytext);
ReadNumber(yytext);
AppendToLineRead(yytext);
}
<INITIAL>{NAMELIST} {
if (verbose > 2) fprintf(stderr,"datcom-parser:NAMELIST: %s\n", yytext);
BEGIN(namelist);
BeginNameList(yytext);
AppendToLineRead(yytext);
}
<namelist>"$" {
if (verbose > 2) fprintf(stderr,"datcom-parser:END OF NAMELIST\n");
BEGIN(INITIAL);
EndNameList();
AppendToLineRead(yytext);
}
<namelist>{ARRVAR} {
char* e;
AppendToLineRead(yytext);
/* Strip trailing garbage. I hope this is safe.. */
e = strchr(yytext, '(');
if (e != NULL) {
*e = '\0';
}
if (verbose > 2) fprintf(stderr,"datcom-parser: ARRAYVARIABLE: %s\n", yytext);
ReadVariable(yytext);
}
<namelist>{VAR} {
char* s;
char* e;
/* Strip trailing garbage. I hope this is safe.. */
s = strchr(yytext, ' ');
e = strchr(yytext, '=');
e = (e != NULL) ? e : s;
s = (s != NULL) ? s : e;
e = (e < s) ? e : s;
if (e != NULL) {
*e = '\0';
}
AppendToLineRead(yytext);
if (verbose > 2) fprintf(stderr,"datcom-parser: VARIABLE: %s\n", yytext);
ReadVariable(yytext);
}
{NACAAIRFOIL} {
if (verbose > 2) fprintf(stderr,"datcom-parser:AIRFOIL: %s\n", yytext);
NACARead(yytext);
ClearLineRead();
}
{COMMAND}{NEOL}* {
if (verbose > 2) fprintf(stderr,"datcom-parser:Command: %s\n", yytext);
/* Drop uninteresting commands */
ClearLineRead();
}
{DIMENSION}{NEOL}* {
if (verbose) fprintf(stderr,"datcom-parser:Dimension: %s\n", yytext);
/* Drop uninteresting commands */
ClearLineRead();
}
{LINECOMMENT} {
/* Drop comment lines */
ClearLineRead();
}
{LENDCOMMENT} {
/* Drop comment lines */
ClearLineRead();
}
{EOL} {
line_number++;
ClearLineRead();
}
"," {
/* Eat ',' */
AppendToLineRead(yytext);
}
{WS} {
/* Eat up whitespace */
}
. {
Fail();
}
%%
/*******************************************************************************
* Verbatim code section
*/
/* Main entry point. */
void ReadDatcom(char* filename, AIRCRAFT* aircraft)
{
yyin = fopen(filename, "r");
if(!yyin){
fprintf(stderr,"Failed to open input file %s\n", filename);
exit(EXIT_FAILURE);
}
InitializeParser(aircraft);
yylex();
fclose(yyin);
}
static void InitializeParser(AIRCRAFT* aircraft)
{
/* Bill Galbraith 10-12-10
Changed the initial value from 0 to 1, so that the line numbers
output actually matches that in the file. */
line_number = 1;
current_aircraft = aircraft;
current_namelist = NL_NONE;
next_double = NULL;
num_doubles = 0;
next_int = NULL;
memset(current_aircraft, 0, sizeof(AIRCRAFT));
current_aircraft->optins.ROUGFC=-1; // using this as the unset value in modeler.c GetShiny()
}
static void Fail()
{
if (verbose > 0) fprintf(stderr, "datcom-parser: Error: Unrecognized or misplaced character '%s' in line %d\n",
yytext, line_number);
fprintf(stderr, "Errant line up to the error is:\n%s\n", LineRead );
exit(-1);
}
static void BeginNameList(char* name)
{
int i;
if (current_namelist != NL_NONE) {
if (verbose > 0) fprintf(stderr,
"datcom-parser: Unterminated NAMELIST in line %d\n",
line_number);
exit(-1);
}
current_namelist = NL_UNKNOWN;
for (i = 0; i < NL_MAX; i++) {
if (strcmp(name, NL_NAME[i]) == 0) {
current_namelist = i;
}
}
if (current_namelist == NL_UNKNOWN) {
if (verbose > 1) fprintf(stderr,
"datcom-parser: Unknown NAMELIST %s in line %d\n",
name,
line_number);
}
}
static void EndNameList()
{
if (current_namelist == NL_NONE) {
if (verbose > 0) fprintf(stderr,
"datcom-parser: Unbegun NAMELIST terminated in line %d\n",
line_number);
exit(-1);
}
current_namelist = NL_NONE;
}
static void ReadVariable(char* var)
{
if(verbose > 3)
{
switch (current_namelist) {
case NL_NONE:
fprintf(stderr,"datcom-parser: NL_NONE\n");
break;
case NL_UNKNOWN: // This case will print elsewhere
// fprintf(stderr,"datcom-parser: NL_UNKNOWN\n");
break;
default:
if(current_namelist < NL_MAX) fprintf(stderr,"datcom-parser: %s\n", NL_NAME[current_namelist]);
}
}
switch (current_namelist) {
case NL_NONE:
if (verbose > 0) fputs("datcom-parser: Variable outside of NAMELIST", stderr);
exit(-1);
break;
case NL_SYNTHS:
SYNTHSReadVariable(var);
break;
case NL_BODY:
BODYReadVariable(var);
break;
case NL_WGPLNF:
PLNFReadVariable(var, ¤t_aircraft->wing);
break;
case NL_HTPLNF:
PLNFReadVariable(var, ¤t_aircraft->htail);
break;
case NL_VTPLNF:
PLNFReadVariable(var, ¤t_aircraft->vtail);
break;
case NL_VFPLNF:
PLNFReadVariable(var, ¤t_aircraft->vfin);
break;
case NL_WGSCHR:
SCHRReadVariable(var, ¤t_aircraft->wingfoil);
break;
case NL_HTSCHR:
SCHRReadVariable(var, ¤t_aircraft->htailfoil);
break;
case NL_VTSCHR:
SCHRReadVariable(var, ¤t_aircraft->vtailfoil);
break;
case NL_VFSCHR:
SCHRReadVariable(var, ¤t_aircraft->vfinfoil);
break;
case NL_PROPWR:
PROPWRReadVariable(var);
break;
case NL_SYMFLP:
// FIXME: Do Something!
break;
case NL_ASYFLP:
// FIXME: Do Something!
break;
case NL_OPTINS:
OPTINSReadVariable(var);
break;
default:
break;
}
}
static void ReadNumber(char* str)
{
if (num_doubles-- && next_double != NULL) {
*next_double = atof(yytext); /* Add error detection here! */
next_double = (num_doubles > 0) ? next_double + 1 : NULL;
} else if (next_int) {
*next_int = (int)atof(yytext); /* Add error detection here! */
next_int = NULL;
} else if (next_bool) {
if (strcmp(yytext, ".TRUE.") == 0) {
*next_bool = 1;
} else {
*next_bool = 0;
}
next_bool=NULL;
}
}
static void PROPWRReadVariable(char* var)
{
num_doubles = 1;
if (strcmp(var, "AIETLP") == 0) {
next_double = ¤t_aircraft->propwr.AIETLP;
} else if (strcmp(var, "NENGSP") == 0) {
next_double = ¤t_aircraft->propwr.NENGSP;
} else if (strcmp(var, "THSTCP") == 0) {
next_double = ¤t_aircraft->propwr.THSTCP;
} else if (strcmp(var, "PHALOC") == 0) {
next_double = ¤t_aircraft->propwr.PHALOC;
} else if (strcmp(var, "PHVLOC") == 0) {
next_double = ¤t_aircraft->propwr.PHVLOC;
} else if (strcmp(var, "PRPRAD") == 0) {
next_double = ¤t_aircraft->propwr.PRPRAD;
} else if (strcmp(var, "BWAPR3") == 0) {
next_double = ¤t_aircraft->propwr.BWAPR3;
} else if (strcmp(var, "BWAPR6") == 0) {
next_double = ¤t_aircraft->propwr.BWAPR6;
} else if (strcmp(var, "BWAPR9") == 0) {
next_double = ¤t_aircraft->propwr.BWAPR9;
} else if (strcmp(var, "NOPBPE") == 0) {
next_double = ¤t_aircraft->propwr.NOPBPE;
} else if (strcmp(var, "BAPR75") == 0) {
next_double = ¤t_aircraft->propwr.BAPR75;
} else if (strcmp(var, "YP") == 0) {
next_double = ¤t_aircraft->propwr.YP;
} else if (strcmp(var, "CROT") == 0) {
num_doubles = 0;
next_int = ¤t_aircraft->propwr.CROT;
} else {
if (verbose > 1) fprintf(stderr,
"datcom-parser: Unknown variable %s in PROPWR NAMELIST close to line %d\n",
var, line_number);
}
}
static void OPTINSReadVariable(char* var)
{
num_doubles = 1;
if (strcmp(var, "ROUGFC") == 0) {
next_double = ¤t_aircraft->optins.ROUGFC;
} else if (strcmp(var, "SREF") == 0) {
next_double = ¤t_aircraft->optins.SREF;
} else if (strcmp(var, "CBARR") == 0) {
next_double = ¤t_aircraft->optins.CBARR;
} else if (strcmp(var, "BLREF") == 0) {
next_double = ¤t_aircraft->optins.BLREF;
} else {
if (verbose > 1) fprintf(stderr,
"datcom-parser: Unknown variable %s in OPTIN NAMELIST close to line %d\n",
var, line_number);
}
}
static void SYNTHSReadVariable(char* var)
{
/*printf("SYNTHS: %s\n", var);*/
num_doubles = 1;
if (strcmp(var, "XCG") == 0) {
next_double = ¤t_aircraft->synths.XCG;
} else if (strcmp(var, "ZCG") == 0) {
next_double = ¤t_aircraft->synths.ZCG;
} else if (strcmp(var, "XW") == 0) {
next_double = ¤t_aircraft->synths.XW;
} else if (strcmp(var, "ZW") == 0) {
next_double = ¤t_aircraft->synths.ZW;
} else if (strcmp(var, "ALIW") == 0) {
next_double = ¤t_aircraft->synths.ALIW;
} else if (strcmp(var, "XH") == 0) {
next_double = ¤t_aircraft->synths.XH;
} else if (strcmp(var, "ZH") == 0) {
next_double = ¤t_aircraft->synths.ZH;
} else if (strcmp(var, "ALIH") == 0) {
next_double = ¤t_aircraft->synths.ALIH;
} else if (strcmp(var, "XV") == 0) {
next_double = ¤t_aircraft->synths.XV;
} else if (strcmp(var, "ZV") == 0) {
next_double = ¤t_aircraft->synths.ZV;
} else if (strcmp(var, "XVF") == 0) {
next_double = ¤t_aircraft->synths.XVF;
} else if (strcmp(var, "ZVF") == 0) {
next_double = ¤t_aircraft->synths.ZVF;
} else if (strcmp(var, "SCALE") == 0) {
next_double = ¤t_aircraft->synths.SCALE;
} else if (strcmp(var, "HINAX") == 0) {
next_double = ¤t_aircraft->synths.HINAX;
} else if (strcmp(var, "VERTUP") == 0) {
num_doubles = 0;
next_int = NULL;
next_bool = ¤t_aircraft->synths.VERTUP;
} else {
if (verbose > 1) fprintf(stderr,
"datcom-parser: Unknown variable %s in SYNTHS NAMELIST in line %d\n",
var, line_number);
}
}
static void BODYReadVariable(char* var)
{
if (strcmp(var, "NX") == 0) {
next_int = ¤t_aircraft->body.NX;
} else if (strcmp(var, "X") == 0) {
num_doubles = current_aircraft->body.NX;
next_double = ¤t_aircraft->body.X[0];
} else if (strcmp(var, "S") == 0) {
num_doubles = current_aircraft->body.NX;
next_double = ¤t_aircraft->body.S[0];
} else if (strcmp(var, "P") == 0) {
num_doubles = current_aircraft->body.NX;
next_double = ¤t_aircraft->body.P[0];
} else if (strcmp(var, "R") == 0) {
num_doubles = current_aircraft->body.NX;
next_double = ¤t_aircraft->body.R[0];
} else if (strcmp(var, "ZU") == 0) {
num_doubles = current_aircraft->body.NX;
next_double = ¤t_aircraft->body.ZU[0];
} else if (strcmp(var, "ZL") == 0) {
num_doubles = current_aircraft->body.NX;
next_double = ¤t_aircraft->body.ZL[0];
} else if (strcmp(var, "BNOSE") == 0) {
num_doubles = 1;
next_double = ¤t_aircraft->body.BNOSE;
} else if (strcmp(var, "BTAIL") == 0) {
num_doubles = 1;
next_double = ¤t_aircraft->body.BTAIL;
} else if (strcmp(var, "BLN") == 0) {
num_doubles = 1;
next_double = ¤t_aircraft->body.BLN;
} else if (strcmp(var, "BLA") == 0) {
num_doubles = 1;
next_double = ¤t_aircraft->body.BLA;
} else if (strcmp(var, "DS") == 0) {
num_doubles = 1;
next_double = ¤t_aircraft->body.DS;
} else if (strcmp(var, "ITYPE") == 0) {
num_doubles = 0;
next_int = ¤t_aircraft->body.ITYPE;
} else if (strcmp(var, "METHOD") == 0) {
num_doubles = 0;
next_int = ¤t_aircraft->body.METHOD;
} else {
if (verbose > 1) fprintf(stderr,
"datcom-parser: Unknown variable %s in BODY NAMELIST in line %d\n",
var, line_number);
}
}
static void PLNFReadVariable(char* var, struct WGPLNF* surface)
{
num_doubles = 1;
if (strcmp(var, "CHRDR") == 0) {
next_double = &surface->CHRDR;
} else if (strcmp(var, "CHRDBP") == 0) {
next_double = &surface->CHRDBP;
} else if (strcmp(var, "CHRDTP") == 0) {
next_double = &surface->CHRDTP;
} else if (strcmp(var, "SSPN") == 0) {
next_double = &surface->SSPN;
} else if (strcmp(var, "SSPNE") == 0) {
next_double = &surface->SSPNE;
} else if (strcmp(var, "SSPNOP") == 0) {
next_double = &surface->SSPNOP;
} else if (strcmp(var, "SAVSI") == 0) {
next_double = &surface->SAVSI;
} else if (strcmp(var, "SAVSO") == 0) {
next_double = &surface->SAVSO;
} else if (strcmp(var, "CHSTAT") == 0) {
next_double = &surface->CHSTAT;
} else if (strcmp(var, "TWISTA") == 0) {
next_double = &surface->TWISTA;
} else if (strcmp(var, "SSPNDD") == 0) {
next_double = &surface->SSPNDD;
} else if (strcmp(var, "DHDADI") == 0) {
next_double = &surface->DHDADI;
} else if (strcmp(var, "DHDADO") == 0) {
next_double = &surface->DHDADO;
} else if (strcmp(var, "TYPE") == 0) {
num_doubles = 0;
next_int = &surface->TYPE;
} else {
if (verbose > 1) fprintf(stderr,
"datcom-parser: Unknown variable %s in PLNF NAMELIST around line %d\n",
var, line_number);
}
}
static void SCHRReadVariable(char* var, DATCOM_AIRFOIL *airfoil)
{
if (strcmp(var, "TYPEIN") == 0) {
next_int = &airfoil->TYPEIN;
} else if (strcmp(var, "NPTS") == 0) {
next_int = &airfoil->NPTS;
} else if (strcmp(var, "XCORD") == 0) {
num_doubles = airfoil->NPTS;
airfoil->XCORD = calloc(num_doubles, sizeof(double));
next_double = &airfoil->XCORD[0];
} else if (strcmp(var, "YUPPER") == 0) {
num_doubles = airfoil->NPTS;
airfoil->YUPPER = calloc(num_doubles, sizeof(double));
next_double = &airfoil->YUPPER[0];
} else if (strcmp(var, "YLOWER") == 0) {
num_doubles = airfoil->NPTS;
airfoil->YLOWER = calloc(num_doubles, sizeof(double));
next_double = &airfoil->YLOWER[0];
} else {
if (verbose > 1) fprintf(stderr,
"datcom-parser: Unknown variable %s in SCHR NAMELIST in line %d\n",
var, line_number);
}
}
static void NACARead(char* str)
{
ClearLineRead();
switch (str[5]) {
case 'W':
current_aircraft->wingfoil.NACA_DESCR =
(char *)malloc(strlen(str) + 1);
strcpy(current_aircraft->wingfoil.NACA_DESCR, str);
break;
case 'H':
current_aircraft->htailfoil.NACA_DESCR =
(char *)malloc(strlen(str) + 1);
strcpy(current_aircraft->htailfoil.NACA_DESCR, str);
break;
case 'V':
current_aircraft->vtailfoil.NACA_DESCR =
(char *)malloc(strlen(str) + 1);
strcpy(current_aircraft->vtailfoil.NACA_DESCR, str);
break;
case 'F':
current_aircraft->vfinfoil.NACA_DESCR =
(char *)malloc(strlen(str) + 1);
strcpy(current_aircraft->vfinfoil.NACA_DESCR, str);
break;
default:
if (verbose > 1) fprintf(stderr, "datcom-parser: Unknow surface in NACA airfoil %s in line %d\n",
str, line_number);
break;
}
}
static void ClearLineRead()
{
strcpy( LineRead,"" );
}
static void AppendToLineRead(char* str)
{
strcat( LineRead, str );
if ( strlen(LineRead) > 80 )
{
fprintf(stderr,"datcom-parser: Line is too long at line %d. Keep it under 80 characters\n%s\n",
line_number, LineRead );
// exit(-1);
}
}