Example #1
0
int check_domain(char *domain,int check)
{
	int len = 64;
	int have_dot = 0;
	int i;

	for (i = 0; domain[i] != '\0';i++)
        {
			
			if(is_char(domain[i]))
				continue;
                	if(is_digital(domain[i]))
				continue;
                	if(is_hyphen(domain[i]))
				continue;
		

                if(is_dot(domain[i]))
		{
			have_dot = 1;
			continue;
		}
                /*error!*/
		return 0;
        }
	if (!have_dot)
		return 0;
	
	if (i>len || i<3)
		return 0;
	
	/*ok*/
	return 1;
}
Example #2
0
CFSWString DealWithText(CFSWString text) {
    /* Proovin kogu sõnniku minema loopida */
    CFSWString res;
    text.Trim();
    text.Replace(L"\n\n", L"\n", 1);
    text.Replace(L"‘", L"'", 1);
    text.Replace(L"`", L"'", 1);
    text.Replace(L"´", L"'", 1);
    text.Replace(L"’", L"'", 1);

    for (INTPTR i = 0; i < text.GetLength(); i++) {
        CFSWString c = text.GetAt(i);
        CFSWString pc = res.GetAt(res.GetLength() - 1);
        CFSWString nc = text.GetAt(i + 1);
        if (c == L"'") {
            if (is_vowel(pc)) 
                res += L"q";
            else
                res += c;
        }
        else
        if (is_char(c)) res += c;
        else
            if (is_digit(c)) res += c;
        else
            if (is_hyphen(c) && is_char(pc) && is_char(nc)) res += sp;
        else
            if (is_symbol(c)) res += c;
        else
            if (is_colon(c) && !is_colon(pc)) res += c;
        else
            if (is_bbracket(c) && !is_bbracket(pc)) res += c;
        else
            if (is_ebracket(c) && is_ending(nc)) res += L"";
        else
            if (is_ebracket(c) && !is_ebracket(pc)) res += c;
        else
            if (is_comma(c) && !is_comma(pc)) res += c;
        else
            if (is_fchar(c)) res += replace_fchar(c);
        else
            if (is_space(c) && !is_whitespace(pc)) res += c;
        else
            if (is_break(c) && !is_break(pc)) { 
                
                res += c;   
            } //kahtlane
        else
            if (is_tab(c) && !is_whitespace(pc)) res += c;
        else            
            if (is_ending(c) && !is_ending(pc) && !is_whitespace(pc)) res += c;

    }
    res.Trim();        
    return res;

}
Example #3
0
/* [email protected] 
 * buffer = "*****@*****.**"
 * at = "@akaedu.com"
 * we need get "akaedu.com"
 */
char * search_domain(char *at)
{
	char *tmp;
	
	tmp = at;
	tmp ++;
	
	for (;*tmp != '\0';tmp++ )
	{
		if(is_char(*tmp))
			continue;
		if(is_digital(*tmp))
			continue;
		if(is_hyphen(*tmp))
			continue;
		if(is_dot(*tmp))
			continue;
		
		return tmp;
	}
	
	return tmp;

}
int _find_token_length(char *curr, unsigned len, int *size, int *width)
{
    int _size  = 0;
    int _width = 0;
    int tok;

    if (len == 0)
        tok = TOK_DONE;

    else
    {
        switch (*curr)
        {
        case ' ':    /* it's a run of spaces */
            tok = TOK_SPACE;
            while (*curr == ' ' && _size < (int)len)
            {
                ++curr;
                ++_size;
                ++_width;
            }
            break;

        case CMD_SPACE:
            tok = TOK_SPACE;
            ++curr;
            ++_size;
            _width = *curr;
            ++curr;
            ++_size;
            break;

        case CMD_LINK:
            tok = TOK_LINK;
            _size += 1+3*sizeof(int); /* skip CMD_LINK + topic_num + topic_off + page_num */
            curr += 1+3*sizeof(int);

            while (*curr != CMD_LINK)
            {
                if (*curr == CMD_LITERAL)
                {
                    ++curr;
                    ++_size;
                }
                ++curr;
                ++_size;
                ++_width;
                assert((unsigned) _size < len);
            }

            ++_size;   /* skip ending CMD_LINK */
            break;

        case CMD_PARA:
            tok = TOK_PARA;
            _size += 3;     /* skip CMD_PARA + indent + margin */
            break;

        case CMD_XONLINE:
            tok = TOK_XONLINE;
            ++_size;
            break;

        case CMD_XDOC:
            tok = TOK_XDOC;
            ++_size;
            break;

        case CMD_CENTER:
            tok = TOK_CENTER;
            ++_size;
            break;

        case '\n':
            tok = TOK_NL;
            ++_size;
            break;

        case CMD_FF:
            tok = TOK_FF;
            ++_size;
            break;

        default:   /* it must be a word */
            tok = TOK_WORD;
            while (true)
            {
                if (_size >= (int)len)
                    break;

                else if (*curr == CMD_LITERAL)
                {
                    curr += 2;
                    _size += 2;
                    _width += 1;
                }

                else if (*curr == '\0')
                {
                    assert(0);
                }

                else if ((unsigned)*curr <= MAX_CMD || *curr == ' ' ||
                         *curr == '\n')
                    break;

                else if (*curr == '-')
                {
                    ++curr;
                    ++_size;
                    ++_width;
                    if (is_hyphen(curr-1))
                        break;
                }

                else
                {
                    ++curr;
                    ++_size;
                    ++_width;
                }
            }
            break;
        } /* switch */
    }

    if (size  != nullptr)
        *size  = _size;
    if (width != nullptr)
        *width = _width;

    return (tok);
}