[sword-devel] Quick example

Patrick Bakker sword-devel@crosswire.org
Thu, 31 Jul 2003 17:28:55 -0700


Hello everyone,
I've just taken a quick peak at using the Sword API while exploring the
idea of creating a frontend for it and produced the following example
program:

#include <swmgr.h>
#include <iostream>
#include <versekey.h>

using namespace std;
using sword::SWMgr;
using sword::ModMap;


// It all begins here.
int
main (int argc, char ** argv)
{
	SWMgr::debug = true;
	SWMgr swordManager;

	ModMap::iterator iter;

	for (iter = swordManager.Modules.begin(); iter !=
swordManager.Modules.end(); iter++)
	{
		cout << "[" << (* iter).first << "]\n";
	}

	return 0;
} // main

Unfortunately it crashes when running and I can't figure out why. Here's
the console output:

Checking working directory for mods.conf...
Checking working directory for mods.d...
Checking SWORD_PATH...
Parsing /etc/sword.conf:/usr/local/etc/sword.conf...
Checking for /etc/sword.conf...found
DataPath in /etc/sword.conf is set to: /usr/share/sword/
Checking for mods.conf in DataPath
Checking for mods.d in DataPath found
Segmentation fault

This seems to be a very similar sequence to that of tests/mgrtest.cpp
which runs fine for me. tests/modtest.cpp immediately produces a
segmentation fault however.

Does anybody have any idea what I'm doing wrong? I'm using CVS as of a
few days ago.

Thanks,
Patrick