Unique ids in header files; fixed bug with html output

main
Thomas Ba. 13 years ago
parent 9daf16b465
commit 123ff51759

@ -1,5 +1,5 @@
#ifndef html_h__ #ifndef html_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define html_h__ #define html_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#include <stdio.h> #include <stdio.h>
@ -9,4 +9,4 @@ void printFoot(FILE * fp);
void out_html(sudoku * s,int c); void out_html(sudoku * s,int c);
int write_html(char* fn,sudoku * s); int write_html(char* fn,sudoku * s);
#endif /* html_h__ */ #endif /* html_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef input_h__ #ifndef input_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define input_h__ #define input_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
/** /**
* Reads the Sudoku from file * Reads the Sudoku from file
@ -9,4 +9,4 @@
*/ */
int s_einlesen(char * path, sudoku * sf, options * o); int s_einlesen(char * path, sudoku * sf, options * o);
#endif /* input_h__ */ #endif /* input_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef imput_nstd_h__ #ifndef imput_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define imput_nstd_h__ #define imput_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
/** /**
* Reads the Sudoku from file * Reads the Sudoku from file
@ -8,4 +8,4 @@
*/ */
int s_b_einlesen(char * path, sudoku * sf); int s_b_einlesen(char * path, sudoku * sf);
#endif /* imput_nstd_h__ */ #endif /* imput_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -39,9 +39,9 @@
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef linux #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 #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 #endif
sudoku s={ {{0}}, {{0}}, {{0}}, {{{1}}}, 81 }; sudoku s={ {{0}}, {{0}}, {{0}}, {{{1}}}, 81 };
char st=0,ret=0; char st=0,ret=0;
@ -68,7 +68,7 @@ int main(int argc, char **argv) {
}else if(o.html == 1){ }else if(o.html == 1){
for(i=0;i<9;i++) { for(i=0;i<9;i++) {
for(j=0;j<9;j++) { 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; o->unicode = 1;
break; break;
case 'H': case 'H':
if(o->html) o->force_html = 1;
o->html = 1; o->html = 1;
break; break;
case 'c': case 'c':
@ -188,7 +189,7 @@ void readOptions(int argc, char **argv, options * o) {
print_help(argc,argv); print_help(argc,argv);
exit(0); exit(0);
} }
if(o->html != 0 && o->outfile == NULL) { if(o->html != 0 && (o->outfile == NULL || o->force_html)) {
o->silent = 1; o->silent = 1;
} }
o->infile = argv[optind]; o->infile = argv[optind];
@ -207,7 +208,7 @@ void newStandard(options * o) {
o->ausgabe = std_ausgabe; o->ausgabe = std_ausgabe;
} }
if(o->html) { if(o->html) {
if(o->outfile == NULL) if(o->outfile == NULL || o->force_html)
o->ausgabe = out_html; o->ausgabe = out_html;
o->write = write_html; o->write = write_html;
} }
@ -226,7 +227,7 @@ void newNonStandard(options * o) {
o->ausgabe = nstd_ausgabe; o->ausgabe = nstd_ausgabe;
} }
if(o->html) { if(o->html) {
if(o->outfile == NULL) if(o->outfile == NULL || o->force_html)
o->ausgabe = out_html; o->ausgabe = out_html;
o->write = write_html; o->write = write_html;
} }
@ -239,7 +240,8 @@ void print_help(int argc, char **argv) {
printf("\033[0;1mOptions\033[0m\n"); printf("\033[0;1mOptions\033[0m\n");
printf(" -U Unicode borders\n"); printf(" -U Unicode borders\n");
printf(" -h This help\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 <file> Output-File\n"); printf(" -o <file> Output-File\n");
printf(" -O <file> Overlay for non-standard files\n"); printf(" -O <file> Overlay for non-standard files\n");
printf(" -c No colors\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("\033[0;1mOptions\033[0m\n");
printf(" -U Unicode borders\n"); printf(" -U Unicode borders\n");
printf(" -h This help\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 <file> Output-File\n"); printf(" -o <file> Output-File\n");
printf(" -O <file> Overlay for non-standard files\n"); printf(" -O <file> Overlay for non-standard files\n");
printf(" -p Plaintext\n"); printf(" -p Plaintext\n");

@ -1,5 +1,5 @@
#ifndef main_h__ #ifndef main_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define main_h__ #define main_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
int main(int argc, char **argv); int main(int argc, char **argv);
void readOptions(int argc, char **argv, options * o); void readOptions(int argc, char **argv, options * o);
@ -7,4 +7,4 @@ void newStandard(options * o);
void newNonStandard(options * o); void newNonStandard(options * o);
void print_help(int argc, char **argv); void print_help(int argc, char **argv);
#endif /* main_h__ */ #endif /* main_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef output_h__ #ifndef output_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define output_h__ #define output_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
/** /**
* Write the sudoku to a file * 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); void s_plain(sudoku* s, int color);
#endif /* output_h__ */ #endif /* output_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef output_nstd_h__ #ifndef output_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define output_nstd_h__ #define output_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
/** /**
* Print the Sudoku on stdout using unicode borders * Print the Sudoku on stdout using unicode borders
@ -27,4 +27,4 @@ char* rahmen(char v);
*/ */
char* colors(char val); char* colors(char val);
#endif /* output_nstd_h__ */ #endif /* output_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef output_std_h__ #ifndef output_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define output_std_h__ #define output_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
/** /**
* Print the Sudoku on stdout using unicode borders * 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); void std_ausgabe(sudoku* s,int color);
#endif /* output_std_h__ */ #endif /* output_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef solver_h__ #ifndef solver_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define solver_h__ #define solver_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
/** /**
* Tries to solve the Sudoku with logic * 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); int s_loes_track(sudoku * s, int pos, options * o);
#endif /* solver_h__ */ #endif /* solver_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef solver_nstd_h__ #ifndef solver_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define solver_nstd_h__ #define solver_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
/** /**
* Checks if there are other posibilities for the number if not return 1 * 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); int solver_nstd_test(sudoku *s, int z, int sp, int zahl);
#endif /* solver_nstd_h__ */ #endif /* solver_nstd_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef solver_std_h__ #ifndef solver_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define solver_std_h__ #define solver_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
/** /**
* Checks if there are other posibilities for the number if not return 1 * 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); int solver_test(sudoku *s, int z, int sp, int zahl);
#endif /* solver_std_h__ */ #endif /* solver_std_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

@ -1,5 +1,5 @@
#ifndef types_h__ #ifndef types_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
#define types_h__ #define types_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__
typedef struct sudoku { typedef struct sudoku {
char feld[9][9]; /* Feld mit den Zahlen */ char feld[9][9]; /* Feld mit den Zahlen */
@ -15,6 +15,7 @@ typedef struct options {
char plaintext; /* Same format as the input */ char plaintext; /* Same format as the input */
char silent; /* just output the result */ char silent; /* just output the result */
char html; /* output html (implies silent) */ 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 solve; /* solve it or not */
char* outfile; /* outfile NULL if none */ char* outfile; /* outfile NULL if none */
char* overlay; /* overlay NULL if none */ char* overlay; /* overlay NULL if none */
@ -26,4 +27,4 @@ typedef struct options {
int (*write)(char*,sudoku*); int (*write)(char*,sudoku*);
} options; } options;
#endif /* types_h__ */ #endif /* types_2b894a04_3a0c_4223_bf83_6ab40c0f5e57_h__ */

Loading…
Cancel
Save