From 123ff51759da0c55c1de7ab832e9e8ab1ffefadb Mon Sep 17 00:00:00 2001 From: Thomas Battermann Date: Sun, 4 Mar 2012 16:03:19 +0100 Subject: [PATCH] Unique ids in header files; fixed bug with html output --- html.h | 6 +++--- input.h | 6 +++--- input_nstd.h | 6 +++--- main.c | 19 +++++++++++-------- main.h | 6 +++--- output.h | 6 +++--- output_nstd.h | 6 +++--- output_std.h | 6 +++--- solver.h | 6 +++--- solver_nstd.h | 6 +++--- solver_std.h | 6 +++--- types.h | 7 ++++--- 12 files changed, 45 insertions(+), 41 deletions(-) diff --git a/html.h b/html.h index a2fdb62..2f17e5c 100644 --- a/html.h +++ b/html.h @@ -1,5 +1,5 @@ -#ifndef html_h__ -#define html_h__ +#ifndef html_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define html_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ #include @@ -9,4 +9,4 @@ void printFoot(FILE * fp); void out_html(sudoku * s,int c); int write_html(char* fn,sudoku * s); -#endif /* html_h__ */ \ No newline at end of file +#endif /* html_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/input.h b/input.h index 1dc2982..798aa6c 100644 --- a/input.h +++ b/input.h @@ -1,5 +1,5 @@ -#ifndef input_h__ -#define input_h__ +#ifndef input_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define input_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ /** * Reads the Sudoku from file @@ -9,4 +9,4 @@ */ int s_einlesen(char * path, sudoku * sf, options * o); -#endif /* input_h__ */ \ No newline at end of file +#endif /* input_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/input_nstd.h b/input_nstd.h index a8d61f4..957602c 100644 --- a/input_nstd.h +++ b/input_nstd.h @@ -1,5 +1,5 @@ -#ifndef imput_nstd_h__ -#define imput_nstd_h__ +#ifndef imput_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define imput_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ /** * Reads the Sudoku from file @@ -8,4 +8,4 @@ */ int s_b_einlesen(char * path, sudoku * sf); -#endif /* imput_nstd_h__ */ \ No newline at end of file +#endif /* imput_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/main.c b/main.c index a3b9918..df7d0bd 100644 --- a/main.c +++ b/main.c @@ -39,9 +39,9 @@ int main(int argc, char **argv) { #ifdef linux - options o = {0,1,0,0,0,1,NULL,NULL,NULL,NULL,NULL,NULL}; + options o = {0,1,0,0,0,0,1,NULL,NULL,NULL,NULL,NULL,NULL}; #else - options o = {0,0,0,0,0,1,NULL,NULL,NULL,NULL,NULL,NULL}; + options o = {0,0,0,0,0,0,1,NULL,NULL,NULL,NULL,NULL,NULL}; #endif sudoku s={ {{0}}, {{0}}, {{0}}, {{{1}}}, 81 }; char st=0,ret=0; @@ -68,7 +68,7 @@ int main(int argc, char **argv) { }else if(o.html == 1){ for(i=0;i<9;i++) { for(j=0;j<9;j++) { - s.feld[i][j] = ((i/3)*3)+1+(j/3); + s.belegung[i][j] = ((i/3)*3)+1+(j/3); } } } @@ -151,6 +151,7 @@ void readOptions(int argc, char **argv, options * o) { o->unicode = 1; break; case 'H': + if(o->html) o->force_html = 1; o->html = 1; break; case 'c': @@ -188,7 +189,7 @@ void readOptions(int argc, char **argv, options * o) { print_help(argc,argv); exit(0); } - if(o->html != 0 && o->outfile == NULL) { + if(o->html != 0 && (o->outfile == NULL || o->force_html)) { o->silent = 1; } o->infile = argv[optind]; @@ -207,7 +208,7 @@ void newStandard(options * o) { o->ausgabe = std_ausgabe; } if(o->html) { - if(o->outfile == NULL) + if(o->outfile == NULL || o->force_html) o->ausgabe = out_html; o->write = write_html; } @@ -226,7 +227,7 @@ void newNonStandard(options * o) { o->ausgabe = nstd_ausgabe; } if(o->html) { - if(o->outfile == NULL) + if(o->outfile == NULL || o->force_html) o->ausgabe = out_html; o->write = write_html; } @@ -239,7 +240,8 @@ void print_help(int argc, char **argv) { printf("\033[0;1mOptions\033[0m\n"); printf(" -U Unicode borders\n"); printf(" -h This help\n"); - printf(" -H HTML-Output"); + printf(" -H HTML-Output\n"); + printf(" twice: print on stdout, even if outfile given\n"); printf(" -o Output-File\n"); printf(" -O Overlay for non-standard files\n"); printf(" -c No colors\n"); @@ -257,7 +259,8 @@ printf("\033[0;1mUsage:\033[0m\n"); printf("\033[0;1mOptions\033[0m\n"); printf(" -U Unicode borders\n"); printf(" -h This help\n"); - printf(" -H HTML-Output"); + printf(" -H HTML-Output\n"); + printf(" twice: print on stdout, even if outfile given\n"); printf(" -o Output-File\n"); printf(" -O Overlay for non-standard files\n"); printf(" -p Plaintext\n"); diff --git a/main.h b/main.h index d49aec8..2d272c4 100644 --- a/main.h +++ b/main.h @@ -1,5 +1,5 @@ -#ifndef main_h__ -#define main_h__ +#ifndef main_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define main_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ int main(int argc, char **argv); void readOptions(int argc, char **argv, options * o); @@ -7,4 +7,4 @@ void newStandard(options * o); void newNonStandard(options * o); void print_help(int argc, char **argv); -#endif /* main_h__ */ \ No newline at end of file +#endif /* main_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/output.h b/output.h index be7357d..9ceffa6 100644 --- a/output.h +++ b/output.h @@ -1,5 +1,5 @@ -#ifndef output_h__ -#define output_h__ +#ifndef output_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define output_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ /** * Write the sudoku to a file @@ -22,4 +22,4 @@ int s_write_error(char* fn,int err); */ void s_plain(sudoku* s, int color); -#endif /* output_h__ */ \ No newline at end of file +#endif /* output_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/output_nstd.h b/output_nstd.h index 3cac742..c30de6e 100644 --- a/output_nstd.h +++ b/output_nstd.h @@ -1,5 +1,5 @@ -#ifndef output_nstd_h__ -#define output_nstd_h__ +#ifndef output_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define output_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ /** * Print the Sudoku on stdout using unicode borders @@ -27,4 +27,4 @@ char* rahmen(char v); */ char* colors(char val); -#endif /* output_nstd_h__ */ \ No newline at end of file +#endif /* output_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/output_std.h b/output_std.h index 815810b..535526a 100644 --- a/output_std.h +++ b/output_std.h @@ -1,5 +1,5 @@ -#ifndef output_std_h__ -#define output_std_h__ +#ifndef output_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define output_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ /** * Print the Sudoku on stdout using unicode borders @@ -15,4 +15,4 @@ void std_ausgabe_unicode(sudoku* s,int color); */ void std_ausgabe(sudoku* s,int color); -#endif /* output_std_h__ */ \ No newline at end of file +#endif /* output_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/solver.h b/solver.h index 6fe81e8..3e3a9ab 100644 --- a/solver.h +++ b/solver.h @@ -1,5 +1,5 @@ -#ifndef solver_h__ -#define solver_h__ +#ifndef solver_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define solver_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ /** * Tries to solve the Sudoku with logic @@ -14,4 +14,4 @@ int sl_loes(sudoku* s, options * o); */ int s_loes_track(sudoku * s, int pos, options * o); -#endif /* solver_h__ */ \ No newline at end of file +#endif /* solver_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/solver_nstd.h b/solver_nstd.h index 3813f25..ea9be4a 100644 --- a/solver_nstd.h +++ b/solver_nstd.h @@ -1,5 +1,5 @@ -#ifndef solver_nstd_h__ -#define solver_nstd_h__ +#ifndef solver_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define solver_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ /** * Checks if there are other posibilities for the number if not return 1 @@ -28,4 +28,4 @@ void solver_nstd_set_num(sudoku* s,int zahl,int z, int sp); */ int solver_nstd_test(sudoku *s, int z, int sp, int zahl); -#endif /* solver_nstd_h__ */ \ No newline at end of file +#endif /* solver_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/solver_std.h b/solver_std.h index 436c443..72f9f73 100644 --- a/solver_std.h +++ b/solver_std.h @@ -1,5 +1,5 @@ -#ifndef solver_std_h__ -#define solver_std_h__ +#ifndef solver_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define solver_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ /** * Checks if there are other posibilities for the number if not return 1 @@ -28,4 +28,4 @@ void solver_set_num(sudoku* s,int zahl,int z, int sp); */ int solver_test(sudoku *s, int z, int sp, int zahl); -#endif /* solver_std_h__ */ \ No newline at end of file +#endif /* solver_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */ diff --git a/types.h b/types.h index 2a9466d..1e4a142 100644 --- a/types.h +++ b/types.h @@ -1,5 +1,5 @@ -#ifndef types_h__ -#define types_h__ +#ifndef types_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ +#define types_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ typedef struct sudoku { char feld[9][9]; /* Feld mit den Zahlen */ @@ -15,6 +15,7 @@ typedef struct options { char plaintext; /* Same format as the input */ char silent; /* just output the result */ char html; /* output html (implies silent) */ + char force_html;/* force html output on stdout even if outfile given */ char solve; /* solve it or not */ char* outfile; /* outfile NULL if none */ char* overlay; /* overlay NULL if none */ @@ -26,4 +27,4 @@ typedef struct options { int (*write)(char*,sudoku*); } options; -#endif /* types_h__ */ \ No newline at end of file +#endif /* types_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */