Index: trunk/src/view.c =================================================================== --- trunk/src/view.c (revision 21332) +++ trunk/src/view.c (revision 21333) @@ -330,6 +330,23 @@ return view_load_post(ctx); } +void *pcb_view_load_start_file(FILE *f) +{ + int c; + load_ctx_t *ctx = malloc(sizeof(load_ctx_t)); + + ctx->doc = lht_dom_init(); + + while((c = fgetc(f)) != EOF) { + lht_err_t err = lht_dom_parser_char(ctx->doc, c); + if ((err != LHTE_SUCCESS) && (err != LHTE_STOP)) { + pcb_view_load_end(ctx); + return NULL; + } + } + return view_load_post(ctx); +} + #define LOADERR "Error loading view: " static void pcb_view_load_objs(pcb_view_t *dst, int grp, lht_node_t *olist) Index: trunk/src/view.h =================================================================== --- trunk/src/view.h (revision 21332) +++ trunk/src/view.h (revision 21333) @@ -28,6 +28,7 @@ #ifndef PCB_VIEW_H #define PCB_VIEW_H +#include #include #include #include "unit.h" @@ -126,8 +127,10 @@ /*** Load a serialized view (or list of views) ***/ -/* Parse a serialized string into memory; returns a load_ctx or NULL on error */ +/* Parse a serialized string/file into memory; returns a load_ctx or NULL on + error. Does not close the file. */ void *pcb_view_load_start_str(const char *src); +void *pcb_view_load_start_file(FILE *f); /* Load the next item from load_ctx; returns NULL on error if there are no more items. If dst is not NULL, it's returned on success; else a newly