Пример #1
0
static void test_DynStrRemoveStartLen()
{
    char_t    *str = NULL;

    DynStr *dstr = DynStrFromCharP(_T("hello"), 32);
    assert( 5 == DynStrLen(dstr) );
    DynStrRemoveStartLen(dstr, 0, 1);
    // should be "ello" now
    assert( 4 == DynStrLen(dstr) );
    str = DynStrGetCStr(dstr);
    assert( 0 == tstrcmp(_T("ello"), str) );
    DynStrRemoveStartLen(dstr, 3, 1);
    // should be "ell" now
    assert( 3 == DynStrLen(dstr) );
    str = DynStrGetCStr(dstr);
    assert( 0 == tstrcmp(_T("ell"), str) );
    DynStrAppendCharP(dstr, _T("blast"));
    // should be "ellblast" now
    assert( 8 == DynStrLen(dstr) );
    str = DynStrGetCStr(dstr);
    assert( 0 == tstrcmp(_T("ellblast"), str) );
    DynStrRemoveStartLen(dstr, 2, 4);
    // should be "elst" now
    assert( 4 == DynStrLen(dstr) );
    str = DynStrGetCStr(dstr);
    assert( 0 == tstrcmp(_T("elst"), str) );
    DynStrDelete(dstr);
}
Пример #2
0
static void test_DynStrTruncate()
{
    char_t *str = NULL;
    DynStr  dstr;

    DynStrInit(&dstr, 0);
    assert(0 == DynStrLen(&dstr));
    DynStrTruncate(&dstr,0);
    assert(0 == DynStrLen(&dstr));
    DynStrAppendCharP(&dstr, _T("hello"));
    assert(5 == DynStrLen(&dstr));
    DynStrTruncate(&dstr, 3);
    assert(3 == DynStrLen(&dstr));
    str = DynStrGetCStr(&dstr);
    assert( 0 == tstrcmp(_T("hel"), str) );

    DynStrTruncate(&dstr, 2);
    assert(2 == DynStrLen(&dstr));
    str = DynStrGetCStr(&dstr);
    assert( 0 == tstrcmp(_T("he"), str) );

    DynStrTruncate(&dstr, 0);
    assert(0 == DynStrLen(&dstr));
    str = DynStrGetCStr(&dstr);
    assert( 0 == tstrcmp(_T(""), str) );

    DynStrFree(&dstr);    

}
Пример #3
0
/* Returns the tobj that has the same name as str and points prev to the tobj that's either a parent or an older sister node to the returned tobj */
struct tobj *tfind(struct tobj *t, struct tobj **prev, char *str){
	if(!t){
		return NULL;
	}
	do{
		if(tstrcmp(str, t->name) == 0){
			return t;
		}
		if(t->type ^ PORTAL){ /* Don't look for stuff that's through a portal */
			*prev = t;
			struct tobj *ct = t->child;
			if(ct){
				do{
					if(tstrcmp(str, ct->name) == 0){
						return ct;
					}
					*prev = ct;
					ct = ct->next;
				}while(ct);
			}
		}
		*prev = t;
		t = t->next;
	}while(t);

