// File: /workspace/github_c_makefile_star2_O1/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, %r14d
movq %rdx, %rbx
movq %rsi, -0x48(%rbp)
movq %rdi, %r15
leaq -0x280(%rbp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x8160
testq %r15, %r15
sete %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
je 0x90f5
leaq 0x70020(%rip), %rdi     # 0x79113
jmp 0x9116
movq %r15, %rdi
callq 0xa4f0
leaq -0x78(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x8390
testl %eax, %eax
je 0x912d
leaq 0x70015(%rip), %rdi     # 0x7912b
callq 0x84a0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, -0x40(%rbp)
movl %r14d, -0x2c(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x34(%rbp), %rcx
movl $0x1, %edx
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0x8210
cmpl $0x11, %eax
je 0x911b
incl -0x2c(%rbp)
leaq -0x280(%rbp), %r13
movslq -0x34(%rbp), %rax
leaq (%rbx,%rax), %r12
movslq -0x30(%rbp), %r14
subq %rax, %r14
movb -0x1(%r14,%r12), %r15b
movb $0x0, -0x1(%r14,%r12)
addq %rax, %rbx
addq $0x6, %rbx
movq %rbx, %rdi
leaq 0x6ff89(%rip), %rsi     # 0x79110
callq 0x8090
movq %r13, %rdi
testq %rax, %rax
je 0x919e
movq %rbx, %rsi
callq 0x82a0
jmp 0x91b3
leaq 0x6ff9f(%rip), %rsi     # 0x79144
movq -0x48(%rbp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x8080
movq %r13, %rdi
callq 0x8966
testl %eax, %eax
je 0x91f0
addq %r14, %r12
movb %r15b, -0x1(%r12)
movl $0x1, %edx
leaq -0x78(%rbp), %rdi
movq %r12, %rsi
leaq -0x34(%rbp), %rcx
xorl %r8d, %r8d
callq 0x8210
movq %r12, %rbx
cmpl $0x11, %eax
jne 0x915c
jmp 0x911b
movq %r13, %rdi
callq 0x8938
movl $0x20, %edi
callq 0x82f0
movq %rax, %rbx
xorl %eax, %eax
movl %eax, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl %eax, 0x18(%rbx)
movq -0x40(%rbp), %rdi
callq 0xa4e6
movl %eax, 0x10(%rbx)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9258
movl -0x2c(%rbp), %eax
movl %eax, 0x14(%rbx)
movq %rbx, %rdi
callq 0x85c6
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x9246
callq 0x83c0
movl $0x20, %esi
movq %rbx, %rdi
callq 0x8300
jmp 0x91bf