diff options
author | Wilrik de Loose <wilrik@wilrik.nl> | 2008-05-07 16:10:38 (GMT) |
---|---|---|
committer | Wilrik de Loose <wilrik@wilrik.nl> | 2008-05-07 16:10:38 (GMT) |
commit | 4c0c2685a6d564c9a6170b8a56c873104046a832 (patch) | |
tree | 5a3428d654bbfc05a5300630cca64398cf8bca25 | |
parent | bbcc93fada48dfbee6b45eb73ba58f53b4f9d1e2 (diff) | |
download | 2iv55-4c0c2685a6d564c9a6170b8a56c873104046a832.zip 2iv55-4c0c2685a6d564c9a6170b8a56c873104046a832.tar.gz 2iv55-4c0c2685a6d564c9a6170b8a56c873104046a832.tar.bz2 |
Coole command line interface erbij gemaakt.
-rw-r--r-- | db_demo/db.c | 8 | ||||
-rw-r--r-- | db_demo/db_demo.ncb | bin | 887808 -> 887808 bytes | |||
-rw-r--r-- | db_demo/db_demo.suo | bin | 19968 -> 19968 bytes | |||
-rw-r--r-- | 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 Binary files differindex 5f33877..8215619 100644 --- a/db_demo/db_demo.ncb +++ b/db_demo/db_demo.ncb diff --git a/db_demo/db_demo.suo b/db_demo/db_demo.suo Binary files differindex 9cb28c4..a05627e 100644 --- a/db_demo/db_demo.suo +++ b/db_demo/db_demo.suo 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 <stdio.h> +#include <stdlib.h> +#include <string.h> #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 <enter> 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; |