int command_parse_file(FILE * fp) { char buffer[4096]; char *p = buffer; int linenumber = 0; while (linenumber++, fgets(p, sizeof (buffer) - (p - buffer), fp)) { int bufferlen = strlen(buffer); if ((bufferlen - 2 >= 0) && buffer[bufferlen - 2] == '\\') { /* line continuation character, read another line into the buffer */ linenumber--; p = buffer + bufferlen - 2; continue; } if (command_parse_string(buffer)) { /* buffer already has an \n */ if_print_message("Error parsing line %d: %s", linenumber, buffer); /* return -1; don't return, lets keep parsing the file. */ } p = buffer; } return 0; }
static void if_run_command(struct sviewer *sview, struct ibuf *ibuf_command) { char *command = ibuf_get(ibuf_command); /* refresh and return if the user entered no data */ if (ibuf_length(ibuf_command) == 0) { if_draw(); return; } if (command_parse_string(command)) { if_display_message("Unknown command: ", 0, "%s", command); } else { update_status_win(); } if_draw(); }