search for: do_call1

Displaying 13 results from an estimated 13 matches for "do_call1".

Did you mean: do_call
2016 Jul 18
2
[PATCH] mllib: Getopt: fix integer parsing
....c index 1f129a7..2d3f9b6 100644 --- a/mllib/getopt-c.c +++ b/mllib/getopt-c.c @@ -30,6 +30,8 @@ #include <error.h> #include <assert.h> +#include "xstrtol.h" + #include <caml/alloc.h> #include <caml/fail.h> #include <caml/memory.h> @@ -117,6 +119,26 @@ do_call1 (value funv, value paramv) CAMLreturn0; } +static int +strtoint (const char *arg) +{ + long int num; + + if (xstrtol (arg, NULL, 0, &num, NULL) != LONGINT_OK) { + fprintf (stderr, _("%s: '%s' is not a numeric value.\n"), + guestfs_int_program_name, arg);...
2016 Jul 18
0
Re: [PATCH] mllib: Getopt: fix integer parsing
...> +++ b/mllib/getopt-c.c > @@ -30,6 +30,8 @@ > #include <error.h> > #include <assert.h> > > +#include "xstrtol.h" > + > #include <caml/alloc.h> > #include <caml/fail.h> > #include <caml/memory.h> > @@ -117,6 +119,26 @@ do_call1 (value funv, value paramv) > CAMLreturn0; > } This function needs to return something other than 'int', since on 64 bit OCaml integers (the final destination) are signed 63 bits. I think returning 'long' is a better idea, and the receiving 'num' should also be ...
2018 Aug 20
1
[PATCH] common/mltools: getopt: add Getopt.OptString
...ng[optstring_len++] = ':'; + } } else { struct option *newopts = realloc (longopts, (longopts_len + 1 + 1) * sizeof (*longopts)); if (newopts == NULL) @@ -393,6 +400,17 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu do_call1 (v, v2); break; + case 8: /* OptString of string * (string option -> unit) */ + v = Field (actionv, 1); + if (optarg) { + v2 = caml_alloc (1, 0); + Store_field (v2, 0, caml_copy_string (optarg)); + } else { + v2 = Val_none; + } + do_call...
2018 Aug 21
0
[PATCH 1/2] common/mltools: getopt: add Getopt.OptString
...ng[optstring_len++] = ':'; + } } else { struct option *newopts = realloc (longopts, (longopts_len + 1 + 1) * sizeof (*longopts)); if (newopts == NULL) @@ -393,6 +400,17 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu do_call1 (v, v2); break; + case 8: /* OptString of string * (string option -> unit) */ + v = Field (actionv, 1); + if (optarg) { + v2 = caml_alloc (1, 0); + Store_field (v2, 0, caml_copy_string (optarg)); + } else { + v2 = Val_none; + } + do_call...
2018 Aug 21
4
[PATCH 0/2] RFC: add output selection for --machine-readable
Hi, this is a first approach (hence RFC, since it misses tests & documentation) in selecting the output for --machine-readable. The possible choices are: * --machine-readable: to stdout, like before * --machine-readable=file:name-of-file: to the specified file * --machine-readable=stream:stdout: explicitly to stdout * --machine-readable=stream:stderr: explicitly to stderr This makes it
2016 Jul 11
0
Re: [PATCH v2] OCaml tools: add and use a Getopt module
On Mon, Jul 11, 2016 at 06:03:39PM +0200, Pino Toscano wrote: > diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c > new file mode 100644 > index 0000000..e5e832c > --- /dev/null > +++ b/mllib/getopt-c.c > +static void > +do_call1 (value funv, value paramv) > +{ > + CAMLparam2 (funv, paramv); > + CAMLlocal1 (rv); > + > + rv = caml_callback_exn (funv, paramv); > + > + if (Is_exception_result (rv)) > + fprintf (stderr, > + "libguestfs: uncaught OCaml exception in getopt callba...
2016 Jul 18
2
Re: [PATCH] mllib: Getopt: fix integer parsing
...0,8 @@ > > #include <error.h> > > #include <assert.h> > > > > +#include "xstrtol.h" > > + > > #include <caml/alloc.h> > > #include <caml/fail.h> > > #include <caml/memory.h> > > @@ -117,6 +119,26 @@ do_call1 (value funv, value paramv) > > CAMLreturn0; > > } > > This function needs to return something other than 'int', since on 64 > bit OCaml integers (the final destination) are signed 63 bits. I > think returning 'long' is a better idea, and the receiving &...
2016 Jul 18
4
[PATCH 1/3] mllib: Getopt: point to man page as additional help
On error, point also to the man page of the current tool in addition to '$TOOL --help'. --- mllib/getopt-c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c index bf40f91..3efd5d3 100644 --- a/mllib/getopt-c.c +++ b/mllib/getopt-c.c @@ -69,8 +69,8 @@ cleanup_option_list (void *ptr) static void __attribute__((noreturn))
2016 Jul 11
2
[PATCH v2] OCaml tools: add and use a Getopt module
...val (keysv); + + for (j = 0; j < len; ++j) { + const char *key = String_val (Field (keysv, j)); + + if (key[0] == '-' && key[1] == opt) { + ret = i; + goto done; + } + } + } + + ret = -1; + + done: + CAMLreturnT (int, ret); +} + +static void +do_call1 (value funv, value paramv) +{ + CAMLparam2 (funv, paramv); + CAMLlocal1 (rv); + + rv = caml_callback_exn (funv, paramv); + + if (Is_exception_result (rv)) + fprintf (stderr, + "libguestfs: uncaught OCaml exception in getopt callback: %s", + caml_format_excep...
2016 Jul 13
3
[PATCH v3 1/2] OCaml tools: add and use a Getopt module
...val (keysv); + + for (j = 0; j < len; ++j) { + const char *key = String_val (Field (keysv, j)); + + if (key[0] == '-' && key[1] == opt) { + ret = i; + goto done; + } + } + } + + ret = -1; + + done: + CAMLreturnT (int, ret); +} + +static void +do_call1 (value funv, value paramv) +{ + CAMLparam2 (funv, paramv); + CAMLlocal1 (rv); + + rv = caml_callback_exn (funv, paramv); + + if (Is_exception_result (rv)) + fprintf (stderr, + "libguestfs: uncaught OCaml exception in getopt callback: %s\n", + caml_format_exc...
2018 Aug 23
3
[PATCH v2 0/2] add output selection for --machine-readable
Hi, this adds the possibility to select the output for --machine-readable in OCaml tools. The possible choices are: * --machine-readable: to stdout, like before * --machine-readable=file:name-of-file: to the specified file * --machine-readable=stream:stdout: explicitly to stdout * --machine-readable=stream:stderr: explicitly to stderr This makes it possible to add additional output for
2016 Jun 24
2
[PATCH] RFC: OCaml tools: add and use a Getopt module
...val (keysv); + + for (j = 0; j < len; ++j) { + const char *key = String_val (Field (keysv, j)); + + if (key[0] == '-' && key[1] == opt) { + ret = i; + goto done; + } + } + } + + ret = -1; + + done: + CAMLreturnT (int, ret); +} + +static void +do_call1 (value funv, value paramv) +{ + CAMLparam2 (funv, paramv); + CAMLlocal1 (rv); + + rv = caml_callback_exn (funv, paramv); + + if (Is_exception_result (rv)) + fprintf (stderr, + "libguestfs: uncaught OCaml exception in getopt callback: %s", + caml_format_excep...
2016 Jun 27
0
Re: [PATCH] RFC: OCaml tools: add and use a Getopt module
...aml heap, and then ... > + if (newopts == NULL) > + caml_raise_out_of_memory (); > + longopts = newopts; > + longopts[longopts_len].name = key; the same pointer is copied to longopts, but ... > + case 0: /* Unit of (unit -> unit) */ > + do_call1 (Field (actionv, 0), Val_unit); At this point you're calling an OCaml function which is likely to allocate, and could therefore call the GC, and could therefore compact the heap, which would move that string around, and make your pointer invalid. (You could try adding `Gc.compact ()' to o...