Hash :
bb51f91d
Author :
Thomas de Grivel
Date :
2024-07-31T16:34:06
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/* kc3
* Copyright 2022,2023,2024 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#include <libkc3/kc3.h>
#include "config.h"
int main (int argc, char **argv)
{
s_call call = {0};
const s_sym *module = NULL;
int r = 1;
s_tag tmp = {0};
kc3_init(NULL, &argc, &argv);
io_puts("KC3 HTTPd loading, please wait...");
module = sym_1("HTTPd");
if (! module_load(module)) {
kc3_clean(NULL);
return 1;
}
call_init(&call);
call.ident.module = module;
call.ident.sym = sym_1("main");
if (argc >= 2)
call.arguments = list_new_str_1
(NULL, argv[0], list_new_str_1
(NULL, argv[1], NULL));
else if (argc == 1)
call.arguments = list_new_str_1(NULL, argv[0], NULL);
else
call.arguments = NULL;
if (! eval_call(&call, &tmp))
goto clean;
switch (tmp.type) {
case TAG_U8:
r = tmp.data.u8;
break;
default:
err_write_1("invalid return type from main: ");
err_inspect_tag(&tmp);
err_write_1("\n");
}
clean:
tag_clean(&tmp);
call_clean(&call);
kc3_clean(NULL);
return r;
}