当前位置: 首页>>代码示例>>C++>>正文


C++ slen函数代码示例

本文整理汇总了C++中slen函数的典型用法代码示例。如果您正苦于以下问题:C++ slen函数的具体用法?C++ slen怎么用?C++ slen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了slen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isdomain

	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;
	}
开发者ID:DSG888,项目名称:SibSUTIS,代码行数:25,代码来源:processing.c

示例2: ejsAddConstant

int ejsAddConstant(Ejs *ejs, EjsModule *mp, cchar *str)
{
    EjsConstants    *cp;
    ssize           len, oldLen;
    int             index;

    cp = mp->constants;
    if (cp->locked) {
        mprLog("ejs vm", 0, "Constant pool for module is locked. Cannot add constant \"%s\".",  str);
        return MPR_ERR_CANT_WRITE;
    }
    lock(mp);
    len = slen(str) + 1;
    if (ejsGrowConstants(ejs, mp, len) < 0) {
        unlock(mp);
        return MPR_ERR_MEMORY;
    }
    memcpy(&cp->pool[cp->poolLength], str, len);
    oldLen = cp->poolLength;
    cp->poolLength += len;

    mprAddKey(cp->table, str, ITOP(cp->indexCount));
    cp->index[cp->indexCount] = ITOP(oldLen << 1 | 1);
    index = cp->indexCount++;
    unlock(mp);
    return index;
}
开发者ID:embedthis,项目名称:ejscript,代码行数:27,代码来源:ejsModule.c

示例3: assert

void String::InsertString(UINT dwPos, CTSTR str)
{
    assert(str);
    if(!str) return;

    assert(dwPos <= curLength);

    if(dwPos == curLength)
    {
        AppendString(str);
        return;
    }

    UINT strLength = slen(str);

    if(strLength)
    {
        lpString = (TSTR)ReAllocate(lpString, (curLength+strLength+1)*sizeof(TCHAR));

        TSTR lpPos = lpString+dwPos;
        mcpyrev(lpPos+strLength, lpPos, ((curLength+1)-dwPos)*sizeof(TCHAR));
        mcpy(lpPos, str, strLength*sizeof(TCHAR));

        curLength += strLength;
    }
}
开发者ID:ChaosPower,项目名称:OBS,代码行数:26,代码来源:XString.cpp

示例4: setContentLength

static int setContentLength(HttpConn *conn, MprList *files)
{
    MprPath     info;
    MprOff      len;
    char        *path, *pair;
    int         next;

    len = 0;
    if (app->upload) {
        httpEnableUpload(conn);
        return 0;
    }
    for (next = 0; (path = mprGetNextItem(files, &next)) != 0; ) {
        if (strcmp(path, "-") != 0) {
            if (mprGetPathInfo(path, &info) < 0) {
                mprError("Cannot access file %s", path);
                return MPR_ERR_CANT_ACCESS;
            }
            len += info.size;
        }
    }
    if (app->formData) {
        for (next = 0; (pair = mprGetNextItem(app->formData, &next)) != 0; ) {
            len += slen(pair);
        }
        len += mprGetListLength(app->formData) - 1;
    }
    if (app->bodyData) {
        len += mprGetBufLength(app->bodyData);
    }
    if (len > 0) {
        httpSetContentLength(conn, len);
    }
    return 0;
}
开发者ID:adammendoza,项目名称:http,代码行数:35,代码来源:http.c

示例5: scmp

int scmp(char m[], char n[])
//	Функция сравнения строк
{
	int i, j = 0;
	if(slen(m) == slen(n))
	{
		for(i = 0; i < slen(m); i++)
			if(m[i] == n[i])
				j++;
		if(i == j)
			return 0;
	}
	else
		return 1;
	return -1;
}
开发者ID:VitaShib,项目名称:SibSUTIS,代码行数:16,代码来源:string.c

示例6: slen

static char *joinLine(cchar *str, ssize *lenp)
{
    cchar   *cp;
    char    *buf, *bp;
    ssize   len;
    int     count, bquote;

    for (count = 0, cp = str; *cp; cp++) {
        if (*cp == '\n') {
            count++;
        }
    }
    len = slen(str);
    if ((buf = mprAlloc(len + (count * 3) + 1)) == 0) {
        return 0;
    }
    bquote = 0;
    for (cp = str, bp = buf; *cp; cp++) {
        if (*cp == '\n') {
            *bp++ = '\\';
            *bp++ = 'n';
            *bp++ = '\\';
        } else if (*cp == '\\' && cp[1] != '\\') {
            bquote++;
        }
        *bp++ = *cp;
    }
    *bp = '\0';
    *lenp = len - bquote;
    return buf;
}
开发者ID:gamman,项目名称:appweb-4,代码行数:31,代码来源:espTemplate.c

