forked from hailo/libhailo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial import, now just a hello world C/sqlite program
Use it as: ./hailo hailo.brn "SELECT count(*) FROM expr;
- Loading branch information
0 parents
commit ffe34da
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
hailo | ||
*.brn | ||
*.trn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
all: | ||
gcc -Wall -lsqlite3 hailo.c -o hailo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sqlite3.h> | ||
|
||
static int callback(void *NotUsed, int argc, char **argv, char **azColName){ | ||
int i; | ||
for(i=0; i<argc; i++){ | ||
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL"); | ||
} | ||
printf("\n"); | ||
return 0; | ||
} | ||
|
||
int main(const int argc, const char **argv) { | ||
sqlite3 *db; | ||
char *zErrMsg = NULL; | ||
int rc; | ||
|
||
rc = sqlite3_open(argv[1], &db); | ||
if ( rc ){ | ||
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); | ||
sqlite3_close(db); | ||
exit(1); | ||
} | ||
|
||
rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg); | ||
if( rc!=SQLITE_OK ){ | ||
fprintf(stderr, "SQL error: %s\n", zErrMsg); | ||
sqlite3_free(zErrMsg); | ||
} | ||
sqlite3_close(db); | ||
|
||
return 0; | ||
} |