Ejemplo n.º 1
0
signed char TreeKeyIdx::create(const char *ipath) {
	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.dat", 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.idx", path);
	FileMgr::removeFile(buf);
	fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	fd2->getFd();
	FileMgr::getSystemFileMgr()->close(fd2);

	TreeKeyIdx newTree(path);
	TreeKeyIdx::TreeNode root;
	stdstr(&(root.name), "");
	newTree.saveTreeNode(&root);

	delete [] path;

	return 0;
}
Ejemplo n.º 2
0
SWLocale::SWLocale(const char *ifilename) {
    p = new Private;
    ConfigEntMap::iterator confEntry;

    name           = 0;
    description    = 0;
    encoding       = 0;
    bookAbbrevs    = 0;
    bookLongNames  = 0;
    bookPrefAbbrev = 0;
    if (ifilename) {
        localeSource   = new SWConfig(ifilename);
    }
    else {
        localeSource   = new SWConfig(0);
        (*localeSource)["Meta"]["Name"] = DEFAULT_LOCALE_NAME;
        (*localeSource)["Meta"]["Description"] = "English (US)";
        bookAbbrevs = (struct abbrev *)builtin_abbrevs;
        for (abbrevsCnt = 0; builtin_abbrevs[abbrevsCnt].osis[0]; abbrevsCnt++);
    }

    confEntry = localeSource->Sections["Meta"].find("Name");
    if (confEntry != localeSource->Sections["Meta"].end())
        stdstr(&name, (*confEntry).second.c_str());

    confEntry = localeSource->Sections["Meta"].find("Description");
    if (confEntry != localeSource->Sections["Meta"].end())
        stdstr(&description, (*confEntry).second.c_str());

    confEntry = localeSource->Sections["Meta"].find("Encoding"); //Either empty (==Latin1) or UTF-8
    if (confEntry != localeSource->Sections["Meta"].end())
        stdstr(&encoding, (*confEntry).second.c_str());
}
Ejemplo n.º 3
0
TxTexCache::~TxTexCache()
{
#if DUMP_CACHE
  if (_options & DUMP_TEXCACHE) {
    /* dump cache to disk */
    std::wstring filename = _ident + L"_MEMORYCACHE.dat";
    CPath cachepath(stdstr().FromUTF16(_path.c_str()).c_str(),"");
	cachepath.AppendDirectory("cache");

    int config = _options & (FILTER_MASK|ENHANCEMENT_MASK|COMPRESS_TEX|COMPRESSION_MASK|FORCE16BPP_TEX|GZ_TEXCACHE);

	TxCache::save(stdstr((std::string &)cachepath).ToUTF16().c_str(), filename.c_str(), config);
  }
#endif
}
Ejemplo n.º 4
0
bool SWBasicFilter::substituteEscapeString(std::string &buf, const char *escString) {
    DualStringMap::iterator it;

    if (*escString == '#') {
        return handleNumericEscapeString(buf, escString);
    }

    if (passAllowedEscapeString(buf, escString)) {
        return true;
    }

    if (!escStringCaseSensitive) {
            char *tmp = 0;
        stdstr(&tmp, escString);
        toupperstr(tmp);
        it = p->escSubMap.find(tmp);
        delete [] tmp;
    } else
    it = p->escSubMap.find(escString);

    if (it != p->escSubMap.end()) {
        buf += it->second.c_str();
        return true;
    }
    return false;
}
Ejemplo n.º 5
0
char RawLD::getEntry(long away) const
{
    uint32_t start = 0;
    uint16_t size = 0;
    char *idxbuf = 0;
    char retval = 0;

    char *buf = new char [ strlen(*key) + 6 ];
    strcpy(buf, *key);

    if (strongsPadding) strongsPad(buf);

    if (!(retval = findOffset(buf, &start, &size, away))) {
        readText(start, &size, &idxbuf, entryBuf);
        rawFilter(entryBuf, 0);    // hack, decipher
        rawFilter(entryBuf, key);
        entrySize = size;        // support getEntrySize call
        if (!key->isPersist())            // If we have our own key
            *key = idxbuf;                // reset it to entry index buffer

        stdstr(&entkeytxt, idxbuf);    // set entry key text that module 'snapped' to.
        delete [] idxbuf;
    }
    else {
        entryBuf = "";
    }

    delete [] buf;
    return retval;
}
Ejemplo n.º 6
0
RawVerse::RawVerse(const char *ipath, int fileMode)
{
    std::string buf;
    buf.reserve(std::strlen(ipath) + sizeof("/ot.vss"));

    path = 0;
    stdstr(&path, ipath);

    buf = path;
    addTrailingDirectorySlash(buf);

    if (fileMode == -1) { // try read/write if possible
        fileMode = FileMgr::RDWR;
    }

    buf.append("ot.vss");
    auto const it(buf.rbegin() + 5u);
    idxfp[0] = FileMgr::getSystemFileMgr()->open(buf.c_str(), fileMode, true);

    (*it) = 'n';
    idxfp[1] = FileMgr::getSystemFileMgr()->open(buf.c_str(), fileMode, true);

    buf.resize(buf.size() - 4u);
    textfp[1] = FileMgr::getSystemFileMgr()->open(buf.c_str(), fileMode, true);

    (*it) = 'o';
    textfp[0] = FileMgr::getSystemFileMgr()->open(buf.c_str(), fileMode, true);

    instance++;
}
Ejemplo n.º 7
0
void TreeKeyIdx::setText(const char *ikey) {
	char *buf = 0;
	stdstr(&buf, ikey);
	SWBuf leaf = strtok(buf, "/");
	leaf.trim();
	root();
	while ((leaf.size()) && (!popError())) {
		bool ok, inChild = false;
		error = KEYERR_OUTOFBOUNDS;
		for (ok = firstChild(); ok; ok = nextSibling()) {
			inChild = true;
			if (leaf == getLocalName()) {
				error = 0;
				break;
			}
		}
		leaf = strtok(0, "/");
		leaf.trim();
		if (!ok) {
		    	if (inChild) {	// if we didn't find a matching child node, default to first child
				parent();
				firstChild();
			}
			error = KEYERR_OUTOFBOUNDS;
		}
	}
	if (leaf.size())
		error = KEYERR_OUTOFBOUNDS;
	delete [] buf;
	unsnappedKeyText = ikey;
	positionChanged();
}
Ejemplo n.º 8
0
SWORD_NAMESPACE_START