示例7: sncopy

/*
    This routine copies at most "count" characters from a string. It ensures the result is always null terminated and
    the buffer does not overflow. Returns MPR_ERR_WONT_FIT if the buffer is too small.
 */
PUBLIC ssize sncopy(char *dest, ssize destMax, cchar *src, ssize count)
{
    ssize      len;

    assert(dest);
    assert(src);
    assert(src != dest);
    assert(0 <= count && count < MAXINT);
    assert(0 < destMax && destMax < MAXINT);

    //  OPT use strnlen(src, count);
    len = slen(src);
    len = min(len, count);
    if (destMax <= len) {
        assert(!MPR_ERR_WONT_FIT);
        return MPR_ERR_WONT_FIT;
    }
    if (len > 0) {
        memcpy(dest, src, len);
        dest[len] = '\0';
    } else {
        *dest = '\0';
        len = 0;
    }
    return len;
}
开发者ID:embedthis,项目名称:mpr,代码行数:30,代码来源:string.c

示例8: strspn

/*
    Trim characters from the given set. Returns a newly allocated string.
 */
PUBLIC char *strim(cchar *str, cchar *set, int where)
{
    char    *s;
    ssize   len, i;

    if (str == 0 || set == 0) {
        return 0;
    }
    if (where == 0) {
        where = MPR_TRIM_START | MPR_TRIM_END;
    }
    if (where & MPR_TRIM_START) {
        i = strspn(str, set);
    } else {
        i = 0;
    }
    s = sclone(&str[i]);
    if (where & MPR_TRIM_END) {
        len = slen(s);
        while (len > 0 && strspn(&s[len - 1], set) > 0) {
            s[len - 1] = '\0';
            len--;
        }
    }
    return s;
}
开发者ID:embedthis,项目名称:mpr,代码行数:29,代码来源:string.c

示例9: nest

/*  
    Prompt for input with the level of current nest (block nest depth)
 */
static char *readline(cchar *msg) 
{ 
    HistEvent   ev; 
    cchar       *str; 
    char        *result;
    ssize       len;
    int         count; 
 
    if (eh == NULL) { 
        eh = initEditLine();
    }
    prompt = msg;
    el_set(eh, EL_PROMPT, issuePrompt);
    el_set(eh, EL_SIGNAL, 1);
    str = el_gets(eh, &count); 
    if (str && count > 0) { 
        result = strdup(str); 
        len = slen(result);
        if (result[len - 1] == '\n') {
            result[len - 1] = '\0'; 
        }
        count = history(cmdHistory, &ev, H_ENTER, result); 
        return result; 
    }  
    return NULL; 
} 
开发者ID:TryndamereStark,项目名称:appweb,代码行数:29,代码来源:ejs.c

示例10: slen

BOOL XFile::WriteAsUTF8(CTSTR lpBuffer, DWORD dwElements)
{
    DWORD retVal = 0;

    if(!lpBuffer)
        return false;

    if (!hFile) return false;

    if (!lpBuffer[0])
        return true;

    if(!dwElements)
        dwElements = slen(lpBuffer);

#ifdef UNICODE
    DWORD dwBytes = (DWORD)wchar_to_utf8_len(lpBuffer, dwElements, 0);
	LPSTR lpDest = (LPSTR)Allocate_Bak(dwBytes + 1);

    if (wchar_to_utf8(lpBuffer, dwElements, lpDest, dwBytes, 0))
        retVal = (Write(lpDest, dwBytes) == dwBytes);
    else
        Log(TEXT("XFile::WriteAsUTF8: wchar_to_utf8 failed: %d"), GetLastError());

    Free(lpDest);
#else
    DWORD retVal = (Write(lpBuffer, dwElements) == dwBytes);
#endif

    return retVal;
}
开发者ID:wwllww,项目名称:LiveStream_MultiIntance,代码行数:31,代码来源:XFile_Windows.cpp

示例11: updateMenu

/*
    Update menu string if text is non-null
    Update enable / disable if "enable" is non-zero. Positive will enable. Negative will disable.
    Update checked status if "check" is non-zero. Positive will enable, negative will disable.
 */
