]>
git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/src/third_party/duktape-1.8.0/examples/guide/uppercase.c
6 static int dummy_upper_case(duk_context
*ctx
) {
8 const char *val
= duk_require_lstring(ctx
, 0, &sz
);
11 /* We're going to need 'sz' additional entries on the stack. */
12 duk_require_stack(ctx
, sz
);
14 for (i
= 0; i
< sz
; i
++) {
16 if (ch
>= 'a' && ch
<= 'z') {
19 duk_push_lstring(ctx
, (const char *) &ch
, 1);
26 int main(int argc
, char *argv
[]) {
29 if (argc
< 2) { exit(1); }
31 ctx
= duk_create_heap_default();
32 if (!ctx
) { exit(1); }
34 duk_push_c_function(ctx
, dummy_upper_case
, 1);
35 duk_push_string(ctx
, argv
[1]);
37 printf("%s -> %s\n", argv
[1], duk_to_string(ctx
, -1));
40 duk_destroy_heap(ctx
);