Пример #1
0
static int parseArgs(int argc, char **argv)
{
    char    *argp, *ip, *cp;
    int     nextArg;

    assert(app);
    nextArg = 0;
    argp = argv[nextArg++];

    if (scmp(argp, "--host") == 0 || scmp(argp, "-h") == 0) {
        ip = argv[nextArg++];
        if (ip == 0) {
            return MPR_ERR_BAD_ARGS;
        }
        if (sncmp(ip, "http://", 7) == 0) {
            ip += 7;
        }
        if ((cp = strchr(ip, ':')) != 0) {
            *cp++ = '\0';
            app->port = atoi(cp);
        } else {
            app->port = 80;
        }
        app->host = sclone(ip);
    }
    return nextArg - 1;
}
Пример #2
0
	int isdomain(char *str)
	{
		char d_ru[] = "ru";
		char d_com[] = "com";
		char d_org[] = "org";
		char *EL[MAXSIZE];
		int i;
		if (6 > slen(str))
			return 0;
		int Z = stok(str, '.', EL);
		if (!((scmp(EL[Z - 1], d_ru) == 0) || (scmp(EL[Z - 1], d_com) == 0) || (scmp(EL[Z - 1], d_org) == 0)))
		{
			suntok(str, '.', EL, Z);
			return 0;
		}
		suntok(str, '.', EL, Z);
		if (3 != Z)
			return 0;
		for (i = 0; str[i] != '\0'; i++)
		{
			if (!((str[i] >= 'A')&&(str[i] <= 'Z') || ( (str[i] >= 'a')&&(str[i] <= 'z')) || str[i] == '.' ))
				return 0;
		}
		return 1;
	}
Пример #3
0
int main(){
  char s[10]="hello";
  printf("%s: %d\n",s,slen(s)); //testing for slen
  char cpy[15]="aba";
  printf("After scpy, %s became: ",cpy);
  scpy(cpy,s);
  printf("%s\n",cpy);
  char ncpy[15]="abalaba";
  printf("After sncpy (n=3), %s became: ",ncpy);
  sncpy(ncpy,s,3);
  printf("%s\n",ncpy);
  char cat[15]="AddOn";
  printf("After scat, %s became: ",cpy);
  scat(cpy,cat);
  printf("%s\n",cpy);
  char s2[18]="hello";
  char s3[5]="po";
  char s4[5]="bao";
  printf("scmp %s and %s: %d\n",s,s2,scmp(s,s2));
  printf("scmp %s and %s: %d\n",s,cpy,scmp(s,cpy));
  printf("scmp %s and %s: %d\n",s,s3,scmp(s,s3));
  printf("scmp %s and %s: %d\n",s,s4,scmp(s,s4));
  printf("schr %s and %c: %s\n",s,'l',schr(s,'l'));
  printf("schr %s and %c: %s\n",s,'t',schr(s,'t'));
  char s5[5]="el";
  printf("sstr %s and %s: %s\n",s,s5,sstr(s,s5));
  printf("sstr %s and %s: %s\n",s,s3,sstr(s,s3));
  return 0;
}
Пример #4
0
HANDLE STDCALL OSFindFirstFile(CTSTR lpFileName, OSFindData &findData)
{
    WIN32_FIND_DATA wfd;
    HANDLE hFind = FindFirstFile(lpFileName, &wfd);

    if(hFind == INVALID_HANDLE_VALUE)
        hFind = NULL;
    else
    {
        BOOL bFoundDumbDir;
        do
        {
            bFoundDumbDir = FALSE;
            if( (scmp(wfd.cFileName, TEXT("..")) == 0) ||
                (scmp(wfd.cFileName, TEXT(".")) == 0)  )
            {
                if(!FindNextFile(hFind, &wfd))
                {
                    FindClose(hFind);
                    return NULL;
                }
                bFoundDumbDir = TRUE;
            }
        }while(bFoundDumbDir);

        scpy(findData.fileName, wfd.cFileName);
        findData.bDirectory = (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
        findData.bHidden = (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0;
    }

    return hFind;
}
Пример #5
0
	size_t
	Hashdh::search(uchar *w, size_t len)
	{
		size_t hval = bitwisehash(w, len, tsize);
		size_t next;

		if(!b_ht->access(hval))
			return (size_t)-1;

		if(scmp(hash->getField(hval), w, len) == 0)
			return b_ht->rank1(hval)-1;

		//using double hashing
		size_t h2 = step_value(w, len, tsize);

		for(uint i=1 ; i<tsize ; i++ ){
			next = (hval + i*h2)%tsize;

			if(!b_ht->access(next))
				return (size_t)-1;

			if(scmp(hash->getField(next), w, len) == 0)
				return b_ht->rank1(next)-1;
		}

		return (size_t)-1;
	}
Пример #6
0
BOOL  STDCALL OSFindNextFile(HANDLE hFind, OSFindData &findData)
{
    WIN32_FIND_DATA wfd;
    BOOL bSuccess = FindNextFile(hFind, &wfd);

    if (bSuccess)
    {
        BOOL bFoundDumbDir;
        do
        {
            bFoundDumbDir = FALSE;
            if( (scmp(wfd.cFileName, TEXT("..")) == 0) ||
                (scmp(wfd.cFileName, TEXT(".")) == 0)  )
            {
                if(!FindNextFile(hFind, &wfd))
                {
                    bSuccess = FALSE;
                    break;
                }
                bFoundDumbDir = TRUE;
            }
        }while(bFoundDumbDir);
    }

    if(bSuccess)
    {
        scpy(findData.fileName, wfd.cFileName);
        findData.bDirectory = (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
        findData.bHidden = (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0;
    }
    else
        *findData.fileName = 0;

    return bSuccess;
}
Пример #7
0
String ConvertTypeToString(TypeInfo &ti, TypeInfo *subType=NULL)
{
    if(!ti.name || !ti.name[0])
        return String() << TEXT("void");
    else if(ti.type == DataType_Object)
    {
        Class *cls = FindClass(ti.name);
        assert(cls);
        while(cls->IsPureScriptClass()) cls = cls->GetParent();
        return String() << cls->GetName() << TEXT("*");
    }
    else if(ti.type == DataType_String)
        return String() << TEXT("String");
    else if(ti.type == DataType_List)
        return String() << TEXT("List<") << ConvertTypeToString(*subType) << TEXT(">");
    else if(ti.type == DataType_Type)
        return String() << TEXT("TypeDataInfo");
    else if(scmp(ti.name, TEXT("bool")) == 0)
        return String() << TEXT("BOOL");
    else if(scmp(ti.name, TEXT("icolor")) == 0)
        return String() << TEXT("DWORD");
    else if(scmp(ti.name, TEXT("handle")) == 0)
        return String() << TEXT("HANDLE");
    else
        return String() << ti.name;
}
Пример #8
0
/*  
    Exit the application
    static function exit(status: Number, how: String = "default"): void
    MOB - status is not implemented
 */
static EjsObj *app_exit(Ejs *ejs, EjsObj *unused, int argc, EjsObj **argv)
{
    cchar   *how;
    int     status, mode;

    if (ejs->dontExit) {
        ejsThrowStateError(ejs, "App.exit has been disabled");
        return 0;
    }
    status = argc >= 1 ? ejsGetInt(ejs, argv[0]) : 0;
    how = ejsToMulti(ejs, argc >= 2 ? ejsToString(ejs, argv[1]): ESV(empty));

    if (scmp(how, "default") == 0) {
        mode = MPR_EXIT_DEFAULT;
    } else if (scmp(how, "immediate") == 0) {
        mode = MPR_EXIT_IMMEDIATE;
    } else if (scmp(how, "graceful") == 0) {
        mode = MPR_EXIT_GRACEFUL;
    } else {
        mode = MPR_EXIT_NORMAL;
    }
    mprTerminate(mode, status);
    ejsAttention(ejs);
    return 0;
}
Пример #9
0
BOOL   STDCALL OSIncompatibleModulesLoaded()
{
    StringList  moduleList;
    
    //Modules that will likely cause OBS to crash because they hooked it.
    //This list is checked on stream start only.

    if (!OSGetLoadedModuleList(GetCurrentProcess(), moduleList))
        return 0;

    for(UINT i=0; i<moduleList.Num(); i++)
    {
        CTSTR moduleName = moduleList[i];

        if (!scmp(moduleName, TEXT("dxtorycore.dll")) ||        //DXTory
            !scmp(moduleName, TEXT("dxtorycore64.dll")) ||      //DXTory
            !scmp(moduleName, TEXT("dxtorymm.dll")) ||          //DXTory
            !scmp(moduleName, TEXT("dxtorymm64.dll")) ||        //DXTory
            !scmp(moduleName, TEXT("rtsshooks.dll")) ||         //EVGA Precision OSD
            !scmp(moduleName, TEXT("axonoverlay.dll")) ||       //Dolby Axon
            !scmp(moduleName, TEXT("action_x86.dll")) ||        //Action!
            !scmp(moduleName, TEXT("action_x64.dll")))          //Action!
        {
            return 1;
        }
        else if (!scmp(moduleName, TEXT("atkdx11disp.dll")))     //ASUS GamerOSD
        {
            //ASUS GamerOSD is so terrible we can't even cleanly shutdown once it loads, trying to unload D3D crashes too (!)
            CrashError (TEXT("ASUS GamerOSD has been detected. This program installs user mode driver hooks which will corrupt the Direct3D state and crash OBS. Please uninstall ASUS GamerOSD if you wish to use OBS."));
        }
    }

    return 0;
}
Пример #10
0
BOOL CALLBACK GraphicsCaptureFindWindow(HWND hwnd, LPARAM lParam)
{
    TCHAR windowClass[256];
    TCHAR windowExecutable[MAX_PATH];

    windowClass[_countof(windowClass)-1] = windowExecutable[MAX_PATH-1] = 0;

    FindWindowData *fwd = (FindWindowData *)lParam;

    if (!IsWindowVisible(hwnd))
        return TRUE;

    if (GetClassName(hwnd, windowClass, _countof(windowClass) - 1) && !scmp(windowClass, fwd->classname))
    {
        //handle old sources which lack an exe name
        if (fwd->exename.IsEmpty())
            return TRUE;

        DWORD processID;
        GetWindowThreadProcessId(hwnd, &processID);

        HANDLE hProc = fwd->pOpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
        if (hProc)
        {
            DWORD wLen = _countof(windowExecutable) - 1;
            if (QueryFullProcessImageName(hProc, 0, windowExecutable, &wLen))
            {
                TCHAR *p;
                p = wcsrchr(windowExecutable, '\\');
                if (p)
                    p++;
                else
                    p = windowExecutable;

                slwr(p);

                if (!scmp(p, fwd->exename))
                {
                    CloseHandle(hProc);
                    fwd->hwnd = hwnd;
                    return FALSE;
                }
            }
            else
            {
                RUNONCE Log(TEXT("OpenProcess worked but QueryFullProcessImageName returned %d for pid %d?"), GetLastError(), processID);
            }

            CloseHandle(hProc);
        }
    }

    return TRUE;
}
Пример #11
0
EXTERN int val_compare( value a, value b ) {
	char tmp_buf[32];
	switch( C(val_type(a),val_type(b)) ) {
	case C(VAL_INT,VAL_INT):
		return icmp(val_int(a),val_int(b));
	case C(VAL_INT32,VAL_INT):
		return icmp(val_int32(a),val_int(b));
	case C(VAL_INT,VAL_INT32):
		return icmp(val_int(a),val_int32(b));
	case C(VAL_INT32,VAL_INT32):
		return icmp(val_int32(a),val_int32(b));
	case C(VAL_INT,VAL_FLOAT):
		return fcmp(val_int(a),val_float(b));
	case C(VAL_INT32,VAL_FLOAT):
		return fcmp(val_int32(a),val_float(b));
	case C(VAL_INT,VAL_STRING):
		return scmp(tmp_buf,sprintf(tmp_buf,"%d",val_int(a)),val_string(b),val_strlen(b));
	case C(VAL_INT32,VAL_STRING):
		return scmp(tmp_buf,sprintf(tmp_buf,"%d",val_int32(a)),val_string(b),val_strlen(b));
	case C(VAL_FLOAT,VAL_INT):
		return fcmp(val_float(a),val_int(b));
	case C(VAL_FLOAT,VAL_INT32):
		return fcmp(val_float(a),val_int32(b));
	case C(VAL_FLOAT,VAL_FLOAT):
		return fcmp(val_float(a),val_float(b));
	case C(VAL_FLOAT,VAL_STRING):
		return scmp(tmp_buf,sprintf(tmp_buf,FLOAT_FMT,val_float(a)),val_string(b),val_strlen(b));
	case C(VAL_STRING,VAL_INT):
		return scmp(val_string(a),val_strlen(a),tmp_buf,sprintf(tmp_buf,"%d",val_int(b)));
	case C(VAL_STRING,VAL_INT32):
		return scmp(val_string(a),val_strlen(a),tmp_buf,sprintf(tmp_buf,"%d",val_int32(b)));
	case C(VAL_STRING,VAL_FLOAT):
		return scmp(val_string(a),val_strlen(a),tmp_buf,sprintf(tmp_buf,FLOAT_FMT,val_float(b)));
	case C(VAL_STRING,VAL_BOOL):
		return scmp(val_string(a),val_strlen(a),val_bool(b)?"true":"false",val_bool(b)?4:5);
	case C(VAL_BOOL,VAL_STRING):
		return scmp(val_bool(a)?"true":"false",val_bool(a)?4:5,val_string(b),val_strlen(b));
	case C(VAL_STRING,VAL_STRING):
		return scmp(val_string(a),val_strlen(a),val_string(b),val_strlen(b));
	case C(VAL_BOOL,VAL_BOOL):
		return (a == b) ? 0 : (val_bool(a) ? 1 : -1);
	case C(VAL_OBJECT,VAL_OBJECT):
		if( a == b )
			return 0;
		{
			value tmp = val_field(a,id_compare);
			if( tmp == val_null )
				return invalid_comparison;
			a = val_callEx(a,tmp,&b,1,NULL);
		}
		if( val_is_int(a) )
			return val_int(a);
		return invalid_comparison;
	default:
		if( a == b )
			return 0;
		return invalid_comparison;
	}
}
Пример #12
0
/*
    Get a password digest using the MD5 algorithm -- See RFC 2617 to understand this code.
 */ 
static char *calcDigest(HttpConn *conn, DigestData *dp, cchar *username)
{
    HttpAuth    *auth;
    char        *digestBuf, *ha1, *ha2;

    auth = conn->rx->route->auth;
    if (!conn->user) {
        conn->user = mprLookupKey(auth->userCache, username);
    }
    assert(conn->user && conn->user->password);
    if (conn->user == 0 || conn->user->password == 0) {
        return 0;
    }

    /*
        Compute HA1. Password is already expected to be in the HA1 format MD5(username:realm:password).
     */
    ha1 = sclone(conn->user->password);

    /*
        HA2
     */ 
    ha2 = mprGetMD5(sfmt("%s:%s", conn->rx->method, dp->uri));

    /*
        H(HA1:nonce:HA2)
     */
    if (scmp(dp->qop, "auth") == 0) {
        digestBuf = sfmt("%s:%s:%s:%s:%s:%s", ha1, dp->nonce, dp->nc, dp->cnonce, dp->qop, ha2);
    } else {
        digestBuf = sfmt("%s:%s:%s", ha1, dp->nonce, ha2);
    }
    return mprGetMD5(digestBuf);
}
Пример #13
0
static void makeAltBody(HttpConn *conn, int status)
{
    HttpRx      *rx;
    HttpTx      *tx;
    cchar       *statusMsg, *msg;

    rx = conn->rx;
    tx = conn->tx;
    assert(rx && tx);

    statusMsg = httpLookupStatus(conn->http, status);
    msg = "";
    if (rx && (!rx->route || rx->route->flags & HTTP_ROUTE_SHOW_ERRORS)) {
        msg = conn->errorMsg;
    }
    if (rx && scmp(rx->accept, "text/plain") == 0) {
        tx->altBody = sfmt("Access Error: %d -- %s\r\n%s\r\n", status, statusMsg, msg);
    } else {
        tx->altBody = sfmt("<!DOCTYPE html>\r\n"
            "<head>\r\n"
            "    <title>%s</title>\r\n"
            "    <link rel=\"shortcut icon\" href=\"data:image/x-icon;,\" type=\"image/x-icon\">\r\n"
            "</head>\r\n"
            "<body>\r\n<h2>Access Error: %d -- %s</h2>\r\n<pre>%s</pre>\r\n</body>\r\n</html>\r\n",
            statusMsg, status, statusMsg, mprEscapeHtml(msg));
    }
    tx->length = slen(tx->altBody);
}
Пример #14
0
/*  
    Return the value of a keyword in the content returned from the last request
    Format either: 
        KEYWORD=value<
        KEYWORD: value,
        "KEYWORD": value,
        "KEYWORD": value,
    Return 0 on errors. Caller must free result.
 */
char *lookupValue(MprTestGroup *gp, char *key)
{
    char    *nextToken, *bp, *result;

    if (gp->content == NULL) {
        gp->content = httpReadString(getConn(gp));
    }
    if (gp->content == 0 || (nextToken = strstr(gp->content, key)) == 0) {
        return 0;
    }
    nextToken += slen(key);
    if (*nextToken != '=' && *nextToken != ':' && *nextToken != '"') {
        return 0;
    }
    if (*nextToken == '"') {
        nextToken++;
    }
    if (*nextToken == ':') {
        nextToken += 2;
    } else {
        nextToken += 1;
    }
    result = sclone(nextToken);
    for (bp = result; *bp && *bp != '<' && *bp != ','; bp++) {
        ;
    }
    *bp++ = '\0';
    if (scmp(result, "null") == 0) {
        return 0;
    }
    return result;
}
Пример #15
0
    bool Init(CTSTR lpFile)
    {
        strFile = lpFile;

        if(!fileOut.Open(lpFile, XFILE_CREATEALWAYS, 1024*1024))
            return false;

        fileOut.OutputDword(DWORD_BE(0x20));
        fileOut.OutputDword(DWORD_BE('ftyp'));
        fileOut.OutputDword(DWORD_BE('isom'));
        fileOut.OutputDword(DWORD_BE(0x200));
        fileOut.OutputDword(DWORD_BE('isom'));
        fileOut.OutputDword(DWORD_BE('iso2'));
        fileOut.OutputDword(DWORD_BE('avc1'));
        fileOut.OutputDword(DWORD_BE('mp41'));

        fileOut.OutputDword(DWORD_BE(0x8));
        fileOut.OutputDword(DWORD_BE('free'));

        mdatStart = fileOut.GetPos();
        fileOut.OutputDword(DWORD_BE(0x1));
        fileOut.OutputDword(DWORD_BE('mdat'));
#ifdef USE_64BIT_MP4
        fileOut.OutputQword(0);
#endif

        bMP3 = scmp(App->GetAudioEncoder()->GetCodec(), TEXT("MP3")) == 0;

        audioFrameSize = App->GetAudioEncoder()->GetFrameSize();

        bStreamOpened = true;

        return true;
    }
Пример #16
0
int main() {
  int (*scmp)(char*,char*) = strcmp;

  assert(scmp("hello","hi") < 0);

  return 0;
}
Пример #17
0
Файл: gift.c Проект: HunL/myACM
int getname(char *s)
{
	    int i;
	    for(i=0;i<n;i++){
	          if(scmp(s,p[i].name))
			                return i;
	    }
}
Пример #18
0
int main()
{
    char s1[] = "ABCDEFGHabcdefgh123456";
    char s2[] = "ABCDEFGHabcdefgh123456          ";
    char dest[100];
    char dest2[STR_MAX_SIZE+1];
    int i, j, c;

    memset(dest, 0, sizeof(dest));

    strcpy(dest, s1);
    strncpy(dest2, s1, STR_MAX_SIZE);
    dest2[STR_MAX_SIZE] = '\0';
    printf("dest2 = %s\n", dest2);

    printf("scmp(s1, dest) = %d\n", scmp(s1, dest));
    printf("scmp(s2, dest) = %d\n", scmp(s2, dest));
    
    printf("before reverse: \"%s\"\n", dest);

    for (i = 0, j = strlen(dest)-1; i < j; i++, j--)
    {
        c = dest[i];
        dest[i] = dest[j];
        dest[j] = c;
    }

    printf("after reverse: \"%s\"\n", dest);
    
    scpy(dest, s2);

    printf("before trim: \"%s\"\n", dest);

    for (i = strlen(dest)-1; i >= 0; i--)
    {
        if (dest[i] != ' ' && dest[i] != '\t' && dest[i] != '\n')
            break;
        dest[i] = '\0';
    }

    printf("after trim: \"%s\"\n", dest);

    printf("slen(s1) = %d\n", slen(s1));
}
Пример #19
0
/*
   Get a Digest value using the MD5 algorithm -- See RFC 2617 to understand this code.
*/
static char *calcDigest(Webs *wp, char *username, char *password)
{
    char  a1Buf[256], a2Buf[256], digestBuf[256];
    char  *ha1, *ha2, *method, *result;

    assure(wp);
    assure(username && *username);
    assure(password);

    /*
        Compute HA1. If username == 0, then the password is already expected to be in the HA1 format 
        (MD5(username:realm:password).
     */
    if (username == 0) {
        ha1 = sclone(password);
    } else {
        fmt(a1Buf, sizeof(a1Buf), "%s:%s:%s", username, wp->realm, password);
        ha1 = websMD5(a1Buf);
    }

    /*
        HA2
     */ 
    method = wp->method;
    fmt(a2Buf, sizeof(a2Buf), "%s:%s", method, wp->digestUri);
    ha2 = websMD5(a2Buf);

    /*
        H(HA1:nonce:HA2)
     */
    if (scmp(wp->qop, "auth") == 0) {
        fmt(digestBuf, sizeof(digestBuf), "%s:%s:%s:%s:%s:%s", ha1, wp->nonce, wp->nc, wp->cnonce, wp->qop, ha2);

    } else if (scmp(wp->qop, "auth-int") == 0) {
        fmt(digestBuf, sizeof(digestBuf), "%s:%s:%s:%s:%s:%s", ha1, wp->nonce, wp->nc, wp->cnonce, wp->qop, ha2);

    } else {
        fmt(digestBuf, sizeof(digestBuf), "%s:%s:%s", ha1, wp->nonce, ha2);
    }
    result = websMD5(digestBuf);
    wfree(ha1);
    wfree(ha2);
    return result;
}
Пример #20
0
void SceneItem::SetRender(bool render)
{
    element->SetInt(TEXT("render"), (int)((render)?1:0));
    bRender = render;
    CTSTR lpClass = element->GetString(TEXT("class"));

    if (bRender) {
        if (!lpClass) {
            AppWarning(TEXT("No class for source '%s' in scene '%s'"), element->GetName(), API->GetSceneElement()->GetName());
        } else {
            XElement *data = element->GetElement(TEXT("data"));
            source = API->CreateImageSource(lpClass, data);
            if(!source) {
                AppWarning(TEXT("Could not create image source '%s' in scene '%s'"), element->GetName(), API->GetSceneElement()->GetName());
            } else {
                API->EnterSceneMutex();
                if (parent && parent->bSceneStarted) {
                    source->BeginScene();

                    if(scmp(lpClass, L"GlobalSource") == 0)
                        source->GlobalSourceEnterScene();
                }
                API->LeaveSceneMutex();
            }
        }
    } else {
        if (source) {
            API->EnterSceneMutex();

            ImageSource *src = source;
            source = NULL;

            if(scmp(lpClass, L"GlobalSource") == 0)
                src->GlobalSourceLeaveScene();

            if (parent && parent->bSceneStarted)
                src->EndScene();
            delete src;

            API->LeaveSceneMutex();
        }
    }
}
Пример #21
0
String GetOperatorName(CTSTR lpName)
{
    for(int i=0; i<VALIDOPS; i++)
    {
        if(scmp(ValidOperators[i], lpName) == 0)
            return String(OperatorNames[i]);
    }

    return String();
}
Пример #22
0
void
oeq(Node *n, Node *res)
{
	Node l, r;

	expr(n->left, &l);
	expr(n->right, &r);
	res->nstore.fmt = 'D';
	res->op = OCONST;
	res->type = TINT;
	res->nstore.u0.sival = 0;
	switch(l.type) {
	default:
		break;
	case TINT:
		switch(r.type) {
		case TINT:
			res->nstore.u0.sival = l.nstore.u0.sival == r.nstore.u0.sival;
			break;
		case TFLOAT:
			res->nstore.u0.sival = l.nstore.u0.sival == r.nstore.u0.sfval;
			break;
		default:
			break;
		}
		break;
	case TFLOAT:
		switch(r.type) {
		case TINT:
			res->nstore.u0.sival = l.nstore.u0.sfval == r.nstore.u0.sival;
			break;
		case TFLOAT:
			res->nstore.u0.sival = l.nstore.u0.sfval == r.nstore.u0.sfval;
			break;
		default:
			break;
		}
		break;
	case TSTRING:
		if(r.type == TSTRING) {
			res->nstore.u0.sival = scmp(r.nstore.u0.sstring, l.nstore.u0.sstring);
			break;
		}
		break;
	case TLIST:
		if(r.type == TLIST) {
			res->nstore.u0.sival = listcmp(l.nstore.u0.sl, r.nstore.u0.sl);
			break;
		}
		break;
	}
	if(n->op == ONEQ)
		res->nstore.u0.sival = !res->nstore.u0.sival;
}
Пример #23
0
static bool scriptisinternalcommand(const char* text, const char* cmd)
{
    int len = (int)strlen(text);
    int cmdlen = (int)strlen(cmd);
    if(cmdlen > len)
        return false;
    else if(cmdlen == len)
        return scmp(text, cmd);
    else if(text[cmdlen] == ' ')
        return (!_strnicmp(text, cmd, cmdlen));
    return false;
}
Пример #24
0
Файл: cd.c Проект: rdavid42/ft_p
int						cd(char *root, int *cs, char *cmd, int *id)
{
	char				**arg;
	char const			*cur = get_cwd();

	(void)id;
	arg = ssplit(cmd, ' ');
	if (scmp(root, cur, slen(root)) != 0)
		return (afree(arg), sc(cs, -2), error(CWD_DENIED), 0);
	go_dir(cs, root, cur, arg[1]);
	return (afree(arg), 1);
}
Пример #25
0
/* Insertion sort for linked lists of character strings.
   The strings all have a common prefix of length p. */
list ListInsertsort(list r, list *tail, int p)
{
   list fi, la, t;

   for (fi = la = r, r = r->next; r; r = la->next)
      if (scmp(r->str+p, la->str+p) >= 0) /* add to tail */
         la = r;
      else if (scmp(r->str+p, fi->str+p) <= 0) { /* add to head */
         la->next = r->next;
         r->next = fi;
         fi = r;
      } else { /* insert into middle */
         for (t = fi; scmp(r->str+p, t->next->str+p) >= 0; )
            t = t->next;
         la->next = r->next;
         r->next = t->next;
         t->next = r;
      }
   *tail = la;
   return fi;
}
Пример #26
0
BOOL   STDCALL OSIncompatibleModulesLoaded()
{
    StringList  moduleList;
    
    //Modules that will likely cause OBS to crash because they hooked it.
    //This list is checked on stream start only.

    if (!OSGetLoadedModuleList(GetCurrentProcess(), moduleList))
        return 0;

    for(UINT i=0; i<moduleList.Num(); i++)
    {
        CTSTR moduleName = moduleList[i];

        if (!scmp(moduleName, TEXT("dxtorycore.dll")) ||        //DXTory
            !scmp(moduleName, TEXT("dxtorycore64.dll")) ||      //DXTory
            !scmp(moduleName, TEXT("dxtorymm.dll")) ||          //DXTory
            !scmp(moduleName, TEXT("dxtorymm64.dll")) ||        //DXTory
            !scmp(moduleName, TEXT("atkdx11disp.dll")) ||       //ASUS OSD
            !scmp(moduleName, TEXT("rtsshooks.dll")))           //EVGA Precision OSD
        {
            return 1;
        }
    }

    return 0;
}
Пример #27
0
BOOL   STDCALL OSIncompatibleModulesLoaded()
{
    StringList  moduleList;

    if (!OSGetLoadedModuleList(GetCurrentProcess(), moduleList))
        return 0;

    for(UINT i=0; i<moduleList.Num(); i++)
    {
        CTSTR moduleName = moduleList[i];

        if (!scmp(moduleName, TEXT("dxtorycore.dll")) ||
            !scmp(moduleName, TEXT("dxtorycore64.dll")) ||
            !scmp(moduleName, TEXT("dxtorymm.dll")) ||
            !scmp(moduleName, TEXT("dxtorymm64.dll")))
        {
            return 1;
        }
    }

    return 0;
}
Пример #28
0
int find_arg(char *str, int argc, char **argv) {
    int i;
    for (i = 1; i < argc; i++) {
        if (!scmp(str, argv[i])) {
            if (i == argc - 1) {
                printf("No argument given for %s\n", str);
                exit(1);
            }
            return i;
        }
    }
    return -1;
}
Пример #29
0
/*
    See if there is acceptable cached content for this request. If so, return true.
    Will setup tx->cacheBuffer as a side-effect if the output should be captured and cached.
 */
static bool fetchCachedResponse(HttpConn *conn)
{
    HttpTx      *tx;
    MprTime     modified, when;
    cchar       *value, *key, *tag;
    int         status, cacheOk, canUseClientCache;

    tx = conn->tx;

    /*
        Transparent caching. Manual caching must manually call httpWriteCached()
     */
    key = makeCacheKey(conn);
    if ((value = httpGetHeader(conn, "Cache-Control")) != 0 && 
            (scontains(value, "max-age=0") == 0 || scontains(value, "no-cache") == 0)) {
        mprLog(3, "Client reload. Cache-control header '%s' rejects use of cached content.", value);

    } else if ((tx->cachedContent = mprReadCache(conn->host->responseCache, key, &modified, 0)) != 0) {
        /*
            See if a NotModified response can be served. This is much faster than sending the response.
            Observe headers:
                If-None-Match: "ec18d-54-4d706a63"
                If-Modified-Since: Fri, 04 Mar 2012 04:28:19 GMT
            Set status to OK when content must be transmitted.
         */
        cacheOk = 1;
        canUseClientCache = 0;
        tag = mprGetMD5(key);
        if ((value = httpGetHeader(conn, "If-None-Match")) != 0) {
            canUseClientCache = 1;
            if (scmp(value, tag) != 0) {
                cacheOk = 0;
            }
        }
        if (cacheOk && (value = httpGetHeader(conn, "If-Modified-Since")) != 0) {
            canUseClientCache = 1;
            mprParseTime(&when, value, 0, 0);
            if (modified > when) {
                cacheOk = 0;
            }
        }
        status = (canUseClientCache && cacheOk) ? HTTP_CODE_NOT_MODIFIED : HTTP_CODE_OK;
        mprLog(3, "cacheHandler: Use cached content for %s, status %d", key, status);
        httpSetStatus(conn, status);
        httpSetHeader(conn, "Etag", mprGetMD5(key));
        httpSetHeader(conn, "Last-Modified", mprFormatUniversalTime(MPR_HTTP_DATE, modified));
        return 1;
    }
    mprLog(3, "cacheHandler: No cached content for %s", key);
    return 0;
}
Пример #30
0
String ConvertParamTypeToString(DefaultVariable *var)
{
    if(!var->typeInfo.name || !var->typeInfo.name[0])
        return String() << TEXT("Error");
    else if(var->typeInfo.type == DataType_Object)
        return String() << var->typeInfo.name << ((var->flags & VAR_OUT) ? TEXT("*&") : TEXT("*"));
    else if(var->typeInfo.type == DataType_List)
    {
        if(~var->flags & VAR_OUT)
            return String() << TEXT("const List<") << ConvertTypeToString(var->subTypeInfo) << TEXT(">&");
        else
            return String() << TEXT("List<") << ConvertTypeToString(var->subTypeInfo) << TEXT(">&");
    }
    else if(var->typeInfo.type == DataType_String)
    {
        if(!(var->flags & VAR_OUT))
            return String(TEXT("CTSTR"));
        else
            return String(TEXT("String&"));
    }
    else if(var->typeInfo.type == DataType_Type)
        return String() << TEXT("TypeDataInfo&");
    else if(var->typeInfo.type == DataType_Struct)
    {
        if(!(var->flags & VAR_OUT))
            return String() << TEXT("const ") << var->typeInfo.name << TEXT("&");
        else
            return String() << var->typeInfo.name << TEXT("&");
    }
    else if(scmp(var->typeInfo.name, TEXT("icolor")) == 0)
        return String() << TEXT("DWORD") << ((var->flags & VAR_OUT) ? TEXT("&") : TEXT(""));
    else if(scmp(var->typeInfo.name, TEXT("handle")) == 0)
        return String() << TEXT("HANDLE") << ((var->flags & VAR_OUT) ? TEXT("&") : TEXT(""));
    else if(scmp(var->typeInfo.name, TEXT("bool")) == 0)
        return String() << TEXT("BOOL") << ((var->flags & VAR_OUT) ? TEXT("&") : TEXT(""));
    else
        return String() << var->typeInfo.name << ((var->flags & VAR_OUT) ? TEXT("&") : TEXT(""));
}