// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/ConfigParser/configparser.cpp
// Function: ConfigParser::ConfigParser(char const*)
ConfigParser::ConfigParser(const char *filename)
{

    if ( filename == NULL )
        return;
    init();
    char buf[BUFSIZE];
    char sql[BUFSIZE] = { 0 };
    char *pre;
    char *next;
    Persistence *db;

    FILE *fp = fopen( filename , "r" );

    if (fp == NULL)
    {
        return;
    }

    db = Persistence::getPersistence();
    db->exec("create table URL(id integer primary key,urlstr varchar(100),type int,deep int default 0,state int default 0)");

    while(fgets( buf , BUFSIZE , fp) != NULL)
    {


        if ( !strncmp( buf , DURATION , strlen( DURATION ) ) )
        {
            this->duration = atoi(buf+strlen(DURATION));
        }

        else if ( !strncmp( buf , TIMEOUT , strlen(TIMEOUT) ) )
        {
            this->timeout = atoi( buf + strlen( TIMEOUT ));
        }

        else if ( !strncmp( buf , JOBNUM , strlen( JOBNUM )) )
        {
            this->jobnum = atoi( buf + strlen( JOBNUM ));
        }

        else if ( !strncmp( buf  , DEEPTH , strlen(DEEPTH)) )
        {
            this->deepth = atoi( buf + strlen( DEEPTH ));
        }

        else if ( !strncmp( buf  , METHOD , strlen( METHOD )) )
        {
            this->method = atoi( buf + strlen( METHOD ));
        }

        else if ( !strncmp( buf, URLS, strlen(URLS)) )
        {
            while( fgets( buf , BUFSIZE , fp )!= NULL)
            {
                if( !strncmp( buf , END , strlen(END)))
                {
                    break;
                }

                if ( (pre = strstr( buf , SEPARATOR )) != NULL)
                {
                    //应该写入数据库
                    *pre = '\0';
		    pre++;
//                    std::cout <<"URL:"<<buf<<" TYPE:"<<atoi(pre)<<std::endl;
		    sprintf( sql ,"insert into URL(urlstr,type) values('%s',%d)",buf,atoi(pre));
		    
//		    db->exec(sql);
		    if ( !Bloom::isExist(buf) )
		    {
			Bloom::addFilter(buf);
			db->exec(sql);
		    }
                }
            }

        }

        else if ( !strncmp( buf ,MODE , strlen(MODE) ))
        {
            while( fgets( buf , BUFSIZE , fp ) != NULL )
            {
                if( !strncmp( buf , END , strlen(END)))
                {
                    break;
                }

                if ( (pre = strstr( buf , SEPARATOR )) != NULL &&
                     (next = strstr( pre + 1 , SEPARATOR )) != NULL)
                {
                    *pre = '\0';
                    pre++;
                    *next = '\0';
                    next++;
		    if ( this->modes[atoi(buf)] == NULL )
                    {
			this->modes[atoi(buf)] = new ModePair(pre,atoi(next));
		    }
                }
            }
        }

        memset(buf , 0 , BUFSIZE);
    }

	fclose(fp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x870, %rsp            # imm = 0x870
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x848(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xb06a
jmp 0xb533
movq -0x848(%rbp), %rdi
callq 0xaf50
leaq -0x810(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x8160
movq -0x10(%rbp), %rdi
leaq 0x9c253(%rip), %rsi     # 0xa72e7
callq 0x8310
movq %rax, -0x830(%rbp)
cmpq $0x0, -0x830(%rbp)
jne 0xb0af
jmp 0xb533
callq 0x9f10
movq %rax, -0x828(%rbp)
movq -0x828(%rbp), %rdi
leaq 0x9715f(%rip), %rsi     # 0xa2228
callq 0xa010
leaq -0x410(%rbp), %rdi
movq -0x830(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x8490
cmpq $0x0, %rax
je 0xb527
leaq -0x410(%rbp), %rdi
leaq 0x97197(%rip), %rsi     # 0xa2295
movl $0x9, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb12d
leaq -0x410(%rbp), %rdi
addq $0x9, %rdi
callq 0x8480
movl %eax, %ecx
movq -0x848(%rbp), %rax
movl %ecx, (%rax)
jmp 0xb50f
leaq -0x410(%rbp), %rdi
leaq 0x97164(%rip), %rsi     # 0xa229f
movl $0x8, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb16b
leaq -0x410(%rbp), %rdi
addq $0x8, %rdi
callq 0x8480
movl %eax, %ecx
movq -0x848(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0xb50d
leaq -0x410(%rbp), %rdi
leaq 0x9712f(%rip), %rsi     # 0xa22a8
movl $0x7, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb1a9
leaq -0x410(%rbp), %rdi
addq $0x7, %rdi
callq 0x8480
movl %eax, %ecx
movq -0x848(%rbp), %rax
movl %ecx, 0x8(%rax)
jmp 0xb50b
leaq -0x410(%rbp), %rdi
leaq 0x970f9(%rip), %rsi     # 0xa22b0
movl $0x7, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb1e7
leaq -0x410(%rbp), %rdi
addq $0x7, %rdi
callq 0x8480
movl %eax, %ecx
movq -0x848(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0xb509
leaq -0x410(%rbp), %rdi
leaq 0x970c3(%rip), %rsi     # 0xa22b8
movl $0x7, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb22e
leaq -0x410(%rbp), %rdi
addq $0x7, %rdi
callq 0x8480
movl %eax, %ecx
movq -0x848(%rbp), %rax
cmpl $0x0, %ecx
setne %cl
andb $0x1, %cl
movb %cl, 0x10(%rax)
jmp 0xb507
leaq -0x410(%rbp), %rdi
leaq 0x97084(%rip), %rsi     # 0xa22c0
movl $0x4, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb357
jmp 0xb251
leaq -0x410(%rbp), %rdi
movq -0x830(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x8490
cmpq $0x0, %rax
je 0xb352
leaq -0x410(%rbp), %rdi
leaq 0x96da3(%rip), %rsi     # 0xa2024
movl $0x3, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb295
jmp 0xb352
leaq -0x410(%rbp), %rdi
leaq 0x97022(%rip), %rsi     # 0xa22c5
callq 0x8090
movq %rax, -0x818(%rbp)
cmpq $0x0, %rax
je 0xb34d
movq -0x818(%rbp), %rax
movb $0x0, (%rax)
movq -0x818(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x818(%rbp)
leaq -0x810(%rbp), %rax
movq %rax, -0x858(%rbp)
leaq -0x410(%rbp), %rax
movq %rax, -0x850(%rbp)
movq -0x818(%rbp), %rdi
callq 0x8480
movq -0x858(%rbp), %rdi
movq -0x850(%rbp), %rdx
movl %eax, %ecx
leaq 0x96fb3(%rip), %rsi     # 0xa22c7
movb $0x0, %al
callq 0x8080
leaq -0x410(%rbp), %rdi
callq 0x8980
cmpl $0x0, %eax
jne 0xb34b
leaq -0x410(%rbp), %rdi
callq 0x8940
movq -0x828(%rbp), %rdi
leaq -0x810(%rbp), %rsi
callq 0xa010
jmp 0xb34d
jmp 0xb251
jmp 0xb505
leaq -0x410(%rbp), %rdi
leaq 0x96f8f(%rip), %rsi     # 0xa22f4
movl $0x4, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb503
jmp 0xb37a
leaq -0x410(%rbp), %rdi
movq -0x830(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x8490
cmpq $0x0, %rax
je 0xb501
leaq -0x410(%rbp), %rdi
leaq 0x96c7a(%rip), %rsi     # 0xa2024
movl $0x3, %edx
callq 0x8150
cmpl $0x0, %eax
jne 0xb3be
jmp 0xb501
leaq -0x410(%rbp), %rdi
leaq 0x96ef9(%rip), %rsi     # 0xa22c5
callq 0x8090
movq %rax, -0x818(%rbp)
cmpq $0x0, %rax
je 0xb4fc
movq -0x818(%rbp), %rdi
addq $0x1, %rdi
leaq 0x96ed1(%rip), %rsi     # 0xa22c5
callq 0x8090
movq %rax, -0x820(%rbp)
cmpq $0x0, %rax
je 0xb4fc
movq -0x818(%rbp), %rax
movb $0x0, (%rax)
movq -0x818(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x818(%rbp)
movq -0x820(%rbp), %rax
movb $0x0, (%rax)
movq -0x820(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x820(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x8480
movl %eax, %ecx
movq -0x848(%rbp), %rax
movslq %ecx, %rcx
cmpq $0x0, 0x18(%rax,%rcx,8)
jne 0xb4fa
movl $0x10, %edi
callq 0x82d0
movq %rax, -0x868(%rbp)
movq %rax, -0x870(%rbp)
movq -0x818(%rbp), %rax
movq %rax, -0x860(%rbp)
movq -0x820(%rbp), %rdi
callq 0x8480
movq -0x868(%rbp), %rdi
movq -0x860(%rbp), %rsi
movl %eax, %edx
callq 0xbb60
jmp 0xb4af
leaq -0x410(%rbp), %rdi
callq 0x8480
movq -0x870(%rbp), %rdx
movl %eax, %ecx
movq -0x848(%rbp), %rax
movslq %ecx, %rcx
movq %rdx, 0x18(%rax,%rcx,8)
jmp 0xb4fa
movq -0x870(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x838(%rbp)
movl %eax, -0x83c(%rbp)
movl $0x10, %esi
callq 0x82e0
jmp 0xb53c
jmp 0xb4fc
jmp 0xb37a
jmp 0xb503
jmp 0xb505
jmp 0xb507
jmp 0xb509
jmp 0xb50b
jmp 0xb50d
jmp 0xb50f
leaq -0x410(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x8160
jmp 0xb0ce
movq -0x830(%rbp), %rdi
callq 0x82c0
addq $0x870, %rsp            # imm = 0x870
popq %rbp
retq
movq -0x838(%rbp), %rdi
callq 0x84e0
nopl (%rax,%rax)