int parse_scene(t_list **tokens) { if (parse_camera(tokens) == 0) return (0); if (parse_window(tokens) == 0) return (0); return (1); }
int WParse::parse(FILE* fp) { unsigned int line = 1; unsigned int max_tags=1024; err=0; num_plots=0; sp = new SetParse*[max_tags]; bool valid_section_tag = false; if (!fp) return ERR_NOFILE; else while (!feof(fp)) { int t=0; char ch; bool valid_att_tag = false, valid_sub_tag = false; char tmpstr[MAX_TAG_LENGTH]; do { do { ch=getc(fp); if (ch=='\n') line++; } while ((ch!='<')&&(!feof(fp))); // wait for a '<' t=0; do { ch=getc(fp); tmpstr[t++]=ch; if (ch=='\n') line++; } while ((ch!=' ')&&(ch!='\t')&& (ch!='\n')&&(ch!='\r')&&(ch!='>')&&(!feof(fp))); tmpstr[t-1]='\0'; // extract the word following the '<' int i; for (i=0; i<NUM_SUBTAGS; i++) // sub tag ? if (strcasecmp(tmpstr,sub_tags[i])==0) valid_sub_tag=true; if (valid_section_tag) // we're in <window> { for (i=0; i<NUM_A_WTAGS; i++) // window tag? if (strcasecmp(tmpstr,window_att_tags[i])==0) valid_att_tag=true; } if (strcasecmp(tmpstr,"window")==0) { valid_section_tag=true; valid_sub_tag=true; } } while (!feof(fp)&&(!valid_att_tag)&&(!valid_sub_tag)); if (feof(fp)) return err; if (sp_size<max_tags) { if (valid_section_tag) parse_window(fp,tmpstr,line,valid_sub_tag,valid_att_tag); } else { // too many tags: array is overflowing!setparse err = ERR_TAGOVERFLOW; errline = line; } } fclose(fp); return err; // got error? }
static void load_file (GFile *file) { GdkWindow *window; char *data; char **lines, **l; if (g_file_load_contents (file, NULL, &data, NULL, NULL, NULL)) { window = gtk_widget_get_window (darea); destroy_children (window); lines = g_strsplit (data, "\n", -1); l = lines; while (*l != NULL) l = parse_window (window, l); } update_store (); }