341
341
static unsigned int printer_subsys_count =
342
342
sizeof (printer_subsystems) / sizeof (struct printer_subsys);
344
static unsigned int g_record[10000];
344
#define G_RECORD_SIZE 10000
346
static uint32_t g_record[G_RECORD_SIZE];
347
349
* Copy record, dealing with wrapping
349
351
static int logsys_rec_get (int rec_idx) {
350
unsigned int rec_size;
351
353
int firstcopy, secondcopy;
353
355
rec_size = flt_data[rec_idx];
355
357
firstcopy = rec_size;
360
if (rec_size > G_RECORD_SIZE || rec_size > flt_data_size) {
361
fprintf (stderr, "rec_size too large. Input file is probably corrupted.\n");
357
365
if (firstcopy + rec_idx > flt_data_size) {
358
366
firstcopy = flt_data_size - rec_idx;
359
367
secondcopy -= firstcopy - rec_size;
361
memcpy (&g_record[0], &flt_data[rec_idx], firstcopy<<2);
369
memcpy (&g_record[0], &flt_data[rec_idx], firstcopy * sizeof(uint32_t));
362
370
if (secondcopy) {
363
memcpy (&g_record[firstcopy], &flt_data[0], secondcopy<<2);
371
memcpy (&g_record[firstcopy], &flt_data[0], secondcopy * sizeof(uint32_t));
365
373
return ((rec_idx + rec_size) % flt_data_size);
368
376
static void logsys_rec_print (const void *record)
370
const unsigned int *buf_uint32t = record;
371
unsigned int rec_size;
372
unsigned int rec_ident;
375
unsigned int arg_size_idx;
378
const uint32_t *buf_uint32t = record;
383
uint32_t arg_size_idx;
378
386
unsigned int rec_idx = 0;
379
unsigned int record_number;
387
uint32_t record_number;
380
388
unsigned int words_processed;
381
389
unsigned int found;
382
390
const char *arguments[64];
472
480
return EXIT_FAILURE;
475
n_required = sizeof (unsigned int);
483
n_required = sizeof (uint32_t);
476
484
n_read = read (fd, &flt_data_size, n_required);
477
485
if (n_read != n_required) {
478
486
fprintf (stderr, "Unable to read fdata header\n");
479
487
return EXIT_FAILURE;
482
n_required = ((flt_data_size + 2) * sizeof(unsigned int));
490
n_required = ((flt_data_size + 2) * sizeof(uint32_t));
484
492
if ((flt_data = malloc (n_required)) == NULL) {
485
493
fprintf (stderr, "exhausted virtual memory\n");
496
504
if (n_read != n_required) {
497
printf ("Warning: read %lu bytes, but expected %lu\n",
498
(unsigned long) n_read, (unsigned long) n_required);
505
printf ("Warning: read %zd bytes, but expected %zu\n",
501
509
rec_idx = flt_data[FDTAIL_INDEX];