~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmidi/cfg.l

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%{
 
2
/*
 
3
 * Cfg file reader, Greg Lee, 8/93.
 
4
 * Adapted from Adagio for KMidi 12/99.
 
5
 *      $Id: cfg.l,v 1.8 2000/08/08 17:32:37 faure Exp $
 
6
 */
 
7
#include <ctype.h>
 
8
#include <stdlib.h>
 
9
#include <unistd.h>
 
10
#include <string.h>
 
11
#include "config.h"
 
12
#include "common.h"
 
13
#include "instrum.h"
 
14
#include "playmidi.h"
 
15
#include "readmidi.h"
 
16
#include "output.h"
 
17
#include "controls.h"
 
18
#include "tables.h"
 
19
#include "version.h"
 
20
 
 
21
#define YY_ALWAYS_INTERACTIVE 0
 
22
#define YY_NEVER_INTERACTIVE 1
 
23
 
 
24
#define YY_INPUT(buf,result,max_size) \
 
25
         result = fread( buf, 1, max_size, yyin );
 
26
 
 
27
extern int set_play_mode(char *cp);
 
28
static int prescanning;
 
29
static char doing_drums = 0;
 
30
static char doing_sf = 0;
 
31
static int patchno = -1;
 
32
static int i, j;
 
33
static char *patchname;
 
34
static char cfg_flag = 1;
 
35
static int tone_bank;
 
36
static void set_patchno(char *m);
 
37
 
 
38
static char *s_dirname = 0;
 
39
static char *sfname = 0;
 
40
 
 
41
static int current_toneset = 0;
 
42
static int current_drumset = 0;
 
43
 
 
44
static int cfg_condition = -1;
 
45
 
 
46
static ToneBank *bank=0;
 
47
static int banknum=0;
 
48
static int rcf_count=1;
 
49
static int font_type=FONT_NORMAL;
 
50
 
 
51
 
 
52
#define MAX_INCLUDE_DEPTH 40
 
53
static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
 
54
static int include_stack_ptr = 0;
 
55
 
 
56
static void new_toneset(int n);
 
57
static void new_patch(const char *vname, int num);
 
58
 
 
59
%}
 
60
 
 
61
%option noyywrap
 
62
%option nounput
 
63
 
 
64
%s P K S
 
65
 
 
66
wh      [ \t]+
 
67
owh     [ \t]*
 
