mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48:29 +00:00
Fix bugs and make improvements to redbean
- Abort if .init.lua fails - Refactor redbean to use new append library - Use first certificate if SNI routing fails - Use function/data sections when building Lua - Don't use self-signed auto-generated cert for client - Add -D staging dirs to redbean lua module default path
This commit is contained in:
parent
55a15c204e
commit
aeeb851422
26 changed files with 703 additions and 513 deletions
|
@ -19,15 +19,33 @@
|
|||
#include "libc/bits/bits.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
/**
|
||||
* Appends string to buffer.
|
||||
* Appends character or word-encoded string to buffer.
|
||||
*
|
||||
* Up to eight characters can be appended. For example:
|
||||
*
|
||||
* appendw(&s, 'h'|'i'<<8);
|
||||
*
|
||||
* Is equivalent to:
|
||||
*
|
||||
* appends(&s, "hi");
|
||||
*
|
||||
* The special case:
|
||||
*
|
||||
* appendw(&s, 0);
|
||||
*
|
||||
* Will append a single NUL character.
|
||||
*
|
||||
* The resulting buffer is guaranteed to be NUL-terminated, i.e.
|
||||
* `!b[appendz(b).i]` will be the case.
|
||||
*
|
||||
* @return bytes appended or -1 if `ENOMEM`
|
||||
*/
|
||||
int appendw(char **b, uint64_t w) {
|
||||
ssize_t appendw(char **b, uint64_t w) {
|
||||
char t[8];
|
||||
unsigned l;
|
||||
if (!w) return 0;
|
||||
unsigned n = 1;
|
||||
WRITE64LE(t, w);
|
||||
return appendd(b, t, (bsrl(w) >> 3) + 1);
|
||||
if (w) n += bsrl(w) >> 3;
|
||||
return appendd(b, t, n);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue