// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movups (%rcx), %xmm0
movups %xmm0, (%rax)
movq 0x9b970(%rip), %rax     # 0x104fb0
movq (%rax), %rdi
callq 0x69560
movl $0x400, %edi            # imm = 0x400
callq 0x35020
movq %rax, -0x438(%rbp)
movq -0x438(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x68290
movq -0x438(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x43c(%rbp)
movl $0x3ff, -0x440(%rbp)    # imm = 0x3FF
movq -0x438(%rbp), %rax
movl 0x14(%rax), %eax
cmpl -0x440(%rbp), %eax
jle 0x696a5
movl -0x440(%rbp), %eax
movl %eax, -0x43c(%rbp)
leaq -0x430(%rbp), %rdi
movq -0x438(%rbp), %rax
movq 0x8(%rax), %rdx
movslq -0x43c(%rbp), %rcx
movl $0x400, %esi            # imm = 0x400
callq 0x31130
movq -0x438(%rbp), %rax
movl 0x14(%rax), %eax
cmpl -0x440(%rbp), %eax
jle 0x696fb
leaq -0x430(%rbp), %rdi
movslq -0x43c(%rbp), %rax
addq %rax, %rdi
addq $-0x5, %rdi
leaq 0x7728e(%rip), %rsi     # 0xe0984
callq 0x6680
leaq -0x438(%rbp), %rdi
callq 0x35080
leaq -0x430(%rbp), %rdi
callq 0x68b80
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
callq 0x693d0
movq %rax, -0x450(%rbp)
movq -0x448(%rbp), %rdi
callq 0x40d40
movl $0x800, %edi            # imm = 0x800
callq 0x35020
movq %rax, -0x458(%rbp)
movq -0x458(%rbp), %rdi
movq -0x450(%rbp), %rdx
leaq 0x77687(%rip), %rsi     # 0xe0de6
movb $0x0, %al
callq 0x35540
movq -0x458(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x62560
leaq 0x776ce(%rip), %rdi     # 0xe0e4b
movb $0x0, %al
callq 0x6070
leaq -0x458(%rbp), %rdi
callq 0x35080
movq -0x450(%rbp), %rdi
callq 0x40d40
movb $0x0, %al
callq 0x670b0
movq 0x9b826(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x69d0
movq 0x9b80f(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x6f84e(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq 0x9b7f7(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
callq 0x6850
leaq -0x30(%rbp), %rax
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
nop