FreeCalypso > hg > ueda-linux
comparison ueda/libuschem/rdschem.c @ 0:cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
| author | Space Falcon <falcon@ivan.Harhan.ORG> |
|---|---|
| date | Mon, 20 Jul 2015 00:24:37 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:cd92449fdb51 |
|---|---|
| 1 /* | |
| 2 * Schematic read-in main routine | |
| 3 */ | |
| 4 | |
| 5 #include <sys/types.h> | |
| 6 #include <stdio.h> | |
| 7 #include "schemstruct.h" | |
| 8 #include "parserint.h" | |
| 9 | |
| 10 extern char *malloc(); | |
| 11 | |
| 12 struct schem_parse_state schem_parse_state; | |
| 13 | |
| 14 struct schem * | |
| 15 read_schem(filename) | |
| 16 char *filename; | |
| 17 { | |
| 18 FILE *f; | |
| 19 struct schem *schem; | |
| 20 register int i; | |
| 21 | |
| 22 f = fopen(filename, "r"); | |
| 23 if (!f) { | |
| 24 perror(filename); | |
| 25 exit(1); | |
| 26 } | |
| 27 | |
| 28 schem = (struct schem *) malloc(sizeof(struct schem)); | |
| 29 if (!schem) { | |
| 30 perror("malloc"); | |
| 31 exit(1); | |
| 32 } | |
| 33 bzero(schem, sizeof(struct schem)); | |
| 34 schem->obj_next = (struct schemobj *) schem; | |
| 35 schem->obj_prev = (struct schemobj *) schem; | |
| 36 schem->orig_filename = filename; | |
| 37 | |
| 38 schem_parse_state.schem = schem; | |
| 39 schem_parse_state.file = f; | |
| 40 schem_parse_state.lineno = 1; | |
| 41 schem_parse_state.pushback_token = 0; | |
| 42 | |
| 43 /* call the meat of the parser */ | |
| 44 rdschem_parse_schemline(); | |
| 45 do | |
| 46 i = rdschem_parse_object(); | |
| 47 while (!i); | |
| 48 | |
| 49 fclose(f); | |
| 50 return(schem); | |
| 51 } | |
| 52 | |
| 53 rdschem_error(msg) | |
| 54 char *msg; | |
| 55 { | |
| 56 fprintf(stderr, "%s: line %d: %s\n", | |
| 57 schem_parse_state.schem->orig_filename, | |
| 58 schem_parse_state.lineno, msg); | |
| 59 exit(1); | |
| 60 } |
