Coverage Report

Created: 2026-08-31 07:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libodraw/libodraw/libodraw_cue_parser.c
Line
Count
Source
1
/* original parser id follows */
2
/* yysccsid[] = "@(#)yaccpar  1.9 (Berkeley) 02/21/93" */
3
/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4
5
#define YYBYACC 1
6
#define YYMAJOR 1
7
#define YYMINOR 9
8
#define YYPATCH 20140715
9
10
2.46M
#define YYEMPTY        (-1)
11
#define yyclearin      (yychar = YYEMPTY)
12
#define yyerrok        (yyerrflag = 0)
13
#define YYRECOVERING() (yyerrflag != 0)
14
11
#define YYENOMEM       (-2)
15
824
#define YYEOF          0
16
17
#ifndef yyparse
18
#define yyparse    libodraw_cue_scanner_parse
19
#endif /* yyparse */
20
21
#ifndef yylex
22
2.46M
#define yylex      libodraw_cue_scanner_lex
23
#endif /* yylex */
24
25
#ifndef yyerror
26
645
#define yyerror    libodraw_cue_scanner_error
27
#endif /* yyerror */
28
29
#ifndef yychar
30
13.0M
#define yychar     libodraw_cue_scanner_char
31
#endif /* yychar */
32
33
#ifndef yyval
34
4.52M
#define yyval      libodraw_cue_scanner_val
35
#endif /* yyval */
36
37
#ifndef yylval
38
2.46M
#define yylval     libodraw_cue_scanner_lval
39
#endif /* yylval */
40
41
#ifndef yydebug
42
#define yydebug    libodraw_cue_scanner_debug
43
#endif /* yydebug */
44
45
#ifndef yynerrs
46
2.13k
#define yynerrs    libodraw_cue_scanner_nerrs
47
#endif /* yynerrs */
48
49
#ifndef yyerrflag
50
2.47M
#define yyerrflag  libodraw_cue_scanner_errflag
51
#endif /* yyerrflag */
52
53
#ifndef yylhs
54
2.18M
#define yylhs      libodraw_cue_scanner_lhs
55
#endif /* yylhs */
56
57
#ifndef yylen
58
2.18M
#define yylen      libodraw_cue_scanner_len
59
#endif /* yylen */
60
61
#ifndef yydefred
62
4.65M
#define yydefred   libodraw_cue_scanner_defred
63
#endif /* yydefred */
64
65
#ifndef yydgoto
66
1.49M
#define yydgoto    libodraw_cue_scanner_dgoto
67
#endif /* yydgoto */
68
69
#ifndef yysindex
70
2.77M
#define yysindex   libodraw_cue_scanner_sindex
71
#endif /* yysindex */
72
73
#ifndef yyrindex
74
145k
#define yyrindex   libodraw_cue_scanner_rindex
75
#endif /* yyrindex */
76
77
#ifndef yygindex
78
2.18M
#define yygindex   libodraw_cue_scanner_gindex
79
#endif /* yygindex */
80
81
#ifndef yytable
82
5.76M
#define yytable    libodraw_cue_scanner_table
83
#endif /* yytable */
84
85
#ifndef yycheck
86
4.24M
#define yycheck    libodraw_cue_scanner_check
87
#endif /* yycheck */
88
89
#ifndef yyname
90
#define yyname     libodraw_cue_scanner_name
91
#endif /* yyname */
92
93
#ifndef yyrule
94
#define yyrule     libodraw_cue_scanner_rule
95
#endif /* yyrule */
96
#define YYPREFIX "libodraw_cue_scanner_"
97
98
#define YYPURE 0
99
100
/*
101
 * CUE parser functions
102
 *
103
 * Copyright (C) 2010-2026, Joachim Metz <joachim.metz@gmail.com>
104
 *
105
 * Refer to AUTHORS for acknowledgements.
106
 *
107
 * This program is free software: you can redistribute it and/or modify
108
 * it under the terms of the GNU Lesser General Public License as published by
109
 * the Free Software Foundation, either version 3 of the License, or
110
 * (at your option) any later version.
111
 *
112
 * This program is distributed in the hope that it will be useful,
113
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
114
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
115
 * GNU General Public License for more details.
116
 *
117
 * You should have received a copy of the GNU Lesser General Public License
118
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
119
 */
120
121
#include <common.h>
122
#include <narrow_string.h>
123
#include <types.h>
124
125
#if defined( HAVE_STDLIB_H ) || defined( WINAPI )
126
#include <stdlib.h>
127
#endif
128
129
#include "libodraw_definitions.h"
130
#include "libodraw_handle.h"
131
#include "libodraw_libcerror.h"
132
#include "libodraw_libcnotify.h"
133
#include "libodraw_types.h"
134
135
#define YYMALLOC  libodraw_cue_scanner_alloc
136
#define YYREALLOC libodraw_cue_scanner_realloc
137
#define YYFREE    libodraw_cue_scanner_free
138
139
2.46M
#define YYLEX_PARAM NULL
140
#define YYPARSE_PARAM parser_state
141
142
#if defined( HAVE_DEBUG_OUTPUT )
143
#define libodraw_cue_parser_rule_print( string ) \
144
  if( libcnotify_verbose != 0 ) libcnotify_printf( "libodraw_cue_parser: rule: %s\n", string )
145
#else
146
#define libodraw_cue_parser_rule_print( string )
147
#endif
148
149
#if !defined( CD_SECS )
150
/* seconds per minute */
151
44.2k
#define CD_SECS     60
152
#endif
153
154
#if !defined( CD_FRAMES )
155
/* frames per second */
156
44.2k
#define CD_FRAMES   75
157
#endif
158
159
#ifdef YYSTYPE
160
#undef  YYSTYPE_IS_DECLARED
161
#define YYSTYPE_IS_DECLARED 1
162
#endif
163
#ifndef YYSTYPE_IS_DECLARED
164
#define YYSTYPE_IS_DECLARED 1
165
typedef union
166
{
167
        /* The numeric value
168
         */
169
        uint32_t numeric_value;
170
171
        /* The string value
172
         */
173
  struct cue_string_value
174
  {
175
    /* The string data
176
     */
177
          const char *data;
178
179
    /* The string length
180
     */
181
    size_t length;
182
183
  } string_value;
184
} YYSTYPE;
185
#endif /* !YYSTYPE_IS_DECLARED */
186
187
typedef struct libodraw_cue_parser_state libodraw_cue_parser_state_t;
188
189
struct libodraw_cue_parser_state
190
{
191
  /* The file
192
   */
193
  libodraw_handle_t *handle;
194
195
  /* The error
196
   */
197
  libcerror_error_t **error;
198
199
  /* The previous file index
200
   */
201
  int previous_file_index;
202
203
  /* The current file index
204
   */
205
  int current_file_index;
206
207
  /* The file type
208
   */
209
  uint8_t file_type;
210
211
  /* Value to indicate a new file command was issued
212
   */
213
  uint8_t new_file;
214
215
  /* The previous file sector
216
   */
217
  uint64_t previous_file_sector;
218
219
  /* The file sector
220
   */
221
  uint64_t file_sector;
222
223
  /* The previous session start sector
224
   */
225
  uint64_t previous_session_start_sector;
226
227
  /* The previous lead-out start sector
228
   */
229
  uint64_t previous_lead_out_start_sector;
230
231
  /* The previous track start sector
232
   */
233
  uint64_t previous_track_start_sector;
234
235
  /* The current start sector
236
   */
237
  uint64_t current_start_sector;
238
239
  /* The session number of sectors
240
   */
241
  uint64_t session_number_of_sectors;
242
243
  /* The lead-out number of sectors
244
   */
245
  uint64_t lead_out_number_of_sectors;
246
247
  /* The track number of sectors
248
   */
249
  uint64_t track_number_of_sectors;
250
251
  /* The previous track type
252
   */
253
  uint8_t previous_track_type;
254
255
  /* The current track type
256
   */
257
  uint8_t current_track_type;
258
259
  /* The previous session
260
   */
261
  int previous_session;
262
263
  /* The current session
264
   */
265
  int current_session;
266
267
  /* The previous lead-out
268
   */
269
  int previous_lead_out;
270
271
  /* The current lead-out
272
   */
273
  int current_lead_out;
274
275
  /* The previous track
276
   */
277
  int previous_track;
278
279
  /* The current track
280
   */
281
  int current_track;
282
283
  /* The previous index
284
   */
285
  int previous_index;
286
287
  /* The current index
288
   */
289
  int current_index;
290
};
291
292
typedef size_t yy_size_t;
293
typedef struct yy_buffer_state* YY_BUFFER_STATE;
294
295
extern \
296
int libodraw_cue_scanner_suppress_error;
297
298
extern \
299
int libodraw_cue_scanner_lex_destroy(
300
     void );
301
302
extern \
303
void *libodraw_cue_scanner_alloc(
304
       yy_size_t size );
305
306
extern \
307
void *libodraw_cue_scanner_realloc(
308
       void *buffer,
309
       yy_size_t size );
310
311
extern \
312
void libodraw_cue_scanner_free(
313
      void *buffer );
314
315
extern \
316
int libodraw_cue_scanner_lex(
317
     void *user_data );
318
319
extern \
320
void libodraw_cue_scanner_error(
321
      void *parser_state,
322
      const char *error_string );
323
324
extern \
325
YY_BUFFER_STATE libodraw_cue_scanner__scan_buffer(
326
                 char *buffer,
327
                 yy_size_t buffer_size );
328
329
extern \
330
void libodraw_cue_scanner__delete_buffer(
331
      YY_BUFFER_STATE buffer_state );
332
333
extern \
334
size_t libodraw_cue_scanner_buffer_offset;
335
336
static char *libodraw_cue_parser_function = "libodraw_cue_parser";
337
338
int libodraw_cue_parser_parse_number(
339
     const char *token,
340
     size_t token_size,
341
     int *number,
342
     libcerror_error_t **error );
343
344
int libodraw_cue_parser_parse_msf(
345
     const char *token,
346
     size_t token_size,
347
     uint64_t *lba,
348
     libcerror_error_t **error );
349
350
int libodraw_cue_parser_parse_track_type(
351
     const char *token,
352
     size_t token_size,
353
     uint8_t *track_type,
354
     libcerror_error_t **error );
355
356
int libodraw_cue_parser_parse_buffer(
357
     libodraw_handle_t *handle,
358
     const uint8_t *buffer,
359
     size_t buffer_size,
360
     libcerror_error_t **error );
