// File: /workspace/github_c_makefile_star2_O3/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
setne %al
testq %rbx, %rbx
setne %cl
testb %cl, %al
jne 0x910d
leaq 0x6e01c(%rip), %rdi     # 0x77113
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84b0
movq %r15, %rdi
callq 0xa4ec
leaq -0x78(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x83a0
testl %eax, %eax
je 0x9135
leaq 0x6dffd(%rip), %rdi     # 0x7712b
callq 0x84b0
jmp 0x915a
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 0x8220
cmpl $0x11, %eax
jne 0x916c
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
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 0x6df6f(%rip), %rsi     # 0x77110
callq 0x8090
movq %r13, %rdi
testq %rax, %rax
je 0x91b8
movq %rbx, %rsi
callq 0x82b0
jmp 0x91cd
leaq 0x6df85(%rip), %rsi     # 0x77144
movq -0x48(%rbp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x8080
movq %r13, %rdi
callq 0x8976
testl %eax, %eax
je 0x920a
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 0x8220
movq %r12, %rbx
cmpl $0x11, %eax
jne 0x9176
jmp 0x915a
movq %r13, %rdi
callq 0x8948
movl $0x20, %edi
callq 0x8300
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 0xa4e2
movl %eax, 0x10(%rbx)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9272
movl -0x2c(%rbp), %eax
movl %eax, 0x14(%rbx)
movq %rbx, %rdi
callq 0x85d6
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x9260
callq 0x83d0
movl $0x20, %esi
movq %rbx, %rdi
callq 0x8310
jmp 0x91d9