68
nm      ([^ \t\n\r\"#]+|\"[^\"\n]+\")
 
69
cm      [ \t]*("#".*)?\n
 
70
 
 
71
%%
 
72
 
 
73
{owh}"#".*      ;
 
74
^#.*\n  ;
 
75
 
 
76
^{owh}"if"{wh}[0-9]+ {
 
77
        int i = 0;
 
78
        while (isspace(yytext[i])) i++;
 
79
        i += 2;
 
80
        cfg_condition = atoi(yytext+i);
 
81
}
 
82
^{owh}"else" {
 
83
        cfg_condition = 0;
 
84
}
 
85
^{owh}("sf"|"sbk"){wh}{nm}{owh}[0-9]* {
 
86
        int sf_oldbank, sf_newbank = banknum;
 
87
        int i = 0, j;
 
88
        while (isspace(yytext[i])) i++;
 
89
        if (yytext[i+1] == 'f') i += 2;
 
90
        else i += 3;
 
91
        while (isspace(yytext[i])) i++;
 
92
        if (yytext[i] == '"') {
 
93
                i++;
 
94
                for (j = i; j < yyleng && yytext[j] != '"'; j++) ;
 
95
                j--;
 
96
        }
 
97
        else for (j = i; j < yyleng && !isspace(yytext[j]); j++) ;
 
98
        sfname = strncpy( (char *)malloc(j-i+1), yytext+i, j-i );
 
99
        sfname[j-i] = '\0';
 
100
        if (doing_drums) sf_newbank += 256;
 
101
        sf_oldbank = sf_newbank;
 
102
        if (j < yyleng) {
 
103
                while (j < yyleng && isspace(yytext[j])) j++;
 
104
                if (j < yyleng && isdigit(yytext[j])) sf_oldbank = atoi(yytext+j);
 
105
        }
 
106
        init_soundfont(sfname, sf_oldbank, sf_newbank, rcf_count);
 
107
}
 
108
^{owh}("dir"|"PatchDir:"){wh}{nm} {
 
109
        int i = 0;
 
110
        while (isspace(yytext[i])) i++;
 
111
        if (yytext[i] == 'd') i += 3;
 
112
        else i += 9;
 
113
        while (isspace(yytext[i])) i++;
 
114
        s_dirname = strcpy( (char *)malloc(strlen(yytext+i)+1), yytext+i );
 
115
        add_to_pathlist(s_dirname, rcf_count);
 
116
        free(s_dirname);
 
117
}
 
118
^{owh}"source"{wh}{nm} {
 
119
        char *fname;
 
120
        int i = 0;
 
121
        FILE *save_yyin;
 
122
 
 
123
        while (isspace(yytext[i])) i++;
 
124
        i += 6;
 
125
        while (isspace(yytext[i])) i++;
 
126
 
 
127
         if (prescanning && cfg_condition >= 0 && cfg_condition < 30 &&
 
128
                rcf_count==1 && !cfg_names[cfg_condition])
 
129
          {
 
130
            cfg_names[cfg_condition] = (char *)safe_malloc(strlen(yytext+i)+1);
 
131
            strcpy(cfg_names[cfg_condition], yytext+i);
 
132
          }
 
133
 
 
134
    if (!prescanning && (cfg_condition < 0 || cfg_condition == cfg_select)) {
 
135
 
 
136
 
 
137
        if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) {
 
138
                ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
 
139
                 "Probable source loop in configuration files");
 
140
                return (-1);
 
141
        }
 
142
        include_stack[include_stack_ptr++] =
 
143
                YY_CURRENT_BUFFER;
 
144
 
 
145
        fname = strcpy( (char *)malloc(strlen(yytext+i)+1), yytext+i );
 
146
 
 
147
        save_yyin = yyin;
 
148
        yyin = NULL;
 
149
 
 
150
        yyin = open_file(fname, 1, OF_VERBOSE, rcf_count);
 
151
 
 
152
        if (yyin == NULL) {
 
153
                ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
 
154
                 "Source file %s not found\n", fname);
 
155
                include_stack_ptr--;
 
156
        }
 
157
 
 
158
        if (yyin == NULL) yyin = save_yyin;
 
159
        else {
 
160
            cfg_condition = -1;
 
161
            rcf_count++;
 
162
            yy_switch_to_buffer(
 
163
                yy_create_buffer( yyin, YY_BUF_SIZE ) );
 
164
        }
 
165
    }
 
166
    cfg_condition = -1;
 
167
}  
 
168
 
 
169
<<EOF>> {
 
170
        if ( --include_stack_ptr < 0 ) {
 
171
                yyterminate();
 
172
        }
 
173
        else {
 
174
                if (yyin) close_file(yyin);
 
175
                yy_delete_buffer( YY_CURRENT_BUFFER );
 
176
                rcf_count--;
 
177
                yy_switch_to_buffer(
 
178
                     include_stack[include_stack_ptr] );
 
179
        }
 
180
}
 
181
 
 
182
^{owh}"drumset"{wh}[0-9]+{wh}("sf"|"sbk"){wh}{nm}       {
 
183
        char *bank_name = NULL;
 
184
        int i = 0;
 
185
        while (isspace(yytext[i])) i++;
 
186
        i += 7;
 
187
        current_drumset = atoi(yytext+i);
 
188
        doing_drums = 1;
 
189
        doing_sf = 1;
 
190
        new_toneset(current_drumset);
 
191
        font_type=FONT_SBK;
 
192
    if (!bank->name) {
 
193
        while (isspace(yytext[i])) i++;
 
194
        while (isdigit(yytext[i])) i++;
 
195
        while (isspace(yytext[i])) i++;
 
196
        if (yytext[i+1] == 'f') i += 2; else i += 3;
 
197
        while (isspace(yytext[i])) i++;
 
198
        patchname = yytext + i;
 
199
        if (patchname[0] == '"') {
 
200
                bank_name = strncpy( (char *)malloc(strlen(patchname)-1), patchname + 1, strlen(patchname)-1 );
 
201
                bank_name[strlen(patchname)-2] = '\0';
 
202
        }
 
203
        else bank_name = strcpy( (char *)malloc(strlen(patchname)+1), patchname );
 
204
        bank->name = bank_name;
 
205
    }
 
206
 
 
207
}
 
