FreeCalypso > hg > ueda-linux
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/libuschem/graphblocks.c Mon Jul 20 00:24:37 2015 +0000 @@ -0,0 +1,40 @@ +/* + * utility functions for working with graphical blocks + */ + +#include <sys/param.h> +#include <stdio.h> +#include "schemstruct.h" + +FILE * +reopen_schem_for_graphblocks(schem) + struct schem *schem; +{ + register FILE *f; + + if (!schem->has_graphblocks) + return(NULL); + f = fopen(schem->orig_filename, "r"); + if (!f) { + fprintf(stderr, "Unable to reopen %s for graphblocks: ", + schem->orig_filename); + perror(NULL); + exit(1); + } + return(f); +} + +write_graphblock_to_file(blk, inf, outf) + struct graphblock *blk; + register FILE *inf, *outf; +{ + char buf[512]; + register int cc, rem; + + fseek(inf, blk->offset, 0); + for (rem = blk->length; rem; rem -= cc) { + cc = MIN(rem, sizeof buf); + fread(buf, 1, cc, inf); + fwrite(buf, 1, cc, outf); + } +}