예제 #1
0
파일: alloc.cpp 프로젝트: f3yagi/mysrc
int SymbolEqual(LispObject symbol1, char *symbol2)
{
    int r;

    CHECK_SYMBOL(symbol1);
    r = StrEqual(LSYMBOL(symbol1)->name, symbol2);
    return r;
}    
예제 #2
0
파일: alloc.cpp 프로젝트: f3yagi/mysrc
static int StringEqual(LispObject str1, LispObject str2)
{
    int r;
    
    CHECK_STRING(str1);
    CHECK_STRING(str2);
    r = StrEqual(LSTRING(str1)->str, LSTRING(str2)->str);
    return r;
}
예제 #3
0
파일: alloc.cpp 프로젝트: f3yagi/mysrc
struct LispCFunction *GetCFunction(char *name)
{
    int i;
    
    for (i = 0; i < CfunctionPointer; i++) {
        int r = StrEqual(Cfunction[i].name, name);
        if (r) return &Cfunction[i];
    }
    return NULL;
}
예제 #4
0
파일: strio.c 프로젝트: CESNET/glite-lb
/*************************************************************************
 * StrEqualLocale
 */
int StrEqualLocale(const char *first, const char *second)
{
  assert(VALID(first));
  assert(VALID(second));

#if defined(LC_COLLATE)
  return (strcoll(first, second) == 0);
#else
  return StrEqual(first, second);
#endif
}
예제 #5
0
파일: util_str.c 프로젝트: borland667/pbis
BOOLEAN
StrnEqual(
    PCSTR pszStr1,
    PCSTR pszStr2,
    DWORD dwChars
    )
{
    DWORD dwLen1, dwLen2;
    PSTR pszCopy1 = NULL;
    PSTR pszCopy2 = NULL;
    BOOLEAN bResult = FALSE;

    /* If same pointer, then must be equal */

    if (pszStr1 == pszStr2)
        return TRUE;

    /* If either is NULL, cannot be substrings */

    if (!pszStr1 || !pszStr2)
        return FALSE;

    dwLen1 = strlen(pszStr1);
    dwLen2 = strlen(pszStr2);

    pszCopy1 = _wbc_strdup(pszStr1);
    if (!pszCopy1)
    {
        goto cleanup;
    }

    pszCopy2 = _wbc_strdup(pszStr2);
    if (!pszCopy2)
    {
        goto cleanup;
    }

    if (dwLen1 > dwChars) {
        *(pszCopy1 + dwChars) = '\0';
    }
    if (dwLen2 > dwChars) {
        *(pszCopy2 + dwChars) = '\0';
    }

    bResult = StrEqual(pszCopy1, pszCopy2);

cleanup:
    _WBC_FREE(pszCopy1);
    _WBC_FREE(pszCopy2);

    return bResult;
}
예제 #6
0
void PathCutExtension(char * path, char * ext)
{
	UInt16 path_len;
	UInt16 ext_len;

	path_len = StrLen(path);
	ext_len = StrLen(ext);

	if (path_len > ext_len+1) {
		path_len -= ext_len + 1;
		if (path[path_len] == '.' && StrEqual(ext, &path[path_len+1])) {		
			path[path_len] = 0;
		}
	}
}
예제 #7
0
void main()
{
    LinkString *s1, *s2, *s3, *s4, *s5, *s6, *s7;
    Assign(s1, "abcd");
    printf("s1:");
    DispStr(s1);
    printf("s1的长度:%d\n", StrLength(s1));
    printf("s1=>s2\n");
    StrCopy(s2, s1);
    printf("s2:");
    DispStr(s2);
    printf("s1和s2%s\n", (StrEqual(s1, s2) == 1 ? "相同" : "不相同"));
    Assign(s3, "12345678");
    printf("s3:");
    DispStr(s3);
    printf("s1和s3连接=>s4\n");
    s4 = Concat(s1, s3);
    printf("s4:");
    DispStr(s4);
    printf("s3[2..5]=>s5\n");
    s5 = SubStr(s3, 2, 4);
    printf("s5:");
    DispStr(s5);
    Assign(s6, "567");
    printf("s6:");
    DispStr(s6);
    printf("s6在s3中位置:%d\n", Index(s3, s6));
    printf("从s3中删除s3[3..6]字符\n");
    DelStr(s3, 3, 4);
    printf("s3:");
    DispStr(s3);
    printf("从s4中将s6替换成s1=>s7\n");
    s7 = RepStrAll(s4, s6, s1);
    printf("s7:");
    DispStr(s7);
}
예제 #8
0
wbcErr
wbcDomainInfo(
    IN const char *domain,
    OUT struct wbcDomainInfo **info
    )
{
    wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
    DWORD dwErr = LW_ERROR_INTERNAL;
    HANDLE hLsa = (HANDLE)NULL;
    PLSASTATUS pLsaStatus = NULL;
    struct wbcDomainInfo *pWbcDomInfo = NULL;
    PLSA_TRUSTED_DOMAIN_INFO pLsaDomInfo = NULL;
    PLSA_AUTH_PROVIDER_STATUS pADProvStatus = NULL;
    int i = 0;

    /* Sanity check */

    BAIL_ON_NULL_PTR_PARAM(domain, dwErr);
    BAIL_ON_NULL_PTR_PARAM(info, dwErr);

    /* Work */

    dwErr = LsaOpenServer(&hLsa);
    BAIL_ON_LSA_ERR(dwErr);
    
    dwErr = LsaGetStatus(hLsa, &pLsaStatus);
    BAIL_ON_LSA_ERR(dwErr);

    /* Find the AD provider entry */

    for (i=0; i<pLsaStatus->dwCount; i++)
    {
        if (strcmp(pLsaStatus->pAuthProviderStatusList[i].pszId,
                   LSA_PROVIDER_TAG_AD) == 0)
        {
            pADProvStatus = &pLsaStatus->pAuthProviderStatusList[i];
            break;
        }
    }

    if (pADProvStatus == NULL)
    {
        dwErr = LW_ERROR_NO_SUCH_DOMAIN;
        BAIL_ON_LSA_ERR(dwErr);
    }

    /* Find the requested domain */

    for (i=0; i<pADProvStatus->dwNumTrustedDomains; i++)
    {
        PLSA_TRUSTED_DOMAIN_INFO pCursorDomInfo = NULL;

        pCursorDomInfo = &pADProvStatus->pTrustedDomainInfoArray[i];
        if (StrEqual(pCursorDomInfo->pszDnsDomain, domain) ||
            StrEqual(pCursorDomInfo->pszNetbiosDomain, domain))
        {
            pLsaDomInfo = pCursorDomInfo;
            break;            
        }
    }

    if (pLsaDomInfo == NULL)
    {
        dwErr = LW_ERROR_NO_SUCH_DOMAIN;
        BAIL_ON_LSA_ERR(dwErr);
    }

    /* Fill in the domain info */

    pWbcDomInfo = _wbc_malloc_zero(
                      sizeof(struct wbcDomainInfo),
                      FreeWbcDomainInfo);
    BAIL_ON_NULL_PTR(pWbcDomInfo, dwErr);

    dwErr = FillDomainInfo(pWbcDomInfo, pLsaDomInfo);
    BAIL_ON_LSA_ERR(dwErr);

    *info = pWbcDomInfo;
    pWbcDomInfo = NULL;

cleanup:
    
    if (pLsaStatus)
    {
        LsaFreeStatus(pLsaStatus);
    }

    if (hLsa != (HANDLE)NULL) {
        LsaCloseServer(hLsa);
    }

    _WBC_FREE(pWbcDomInfo);
    
    wbc_status = map_error_to_wbc_status(dwErr);

    return wbc_status;
}
예제 #9
0
static Bool ArgMatch(RuleArg * pattern, Var * arg, RuleArgVariant parent_variant)
{
    Type * atype;
    Var * pvar, * left, * right;
    UInt8 j;
    RuleArgVariant v = pattern->variant;

    if (arg == NULL) return v == RULE_ANY;

    atype = arg->type;

    switch(v) {

    case RULE_ADD:
    case RULE_SUB:
        right = arg->var;

        // If we have variable and not arithmetic operation, try to match using substraction or addition with 0
        // %A => %A-0 or %A+0

        if (arg->mode == INSTR_VAR || arg->mode == INSTR_INT) {
            left  = arg;
            right = ZERO;
        } else {
            if (v == RULE_ADD && arg->mode != INSTR_ADD) return false;
            if (v == RULE_SUB && arg->mode != INSTR_SUB) return false;
            left = arg->adr;
        }
        if (!ArgMatch(pattern->index, right, v)) return false;
        return ArgMatch(pattern->arr, left, v);
        break;

    // <X>..<Y>
    case RULE_RANGE:
        if (arg->mode != INSTR_RANGE) return false;		// pattern expects element, and variable is not an element
        if (!ArgMatch(pattern->index, arg->var, v)) return false;
        return ArgMatch(pattern->arr, arg->adr, v);
        break;

    // In case of destination register, we ignore all flag registers, that are specified in pattern and not specified in argument.
    // I.e. instruction may affect more flags, than the source instruction requires.
    // All flags defined by source instruction (argument) must be part of pattern though.

    // <X>,<Y>
    case RULE_TUPLE:
        if (arg->mode != INSTR_TUPLE) return false;
        if (!ArgMatch(pattern->index, arg->var, v)) return false;
        return ArgMatch(pattern->arr, arg->adr, v);
        break;

    // <X>$<Y>
    case RULE_BYTE:
        if (arg->mode != INSTR_BYTE) return false;		// pattern expects byte, and variable is not an byte
        if (!ArgMatch(pattern->index, arg->var, v)) return false;
        return ArgMatch(pattern->arr, arg->adr, v);
        break;

    // <X>(<Y>)
    case RULE_ELEMENT:
        if (arg->mode != INSTR_ELEMENT) return false;		// pattern expects element, and variable is not an element
        if (!ArgMatch(pattern->index, arg->var, v)) return false;
        return ArgMatch(pattern->arr, arg->adr, v);
        break;

    // const %A:type
    case RULE_CONST:
        if (!VarIsConst(arg)) return false;
        if (!VarMatchesPattern(arg, pattern)) return false;
        break;

    // Exact variable.
    case RULE_REGISTER:
        pvar = pattern->var;
        if (VarIsConst(pvar)) {
            if (!VarIsConst(arg)) return false;
            if (pvar->mode == INSTR_TEXT) {
                if (!StrEqual(pvar->str, arg->str)) return false;
            } else if (pvar->mode == INSTR_INT) {
//				if (pvar->value_nonempty) {
                if (arg->mode != INSTR_INT || !IntEq(&pvar->n, &arg->n)) return false;
//				}
            }
        } else {
            if (pattern->var != NULL && !VarIsEqual(arg, pattern->var)) return false;
        }
        break;

    case RULE_VARIANT:
        if (!VarIsOneOf(arg, pattern->var)) return false;
        break;

    case RULE_VARIABLE:
        if (arg->mode != INSTR_VAR) return false;
        if (FlagOn(arg->submode, SUBMODE_REG)) return false;
        if (parent_variant != RULE_BYTE && !VarMatchesPattern(arg, pattern)) return false;
        break;

    // @%A
    case RULE_DEREF:
        if (arg->mode != INSTR_DEREF) return false;
        arg = arg->var;
        if (!ArgMatch(pattern->arr, arg, v)) return false;
//		if (!VarMatchesPattern(arg, pattern)) return false;
        break;

    // %A:type
    case RULE_ARG:
        // In Emit phase, we need to exactly differentiate between single variable and byte offset.
        if (arg->mode == INSTR_VAR || VarIsConst(arg) || (arg->mode == INSTR_BYTE && MATCH_MODE != PHASE_EMIT)) {
            if (parent_variant != RULE_TUPLE && FlagOn(arg->submode, SUBMODE_REG)) return false;
            if (!VarMatchesPattern(arg, pattern)) return false;
        } else {
            return false;
        }
//		if (arg->mode == INSTR_DEREF || arg->mode == INSTR_RANGE || (arg->mode == INSTR_BYTE && MATCH_MODE == PHASE_EMIT) || arg->mode == INSTR_ELEMENT) return false;
//		if (parent_variant != RULE_TUPLE && FlagOn(arg->submode, SUBMODE_REG)) return false;
//		if (!VarMatchesPattern(arg, pattern)) return false;
        break;

    case RULE_ANY:
        break;

    default:
        break;
    }

    // If there is macro argument number %A-%Z specified in rule argument, we set or check it here

    if (pattern->arg_no != 0) {

        // For array element variable store array into the macro argument

        pvar = arg;
//		if (arg->mode == INSTR_ELEMENT && !VarIsStructElement(arg)) {
//			pvar = arg->adr;
//		}

        j = pattern->arg_no-1;
        if (MACRO_ARG[j] == NULL) {
            MACRO_ARG[j] = pvar;
        } else {
            if (MACRO_ARG[j] != pvar) return false;
        }

        // Set the index items

//		if (pattern->index != NULL) {
//			if (!ArgMatch(pattern->index, arg->var)) return false;
//		}
    }
    return true;
}
예제 #10
0
void NativePlayerWnd::ProcessFSCommand( char* cmd, char* args )
{
    if ( StrEqual(cmd, "quit") )
    {
        // Quit
        ExitApp();
    }
    else if ( StrEqual(cmd, "fullscreen") )
    {
        SetFullScreen( IsTrue(args) != 0 );
    }
    else if ( StrEqual(cmd, "allowscale") )
    {
        SetScaleMode( IsTrue(args) );
    }
    else if ( StrEqual(cmd, "exec") )
    {
        // make sure we don't pass any parameters
        // to the app we want to spawn. We don't want
        // anybody to do "del *.*"
        int     len = strlen(args) + 1;
        char    *tmpString = new char[len];

        if ( tmpString == 0 )
            return;

        for ( int i = 0; i < len; i++ )
        {
            tmpString[i] = args[i];
            if ( tmpString[i] == ' ' )
            {
                tmpString[i] = 0;
                break;
            }
        }
        ExecSystem( tmpString );
        delete [] tmpString;
    }
    else if ( StrEqual(cmd, "showmenu") )
    {
        // Toggle the full screen flags
        /*
        showMenu = IsTrue(args);
        HMENU hMenu = GetMenu( hwnd );

        if (!showMenu)
        {
        	if (hMenu)
        	{
        		// Save and clear the menu bar
        		savedMenu = hMenu;
        		SetMenu( hwnd, 0);
        	}
        }
        else
        {
        	SetMenu( hwnd, savedMenu );
        }
        */
    }
    else
    {
        flash->command(cmd, args);
    }
}