// File: rurban[P]dgnlib/cpl_error.cpp
// Function: CPLLoggingErrorHandler
void CPL_STDCALL CPLLoggingErrorHandler( CPLErr eErrClass, int nError, 
                             const char * pszErrorMsg )

{
    static int       bLogInit = FALSE;
    static FILE *    fpLog = stderr;

    if( !bLogInit )
    {
        const char *cpl_log = NULL;

        CPLSetConfigOption( "CPL_TIMESTAMP", "ON" );

        bLogInit = TRUE;

        cpl_log = CPLGetConfigOption("CPL_LOG", NULL );

        fpLog = stderr;
        if( cpl_log != NULL && EQUAL(cpl_log,"OFF") )
        {
            fpLog = NULL;
        }
        else if( cpl_log != NULL )
        {
            char      path[5000];
            int       i = 0;

            strcpy( path, cpl_log );

            while( (fpLog = fopen( path, "rt" )) != NULL ) 
            {
                fclose( fpLog );

                /* generate sequenced log file names, inserting # before ext.*/
                if (strrchr(cpl_log, '.') == NULL)
                {
                    sprintf( path, "%s_%d%s", cpl_log, i++,
                             ".log" );
                }
                else
                {
                    int pos = 0;
                    char *cpl_log_base = strdup(cpl_log);
                    pos = strcspn(cpl_log_base, ".");
                    if (pos > 0)
                    {
                        cpl_log_base[pos] = '\0';
                    }
                    sprintf( path, "%s_%d%s", cpl_log_base,
                             i++, ".log" );
                }
            }

            fpLog = fopen( path, "wt" );
        }
    }

    if( fpLog == NULL )
        return;

    if( eErrClass == CE_Debug )
        fprintf( fpLog, "%s\n", pszErrorMsg );
    else if( eErrClass == CE_Warning )
        fprintf( fpLog, "Warning %d: %s\n", nError, pszErrorMsg );
    else
        fprintf( fpLog, "ERROR %d: %s\n", nError, pszErrorMsg );

    fflush( fpLog );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x13b0, %rsp           # imm = 0x13B0
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
cmpb $0x0, 0x19734(%rip)     # 0x1f690
jne 0x5f8c
leaq 0x1972b(%rip), %rdi     # 0x1f690
callq 0x2510
cmpl $0x0, %eax
je 0x5f8c
movq 0x1906a(%rip), %rax     # 0x1efe0
movq (%rax), %rax
movq %rax, 0x19708(%rip)     # 0x1f688
leaq 0x19709(%rip), %rdi     # 0x1f690
callq 0x21b0
cmpl $0x0, 0x196ed(%rip)     # 0x1f680
jne 0x6153
movq $0x0, -0x18(%rbp)
leaq 0x135b0(%rip), %rdi     # 0x19558
leaq 0x139f1(%rip), %rsi     # 0x199a0
callq 0x4170
movl $0x1, 0x196c2(%rip)     # 0x1f680
leaq 0x135a4(%rip), %rdi     # 0x19569
xorl %eax, %eax
movl %eax, %esi
callq 0x40b0
movq %rax, -0x18(%rbp)
movq 0x19007(%rip), %rax     # 0x1efe0
movq (%rax), %rax
movq %rax, 0x196a5(%rip)     # 0x1f688
cmpq $0x0, -0x18(%rbp)
je 0x600f
movq -0x18(%rbp), %rdi
leaq 0x1359d(%rip), %rsi     # 0x19592
callq 0x2300
cmpl $0x0, %eax
jne 0x600f
movq $0x0, 0x1967e(%rip) # 0x1f688
jmp 0x6151
cmpq $0x0, -0x18(%rbp)
je 0x614f
movl $0x0, -0x13a4(%rbp)
leaq -0x13a0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x22c0
leaq -0x13a0(%rbp), %rdi
leaq 0x13554(%rip), %rsi     # 0x19596
callq 0x2350
movq %rax, 0x1963a(%rip)     # 0x1f688
cmpq $0x0, %rax
je 0x6135
movq 0x19629(%rip), %rdi     # 0x1f688
callq 0x22f0
movq -0x18(%rbp), %rdi
movl $0x2e, %esi
callq 0x2310
cmpq $0x0, %rax
jne 0x60ae
leaq -0x13a0(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl -0x13a4(%rbp), %ecx
movl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x13a4(%rbp)
leaq 0x134fe(%rip), %rsi     # 0x19599
leaq 0x134ff(%rip), %r8      # 0x195a1
movb $0x0, %al
callq 0x20a0
jmp 0x6130
movl $0x0, -0x13a8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2520
movq %rax, -0x13b0(%rbp)
movq -0x13b0(%rbp), %rdi
leaq 0x1491a(%rip), %rsi     # 0x1a9f0
callq 0x2070
movl %eax, -0x13a8(%rbp)
cmpl $0x0, -0x13a8(%rbp)
jle 0x60fc
movq -0x13b0(%rbp), %rax
movslq -0x13a8(%rbp), %rcx
movb $0x0, (%rax,%rcx)
leaq -0x13a0(%rbp), %rdi
movq -0x13b0(%rbp), %rdx
movl -0x13a4(%rbp), %ecx
movl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x13a4(%rbp)
leaq 0x13477(%rip), %rsi     # 0x19599
leaq 0x13478(%rip), %r8      # 0x195a1
movb $0x0, %al
callq 0x20a0
jmp 0x6034
leaq -0x13a0(%rbp), %rdi
leaq 0x1342e(%rip), %rsi     # 0x19571
callq 0x2350
movq %rax, 0x19539(%rip)     # 0x1f688
jmp 0x6151
jmp 0x6153
cmpq $0x0, 0x1952d(%rip)     # 0x1f688
jne 0x615f
jmp 0x61ce
cmpl $0x1, -0x4(%rbp)
jne 0x6180
movq 0x1951c(%rip), %rdi     # 0x1f688
movq -0x10(%rbp), %rdx
leaq 0x13417(%rip), %rsi     # 0x1958e
movb $0x0, %al
callq 0x2410
jmp 0x61c2
cmpl $0x2, -0x4(%rbp)
jne 0x61a4
movq 0x194fb(%rip), %rdi     # 0x1f688
movl -0x8(%rbp), %edx
movq -0x10(%rbp), %rcx
leaq 0x133d9(%rip), %rsi     # 0x19574
movb $0x0, %al
callq 0x2410
jmp 0x61c0
movq 0x194dd(%rip), %rdi     # 0x1f688
movl -0x8(%rbp), %edx
movq -0x10(%rbp), %rcx
leaq 0x133cb(%rip), %rsi     # 0x19584
movb $0x0, %al
callq 0x2410
jmp 0x61c2
movq 0x194bf(%rip), %rdi     # 0x1f688
callq 0x2340
addq $0x13b0, %rsp           # imm = 0x13B0
popq %rbp
retq
nopw (%rax,%rax)