FreeCalypso > hg > ueda-linux
comparison ueda/libuschem/graphblocks.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 * utility functions for working with graphical blocks | |
3 */ | |
4 | |
5 #include <sys/param.h> | |
6 #include <stdio.h> | |
7 #include "schemstruct.h" | |
8 | |
9 FILE * | |
10 reopen_schem_for_graphblocks(schem) | |
11 struct schem *schem; | |
12 { | |
13 register FILE *f; | |
14 | |
15 if (!schem->has_graphblocks) | |
16 return(NULL); | |
17 f = fopen(schem->orig_filename, "r"); | |
18 if (!f) { | |
19 fprintf(stderr, "Unable to reopen %s for graphblocks: ", | |
20 schem->orig_filename); | |
21 perror(NULL); | |
22 exit(1); | |
23 } | |
24 return(f); | |
25 } | |
26 | |
27 write_graphblock_to_file(blk, inf, outf) | |
28 struct graphblock *blk; | |
29 register FILE *inf, *outf; | |
30 { | |
31 char buf[512]; | |
32 register int cc, rem; | |
33 | |
34 fseek(inf, blk->offset, 0); | |
35 for (rem = blk->length; rem; rem -= cc) { | |
36 cc = MIN(rem, sizeof buf); | |
37 fread(buf, 1, cc, inf); | |
38 fwrite(buf, 1, cc, outf); | |
39 } | |
40 } |