summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-06 20:41:37 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-07 02:58:14 (GMT)
commit6dbc788e8c015a6d63848d00f7a241518dc39210 (patch)
tree3b6868a066b82e7a701cb76a263fed5a9b921136 /kicad
parentdb112f168a9cea55c0bbc3085e4a19a406c34de7 (diff)
downloadeeshow-6dbc788e8c015a6d63848d00f7a241518dc39210.zip
eeshow-6dbc788e8c015a6d63848d00f7a241518dc39210.tar.gz
eeshow-6dbc788e8c015a6d63848d00f7a241518dc39210.tar.bz2
kicad/: record LibDir path in "struct file_names"
Diffstat (limited to 'kicad')
-rw-r--r--kicad/ext.c16
-rw-r--r--kicad/ext.h2
-rw-r--r--kicad/pro.c29
3 files changed, 43 insertions, 4 deletions
diff --git a/kicad/ext.c b/kicad/ext.c
index 165687a..13f244d 100644
--- a/kicad/ext.c
+++ b/kicad/ext.c
@@ -51,13 +51,13 @@ static void do_classify_files_ab(struct file_names *a, struct file_names *b,
enum ext ext;
a->pro = a->sch = a->pl = NULL;
- a->libs = NULL;
- a->n_libs = 0;
+ a->libs = a->search = NULL;
+ a->n_libs = a->n_search = 0;
if (b) {
b->pro = b->sch = b->pl = NULL;
- b->libs = NULL;
- b->n_libs = 0;
+ b->libs = b->search = NULL;
+ b->n_libs = b->n_search = 0;
}
fn = a;
@@ -138,13 +138,18 @@ struct file_names *clone_file_names(const struct file_names *fn)
new->sch = fn && fn->sch ? stralloc(fn->sch) : NULL;
new->pl = fn && fn->pl ? stralloc(fn->pl) : NULL;
new->n_libs = fn ? fn->n_libs : 0;
+ new->n_search = fn ? fn->n_search : 0;
if (!fn) {
new->libs = NULL;
+ new->search = NULL;
return new;
}
new->libs = alloc_type_n(const char *, fn->n_libs);
for (i = 0; i != fn->n_libs; i++)
new->libs[i] = stralloc(fn->libs[i]);
+ new->search = alloc_type_n(const char *, fn->n_search);
+ for (i = 0; i != fn->n_search; i++)
+ new->search[i] = stralloc(fn->search[i]);
return new;
}
@@ -159,4 +164,7 @@ void free_file_names(struct file_names *fn)
for (i = 0; i != fn->n_libs; i++)
free((void *) fn->libs[i]);
free(fn->libs);
+ for (i = 0; i != fn->n_search; i++)
+ free((void *) fn->search[i]);
+ free(fn->search);
}
diff --git a/kicad/ext.h b/kicad/ext.h
index 8c8ba67..77d66a4 100644
--- a/kicad/ext.h
+++ b/kicad/ext.h
@@ -29,6 +29,8 @@ struct file_names {
const char *pl; /* just one allowed, may be NULL */
const char **libs;
unsigned n_libs;
+ const char **search; /* search paths from LibDir */
+ unsigned n_search;
};
diff --git a/kicad/pro.c b/kicad/pro.c
index a113ba1..d1e793c 100644
--- a/kicad/pro.c
+++ b/kicad/pro.c
@@ -27,11 +27,29 @@ struct pro_ctx {
pro_idle,
pro_libs, // [eeschema/libraries]
pro_editor, // [schematic_editor]
+ pro_eeschema, // [eeschema]
} state;
struct file_names *fn;
};
+static void add_libdir(struct file_names *fn, char *s)
+{
+ char *p;
+
+ while (1) {
+ p = strtok(s, ":;");
+ if (!p)
+ break;
+ s = NULL;
+ fn->n_search++;
+ fn->search =
+ realloc_type_n(fn->search, const char *, fn->n_search);
+ fn->search[fn->n_search - 1] = stralloc(p);
+ }
+}
+
+
static bool pro_parse_line(const struct file *file,
void *user, const char *line)
{
@@ -46,6 +64,10 @@ static bool pro_parse_line(const struct file *file,
pro->state = pro_editor;
return 1;
}
+ if (strbegins(line, "[eeschema]")) {
+ pro->state = pro_eeschema;
+ return 1;
+ }
if (*line == '[') {
pro->state = pro_idle;
return 1;
@@ -77,6 +99,13 @@ static bool pro_parse_line(const struct file *file,
return 1;
}
break;
+ case pro_eeschema:
+ if (sscanf(line, "LibDir=%ms", &s) == 1) {
+ add_libdir(pro->fn, s);
+ free(s);
+ return 1;
+ }
+ break;
default:
BUG("invalid state %d", pro->state);
}