361
362
363
/* compatibility with bison */
364
#ifdef YYPARSE_PARAM
365
/* compatibility with FreeBSD */
366
# ifdef YYPARSE_PARAM_TYPE
367
#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
368
# else
369
#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
370
# endif
371
#else
372
# define YYPARSE_DECL() yyparse(void * parser_state)
373
#endif
374
375
/* Parameters sent to lex. */
376
#ifdef YYLEX_PARAM
377
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
378
2.46M
# define YYLEX yylex(YYLEX_PARAM)
379
#else
380
# define YYLEX_DECL() yylex((void *)  NULL)
381
# define YYLEX yylex(NULL)
382
#endif
383
384
/* Parameters sent to yyerror. */
385
#ifndef YYERROR_DECL
386
#define YYERROR_DECL() yyerror(void * parser_state, const char *s)
387
#endif
388
#ifndef YYERROR_CALL
389
645
#define YYERROR_CALL(msg) yyerror(parser_state, msg)
390
#endif
391
392
extern int YYPARSE_DECL();
393
394
#define CUE_END_OF_LINE 257
395
#define CUE_SEMI_COLON 258
396
#define CUE_2DIGIT 259
397
#define CUE_CATALOG_NUMBER 260
398
#define CUE_ISRC_CODE 261
399
#define CUE_KEYWORD_STRING 262
400
#define CUE_MSF 263
401
#define CUE_STRING 264
402
#define CUE_CATALOG 265
403
#define CUE_CD_DA 266
404
#define CUE_CD_ROM 267
405
#define CUE_CD_ROM_XA 268
406
#define CUE_CD_TEXT 269
407
#define CUE_CDTEXTFILE 270
408
#define CUE_COPY 271
409
#define CUE_DATAFILE 272
410
#define CUE_FLAGS 273
411
#define CUE_FOUR_CHANNEL_AUDIO 274
412
#define CUE_FILE 275
413
#define CUE_INDEX 276
414
#define CUE_ISRC 277
415
#define CUE_NO_COPY 278
416
#define CUE_NO_PRE_EMPHASIS 279
417
#define CUE_POSTGAP 280
418
#define CUE_PRE_EMPHASIS 281
419
#define CUE_PREGAP 282
420
#define CUE_REMARK 283
421
#define CUE_TRACK 284
422
#define CUE_TWO_CHANNEL_AUDIO 285
423
#define CUE_CDTEXT_ARRANGER 286
424
#define CUE_CDTEXT_COMPOSER 287
425
#define CUE_CDTEXT_DISC_ID 288
426
#define CUE_CDTEXT_GENRE 289
427
#define CUE_CDTEXT_MESSAGE 290
428
#define CUE_CDTEXT_PERFORMER 291
429
#define CUE_CDTEXT_SIZE_INFO 292
430
#define CUE_CDTEXT_SONGWRITER 293
431
#define CUE_CDTEXT_TITLE 294
432
#define CUE_CDTEXT_TOC_INFO1 295
433
#define CUE_CDTEXT_TOC_INFO2 296
434
#define CUE_CDTEXT_UPC_EAN 297
435
#define CUE_REMARK_LEAD_OUT 298
436
#define CUE_REMARK_ORIGINAL_MEDIA_TYPE 299
437
#define CUE_REMARK_RUN_OUT 300
438
#define CUE_REMARK_SESSION 301
439
#define CUE_UNDEFINED 302
440
324k
#define YYERRCODE 256
441
typedef short YYINT;
442
static const YYINT libodraw_cue_scanner_lhs[] = {        -1,
443
    0,    0,    1,    1,    2,    2,    2,    2,    3,    3,
444
   10,   10,   10,   10,    4,    4,   15,   16,   16,   21,
445
   21,   21,   18,   18,   22,   22,   22,   22,   22,   22,
446
   19,   19,   26,   26,   26,   20,   20,   28,   28,   28,
447
   28,   28,   28,   28,   28,   28,   28,   28,    6,   12,
448
   37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
449
   37,   37,    7,    8,    9,   11,    5,   23,   38,   38,
450
   27,   29,   30,   31,   24,   32,   33,   34,   35,   25,
451
   36,   13,   13,   13,   13,   13,   39,   40,   41,   44,
452
   42,   43,   17,   17,   14,
453
};
454
static const YYINT libodraw_cue_scanner_len[] = {         2,
455
    4,    5,    0,    1,    0,    1,    1,    1,    0,    2,
456
    1,    1,    1,    1,    0,    2,    5,    0,    2,    1,
457
    1,    1,    0,    2,    1,    1,    1,    1,    1,    1,
458
    0,    2,    1,    1,    1,    0,    2,    1,    1,    1,
459
    1,    1,    1,    1,    1,    1,    1,    1,    3,    3,
460
    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
461
    1,    1,    2,    2,    2,    3,    4,    3,    0,    2,
462
    4,    2,    4,    2,    3,    2,    2,    3,    2,    3,
463
    2,    1,    1,    1,    1,    1,    3,    3,    3,    1,
464
    3,    3,    3,    4,    1,
465
};
466
static const YYINT libodraw_cue_scanner_defred[] = {      0,
467
    0,    0,    0,    4,    0,   95,    0,    0,    0,    0,
468
    0,   51,   52,   53,   54,   55,   56,   57,   58,   59,
469
   60,   61,   62,    0,    0,    0,    0,    0,    0,    6,
470
    7,    8,    0,   11,   12,   13,   14,    0,   82,   83,
471
   84,   85,   86,    0,   49,   63,   64,   65,    0,    0,
472
    0,    0,    0,    0,    0,    0,   10,    0,    0,   66,
473
   87,   88,   91,   92,    1,   20,   21,   22,    0,    0,
474
    0,    0,    0,   50,   89,   16,    0,    0,   19,    0,
475
    2,    0,    0,    0,    0,    0,   25,   29,   30,    0,
476
    0,   26,   27,   28,   67,    0,   93,    0,    0,    0,
477
    0,    0,   34,   35,    0,    0,   33,   24,   94,   70,
478
   68,   75,   80,    0,    0,    0,    0,    0,    0,    0,
479
    0,    0,   38,   47,   48,   17,    0,   39,   40,   41,
480
   42,   43,   44,   45,   46,   32,    0,   72,    0,   74,
481
   76,   77,    0,   79,   81,   37,   71,    0,   78,   73,
482
};
483
static const YYINT libodraw_cue_scanner_dgoto[] = {       2,
484
    3,   28,   29,   65,   66,    4,   30,   31,   32,   33,
485
   34,   35,   36,   37,   69,   70,   78,   90,  105,  126,
486
   71,   91,   92,   93,   94,  106,  107,  127,  128,  129,
487
  130,  131,  132,  133,  134,  135,   38,   99,   39,   40,
488
   41,   42,   43,   44,
489
};
490
static const YYINT libodraw_cue_scanner_sindex[] = {   -258,
491
 -251,    0, -152,    0, -247,    0, -245, -244, -241, -243,
492
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
493
    0,    0,    0, -246, -239, -238, -240,  -62, -234,    0,
494
    0,    0,  -62,    0,    0,    0,    0, -229,    0,    0,
495
    0,    0,    0, -220,    0,    0,    0,    0, -214, -212,
496
 -211, -210, -209, -231, -227,  -62,    0, -208, -204,    0,
497
    0,    0,    0,    0,    0,    0,    0,    0, -231, -228,
498
 -231, -201, -231,    0,    0,    0, -254, -107,    0, -199,
499
    0, -200, -194, -191, -189, -190,    0,    0,    0,  -35,
500
 -107,    0,    0,    0,    0, -179,    0, -191, -178, -177,
501
 -172, -153,    0,    0, -197,  -35,    0,    0,    0,    0,
502
    0,    0,    0, -156, -149, -155, -147, -146, -145, -150,
503
 -140, -138,    0,    0,    0,    0, -197,    0,    0,    0,
504
    0,    0,    0,    0,    0,    0, -137,    0, -142,    0,
505
    0,    0, -135,    0,    0,    0,    0, -134,    0,    0,
506
};
507
static const YYINT libodraw_cue_scanner_rindex[] = {      1,
508
    0,    0,    2,    0,    0,    0,    0,    0,    0,    0,
509
 -132,    0,    0,    0,    0,    0,    0,    0,    0,    0,
510
    0,    0,    0,    0,    0,    0,    0,   30,    0,    0,
511
    0,    0,   30,    0,    0,    0,    0,    0,    0,    0,
512
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
513
    0,    0,    0,   24,    0,   30,    0,    0,    0,    0,
514
    0,    0,    0,    0,    0,    0,    0,    0,   24,    0,
515
 -159,    0,   24,    0,    0,    0,    0,   59,    0,    0,
516
    0,    0,    0, -131,    0,    0,    0,    0,    0,   32,
517
   59,    0,    0,    0,    0,    0,    0, -131,    0,    0,
518
    0,    0,    0,    0,   57,   32,    0,    0,    0,    0,
519
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
520
    0,    0,    0,    0,    0,    0,   57,    0,    0,    0,
521
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
522
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
523
};
524
static const YYINT libodraw_cue_scanner_gindex[] = {      0,
525
    0,    0,  -22,  -69,   98,    0,    0,    0,    0,    0,
526
    0,  -63,  -51,  -40,    0,   58,    0,   37,   26,    3,
527
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
528
    0,    0,    0,    0,    0,    0,    0,   35,    0,    0,
529
    0,    0,    0,    0,
530
};
531
9.35M
#define YYTABLESIZE 344
532
static const YYINT libodraw_cue_scanner_table[] = {      76,
533
    3,    5,   67,   81,   82,   54,    1,   83,    5,   45,
534
   57,   46,   47,   68,   87,   48,   50,   67,   53,   67,
535
   49,   67,   51,   15,   52,    6,   88,   87,   68,    9,
536
   68,   31,   68,   73,   58,   59,   72,   89,  103,   88,
537
   55,  123,   60,   55,   61,   62,   63,   64,   74,  104,
538
   89,   11,   75,  124,  103,   77,   36,   95,   23,    6,
539
   80,   96,   97,  123,  125,  104,   24,   25,   26,   27,
540
   98,  100,  101,  115,  116,  124,  117,  109,  111,  112,
541
  118,  119,  120,  121,  113,   11,  125,  122,   12,   13,
542
   14,   15,   16,   17,   18,   19,   20,   21,   22,   23,
543
   24,   25,   26,   27,    6,  114,  137,  138,  139,  140,
544
  141,  142,  143,    7,    8,    9,  144,   10,  145,  147,
545
  148,  149,  150,   90,   18,   69,   56,  108,   79,  146,
546
   11,  136,  110,   12,   13,   14,   15,   16,   17,   18,
547
   19,   20,   21,   22,   23,   24,   25,   26,   27,    6,
548
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
549
    0,    0,    0,    0,    0,   84,    0,    0,    0,   85,
550
    0,    0,    0,    0,   86,   11,    0,    0,   12,   13,
551
   14,   15,   16,   17,   18,   19,   20,   21,   22,   23,
552
   24,   25,   26,   27,    6,    0,    0,    0,    0,    0,
553
    0,    0,    0,    0,    0,    0,    0,   10,    0,    0,
554
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
555
   11,    6,    0,   12,   13,   14,   15,   16,   17,   18,
556
   19,   20,   21,   22,   23,   24,   25,   26,   27,    0,
557
  102,    0,    0,    0,    0,    0,    0,   11,    0,    0,
558
    0,    0,    0,    0,    0,    0,    0,    3,    0,    0,
559
    0,    0,   24,   25,   26,   27,    3,    3,    3,    0,
560
    3,    0,    0,    0,    0,    3,    5,    0,    0,    0,
561
    0,    0,    0,    3,    3,    5,    3,    3,    3,    3,
562
    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
563
    3,    3,   31,   31,    9,   31,   31,   18,    0,   31,
564
   31,   31,   31,    9,    0,   31,   31,   31,   31,   31,
565
   31,   31,   31,   31,   31,   31,   31,   31,   31,   23,
566
   23,   36,   23,   23,   23,    0,   23,   23,   23,   23,
567
   36,    0,   23,   23,
568
};
569
static const YYINT libodraw_cue_scanner_check[] = {      69,
570
    0,    0,   54,   73,  259,   28,  265,  262,  260,  257,
571
   33,  257,  257,   54,   78,  257,  263,   69,  259,   71,
572
  264,   73,  262,    0,  263,  257,   78,   91,   69,    0,
573
   71,    0,   73,   56,  264,  256,  264,   78,   90,   91,
574
  275,  105,  257,  275,  257,  257,  257,  257,  257,   90,
575
   91,  283,  257,  105,  106,  284,    0,  257,    0,  257,
576
  262,  262,  257,  127,  105,  106,  298,  299,  300,  301,
577
  262,  261,  263,  271,  272,  127,  274,  257,  257,  257,
578
  278,  279,  280,  281,  257,  283,  127,  285,  286,  287,
579
  288,  289,  290,  291,  292,  293,  294,  295,  296,  297,
580
  298,  299,  300,  301,  257,  259,  263,  257,  264,  257,
581
  257,  257,  263,  266,  267,  268,  257,  270,  257,  257,
582
  263,  257,  257,  256,  284,  257,   29,   91,   71,  127,
583
  283,  106,   98,  286,  287,  288,  289,  290,  291,  292,
584
  293,  294,  295,  296,  297,  298,  299,  300,  301,  257,
585
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
586
   -1,   -1,   -1,   -1,   -1,  273,   -1,   -1,   -1,  277,
587
   -1,   -1,   -1,   -1,  282,  283,   -1,   -1,  286,  287,
588
  288,  289,  290,  291,  292,  293,  294,  295,  296,  297,
589
  298,  299,  300,  301,  257,   -1,   -1,   -1,   -1,   -1,
590
   -1,   -1,   -1,   -1,   -1,   -1,   -1,  270,   -1,   -1,
591
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
592
  283,  257,   -1,  286,  287,  288,  289,  290,  291,  292,
593
  293,  294,  295,  296,  297,  298,  299,  300,  301,   -1,
594
  276,   -1,   -1,   -1,   -1,   -1,   -1,  283,   -1,   -1,
595
   -1,   -1,   -1,   -1,   -1,   -1,   -1,  257,   -1,   -1,
596
   -1,   -1,  298,  299,  300,  301,  266,  267,  268,   -1,
597
  270,   -1,   -1,   -1,   -1,  275,  275,   -1,   -1,   -1,
598
   -1,   -1,   -1,  283,  284,  284,  286,  287,  288,  289,
599
  290,  291,  292,  293,  294,  295,  296,  297,  298,  299,
600
  300,  301,  271,  272,  275,  274,  275,  284,   -1,  278,
601
  279,  280,  281,  284,   -1,  284,  285,  286,  287,  288,
602
  289,  290,  291,  292,  293,  294,  295,  296,  297,  271,
603
  272,  275,  274,  275,  276,   -1,  278,  279,  280,  281,
604
  284,   -1,  284,  285,
605
};
606
1.64k
#define YYFINAL 2
607
#ifndef YYDEBUG
608
#define YYDEBUG 0
609
#endif
610
#define YYMAXTOKEN 302
611
#define YYUNDFTOKEN 349
612
#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
613
#if YYDEBUG
614
static const char *const libodraw_cue_scanner_name[] = {
615
616
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
617
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
618
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
619
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
620
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
621
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
622
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CUE_END_OF_LINE",
623
"CUE_SEMI_COLON","CUE_2DIGIT","CUE_CATALOG_NUMBER","CUE_ISRC_CODE",
624
"CUE_KEYWORD_STRING","CUE_MSF","CUE_STRING","CUE_CATALOG","CUE_CD_DA",
625
"CUE_CD_ROM","CUE_CD_ROM_XA","CUE_CD_TEXT","CUE_CDTEXTFILE","CUE_COPY",
626
"CUE_DATAFILE","CUE_FLAGS","CUE_FOUR_CHANNEL_AUDIO","CUE_FILE","CUE_INDEX",
627
"CUE_ISRC","CUE_NO_COPY","CUE_NO_PRE_EMPHASIS","CUE_POSTGAP","CUE_PRE_EMPHASIS",
628
"CUE_PREGAP","CUE_REMARK","CUE_TRACK","CUE_TWO_CHANNEL_AUDIO",
629
"CUE_CDTEXT_ARRANGER","CUE_CDTEXT_COMPOSER","CUE_CDTEXT_DISC_ID",
630
"CUE_CDTEXT_GENRE","CUE_CDTEXT_MESSAGE","CUE_CDTEXT_PERFORMER",
631
"CUE_CDTEXT_SIZE_INFO","CUE_CDTEXT_SONGWRITER","CUE_CDTEXT_TITLE",
632
"CUE_CDTEXT_TOC_INFO1","CUE_CDTEXT_TOC_INFO2","CUE_CDTEXT_UPC_EAN",
633
"CUE_REMARK_LEAD_OUT","CUE_REMARK_ORIGINAL_MEDIA_TYPE","CUE_REMARK_RUN_OUT",
634
"CUE_REMARK_SESSION","CUE_UNDEFINED",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
635
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol",
636
};
637
static const char *const libodraw_cue_scanner_rule[] = {
638
"$accept : cue_main",
639
"cue_main : cue_header_item cue_session_type cue_main_items cue_main_tracks",
640
"cue_main : cue_header_item cue_main_items cue_file cue_main_items cue_main_tracks",
641
"cue_header_item :",
642
"cue_header_item : cue_catalog",
643
"cue_session_type :",
644
"cue_session_type : cue_cd_da",
645
"cue_session_type : cue_cd_rom",
646
"cue_session_type : cue_cd_rom_xa",
647
"cue_main_items :",
648
"cue_main_items : cue_main_item cue_main_items",
649
"cue_main_item : cue_cdtextfile",
650
"cue_main_item : cue_cdtext",
651
"cue_main_item : cue_remark_item",
652
"cue_main_item : cue_empty_line",
653
"cue_main_tracks :",
654
"cue_main_tracks : cue_main_track cue_main_tracks",
655
"cue_main_track : cue_main_track_preceding_items cue_track cue_main_track_leading_items cue_main_track_index_items cue_main_track_trailing_items",
656
"cue_main_track_preceding_items :",
657
"cue_main_track_preceding_items : cue_main_track_preceding_item cue_main_track_preceding_items",
658
"cue_main_track_preceding_item : cue_file",
659
"cue_main_track_preceding_item : cue_remark_item",
660
"cue_main_track_preceding_item : cue_empty_line",
661
"cue_main_track_leading_items :",
662
"cue_main_track_leading_items : cue_main_track_leading_item cue_main_track_leading_items",
663
"cue_main_track_leading_item : cue_cdtext",
664
"cue_main_track_leading_item : cue_flags",
665
"cue_main_track_leading_item : cue_isrc",
666
"cue_main_track_leading_item : cue_pregap",
667
"cue_main_track_leading_item : cue_remark_item",
668
"cue_main_track_leading_item : cue_empty_line",
669
"cue_main_track_index_items :",
670
"cue_main_track_index_items : cue_main_track_index_item cue_main_track_index_items",
671
"cue_main_track_index_item : cue_index",
672
"cue_main_track_index_item : cue_remark_item",
673
"cue_main_track_index_item : cue_empty_line",
674
"cue_main_track_trailing_items :",
675
"cue_main_track_trailing_items : cue_main_track_trailing_item cue_main_track_trailing_items",
676
"cue_main_track_trailing_item : cue_cdtext",
677
"cue_main_track_trailing_item : cue_copy",
678
"cue_main_track_trailing_item : cue_datafile",
679
"cue_main_track_trailing_item : cue_four_channel_audio",
680
"cue_main_track_trailing_item : cue_no_copy",
681
"cue_main_track_trailing_item : cue_no_pre_emphasis",
682
"cue_main_track_trailing_item : cue_postgap",
683
"cue_main_track_trailing_item : cue_pre_emphasis",
684
"cue_main_track_trailing_item : cue_two_channel_audio",
685
"cue_main_track_trailing_item : cue_remark_item",
686
"cue_main_track_trailing_item : cue_empty_line",
687
"cue_catalog : CUE_CATALOG CUE_CATALOG_NUMBER CUE_END_OF_LINE",
688
"cue_cdtext : cue_cdtext_type CUE_STRING CUE_END_OF_LINE",
689
"cue_cdtext_type : CUE_CDTEXT_ARRANGER",
690
"cue_cdtext_type : CUE_CDTEXT_COMPOSER",
691
"cue_cdtext_type : CUE_CDTEXT_DISC_ID",
692
"cue_cdtext_type : CUE_CDTEXT_GENRE",
693
"cue_cdtext_type : CUE_CDTEXT_MESSAGE",
694
"cue_cdtext_type : CUE_CDTEXT_PERFORMER",
695
"cue_cdtext_type : CUE_CDTEXT_SIZE_INFO",
696
"cue_cdtext_type : CUE_CDTEXT_SONGWRITER",
697
"cue_cdtext_type : CUE_CDTEXT_TITLE",
698
"cue_cdtext_type : CUE_CDTEXT_TOC_INFO1",
699
"cue_cdtext_type : CUE_CDTEXT_TOC_INFO2",
700
"cue_cdtext_type : CUE_CDTEXT_UPC_EAN",
701
"cue_cd_da : CUE_CD_DA CUE_END_OF_LINE",
702
"cue_cd_rom : CUE_CD_ROM CUE_END_OF_LINE",
703
"cue_cd_rom_xa : CUE_CD_ROM_XA CUE_END_OF_LINE",
704
"cue_cdtextfile : CUE_CDTEXTFILE CUE_STRING CUE_END_OF_LINE",
705
"cue_file : CUE_FILE CUE_STRING CUE_KEYWORD_STRING CUE_END_OF_LINE",
706
"cue_flags : CUE_FLAGS cue_flags_types CUE_END_OF_LINE",
707
"cue_flags_types :",
708
"cue_flags_types : CUE_KEYWORD_STRING cue_flags_types",
709
"cue_index : CUE_INDEX CUE_2DIGIT CUE_MSF CUE_END_OF_LINE",
710
"cue_copy : CUE_COPY CUE_END_OF_LINE",
711
"cue_datafile : CUE_DATAFILE CUE_STRING CUE_MSF CUE_END_OF_LINE",
712
"cue_four_channel_audio : CUE_FOUR_CHANNEL_AUDIO CUE_END_OF_LINE",
713
"cue_isrc : CUE_ISRC CUE_ISRC_CODE CUE_END_OF_LINE",
714
"cue_no_copy : CUE_NO_COPY CUE_END_OF_LINE",
715
"cue_no_pre_emphasis : CUE_NO_PRE_EMPHASIS CUE_END_OF_LINE",
716
"cue_postgap : CUE_POSTGAP CUE_MSF CUE_END_OF_LINE",
717
"cue_pre_emphasis : CUE_PRE_EMPHASIS CUE_END_OF_LINE",
718
"cue_pregap : CUE_PREGAP CUE_MSF CUE_END_OF_LINE",
719
"cue_two_channel_audio : CUE_TWO_CHANNEL_AUDIO CUE_END_OF_LINE",
720
"cue_remark_item : cue_lead_out",
721
"cue_remark_item : cue_original_media_type",
722
"cue_remark_item : cue_remark",
723
"cue_remark_item : cue_run_out",
724
"cue_remark_item : cue_session",
725
"cue_lead_out : CUE_REMARK_LEAD_OUT CUE_MSF CUE_END_OF_LINE",
726
"cue_original_media_type : CUE_REMARK_ORIGINAL_MEDIA_TYPE CUE_KEYWORD_STRING CUE_END_OF_LINE",
727
"cue_remark : cue_remark_start error CUE_END_OF_LINE",
728
"cue_remark_start : CUE_REMARK",
729
"cue_run_out : CUE_REMARK_RUN_OUT CUE_MSF CUE_END_OF_LINE",
730
"cue_session : CUE_REMARK_SESSION CUE_2DIGIT CUE_END_OF_LINE",
731
"cue_track : CUE_TRACK CUE_KEYWORD_STRING CUE_END_OF_LINE",
732
"cue_track : CUE_TRACK CUE_2DIGIT CUE_KEYWORD_STRING CUE_END_OF_LINE",
733
"cue_empty_line : CUE_END_OF_LINE",
734
735
};
736
#endif
737
738
int      yydebug;
739
int      yynerrs;
740
741
int      yyerrflag;
742
int      yychar;
743
YYSTYPE  yyval;
744
YYSTYPE  yylval;
745
746
/* define the initial stack-sizes */
747
#ifdef YYSTACKSIZE
748
#undef YYMAXDEPTH
749
#define YYMAXDEPTH  YYSTACKSIZE
750
#else
751
#ifdef YYMAXDEPTH
752
#define YYSTACKSIZE YYMAXDEPTH
753
#else
754
#define YYSTACKSIZE 10000
755
15
#define YYMAXDEPTH  10000
756
#endif
757
#endif
758
759
1
#define YYINITSTACKSIZE 200
760
761
typedef struct {
762
    unsigned stacksize;
763
    YYINT    *s_base;
764
    YYINT    *s_mark;
765
    YYINT    *s_last;
766
    YYSTYPE  *l_base;
767
    YYSTYPE  *l_mark;
768
} YYSTACKDATA;
769
/* variables for the parser stack */
770
static YYSTACKDATA yystack;
771
772
/* Parses a number
773
 * Returns 1 if successful or -1 on error
774
 */
