示例#1
0
文件: swtext.cpp 项目: raphink/sword
SWKey *SWText::createKey() const {
	VerseKey *vk = new VerseKey();

	vk->setVersificationSystem(versification);

	return vk;
}
示例#2
0
SWHANDLE listkey_getVerselistIterator(const char *list, const char *key, const char *v11n) {
	VerseKey versekey;
        versekey.setVersificationSystem(v11n);
	static ListKey verses;
	
	versekey.setText(key);
	verses.clear();
	verses = versekey.parseVerseList(list, versekey);
	return (SWHANDLE)&verses;
}
示例#3
0
char RawVerse::createModule(const char *ipath, const char *v11n)
{
	char *path = 0;
	char *buf = new char [ strlen (ipath) + 20 ];
	FileDesc *fd, *fd2;

	stdstr(&path, ipath);

	if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
		path[strlen(path)-1] = 0;

	sprintf(buf, "%s/ot", path);
	FileMgr::removeFile(buf);
	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	fd->getFd();
	FileMgr::getSystemFileMgr()->close(fd);

	sprintf(buf, "%s/nt", path);
	FileMgr::removeFile(buf);
	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	fd->getFd();
	FileMgr::getSystemFileMgr()->close(fd);

	sprintf(buf, "%s/ot.vss", path);
	FileMgr::removeFile(buf);
	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	fd->getFd();

	sprintf(buf, "%s/nt.vss", path);
	FileMgr::removeFile(buf);
	fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	fd2->getFd();

	VerseKey vk;
	vk.setVersificationSystem(v11n);
	vk.setIntros(1);

	__s32 offset = 0;
	__u16 size = 0;
	offset = archtosword32(offset);
	size = archtosword16(size);

	for (vk = TOP; !vk.popError(); vk++) {
		if (vk.getTestament() < 2) {
			fd->write(&offset, 4);
			fd->write(&size, 2);
		}
		else	{
			fd2->write(&offset, 4);
			fd2->write(&size, 2);
		}
	}
	fd2->write(&offset, 4);
	fd2->write(&size, 2);

	FileMgr::getSystemFileMgr()->close(fd);
	FileMgr::getSystemFileMgr()->close(fd2);

	delete [] path;
	delete [] buf;
	
	return 0;
}
示例#4
0
char zVerse::createModule(const char *ipath, int blockBound, const char *v11n)
{
	char *path = 0;
	char *buf = new char [ strlen (ipath) + 20 ];
	char retVal = 0;
	FileDesc *fd, *fd2;
	__s32 offset = 0;
	__s16 size = 0;
	VerseKey vk;

	stdstr(&path, ipath);

	if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
		path[strlen(path)-1] = 0;

	sprintf(buf, "%s/ot.%czs", path, uniqueIndexID[blockBound]);
	FileMgr::removeFile(buf);
	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	if (fd->getFd() < 1) goto erroropen1;
	FileMgr::getSystemFileMgr()->close(fd);

	sprintf(buf, "%s/nt.%czs", path, uniqueIndexID[blockBound]);
	FileMgr::removeFile(buf);
	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	if (fd->getFd() < 1) goto erroropen1;
	FileMgr::getSystemFileMgr()->close(fd);

	sprintf(buf, "%s/ot.%czz", path, uniqueIndexID[blockBound]);
	FileMgr::removeFile(buf);
	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	if (fd->getFd() < 1) goto erroropen1;
	FileMgr::getSystemFileMgr()->close(fd);

	sprintf(buf, "%s/nt.%czz", path, uniqueIndexID[blockBound]);
	FileMgr::removeFile(buf);
	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	if (fd->getFd() < 1) goto erroropen1;
	FileMgr::getSystemFileMgr()->close(fd);

	sprintf(buf, "%s/ot.%czv", path, uniqueIndexID[blockBound]);
	FileMgr::removeFile(buf);
	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	if (fd->getFd() < 1) goto erroropen1;

	sprintf(buf, "%s/nt.%czv", path, uniqueIndexID[blockBound]);
	FileMgr::removeFile(buf);
	fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	if (fd2->getFd() < 1) goto erroropen2;

	vk.setVersificationSystem(v11n);
	vk.setIntros(true);

	offset = archtosword32(offset);
	size   = archtosword16(size);

	for (vk = TOP; !vk.popError(); vk++) {
		if (vk.getTestament() < 2) {
			if (fd->write(&offset, 4) != 4) goto writefailure;	//compBufIdxOffset
			if (fd->write(&offset, 4) != 4) goto writefailure;
			if (fd->write(&size, 2) != 2) goto writefailure;
		}
		else {
			if (fd2->write(&offset, 4) != 4) goto writefailure;	//compBufIdxOffset
			if (fd2->write(&offset, 4) != 4) goto writefailure;
			if (fd2->write(&size, 2) != 2) goto writefailure;
		}
	}
	fd2->write(&offset, 4);	//compBufIdxOffset
	fd2->write(&offset, 4);
	fd2->write(&size, 2);

	goto cleanup;

erroropen1:
	retVal = -1;
	goto cleanup1;

erroropen2:
	retVal = -1;
	goto cleanup;

writefailure:
	retVal = -2;

cleanup:
	FileMgr::getSystemFileMgr()->close(fd2);
cleanup1:
	FileMgr::getSystemFileMgr()->close(fd);

	delete [] path;
	delete [] buf;
	
	return retVal;
}