From 4c0c2685a6d564c9a6170b8a56c873104046a832 Mon Sep 17 00:00:00 2001 From: Wilrik de Loose Date: Wed, 7 May 2008 16:10:38 +0000 Subject: Coole command line interface erbij gemaakt. --- db_demo/db.c | 8 ++++++-- db_demo/db_demo.ncb | Bin 887808 -> 887808 bytes db_demo/db_demo.suo | Bin 19968 -> 19968 bytes db_demo/main.c | 22 +++++++++++++++++++++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/db_demo/db.c b/db_demo/db.c index 3a58c3f..ea82019 100644 --- a/db_demo/db.c +++ b/db_demo/db.c @@ -31,7 +31,7 @@ static int db_set_error(const char *f_pError) static void db_raise_warning(void) { - printf("Database exception!\n"); +// printf("Database exception!\n"); printf("%s", g_pError); } // db_raise_warning @@ -164,6 +164,8 @@ int db_output(void) } } + printf("\n"); + // print column names for (i = 0; i < l_iNFields; i++) { @@ -215,6 +217,8 @@ int db_output(void) printf("\n"); } + printf("\nResults: %d\n\n", l_iNTuples); + return DB_OK; } // db_output @@ -251,7 +255,7 @@ int db_execute(const char* f_pQuery) } else { - printf("%s\n", l_pCmdStatus); + printf("\n%s\n\n", l_pCmdStatus); } return DB_OK; diff --git a/db_demo/db_demo.ncb b/db_demo/db_demo.ncb index 5f33877..8215619 100644 Binary files a/db_demo/db_demo.ncb and b/db_demo/db_demo.ncb differ diff --git a/db_demo/db_demo.suo b/db_demo/db_demo.suo index 9cb28c4..a05627e 100644 Binary files a/db_demo/db_demo.suo and b/db_demo/db_demo.suo differ diff --git a/db_demo/main.c b/db_demo/main.c index 37286f1..2120be9 100644 --- a/db_demo/main.c +++ b/db_demo/main.c @@ -1,9 +1,29 @@ +#include +#include +#include #include "db.h" +// prints a new line +void newline(void) { printf("%s> ", DBNAME); } + int main(int argc, char *argv[]) { + char string[1024]; + + printf("type exit and hit to quit the program...\n\n"); + db_init(); - db_execute("SELECT * FROM testicle ORDER BY teller"); + newline(); + + // parse user input + while (gets(string)) + { + if (!strcmp(string, "exit")) exit(0); + else if (!strcmp(string, "")) {} + else db_execute(string); + newline(); + } + db_close(); return 0; -- cgit v0.12