775
int libodraw_cue_parser_parse_number(
776
     const char *token,
777
     size_t token_size,
778
     int *number,
779
     libcerror_error_t **error )
780
59.5k
{
781
59.5k
  static char *function = "libodraw_cue_parser_parse_number";
782
59.5k
  int safe_number       = 0;
783
784
59.5k
  if( token == NULL )
785
0
  {
786
0
    libcerror_error_set(
787
0
     error,
788
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
789
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
790
0
     "%s: invalid token.",
791
0
     function );
792
793
0
    return( -1 );
794
0
  }
795
59.5k
  if( ( token_size < 1 )
796
59.5k
   || ( token_size > 2 ) )
797
0
  {
798
0
    libcerror_error_set(
799
0
     error,
800
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
801
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
802
0
     "%s: invalid token size value out of bounds.",
803
0
     function );
804
805
0
    return( -1 );
806
0
  }
807
59.5k
  if( number == NULL )
808
0
  {
809
0
    libcerror_error_set(
810
0
     error,
811
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
812
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
813
0
     "%s: invalid number.",
814
0
     function );
815
816
0
    return( -1 );
817
0
  }
818
59.5k
  if( ( token[ 0 ] < '0' )
819
59.5k
   || ( token[ 0 ] > '9' ) )
820
0
  {
821
0
    libcerror_error_set(
822
0
     error,
823
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
824
0
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
825
0
     "%s: unsupported first digit of number token.",
826
0
     function );
827
828
0
    return( -1 );
829
0
  }
830
59.5k
  safe_number = token[ 0 ] - '0';
831
832
59.5k
  if( token_size == 2 )
833
59.5k
  {
834
59.5k
    safe_number *= 10;
835
836
59.5k
    if( ( token[ 1 ] < '0' )
837
59.5k
     || ( token[ 1 ] > '9' ) )
838
0
    {
839
0
      libcerror_error_set(
840
0
       error,
841
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
842
0
       LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
843
0
       "%s: unsupported second digit of number token.",
844
0
       function );
845
846
0
      return( -1 );
847
0
    }
848
59.5k
    safe_number += token[ 1 ] - '0';
849
59.5k
  }
850
59.5k
  *number = safe_number;
851
852
59.5k
  return( 1 );
853
59.5k
}
854
855
/* Parses a MFS (minutes:seconds:frames) value and converts it into a logical block address (LBA)
856
 * Returns 1 if successful or -1 on error
857
 */
