mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-08-24 05:25:53 +03:00
120 lines
2.4 KiB
C
120 lines
2.4 KiB
C
/*
|
|
* gencat.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 "tree.h"
|
|
#include "libs.h"
|
|
#include "pdf.h"
|
|
#include "gencat.h"
|
|
|
|
|
|
int quiet = 0;
|
|
|
|
|
|
static void usage(const char *name)
|
|
{
|
|
fprintf(stderr,
|
|
"usage: %s [-F] [-d|-D] [-p] [-P] [-q] [-L libdir ...] [-l lib ...] hierarchy\n"
|
|
" %*s [descriptions ...]\n\n"
|
|
" -d dump the tree instead of generating a PDF\n"
|
|
" -D dump all the canonical component names (without aliases)\n"
|
|
" -F use fped footprints instead of KiCad components\n"
|
|
" -L libdir search all libraries in the specified directory\n"
|
|
" -l lib search the specified library\n"
|
|
" -p use portrait orientation; default: landscape\n"
|
|
" -P generate Postscript instead of PDF (mainly for debugging)\n"
|
|
" -q don't show progress\n"
|
|
, name, (int) strlen(name), "");
|
|
exit(1);
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct lib *lib = &comp_lib;
|
|
FILE *file;
|
|
int c;
|
|
int opt_dump_tree = 0, opt_dump_comp = 0, postscript = 0, portrait = 0;
|
|
char **arg;
|
|
|
|
while ((c = getopt(argc, argv, "dDFL:l:Ppq")) != EOF)
|
|
switch (c) {
|
|
case 'd':
|
|
opt_dump_tree = 1;
|
|
break;
|
|
case 'D':
|
|
opt_dump_comp = 1;
|
|
break;
|
|
case 'F':
|
|
lib = &fped_lib;
|
|
break;
|
|
case 'L':
|
|
add_libdir(lib, optarg);
|
|
break;
|
|
case 'l':
|
|
add_lib(lib, optarg);
|
|
break;
|
|
case 'P':
|
|
postscript = 1;
|
|
break;
|
|
case 'p':
|
|
portrait = 1;
|
|
break;
|
|
case 'q':
|
|
quiet = 1;
|
|
break;
|
|
default:
|
|
usage(*argv);
|
|
}
|
|
|
|
if (opt_dump_tree && opt_dump_comp)
|
|
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(lib, tree);
|
|
|
|
for (arg = argv+optind+1; *arg; arg++) {
|
|
file = fopen(*arg, "r");
|
|
if (!file) {
|
|
perror(*arg);
|
|
exit(1);
|
|
}
|
|
read_desc(file);
|
|
fclose(file);
|
|
}
|
|
if (opt_dump_tree)
|
|
dump_tree();
|
|
else if (opt_dump_comp)
|
|
dump_comp();
|
|
else
|
|
make_pdf(!postscript, portrait);
|
|
return 0;
|
|
}
|