summaryrefslogtreecommitdiff
path: root/examples/classes/flatapilookup.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/classes/flatapilookup.c')
-rw-r--r--examples/classes/flatapilookup.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/examples/classes/flatapilookup.c b/examples/classes/flatapilookup.c
new file mode 100644
index 0000000..b76e7e2
--- /dev/null
+++ b/examples/classes/flatapilookup.c
@@ -0,0 +1,63 @@
+/******************************************************************************
+ *
+ * flatapilookup.c -
+ *
+ * $Id: flatapilookup.c 3162 2014-04-17 04:05:54Z greg.hellings $
+ *
+ * Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * 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 version 2.
+ *
+ * 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.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <flatapi.h>
+
+int main(int argc, char **argv) {
+ if (argc != 3) {
+ fprintf(stderr, "\nusage: %s <modname> <\"lookup key\">\n"
+ "\tExample: lookup KJV \"James 1:19\"\n\n", argv[0]);
+ exit(-1);
+ }
+
+
+ SWHANDLE mgr = org_crosswire_sword_SWMgr_new();
+
+ SWHANDLE module = org_crosswire_sword_SWMgr_getModuleByName(mgr, argv[1]);
+
+ if (!module) {
+ fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]);
+ const struct org_crosswire_sword_ModInfo *modInfos = org_crosswire_sword_SWMgr_getModInfoList(mgr);
+ while (modInfos && modInfos->name) {
+ fprintf(stderr, "[%s]\t - %s\n", modInfos->name, modInfos->description);
+ ++modInfos;
+ }
+ org_crosswire_sword_SWMgr_delete(mgr);
+ exit(-1);
+ }
+
+ org_crosswire_sword_SWModule_setKeyText(module, argv[2]);
+
+ // we render before we print keyText so our keyText snaps to the closest entry
+ const char *renderText = org_crosswire_sword_SWModule_renderText(module);
+ printf("==Render=Entry============\n");
+ printf("%s\n", org_crosswire_sword_SWModule_getKeyText(module));
+ printf("%s\n", renderText);
+ printf("==========================\n");
+
+ org_crosswire_sword_SWMgr_delete(mgr);
+
+ return 0;
+}