search for: guestfs_int_mllib_getopt_parse

Displaying 20 results from an estimated 23 matches for "guestfs_int_mllib_getopt_parse".

2016 Jul 15
0
[PATCH 1/3] mllib: Fix parsing of integers on the command line and use correct int type.
...9; types in the OCaml code, instead of using (native) 'int'. --- mllib/getopt-c.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c index 1f129a7..afb8793 100644 --- a/mllib/getopt-c.c +++ b/mllib/getopt-c.c @@ -247,7 +247,8 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu actionv = Field (specv, 1); switch (Tag_val (actionv)) { - int num; + long num; + int nchars; case 0: /* Unit of (unit -> unit) */ v = Field (actionv, 0); @@ -274,7 +275,8 @@ guestfs_int_mllib_getopt_parse (val...
2018 Aug 20
1
[PATCH] common/mltools: getopt: add Getopt.OptString
...+++++++++++- common/mltools/test-getopt.sh | 11 +++++++++++ 5 files changed, 55 insertions(+), 3 deletions(-) diff --git a/common/mltools/getopt-c.c b/common/mltools/getopt-c.c index 7b7e39be2..5fa703428 100644 --- a/common/mltools/getopt-c.c +++ b/common/mltools/getopt-c.c @@ -274,6 +274,10 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu has_arg = 1; break; + case 8: /* OptString of string * (string option -> unit) */ + has_arg = 2; + break; + default: error (EXIT_FAILURE, 0, "internal error: unhandled T...
2016 Jul 18
2
[PATCH] mllib: Getopt: fix integer parsing
...int_program_name, arg); + show_error (EXIT_FAILURE); + } + + if (num <= INT_MIN || num >= INT_MAX) { + fprintf (stderr, _("%s: %s: integer out of range\n"), + guestfs_int_program_name, arg); + show_error (EXIT_FAILURE); + } + + return (int) num; +} + value guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, value usage_msgv) { @@ -274,21 +296,13 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu break; case 5: /* Int of string * (int -> unit) */ - if (sscanf (optarg, "%d", &num) != 1) {...
2018 Aug 21
0
[PATCH 1/2] common/mltools: getopt: add Getopt.OptString
...+++++++++++- common/mltools/test-getopt.sh | 11 +++++++++++ 5 files changed, 55 insertions(+), 3 deletions(-) diff --git a/common/mltools/getopt-c.c b/common/mltools/getopt-c.c index 7b7e39be2..5fa703428 100644 --- a/common/mltools/getopt-c.c +++ b/common/mltools/getopt-c.c @@ -274,6 +274,10 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu has_arg = 1; break; + case 8: /* OptString of string * (string option -> unit) */ + has_arg = 2; + break; + default: error (EXIT_FAILURE, 0, "internal error: unhandled T...
2016 Jul 18
0
Re: [PATCH] mllib: Getopt: fix integer parsing
...guestfs_int_program_name, arg); > + show_error (EXIT_FAILURE); These bounds are not tight enough. On 32 bit they should check the range of a 31 bit signed int, and on 64 bit, a 63 bit signed int. Rich. > + } > + > + return (int) num; > +} > + > value > guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, value usage_msgv) > { > @@ -274,21 +296,13 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu > break; > > case 5: /* Int of string * (int -> unit) */ > - if (sscanf (optarg, &quo...
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 13
0
[PATCH v3 2/2] mllib: Getopt: support hidden options
....550baa4 100644 --- a/mllib/getopt.ml +++ b/mllib/getopt.ml @@ -43,6 +43,8 @@ type t = { usage_msg : usage_msg; } +let hidden_option_description = "" + external getopt_parse : string array -> (c_keys * spec * doc) array -> ?anon_fun:anon_fun -> usage_msg -> unit = "guestfs_int_mllib_getopt_parse" let column_wrap = 38 @@ -56,6 +58,11 @@ let show_help h () = let prologue = sprintf (f_"%s\nOptions:\n") h.usage_msg in Buffer.add_string b prologue; + let specs = List.filter ( + fun (_, _, doc) -> + doc <> hidden_option_description + ) h.specs in +...
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 15
5
[PATCH 0/3] mllib: Various fixes and changes to Getopt module.
The second patch is obviously not complete yet - for discussion only. Rich.
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 Jul 13
3
[PATCH v3 1/2] OCaml tools: add and use a Getopt module
...r.h> +#include <assert.h> + +#include <caml/alloc.h> +#include <caml/fail.h> +#include <caml/memory.h> +#include <caml/mlvalues.h> +#include <caml/callback.h> +#include <caml/printexc.h> + +#include "guestfs-internal-frontend.h" + +extern value guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, value usage_msgv); + +#define Val_none Val_int(0) + +#ifdef HAVE_ATTRIBUTE_CLEANUP +#define CLEANUP_FREE_OPTION_LIST __attribute__((cleanup(cleanup_option_list))) + +static void +cleanup_option_list (void *ptr) +{ + struct option *opts = * (struct optio...
2016 Jun 24
2
[PATCH] RFC: OCaml tools: add and use a Getopt module
....h> + +#include <caml/alloc.h> +#include <caml/fail.h> +#include <caml/memory.h> +#include <caml/mlvalues.h> +#include <caml/callback.h> +#include <caml/printexc.h> + +#include <guestfs.h> +#include "guestfs-internal-frontend.h" + +extern value guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, value usage_msgv); + +#define Val_none Val_int(0) + +static void +xwrite (int fd, const void *v_buf, size_t len) +{ + int r; + const char *buf = v_buf; + + while (len > 0) { + r = write (fd, buf, len); + if (r == -1) + error (EXIT_FAILUR...
2016 Jul 11
2
[PATCH v2] OCaml tools: add and use a Getopt module
....h> + +#include <caml/alloc.h> +#include <caml/fail.h> +#include <caml/memory.h> +#include <caml/mlvalues.h> +#include <caml/callback.h> +#include <caml/printexc.h> + +#include <guestfs.h> +#include "guestfs-internal-frontend.h" + +extern value guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, value usage_msgv); + +#define Val_none Val_int(0) + +#ifdef HAVE_ATTRIBUTE_CLEANUP +#define CLEANUP_FREE_OPTION_LIST __attribute__((cleanup(cleanup_option_list))) + +static void +cleanup_option_list (void *ptr) +{ + struct option *opts = * (struct optio...
2016 Jun 27
0
Re: [PATCH] RFC: OCaml tools: add and use a Getopt module
...line options to the specified ones, > sorting them, and setting [long_options] to them. > > diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c > new file mode 100644 > index 0000000..d44448f > --- /dev/null > +++ b/mllib/getopt-c.c > @@ -0,0 +1,398 @@ > +value > +guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, value usage_msgv) I'm not convinced that this function is safe against OCaml GC compaction. In particular there are problems such as: ... > + for (j = 0; j < len; ++j) { > + const char *key = String_val (Field (keysv, j)); key no...
2017 Jun 15
0
[PATCH v6 11/41] utils: Rename ‘guestfs-internal-frontend.h’ to ‘utils.h’.
...mllib/getopt-c.c b/mllib/getopt-c.c index d2d98768c..7b9af5958 100644 --- a/mllib/getopt-c.c +++ b/mllib/getopt-c.c @@ -40,7 +40,7 @@ #include <caml/callback.h> #include <caml/printexc.h> -#include "guestfs-internal-frontend.h" +#include "utils.h" extern value guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, value usage_msgv); diff --git a/mllib/uri-c.c b/mllib/uri-c.c index ffb55306b..592d09939 100644 --- a/mllib/uri-c.c +++ b/mllib/uri-c.c @@ -31,7 +31,7 @@ #include <caml/mlvalues.h> #include <guestfs.h> -#include "guestfs-internal-f...
2017 Jun 19
0
[PATCH v7 12/13] utils: Rename ‘guestfs-internal-frontend.h’ to ‘guestfs-utils.h’.
...topt-c.c b/mllib/getopt-c.c index d2d98768c..7b7e39be2 100644 --- a/mllib/getopt-c.c +++ b/mllib/getopt-c.c @@ -40,7 +40,7 @@ #include <caml/callback.h> #include <caml/printexc.h> -#include "guestfs-internal-frontend.h" +#include "guestfs-utils.h" extern value guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, value usage_msgv); diff --git a/mllib/uri-c.c b/mllib/uri-c.c index ffb55306b..3e539c50e 100644 --- a/mllib/uri-c.c +++ b/mllib/uri-c.c @@ -31,7 +31,7 @@ #include <caml/mlvalues.h> #include <guestfs.h> -#include "guestfs-internal-f...
2016 Sep 08
4
[PATCH 0/3] Use gnulib's getprogname
Hi, this series update libguestfs to a recent gnulib version, so that we can use its new getprogname module, and solve altogether one of the porting issues (the need for 'program_name' by the error module of gnulib), and have a single way to get the name of the current program. A number of changes in tools mostly, although mechanical. Thanks, Pino Toscano (3): Update gnulib to latest
2017 Apr 04
1
[PATCH] Use Unicode single quotes ‘’ in place of short single quoted strings throughout.
...NULL, 0, &num, "") != LONGINT_OK) { - fprintf (stderr, _("%s: '%s' is not a numeric value.\n"), + fprintf (stderr, _("%s: ‘%s’ is not a numeric value.\n"), getprogname (), arg); show_error (EXIT_FAILURE); } @@ -375,10 +375,10 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu v = Field (actionv, 1); if (!list_mem (v, optarg)) { if (c != 0) { - fprintf (stderr, _("%s: '%s' is not allowed for -%c; allowed values are:\n"), + fprintf (stderr, _("%s: ‘%s’ is not...
2017 Jun 19
16
[PATCH v7 00/13] Refactor utilities
This is just the utilities part of the patch series from: https://www.redhat.com/archives/libguestfs/2017-June/msg00103.html I believe this addresses everything raised in comments on that patch series. Rich.
2017 Jun 09
12
[PATCH 00/12] Refactor utility functions.
This turned out to be rather more involved than I thought. We have lots of utility functions, spread all over the repository, with not a lot of structure. This moves many of them under common/ and structures them so there are clear dependencies. This doesn't complete the job by any means. Other items I had on my to-do list for this change were: - Split up mllib/common_utils into: -