Implemented helpers to get talker email and name.
[cascardo/avaliacao2008.git] / helper_test.c
diff --git a/helper_test.c b/helper_test.c
new file mode 100644 (file)
index 0000000..d29b0da
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  Copyright (C) 2009  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include "helper.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv)
+{
+       sqlite3 *db;
+       char *dbname;
+       char *email;
+       int talker_id;
+       if (argc < 3) {
+               fprintf(stderr, "<program> <db> <id>\n");
+               return 1;
+       }
+       dbname = argv[1];
+       talker_id = atoi(argv[2]);
+       sqlite3_open(dbname, &db);
+       email = get_talker_email(db, talker_id);
+       sqlite3_close(db);
+       if (email) {
+               printf("Talker email is %s\n", email);
+               free(email);
+       } else {
+               fprintf(stderr, "Could not find talker\n");
+       }
+       return 0;
+}