Diff

Differences From Artifact [a3ef943f52]:

To Artifact [6584aa9678]:


324
325
326
327
328
329
330
331

332
333
334

335
336
337
338
339
340
341
342
343
344
345
346
347

348
349
350
351
352
353
354
324
325
326
327
328
329
330

331
332

333
334
335
336
337





338
339
340
341

342
343
344
345
346
347
348
349







-
+

-

+



-
-
-
-
-




-
+







	} else {
		fprintf(outfp, "@INVALID@%s@INVALID@", buffer_p);
	}

	return;
}

static int parse_xvfs_minirivet(FILE *outfp, const char * const file, const struct options * const options) {
static int parse_xvfs_minirivet(FILE *outfp, const char * const template, const struct options * const options) {
	struct xvfs_state xvfs_state;
	FILE *fp;
	int ch, ch_buf;
	int template_idx = 0;
	char tcl_buffer[8192], *tcl_buffer_p;
	enum xvfs_minirivet_mode mode;

	fp = fopen(file, "r");
	if (!fp) {
		return(0);
	}

	xvfs_state.child_count = 0;
	xvfs_state.child_len   = 65536;
	xvfs_state.children    = malloc(sizeof(*xvfs_state.children) * xvfs_state.child_len);

#define parse_xvfs_minirivet_getbyte(var) var = fgetc(fp); if (var == EOF) { break; }
#define parse_xvfs_minirivet_getbyte(var) var = template[template_idx]; template_idx++; if (var == 0) { break; }

	mode = XVFS_MINIRIVET_MODE_COPY;
	tcl_buffer_p = NULL;
	while (1) {
		parse_xvfs_minirivet_getbyte(ch);

		switch (mode) {
410
411
412
413
414
415
416




















417

418
419
420


421






422
423















424
425
426
427
428
429
430
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431

432
433


434
435
436
437
438
439
440
441
442


443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+

-
-
+
+

+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







				tcl_buffer_p++;
				break;
		}
	}

#undef parse_xvfs_minirivet_getbyte

	return(1);
}

static int xvfs_create(FILE *outfp, const struct options * const options) {
	const int template_len = 65536;
	const char * const template_file = "lib/xvfs/xvfs.c.rvt";
	FILE *fp;
	char *template, *template_p;
	int template_remain;
	size_t fread_ret;
	int retval;

	fp = fopen(template_file, "r");
	if (!fp) {
		return(0);
	}

	template = malloc(template_len);
	template_remain = template_len;
	if (!template) {
	fclose(fp);
		fclose(fp);

	return(1);
}
		return(0);
	}

	template_p = template;
	while (1) {
		fread_ret = fread(template_p, 1, template_remain, fp);
		if (fread_ret <= 0) {
			break;
		}
static int xvfs_create(FILE *outfp, const struct options * const options) {
	return(parse_xvfs_minirivet(outfp, "lib/xvfs/xvfs.c.rvt", options));

		template_p += fread_ret;
		template_remain -= fread_ret;
	}
	if (template_remain > 0) {
		*template_p = '\0';
	}

	fclose(fp);

	retval = parse_xvfs_minirivet(outfp, template, options);

	free(template);

	return(retval);
}

/*
 * Parse command line options
 */
static int parse_options(int argc, char **argv, struct options *options) {
	char *arg;