]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/src/third_party/duktape-1.8.0/examples/eval/eval.c
2 * Very simple example program for evaluating expressions from
9 static int eval_raw(duk_context
*ctx
) {
14 static int tostring_raw(duk_context
*ctx
) {
15 duk_to_string(ctx
, -1);
19 static void usage_exit(void) {
20 fprintf(stderr
, "Usage: eval <expression> [<expression>] ...\n");
25 int main(int argc
, char *argv
[]) {
34 ctx
= duk_create_heap_default();
35 for (i
= 1; i
< argc
; i
++) {
36 printf("=== eval: '%s' ===\n", argv
[i
]);
37 duk_push_string(ctx
, argv
[i
]);
38 duk_safe_call(ctx
, eval_raw
, 1 /*nargs*/, 1 /*nrets*/);
39 duk_safe_call(ctx
, tostring_raw
, 1 /*nargs*/, 1 /*nrets*/);
40 res
= duk_get_string(ctx
, -1);
41 printf("%s\n", res
? res
: "null");
45 duk_destroy_heap(ctx
);