// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Download/MatchURL.cpp
// Function: GetURLFromBody(ModePair*, char*, char*, int)
void GetURLFromBody( ModePair *pattern , char *host ,  char *body, int deep)
{
	regex_t reg,http;
	regmatch_t pmatch;
	char url[512] = { 0 };
	char *regexstr = NULL;
	char *temp;
	char chr;
	char *c;
	int len;
	if ( pattern == NULL || body == NULL )
	{
		puts("pattern or body is NULL");
		return ;
	}
	regexstr = pattern->getMode();
//	puts(body);
//	puts(regexstr);
	if (regcomp(&reg,regexstr,0)!=0)
	{
		puts("Regular Experssion Error");
		return ;
	}
	temp = body;	
	for(;;)
	{
		if (regexec(&reg,temp,1,&pmatch,0) == REG_NOMATCH)
		{
//			puts("NO Match");
			break;
		}
		else
		{
			temp = temp + pmatch.rm_so;
			len = pmatch.rm_eo - pmatch.rm_so;
			//write(STDOUT_FILENO,temp+6,len-7);
			c = temp +len -1;
			chr = *c;
			*c = '\0';
			if ( isAbsoluteURL( temp + 6 ) )	
			{
				sprintf(url,"%s",temp+6);
			}
			else
			{
				sprintf(url,"http://%s%s",host,temp+6);
			}
			///--------------store database
			if ( !Bloom::isExist(url) )
			{
				Bloom::addFilter(url);
//				puts(url);
				URL *u = new URL();
				u->setType(pattern->getType());
				u->setURLStr(url);
				u->setDeep(deep+1);
				u->save();
				delete u;
			}
			///--------------
			*c = chr;
			temp+=len;
		}
	}
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %ecx, -0x2c(%rbp)
movq %rdx, %r12
movq %rsi, -0x48(%rbp)
movq %rdi, %rbx
leaq -0x280(%rbp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x8160
testq %rbx, %rbx
setne %al
testq %r12, %r12
setne %cl
testb %cl, %al
jne 0x9035
leaq 0x5f0f4(%rip), %rdi     # 0x68113
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84b0
movq %rbx, %rdi
callq 0xa380
leaq -0x78(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x83a0
testl %eax, %eax
je 0x906d
leaq 0x5f0d5(%rip), %rdi     # 0x6812b
callq 0x84b0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, -0x40(%rbp)
incl -0x2c(%rbp)
leaq -0x280(%rbp), %rbx
leaq -0x78(%rbp), %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
leaq -0x34(%rbp), %rcx
xorl %r8d, %r8d
callq 0x8220
cmpl $0x11, %eax
je 0x905b
movslq -0x34(%rbp), %rax
leaq (%r12,%rax), %r13
movslq -0x30(%rbp), %r14
subq %rax, %r14
movb -0x1(%r14,%r13), %r15b
movb $0x0, -0x1(%r14,%r13)
addq %rax, %r12
addq $0x6, %r12
movq %r12, %rdi
callq 0x8fb8
movq %rbx, %rdi
testl %eax, %eax
je 0x90d0
movq %r12, %rsi
callq 0x82b0
jmp 0x90e5
leaq 0x5f06d(%rip), %rsi     # 0x68144
movq -0x48(%rbp), %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x8080
movq %rbx, %rdi
callq 0x887a
testl %eax, %eax
jne 0x914e
movq %rbx, %rdi
callq 0x884c
pushq $0x20
popq %rdi
callq 0x8300
movq %rax, %r12
andl $0x0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
andl $0x0, 0x18(%rax)
movq -0x40(%rbp), %rdi
callq 0xa376
movl %eax, 0x10(%r12)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x915e
movl -0x2c(%rbp), %eax
movl %eax, 0x14(%r12)
movq %r12, %rdi
callq 0x9194
movq %r12, %rdi
callq 0x91ee
movq %r12, %rdi
pushq $0x20
popq %rsi
callq 0x8310
addq %r14, %r13
movb %r15b, -0x1(%r13)
movq %r13, %r12
jmp 0x907b
nop