// File: /workspace/github_c_makefile_star2_O0/inflex[P]ripMIME/MIME_headers.c
// Function: MIMEH_parse_contentdisposition
int MIMEH_parse_contentdisposition( char *header_name, char *header_value, struct MIMEH_header_info *hinfo )
{
    char  *p;
    char *hv = strdup(header_value);

    // CONTENT DISPOSITION ------------------------------
    // CONTENT DISPOSITION ------------------------------
    // CONTENT DISPOSITION ------------------------------

    //LOGGER_log("%s:%d:DEBUG: Headers='%s'",FL,header_value);
    p = strstr(header_name,"content-disposition");
    if (p != NULL)
    {
        /** 20041216-1107:PLD: Increase our sanity **/
        hinfo->sanity++;

        // Change p to now point to the header VALUE, p no longer
        //      points to the content-disposition start!

        p = header_value;
        PLD_strlower( header_value );

        // Here we just check to find out what type of disposition we have.
        if (strstr(p,"inline"))
        {
            hinfo->content_disposition = _CDISPOSITION_INLINE;
        }
        else if (strstr(p,"form-data"))
        {
            hinfo->content_disposition = _CDISPOSITION_FORMDATA;
        }
        else if (strstr(p,"attachment"))
        {
            hinfo->content_disposition = _CDISPOSITION_ATTACHMENT;
        }
        else
        {
            hinfo->content_disposition = _CDISPOSITION_UNKNOWN;
        }

        // Copy the string to our content-transfer string storage field
        if (p != NULL)
        {
            char *q = p;

            // Step 1 - jump over any whitespace
            while ( *q == ' ' || *q == '\t') q++;

            // Step 2 - Copy the string
            PLD_strncpy( hinfo->content_disposition_string, q, _MIMEH_CONTENT_DISPOSITION_MAX);

            // Step 3 - clean up the string
            q = hinfo->content_disposition_string;
            while (*q && *q != ' ' && *q != '\t' && *q != '\n' && *q != '\r' && *q != ';') q++;

            // Step 4 - Terminate the string
            *q = '\0';
        }

        DMIMEH LOGGER_log("%s:%d:MIMEH_parse_contentdisposition:DEBUG: Disposition string = '%s'",FL, hv);

        // Commence to decode the disposition string into its components.
        p = strpbrk( hv, ";\t\n\r " );
        if (p != NULL)
        {
            //          struct PLD_strtok tx;
            char *param;

            hinfo->name[0]='\0';

            p++;
            param = p;
            while ( param != NULL )
            {
                int parse_result;
                char *data_end_point;

                if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_parse_contentdisposition:DEBUG: Parsing '%s'",FL,param);

                // Seek out possible 'filename' parameters

                parse_result = MIMEH_parse_header_parameter(hinfo, param, "filename", hinfo->name, sizeof(hinfo->name), &data_end_point);
                if (data_end_point > param) param = data_end_point;
                if (parse_result == 0) {
                    FNFILTER_filter(hinfo->name, _MIMEH_FILENAMELEN_MAX);
                    SS_push(&(hinfo->ss_filenames), hinfo->name, strlen(hinfo->name));
                    if (SS_count(&(hinfo->ss_filenames)) > 1)
                    {
                        MIMEH_set_defect(hinfo,MIMEH_DEFECT_MULTIPLE_FILENAMES);
                    }
                }

                param = strpbrk( param , ";\n\r\t " );
                if (param) param++;

                //param = PLD_strtok( &tx, NULL, ";\n\r\t " );
            } // While

            if ( hinfo->filename[0] == '\0' )
            {
                snprintf( hinfo->filename, sizeof(hinfo->filename), "%s", hinfo->name );
            }

            // Handle situations where we'll need the filename for the future.
            if ( hinfo->content_type == _CTYPE_MULTIPART_APPLEDOUBLE )
            {
                snprintf( glb.appledouble_filename, sizeof(glb.appledouble_filename), "%s", hinfo->filename );
                if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_parse_contentdisposition:DEBUG: Setting appledouble filename to: '%s'",FL,glb.appledouble_filename);
            }

        } // If the header-value contained ;'s ( indicating parameters )

    } // If the header-name actually contained 'content-disposition'

    if (hv != NULL) free(hv);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2390
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x1001b(%rip), %rsi     # 0x1dbd7
callq 0x23b0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xdf93
movq -0x18(%rbp), %rax
movl 0x18d30(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18d30(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x105f0
movq -0x20(%rbp), %rdi
leaq 0xffec(%rip), %rsi      # 0x1dbeb
callq 0x23b0
cmpq $0x0, %rax
je 0xdc1a
movq -0x18(%rbp), %rax
movl $0x64, 0x17100(%rax)
jmp 0xdc78
movq -0x20(%rbp), %rdi
leaq 0xffcd(%rip), %rsi      # 0x1dbf2
callq 0x23b0
cmpq $0x0, %rax
je 0xdc40
movq -0x18(%rbp), %rax
movl $0x12c, 0x17100(%rax)   # imm = 0x12C
jmp 0xdc76
movq -0x20(%rbp), %rdi
leaq 0xfb20(%rip), %rsi      # 0x1d76b
callq 0x23b0
cmpq $0x0, %rax
je 0xdc66
movq -0x18(%rbp), %rax
movl $0xc8, 0x17100(%rax)
jmp 0xdc74
movq -0x18(%rbp), %rax
movl $0x0, 0x17100(%rax)
jmp 0xdc76
jmp 0xdc78
cmpq $0x0, -0x20(%rbp)
je 0xdd6d
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, -0x49(%rbp)
je 0xdcac
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0xdcb5
jmp 0xdcc3
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xdc8b
movq -0x18(%rbp), %rdi
addq $0x17104, %rdi          # imm = 0x17104
movq -0x30(%rbp), %rsi
movl $0xa00, %edx            # imm = 0xA00
callq 0x10640
movq -0x18(%rbp), %rax
addq $0x17104, %rax          # imm = 0x17104
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4a(%rbp)
je 0xdd4f
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x20, %ecx
movb %al, -0x4a(%rbp)
je 0xdd4f
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x9, %ecx
movb %al, -0x4a(%rbp)
je 0xdd4f
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x4a(%rbp)
je 0xdd4f
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xd, %ecx
movb %al, -0x4a(%rbp)
je 0xdd4f
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3b, %eax
setne %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
testb $0x1, %al
jne 0xdd58
jmp 0xdd66
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xdcea
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x1, 0x24a08(%rip)     # 0x3277c
jl 0xdd94
movq -0x28(%rbp), %rcx
leaq 0xfe7b(%rip), %rdi      # 0x1dbfc
leaq 0xe6e6(%rip), %rsi      # 0x1c46e
movl $0x98f, %edx            # imm = 0x98F
movb $0x0, %al
callq 0x117c0
movq -0x28(%rbp), %rdi
leaq 0xf3c9(%rip), %rsi      # 0x1d168
callq 0x22e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xdf91
movq -0x18(%rbp), %rax
movb $0x0, 0x6efe(%rax)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xdeea
cmpl $0x1, 0x24998(%rip)     # 0x3277c
jl 0xde04
movq -0x38(%rbp), %rcx
leaq 0xfe51(%rip), %rdi      # 0x1dc42
leaq 0xe676(%rip), %rsi      # 0x1c46e
movl $0x9a1, %edx            # imm = 0x9A1
movb $0x0, %al
callq 0x117c0
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x18(%rbp), %rcx
addq $0x6efe, %rcx           # imm = 0x6EFE
leaq 0x13b45(%rip), %rdx     # 0x21963
movl $0x27f7, %r8d           # imm = 0x27F7
leaq -0x48(%rbp), %r9
callq 0xc2d0
movl %eax, -0x3c(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x38(%rbp), %rax
jbe 0xde42
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0xdebe
movq -0x18(%rbp), %rdi
addq $0x6efe, %rdi           # imm = 0x6EFE
movl $0x1000, %esi           # imm = 0x1000
callq 0x144e0
movq -0x18(%rbp), %rax
addq $0x15ec8, %rax          # imm = 0x15EC8
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
addq $0x6efe, %rax           # imm = 0x6EFE
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
addq $0x6efe, %rdi           # imm = 0x6EFE
callq 0x2100
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x38e0
movq -0x18(%rbp), %rdi
addq $0x15ec8, %rdi          # imm = 0x15EC8
callq 0x3ab0
cmpl $0x1, %eax
jle 0xdebc
movq -0x18(%rbp), %rdi
movl $0xa, %esi
callq 0xa610
jmp 0xdebe
movq -0x38(%rbp), %rdi
leaq 0xf8ad(%rip), %rsi      # 0x1d776
callq 0x22e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xdee5
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xddd2
movq -0x18(%rbp), %rax
movsbl 0x5efd(%rax), %eax
cmpl $0x0, %eax
jne 0xdf23
movq -0x18(%rbp), %rdi
addq $0x5efd, %rdi           # imm = 0x5EFD
movq -0x18(%rbp), %rcx
addq $0x6efe, %rcx           # imm = 0x6EFE
movl $0x1001, %esi           # imm = 0x1001
leaq 0x1108e(%rip), %rdx     # 0x1efaa
movb $0x0, %al
callq 0x2130
movq -0x18(%rbp), %rax
cmpl $0x66, 0x27f8(%rax)
jne 0xdf8f
movq -0x18(%rbp), %rcx
addq $0x5efd, %rcx           # imm = 0x5EFD
leaq 0x1d02e(%rip), %rdi     # 0x2af70
addq $0x27ff, %rdi           # imm = 0x27FF
movl $0x27f7, %esi           # imm = 0x27F7
leaq 0x11055(%rip), %rdx     # 0x1efaa
movb $0x0, %al
callq 0x2130
cmpl $0x1, 0x24819(%rip)     # 0x3277c
jl 0xdf8d
leaq 0xfd0f(%rip), %rdi      # 0x1dc7b
leaq 0xe4fb(%rip), %rsi      # 0x1c46e
movl $0x9bf, %edx            # imm = 0x9BF
leaq 0x1cff1(%rip), %rcx     # 0x2af70
addq $0x27ff, %rcx           # imm = 0x27FF
movb $0x0, %al
callq 0x117c0
jmp 0xdf8f
jmp 0xdf91
jmp 0xdf93
cmpq $0x0, -0x28(%rbp)
je 0xdfa3
movq -0x28(%rbp), %rdi
callq 0x2030
xorl %eax, %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)