diff options
author | Andre Heider <a.heider@gmail.com> | 2022-12-09 15:16:31 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2023-01-16 11:21:34 +0100 |
commit | 63413578a8e32e90cbb01d8bffff7f6db5a3a7a5 (patch) | |
tree | e04de39b9ff11c13f0d0a0685fcfc0244835cd44 | |
parent | 23977554d9694d025eada50a5547e99ee1be7838 (diff) | |
download | uhttpd2-63413578a8e32e90cbb01d8bffff7f6db5a3a7a5.tar.gz |
ucode: respect all arguments passed to send()
Similar to ucode's print() this now prints any given values to stdout:
uhttpd.send(a, b, c, "\n");
Signed-off-by: Andre Heider <a.heider@gmail.com>
-rw-r--r-- | ucode.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -115,20 +115,22 @@ uh_ucode_recv(uc_vm_t *vm, size_t nargs) static uc_value_t * uh_ucode_send(uc_vm_t *vm, size_t nargs) { - uc_value_t *val = uc_fn_arg(0); - ssize_t len; + uc_value_t *val; + size_t arridx; + ssize_t len = 0; char *p; - if (ucv_type(val) == UC_STRING) { - len = write(STDOUT_FILENO, ucv_string_get(val), ucv_string_length(val)); - } - else if (val != NULL) { - p = ucv_to_string(vm, val); - len = p ? write(STDOUT_FILENO, p, strlen(p)) : 0; - free(p); - } - else { - len = 0; + for (arridx = 0; arridx < nargs; arridx++) { + val = uc_fn_arg(arridx); + + if (ucv_type(val) == UC_STRING) { + len += write(STDOUT_FILENO, ucv_string_get(val), ucv_string_length(val)); + } + else if (val != NULL) { + p = ucv_to_string(vm, val); + len += p ? write(STDOUT_FILENO, p, strlen(p)) : 0; + free(p); + } } return ucv_int64_new(len); |