#include #include #include #include "inc/echo_file.h" #include "inc/solver.h" #include "inc/puzzle.h" #include "inc/kakuro.h" int main(int argc, char **argv) { Puzzle *puzzle; unsigned short width = 8, height = 8; time_t start_time = time(NULL); /* ECHO HEADER */ if(!echo_file("htm/header.txt")) { fputs("Failed to echo header!", stderr); exit(EXIT_FAILURE); } /* CHECK USER WIDTH/HEIGHT */ if(argc > 1) { width = (unsigned short) strtol(argv[1], NULL, 0); if(argv[2]) height = (unsigned short) strtol(argv[2], NULL, 0); } /* MAIN LOGIC */ srand(time(NULL)); puzzle = create_puzzle(width, height); if(puzzle != NULL) { generate_puzzle(puzzle); draw_puzzle(puzzle); destroy_puzzle(puzzle); } printf("

Generated in %lu seconds.", (unsigned long) (time(NULL) - start_time)); /* ECHO FOOTER */ if(!echo_file("htm/footer.txt")) { fputs("Failed to echo footer!", stderr); exit(EXIT_FAILURE); } return 0; } void _log(char *msg, int line, char *fname) { FILE *f = fopen("logfile", "a"); if(f != NULL) { fprintf(f, "%s:%d:\t%s", fname, line, msg); fclose(f); } return; }