summaryrefslogtreecommitdiffstats
path: root/tests/getass.c
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-04-14 21:52:55 -0400
committerBrian Cully <github.20.shmit@spamgourmet.com>2008-04-14 21:52:55 -0400
commit6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 (patch)
tree86d7c281bcdbf67eb53cee064aa905e740ec5ccf /tests/getass.c
downloadnastd-6ba98a9f9f48e13738d9736cba9c45b5e94f42f2.tar.gz
nastd-6ba98a9f9f48e13738d9736cba9c45b5e94f42f2.zip
Initial import
Diffstat (limited to 'tests/getass.c')
-rw-r--r--tests/getass.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/getass.c b/tests/getass.c
new file mode 100644
index 0000000..7f81bf8
--- /dev/null
+++ b/tests/getass.c
@@ -0,0 +1,59 @@
+#include <assd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ assh *asshole;
+ ass_array *aa;
+ ass_options opts;
+ int i, rc;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+
+ asshole = ass_sphincter_new();
+ if (asshole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to asshole.\n");
+ return 2;
+ }
+
+ /* Get the default options. */
+ rc = ass_options_get(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ /* Add more fallthrough threads. */
+ opts.fallthrough_threads = 5;
+ rc = ass_options_set(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't set options: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ rc = ass_get(asshole, argv[1]);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't perform query: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ aa = ass_get_result(asshole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("Result[%d]: `%s'\n", i, aa->items[i]->strdata);
+ ass_free_result(aa);
+
+ ass_sphincter_close(asshole);
+ return 0;
+}