summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-04 01:55:29 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-04 02:11:45 (GMT)
commit9132d430693cfda5e0c046a902cab469f83418de (patch)
tree3ddfe6bb9b282f9b70464bb0a5016a1b3c55e8a2
parent1eebec29e302f07a77cfcfa6db5a08dedc727eda (diff)
downloadeeshow-9132d430693cfda5e0c046a902cab469f83418de.zip
eeshow-9132d430693cfda5e0c046a902cab469f83418de.tar.gz
eeshow-9132d430693cfda5e0c046a902cab469f83418de.tar.bz2
main/eediff.c: the big leap - use diff_process_file (WIP)
There is still some cleanup left to do, including doing something about -e and -1.
-rw-r--r--gfx/diff.c6
-rw-r--r--gfx/diff.h6
-rw-r--r--main/eediff.c70
3 files changed, 9 insertions, 73 deletions
diff --git a/gfx/diff.c b/gfx/diff.c
index 824b37f..bbb8142 100644
--- a/gfx/diff.c
+++ b/gfx/diff.c
@@ -150,7 +150,7 @@ static void *diff_init(void)
}
-static void *diff_process_file(struct diff *diff, struct file_names *file_names,
+void *diff_process_file(struct diff *diff, struct file_names *file_names,
int argc, char *const *argv, const char *opts)
{
struct file_names *fn = file_names;
@@ -242,10 +242,6 @@ static bool diff_args(void *ctx, int argc, char *const *argv, const char *opts)
diff->new_gfx = diff_process_file(diff, &file_names, argc, argv, opts);
free_file_names(&file_names);
- diff->gfx = gfx_init(&cro_img_ops);
- if (!diff->gfx)
- return 0;
-
return gfx_args(diff->gfx, argc, argv, opts);
}
diff --git a/gfx/diff.h b/gfx/diff.h
index 5bee90c..90eb66d 100644
--- a/gfx/diff.h
+++ b/gfx/diff.h
@@ -20,6 +20,7 @@
#include "gfx/gfx.h"
#include "gfx/cro.h"
+#include "kicad/ext.h"
extern const struct gfx_ops diff_ops;
@@ -31,6 +32,8 @@ struct area {
struct area *next;
};
+struct diff;
+
void add_area(struct area **areas, int xa, int ya, int xb, int yb,
uint32_t color);
@@ -41,4 +44,7 @@ void diff_to_canvas(cairo_t *cr, int cx, int cy, float scale,
struct cro_ctx *new, struct cro_ctx *new_extra,
const struct area *areas);
+void *diff_process_file(struct diff *diff, struct file_names *file_names,
+ int argc, char *const *argv, const char *opts);
+
#endif /* !GFX_DIFF_H */
diff --git a/main/eediff.c b/main/eediff.c
index 16653f1..feba8cd 100644
--- a/main/eediff.c
+++ b/main/eediff.c
@@ -69,17 +69,11 @@ void usage(const char *name)
int main(int argc, char **argv)
{
- struct lib lib;
- struct sch_ctx sch_ctx;
- struct file pro_file, sch_file;
bool extra = 0;
bool one_sheet = 0;
- struct pl_ctx *pl = NULL;
char c;
int dashdash;
- unsigned i;
struct file_names file_names;
- struct file_names *fn = &file_names;
int gfx_argc;
char **gfx_argv;
struct gfx *gfx;
@@ -141,12 +135,6 @@ int main(int argc, char **argv)
sizeof(const char *) * (gfx_argc + 1));
}
- if (file_names.pro) {
- if (!file_open(&pro_file, file_names.pro, NULL))
- return 1;
- fn = pro_parse_file(&pro_file, &file_names);
- }
-
gfx = gfx_init(&diff_ops);
if (!gfx_args(gfx, gfx_argc, gfx_argv, OPTIONS))
return 1;
@@ -155,67 +143,13 @@ int main(int argc, char **argv)
free(gfx_argv);
- sch_init(&sch_ctx, !one_sheet);
- if (!file_open(&sch_file, fn->sch, file_names.pro ? &pro_file : NULL))
+ if (!diff_process_file(gfx_user(gfx), &file_names,
+ dashdash - optind - 1, argv + optind + 1, OPTIONS))
return 1;
-
- lib_init(&lib);
- for (i = 0; i != fn->n_libs; i++)
- if (!lib_parse(&lib, fn->libs[i],
- file_names.pro ? &pro_file : &sch_file))
- return 1;
-
- if (file_names.pro)
- file_close(&pro_file);
-
- if (fn->pl) {
- struct file file;
-
- if (!file_open(&file, fn->pl, &sch_file))
- return 1;
- pl = pl_parse(&file);
- file_close(&file);
- if (!pl)
- return 1;
- }
-
- if (fn != &file_names) {
- free_file_names(fn);
- free(fn);
- }
free_file_names(&file_names);
- if (!sch_parse(&sch_ctx, &sch_file, &lib, NULL))
- return 1;
- file_close(&sch_file);
-
- if (one_sheet) {
- sch_render(sch_ctx.sheets, gfx);
- if (extra)
- sch_render_extra(sch_ctx.sheets, gfx);
- if (pl)
- pl_render(pl, gfx, sch_ctx.sheets, sch_ctx.sheets);
- } else {
- const struct sheet *sheet;
-
- for (sheet = sch_ctx.sheets; sheet; sheet = sheet->next) {
- gfx_sheet_name(gfx, sheet->title);
- sch_render(sheet, gfx);
- if (extra)
- sch_render_extra(sheet, gfx);
- if (pl)
- pl_render(pl, gfx, sch_ctx.sheets, sheet);
- if (sheet->next)
- gfx_new_sheet(gfx);
- }
- }
retval = gfx_end(gfx);
- sch_free(&sch_ctx);
- lib_free(&lib);
- if (pl)
- pl_free(pl);
-
file_cleanup();
cairo_debug_reset_static_data();