1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-05 07:32:49 +02:00
eda-tools/genex/genex.c
Werner Almesberger 0565adf11f genex: changed default orientation back to landscape; option -p for portrait
Since -l and -L are already taken, it's easier to make landscape the
default. genex will typically be invoked from some wrapper anyway.
2012-04-17 08:21:14 -03:00

98 lines
1.9 KiB
C

/*
* genex.c - Generate expanded component view
*
* Copyright 2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "comp.h"
#include "libs.h"
#include "pdf.h"
static void usage(const char *name)
{
fprintf(stderr,
"usage: %s [-d] [-p] [-P] [-L libdir ...] [-l lib ...] hierarchy\n"
" %*s [descriptions ...]\n\n"
" -d dump the tree instead of generating a PDF\n"
" -L libdir search all libraries in the specified directory\n"
" -l lib search the specified component library\n"
" -p use portrait orientation; default: landscape\n"
" -P generate Postscript instead of PDF (mainly for debugging)\n"
, name, (int) strlen(name), "");
exit(1);
}
int main(int argc, char **argv)
{
FILE *file;
int c;
int dump = 0, postscript = 0, portrait = 0;
char **arg;
while ((c = getopt(argc, argv, "dL:l:Pp")) != EOF)
switch (c) {
case 'd':
dump = 1;
break;
case 'L':
add_libdir(optarg);
break;
case 'l':
add_lib(optarg);
break;
case 'P':
postscript = 1;
break;
case 'p':
portrait = 1;
break;
default:
usage(*argv);
}
switch (argc-optind) {
case 1:
case 2:
break;
default:
usage(*argv);
}
file = fopen(argv[optind], "r");
if (!file) {
perror(argv[optind]);
exit(1);
}
read_tree(file);
fclose(file);
set_libs(tree, lookup_sym);
for (arg = argv+optind+1; *arg; arg++) {
file = fopen(*arg, "r");
if (!file) {
perror(*arg);
exit(1);
}
read_desc(file);
fclose(file);
}
if (dump)
dump_tree();
else
make_pdf(!postscript, portrait);
return 0;
}