858
int libodraw_cue_parser_parse_msf(
859
     const char *token,
860
     size_t token_size,
861
     uint64_t *lba,
862
     libcerror_error_t **error )
863
44.2k
{
864
44.2k
  static char *function = "libodraw_cue_parser_parse_msf";
865
44.2k
  uint64_t safe_lba     = 0;
866
867
44.2k
  if( token == NULL )
868
0
  {
869
0
    libcerror_error_set(
870
0
     error,
871
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
872
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
873
0
     "%s: invalid token.",
874
0
     function );
875
876
0
    return( -1 );
877
0
  }
878
44.2k
  if( token_size != 8 )
879
0
  {
880
0
    libcerror_error_set(
881
0
     error,
882
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
883
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
884
0
     "%s: invalid token size value out of bounds.",
885
0
     function );
886
887
0
    return( -1 );
888
0
  }
889
44.2k
  if( lba == NULL )
890
0
  {
891
0
    libcerror_error_set(
892
0
     error,
893
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
894
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
895
0
     "%s: invalid LBA.",
896
0
     function );
897
898
0
    return( -1 );
899
0
  }
900
44.2k
  if( ( token[ 0 ] < '0' )
901
44.2k
   || ( token[ 0 ] > '9' )
902
44.2k
   || ( token[ 1 ] < '0' )
903
44.2k
   || ( token[ 1 ] > '9' )
904
44.2k
   || ( token[ 2 ] != ':' )
905
44.2k
   || ( token[ 3 ] < '0' )
906
44.2k
   || ( token[ 3 ] > '9' )
907
44.2k
   || ( token[ 4 ] < '0' )
908
44.2k
   || ( token[ 4 ] > '9' )
909
44.2k
   || ( token[ 5 ] != ':' )
910
44.2k
   || ( token[ 6 ] < '0' )
911
44.2k
   || ( token[ 6 ] > '9' )
912
44.2k
   || ( token[ 7 ] < '0' )
913
44.2k
   || ( token[ 7 ] > '9' ) )
914
0
  {
915
0
    libcerror_error_set(
916
0
     error,
917
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
918
0
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
919
0
     "%s: unsupported MSF token.",
920
0
     function );
921
922
0
    return( -1 );
923
0
  }
924
  /* Note that the MSF are relative, so there is no need for the MSF offset correction
925
   */
926
44.2k
        safe_lba  = ( ( token[ 0 ] - '0' ) * 10 ) + ( token[ 1 ] - '0' ); \
927
44.2k
        safe_lba *= CD_SECS; \
928
44.2k
        safe_lba += ( ( token[ 3 ] - '0' ) * 10 ) + ( token[ 4 ] - '0' ); \
929
44.2k
        safe_lba *= CD_FRAMES; \
930
44.2k
        safe_lba += ( ( token[ 6 ] - '0' ) * 10 ) + ( token[ 7 ] - '0' );
931
932
44.2k
  *lba = safe_lba;
933
934
44.2k
  return( 1 );
935
44.2k
}
936
937
/* Parses a track type
938
 * Returns 1 if successful or -1 on error
939
 */
940
int libodraw_cue_parser_parse_track_type(
941
     const char *token,
942
     size_t token_size,
943
     uint8_t *track_type,
944
     libcerror_error_t **error )
945
35.0k
{
946
35.0k
  static char *function = "libodraw_cue_parser_parse_track_type";
947
948
35.0k
  if( token == NULL )
949
0
  {
950
0
    libcerror_error_set(
951
0
     error,
952
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
953
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
954
0
     "%s: invalid token.",
955
0
     function );
956
957
0
    return( -1 );
958
0
  }
959
35.0k
  if( token_size < 1 )
960
0
  {
961
0
    libcerror_error_set(
962
0
     error,
963
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
964
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
965
0
     "%s: invalid token size value out of bounds.",
966
0
     function );
967
968
0
    return( -1 );
969
0
  }
970
35.0k
  if( track_type == NULL )
971
0
  {
972
0
    libcerror_error_set(
973
0
     error,
974
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
975
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
976
0
     "%s: invalid track type.",
977
0
     function );
978
979
0
    return( -1 );
980
0
  }
981
35.0k
  *track_type = LIBODRAW_TRACK_TYPE_UNKNOWN;
982
983
35.0k
  if( token_size == 3 )
984
472
  {
985
472
    if( narrow_string_compare(
986
472
         token,
987
472
         "CDG",
988
472
         3 ) == 0 )
989
206
    {
990
206
      *track_type = LIBODRAW_TRACK_TYPE_CDG;
991
206
    }
992
472
  }
993
34.5k
  else if( token_size == 5 )
994
3.56k
  {
995
3.56k
    if( narrow_string_compare(
996
3.56k
         token,
997
3.56k
         "AUDIO",
998
3.56k
         5 ) == 0 )
999
3.21k
    {
1000
3.21k
      *track_type = LIBODRAW_TRACK_TYPE_AUDIO;
1001
3.21k
    }
1002
3.56k
  }
1003
31.0k
  else if( token_size == 8 )
1004
2.20k
  {
1005
2.20k
    if( narrow_string_compare(
1006
2.20k
         token,
1007
2.20k
         "CDI",
1008
2.20k
         3 ) == 0 )
1009
800
    {
1010
800
      if( token[ 3 ] == '/' )
1011
600
      {
1012
600
        if( narrow_string_compare(
1013
600
             &( token[ 4 ] ),
1014
600
             "2336",
1015
600
             4 ) == 0 )
1016
202
        {
1017
202
           *track_type = LIBODRAW_TRACK_TYPE_CDI_2336;
1018
202
        }
1019
398
        else if( narrow_string_compare(
1020
398
            &( token[ 4 ] ),
1021
398
            "2352",
1022
398
            4 ) == 0 )
1023
203
        {
1024
203
           *track_type = LIBODRAW_TRACK_TYPE_CDI_2352;
1025
203
        }
1026
600
      }
1027
800
    }
1028
2.20k
  }
1029
28.8k
  else if( token_size == 9 )
1030
2.87k
  {
1031
2.87k
    if( narrow_string_compare(
1032
2.87k
         token,
1033
2.87k
         "MODE1_RAW",
1034
2.87k
         9 ) == 0 )
1035
2.38k
    {
1036
2.38k
      *track_type = LIBODRAW_TRACK_TYPE_MODE1_2352;
1037
2.38k
    }
1038
492
    else if( narrow_string_compare(
1039
492
              token,
1040
492
              "MODE2_RAW",
1041
492
              9 ) == 0 )
1042
202
    {
1043
202
      *track_type = LIBODRAW_TRACK_TYPE_MODE2_2352;
1044
202
    }
1045
2.87k
  }
1046
25.9k
  else if( token_size == 10 )
1047
2.47k
  {
1048
2.47k
    if( narrow_string_compare(
1049
2.47k
         token,
1050
2.47k
         "MODE",
1051
2.47k
         4 ) == 0 )
1052
2.25k
    {
1053
2.25k
      if( token[ 5 ] == '/' )
1054
1.99k
      {
1055
1.99k
        if( token[ 4 ] == '1' )
1056
595
        {
1057
595
          if( narrow_string_compare(
1058
595
               &( token[ 6 ] ),
1059
595
               "2048",
1060
595
               4 ) == 0 )
1061
202
          {
1062
202
             *track_type = LIBODRAW_TRACK_TYPE_MODE1_2048;
1063
202
          }
1064
393
          else if( narrow_string_compare(
1065
393
              &( token[ 6 ] ),
1066
393
              "2352",
1067
393
              4 ) == 0 )
1068
195
          {
1069
195
             *track_type = LIBODRAW_TRACK_TYPE_MODE1_2352;
1070
195
          }
1071
595
        }
1072
1.40k
        else if( token[ 4 ] == '2' )
1073
1.20k
        {
1074
1.20k
          if( narrow_string_compare(
1075
1.20k
               &( token[ 6 ] ),
1076
1.20k
               "2048",
1077
1.20k
               4 ) == 0 )
1078
202
          {
1079
202
             *track_type = LIBODRAW_TRACK_TYPE_MODE2_2048;
1080
202
          }
1081
998
          else if( narrow_string_compare(
1082
998
              &( token[ 6 ] ),
1083
998
              "2324",
1084
998
              4 ) == 0 )
1085
202
          {
1086
202
             *track_type = LIBODRAW_TRACK_TYPE_MODE2_2324;
1087
202
          }
1088
796
          else if( narrow_string_compare(
1089
796
              &( token[ 6 ] ),
1090
796
              "2336",
1091
796
              4 ) == 0 )
1092
202
          {
1093
202
             *track_type = LIBODRAW_TRACK_TYPE_MODE2_2336;
1094
202
          }
1095
594
          else if( narrow_string_compare(
1096
594
              &( token[ 6 ] ),
1097
594
              "2352",
1098
594
              4 ) == 0 )
1099
396
          {
1100
396
             *track_type = LIBODRAW_TRACK_TYPE_MODE2_2352;
1101
396
          }
1102
1.20k
        }
1103
1.99k
      }
1104
2.25k
    }
1105
2.47k
  }
1106
35.0k
  return( 1 );
1107
35.0k
}
1108
1109
/* Parses a CUE file
1110
 * Returns 1 if successful or -1 on error
1111
 */
1112
int libodraw_cue_parser_parse_buffer(
1113
     libodraw_handle_t *handle,
1114
     const uint8_t *buffer,
1115
     size_t buffer_size,
1116
     libcerror_error_t **error )
1117
1.49k
{
1118
1.49k
  libodraw_cue_parser_state_t parser_state;
1119
  
1120
1.49k
  static char *function        = "libodraw_cue_parser_parse_buffer";
1121
1.49k
  YY_BUFFER_STATE buffer_state = NULL;
1122
1.49k
  size_t buffer_offset         = 0;
1123
1.49k
  int result                   = -1;
1124
1125
1.49k
  if( buffer == NULL )
1126
0
  {
1127
0
    libcerror_error_set(
1128
0
     error,
1129
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1130
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1131
0
     "%s: invalid buffer.",
1132
0
     function );
1133
1134
0
    return( -1 );
1135
0
  }
1136
1.49k
  if( buffer_size >= 3 )
1137
1.49k
  {
1138
1.49k
    if( ( buffer[ 0 ] == 0x0ef )
1139
23
     && ( buffer[ 1 ] == 0x0bb )
1140
11
     && ( buffer[ 2 ] == 0x0bf ) )
1141
1
    {
1142
1
      buffer_offset = 3;
1143
1
    }
1144
1.49k
  }
1145
1.49k
  buffer_state = libodraw_cue_scanner__scan_buffer(
1146
1.49k
                  (char *) &( buffer[ buffer_offset ] ),
1147
1.49k
                  buffer_size - buffer_offset );
1148
1149
1.49k
  libodraw_cue_scanner_buffer_offset = (size_t) buffer_offset;
1150
1151
1.49k
  if( buffer_state != NULL )
1152
1.49k
  {
1153
1.49k
    parser_state.handle                         = handle;
1154
1.49k
    parser_state.error                          = error;
1155
1.49k
    parser_state.previous_file_index            = -1;
1156
1.49k
    parser_state.current_file_index             = -1;
1157
1.49k
    parser_state.file_type                      = 0;
1158
1.49k
    parser_state.previous_file_sector           = 0;
1159
1.49k
    parser_state.file_sector                    = 0;
1160
1.49k
    parser_state.previous_session_start_sector  = 0;
1161
1.49k
    parser_state.previous_lead_out_start_sector = 0;
1162
1.49k
    parser_state.previous_track_start_sector    = 0;
1163
1.49k
    parser_state.current_start_sector           = 0;
1164
1.49k
    parser_state.session_number_of_sectors      = 0;
1165
1.49k
    parser_state.lead_out_number_of_sectors     = 0;
1166
1.49k
    parser_state.track_number_of_sectors        = 0;
1167
1.49k
    parser_state.previous_track_type            = 0;
1168
1.49k
    parser_state.current_track_type             = 0;
1169
1.49k
    parser_state.previous_session               = 0;
1170
1.49k
    parser_state.current_session                = 0;
1171
1.49k
    parser_state.previous_lead_out              = 0;
1172
1.49k
    parser_state.current_lead_out               = 0;
1173
1.49k
    parser_state.previous_track                 = 0;
1174
1.49k
    parser_state.current_track                  = 0;
1175
1.49k
    parser_state.previous_index                 = 0;
1176
1.49k
    parser_state.current_index                  = 0;
1177
1178
1.49k
    if( libodraw_cue_scanner_parse(
1179
1.49k
         &parser_state ) == 0 )
1180
824
    {
1181
824
      result = 1;
1182
824
    }
1183
1.49k
    libodraw_cue_scanner__delete_buffer(
1184
1.49k
     buffer_state );
1185
1186
1.49k
    if( parser_state.current_session > 0 )
1187
0
    {
1188
0
      if( libodraw_handle_append_session(
1189
0
           parser_state.handle,
1190
0
           parser_state.previous_session_start_sector,
1191
0
           0,
1192
0
           parser_state.error ) != 1 )
1193
0
      {
1194
0
        libcerror_error_set(
1195
0
         parser_state.error,
1196
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1197
0
         LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1198
0
         "%s: unable to append session.",
1199
0
         function );
1200
1201
0
        result = -1;
1202
0
      }
1203
0
    }
1204
1.49k
    if( parser_state.current_lead_out > parser_state.previous_lead_out )
1205
0
    {
1206
0
      if( libodraw_handle_append_lead_out(
1207
0
           parser_state.handle,
1208
0
           parser_state.previous_lead_out_start_sector,
1209
0
           0,
1210
0
           parser_state.error ) != 1 )
1211
0
      {
1212
0
        libcerror_error_set(
1213
0
         parser_state.error,
1214
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1215
0
         LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1216
0
         "%s: unable to append lead-out.",
1217
0
         function );
1218
1219
0
        result = -1;
1220
0
      }
1221
0
    }
1222
1.49k
    if( parser_state.current_track > 0 )
1223
255
    {
1224
255
      if( parser_state.previous_file_index < 0 )
1225
43
      {
1226
43
        parser_state.file_sector = parser_state.previous_track_start_sector;
1227
1228
43
        parser_state.previous_file_index += 1;
1229
43
      }
1230
255
      parser_state.previous_file_sector = parser_state.previous_track_start_sector
1231
255
                                        - parser_state.file_sector;
1232
1233
255
      if( libodraw_handle_append_track(
1234
255
           parser_state.handle,
1235
255
           parser_state.previous_track_start_sector,
1236
255
           0,
1237
255
           parser_state.current_track_type,
1238
255
           parser_state.current_file_index,
1239
255
           parser_state.previous_file_sector,
1240
255
           parser_state.error ) != 1 )
1241
81
      {
1242
81
        libcerror_error_set(
1243
81
         parser_state.error,
1244
81
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1245
81
         LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1246
81
         "%s: unable to append track.",
1247
81
         function );
1248
1249
81
        result = -1;
1250
81
      }
1251
255
    }
1252
1.49k
  }
1253
1.49k
  libodraw_cue_scanner_lex_destroy();
1254
1255
1.49k
  return( result );
1256
1.49k
}
1257
1258
1259
#if YYDEBUG
1260
#include <stdio.h>    /* needed for printf */
1261
#endif
1262
1263
#include <stdlib.h> /* needed for malloc, etc */
1264
#include <string.h> /* needed for memset */
1265
1266
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
1267
static int yygrowstack(YYSTACKDATA *data)
1268
9
{
1269
9
    int i;
1270
9
    unsigned newsize;
1271
9
    YYINT *newss;
1272
9
    YYSTYPE *newvs;
1273
1274
9
    if ((newsize = data->stacksize) == 0)
1275
1
        newsize = YYINITSTACKSIZE;
1276
8
    else if (newsize >= YYMAXDEPTH)
1277
2
        return YYENOMEM;
1278
6
    else if ((newsize *= 2) > YYMAXDEPTH)
1279
1
        newsize = YYMAXDEPTH;
1280
1281
7
    i = (int) (data->s_mark - data->s_base);
1282
7
    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
1283
7
    if (newss == 0)
1284
0
        return YYENOMEM;
1285
1286
7
    data->s_base = newss;
1287
7
    data->s_mark = newss + i;
1288
1289
7
    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1290
7
    if (newvs == 0)
1291
0
        return YYENOMEM;
1292
1293
7
    data->l_base = newvs;
1294
7
    data->l_mark = newvs + i;
1295
1296
7
    data->stacksize = newsize;
1297
7
    data->s_last = data->s_base + newsize - 1;
1298
7
    return 0;
1299
7
}
1300
1301
#if YYPURE || defined(YY_NO_LEAKS)
1302
static void yyfreestack(YYSTACKDATA *data)
1303
{
1304
    free(data->s_base);
1305
    free(data->l_base);
1306
    memset(data, 0, sizeof(*data));
1307
}
1308
#else
1309
#define yyfreestack(data) /* nothing */
1310
#endif
1311
1312
27
#define YYABORT  goto yyabort
1313
#define YYREJECT goto yyabort
1314
#define YYACCEPT goto yyaccept
1315
#define YYERROR  goto yyerrlab
1316
1317
int
1318
YYPARSE_DECL()
1319
1.49k
{
1320
1.49k
    int yym, yyn, yystate;
1321
#if YYDEBUG
1322
    const char *yys;
1323
1324
    if ((yys = getenv("YYDEBUG")) != 0)
1325
    {
1326
        yyn = *yys;
1327
        if (yyn >= '0' && yyn <= '9')
1328
            yydebug = yyn - '0';
1329
    }
1330
#endif
1331
1332
1.49k
    yynerrs = 0;
1333
1.49k
    yyerrflag = 0;
1334
1.49k
    yychar = YYEMPTY;
1335
1.49k
    yystate = 0;
1336
1337
#if YYPURE
1338
    memset(&yystack, 0, sizeof(yystack));
1339
#endif
1340
1341
1.49k
    if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1342
1.49k
    yystack.s_mark = yystack.s_base;
1343
1.49k
    yystack.l_mark = yystack.l_base;
1344
1.49k
    yystate = 0;
1345
1.49k
    *yystack.s_mark = 0;
1346
1347
4.65M
yyloop:
1348
4.65M
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1349
2.61M
    if (yychar < 0)
1350
2.46M
    {
1351
2.46M
        if ((yychar = YYLEX) < 0) yychar = YYEOF;
1352
#if YYDEBUG
1353
        if (yydebug)
1354
        {
1355
            yys = yyname[YYTRANSLATE(yychar)];
1356
            printf("%sdebug: state %d, reading %d (%s)\n",
1357
                    YYPREFIX, yystate, yychar, yys);
1358
        }
1359
#endif
1360
2.46M
    }
1361
2.61M
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1362
2.60M
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1363
2.46M
    {
1364
#if YYDEBUG
1365
        if (yydebug)
1366
            printf("%sdebug: state %d, shifting to state %d\n",
1367
                    YYPREFIX, yystate, yytable[yyn]);
1368
#endif
1369
2.46M
        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1370
1
        {
1371
1
            goto yyoverflow;
1372
1
        }
1373
2.46M
        yystate = yytable[yyn];
1374
2.46M
        *++yystack.s_mark = yytable[yyn];
1375
2.46M
        *++yystack.l_mark = yylval;
1376
2.46M
        yychar = YYEMPTY;
1377
2.46M
        if (yyerrflag > 0)  --yyerrflag;
1378
2.46M
        goto yyloop;
1379
2.46M
    }
1380
145k
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1381
145k
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1382
144k
    {
1383
144k
        yyn = yytable[yyn];
1384
144k
        goto yyreduce;
1385
144k
    }
1386
643
    if (yyerrflag) goto yyinrecovery;
1387
1388
643
    YYERROR_CALL("syntax error");
1389
1390
643
    goto yyerrlab;
1391
1392
643
yyerrlab:
1393
643
    ++yynerrs;
1394
1395
643
yyinrecovery:
1396
643
    if (yyerrflag < 3)
1397
643
    {
1398
643
        yyerrflag = 3;
1399
643
        for (;;)
1400
162k
        {
1401
162k
            if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
1402
161k
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1403
0
            {
1404
#if YYDEBUG
1405
                if (yydebug)
1406
                    printf("%sdebug: state %d, error recovery shifting\
1407
 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
1408
#endif
1409
0
                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1410
0
                {
1411
0
                    goto yyoverflow;
1412
0
                }
1413
0
                yystate = yytable[yyn];
1414
0
                *++yystack.s_mark = yytable[yyn];
1415
0
                *++yystack.l_mark = yylval;
1416
0
                goto yyloop;
1417
0
            }
1418
162k
            else
1419
162k
            {
1420
#if YYDEBUG
1421
                if (yydebug)
1422
                    printf("%sdebug: error recovery discarding state %d\n",
1423
                            YYPREFIX, *yystack.s_mark);
1424
#endif
1425
162k
                if (yystack.s_mark <= yystack.s_base) goto yyabort;
1426
161k
                --yystack.s_mark;
1427
161k
                --yystack.l_mark;
1428
161k
            }
1429
162k
        }
1430
643
    }
1431
0
    else
1432
0
    {
1433
0
        if (yychar == YYEOF) goto yyabort;
1434
#if YYDEBUG
1435
        if (yydebug)
1436
        {
1437
            yys = yyname[YYTRANSLATE(yychar)];
1438
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1439
                    YYPREFIX, yystate, yychar, yys);
1440
        }
1441
#endif
1442
0
        yychar = YYEMPTY;
1443
0
        goto yyloop;
1444
0
    }
1445
1446
2.18M
yyreduce:
1447
#if YYDEBUG
1448
    if (yydebug)
1449
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1450
                YYPREFIX, yystate, yyn, yyrule[yyn]);