208
^{owh}"drumset"{wh}[0-9]+{wh}("sf"|"sbk")       {
 
209
        int i = 0;
 
210
        while (isspace(yytext[i])) i++;
 
211
        i += 7;
 
212
        current_drumset = atoi(yytext+i);
 
213
        doing_drums = 1;
 
214
        doing_sf = 1;
 
215
        new_toneset(current_drumset);
 
216
        font_type=FONT_SBK;
 
217
}
 
218
^{owh}"drumset"{wh}[0-9]+{wh}{nm}       {
 
219
        char *bank_name = NULL;
 
220
        int i = 0;
 
221
        while (isspace(yytext[i])) i++;
 
222
        i += 7;
 
223
        current_drumset = atoi(yytext+i);
 
224
        doing_drums = 1;
 
225
        doing_sf = 0;
 
226
        new_toneset(current_drumset);
 
227
        font_type=FONT_NORMAL;
 
228
    if (!bank->name) {
 
229
        while (isspace(yytext[i])) i++;
 
230
        while (isdigit(yytext[i])) i++;
 
231
        while (isspace(yytext[i])) i++;
 
232
        patchname = yytext + i;
 
233
        if (patchname[0] == '"') {
 
234
                bank_name = strncpy( (char *)malloc(strlen(patchname)-1), patchname + 1, strlen(patchname)-1 );
 
235
                bank_name[strlen(patchname)-2] = '\0';
 
236
        }
 
237
        else bank_name = strcpy( (char *)malloc(strlen(patchname)+1), patchname );
 
238
        bank->name = bank_name;
 
239
    }
 
240
}
 
241
^{owh}"drumset"{wh}[0-9]+       {
 
242
        int i = 0;
 
243
        while (isspace(yytext[i])) i++;
 
244
        i += 7;
 
245
        current_drumset = atoi(yytext+i);
 
246
        doing_drums = 1;
 
247
        doing_sf = 0;
 
248
        new_toneset(current_drumset);
 
249
        font_type=FONT_NORMAL;
 
250
}
 
251
^{owh}"bank"{wh}[0-9]+{wh}("sf"|"sbk")  {
 
252
        int i = 0;
 
253
        while (isspace(yytext[i])) i++;
 
254
        i += 4;
 
255
        current_toneset = atoi(yytext+i);
 
256
        doing_drums = 0;
 
257
        doing_sf = 1;
 
258
        new_toneset(current_toneset);
 
259
        font_type=FONT_SBK;
 
260
}
 
261
^{owh}"bank"{wh}[0-9]+  {
 
262
        int i = 0;
 
263
        while (isspace(yytext[i])) i++;
 
264
        i += 4;
 
265
        current_toneset = atoi(yytext+i);
 
266
        doing_drums = 0;
 
267
        doing_sf = 0;
 
268
        new_toneset(current_toneset);
 
269
        font_type=FONT_NORMAL;
 
270
}
 
271
^{owh}"sfx"     {
 
272
        current_toneset = SFXBANK;
 
273
        doing_drums = 0;
 
274
        doing_sf = 0;
 
275
        new_toneset(current_toneset);
 
276
        font_type=FONT_NORMAL;
 
277
}
 
278
^{owh}"drumsfx1"        {
 
279
        current_drumset = SFXDRUM1;
 
280
        doing_drums = 1;
 
281
        doing_sf = 0;
 
282
        new_toneset(current_toneset);
 
283
        font_type=FONT_NORMAL;
 
284
        bank->name = "drumsfx1";
 
285
}
 
286
^{owh}"drumsfx2"        {
 
287
        current_drumset = SFXDRUM2;
 
288
        doing_drums = 1;
 
289
        doing_sf = 0;
 
290
        new_toneset(current_toneset);
 
291
        font_type=FONT_NORMAL;
 
292
        bank->name = "drumsfx2";
 
293
}
 
294
 
 
295
^{owh}"[Melodic Patches]" {
 
296
        doing_drums = 0;
 
297
}
 
298
^{owh}"[Drum Patches]" {
 
299
        doing_drums = 1;
 
300
        current_drumset = current_toneset;
 
301
}
 