/******************************************************************************
 * RawGenBook Constructor - Initializes data for instance of RawGenBook
 *
 * ENT:	iname - Internal name for module
 *	idesc - Name to display to user for module
 *	idisp	 - Display object to use for displaying
 */

RawGenBook::RawGenBook(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, const char *keyType)
		: SWGenBook(iname, idesc, idisp, enc, dir, mark, ilang) {

	char *buf = new char [ strlen (ipath) + 20 ];

	path = 0;
	stdstr(&path, ipath);
	verseKey = !strcmp("VerseKey", keyType);

	if (verseKey) setType("Biblical Texts");

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

	delete key;
	key = createKey();


	sprintf(buf, "%s.bdt", path);
	bdtfd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::RDWR, true);

	delete [] buf;

}
Ejemplo n.º 9
0
QIcon* get( NamedSymbol* ns )
{
  Parameter* opts = get_options( ns );
  Locator* l = get_locator( ns );
  int gt = get_grist_type( ns );

  opts = find_by_hash( opts, hashlittle( "cts" ) );
  opts = find_child_by_hash( opts, hashlittle( "icon" ) );
  if( opts && !safe_to_convert( opts, E_VART_STRING ) )
    opts = 0x0;

  QIcon* icon = 0x0;

  if( opts )
  {
    QFileInfo fi( l->m_Buffer );
    QDir parent_dir( fi.absoluteDir() );
    QString qstr = parent_dir.absoluteFilePath( QString( as_string( *opts )->m_Raw ) );
    std::string stdstr( qstr.toStdString() );
    icon = get( stdstr.c_str() );
  }

  if( !icon )
    icon = get( g_NodeSVGResourcePaths[gt] );

  return icon;
}
Ejemplo n.º 10
0
signed char RawStr::createModule(const char *ipath)
{
	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.dat", 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.idx", path);
	FileMgr::removeFile(buf);
	fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
	fd2->getFd();
	FileMgr::getSystemFileMgr()->close(fd2);

	delete [] path;
	
	return 0;
}
Ejemplo n.º 11
0
RawVerse::RawVerse(const char *ipath, int fileMode)
{
	SWBuf buf;

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

	if (fileMode == -1) { // try read/write if possible
		fileMode = FileMgr::RDWR;
	}
		
	buf.setFormatted("%s/ot.vss", path);
	idxfp[0] = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);

	buf.setFormatted("%s/nt.vss", path);
	idxfp[1] = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);

	buf.setFormatted("%s/ot", path);
	textfp[0] = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);

	buf.setFormatted("%s/nt", path);
	textfp[1] = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);

	instance++;
}
Ejemplo n.º 12
0
void CNotificationImp::DisplayMessage(int DisplayTime, const char * Message) const
{
    if (!m_hWnd) { return; }

    if (m_NextMsg > 0 || DisplayTime > 0)
    {
        time_t Now = time(NULL);
        if (DisplayTime == 0 && Now < m_NextMsg)
        {
            return;
        }
        if (DisplayTime > 0)
        {
            m_NextMsg = Now + DisplayTime;
        }
        if (m_NextMsg == 0)
        {
            m_NextMsg = 0;
        }
    }

    if (InFullScreen())
    {
        if (m_gfxPlugin && m_gfxPlugin->DrawStatus)
        {
            WriteTrace(TraceGFXPlugin, TraceDebug, "DrawStatus - Starting");
            m_gfxPlugin->DrawStatus(Message, FALSE);
            WriteTrace(TraceGFXPlugin, TraceDebug, "DrawStatus - Done");
        }
    }
    else
    {
        m_hWnd->SetStatusText(0, stdstr(Message).ToUTF16().c_str());
    }
}
Ejemplo n.º 13
0
TreeKeyIdx::TreeNode::TreeNode() {

	name       = 0;
	stdstr(&name, "");
	userData   = 0;

	clear();
}
Ejemplo n.º 14
0
SWText::SWText(const char *imodname, const char *imoddesc, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, const char *versification): SWModule(staticCreateKey(versification), imodname, imoddesc, "Biblical Texts", enc, dir, mark, ilang) {
    this->versification = 0;
    stdstr(&(this->versification), versification);
    tmpVK1 = (VerseKey *)createKey();
    tmpVK2 = (VerseKey *)createKey();
        tmpSecond = false;
    skipConsecutiveLinks = false;
}
Ejemplo n.º 15
0
void CNotificationImp::DisplayWarning(const char * Message) const
{
    HWND Parent = NULL;
    if (m_hWnd)
    {
        Parent = reinterpret_cast<HWND>(m_hWnd->GetWindowHandle());
    }
    MessageBoxW(Parent, stdstr(Message).ToUTF16().c_str(), wGS(MSG_MSGBOX_WARNING_TITLE).c_str(), MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
}
Ejemplo n.º 16
0
void TreeKey::assureKeyPath(const char *keyBuffer) {

	if (!keyBuffer) {
		keyBuffer = unsnappedKeyText;
		//assert we have something to do before setting root
		if (!*keyBuffer)
			return;
	}

	char *keybuf = 0;
	stdstr(&keybuf, keyBuffer);

	root();

	// TODO: change to NOT use strtok. strtok is dangerous.
	SWBuf tok = strtok(keybuf, "/");
	tok.trim();
	while (tok.size()) {
		bool foundkey = false;
		if (hasChildren()) {
			firstChild();
			if (tok == getLocalName()) {
				foundkey = true;
			}
			else {
				while (nextSibling()) {
					if (getLocalName()) {
						if (tok == getLocalName()) {
							foundkey = true;
							break;
						}
					}
				}
			}
			if (!foundkey) {
				append();
				setLocalName(tok);
				save();	    
			}
		}
		else {
			appendChild();
			setLocalName(tok);
			save();
		}

#ifdef DEBUG
//      std::cout << getLocalName() << " : " << tok << std::endl;
#endif

		tok = strtok(0, "/");
		tok.trim();

	}
	delete [] keybuf;
}
Ejemplo n.º 17
0
void CNotificationImp::FatalError(const char  * Message) const
{
    WriteTrace(TraceUserInterface, TraceError, Message);
    WindowMode();

    HWND Parent = NULL;
    if (m_hWnd) { Parent = reinterpret_cast<HWND>(m_hWnd->GetWindowHandle()); }
    MessageBoxW(Parent, stdstr(Message).ToUTF16().c_str(), L"Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
    ExitThread(0);
}
Ejemplo n.º 18
0
FileDesc::FileDesc(FileMgr *parent, const char *path, int mode, int perms, bool tryDowngrade) {
	this->parent = parent;
	this->path = 0;
	stdstr(&this->path, path);
	this->mode = mode;
	this->perms = perms;
	this->tryDowngrade = tryDowngrade;
	offset = 0;
	fd = -77;
}
Ejemplo n.º 19
0
/* ---------------------------------------------------------------------- */
void PHRQ_io::
screen_msg(const char * str)
/* ---------------------------------------------------------------------- */
{
	std::string stdstr(str);
	if (error_file != NULL && screen_on)
	{
		fprintf(error_file, "%s", str);
	}
}
Ejemplo n.º 20
0
void SWBasicFilter::addEscapeStringSubstitute(const char *findString, const char *replaceString) {
    char *buf = 0;

    if (!escStringCaseSensitive) {
        stdstr(&buf, findString);
        toupperstr(buf);
        p->escSubMap.insert(DualStringMap::value_type(buf, replaceString));
        delete [] buf;
    }
    else p->escSubMap.insert(DualStringMap::value_type(findString, replaceString));
}
Ejemplo n.º 21
0
TxTexCache::TxTexCache(int options, int cachesize, const wchar_t *path, const wchar_t *ident,
                       dispInfoFuncExt callback
                       ) : TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback)
{
  /* assert local options */
  if (_path.empty() || _ident.empty() || !_cacheSize)
    _options &= ~DUMP_TEXCACHE;

#if DUMP_CACHE
  if (_options & DUMP_TEXCACHE) {
    /* find it on disk */
    std::wstring filename = _ident + L"_MEMORYCACHE.dat";
	CPath cachepath(stdstr().FromUTF16(_path.c_str()),"");
    cachepath.AppendDirectory("cache");
    int config = _options & (FILTER_MASK|ENHANCEMENT_MASK|COMPRESS_TEX|COMPRESSION_MASK|FORCE16BPP_TEX|GZ_TEXCACHE);

	TxCache::load(stdstr((std::string &)cachepath).ToUTF16().c_str(), filename.c_str(), config);
  }
#endif
}
Ejemplo n.º 22
0
void SWBasicFilter::addAllowedEscapeString(const char *findString) {
    char *buf = 0;

    if (!escStringCaseSensitive) {
        stdstr(&buf, findString);
        toupperstr(buf);
        p->escPassSet.insert(StringSet::value_type(buf));
        delete [] buf;
    }
    else p->escPassSet.insert(StringSet::value_type(findString));
}
Ejemplo n.º 23
0
void SWBasicFilter::addTokenSubstitute(const char *findString, const char *replaceString) {
    char *buf = 0;

    if (!tokenCaseSensitive) {
        stdstr(&buf, findString);
        toupperstr(buf);
        p->tokenSubMap[buf] = replaceString;
        delete [] buf;
    }
    else p->tokenSubMap[findString] = replaceString;
}
Ejemplo n.º 24
0
void CPlugins::CreatePluginDir ( const stdstr & DstDir ) const {
   char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], 
	   fname[_MAX_FNAME], ext[_MAX_EXT];
	_splitpath(DstDir.c_str(), drive, dir, fname, ext );			
	_makepath(path_buffer, drive, dir, "", "" );
	if (CreateDirectory(path_buffer,NULL) == 0 && GetLastError() == ERROR_PATH_NOT_FOUND) 
	{
		path_buffer[strlen(path_buffer) - 1] = 0;
		CreatePluginDir(stdstr(path_buffer));
		CreateDirectory(path_buffer,NULL);
	}
}
Ejemplo n.º 25
0
const char *ListKey::getOSISRefRangeText() const {
	char *buf = new char[(arraycnt + 1) * 255];
	buf[0] = 0;
	for (int i = 0; i < arraycnt; i++) {
		strcat(buf, array[i]->getOSISRefRangeText());
		if (i < arraycnt-1)
			strcat(buf, ";");
	}
	stdstr(&rangeText, buf);
	delete [] buf;
	return rangeText;
}
Ejemplo n.º 26
0
void CNotificationImp::DisplayError(const char * Message) const
{
    WriteTrace(TraceUserInterface, TraceError, Message);
    WindowMode();

    HWND Parent = NULL;
    if (m_hWnd)
    {
        Parent = reinterpret_cast<HWND>(m_hWnd->GetWindowHandle());
    }
    MessageBoxW(Parent, stdstr(Message).ToUTF16().c_str(), wGS(MSG_MSGBOX_ERROR_TITLE).c_str(), MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
}
Ejemplo n.º 27
0
bool CNotificationImp::AskYesNoQuestion(const char * Question) const
{
    WriteTrace(TraceUserInterface, TraceError, Question);
    WindowMode();

    HWND Parent = NULL;
    if (m_hWnd)
    {
        Parent = reinterpret_cast<HWND>(m_hWnd->GetWindowHandle());
    }
    int result = MessageBoxW(Parent, stdstr(Question).ToUTF16().c_str(), wGS(MSG_MSGBOX_WARNING_TITLE).c_str(), MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2 | MB_SETFOREGROUND);
    return result == IDYES;
}
Ejemplo n.º 28
0
void LocaleMgr::setDefaultLocaleName(const char *name) {
	char *tmplang=0;
	stdstr(&tmplang, name);
	// discard everything after '.' usually encoding e.g. .UTF-8
	strtok(tmplang, ".");
	// also discard after '@' so e.g. @euro locales are found
	strtok(tmplang, "@");

	stdstr(&defaultLocaleName, tmplang);

	// First check for what we ask for
	if (!getLocale(tmplang)) {
		// check for locale without country
		char *nocntry=0;
		stdstr(&nocntry, tmplang);
		strtok(nocntry, "_");
		if (getLocale(nocntry)) {
			stdstr(&defaultLocaleName, nocntry);
		}
		delete [] nocntry;
	}
	delete [] tmplang;
}
Ejemplo n.º 29
0
SWMgr::SWMgr(const char *iConfigPath, bool autoload, SWFilterMgr *filterMgr, bool multiMod, bool augmentHome) {

	init();

	mgrModeMultiMod = multiMod;
	SWBuf path;
	
	this->filterMgr = filterMgr;
	if (filterMgr)
		filterMgr->setParentMgr(this);
	
	this->augmentHome = augmentHome;

	path = iConfigPath;
	int len = path.length();
	if ((len < 1) || ((iConfigPath[len-1] != '\\') && (iConfigPath[len-1] != '/')))
		path += "/";
	if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
		stdstr(&prefixPath, path.c_str());
		path += "mods.conf";
		stdstr(&configPath, path.c_str());
	}
	else {
		if (FileMgr::existsDir(path.c_str(), "mods.d")) {
			stdstr(&prefixPath, path.c_str());
			path += "mods.d";
			stdstr(&configPath, path.c_str());
			configType = 1;
		}
	}

	config = 0;
	sysConfig = 0;

	if (autoload && configPath)
		Load();
}
Ejemplo n.º 30
0
void TreeKeyIdx::copyFrom(const TreeKeyIdx &ikey) {
	unsnappedKeyText = "";

	SWKey::copyFrom(ikey);

	currentNode.offset = ikey.currentNode.offset;
	currentNode.parent = ikey.currentNode.parent;
	currentNode.next = ikey.currentNode.next;
	currentNode.firstChild = ikey.currentNode.firstChild;
	stdstr(&(currentNode.name), ikey.currentNode.name);
	currentNode.dsize = ikey.currentNode.dsize;

	if (currentNode.userData)
		delete [] currentNode.userData;
	if (currentNode.dsize) {
		currentNode.userData = new char [ currentNode.dsize ];
		memcpy(currentNode.userData, ikey.currentNode.userData, currentNode.dsize);
	}
	else currentNode.userData = 0;

	bool newFiles = true;

	if (path && ikey.path)
		newFiles = strcmp(path, ikey.path);

	if (newFiles) {
		stdstr(&path, ikey.path);

		if (idxfd) {
			FileMgr::getSystemFileMgr()->close(idxfd);
			FileMgr::getSystemFileMgr()->close(datfd);
		}
		idxfd = FileMgr::getSystemFileMgr()->open(ikey.idxfd->path, ikey.idxfd->mode, ikey.idxfd->perms);
		datfd = FileMgr::getSystemFileMgr()->open(ikey.datfd->path, ikey.datfd->mode, ikey.datfd->perms);
	}
	positionChanged();
}