Coverage Report

Created: 2026-04-04 07:47

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
3.41M
#define YYEMPTY        (-1)
11
#define yyclearin      (yychar = YYEMPTY)
12
#define yyerrok        (yyerrflag = 0)
13
#define YYRECOVERING() (yyerrflag != 0)
14
11
#define YYENOMEM       (-2)
15
813
#define YYEOF          0
16
17
#ifndef yyparse
18
#define yyparse    libodraw_cue_scanner_parse
19
#endif /* yyparse */
20
21
#ifndef yylex
22
3.41M
#define yylex      libodraw_cue_scanner_lex
23
#endif /* yylex */
24
25
#ifndef yyerror
26
664
#define yyerror    libodraw_cue_scanner_error
27
#endif /* yyerror */
28
29
#ifndef yychar
30
17.9M
#define yychar     libodraw_cue_scanner_char
31
#endif /* yychar */
32
33
#ifndef yyval
34
6.27M
#define yyval      libodraw_cue_scanner_val
35
#endif /* yyval */
36
37
#ifndef yylval
38
3.41M
#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.17k
#define yynerrs    libodraw_cue_scanner_nerrs
47
#endif /* yynerrs */
48
49
#ifndef yyerrflag
50
3.41M
#define yyerrflag  libodraw_cue_scanner_errflag
51
#endif /* yyerrflag */
52
53
#ifndef yylhs
54
3.05M
#define yylhs      libodraw_cue_scanner_lhs
55
#endif /* yylhs */
56
57
#ifndef yylen
58
3.05M
#define yylen      libodraw_cue_scanner_len
59
#endif /* yylen */
60
61
#ifndef yydefred
62
6.46M
#define yydefred   libodraw_cue_scanner_defred
63
#endif /* yydefred */
64
65
#ifndef yydgoto
66
2.04M
#define yydgoto    libodraw_cue_scanner_dgoto
67
#endif /* yydgoto */
68
69
#ifndef yysindex
70
3.81M
#define yysindex   libodraw_cue_scanner_sindex
71
#endif /* yysindex */
72
73
#ifndef yyrindex
74
175k
#define yyrindex   libodraw_cue_scanner_rindex
75
#endif /* yyrindex */
76
77
#ifndef yygindex
78
3.05M
#define yygindex   libodraw_cue_scanner_gindex
79
#endif /* yygindex */
80
81
#ifndef yytable
82
8.00M
#define yytable    libodraw_cue_scanner_table
83
#endif /* yytable */
84
85
#ifndef yycheck
86
5.86M
#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-2025, 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
3.41M
#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.9k
#define CD_SECS     60
152
#endif
153
154
#if !defined( CD_FRAMES )
155
/* frames per second */
156
44.9k
#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
3.41M
# 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
664
#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
443k
#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
12.9M
#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.62k
#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
64.0k
{
781
64.0k
  static char *function = "libodraw_cue_parser_parse_number";
782
64.0k
  int safe_number       = 0;
783
784
64.0k
  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
64.0k
  if( ( token_size < 1 )
796
64.0k
   || ( 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
64.0k
  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
64.0k
  if( ( token[ 0 ] < '0' )
819
64.0k
   || ( 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
64.0k
  safe_number = token[ 0 ] - '0';
831
832
64.0k
  if( token_size == 2 )
833
64.0k
  {
834
64.0k
    safe_number *= 10;
835
836
64.0k
    if( ( token[ 1 ] < '0' )
837
64.0k
     || ( 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
64.0k
    safe_number += token[ 1 ] - '0';
849
64.0k
  }
850
64.0k
  *number = safe_number;
851
852
64.0k
  return( 1 );
853
64.0k
}
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.9k
{
864
44.9k
  static char *function = "libodraw_cue_parser_parse_msf";
865
44.9k
  uint64_t safe_lba     = 0;
866
867
44.9k
  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.9k
  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.9k
  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.9k
  if( ( token[ 0 ] < '0' )
901
44.9k
   || ( token[ 0 ] > '9' )
902
44.9k
   || ( token[ 1 ] < '0' )
903
44.9k
   || ( token[ 1 ] > '9' )
904
44.9k
   || ( token[ 2 ] != ':' )
905
44.9k
   || ( token[ 3 ] < '0' )
906
44.9k
   || ( token[ 3 ] > '9' )
907
44.9k
   || ( token[ 4 ] < '0' )
908
44.9k
   || ( token[ 4 ] > '9' )
909
44.9k
   || ( token[ 5 ] != ':' )
910
44.9k
   || ( token[ 6 ] < '0' )
911
44.9k
   || ( token[ 6 ] > '9' )
912
44.9k
   || ( token[ 7 ] < '0' )
913
44.9k
   || ( 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.9k
        safe_lba  = ( ( token[ 0 ] - '0' ) * 10 ) + ( token[ 1 ] - '0' ); \
927
44.9k
        safe_lba *= CD_SECS; \
928
44.9k
        safe_lba += ( ( token[ 3 ] - '0' ) * 10 ) + ( token[ 4 ] - '0' ); \
929
44.9k
        safe_lba *= CD_FRAMES; \
930
44.9k
        safe_lba += ( ( token[ 6 ] - '0' ) * 10 ) + ( token[ 7 ] - '0' );
931
932
44.9k
  *lba = safe_lba;
933
934
44.9k
  return( 1 );
935
44.9k
}
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
42.6k
{
946
42.6k
  static char *function = "libodraw_cue_parser_parse_track_type";
947
948
42.6k
  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
42.6k
  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
42.6k
  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
42.6k
  *track_type = LIBODRAW_TRACK_TYPE_UNKNOWN;
982
983
42.6k
  if( token_size == 3 )
984
500
  {
985
500
    if( narrow_string_compare(
986
500
         token,
987
500
         "CDG",
988
500
         3 ) == 0 )
989
206
    {
990
206
      *track_type = LIBODRAW_TRACK_TYPE_CDG;
991
206
    }
992
500
  }
993
42.1k
  else if( token_size == 5 )
994
4.70k
  {
995
4.70k
    if( narrow_string_compare(
996
4.70k
         token,
997
4.70k
         "AUDIO",
998
4.70k
         5 ) == 0 )
999
4.47k
    {
1000
4.47k
      *track_type = LIBODRAW_TRACK_TYPE_AUDIO;
1001
4.47k
    }
1002
4.70k
  }
1003
37.4k
  else if( token_size == 8 )
1004
2.44k
  {
1005
2.44k
    if( narrow_string_compare(
1006
2.44k
         token,
1007
2.44k
         "CDI",
1008
2.44k
         3 ) == 0 )
1009
801
    {
1010
801
      if( token[ 3 ] == '/' )
1011
602
      {
1012
602
        if( narrow_string_compare(
1013
602
             &( token[ 4 ] ),
1014
602
             "2336",
1015
602
             4 ) == 0 )
1016
203
        {
1017
203
           *track_type = LIBODRAW_TRACK_TYPE_CDI_2336;
1018
203
        }
1019
399
        else if( narrow_string_compare(
1020
399
            &( token[ 4 ] ),
1021
399
            "2352",
1022
399
            4 ) == 0 )
1023
203
        {
1024
203
           *track_type = LIBODRAW_TRACK_TYPE_CDI_2352;
1025
203
        }
1026
602
      }
1027
801
    }
1028
2.44k
  }
1029
34.9k
  else if( token_size == 9 )
1030
3.54k
  {
1031
3.54k
    if( narrow_string_compare(
1032
3.54k
         token,
1033
3.54k
         "MODE1_RAW",
1034
3.54k
         9 ) == 0 )
1035
3.06k
    {
1036
3.06k
      *track_type = LIBODRAW_TRACK_TYPE_MODE1_2352;
1037
3.06k
    }
1038
478
    else if( narrow_string_compare(
1039
478
              token,
1040
478
              "MODE2_RAW",
1041
478
              9 ) == 0 )
1042
202
    {
1043
202
      *track_type = LIBODRAW_TRACK_TYPE_MODE2_2352;
1044
202
    }
1045
3.54k
  }
1046
31.4k
  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.27k
    {
1053
2.27k
      if( token[ 5 ] == '/' )
1054
2.07k
      {
1055
2.07k
        if( token[ 4 ] == '1' )
1056
596
        {
1057
596
          if( narrow_string_compare(
1058
596
               &( token[ 6 ] ),
1059
596
               "2048",
1060
596
               4 ) == 0 )
1061
202
          {
1062
202
             *track_type = LIBODRAW_TRACK_TYPE_MODE1_2048;
1063
202
          }
1064
394
          else if( narrow_string_compare(
1065
394
              &( token[ 6 ] ),
1066
394
              "2352",
1067
394
              4 ) == 0 )
1068
195
          {
1069
195
             *track_type = LIBODRAW_TRACK_TYPE_MODE1_2352;
1070
195
          }
1071
596
        }
1072
1.48k
        else if( token[ 4 ] == '2' )
1073
1.27k
        {
1074
1.27k
          if( narrow_string_compare(
1075
1.27k
               &( token[ 6 ] ),
1076
1.27k
               "2048",
1077
1.27k
               4 ) == 0 )
1078
202
          {
1079
202
             *track_type = LIBODRAW_TRACK_TYPE_MODE2_2048;
1080
202
          }
1081
1.07k
          else if( narrow_string_compare(
1082
1.07k
              &( token[ 6 ] ),
1083
1.07k
              "2324",
1084
1.07k
              4 ) == 0 )
1085
204
          {
1086
204
             *track_type = LIBODRAW_TRACK_TYPE_MODE2_2324;
1087
204
          }
1088
868
          else if( narrow_string_compare(
1089
868
              &( token[ 6 ] ),
1090
868
              "2336",
1091
868
              4 ) == 0 )
1092
202
          {
1093
202
             *track_type = LIBODRAW_TRACK_TYPE_MODE2_2336;
1094
202
          }
1095
666
          else if( narrow_string_compare(
1096
666
              &( token[ 6 ] ),
1097
666
              "2352",
1098
666
              4 ) == 0 )
1099
467
          {
1100
467
             *track_type = LIBODRAW_TRACK_TYPE_MODE2_2352;
1101
467
          }
1102
1.27k
        }
1103
2.07k
      }
1104
2.27k
    }
1105
2.47k
  }
1106
42.6k
  return( 1 );
1107
42.6k
}
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.51k
{
1118
1.51k
  libodraw_cue_parser_state_t parser_state;
1119
  
1120
1.51k
  static char *function        = "libodraw_cue_parser_parse_buffer";
1121
1.51k
  YY_BUFFER_STATE buffer_state = NULL;
1122
1.51k
  size_t buffer_offset         = 0;
1123
1.51k
  int result                   = -1;
1124
1125
1.51k
  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.51k
  if( buffer_size >= 3 )
1137
1.51k
  {
1138
1.51k
    if( ( buffer[ 0 ] == 0x0ef )
1139
25
     && ( buffer[ 1 ] == 0x0bb )
1140
13
     && ( buffer[ 2 ] == 0x0bf ) )
1141
1
    {
1142
1
      buffer_offset = 3;
1143
1
    }
1144
1.51k
  }
1145
1.51k
  buffer_state = libodraw_cue_scanner__scan_buffer(
1146
1.51k
                  (char *) &( buffer[ buffer_offset ] ),
1147
1.51k
                  buffer_size - buffer_offset );
1148
1149
1.51k
  libodraw_cue_scanner_buffer_offset = (size_t) buffer_offset;
1150
1151
1.51k
  if( buffer_state != NULL )
1152
1.51k
  {
1153
1.51k
    parser_state.handle                         = handle;
1154
1.51k
    parser_state.error                          = error;
1155
1.51k
    parser_state.previous_file_index            = -1;
1156
1.51k
    parser_state.current_file_index             = -1;
1157
1.51k
    parser_state.file_type                      = 0;
1158
1.51k
    parser_state.previous_file_sector           = 0;
1159
1.51k
    parser_state.file_sector                    = 0;
1160
1.51k
    parser_state.previous_session_start_sector  = 0;
1161
1.51k
    parser_state.previous_lead_out_start_sector = 0;
1162
1.51k
    parser_state.previous_track_start_sector    = 0;
1163
1.51k
    parser_state.current_start_sector           = 0;
1164
1.51k
    parser_state.session_number_of_sectors      = 0;
1165
1.51k
    parser_state.lead_out_number_of_sectors     = 0;
1166
1.51k
    parser_state.track_number_of_sectors        = 0;
1167
1.51k
    parser_state.previous_track_type            = 0;
1168
1.51k
    parser_state.current_track_type             = 0;
1169
1.51k
    parser_state.previous_session               = 0;
1170
1.51k
    parser_state.current_session                = 0;
1171
1.51k
    parser_state.previous_lead_out              = 0;
1172
1.51k
    parser_state.current_lead_out               = 0;
1173
1.51k
    parser_state.previous_track                 = 0;
1174
1.51k
    parser_state.current_track                  = 0;
1175
1.51k
    parser_state.previous_index                 = 0;
1176
1.51k
    parser_state.current_index                  = 0;
1177
1178
1.51k
    if( libodraw_cue_scanner_parse(
1179
1.51k
         &parser_state ) == 0 )
1180
813
    {
1181
813
      result = 1;
1182
813
    }
1183
1.51k
    libodraw_cue_scanner__delete_buffer(
1184
1.51k
     buffer_state );
1185
1186
1.51k
    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.51k
    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.51k
    if( parser_state.current_track > 0 )
1223
266
    {
1224
266
      if( parser_state.previous_file_index < 0 )
1225
53
      {
1226
53
        parser_state.file_sector = parser_state.previous_track_start_sector;
1227
1228
53
        parser_state.previous_file_index += 1;
1229
53
      }
1230
266
      parser_state.previous_file_sector = parser_state.previous_track_start_sector
1231
266
                                        - parser_state.file_sector;
1232
1233
266
      if( libodraw_handle_append_track(
1234
266
           parser_state.handle,
1235
266
           parser_state.previous_track_start_sector,
1236
266
           0,
1237
266
           parser_state.current_track_type,
1238
266
           parser_state.current_file_index,
1239
266
           parser_state.previous_file_sector,
1240
266
           parser_state.error ) != 1 )
1241
84
      {
1242
84
        libcerror_error_set(
1243
84
         parser_state.error,
1244
84
         LIBCERROR_ERROR_DOMAIN_RUNTIME,
1245
84
         LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
1246
84
         "%s: unable to append track.",
1247
84
         function );
1248
1249
84
        result = -1;
1250
84
      }
1251
266
    }
1252
1.51k
  }
1253
1.51k
  libodraw_cue_scanner_lex_destroy();
1254
1255
1.51k
  return( result );
1256
1.51k
}
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
36
#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.51k
{
1320
1.51k
    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.51k
    yynerrs = 0;
1333
1.51k
    yyerrflag = 0;
1334
1.51k
    yychar = YYEMPTY;
1335
1.51k
    yystate = 0;
1336
1337
#if YYPURE
1338
    memset(&yystack, 0, sizeof(yystack));
1339
#endif
1340
1341
1.51k
    if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1342
1.51k
    yystack.s_mark = yystack.s_base;
1343
1.51k
    yystack.l_mark = yystack.l_base;
1344
1.51k
    yystate = 0;
1345
1.51k
    *yystack.s_mark = 0;
1346
1347
6.46M
yyloop:
1348
6.46M
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1349
3.59M
    if (yychar < 0)
1350
3.41M
    {
1351
3.41M
        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
3.41M
    }
1361
3.59M
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1362
3.58M
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1363
3.41M
    {
1364
#if YYDEBUG
1365
        if (yydebug)
1366
            printf("%sdebug: state %d, shifting to state %d\n",
1367
                    YYPREFIX, yystate, yytable[yyn]);
1368
#endif
1369
3.41M
        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1370
1
        {
1371
1
            goto yyoverflow;
1372
1
        }
1373
3.41M
        yystate = yytable[yyn];
1374
3.41M
        *++yystack.s_mark = yytable[yyn];
1375
3.41M
        *++yystack.l_mark = yylval;
1376
3.41M
        yychar = YYEMPTY;
1377
3.41M
        if (yyerrflag > 0)  --yyerrflag;
1378
3.41M
        goto yyloop;
1379
3.41M
    }
1380
175k
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1381
175k
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1382
175k
    {
1383
175k
        yyn = yytable[yyn];
1384
175k
        goto yyreduce;
1385
175k
    }
1386
662
    if (yyerrflag) goto yyinrecovery;
1387
1388
662
    YYERROR_CALL("syntax error");
1389
1390
662
    goto yyerrlab;
1391
1392
662
yyerrlab:
1393
662
    ++yynerrs;
1394
1395
662
yyinrecovery:
1396
662
    if (yyerrflag < 3)
1397
662
    {
1398
662
        yyerrflag = 3;
1399
662
        for (;;)
1400
222k
        {
1401
222k
            if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
1402
221k
                    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
222k
            else
1419
222k
            {
1420
#if YYDEBUG
1421
                if (yydebug)
1422
                    printf("%sdebug: error recovery discarding state %d\n",
1423
                            YYPREFIX, *yystack.s_mark);
1424
#endif
1425
222k
                if (yystack.s_mark <= yystack.s_base) goto yyabort;
1426
221k
                --yystack.s_mark;
1427
221k
                --yystack.l_mark;
1428
221k
            }
1429
222k
        }
1430
662
    }
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
3.05M
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
3.05M
    yym = yylen[yyn];
1453
3.05M
    if (yym)
1454
2.87M
        yyval = yystack.l_mark[1-yym];
1455
175k
    else
1456
175k
        memset(&yyval, 0, sizeof yyval);
1457
3.05M
    switch (yyn)
1458
3.05M
    {
1459
1
case 49:
1460
1
  {
1461
1
    libodraw_cue_parser_rule_print(
1462
1
     "cue_catalog" );
1463
1
  }
1464
1
break;
1465
721
case 50:
1466
721
  {
1467
721
    libodraw_cue_parser_rule_print(
1468
721
     "cue_cdtext" );
1469
721
  }
1470
721
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
708k
case 67:
1496
708k
  {
1497
708k
    libodraw_cue_parser_rule_print(
1498
708k
     "cue_file" );
1499
1500
708k
    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
708k
    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
708k
    ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_UNKNOWN;
1523
1524
708k
    if( yystack.l_mark[-1].string_value.length == 3 )
1525
33.0k
    {
1526
33.0k
      if( narrow_string_compare(
1527
33.0k
           yystack.l_mark[-1].string_value.data,
1528
33.0k
           "MP3",
1529
33.0k
           3 ) == 0 )
1530
22.1k
      {
1531
22.1k
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_AUDIO_MPEG1_LAYER3;
1532
22.1k
      }
1533
33.0k
    }
1534
675k
    else if( yystack.l_mark[-1].string_value.length == 4 )
1535
4.13k
    {
1536
4.13k
      if( narrow_string_compare(
1537
4.13k
           yystack.l_mark[-1].string_value.data,
1538
4.13k
           "AIFF",
1539
4.13k
           4 ) == 0 )
1540
194
      {
1541
194
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_AUDIO_AIFF;
1542
194
      }
1543
3.94k
      else if( narrow_string_compare(
1544
3.94k
                yystack.l_mark[-1].string_value.data,
1545
3.94k
                "WAVE",
1546
3.94k
                4 ) == 0 )
1547
578
      {
1548
578
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_AUDIO_WAVE;
1549
578
      }
1550
4.13k
    }
1551
671k
    else if( yystack.l_mark[-1].string_value.length == 6 )
1552
394
    {
1553
394
      if( narrow_string_compare(
1554
394
           yystack.l_mark[-1].string_value.data,
1555
394
           "BINARY",
1556
394
           6 ) == 0 )
1557
195
      {
1558
195
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_BINARY_LITTLE_ENDIAN;
1559
195
      }
1560
394
    }
1561
671k
    else if( yystack.l_mark[-1].string_value.length == 8 )
1562
560
    {
1563
560
      if( narrow_string_compare(
1564
560
           yystack.l_mark[-1].string_value.data,
1565
560
           "MOTOROLA",
1566
560
           8 ) == 0 )
1567
194
      {
1568
194
        ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_BINARY_BIG_ENDIAN;
1569
194
      }
1570
560
    }
1571
708k
    if( libodraw_handle_append_data_file(
1572
708k
         ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1573
708k
         yystack.l_mark[-2].string_value.data,
1574
708k
         yystack.l_mark[-2].string_value.length,
1575
708k
         ( (libodraw_cue_parser_state_t *) parser_state )->file_type,
1576
708k
         ( (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
708k
    ( (libodraw_cue_parser_state_t *) parser_state )->current_file_index += 1;
1588
708k
  }
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.7k
case 71:
1597
40.7k
  {
1598
40.7k
    libodraw_cue_parser_rule_print(
1599
40.7k
     "cue_index" );
1600
1601
40.7k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_index = ( (libodraw_cue_parser_state_t *) parser_state )->current_index;
1602
1603
40.7k
    if( libodraw_cue_parser_parse_number(
1604
40.7k
         yystack.l_mark[-2].string_value.data,
1605
40.7k
         yystack.l_mark[-2].string_value.length,
1606
40.7k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_index ),
1607
40.7k
         ( (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.7k
    if( ( ( (libodraw_cue_parser_state_t *) parser_state )->current_index != 0 )
1619
26.6k
     && ( ( (libodraw_cue_parser_state_t *) parser_state )->current_index != ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_index + 1 ) ) )
1620
10
    {
1621
10
      libcerror_error_set(
1622
10
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
1623
10
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1624
10
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
1625
10
       "%s: unsupported index number - values are not sequential.",
1626
10
       libodraw_cue_parser_function );
1627
1628
10
      YYABORT;
1629
10
    }
1630
40.6k
    if( libodraw_cue_parser_parse_msf(
1631
40.6k
         yystack.l_mark[-1].string_value.data,
1632
40.6k
         yystack.l_mark[-1].string_value.length,
1633
40.6k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector ),
1634
40.6k
         ( (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.6k
    if( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector != 0 )
1648
36.0k
    {
1649
36.0k
      if( ( ( (libodraw_cue_parser_state_t *) parser_state )->current_index == 0 )
1650
22.1k
       || ( ( (libodraw_cue_parser_state_t *) parser_state )->current_index == 1 ) )
1651
35.6k
      {
1652
35.6k
        if( ( ( (libodraw_cue_parser_state_t *) parser_state )->session_number_of_sectors == 0 )
1653
35.3k
         || ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type == LIBODRAW_TRACK_TYPE_AUDIO ) )
1654
690
        {
1655
690
          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
690
          ( (libodraw_cue_parser_state_t *) parser_state )->session_number_of_sectors = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector
1667
690
                                                                                      - ( (libodraw_cue_parser_state_t *) parser_state )->previous_session_start_sector;
1668
690
        }
1669
35.6k
        if( ( ( (libodraw_cue_parser_state_t *) parser_state )->lead_out_number_of_sectors == 0 )
1670
35.3k
         || ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type == LIBODRAW_TRACK_TYPE_AUDIO ) )
1671
690
        {
1672
690
          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
690
          ( (libodraw_cue_parser_state_t *) parser_state )->lead_out_number_of_sectors = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector
1684
690
                                                                                       - ( (libodraw_cue_parser_state_t *) parser_state )->previous_lead_out_start_sector;
1685
690
        }
1686
35.6k
      }
1687
36.0k
      if( ( (libodraw_cue_parser_state_t *) parser_state )->current_index == 1 )
1688
21.8k
      {
1689
21.8k
        if( ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors == 0 )
1690
16.2k
        {
1691
16.2k
          if( ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector < ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector )
1692
2
          {
1693
2
            libcerror_error_set(
1694
2
             ( (libodraw_cue_parser_state_t *) parser_state )->error,
1695
2
             LIBCERROR_ERROR_DOMAIN_RUNTIME,
1696
2
             LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
1697
2
             "%s: invalid track start sector value precedes previous.",
1698
2
             libodraw_cue_parser_function );
1699
1700
2
            YYABORT;
1701
2
          }
1702
16.1k
          ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector
1703
16.1k
                                                                                    - ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector;
1704
16.1k
        }
1705
21.8k
      }
1706
36.0k
    }
1707
40.6k
    if( ( (libodraw_cue_parser_state_t *) parser_state )->current_index == 1 )
1708
26.2k
    {
1709
26.2k
      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
26.2k
      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
26.2k
      if( ( (libodraw_cue_parser_state_t *) parser_state )->current_track > 1 )
1750
20.7k
      {
1751
20.7k
        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.7k
        ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector
1758
20.7k
                                                                               - ( (libodraw_cue_parser_state_t *) parser_state )->file_sector;
1759
1760
20.7k
        if( libodraw_handle_append_track(
1761
20.7k
             ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1762
20.7k
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector,
1763
20.7k
             ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors,
1764
20.7k
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type,
1765
20.7k
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index,
1766
20.7k
             ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_sector,
1767
20.7k
             ( (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.7k
        if( ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index < ( (libodraw_cue_parser_state_t *) parser_state )->current_file_index )
1779
20.2k
        {
1780
20.2k
          ( (libodraw_cue_parser_state_t *) parser_state )->file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector;
1781
1782
20.2k
          ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index += 1;
1783
20.2k
        }
1784
20.7k
        ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector = ( (libodraw_cue_parser_state_t *) parser_state )->current_start_sector;
1785
20.7k
        ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors     = 0;
1786
20.7k
      }
1787
26.2k
    }
1788
40.6k
  }
1789
40.6k
break;
1790
40.6k
case 72:
1791
188
  {
1792
188
    libodraw_cue_parser_rule_print(
1793
188
     "cue_copy" );
1794
188
  }
1795
188
break;
1796
4.21k
case 73:
1797
4.21k
  {
1798
4.21k
    libodraw_cue_parser_rule_print(
1799
4.21k
     "cue_datafile" );
1800
1801
4.21k
    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
4.21k
    if( libodraw_cue_parser_parse_msf(
1813
4.21k
         yystack.l_mark[-1].string_value.data,
1814
4.21k
         yystack.l_mark[-1].string_value.length,
1815
4.21k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors ),
1816
4.21k
         ( (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
4.21k
    ( (libodraw_cue_parser_state_t *) parser_state )->file_type = LIBODRAW_FILE_TYPE_BINARY_LITTLE_ENDIAN;
1828
1829
4.21k
    if( libodraw_handle_append_data_file(
1830
4.21k
         ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1831
4.21k
         yystack.l_mark[-2].string_value.data,
1832
4.21k
         yystack.l_mark[-2].string_value.length,
1833
4.21k
         ( (libodraw_cue_parser_state_t *) parser_state )->file_type,
1834
4.21k
         ( (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
4.21k
    if( ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index < 0 )
1846
129
    {
1847
129
      ( (libodraw_cue_parser_state_t *) parser_state )->file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector;
1848
1849
129
      ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index += 1;
1850
129
    }
1851
4.21k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_sector = ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector
1852
4.21k
                                                                           - ( (libodraw_cue_parser_state_t *) parser_state )->file_sector;
1853
1854
4.21k
    if( libodraw_handle_append_track(
1855
4.21k
         ( (libodraw_cue_parser_state_t *) parser_state )->handle,
1856
4.21k
         ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_start_sector,
1857
4.21k
         ( (libodraw_cue_parser_state_t *) parser_state )->track_number_of_sectors,
1858
4.21k
         ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type,
1859
4.21k
         ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_index,
1860
4.21k
         ( (libodraw_cue_parser_state_t *) parser_state )->previous_file_sector,
1861
4.21k
         ( (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
4.21k
    ( (libodraw_cue_parser_state_t *) parser_state )->current_file_index += 1;
1873
4.21k
  }
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
19.3k
case 93:
2059
19.3k
  {
2060
19.3k
    libodraw_cue_parser_rule_print(
2061
19.3k
     "cue_track" );
2062
2063
19.3k
    if( ( (libodraw_cue_parser_state_t *) parser_state )->current_track != 0 )
2064
3
    {
2065
3
      libcerror_error_set(
2066
3
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2067
3
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2068
3
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
2069
3
       "%s: unsupported track number - only single track supported.",
2070
3
       libodraw_cue_parser_function );
2071
2072
3
      YYABORT;
2073
3
    }
2074
19.3k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type = ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type;
2075
2076
19.3k
    if( libodraw_cue_parser_parse_track_type(
2077
19.3k
         yystack.l_mark[-1].string_value.data,
2078
19.3k
         yystack.l_mark[-1].string_value.length,
2079
19.3k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type ),
2080
19.3k
         ( (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
19.3k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_index = 0;
2092
19.3k
    ( (libodraw_cue_parser_state_t *) parser_state )->current_index  = 0;
2093
19.3k
  }
2094
0
break;
2095
23.3k
case 94:
2096
23.3k
  {
2097
23.3k
    libodraw_cue_parser_rule_print(
2098
23.3k
     "cue_track" );
2099
2100
23.3k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_track = ( (libodraw_cue_parser_state_t *) parser_state )->current_track;
2101
2102
23.3k
    if( libodraw_cue_parser_parse_number(
2103
23.3k
         yystack.l_mark[-2].string_value.data,
2104
23.3k
         yystack.l_mark[-2].string_value.length,
2105
23.3k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_track ),
2106
23.3k
         ( (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
23.3k
    if( ( ( (libodraw_cue_parser_state_t *) parser_state )->current_track != 0 )
2118
14.2k
     && ( ( (libodraw_cue_parser_state_t *) parser_state )->current_track != ( ( (libodraw_cue_parser_state_t *) parser_state )->previous_track + 1 ) ) )
2119
17
    {
2120
17
      libcerror_error_set(
2121
17
       ( (libodraw_cue_parser_state_t *) parser_state )->error,
2122
17
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
2123
17
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
2124
17
       "%s: unsupported track number - values are not sequential.",
2125
17
       libodraw_cue_parser_function );
2126
2127
17
      YYABORT;
2128
17
    }
2129
23.2k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_track_type = ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type;
2130
2131
23.2k
    if( libodraw_cue_parser_parse_track_type(
2132
23.2k
         yystack.l_mark[-1].string_value.data,
2133
23.2k
         yystack.l_mark[-1].string_value.length,
2134
23.2k
         &( ( (libodraw_cue_parser_state_t *) parser_state )->current_track_type ),
2135
23.2k
         ( (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
23.2k
    ( (libodraw_cue_parser_state_t *) parser_state )->previous_index = 0;
2147
23.2k
    ( (libodraw_cue_parser_state_t *) parser_state )->current_index  = 0;
2148
23.2k
  }
2149
0
break;
2150
3.05M
    }
2151
3.05M
    yystack.s_mark -= yym;
2152
3.05M
    yystate = *yystack.s_mark;
2153
3.05M
    yystack.l_mark -= yym;
2154
3.05M
    yym = yylhs[yyn];
2155
3.05M
    if (yystate == 0 && yym == 0)
2156
813
    {
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
813
        yystate = YYFINAL;
2163
813
        *++yystack.s_mark = YYFINAL;
2164
813
        *++yystack.l_mark = yyval;
2165
813
        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
813
        if (yychar == YYEOF) goto yyaccept;
2178
0
        goto yyloop;
2179
813
    }
2180
3.05M
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
2181
1.88M
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
2182
1.00M
        yystate = yytable[yyn];
2183
2.04M
    else
2184
2.04M
        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
3.05M
    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
2191
1
    {
2192
1
        goto yyoverflow;
2193
1
    }
2194
3.05M
    *++yystack.s_mark = (YYINT) yystate;
2195
3.05M
    *++yystack.l_mark = yyval;
2196
3.05M
    goto yyloop;
2197
2198
2
yyoverflow:
2199
2
    YYERROR_CALL("yacc stack overflow");
2200
2201
700
yyabort:
2202
700
    yyfreestack(&yystack);
2203
700
    return (1);
2204
2205
813
yyaccept:
2206
813
    yyfreestack(&yystack);
2207
813
    return (0);
2208
2
}