1451
#endif
1452
2.18M
    yym = yylen[yyn];
1453
2.18M
    if (yym)
1454
2.04M
        yyval = yystack.l_mark[1-yym];
1455
144k
    else
1456
144k
        memset(&yyval, 0, sizeof yyval);
1457
2.18M
    switch (yyn)
1458
2.18M
    {
1459
2
case 49:
1460
2
  {
1461
2
    libodraw_cue_parser_rule_print(
1462
2
     "cue_catalog" );
1463
2
  }
1464
2
break;
1465
720
case 50:
1466
720
  {
1467
720
    libodraw_cue_parser_rule_print(
1468
720
     "cue_cdtext" );
1469
720
  }
1470
720
break;
1471
0
case 63:
1472
0
  {
1473
0
    libodraw_cue_parser_rule_print(
1474
0
     "cue_cd_da" );
1475
0
  }
1476
0
break;
1477
1
case 64:
1478
1
  {
1479
1
    libodraw_cue_parser_rule_print(
1480
1
     "cue_cd_rom" );
1481
1
  }
1482
1
break;
1483
1
case 65:
1484
1
  {
1485
1
    libodraw_cue_parser_rule_print(
1486
1
     "cue_cd_rom_xa" );
1487
1
  }
1488
1
break;
1489
0
case 66:
1490
0
  {
1491
0
    libodraw_cue_parser_rule_print(
1492
0
     "cue_cdtextfile" );
1493
0
  }
1494
0
break;
1495
500k
case 67:
1496
500k
  {
1497
500k
    libodraw_cue_parser_rule_print(
1498
500k
     "cue_file" );
1499
1500
500k
    if( yystack.l_mark[-2].string_value.data == NULL )
1501
1
    {
1502
1
      libcerror_error_set(
1503
1
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1504
1
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1505
1
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1506
1
       "%s: invalid filename.",
1507
1
       libodraw_cue_parser_function );
1508
1509
1
      YYABORT;
1510
1
    }
1511
500k
    if( yystack.l_mark[-1].string_value.data == NULL )
1512
0
    {
1513
0
      libcerror_error_set(
1514
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1515
0
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1516
0
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1517
0
       "%s: invalid file type.",
1518
0
       libodraw_cue_parser_function );
1519
1520
0
      YYABORT;
1521
0
    }
1522
500k
    ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_UNKNOWN;
1523
1524
500k
    if( yystack.l_mark[-1].string_value.length == 3 )
1525
3.70k
    {
1526
3.70k
      if( narrow_string_compare(
1527
3.70k
           yystack.l_mark[-1].string_value.data,
1528
3.70k
           "MP3",
1529
3.70k
           3 ) == 0 )
1530
1.28k
      {
1531
1.28k
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_AUDIO_MPEG1_LAYER3;
1532
1.28k
      }
1533
3.70k
    }
1534
496k
    else if( yystack.l_mark[-1].string_value.length == 4 )
1535
2.52k
    {
1536
2.52k
      if( narrow_string_compare(
1537
2.52k
           yystack.l_mark[-1].string_value.data,
1538
2.52k
           "AIFF",
1539
2.52k
           4 ) == 0 )
1540
194
      {
1541
194
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_AUDIO_AIFF;
1542
194
      }
1543
2.33k
      else if( narrow_string_compare(
1544
2.33k
                yystack.l_mark[-1].string_value.data,
1545
2.33k
                "WAVE",
1546
2.33k
                4 ) == 0 )
1547
500
      {
1548
500
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_AUDIO_WAVE;
1549
500
      }
1550
2.52k
    }
1551
494k
    else if( yystack.l_mark[-1].string_value.length == 6 )
1552
547
    {
1553
547
      if( narrow_string_compare(
1554
547
           yystack.l_mark[-1].string_value.data,
1555
547
           "BINARY",
1556
547
           6 ) == 0 )
1557
195
      {
1558
195
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_BINARY_LITTLE_ENDIAN;
1559
195
      }
1560
547
    }
1561
493k
    else if( yystack.l_mark[-1].string_value.length == 8 )
1562
513
    {
1563
513
      if( narrow_string_compare(
1564
513
           yystack.l_mark[-1].string_value.data,
1565
513
           "MOTOROLA",
1566
513
           8 ) == 0 )
1567
194
      {
1568
194
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_BINARY_BIG_ENDIAN;
1569
194
      }
1570
513
    }
1571
500k
    if( libodraw_handle_append_data_file(
1572
500k
         ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1573
500k
         yystack.l_mark[-2].string_value.data,
1574
500k
         yystack.l_mark[-2].string_value.length,
1575
500k
         ( (libodraw_cue_parser_state_t *) parser_state )->file_type,
1576
500k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1577
0
    {
1578
0
      libcerror_error_set(
1579
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1580
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1581
0
       LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1582
0
       "%s: unable to append data file.",
1583
0
       libodraw_cue_parser_function );
1584
1585
0
      YYABORT;
1586
0
    }
1587
500k
    ( (libodraw_cue_parser_state_t *) parser_state )->current_file_index += 1;
1588
500k
  }
1589
0
break;
1590
0
case 68:
1591
0
  {
1592
0
    libodraw_cue_parser_rule_print(
1593
0
     "cue_flags" );
1594
0
  }
1595
0
break;
1596
40.5k
case 71:
1597
40.5k
  {
1598
40.5k
    libodraw_cue_parser_rule_print(
1599
40.5k
     "cue_index" );
1600
1601
40.5k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_index = ( (libodraw_cue_parser_state_t *) parser_state )->current_index;
1602
1603
40.5k
    if( libodraw_cue_parser_parse_number(
1604
40.5k
         yystack.l_mark[-2].string_value.data,
1605
40.5k
         yystack.l_mark[-2].string_value.length,
1606
40.5k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_index ),
1607
40.5k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1608
0
    {
1609
0
      libcerror_error_set(
1610
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1611
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1612
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1613
0
       "%s: unable to parse index number.",
1614
0
       libodraw_cue_parser_function );
1615
1616
0
      YYABORT;
1617
0
    }
1618
40.5k
    if( ( ( (libodraw_cue_parser_state_t *) parser_state )->current_index != 0 )
1619
25.2k
     && ( ( (libodraw_cue_parser_state_t *) parser_state )->current_index != ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_index + 1 ) ) )
1620
9
    {
1621
9
      libcerror_error_set(
1622
9
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1623
9
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1624
9
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
1625
9
       "%s: unsupported index number - values are not sequential.",
1626
9
       libodraw_cue_parser_function );
1627
1628
9
      YYABORT;
1629
9
    }
1630
40.4k
    if( libodraw_cue_parser_parse_msf(
1631
40.4k
         yystack.l_mark[-1].string_value.data,
1632
40.4k
         yystack.l_mark[-1].string_value.length,
1633
40.4k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector ),
1634
40.4k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1635
0
    {
1636
0
      libcerror_error_set(
1637
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1638
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1639
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1640
0
       "%s: unable to parse index MSF.",
1641
0
       libodraw_cue_parser_function );
1642
1643
0
      YYABORT;
1644
0
    }
1645
    /* The MSF can be relative to the start of the file
1646
     */
1647
40.4k
    if( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector != 0 )
1648
36.6k
    {
1649
36.6k
      if( ( ( (libodraw_cue_parser_state_t *) parser_state )->current_index == 0 )
1650
21.6k
       || ( ( (libodraw_cue_parser_state_t *) parser_state )->current_index == 1 ) )
1651
36.2k
      {
1652
36.2k
        if( ( ( (libodraw_cue_parser_state_t *) parser_state )->session_number_of_sectors == 0 )
1653
36.0k
         || ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type == LIBODRAW_TRACK_TYPE_AUDIO ) )
1654
651
        {
1655
651
          if( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector < ( (libodraw_cue_parser_state_t *) parser_state )->previous_session_start_sector )
1656
0
          {
1657
0
            libcerror_error_set(
1658
0
             ( (libodraw_cue_parser_state_t *) parser_state )->error,
1659
0
             LIBCERROR_ERROR_DOMAIN_RUNTIME,
1660
0
             LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1661
0
             "%s: invalid session start sector value precedes previous.",
1662
0
             libodraw_cue_parser_function );
1663
1664
0
            YYABORT;
1665
0
          }
1666
651
          ( (libodraw_cue_parser_state_t *) parser_state )->session_number_of_sectors = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector
1667
651
                                                                                      - ( (libodraw_cue_parser_state_t *) parser_state )->previous_session_start_sector;
1668
651
        }
1669
36.2k
        if( ( ( (libodraw_cue_parser_state_t *) parser_state )->lead_out_number_of_sectors == 0 )
1670
36.0k
         || ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type == LIBODRAW_TRACK_TYPE_AUDIO ) )
1671
651
        {
1672
651
          if( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector < ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out_start_sector )
1673
0
          {
1674
0
            libcerror_error_set(
1675
0
             ( (libodraw_cue_parser_state_t *) parser_state )->error,
1676
0
             LIBCERROR_ERROR_DOMAIN_RUNTIME,
1677
0
             LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1678
0
             "%s: invalid lead-out start sector value precedes previous.",
1679
0
             libodraw_cue_parser_function );
1680
1681
0
            YYABORT;
1682
0
          }
1683
651
          ( (libodraw_cue_parser_state_t *) parser_state )->lead_out_number_of_sectors = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector
1684
651
                                                                                       - ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out_start_sector;
1685
651
        }
1686
36.2k
      }
1687
36.6k
      if( ( (libodraw_cue_parser_state_t *) parser_state )->current_index == 1 )
1688
21.2k
      {
1689
21.2k
        if( ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors == 0 )
1690
16.8k
        {
1691
16.8k
          if( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector < ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector )
1692
1
          {
1693
1
            libcerror_error_set(
1694
1
             ( (libodraw_cue_parser_state_t *) parser_state )->error,
1695
1
             LIBCERROR_ERROR_DOMAIN_RUNTIME,
1696
1
             LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1697
1
             "%s: invalid track start sector value precedes previous.",
1698
1
             libodraw_cue_parser_function );
1699
1700
1
            YYABORT;
1701
1
          }
1702
16.8k
          ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector
1703
16.8k
                                                                                    - ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector;
1704
16.8k
        }
1705
21.2k
      }
1706
36.6k
    }
1707
40.4k
    if( ( (libodraw_cue_parser_state_t *) parser_state )->current_index == 1 )
1708
24.9k
    {
1709
24.9k
      if( ( (libodraw_cue_parser_state_t *) parser_state )->current_session > 1 )
1710
0
      {
1711
0
        if( libodraw_handle_append_session(
1712
0
             ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1713
0
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_session_start_sector,
1714
0
             ( (libodraw_cue_parser_state_t *) parser_state )->session_number_of_sectors,
1715
0
             ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1716
0
        {
1717
0
          libcerror_error_set(
1718
0
           ( (libodraw_cue_parser_state_t *) parser_state )->error,
1719
0
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
1720
0
           LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1721
0
           "%s: unable to append session.",
1722
0
           libodraw_cue_parser_function );
1723
1724
0
          YYABORT;
1725
0
        }
1726
0
        ( (libodraw_cue_parser_state_t *) parser_state )->previous_session_start_sector = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector;
1727
0
        ( (libodraw_cue_parser_state_t *) parser_state )->session_number_of_sectors     = 0;
1728
0
      }
1729
24.9k
      if( ( (libodraw_cue_parser_state_t *) parser_state )->current_lead_out > ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out )
1730
0
      {
1731
0
        if( libodraw_handle_append_lead_out(
1732
0
             ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1733
0
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out_start_sector,
1734
0
             ( (libodraw_cue_parser_state_t *) parser_state )->lead_out_number_of_sectors,
1735
0
             ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1736
0
        {
1737
0
          libcerror_error_set(
1738
0
           ( (libodraw_cue_parser_state_t *) parser_state )->error,
1739
0
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
1740
0
           LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1741
0
           "%s: unable to append lead-out.",
1742
0
           libodraw_cue_parser_function );
1743
1744
0
          YYABORT;
1745
0
        }
1746
0
        ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out          = ( (libodraw_cue_parser_state_t *) parser_state )->current_lead_out;
1747
0
        ( (libodraw_cue_parser_state_t *) parser_state )->lead_out_number_of_sectors = 0;
1748
0
      }
1749
24.9k
      if( ( (libodraw_cue_parser_state_t *) parser_state )->current_track > 1 )
1750
20.5k
      {
1751
20.5k
        if( ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index < 0 )
1752
136
        {
1753
136
          ( (libodraw_cue_parser_state_t *) parser_state )->file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector;
1754
1755
136
          ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index += 1;
1756
136
        }
1757
20.5k
        ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector
1758
20.5k
                                                                               - ( (libodraw_cue_parser_state_t *) parser_state )->file_sector;
1759
1760
20.5k
        if( libodraw_handle_append_track(
1761
20.5k
             ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1762
20.5k
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector,
1763
20.5k
             ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors,
1764
20.5k
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type,
1765
20.5k
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index,
1766
20.5k
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_sector,
1767
20.5k
             ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1768
1
        {
1769
1
          libcerror_error_set(
1770
1
           ( (libodraw_cue_parser_state_t *) parser_state )->error,
1771
1
           LIBCERROR_ERROR_DOMAIN_RUNTIME,
1772
1
           LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1773
1
           "%s: unable to append track.",
1774
1
           libodraw_cue_parser_function );
1775
1776
1
          YYABORT;
1777
1
        }
1778
20.5k
        if( ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index < ( (libodraw_cue_parser_state_t *) parser_state )->current_file_index )
1779
20.0k
        {
1780
20.0k
          ( (libodraw_cue_parser_state_t *) parser_state )->file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector;
1781
1782
20.0k
          ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index += 1;
1783
20.0k
        }
1784
20.5k
        ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector;
1785
20.5k
        ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors     = 0;
1786
20.5k
      }
1787
24.9k
    }
1788
40.4k
  }
1789
40.4k
break;
1790
40.4k
case 72:
1791
188
  {
1792
188
    libodraw_cue_parser_rule_print(
1793
188
     "cue_copy" );
1794
188
  }
1795
188
break;
1796
3.78k
case 73:
1797
3.78k
  {
1798
3.78k
    libodraw_cue_parser_rule_print(
1799
3.78k
     "cue_datafile" );
1800
1801
3.78k
    if( yystack.l_mark[-2].string_value.data == NULL )
1802
1
    {
1803
1
      libcerror_error_set(
1804
1
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1805
1
       LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1806
1
       LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1807
1
       "%s: invalid filename.",
1808
1
       libodraw_cue_parser_function );
1809
1810
1
      YYABORT;
1811
1
    }
1812
3.78k
    if( libodraw_cue_parser_parse_msf(
1813
3.78k
         yystack.l_mark[-1].string_value.data,
1814
3.78k
         yystack.l_mark[-1].string_value.length,
1815
3.78k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors ),
1816
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1817
0
    {
1818
0
      libcerror_error_set(
1819
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1820
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1821
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1822
0
       "%s: unable to parse datafile MSF.",
1823
0
       libodraw_cue_parser_function );
1824
1825
0
      YYABORT;
1826
0
    }
1827
3.78k
    ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_BINARY_LITTLE_ENDIAN;
1828
1829
3.78k
    if( libodraw_handle_append_data_file(
1830
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1831
3.78k
         yystack.l_mark[-2].string_value.data,
1832
3.78k
         yystack.l_mark[-2].string_value.length,
1833
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->file_type,
1834
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1835
0
    {
1836
0
      libcerror_error_set(
1837
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1838
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1839
0
       LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1840
0
       "%s: unable to append data file.",
1841
0
       libodraw_cue_parser_function );
1842
1843
0
      YYABORT;
1844
0
    }
1845
3.78k
    if( ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index < 0 )
1846
124
    {
1847
124
      ( (libodraw_cue_parser_state_t *) parser_state )->file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector;
1848
1849
124
      ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index += 1;
1850
124
    }
1851
3.78k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector
1852
3.78k
                                                                           - ( (libodraw_cue_parser_state_t *) parser_state )->file_sector;
1853
1854
3.78k
    if( libodraw_handle_append_track(
1855
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1856
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector,
1857
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors,
1858
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type,
1859
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index,
1860
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_sector,
1861
3.78k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1862
1
    {
1863
1
      libcerror_error_set(
1864
1
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1865
1
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1866
1
       LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1867
1
       "%s: unable to append track.",
1868
1
       libodraw_cue_parser_function );
1869
1870
1
      YYABORT;
1871
1
    }
1872
3.78k
    ( (libodraw_cue_parser_state_t *) parser_state )->current_file_index += 1;
1873
3.78k
  }
1874
0
break;
1875
0
case 74:
1876
0
  {
1877
0
    libodraw_cue_parser_rule_print(
1878
0
     "cue_four_channel_audio" );
1879
0
  }
1880
0
break;
1881
365
case 75:
1882
365
  {
1883
365
    libodraw_cue_parser_rule_print(
1884
365
     "cue_isrc" );
1885
365
  }
1886
365
break;
1887
179
case 76:
1888
179
  {
1889
179
    libodraw_cue_parser_rule_print(
1890
179
     "cue_no_copy" );
1891
179
  }
1892
179
break;
1893
0
case 77:
1894
0
  {
1895
0
    libodraw_cue_parser_rule_print(
1896
0
     "cue_no_pre_emphasis" );
1897
0
  }
1898
0
break;
1899
0
case 78:
1900
0
  {
1901
0
    libodraw_cue_parser_rule_print(
1902
0
     "cue_postgap" );
1903
0
  }
1904
0
break;
1905
0
case 79:
1906
0
  {
1907
0
    libodraw_cue_parser_rule_print(
1908
0
     "cue_pre_emphasis" );
1909
0
  }
1910
0
break;
1911
0
case 80:
1912
0
  {
1913
0
    libodraw_cue_parser_rule_print(
1914
0
     "cue_pregap" );
1915
0
  }
1916
0
break;
1917
0
case 81:
1918
0
  {
1919
0
    libodraw_cue_parser_rule_print(
1920
0
     "cue_two_channel_audio" );
1921
0
  }
1922
0
break;
1923
0
case 87:
1924
0
  {
1925
0
    libodraw_cue_parser_rule_print(
1926
0
     "cue_lead_out" );
1927
1928
0
    if( libodraw_cue_parser_parse_msf(
1929
0
         yystack.l_mark[-1].string_value.data,
1930
0
         yystack.l_mark[-1].string_value.length,
1931
0
         &( ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out_start_sector ),
1932
0
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1933
0
    {
1934
0
      libcerror_error_set(
1935
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1936
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1937
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1938
0
       "%s: unable to parse lead-out MSF.",
1939
0
       libodraw_cue_parser_function );
1940
1941
0
      YYABORT;
1942
0
    }
1943
0
    if( ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors == 0 )
1944
0
    {
1945
0
      if( ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out_start_sector < ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector )
1946
0
      {
1947
0
        libcerror_error_set(
1948
0
         ( (libodraw_cue_parser_state_t *) parser_state )->error,
1949
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1950
0
         LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1951
0
         "%s: invalid lead-out start sector value precedes previous track start sector.",
1952
0
         libodraw_cue_parser_function );
1953
1954
0
        YYABORT;
1955
0
      }
1956
0
      ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors = ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out_start_sector
1957
0
                                                                                - ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector;
1958
0
    }
1959
0
    ( (libodraw_cue_parser_state_t *) parser_state )->current_lead_out += 1;
1960
0
  }
1961
0
break;
1962
0
case 88:
1963
0
  {
1964
0
    libodraw_cue_parser_rule_print(
1965
0
     "cue_original_media_type" );
1966
0
  }
1967
0
break;
1968
0
case 89:
1969
0
  {
1970
0
    libodraw_cue_parser_rule_print(
1971
0
     "cue_remark" );
1972
1973
0
    libodraw_cue_scanner_suppress_error = 0;
1974
0
  }
1975
0
break;
1976
0
case 90:
1977
0
  {
1978
    /* The build-in rule error will gobble up all the tokens until the end-of-line
1979
     * because these are no syntax errors suppress the error output
1980
     */
1981
0
    libodraw_cue_scanner_suppress_error = 1;
1982
0
  }
1983
0
break;
1984
0
case 91:
1985
0
  {
1986
0
    libodraw_cue_parser_rule_print(
1987
0
     "cue_run_out" );
1988
1989
0
    if( libodraw_cue_parser_parse_msf(
1990
0
         yystack.l_mark[-1].string_value.data,
1991
0
         yystack.l_mark[-1].string_value.length,
1992
0
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector ),
1993
0
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
1994
0
    {
1995
0
      libcerror_error_set(
1996
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1997
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1998
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1999
0
       "%s: unable to parse run-out MSF.",
2000
0
       libodraw_cue_parser_function );
2001
2002
0
      YYABORT;
2003
0
    }
2004
0
    if( ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors == 0 )
2005
0
    {
2006
0
      if( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector < ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector )
2007
0
      {
2008
0
        libcerror_error_set(
2009
0
         ( (libodraw_cue_parser_state_t *) parser_state )->error,
2010
0
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
2011
0
         LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
2012
0
         "%s: invalid track start sector value precedes previous.",
2013
0
         libodraw_cue_parser_function );
2014
2015
0
        YYABORT;
2016
0
      }
2017
0
      ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector
2018
0
                                            - ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector;
2019
0
    }
2020
0
  }
2021
0
break;
2022
0
case 92:
2023
0
  {
2024
0
    libodraw_cue_parser_rule_print(
2025
0
     "cue_session" );
2026
2027
0
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_session = ( (libodraw_cue_parser_state_t *) parser_state )->current_session;
2028
2029
0
    if( libodraw_cue_parser_parse_number(
2030
0
         yystack.l_mark[-1].string_value.data,
2031
0
         yystack.l_mark[-1].string_value.length,
2032
0
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_session ),
2033
0
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
2034
0
    {
2035
0
      libcerror_error_set(
2036
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2037
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2038
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
2039
0
       "%s: unable to parse session number.",
2040
0
       libodraw_cue_parser_function );
2041
2042
0
      YYABORT;
2043
0
    }
2044
0
    if( ( ( (libodraw_cue_parser_state_t *) parser_state )->current_session != 0 )
2045
0
     && ( ( (libodraw_cue_parser_state_t *) parser_state )->current_session != ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_session + 1 ) ) )
2046
0
    {
2047
0
      libcerror_error_set(
2048
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2049
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2050
0
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
2051
0
       "%s: unsupported session number - values are not sequential.",
2052
0
       libodraw_cue_parser_function );
2053
2054
0
      YYABORT;
2055
0
    }
2056
0
  }
2057
0
break;
2058
16.0k
case 93:
2059
16.0k
  {
2060
16.0k
    libodraw_cue_parser_rule_print(
2061
16.0k
     "cue_track" );
2062
2063
16.0k
    if( ( (libodraw_cue_parser_state_t *) parser_state )->current_track != 0 )
2064
1
    {
2065
1
      libcerror_error_set(
2066
1
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2067
1
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2068
1
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
2069
1
       "%s: unsupported track number - only single track supported.",
2070
1
       libodraw_cue_parser_function );
2071
2072
1
      YYABORT;
2073
1
    }
2074
16.0k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type = ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type;
2075
2076
16.0k
    if( libodraw_cue_parser_parse_track_type(
2077
16.0k
         yystack.l_mark[-1].string_value.data,
2078
16.0k
         yystack.l_mark[-1].string_value.length,
2079
16.0k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type ),
2080
16.0k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
2081
0
    {
2082
0
      libcerror_error_set(
2083
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2084
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2085
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
2086
0
       "%s: unable to parse track type.",
2087
0
       libodraw_cue_parser_function );
2088
2089
0
      YYABORT;
2090
0
    }
2091
16.0k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_index = 0;
2092
16.0k
    ( (libodraw_cue_parser_state_t *) parser_state )->current_index  = 0;
2093
16.0k
  }
2094
0
break;
2095
19.0k
case 94:
2096
19.0k
  {
2097
19.0k
    libodraw_cue_parser_rule_print(
2098
19.0k
     "cue_track" );
2099
2100
19.0k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_track = ( (libodraw_cue_parser_state_t *) parser_state )->current_track;
2101
2102
19.0k
    if( libodraw_cue_parser_parse_number(
2103
19.0k
         yystack.l_mark[-2].string_value.data,
2104
19.0k
         yystack.l_mark[-2].string_value.length,
2105
19.0k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_track ),
2106
19.0k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
2107
0
    {
2108
0
      libcerror_error_set(
2109
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2110
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2111
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
2112
0
       "%s: unable to parse track number.",
2113
0
       libodraw_cue_parser_function );
2114
2115
0
      YYABORT;
2116
0
    }
2117
19.0k
    if( ( ( (libodraw_cue_parser_state_t *) parser_state )->current_track != 0 )
2118
11.8k
     && ( ( (libodraw_cue_parser_state_t *) parser_state )->current_track != ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_track + 1 ) ) )
2119
12
    {
2120
12
      libcerror_error_set(
2121
12
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2122
12
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2123
12
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
2124
12
       "%s: unsupported track number - values are not sequential.",
2125
12
       libodraw_cue_parser_function );
2126
2127
12
      YYABORT;
2128
12
    }
2129
19.0k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type = ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type;
2130
2131
19.0k
    if( libodraw_cue_parser_parse_track_type(
2132
19.0k
         yystack.l_mark[-1].string_value.data,
2133
19.0k
         yystack.l_mark[-1].string_value.length,
2134
19.0k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type ),
2135
19.0k
         ( (libodraw_cue_parser_state_t *) parser_state )->error ) != 1 )
2136
0
    {
2137
0
      libcerror_error_set(
2138
0
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2139
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2140
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
2141
0
       "%s: unable to parse track type.",
2142
0
       libodraw_cue_parser_function );
2143
2144
0
      YYABORT;
2145
0
    }
2146
19.0k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_index = 0;
2147
19.0k
    ( (libodraw_cue_parser_state_t *) parser_state )->current_index  = 0;
2148
19.0k
  }
2149
0
break;
2150
2.18M
    }
2151
2.18M
    yystack.s_mark -= yym;
2152
2.18M
    yystate = *yystack.s_mark;
2153
2.18M
    yystack.l_mark -= yym;
2154
2.18M
    yym = yylhs[yyn];
2155
2.18M
    if (yystate == 0 && yym == 0)
2156
824
    {
2157
#if YYDEBUG
2158
        if (yydebug)
2159
            printf("%sdebug: after reduction, shifting from state 0 to\
2160
 state %d\n", YYPREFIX, YYFINAL);
2161
#endif
2162
824
        yystate = YYFINAL;
2163
824
        *++yystack.s_mark = YYFINAL;
2164
824
        *++yystack.l_mark = yyval;
2165
824
        if (yychar < 0)
2166
0
        {
2167
0
            if ((yychar = YYLEX) < 0) yychar = YYEOF;
2168
#if YYDEBUG
2169
            if (yydebug)
2170
            {
2171
                yys = yyname[YYTRANSLATE(yychar)];
2172
                printf("%sdebug: state %d, reading %d (%s)\n",
2173
                        YYPREFIX, YYFINAL, yychar, yys);
2174
            }
2175
#endif
2176
0
        }
2177
824
        if (yychar == YYEOF) goto yyaccept;
2178
0
        goto yyloop;
2179
824
    }
2180
2.18M
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
2181
1.32M
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
2182
688k
        yystate = yytable[yyn];
2183
1.49M
    else
2184
1.49M
        yystate = yydgoto[yym];
2185
#if YYDEBUG
2186
    if (yydebug)
2187
        printf("%sdebug: after reduction, shifting from state %d \
2188
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
2189
#endif
2190
2.18M
    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
2191
1
    {
2192
1
        goto yyoverflow;
2193
1
    }
2194
2.18M
    *++yystack.s_mark = (YYINT) yystate;
2195
2.18M
    *++yystack.l_mark = yyval;
2196
2.18M
    goto yyloop;
2197
2198
2
yyoverflow:
2199
2
    YYERROR_CALL("yacc stack overflow");
2200
2201
672
yyabort:
2202
672
    yyfreestack(&yystack);
2203
672
    return (1);
2204
2205
824
yyaccept:
2206
824
    yyfreestack(&yystack);
2207
824
    return (0);
2208
2
}