view ueda/libuschem/rdschem.c @ 61:ff1d565d233c

pads2gpcb: handle dummy decals with no pins (found in the E-Sample PCB)
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 31 Jan 2016 05:02:49 +0000
parents cd92449fdb51
children
line wrap: on
line source

/*
 * Schematic read-in main routine
 */

#include <sys/types.h>
#include <stdio.h>
#include "schemstruct.h"
#include "parserint.h"

extern char *malloc();

struct schem_parse_state schem_parse_state;

struct schem *
read_schem(filename)
	char *filename;
{
	FILE *f;
	struct schem *schem;
	register int i;

	f = fopen(filename, "r");
	if (!f) {
		perror(filename);
		exit(1);
	}

	schem = (struct schem *) malloc(sizeof(struct schem));
	if (!schem) {
		perror("malloc");
		exit(1);
	}
	bzero(schem, sizeof(struct schem));
	schem->obj_next = (struct schemobj *) schem;
	schem->obj_prev = (struct schemobj *) schem;
	schem->orig_filename = filename;

	schem_parse_state.schem = schem;
	schem_parse_state.file = f;
	schem_parse_state.lineno = 1;
	schem_parse_state.pushback_token = 0;

	/* call the meat of the parser */
	rdschem_parse_schemline();
	do
		i = rdschem_parse_object();
	while (!i);

	fclose(f);
	return(schem);
}

rdschem_error(msg)
	char *msg;
{
	fprintf(stderr, "%s: line %d: %s\n",
		schem_parse_state.schem->orig_filename,
		schem_parse_state.lineno, msg);
	exit(1);
}