int main(int argc, char **argv) { char line_buffer[1024]; /* get input variables */ if (fgets(line_buffer, 1024, stdin) == NULL) { fprintf(stderr, "fgets: crash\n"); exit(-1); } get_input_variables(line_buffer); /* get circuit spec */ if (fgets(line_buffer, 1024, stdin) == NULL) { fprintf(stderr, "fgets: crash\n"); exit(-1); } get_circuit(line_buffer); replace_labels(circuit); /* evaluate until eof */ while (fgets(line_buffer, 1024, stdin) != NULL) { set_inputs(line_buffer); final_val = evaluate(circuit); } printf("Result: %d\n", final_val); free_element(circuit); exit(0); }
void compile(t_cmd *line, char *path) { char *header[2]; t_cmd *asms[3]; int pos; header[0] = header[1] = NULL; asms[2] = NULL; pos = 0; *asms = line; while (line) { line->bin_size = -1; asms[1] = line->next; treat_asm(line, header, asms, &pos); line = asms[1]; } replace_labels(*asms, asms[2]); export_bin(*asms, header, pos, path); my_putstr(GREEN "Compilation succeed.\n" BLANK); my_putstr("Output file : "); my_putstr(path); my_putstr(".cor"); my_putchar('\n'); }