// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x23a0
movq %rax, %r13
leaq 0xc676(%rip), %rsi      # 0x16a47
movq %rbx, %rdi
callq 0x23c0
testq %rax, %rax
je 0xa642
incl 0x18d30(%r14)
movq %r15, %rdi
callq 0xbeb9
leaq 0xc663(%rip), %rsi      # 0x16a5b
movq %r15, %rdi
callq 0x23c0
testq %rax, %rax
je 0xa412
movl $0x64, 0x17100(%r14)
jmp 0xa45f
leaq 0xc649(%rip), %rsi      # 0x16a62
movq %r15, %rdi
callq 0x23c0
testq %rax, %rax
je 0xa433
movl $0x12c, 0x17100(%r14) # imm = 0x12C
jmp 0xa45f
leaq 0xc1a1(%rip), %rsi      # 0x165db
movq %r15, %rdi
callq 0x23c0
testq %rax, %rax
je 0xa454
movl $0xc8, 0x17100(%r14)
jmp 0xa45f
movl $0x0, 0x17100(%r14)
testq %r15, %r15
je 0xa4af
movzbl (%r15), %eax
cmpl $0x20, %eax
je 0xa472
cmpl $0x9, %eax
jne 0xa477
incq %r15
jmp 0xa464
leaq 0x17104(%r14), %rbx
movl $0xa00, %edx            # imm = 0xA00
movq %rbx, %rdi
movq %r15, %rsi
callq 0xbede
movabsq $0x800000100002601, %rax # imm = 0x800000100002601
movzbl (%rbx), %ecx
cmpq $0x3b, %rcx
ja 0xa4a7
btq %rcx, %rax
jb 0xa4ac
incq %rbx
jmp 0xa498
movb $0x0, (%rbx)
cmpl $0x0, 0x21ed6(%rip)     # 0x2c38c
jle 0xa4d5
leaq 0xc5ad(%rip), %rdi      # 0x16a6c
leaq 0xae18(%rip), %rsi      # 0x152de
movl $0x98f, %edx            # imm = 0x98F
movq %r13, %rcx
xorl %eax, %eax
callq 0xc84f
leaq 0xbafc(%rip), %rsi      # 0x15fd8
movq %r13, %rdi
callq 0x22f0
testq %rax, %rax
je 0xa642
movq %rax, %r12
movq %r13, 0x8(%rsp)
leaq 0x6efe(%r14), %r15
movb $0x0, 0x6efe(%r14)
leaq 0x15ec8(%r14), %r13
leaq 0x10(%rsp), %rbx
leaq 0xc0cf(%rip), %rbp      # 0x165e6
incq %r12
cmpl $0x0, 0x21e6b(%rip)     # 0x2c38c
jle 0xa540
leaq 0xc588(%rip), %rdi      # 0x16ab2
leaq 0xadad(%rip), %rsi      # 0x152de
movl $0x9a1, %edx            # imm = 0x9A1
movq %r12, %rcx
xorl %eax, %eax
callq 0xc84f
movq %r14, %rdi
movq %r12, %rsi
leaq 0x10604(%rip), %rdx     # 0x1ab51
movq %r15, %rcx
movl $0x27f7, %r8d           # imm = 0x27F7
movq %rbx, %r9
callq 0x9285
movq 0x10(%rsp), %rcx
cmpq %r12, %rcx
cmovaq %rcx, %r12
testl %eax, %eax
jne 0xa5ab
movq %r15, %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xe573
movq %r15, %rdi
callq 0x2110
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32eb
movq %r13, %rdi
callq 0x33f8
cmpl $0x2, %eax
jl 0xa5ab
movq %r14, %rdi
movl $0xa, %esi
callq 0x7f77
movq %r12, %rdi
movq %rbp, %rsi
callq 0x22f0
movq %rax, %r12
testq %rax, %rax
jne 0xa517
leaq 0x5efd(%r14), %rbx
cmpb $0x0, 0x5efd(%r14)
jne 0xa5ec
leaq 0xda86(%rip), %rdx      # 0x18060
movl $0x1001, %esi           # imm = 0x1001
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2140
cmpl $0x66, 0x27f8(%r14)
movq 0x8(%rsp), %r13
jne 0xa642
leaq 0x1cd7d(%rip), %rdi     # 0x2737f
leaq 0xda57(%rip), %rdx      # 0x18060
movl $0x27f7, %esi           # imm = 0x27F7
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2140
cmpl $0x0, 0x21d6d(%rip)     # 0x2c38c
jle 0xa642
leaq 0xc4c3(%rip), %rdi      # 0x16aeb
leaq 0xacaf(%rip), %rsi      # 0x152de
leaq 0x1cd49(%rip), %rcx     # 0x2737f
movl $0x9bf, %edx            # imm = 0x9BF
xorl %eax, %eax
callq 0xc84f
testq %r13, %r13
je 0xa64f
movq %r13, %rdi
callq 0x2030
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq