2012-03-31 00:53:51 +03:00
|
|
|
/*
|
|
|
|
* 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>
|
2012-04-17 14:17:34 +03:00
|
|
|
#include <string.h>
|
2012-03-31 00:53:51 +03:00
|
|
|
|
|
|
|
#include "comp.h"
|
|
|
|
#include "libs.h"
|
2012-04-12 05:10:42 +03:00
|
|
|
#include "pdf.h"
|
2012-03-31 00:53:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
static void usage(const char *name)
|
|
|
|
{
|
2012-04-16 21:55:48 +03:00
|
|
|
fprintf(stderr,
|
2012-04-17 14:21:14 +03:00
|
|
|
"usage: %s [-d] [-p] [-P] [-L libdir ...] [-l lib ...] hierarchy\n"
|
2012-04-17 14:17:34 +03:00
|
|
|
" %*s [descriptions ...]\n\n"
|
2012-04-17 11:43:46 +03:00
|
|
|
" -d dump the tree instead of generating a PDF\n"
|
2012-04-16 21:55:48 +03:00
|
|
|
" -L libdir search all libraries in the specified directory\n"
|
|
|
|
" -l lib search the specified component library\n"
|
2012-04-17 14:21:14 +03:00
|
|
|
" -p use portrait orientation; default: landscape\n"
|
2012-04-17 14:17:34 +03:00
|
|
|
" -P generate Postscript instead of PDF (mainly for debugging)\n"
|
|
|
|
, name, (int) strlen(name), "");
|
2012-03-31 00:53:51 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
FILE *file;
|
|
|
|
int c;
|
2012-04-17 14:21:14 +03:00
|
|
|
int dump = 0, postscript = 0, portrait = 0;
|
2012-04-17 11:39:32 +03:00
|
|
|
char **arg;
|
2012-03-31 00:53:51 +03:00
|
|
|
|
2012-04-17 14:21:14 +03:00
|
|
|
while ((c = getopt(argc, argv, "dL:l:Pp")) != EOF)
|
2012-03-31 00:53:51 +03:00
|
|
|
switch (c) {
|
2012-04-17 11:43:46 +03:00
|
|
|
case 'd':
|
|
|
|
dump = 1;
|
|
|
|
break;
|
2012-03-31 00:53:51 +03:00
|
|
|
case 'L':
|
|
|
|
add_libdir(optarg);
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
add_lib(optarg);
|
|
|
|
break;
|
2012-04-17 14:17:34 +03:00
|
|
|
case 'P':
|
|
|
|
postscript = 1;
|
|
|
|
break;
|
2012-04-17 14:21:14 +03:00
|
|
|
case 'p':
|
|
|
|
portrait = 1;
|
|
|
|
break;
|
2012-03-31 00:53:51 +03:00
|
|
|
default:
|
|
|
|
usage(*argv);
|
|
|
|
}
|
|
|
|
|
2012-04-17 11:39:32 +03:00
|
|
|
switch (argc-optind) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
default:
|
2012-03-31 00:53:51 +03:00
|
|
|
usage(*argv);
|
2012-04-17 11:39:32 +03:00
|
|
|
}
|
2012-03-31 00:53:51 +03:00
|
|
|
|
|
|
|
file = fopen(argv[optind], "r");
|
|
|
|
if (!file) {
|
|
|
|
perror(argv[optind]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
read_tree(file);
|
|
|
|
fclose(file);
|
2012-04-17 11:39:32 +03:00
|
|
|
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);
|
|
|
|
}
|
2012-04-17 11:43:46 +03:00
|
|
|
if (dump)
|
|
|
|
dump_tree();
|
|
|
|
else
|
2012-04-17 14:21:14 +03:00
|
|
|
make_pdf(!postscript, portrait);
|
2012-03-31 00:53:51 +03:00
|
|
|
return 0;
|
|
|
|
}
|