summaryrefslogtreecommitdiff
path: root/kicad/pro.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-06 17:41:37 -0300
committerWerner Almesberger <werner@almesberger.net>2016-09-06 23:58:14 -0300
commit6dbc788e8c015a6d63848d00f7a241518dc39210 (patch)
tree3b6868a066b82e7a701cb76a263fed5a9b921136 /kicad/pro.c
parentdb112f168a9cea55c0bbc3085e4a19a406c34de7 (diff)
downloadeeshow-6dbc788e8c015a6d63848d00f7a241518dc39210.tar.gz
eeshow-6dbc788e8c015a6d63848d00f7a241518dc39210.tar.bz2
eeshow-6dbc788e8c015a6d63848d00f7a241518dc39210.zip
kicad/: record LibDir path in "struct file_names"
Diffstat (limited to 'kicad/pro.c')
-rw-r--r--kicad/pro.c29
1 files changed, 29 insertions, 0 deletions
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);
}