FreeCalypso > hg > ueda-linux
view ueda/uschem-print/main.c @ 92:e147e428b417
ifctf-part-lib/footprints/SN74AVC4T774PW.fp: created based on datasheet
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 15 Dec 2018 23:34:05 +0000 |
parents | cd92449fdb51 |
children |
line wrap: on
line source
#include <sys/types.h> #include <stdio.h> #include "../libuschem/schemstruct.h" extern char *malloc(); extern int optind; extern char *optarg; extern char *MCLfile; extern struct schem *read_schem(); extern char default_prefs_pathname[]; struct schem **schem_pages; int npages; char *prefs_file = default_prefs_pathname; int printsize_x = 1224, printsize_y = 792, printmargin; main(argc, argv) char **argv; { register int c; register struct schem *schem; while ((c = getopt(argc, argv, "I:m:M:p:P:")) != EOF) switch (c) { case 'I': add_symfile_dir(optarg); break; case 'm': printmargin = atoi(optarg); break; case 'M': MCLfile = optarg; break; case 'p': prefs_file = optarg; break; case 'P': set_paper_size(optarg); break; default: usage: fprintf(stderr, "usage: %s [-options] schemfile...\n", argv[0]); exit(1); } if (!argv[optind]) goto usage; npages = argc - optind; read_MCL(); hash_MCL(); set_default_sympath(); read_pinouts(); schem_pages = (struct schem **) malloc(sizeof(struct schem *) * npages); if (!schem_pages) { perror("malloc"); exit(1); } for (c = 0; c < npages; c++) { schem = read_schem(argv[optind+c]); if (!schem->is_graph) { fprintf(stderr, "%s: non-graphical schematic cannot be printed\n", schem->orig_filename); exit(1); } schem_pages[c] = schem; match_schem_to_mcl(schem); load_graphsyms(schem); instantiate_graphsym_pins(schem, 0); /* for SymOnPin */ } emit_header(); emit_prolog(); emit_setup(); for (c = 0; c < npages; c++) print_schem_page(c); puts("%%Trailer"); puts("%%EOF"); exit(0); } emit_header() { puts("%!PS-Adobe-3.0"); puts("%%Creator: uschem-print"); puts("%%LanguageLevel: 2"); puts("%%Orientation: Landscape"); printf("%%%%Pages: %d\n", npages); puts("%%EndComments"); } emit_setup() { puts("%%BeginSetup"); printf("/printsize_x %d def\n", printsize_x); printf("/printsize_y %d def\n", printsize_y); puts("<< /PageSize [printsize_x printsize_y] >> setpagedevice"); printf("/printmargin %d def\n", printmargin); puts("$uschem begin"); emit_file(prefs_file); puts("end"); puts("%%EndSetup"); } emit_file(pathname) char *pathname; { register FILE *f; char buf[512]; register int cc; f = fopen(pathname, "r"); if (!f) { perror(pathname); exit(1); } while ((cc = fread(buf, 1, sizeof buf, f)) > 0) fwrite(buf, 1, cc, stdout); fclose(f); }