// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/lib/htmshell.c
// Function: htmlVaWarn
void htmlVaWarn(char *format, va_list args)
/* Write an error message. */
{
va_list argscp;
va_copy(argscp, args);
htmlWarnBoxSetup(stdout); // sets up the warnBox if it hasn't already been done.
char warning[1024];

// html-encode arguments to fight XSS
struct dyString *ds = newDyString(1024);
vaHtmlDyStringPrintf(ds, format, args);
int n = ds->stringSize;
int nLimit = sizeof(warning) - 1;
if (ds->stringSize > nLimit)
    n = nLimit;
safencpy(warning, sizeof warning, ds->string, n);
if (ds->stringSize > nLimit)
    strcpy(warning+n-5,"[...]"); // show truncation
freeDyString(&ds);

// Replace newlines with BR tag
char *warningBR = htmlWarnEncode(warning); 

// Javascript-encode the entire message because it is
// going to appear as a javascript string literal
// as it gets appended to the warnList html.
// JS-encoding here both allows us to use any character in the message
// and keeps js-encodings in events like onmouseover="stuff %s|js| stuff" secure.
char *jsEncodedMessage = javascriptEncode (warningBR); 
freeMem(warningBR);
struct dyString *dy = dyStringNew(2048);
dyStringPrintf(dy,
    "showWarnBox();"
    "var warnList=document.getElementById('warnList');"
    "warnList.innerHTML += '<li>%s</li>';\n", jsEncodedMessage);
jsInline(dy->string);  
// TODO GALT does --ERROR -- tag still work?
printf("<!-- ERROR -->\n");
// NOTE that "--ERROR --" is needed at the end of this print!!
dyStringFree(&dy);
freeMem(jsEncodedMessage);

/* Log useful CGI info to stderr */
logCgiToStderr();

/* write warning/error message to stderr so they get logged. */
vfprintf(stderr, format, argscp);
fprintf(stderr, "\n");
fflush(stderr);
va_end(argscp);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x430, %rsp            # imm = 0x430
movq %rsi, %r14
movq %rdi, %rbx
movq 0x10(%rsi), %rax
movq %rax, 0x20(%rsp)
movups (%rsi), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0xb7d3c(%rip), %rax     # 0xbefb0
movq (%rax), %rdi
callq 0x48679
movl $0x400, %edi            # imm = 0x400
callq 0x261d0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x47ac0
movq 0x8(%rsp), %rax
movl 0x14(%rax), %ecx
movl $0x3ff, %esi            # imm = 0x3FF
cmpl %esi, %ecx
cmovll %ecx, %esi
movq 0x8(%rax), %rdx
movslq %esi, %r14
leaq 0x30(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rcx
callq 0x23c98
movq 0x8(%rsp), %rax
cmpl $0x400, 0x14(%rax)      # imm = 0x400
jl 0x72e3
movw $0x5d, 0x2f(%rsp,%r14)
movl $0x2e2e2e5b, 0x2b(%rsp,%r14) # imm = 0x2E2E2E5B
leaq 0x8(%rsp), %rdi
callq 0x2620d
leaq 0x30(%rsp), %rdi
callq 0x47fac
movq %rax, %r15
movq %rax, %rdi
callq 0x48565
movq %rax, %r14
movq %r15, %rdi
callq 0x2dd41
movl $0x800, %edi            # imm = 0x800
callq 0x261d0
leaq 0x28(%rsp), %r15
movq %rax, (%r15)
leaq 0x8fae7(%rip), %rsi     # 0x96e0d
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2656a
movq (%r15), %rax
movq 0x8(%rax), %rdi
callq 0x43c7a
leaq 0x90484(%rip), %rdi     # 0x977ca
callq 0x6bb0
movq %r15, %rdi
callq 0x2620d
movq %r14, %rdi
callq 0x2dd41
xorl %eax, %eax
callq 0x707d
movq 0xb7c6f(%rip), %r14     # 0xbefd8
movq (%r14), %rdi
leaq 0x10(%rsp), %rdx
movq %rbx, %rsi
callq 0x69e0
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x6930
movq (%r14), %rdi
callq 0x6870
addq $0x430, %rsp            # imm = 0x430
popq %rbx
popq %r14
popq %r15
retq