302
 
 
303
^{owh}[0-9,]+("="|{wh}){nm} {
 
304
        const char *gm_name = NULL;
 
305
        char *vc_name = NULL;
 
306
        patchno = atoi(yytext);
 
307
        tone_bank = 0;
 
308
        if (patchno >= 0) {
 
309
                i = 0;
 
310
                while (isspace(yytext[i])) i++;
 
311
                while (isdigit(yytext[i])) i++;
 
312
                if (yytext[i] == ',') {
 
313
                        i++;
 
314
                        tone_bank = atoi(yytext + i);
 
315
                        while (isdigit(yytext[i])) i++;
 
316
                }
 
317
                else {
 
318
                        if (doing_drums) tone_bank = current_drumset;
 
319
                        else tone_bank = current_toneset;
 
320
                }
 
321
                new_toneset(tone_bank);
 
322
 
 
323
                while (isspace(yytext[i])) i++;
 
324
                if (!cfg_flag && yytext[i] == '=') i++;
 
325
                if ( (patchname = strrchr(yytext + i, '\\')) == NULL)
 
326
                        patchname = yytext + i;
 
327
                else patchname++;
 
328
                if (patchname[0] == '"') {
 
329
                        vc_name = strncpy( (char *)malloc(strlen(patchname)-1), patchname + 1, strlen(patchname)-1 );
 
330
                        vc_name[strlen(patchname)-2] = '\0';
 
331
                }
 
332
                else vc_name = strcpy( (char *)malloc(strlen(patchname)+1), patchname );
 
333
                if (patchno < 128) gm_name = gm_voice[doing_drums? patchno+128 : patchno].vname;
 
334
                else {
 
335
                    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Bad patch number %d in cfg file.", patchno);
 
336
                }
 
337
                if (gm_name == NULL) gm_name = (doing_drums)? "drum":"instr";
 
338
 
 
339
                ctl->cmsg(CMSG_INFO, VERB_DEBUG, "config: voice %s[%d,%d] = patch %s",
 
340
                        gm_name, patchno, tone_bank, vc_name);
 
341
 
 
342
                new_patch(vc_name, patchno);
 
343
 
 
344
        }
 
345
        BEGIN(P);
 
346
}
 
347
 
 
348
^{owh}[A-Z][^\n\r\t\=,#]+(","{owh}[0-9]+)?{owh}"="{owh}{nm} {
 
349
        const char *gm_name = NULL;
 
350
        char *vc_name = NULL;
 
351
        int i;
 
352
        set_patchno(yytext);
 
353
        tone_bank = 0;
 
354
        if (patchno < 256) {
 
355
                i = 0;
 
356
                while (yytext[i] != '=' && yytext[i] != ',') i++;
 
357
                if (yytext[i] == ',') {
 
358
                        i++;
 
359
                        tone_bank = atoi(yytext + i);
 
360
                }
 
361
                else {
 
362
                        if (doing_drums) tone_bank = current_drumset;
 
363
                        else tone_bank = current_toneset;
 
364
                }
 
365
 
 
366
                while (yytext[i] != '=') i++;
 
367
                i++;
 
368
                while (isspace(yytext[i])) i++;
 
369
                if ( (patchname = strrchr(yytext + i, '\\')) == NULL)
 
370
                        patchname = yytext + i;
 
371
                else patchname++;
 
372
                if (patchname[0] == '"') {
 
373
                        vc_name = strncpy( (char *)malloc(strlen(patchname)-1), patchname + 1, strlen(patchname)-1 );
 
374
                        vc_name[strlen(patchname)-2] = '\0';
 
375
                }
 
376
                else vc_name = strcpy( (char *)malloc(strlen(patchname)+1), patchname );
 
377
                gm_name = gm_voice[patchno].vname;
 
378
                if (gm_name == NULL) gm_name = (doing_drums)? "drum":"instr";
 
379
 
 
380
                ctl->cmsg(CMSG_INFO, VERB_DEBUG, "config: voice %s[%d,%d] = patch %s",
 
381
                        gm_name, patchno, tone_bank, vc_name);
 
382
 
 
383
        }
 
384
        else {
 
385
                ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Bad line \"%s ...\" in cfg file.", yytext);
 
386
        }
 
387
        new_patch(vc_name, patchno);
 
388
        
 
389
        BEGIN(P);
 
390
}
 
391
 
 
392
^{owh}"-p"{owh}[0-9]+   { if (prescanning) {
 
393
                i=0; while(isspace(yytext[i])) i++;
 
394
                j = atoi(yytext+i+2);
 
395
                if (j > 1 && j < MAX_VOICES) voices = j;
 
396
        } }
 
397
^{owh}"-A"{wh}[0-9]+    { if (prescanning) {
 
398
                i=0; while(isspace(yytext[i])) i++;
 
399
                j = atoi(yytext+i+2);
 
400
                if (j > 1 && j < MAX_AMPLIFICATION) amplification = j;
 
401
        } }
 
402
^{owh}"-C"{owh}[0-9]+   { if (prescanning) {
 
403
                i=0; while(isspace(yytext[i])) i++;
 
404
                j = atoi(yytext+i+2);
 
405
                if (j > 1 && j < MAX_CONTROL_RATIO) control_ratio = j;
 
406
        } }
 
407
^{owh}"-s"{owh}[0-9]+   { if (prescanning) {
 
408
                i=0; while(isspace(yytext[i])) i++;
 
409
                j = atoi(yytext+i+2);
 
410
                if (j < 100) j *= 1000;
 
411
                if (j > MIN_OUTPUT_RATE && j < MAX_OUTPUT_RATE) play_mode->rate = j;
 
412
        } }
 
413
^{owh}"-r"{owh}[0-9]+   { if (prescanning) {
 
414
                i=0; while(isspace(yytext[i])) i++;
 
415
                j = atoi(yytext+i+2);
 
416
                max_patch_memory = j * 1000000;
 
417
        } }
 
418
^{owh}"-k"{owh}[0-9]+   { if (prescanning) {
 
419
                i=0; while(isspace(yytext[i])) i++;
 
420
                j = atoi(yytext+i+2);
 
421
                if (j >= 0 && j <= 3) current_interpolation = j;
 
422
        } }
 
423
^{owh}"-X"{owh}[0-9]+   { if (prescanning) {
 
424
                i=0; while(isspace(yytext[i])) i++;
 
425
                j = atoi(yytext+i+2);
 
426
                if (j >= 0 && j <= 2) opt_expression_curve = j;
 
427
        } }
 
428
^{owh}"-V"{owh}[0-9]+   { if (prescanning) {
 
429
                i=0; while(isspace(yytext[i])) i++;
 
430
                j = atoi(yytext+i+2);
 
431
                if (j >= 0 && j <= 2) opt_volume_curve = j;
 
432
        } }
 
433
^{owh}"-O"{owh}[a-zA-Z] { if (prescanning) {
 
434
                i=0; while(isspace(yytext[i])) i++;
 
435
                i+=2;
 
436
                while(isspace(yytext[i])) i++;
 
437
                if (set_play_mode(yytext+i)) /* error */;
 
438
        } }
 
439
 
 
440
<P>{owh}"amp"{owh}"="{owh}[0-9]+        {
 
441
        int i = 0;
 
442
        while (yytext[i] != '=') i++;
 
443
        bank->tone[patchno].amp = atoi(yytext+i+1);
 
444
        BEGIN(P);
 
445
}
 
446
<P>{owh}"note"{owh}"="{owh}[0-9]+       {
 
447
        int i = 0;
 
448
        while (yytext[i] != '=') i++;
 
449
        bank->tone[patchno].note = atoi(yytext+i+1);
 
450
        BEGIN(P);
 
451
}
 
452
<P>{owh}"tuning"{owh}"="{owh}("+"|"-")[0-9]+    {
 
453
        int i = 0;
 
454
        while (yytext[i] != '=') i++;
 
455
        bank->tone[patchno].tuning = atoi(yytext+i+1);
 
456
        BEGIN(P);
 
457
}
 
458
<P>{owh}"keep"{owh}"="  BEGIN(K);
 
459
<P>{owh}"strip"{owh}"=" BEGIN(S);
 
460
 
 
461
<K>{owh}"loop"  {
 
462
                  bank->tone[patchno].strip_loop=0;
 
463
        BEGIN(P);
 
464
}
 
465
<K>{owh}"tail"  {
 
466
                  bank->tone[patchno].strip_tail=0;
 
467
        BEGIN(P);
 
468
}
 
469
<K>{owh}"env"   {
 
470
                  bank->tone[patchno].strip_envelope=0;
 
471
        BEGIN(P);
 
472
}
 
473
<S>{owh}"loop"  {
 
474
                  bank->tone[patchno].strip_loop=1;
 
475
        BEGIN(P);
 
476
}
 
477
<S>{owh}"tail"  {
 
478
                  bank->tone[patchno].strip_tail=1;
 
479
        BEGIN(P);
 
480
}
 
