mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-02 18:57:31 +02:00
71aeab9ab8
This is to allow further I/O abstraction, later.
90 lines
1.7 KiB
C
90 lines
1.7 KiB
C
/*
|
|
* main.c - Convert Eeschema schematics to FIG
|
|
*
|
|
* Written 2016 by Werner Almesberger
|
|
* Copyright 2016 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 "fig.h"
|
|
#include "cairo.h"
|
|
#include "gfx.h"
|
|
#include "file.h"
|
|
#include "lib.h"
|
|
#include "sch.h"
|
|
|
|
|
|
static bool do_sch_parse(void *user, const char *line)
|
|
{
|
|
return sch_parse(user, line);
|
|
}
|
|
|
|
|
|
static bool do_lib_parse(void *user, const char *line)
|
|
{
|
|
return lib_parse(user, line);
|
|
}
|
|
|
|
|
|
static void usage(const char *name)
|
|
{
|
|
fprintf(stderr,
|
|
"usage: %s [-t template.fig] [-Dvar=value ...] [file.lib ...] file.sch\n",
|
|
name);
|
|
exit(1);
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct sch_ctx sch_ctx;
|
|
const char *template = NULL;
|
|
char c;
|
|
int arg;
|
|
int n_vars = 0;
|
|
const char **vars = NULL;
|
|
|
|
while ((c = getopt(argc, argv, "t:D:")) != EOF)
|
|
switch (c) {
|
|
case 't':
|
|
template = optarg;
|
|
break;
|
|
case 'D':
|
|
if (!strchr(optarg, '='))
|
|
usage(*argv);
|
|
n_vars++;
|
|
vars = realloc(vars, sizeof(const char *) * n_vars);
|
|
vars[n_vars - 1] = optarg;
|
|
break;
|
|
default:
|
|
usage(*argv);
|
|
}
|
|
|
|
if (argc - optind < 1)
|
|
usage(*argv);
|
|
|
|
for (arg = optind; arg != argc - 1; arg++) {
|
|
struct lib_ctx ctx;
|
|
|
|
lib_init(&ctx);
|
|
file_read(argv[arg], do_lib_parse, &ctx);
|
|
}
|
|
|
|
sch_init(&sch_ctx);
|
|
file_read(argv[argc - 1], do_sch_parse, &sch_ctx);
|
|
gfx_init(&fig_ops, template, n_vars, vars);
|
|
//gfx_init(&cairo_ops, template, n_vars, vars);
|
|
sch_render(&sch_ctx);
|
|
gfx_end();
|
|
}
|