Exemplo n.º 1
0
void do_one_sub(wchar_t *line)
{
  struct listnode *ln;
  ln=common_subs;

    while((ln=ln->next)) 
        if(check_one_action(line,ln->left)) {
            // check its gag 
            if ( !wcscmp(ln->right, L".") ) {
				wcscpy(line, L".");
                return;
            }
            BOOL bAnchored = FALSE;
            wchar_t pattern[BUFFER_SIZE],SubStr[BUFFER_SIZE],result[BUFFER_SIZE];
            prepare_actionalias(ln->left , pattern, sizeof(pattern)/sizeof(wchar_t));
            prepare_actionalias(ln->right , SubStr, sizeof(SubStr)/sizeof(wchar_t));
            int pattern_len = wcslen(pattern);
			int sublen = wcslen(SubStr);
            if ( pattern_len == 0 ) 
                continue;

            result[0] = 0;
            wchar_t* line1 = line;
            wchar_t* ptr, *res = result;
			int rest = sizeof(result)/sizeof(wchar_t) - 1;
            while ( (ptr = wcsstr(line1, pattern)) != NULL ) {
				int to_copy = ptr - line1;
				if (to_copy > rest)
					to_copy = rest;
                wcsncpy(res, line1, to_copy );
				res[to_copy] = L'\0';
                res += to_copy;
				rest -= to_copy;

				to_copy = sublen;
				if (to_copy > rest)
					to_copy = rest;
                wcsncpy(res, SubStr, to_copy);
				res[to_copy] = L'\0';
                res += to_copy;
				rest -= to_copy;

                line1 += pattern_len + (ptr-line1);
            
            }
            if ( *line1 ) {
                wcscat(result, line1);
            }
            wcscpy(line, result);
            if(!bMultiSub)
			 return;
        
        }
}
Exemplo n.º 2
0
bool do_one_antisub(const char *line, struct session *ses)
{
    struct listnode *ln;
    pvars_t vars;

    ln = ses->antisubs;

    while ((ln = ln->next))
        if (check_one_action(line, ln->left, &vars, false, ses))
            return true;
    return false;
}
Exemplo n.º 3
0
void do_one_sub(char *line)
{
  struct listnode *ln;
  ln=common_subs;

    while((ln=ln->next)) 
        if(check_one_action(line,ln->left)) {
            // check its gag 
            if ( *ln->right == '.' && *(ln->right+1) == 0 ) {
                line[0] = '.';
                line[1] = 0;
                return;
            }
            BOOL bAnchored = FALSE;
            char pattern[BUFFER_SIZE],SubStr[BUFFER_SIZE],result[BUFFER_SIZE];
            prepare_actionalias(ln->left , pattern);
            prepare_actionalias(ln->right , SubStr);
            int pattern_len = strlen(pattern);
            if ( pattern_len == 0 ) 
                continue;

            result[0] = 0;
            char* line1 = line;
            char* ptr, *res = result;
            while ( (ptr = strstr(line1, pattern)) != NULL ) {
                strncpy(res, line1, ptr-line1 );
                res += ptr-line1;
                strcpy(res, SubStr);
                res += strlen(res);
                line1 += pattern_len + (ptr-line1);
            
            }
            if ( *line1 ) {
                strcat(result, line1);
            }
            strcpy(line, result);
            if(!bMultiSub)
			 return;
        
        }
}