	return NULL;
}
Пример #4
0
static eExecutableType iIsFileExecutableExt(cEnvironmentHelper* pEnvironmentHelper, cFile& file)
{
	size_t i;
	tcstring ext = file.getExtension();
	if (ext)
	{
		for (i=0; i<countof(executable_ext); i++)
		{
			if (0 == tstrcmp(ext, executable_ext[i]))
				return file.fi.executable_type = eExecutableImage;
		}
		if (0 == tstrcmp(ext, _T("DLL")))
		{
			return file.fi.executable_type = eExecutableLibrary;
		}
		for (i=0; i<countof(script_ext); i++)
		{
			if (0 == tstrcmp(ext, script_ext[i]))
			{
				file.fi.format = eFormatText;
				return file.fi.executable_type = eExecutableScript;
			}
		}
	}
	return file.fi.executable_type;
}
Пример #5
0
static void test_DynStrReplace()
{
    DynStr *dstr = DynStrFromCharP(_T("hello"), 0);
    DynStrReplace(dstr, _T('h'), _T('p'));
    assert( 0 == tstrcmp(_T("pello"), dstr->str) );
    DynStrReplace(dstr, _T('z'), _T('k'));
    assert( 0 == tstrcmp(_T("pello"), dstr->str) );
    DynStrDelete(dstr);
}
Пример #6
0
int CAht::BuildPartsSub( int id, char *fname )
{
    //		簡易ahtパース
    //
    int i,res,maxline;
    CStrNote note;
    CMemBuf tmp;
    AHTPARTS *p;
    char s1[256];
    
    p = GetParts( id );
    if ( p == NULL ) return -2;
    
    p->classname[0] = 0;
    p->name[0] = 0;
    p->icon = 0;
    
    res = tmp.PutFile( fname );
    if ( res < 0 ) {
        return -1;
    }
    note.Select( tmp.GetBuffer() );
    maxline = note.GetMaxLine();
    getpath( fname, p->name, 1+8+16 );			// 仮にファイル名を入れておく
    
    for(i=0;i<maxline;i++) {
        pickptr = 0;
        note.GetLine( linebuf, i, 255 );
        PickLineBuffer( s1 );
        if ( tstrcmp( s1,"#aht" ) ) {
            PickLineBuffer( s1 );
            if ( tstrcmp( s1,"iconid" ) ) {
                PickLineBuffer( s1 );
                p->icon = atoi( s1 );
            }
            if ( tstrcmp( s1,"name" ) ) {
                PickLineBuffer( s1 );
                strcpy( p->name, s1 );
            }
            if ( tstrcmp( s1,"class" ) ) {
                PickLineBuffer( s1 );
                strcpy( p->classname, s1 );
            }
        }
    }
    
    return 0;
}
Пример #7
0
/* API function documented in wimlib.h  */
WIMLIBAPI int
wimlib_resolve_image(WIMStruct *wim, const tchar *image_name_or_num)
{
    tchar *p;
    long image;
    int i;

    if (!image_name_or_num || !*image_name_or_num)
        return WIMLIB_NO_IMAGE;

    if (!tstrcasecmp(image_name_or_num, T("all"))
            || !tstrcasecmp(image_name_or_num, T("*")))
        return WIMLIB_ALL_IMAGES;
    image = tstrtol(image_name_or_num, &p, 10);
    if (p != image_name_or_num && *p == T('\0') && image > 0) {
        if (image > wim->hdr.image_count)
            return WIMLIB_NO_IMAGE;
        return image;
    } else {
        for (i = 1; i <= wim->hdr.image_count; i++) {
            if (!tstrcmp(image_name_or_num,
                         wimlib_get_image_name(wim, i)))
                return i;
        }
        return WIMLIB_NO_IMAGE;
    }
}
Пример #8
0
static void test_DynStrRelease()
{
    char_t * str;
    DynStr * dstr = DynStrFromCharP(_T("rusty"), 20);
    str = DynStrReleaseStr(dstr);
    assert( 0 == tstrcmp(_T("rusty"), str));
    assert( 0 == DynStrLen(dstr) );
    assert( NULL == DynStrGetCStr(dstr) );
    DynStrAppendCharP(dstr, _T("moo"));
    assert( 3 == DynStrLen(dstr) );
    assert( 0 == tstrcmp(_T("moo"), DynStrGetCStr(dstr)));
    DynStrAppendCharP2(dstr, _T(""), _T("r"));
    assert( 4 == DynStrLen(dstr) );
    assert( 0 == tstrcmp(_T("moor"), DynStrGetCStr(dstr)));
    assert( 0 == tstrcmp(_T("rusty"), str));
    DynStrDelete(dstr);
    assert( 0 == tstrcmp(_T("rusty"), str));
    free(str);
}
Пример #9
0
void PediaMainForm::changeLanguage(const char_t* code)
{
    PediaPreferences& prefs = application().preferences().pediaPrefs;
    if (0 != tstrcmp(code, prefs.languageCode))
    {
        prefs.articleCount = prefs.articleCountNotChecked;
        memmove(prefs.languageCode, code, tstrlen(code) * sizeof(char_t));
        prefs.dbDate[0] = '\0';
    }
    setDisplayMode(showAbout);
    update();
}
Пример #10
0
//------------------------------------------------------------------------
bool StringListParameter::fromString (const TChar* string, ParamValue& valueNormalized) const
{
	int32 index = 0;
	FOREACH_T(TChar*, str, strings)
		if (tstrcmp (str, string) == 0)
		{
			valueNormalized = toNormalized ((ParamValue)index);
			return true;
		}
		index++;
	ENDFOR
	return false;
}
Пример #11
0
bool srvComparePath(cEnvironmentHelper* pEnvironmentHelper, tcstring sPath1, tcstring sPath2, bool bCompareImages)
{
	cFile file1(pEnvironmentHelper, sPath1);
	cFile file2(pEnvironmentHelper, sPath2);
	if (0 == tstrcmp(file1.getFull(), file2.getFull()))
		return true;
	if (bCompareImages)
	{
		if (srvIsImageCopy(pEnvironmentHelper, file1, file2))
			return true;
	}
	return false;
}
Пример #12
0
int CAht::BuildGlobalIDSub( char *fname, char *pname, int i )
{
    int j,myid;
    AHTMODEL *m;
    j = i + 1; myid = 0;
    while(1) {								// 同じファイル、パスを探す
        if ( j >= model_cnt ) break;
        m = GetModel( j );
        if ( m != NULL ) {
            if ( m->GetGlobalId() == -1 ) {
                if ( tstrcmp( m->GetSource(), fname ) ) {
                    if ( tstrcmp( m->GetSourcePath(), pname ) ) {
                        myid++;
                        m->SetGlobalId( myid );
                    }
                }
            }
        }
        j++;
    }
    return myid;
}
Пример #13
0
static void test_DynStrFromCharP()
{
    DynStr * dstr;
    char_t * str;

    dstr = DynStrFromCharP(_T("hello"), 0);
    assert( 5 == DynStrLen(dstr) );
    str = DynStrGetCStr(dstr);
    assert( 0 == tstrcmp(_T("hello"), str));
    DynStrDelete(dstr);

    dstr = DynStrFromCharP2(_T("from"), _T("hell"));
    assert( 8 == DynStrLen(dstr) );
    str = DynStrGetCStr(dstr);
    assert( 0 == tstrcmp(_T("fromhell"), str));
    DynStrDelete(dstr);

    dstr = DynStrFromCharP3(_T("me"), _T(""), _T("llow"));
    assert( 6 == DynStrLen(dstr) );
    str = DynStrGetCStr(dstr);
    assert( 0 == tstrcmp(_T("mellow"), str));
    DynStrDelete(dstr);
}
Пример #14
0
void AHTMODEL::SetAHTOption( char *name, char *value )
{
    if (tstrcmp(name,"flag")) {
        int i;
        i = atoi( value );
        flag = i | AHTMODEL_FLAG_READY;
        return;
    }
    if (tstrcmp(name,"name")) {
        SetName( value );
        return;
    }
    if (tstrcmp(name,"class")) {
        SetClass( value );
        return;
    }
    if (tstrcmp(name,"author")) {
        SetAuthor( value );
        return;
    }
    if (tstrcmp(name,"ver")) {
        SetVersion( value );
        return;
    }
    if (tstrcmp(name,"icon")) {
        SetIconFile( value );
        return;
    }
    if (tstrcmp(name,"iconid")) {
        SetIconId( atoi( value ) );
        return;
    }
    if (tstrcmp(name,"exp")) {
        exp->PutStr( value );
        exp->PutCR();
        return;
    }
    if (tstrcmp(name,"helpkw")) {
        SetHelpKeyword( value );
        return;
    }
}
Пример #15
0
AHTPROP *AHTMODEL::GetPropertyFromAlias( char *propname )
{
    //		プロパティ名から検索
    //
    int i;
    char tmp[128];
    strcpy2( tmp, propname, 128 );
    strcase( tmp );
    for(i=0;i<prop_cnt;i++) {
        if ( tstrcmp( mem_prop[i]->name, tmp ) ) {
            return mem_prop[i];
        }
    }
    return NULL;
}
Пример #16
0
int AHTMODEL::GetPropertyID( char *propname )
{
    //		プロパティ名から検索
    //
    int i;
    char tmp[128];
    strcpy2( tmp, propname, 128 );
    strcase( tmp );
    for(i=0;i<prop_cnt;i++) {
        if ( tstrcmp( mem_prop[i]->orgname, tmp ) ) {
            return i;
        }
    }
    return -1;
}
Пример #17
0
char *AHTMODEL::GetAHTOption( char *name )
{
    if (tstrcmp(name,"flag")) {
        sprintf( s_flag, "%d", GetFlag() );
        return s_flag;
    }
    if (tstrcmp(name,"glid")) {
        sprintf( s_glid, "%d", GetGlobalId2() );
        return s_glid;
    }
    if (tstrcmp(name,"name")) {
        return GetName();
    }
    if (tstrcmp(name,"class")) {
        return GetClass();
    }
    if (tstrcmp(name,"author")) {
        return GetAuthor();
    }
    if (tstrcmp(name,"ver")) {
        return GetVersion();
    }
    if (tstrcmp(name,"icon")) {
        return GetIconFile();
    }
    if (tstrcmp(name,"exp")) {
        return exp->GetBuffer();
    }
    if (tstrcmp(name,"source")) {
        return fname;
    }
    if (tstrcmp(name,"helpkw")) {
        return GetHelpKeyword();
    }
    return (char *)&dummy;
}
Пример #18
0
bool srvIsWinSystemFile( cEnvironmentHelper* pEnvironmentHelper, cFile &file, bool* pbSystemName,  bool* pbSystemPath )
{
	tcstring sFullName = file.getFull();
	tcstring sFileName = file.getFilename();
	tstring  sLocation = NULL;
	bool bResult = false;
	if (pbSystemName)
		*pbSystemName = false;
	if (pbSystemPath)
		*pbSystemPath = false;
	for (unsigned i = 0; i < countof(arrSystemFiles); i++)
	{
		if (0 != tstrcmp(arrSystemFiles[i].filename, sFileName))
			continue;

		sLocation = pEnvironmentHelper->ExpandEnvironmentStr(arrSysLocations[arrSystemFiles[i].location]);
		if (!sLocation)
			break;
		if (tstrchar(sLocation) == _T('%') || tstrchar(sLocation) == 0) // expand failed
			break;
		if (sLocation[1] != ':')
			break;
		tstrupr(sLocation);
		if (pbSystemName)
			*pbSystemName = true;
		if (!tstrcmpinc(&sFullName, sLocation))
			break;
		while (tstrchar(sFullName) == '\\')
			sFullName = tstrinc(sFullName);
		if (sFullName != sFileName)
			break;
		if (pbSystemPath)
			*pbSystemPath = true;
		bResult = true;
		break;
	}
	if (sLocation)
		tstrfree(sLocation);
	return bResult;
}
Пример #19
0
int AHTMODEL::SetProp( AHTPROP *prop, char *name, char *value )
{
    int i,type;
    char tmp[32];
    AHTPROP *p;
    
    p = prop;
    
    strcpy2( tmp, name, 16 );
    strcase( tmp );
    i = -1;
    type = 0;
    if (tstrcmp(tmp,"name")) i = 0;
    if (tstrcmp(tmp,"help")) i = 1;
    if (tstrcmp(tmp,"default")) i = 2;
    
    if (tstrcmp(tmp,"sub")) i = 3;
    if (tstrcmp(tmp,"sub2")) i = 4;
    if (tstrcmp(tmp,"min")) i = 3;
    if (tstrcmp(tmp,"max")) i = 4;
    if (tstrcmp(tmp,"prm")) i = 3;
    if (tstrcmp(tmp,"opt")) i = 4;
    
    if (tstrcmp(tmp,"int")) { i = 5; type = AHTTYPE_EDIT_INT; }
    if (tstrcmp(tmp,"double")) { i = 5; type = AHTTYPE_EDIT_DOUBLE; }
    if (tstrcmp(tmp,"str")) { i = 5; type = AHTTYPE_EDIT_STRING; }
    if (tstrcmp(tmp,"combox")) { i = 5; type = AHTTYPE_CBOX_STRING; }
    if (tstrcmp(tmp,"chkbox")) { i = 5; type = AHTTYPE_CHKB_INT; }
    if (tstrcmp(tmp,"color")) { i = 5; type = AHTTYPE_COLS_INT; }
    if (tstrcmp(tmp,"font")) { i = 5; type = AHTTYPE_FONT_STRING; }
    if (tstrcmp(tmp,"file")) { i = 5; type = AHTTYPE_FILE_STRING; }
    if (tstrcmp(tmp,"exec")) { i = 5; type = AHTTYPE_EXTF_STRING; }
    
    if (tstrcmp(tmp,"parts")) { i = 5; type = AHTTYPE_PARTS_INT; }
    if (tstrcmp(tmp,"pprop")) { i = 5; type = AHTTYPE_PARTS_PROP_STRING; }
    if (tstrcmp(tmp,"popt")) { i = 5; type = AHTTYPE_PARTS_OPT_STRING; }
    
    //Alertf( "%s=%s(%d)", tmp, value, i );
    if ( i < 0 ) return -1;
    
    switch( i ) {
        case 0:
            SetPropName( p, value );
            break;
        case 1:
            SetPropHelp( p, value );
            break;
        case 2:
            SetPropDefval( p, value );
            break;
        case 3:
            SetPropDefval2( p, value );
            break;
        case 4:
            SetPropDefval3( p, value );
            break;
        case 5:
            p->ahttype = type;
            break;
    }
    
    return i;
}
Пример #20
0
void PediaMainForm::prepareAbout()
{
    PediaPreferences& prefs = application().preferences().pediaPrefs;

    infoRenderer_.clear();

    DefinitionModel* model = new_nt DefinitionModel();
    if (NULL == model)
    {
        application().alert(notEnoughMemoryAlert);
        return;
    }

    DefinitionModel::Elements_t& elems = model->elements;
    TextElement*  text;

    elems.push_back(text=new TextElement("Welcome to Encyclopedia."));
    text->setJustification(DefinitionElement::justifyCenter);
    text->setStyle(StyleGetStaticStyle(styleNameHeader));

    elems.push_back(new LineBreakElement(1, 2));
    elems.push_back(new LineBreakElement(1, 2));

    CDynStr str;
    const char_t* lang = GetLangNameByLangCode(prefs.languageCode, tstrlen(prefs.languageCode));
    if (NULL == str.AppendCharP3("You're using ", lang, " encyclopedia"))
        goto NoMemory;

    bool noStats = false;
    if (8 == tstrlen(prefs.dbDate))
    {
        if (NULL == str.AppendCharP(" last updated on "))
            goto NoMemory;
        if (NULL == str.AppendCharPBuf(prefs.dbDate, 4))
            goto NoMemory;
        if (NULL == str.AppendCharP("-"))
            goto NoMemory;
        if (NULL == str.AppendCharPBuf(&prefs.dbDate[4], 2))
            goto NoMemory;
        if (NULL == str.AppendCharP("-"))
            goto NoMemory;
        if (NULL == str.AppendCharPBuf(&prefs.dbDate[6], 2))
            goto NoMemory;
    }
    else
        noStats = true;

    if (prefs.articleCountNotChecked != prefs.articleCount)
    {
        char_t buffer[24];
        int len = formatNumber(prefs.articleCount, buffer, sizeof(buffer));
        if (NULL == str.AppendCharP(" with "))
            goto NoMemory;
        if (NULL == str.AppendCharPBuf(buffer, len))
            goto NoMemory;
        if (NULL == str.AppendCharP(" articles"))
            goto NoMemory;
    }
    else
        noStats = true;

//    if (noStats)
//        fetchStats();

    if (NULL == str.AppendCharP("."))
        goto NoMemory;

    elems.push_back(text = new TextElement(str.GetCStr()));
    text->setJustification(DefinitionElement::justifyLeft);

    uint_t l = 0;
    elems.push_back(text = new TextElement(" You can change encyclopedia to "));
    elems.back()->setJustification(DefinitionElement::justifyLeft);
    for (ulong_t i = 0; i < availLangCodesCount_; ++i)
    {
        const char_t* code = availLangCodes_[i];
        if (0 == tstrcmp(code, prefs.languageCode))
            continue;

        const char_t* name = GetLangNameByLangCode(code, tstrlen(code));
        assert(NULL != name);
        if (NULL == name)
            continue;

        text = new_nt TextElement(name);
        if (NULL == text)
            goto NoMemory;
        elems.push_back(text);
        elems.back()->setJustification(DefinitionElement::justifyLeft);

        if (NULL == str.AssignCharP(urlSchemaEncyclopedia urlSeparatorSchemaStr pediaUrlPartSetLang urlSeparatorSchemaStr))
            goto NoMemory;

        if (NULL == str.AppendCharP(code))
            goto NoMemory;

        text->setHyperlink(str.GetCStr(), hyperlinkUrl);

        const char_t* delim = _T(", ");
        ++l;
        if (availLangCodesCount_ - 2 == l)
            delim = _T(" or ");                        
        else if (availLangCodesCount_ - 1 == l)
            delim = NULL;

        if (NULL != delim)
        {
            text = new_nt TextElement(delim);
            if (NULL == text)
                goto NoMemory;
            elems.push_back(text);
            elems.back()->setJustification(DefinitionElement::justifyLeft);
        }    
    }

    elems.push_back(new LineBreakElement(1, 2));
    elems.push_back(new LineBreakElement(1, 2));
    //elems.back()->setJustification(DefinitionElement::justifyLeft);

    elems.push_back(new TextElement("You can "));
    elems.back()->setJustification(DefinitionElement::justifyLeft);

    elems.push_back(text = new TextElement("search"));
    elems.back()->setJustification(DefinitionElement::justifyLeft);

    text->setHyperlink(urlSchemaEncyclopedia urlSeparatorSchemaStr pediaUrlPartSearchDialog, hyperlinkUrl);
    elems.push_back(new TextElement(" for articles or get a "));
    elems.back()->setJustification(DefinitionElement::justifyLeft);

    elems.push_back(text = new TextElement("random"));
    if (NULL == str.AssignCharP(urlSchemaEncyclopediaRandom urlSeparatorSchemaStr))
        goto NoMemory;
    if (NULL == str.AppendCharP(prefs.languageCode))
        goto NoMemory;
    text->setHyperlink(str.GetCStr(), hyperlinkUrl);
    elems.back()->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(new TextElement(" article."));
    elems.back()->setJustification(DefinitionElement::justifyLeft);
    infoRenderer_.setModel(model, Definition::ownModel);
    return;
NoMemory:
    delete model;
    application().alert(notEnoughMemoryAlert);   
}
Пример #21
0
int AHTMODEL::SetAHTPropertyString( char *propname, char *str )
{
    //		AHT設定文字列を解析する
    //
    int res;
    int qmode;
    int amb;
    unsigned char a1;
    char *vp;
    char *pname;
    char *pvalue;
    AHTPROP *p;
    vp = str;
    res = 0;
    p = SetProperty( propname, NULL, NULL );
    
    while(1) {
        //		パラメーター名を抽出
        while(1) {
            a1=*vp;if ((a1!=32)&&(a1!=9)) break;
            vp++;
        }
        if ( a1 == 0 ) break;
        pname = vp;					// パラメーター名
        while(1) {
            a1=*vp;
            if ( a1 == 0 ) break;
            if ( a1 == ',' ) break;
            if ( a1 == '=' ) break;
            if (a1>=129) {					// 全角文字チェック
                if ((a1<=159)||(a1>=224)) {
                    vp++;
                }
            }
            vp++;
        }
        *vp = 0;
        if ( a1 == '=' ) {
            //		パラメーターを抽出
            vp++;
            qmode = 0;
            if ( *vp == 0x22 ) { qmode = 1; vp++; }
            pvalue = vp;
            while(1) {
                a1=*vp;
                if ( a1 == 0 ) break;
                if ( qmode == 0 ) {
                    if ( a1 == ',' ) { *vp++=0; break; }
                } else {
                    if ( a1 == 0x22 ) { *vp=0; qmode=0; }
                    if ( a1 == 0x5c ) {					// '¥' extra control
                        if ( vp[1] == 'n' ) {
                            vp[0] = 13; vp[1] = 10;
                        }
                        vp++;
                    }
                }
                if (a1>=129) {					// 全角文字チェック
                    if ((a1<=159)||(a1>=224)) {
                        vp++;
                    }
                }
                vp++;
            }
            if ( SetProp( p, pname, pvalue ) < 0 ) res = 1;
        } else {
            //		単独タイプ
            //
            amb = 1;
            if (tstrcmp(pname,"withid")) {
                p->SetMode( AHTMODE_WITH_ID );
                if ( p->newval == NULL ) {
                    char tmp[512];
                    strcpy( tmp, p->defval );
                    sprintf( tmp, "%s_%d", p->defval,id );
                    p->SetNewVal( tmp );
                }
                amb = 0;
            }
            if (tstrcmp(pname,"read")) {
                p->SetMode( AHTMODE_READ_ONLY );
                amb = 0;
            }
            if (tstrcmp(pname,"pure")) {
                p->SetMode( AHTMODE_OUTPUT_PURE );
                amb = 0;
            }
            if (tstrcmp(pname,"raw")) {
                p->SetMode( AHTMODE_OUTPUT_RAW );
                amb = 0;
            }
            if (tstrcmp(pname,"mes")) {
                p->ClearMode( AHTMODE_OUTPUT_PURE );
                amb = 0;
            }
            if (tstrcmp(pname,"refname")) {
                refprop = p;
                amb = 0;
            }
            
            if ( amb ) {
                if ( SetProp( p, pname, "" ) < 0 ) res = 1;
            }
            if ( a1 == ',' ) vp++;
        }
    }
    return res;
}
Пример #22
0
void tloop(int history)
{
	using_history();
	stifle_history(history);

	lookf(self.next);

	while(1){
		int fail = 0;
		struct tobj *prev = NULL;
		struct tobj *noun = NULL;
		char *input = readline(">> ");
		char *verbstr = input;
		char *nounstr = verbstr;
		add_history(verbstr);

		/* Blank out spaces and punctuation and set the noun as the last word */
		while(*input){
			if(!isalpha(*input)){
				*input = '\0';
				if(isalpha(*(input + 1))){
					nounstr = input + 1;
				}
			}
			++input;
		}
		input = verbstr; /* Restore input back to where it was */

		/* Do basic substition for shortcut commands */
		if(tstrequals(verbstr, 2, "n", "north")){
			verbstr = "go";
			nounstr = "north";
		}
		else if(tstrequals(verbstr, 2, "ne", "northeast")){
			verbstr = "go";
			nounstr = "northeast";
		}
		else if(tstrequals(verbstr, 2, "e", "east")){
			verbstr = "go";
			nounstr = "east";
		}
		else if(tstrequals(verbstr, 2, "se", "southeast")){
			verbstr = "go";
			nounstr = "southeast";
		}
		else if(tstrequals(verbstr, 2, "s", "south")){
			verbstr = "go";
			nounstr = "south";
		}
		else if(tstrequals(verbstr, 2, "sw", "southwest")){
			verbstr = "go";
			nounstr = "southwest";
		}
		else if(tstrequals(verbstr, 2, "w", "west")){
			verbstr = "go";
			nounstr = "west";
		}
		else if(tstrequals(verbstr, 2, "nw", "northwest")){
			verbstr = "go";
			nounstr = "northwest";
		}
		else if(tstrequals(verbstr, 1, "out")){
			verbstr = "go";
			nounstr = "out";
		}

		noun = tfind(&self, &prev, nounstr);
		if(noun == NULL){
			if(verbstr != nounstr){
				if(tstrequals(verbstr, 2, "go", "travel")){
					printf("You can't go ``%s'' here.\n", nounstr);
				}
				else{
					printf("You don't see ``%s'' here.\n", nounstr);
				}
				fail = 1;
			}
			else{
				prev = NULL;
				noun = self.next;
			}
		}
		if(!fail){
			if(tstrcmp(verbstr, "look") == 0){
				lookf(noun);
			}
			else if(tstrequals(verbstr, 2, "i", "inventory")){
				lookf(&self);
			}
			else if(tstrequals(verbstr, 3, "eat", "consume", "ingest")){
				eatf(prev, noun);
			}
			else if(tstrequals(verbstr, 2, "go", "travel")){
				gof(noun);
			}
			else if(tstrequals(verbstr, 3, "drop", "leave", "abandon")){
				dropf(prev, noun);
			}
			else if(tstrequals(verbstr, 3, "talk", "say", "speak")){
				talkf(noun);
			}
			else if(tstrequals(verbstr, 6, "break", "smash", "kick", "punch", "headbutt", "kill")){
				breakf(noun);
			}
			else if(tstrcmp(verbstr, "unlock") == 0){
				unlockf(noun);
			}
			else if(tstrequals(verbstr, 2, "lock", "bar")){
				lockf(noun);
			}
			else if(tstrequals(verbstr, 5, "pick", "get", "take", "steal", "pack")){
				pickf(prev, noun);
			}
			else{
				printf("Don't know how to ``%s.''\n", verbstr);
				fail = 1;
			}
		}
		free(input);
	}
}
Пример #23
0
inline bool CField::operator!=(const tchar* sValue) const
{
	return (tstrcmp(sValue, GetString()) != 0);
}