481
<S>{owh}"env"   {
 
482
                  bank->tone[patchno].strip_envelope=1;
 
483
        BEGIN(P);
 
484
}
 
485
^{owh}[A-Z][^\n\r\t\:#]+{owh}":"{owh}"poly"  {
 
486
        set_patchno(yytext);
 
487
        if (patchno < 256) gm_voice[patchno].flags &= ~SOLO_MASK;
 
488
}
 
489
^{owh}[A-Z][^\n\r\t\:#]+{owh}":"{owh}"solo"  {
 
490
        set_patchno(yytext);
 
491
        if (patchno < 256) gm_voice[patchno].flags |= SOLO_MASK;
 
492
}
 
493
 
 
494
. |
 
495
\n      {
 
496
        patchno = -1;
 
497
        BEGIN(0);
 
498
}
 
499
%%
 
500
 
 
501
static void new_toneset(int n)
 
502
{
 
503
        banknum=n;
 
504
 
 
505
        if (!doing_drums) {
 
506
          if (!tonebank[n]) {
 
507
                tonebank[n]=(ToneBank *)safe_malloc(sizeof(ToneBank));
 
508
                memset(tonebank[n], 0, sizeof(ToneBank));
 
509
          }
 
510
          bank=tonebank[n];
 
511
        }
 
512
        else {
 
513
          if (!drumset[n]) {
 
514
                drumset[n]=(ToneBank *)safe_malloc(sizeof(ToneBank));
 
515
                memset(drumset[n], 0, sizeof(ToneBank));
 
516
          }
 
517
          bank=drumset[n];
 
518
        }
 
519
}
 
520
 
 
521
static void new_patch(const char *vname, int num)
 
522
{
 
523
        if (bank->tone[num].name) return;
 
524
        bank->tone[num].name=vname;
 
525
        bank->tone[num].note=bank->tone[num].amp=bank->tone[num].pan=
 
526
          bank->tone[num].strip_loop=bank->tone[num].strip_envelope=
 
527
            bank->tone[num].sf_ix=
 
528
            bank->tone[num].strip_tail=bank->tone[num].last_used=-1;
 
529
        bank->tone[num].font_type=font_type;
 
530
        bank->tone[num].tuning=0;
 
531
        bank->tone[num].layer=0;
 
532
}
 
533
 
 
534
static void set_patchno(char *m)
 
535
{
 
536
        int i,j,w,y;
 
537
        const char *vn;
 
538
        y = w = 0;
 
539
        while (isspace(m[w])) w++;
 
540
        for (i = 0; i < 256; i++) {
 
541
                vn = gm_voice[i].vname;
 
542
                if (vn == NULL) continue;
 
543
                for (j = 0; m[j+w] && vn[j+y] && m[j+w] == vn[j+y]; j++)
 
544
                    if (vn[j+y+1] && isspace(vn[j+y+1]) && m[j+w+1] && !isspace(m[j+w+1]) ) y++ ;
 
545
                if (!m[j+w] || m[j+w] == '=' || m[j+w] == ',' || m[j+w] == ':') break;
 
546
                if (!vn[j+y] && isspace(m[j+w])) break;
 
547
        }
 
548
        if (i < 256 && vn != NULL) patchno = i;
 
549
        else patchno = 256;
 
550
}
 
551
 
 
552
 
 
553
char *current_config_file = 0;
 
554
 
 
555
int read_config_file(const char *name, int prescan)
 
556
{
 
557
        int retvalue;
 
558
        prescanning = prescan;
 
559
        include_stack_ptr = 0;
 
560
        rcf_count = 1;
 
561
 
 
562
        if (prescanning) {
 
563
           current_config_file = (char *)safe_malloc(strlen(name)+1);
 
564
           strcpy(current_config_file, name);
 
565
        }
 
566
 
 
567
        yyin = open_file(name, 1, OF_VERBOSE, rcf_count);
 
568
        if (!yyin) return -1;
 
569
 
 
570
        current_toneset = current_drumset = 0;
 
571
        doing_drums = doing_sf = 0;
 
572
        if (!(retvalue = yylex())) {
 
573
           if (prescan) got_a_configuration = 1;
 
574
           else got_a_configuration = 2;
 
575
        }
 
576
        close_file(yyin);
 
577
        return retvalue;
 
578
}