// File: /workspace/github_c_makefile_star2_O2/inflex[P]ripMIME/MIME_headers.c
// Function: MIMEH_parse_contenttransferencoding
int MIMEH_parse_contenttransferencoding( char *header_name, char *header_value, struct MIMEH_header_info *hinfo )
{
    char *p, *q;
    char c = '\n';

    // CONTENT TRANSFER ENCODING ---------------------
    // CONTENT TRANSFER ENCODING ---------------------
    // CONTENT TRANSFER ENCODING ---------------------


    p = strstr(header_name,"content-transfer-encoding");
    if (p)
    {
        /** 20041216-1107:PLD: Increase our sanity **/
        hinfo->sanity++;

        q = strpbrk(header_value,"\n\r;");
        if (q != NULL)
        {
            c = *q;
            *q = '\0';
        }

        p = header_value;

        PLD_strlower( p );

        if (strstr(p,"base64"))
        {
            hinfo->content_transfer_encoding = _CTRANS_ENCODING_B64;
            if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_parse_contenttransferencoding: Encoding set to BASE64", FL);
        }
        else if (strstr(p,"7bit"))
        {
            hinfo->content_transfer_encoding = _CTRANS_ENCODING_7BIT;
            if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_parse_contenttransferencoding: Encoding set to 7-BIT ", FL);
        }
        else if (strstr(p,"8bit"))
        {
            hinfo->content_transfer_encoding = _CTRANS_ENCODING_8BIT;
            if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_parse_contenttransferencoding: Encoding set to 8-BIT", FL);
        }
        else if (strstr(p,"quoted-printable"))
        {
            hinfo->content_transfer_encoding = _CTRANS_ENCODING_QP;
            if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_parse_contenttransferencoding: Encoding set to Quoted-Printable", FL);
        }
        else if (strstr(p,"binary"))
        {
            hinfo->content_transfer_encoding = _CTRANS_ENCODING_BINARY;
            if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_parse_contenttransferencoding: Encoding set to Binary", FL);
        }
        else if (
                (strstr(p,"uu"))
                ||(strstr(p,"x-u"))
                ||(strcmp(p,"u") == 0)
                )
        {
            hinfo->content_transfer_encoding = _CTRANS_ENCODING_UUENCODE;
            if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_parse_contenttransferencoding: Encoding set to UUENCODE", FL);
        }
        else hinfo->content_transfer_encoding = _CTRANS_ENCODING_RAW;


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

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

            // Step 2 - Copy the string
            PLD_strncpy( hinfo->content_transfer_encoding_string, cp, _MIMEH_CONTENT_TRANSFER_ENCODING_MAX);

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

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

        // Set the character which we changed to a \0 back to its original form so that
        //      we don't cause problems from tainted data for any further parsing calls
        //      which use the data.
        if (q != NULL) *q = c;
    }

    return 0;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
leaq 0xb9e4(%rip), %rsi      # 0x15869
callq 0x23d0
testq %rax, %rax
je 0xa0d2
incl 0x18d30(%rbx)
leaq 0xb9e3(%rip), %rsi      # 0x15883
movq %r15, %rdi
callq 0x2300
movq %rax, %r14
testq %rax, %rax
je 0x9eb9
movb (%r14), %bpl
movb $0x0, (%r14)
jmp 0x9ebc
movb $0xa, %bpl
movq %r15, %rdi
callq 0xba23
leaq 0x7346(%rip), %rsi      # 0x11211
movq %r15, %rdi
callq 0x23d0
testq %rax, %rax
je 0x9f07
movl $0x64, 0x166f8(%rbx)
cmpl $0x0, 0x214a3(%rip)     # 0x2b38c
jle 0xa061
leaq 0xb991(%rip), %rdi      # 0x15887
leaq 0xa3e1(%rip), %rsi      # 0x142de
movl $0x903, %edx            # imm = 0x903
jmp 0xa05a
leaq 0xb9bb(%rip), %rsi      # 0x158c9
movq %r15, %rdi
callq 0x23d0
testq %rax, %rax
je 0x9f4a
movl $0x65, 0x166f8(%rbx)
cmpl $0x0, 0x21460(%rip)     # 0x2b38c
jle 0xa061
leaq 0xb995(%rip), %rdi      # 0x158ce
leaq 0xa39e(%rip), %rsi      # 0x142de
movl $0x908, %edx            # imm = 0x908
jmp 0xa05a
leaq 0xb9bf(%rip), %rsi      # 0x15910
movq %r15, %rdi
callq 0x23d0
testq %rax, %rax
je 0x9f8d
movl $0x66, 0x166f8(%rbx)
cmpl $0x0, 0x2141d(%rip)     # 0x2b38c
jle 0xa061
leaq 0xb999(%rip), %rdi      # 0x15915
leaq 0xa35b(%rip), %rsi      # 0x142de
movl $0x90d, %edx            # imm = 0x90D
jmp 0xa05a
leaq 0xb9c2(%rip), %rsi      # 0x15956
movq %r15, %rdi
callq 0x23d0
testq %rax, %rax
je 0x9fd0
movl $0x67, 0x166f8(%rbx)
cmpl $0x0, 0x213da(%rip)     # 0x2b38c
jle 0xa061
leaq 0xb9a8(%rip), %rdi      # 0x15967
leaq 0xa318(%rip), %rsi      # 0x142de
movl $0x912, %edx            # imm = 0x912
jmp 0xa05a
leaq 0xb9dc(%rip), %rsi      # 0x159b3
movq %r15, %rdi
callq 0x23d0
testq %rax, %rax
je 0xa00c
movl $0x69, 0x166f8(%rbx)
cmpl $0x0, 0x21397(%rip)     # 0x2b38c
jle 0xa061
leaq 0xb9bc(%rip), %rdi      # 0x159ba
leaq 0xa2d9(%rip), %rsi      # 0x142de
movl $0x917, %edx            # imm = 0x917
jmp 0xa05a
leaq 0xb9e9(%rip), %rsi      # 0x159fc
movq %r15, %rdi
callq 0x23d0
testq %rax, %rax
jne 0xa034
leaq 0xb9d8(%rip), %rsi      # 0x159ff
movq %r15, %rdi
callq 0x23d0
testq %rax, %rax
je 0xa068
movl $0x6a, 0x166f8(%rbx)
cmpl $0x0, 0x21347(%rip)     # 0x2b38c
jle 0xa061
leaq 0xb9b5(%rip), %rdi      # 0x15a03
leaq 0xa289(%rip), %rsi      # 0x142de
movl $0x920, %edx            # imm = 0x920
xorl %eax, %eax
callq 0xc2a1
testq %r15, %r15
jne 0xa084
jmp 0xa0ca
cmpb $0x75, (%r15)
jne 0xa075
cmpb $0x0, 0x1(%r15)
je 0xa034
movl $0x68, 0x166f8(%rbx)
jmp 0xa084
incq %r15
movzbl (%r15), %eax
cmpl $0x20, %eax
je 0xa081
cmpl $0x9, %eax
je 0xa081
addq $0x166fc, %rbx          # imm = 0x166FC
movl $0xa00, %edx            # imm = 0xA00
movq %rbx, %rdi
movq %r15, %rsi
callq 0xba3e
movabsq $0x800000100002601, %rax # imm = 0x800000100002601
movzbl (%rbx), %ecx
cmpq $0x3b, %rcx
ja 0xa0c2
btq %rcx, %rax
jb 0xa0c7
incq %rbx
jmp 0xa0b3
movb $0x0, (%rbx)
testq %r14, %r14
je 0xa0d2
movb %bpl, (%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq