Hash :
5bc77c4d
Author :
Thomas de Grivel
Date :
2025-10-06T14:30:45
config_prog, default argv0 and prefix
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
/* kc3
* Copyright from 2022 to 2025 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"
const char *g_argv0_default = PROG;
const char *g_argv0_dir_default = PREFIX;
int main (int argc, char **argv)
{
s_call call = {0};
// s_env *env;
const s_sym *module = NULL;
sw r = 1;
s_tag tmp = {0};
kc3_init(NULL, &argc, &argv);
// env = env_global();
module = sym_1("Kpkg.Main");
call_init(&call);
call.ident.module = module;
call.ident.sym = sym_1("main");
if (! eval_call(&call, &tmp)) {
err_puts("kpkg: eval_call");
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;
}