From 4e68dc71bbc55358e37df1d3cd8fec9c5ead60f2 Mon Sep 17 00:00:00 2001 From: Thomas Battermann Date: Sun, 4 Mar 2012 07:08:03 +0100 Subject: [PATCH] Implemented html && fixed readme --- README.md | 21 +++++++++++---------- html.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ html.h | 12 ++++++++++++ 3 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 html.c create mode 100644 html.h diff --git a/README.md b/README.md index c4f9701..6568a4b 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,14 @@ For better usage the Output is colored. # Usage -age: - ./sudokuloeser [options] -Options - -U Unicode borders - -h This help - -o Output-File - -O Overlay for non-standard files -c No colors - -p Plaintext - -n Dont solve, just print - -s silent + Usage: + ./sudokuloeser [options] + Options + -U Unicode borders + -h This help + -H HTML-Output + -o Output-File + -O Overlay for non-standard files -c No colors + -p Plaintext + -n Dont solve, just print + -s silent diff --git a/html.c b/html.c new file mode 100644 index 0000000..db0a60f --- /dev/null +++ b/html.c @@ -0,0 +1,55 @@ +#include "types.h" +#include +#include "html.h" + +void out_html(sudoku * s,int c) { + genHTML(s,stdout); +} + +int write_html(char* fn,sudoku* s) { + FILE * fp = fopen(fn,"w"); + if(fp == NULL) return 0; + genHTML(s,fp); + fclose(fp); + return 1; +} + +void genHTML(sudoku * s,FILE * fp) { + int i,j; + /* Header ausgeben */ + printHead(fp); + /* Tabelle ausgeben */ + for(i=0;i<9;i++) { + fprintf(fp," \n"); + for(j=0;j<9;j++) { + fprintf(fp,"\t\t\t\t%d\n", + s->belegung[i][j], + ((s->vorgabe[i][j] != 0) ? ((s->vorgabe[i][j] == 1) ? " v" : "") : " b"), + s->feld[i][j]); + } + fprintf(fp," \n"); + } + /* Footer ausgeben */ + printFoot(fp); +} + +void printHead(FILE * fp) { + fprintf(fp,"\n"); + fprintf(fp,"\n"); + fprintf(fp," \n"); + fprintf(fp," Sudoku (solved)\n"); + fprintf(fp," \n"); + fprintf(fp," \n"); + fprintf(fp," \n"); + fprintf(fp," \n"); +} + +void printFoot(FILE * fp) { + fprintf(fp,"
\n"); + fprintf(fp," \n"); + fprintf(fp,"\n"); +} \ No newline at end of file diff --git a/html.h b/html.h new file mode 100644 index 0000000..a2fdb62 --- /dev/null +++ b/html.h @@ -0,0 +1,12 @@ +#ifndef html_h__ +#define html_h__ + +#include + +void genHTML(sudoku * s,FILE * fp); +void printHead(FILE * fp); +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