static void updateMenu(int id, char *text, int enable, int check)
{
    MENUITEMINFO    menuInfo;
    int             rc;

    if (text) {
        memset(&menuInfo, 0, sizeof(menuInfo));
        menuInfo.fMask = MIIM_STRING;
        menuInfo.cbSize = sizeof(menuInfo);
        menuInfo.fType = MFT_STRING;
        menuInfo.dwTypeData = NULL;
        menuInfo.fMask = MIIM_STRING;
        menuInfo.dwTypeData = text;
        menuInfo.cch = (uint) slen(text) + 1;
        rc = SetMenuItemInfo(app->subMenu, id, FALSE, &menuInfo);
    }
    if (enable > 0) {
        rc = EnableMenuItem(app->subMenu, id, MF_BYCOMMAND | MF_ENABLED);
    } else if (enable < 0) {
        rc = EnableMenuItem(app->subMenu, id, MF_BYCOMMAND | MF_GRAYED);
    }
    if (check > 0) {
        rc = CheckMenuItem(app->subMenu, id, MF_BYCOMMAND | MF_CHECKED);
    } else if (check < 0) {
        rc = CheckMenuItem(app->subMenu, id, MF_BYCOMMAND | MF_UNCHECKED);
    }
    rc = DrawMenuBar(app->appHwnd);
}
开发者ID:varphone,项目名称:appweb-4,代码行数:33,代码来源:appwebMonitor.c

示例12: while

String XConfig::ProcessString(TSTR &lpTemp)
{
    TSTR lpStart = lpTemp;

    BOOL bFoundEnd = FALSE;
    BOOL bPreviousWasEscaped = FALSE;
    while(*++lpTemp)
    {
        if (*lpTemp == '\\' && lpTemp[-1] == '\\')
        {
            bPreviousWasEscaped = TRUE;
            continue;
        }
        if(*lpTemp == '"' && (bPreviousWasEscaped || lpTemp[-1] != '\\'))
        {
            bFoundEnd = TRUE;
            break;
        }
        bPreviousWasEscaped = FALSE;
    }

    if(!bFoundEnd)
        return String();

    ++lpTemp;

    TCHAR backupChar = *lpTemp;
    *lpTemp = 0;
    String string = lpStart;
    *lpTemp = backupChar;

    if (string.Length() == 2)
        return String();

    String stringOut = string.Mid(1, string.Length()-1);
    if (stringOut.IsEmpty())
        return String();

    TSTR lpStringOut = stringOut;
    while(*lpStringOut != 0 && (lpStringOut = schr(lpStringOut, '\\')) != 0)
    {
        switch(lpStringOut[1])
        {
            case 0:     *lpStringOut = 0; break;
            case '"':   *lpStringOut = '"';  scpy(lpStringOut+1, lpStringOut+2); break;
            case 't':   *lpStringOut = '\t'; scpy(lpStringOut+1, lpStringOut+2); break;
            case 'r':   *lpStringOut = '\r'; scpy(lpStringOut+1, lpStringOut+2); break;
            case 'n':   *lpStringOut = '\n'; scpy(lpStringOut+1, lpStringOut+2); break;
            case '/':   *lpStringOut = '/';  scpy(lpStringOut+1, lpStringOut+2); break;
            case '\\':  scpy(lpStringOut+1, lpStringOut+2); break;
        }

        lpStringOut++;
    }

    stringOut.SetLength(slen(stringOut));

    return stringOut;
}
开发者ID:CasperGemini,项目名称:OBS,代码行数:59,代码来源:XConfig.cpp

示例13: main

int main(void)
{
  char str[] = "hello";
  rprint(str);
  printf("\n");
  printf("str's length is %d\n", slen(str));
  return 0;
}
开发者ID:xunzhang,项目名称:code_tips,代码行数:8,代码来源:Reverse_Print.c

示例14:

static cchar *checkFormat(EdiValidation *vp, EdiRec *rec, cchar *fieldName, cchar *value)
{
    int     matched[HTTP_MAX_ROUTE_MATCHES * 2];

    if (pcre_exec(vp->mdata, NULL, value, (int) slen(value), 0, 0, matched, sizeof(matched) / sizeof(int)) > 0) {
        return 0;
    }
    return "is in the wrong format";
}
开发者ID:varphone,项目名称:appweb-4,代码行数:9,代码来源:edi.c

示例15: estTrace

static void estTrace(void *fp, int level, char *str)
{
    level += 3;
    if (level <= websGetLogLevel()) {
        str = sclone(str);
        str[slen(str) - 1] = '\0';
        trace(level, "%s", str);
    }
}
开发者ID:JasonCC,项目名称:goahead,代码行数:9,代码来源:est.c


注:本文中的slen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。