search for: string_val

Displaying 20 results from an estimated 177 matches for "string_val".

2020 Sep 01
3
Re: [nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...wrapper (int readonly, int is_tls, struct nbdkit_exports *exports) /* Convert exports list into calls to nbdkit_add_export. */ while (rv != Val_int (0)) { - const char *name, *desc; + const char *name, *desc = NULL; v = Field (rv, 0); /* export struct */ name = String_val (Field (v, 0)); - desc = String_val (Field (v, 1)); + if (Is_block (Field (v, 1))) + desc = String_val (Field (Field (v, 1), 0)); if (nbdkit_add_export (exports, name, desc) == -1) { caml_enter_blocking_section (); CAMLreturnT (int, -1); -- Eric Blake, Principa...
2014 Aug 26
3
Segmentation fault when trying to add binding
....a917c24 100644 --- a/v2v/xml-c.c +++ b/v2v/xml-c.c @@ -141,6 +141,16 @@ v2v_xml_xpath_new_context (value docv) } value +v2v_xml_xpath_register_ns (value prefix, value uri, value xpathctx) +{ + CAMLparam3 (prefix, uri, xpathctx); + CAMLlocal1 (retval); + retval = xmlXPathRegisterNs (BAD_CAST String_val (prefix), BAD_CAST String_val (uri), xpathctx); + + CAMLreturn (retval); +} + +value v2v_xml_xpath_eval_expression (value xpathctxv, value exprv) { CAMLparam2 (xpathctxv, exprv); diff --git a/v2v/xml.ml b/v2v/xml.ml index 78cb022..2e4d222 100644 --- a/v2v/xml.ml +++ b/v2v/xml.ml @@ -31,6 +31,...
2017 Jul 31
0
[PATCH v11 02/10] daemon: Embed the ocaml-augeas library in the daemon.
...l(rv) = t; + + CAMLreturn (rv); +} + +#pragma GCC diagnostic ignored "-Wmissing-prototypes" + +/* val create : string -> string option -> flag list -> t */ +CAMLprim value +ocaml_augeas_create (value rootv, value loadpathv, value flagsv) +{ + CAMLparam1 (rootv); + char *root = String_val (rootv); + char *loadpath; + int flags = 0, i; + augeas_t t; + + /* Optional loadpath. */ + loadpath = + loadpathv == Val_int (0) + ? NULL + : String_val (Field (loadpathv, 0)); + + /* Convert list of flags to C. */ + for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) { +...
2014 Apr 22
3
[PATCH 1/2] builder: add an optional suffix string for INI parsing errors
...filenamev) +virt_builder_parse_index (value progv, value error_suffixv, value filenamev) { CAMLparam2 (progv, filenamev); CAMLlocal5 (rv, v, sv, sv2, fv); @@ -58,6 +58,7 @@ virt_builder_parse_index (value progv, value filenamev) parse_context_init (&context); context.program_name = String_val (progv); context.input_file = String_val (filenamev); + context.error_suffix = String_val (error_suffixv); in = fopen (String_val (filenamev), "r"); if (in == NULL) diff --git a/builder/index-struct.h b/builder/index-struct.h index 3edd06d..150535d 100644 --- a/builder/index-s...
2010 Jun 28
8
[PATCH] add xl ocaml bindings
...+ int i; + char **array; + + for (i = 0, a = Field(v, 5); a != Val_emptylist; a = Field(a, 1)) { i++; } + + array = calloc((i + 1) * 2, sizeof(char *)); + if (!array) + return 1; + for (i = 0, a = Field(v, 5); a != Val_emptylist; a = Field(a, 1), i++) { + value b = Field(a, 0); + array[i * 2] = String_val(Field(b, 0)); + array[i * 2 + 1] = String_val(Field(b, 1)); + } + *c_val = array; + CAMLreturn(0); +} + +static int domain_create_info_val (libxl_domain_create_info *c_val, value v) +{ + CAMLparam1(v); + CAMLlocal1(a); + int i; + + c_val->hvm = Bool_val(Field(v, 0)); + c_val->hap = Bool_val(...
2020 Sep 01
0
Re: [nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...mpare it with Val_int(0), ie: value v = /* something which has type ‘string option’ */; if (v == Val_int(0)) /* It's None */ printf ("None\n"); else { /* It's Some string, set sv to the string value */ value sv = Field (v, 0); printf ("Some %s\n", String_val (sv)); } The weird casting macros have the form: To_from() Also that String_val is only valid for a short period of time, basically until the next OCaml allocation in the current thread. > +++ w/plugins/ocaml/ocaml.c > @@ -332,11 +332,12 @@ list_exports_wrapper (int readonly, int > is...
2017 Aug 09
0
[PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.
...l(rv) = t; + + CAMLreturn (rv); +} + +#pragma GCC diagnostic ignored "-Wmissing-prototypes" + +/* val create : string -> string option -> flag list -> t */ +CAMLprim value +ocaml_augeas_create (value rootv, value loadpathv, value flagsv) +{ + CAMLparam1 (rootv); + char *root = String_val (rootv); + char *loadpath; + int flags = 0, i; + augeas_t t; + + /* Optional loadpath. */ + loadpath = + loadpathv == Val_int (0) + ? NULL + : String_val (Field (loadpathv, 0)); + + /* Convert list of flags to C. */ + for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) { +...
2018 Jan 29
1
[PATCH] customize: Correctly handle crypt(3) returning NULL.
...aml/alloc.h> #include <caml/memory.h> #include <caml/mlvalues.h> +#include <caml/unixsupport.h> #pragma GCC diagnostic ignored "-Wmissing-prototypes" @@ -44,6 +46,8 @@ virt_customize_crypt (value keyv, value saltv) * is not thread safe. */ r = crypt (String_val (keyv), String_val (saltv)); + if (r == NULL) + unix_error (errno, (char *) "crypt", Nothing); rv = caml_copy_string (r); CAMLreturn (rv); -- 2.13.2
2015 Oct 13
6
[PATCH 0/4] rpm: Choose providers better (RHBZ#1266918).
Fix for https://bugzilla.redhat.com/show_bug.cgi?id=1266918
2020 Sep 01
1
Re: [nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...= /* something which has type ‘string option’ */; > > if (v == Val_int(0)) /* It's None */ > printf ("None\n"); > else { > /* It's Some string, set sv to the string value */ > value sv = Field (v, 0); > printf ("Some %s\n", String_val (sv)); > } > > The weird casting macros have the form: To_from() > > Also that String_val is only valid for a short period of time, > basically until the next OCaml allocation in the current thread. That's helpful, as well. > >> +++ w/plugins/ocaml/ocaml.c &gt...
2016 Feb 05
7
[PATCH 0/7] lib: Stop exporting the safe_malloc, etc. functions.
The safe_malloc (etc) functions call g->abort_fn on failure. That's not appropriate for language bindings, and we never intended that these internal functions be used from language bindings, that was just a historical accident. This patch series removes any external use of the safe_* functions. Rich.
2014 Jul 30
2
[PATCH 1/3] ext2: create a struct for the OCaml 't' type
...= *data; CAMLreturn (fsv); } @@ -122,18 +127,18 @@ supermin_ext2fs_open (value filev) CAMLlocal1 (fsv); int fs_flags = EXT2_FLAG_RW; errcode_t err; - ext2_filsys fs; + struct ext2_data data; #ifdef EXT2_FLAG_64BITS fs_flags |= EXT2_FLAG_64BITS; #endif err = ext2fs_open (String_val (filev), fs_flags, 0, 0, - unix_io_manager, &fs); + unix_io_manager, &data.fs); if (err != 0) ext2_error_to_exception ("ext2fs_open", err, String_val (filev)); - fsv = Val_ext2fs (fs); + fsv = Val_ext2fs (&data); CAMLretur...
2014 Mar 19
7
[PATCH 1/3] builder: make the C index parser reentrant
...ontext *context, FILE *in); value virt_builder_parse_index (value filenamev) @@ -52,26 +52,30 @@ virt_builder_parse_index (value filenamev) CAMLlocal5 (rv, v, sv, sv2, fv); struct section *sections; size_t i, nr_sections; + struct parse_context context; + FILE *in; - yyin = fopen (String_val (filenamev), "r"); - if (yyin == NULL) + parse_context_init (&context); + + in = fopen (String_val (filenamev), "r"); + if (in == NULL) unix_error (errno, (char *) "fopen", filenamev); - if (yyparse () != 0) { - fclose (yyin); + if (do_parse (&c...
2010 Jan 07
1
Segfault in GetNewPage, memory.c.
...l_string calls > external parse_sexp : string -> sexp = "parse_sexp" which access the C glue code wrapping R_ParseVector. > CAMLprim value parse_sexp (value s) { > CAMLparam1(s); > SEXP text ; > SEXP pr ; > ParseStatus status; > PROTECT(text = mkString(String_val(s))); > PROTECT(pr=R_ParseVector(text, 1, &status, R_NilValue)); > UNPROTECT(2); > switch (status) { > case PARSE_OK: > break; > case PARSE_INCOMPLETE: > case PARSE_EOF: > caml_raise_with_string(*caml_named_value("Parse_incomplete")...
2016 Apr 14
1
Re: [PATCH v2] customize/perl_edit-c.c: Don't use internal APIs.
...e/perl_edit-c.c @@ -37,7 +37,7 @@ virt_customize_edit_file_perl (value verbosev, value gv, value gpv, { CAMLparam5 (verbosev, gv, gpv, filev, exprv); int r; - guestfs_h *g = (guestfs_h *) Int64_val (gpv); + guestfs_h *g = (guestfs_h *) (intptr_t) Int64_val (gpv); r = edit_file_perl (g, String_val (filev), String_val (exprv), NULL, Bool_val (verbosev)); Thanks, -- Pino Toscano
2016 Apr 12
3
[PATCH v2] customize/perl_edit-c.c: Don't use internal APIs.
In v1 of this patch, there was the (small) possibility that 'g' might have been garbage collected while we were in the C function. Avoid this by passing 'g' to the function as well as the C pointer, so that 'g' is pinned as a garbage collector root [by CAMLparam5] so it cannot be collected while we're in the function. Rich.
2019 May 30
5
[PATCH 0/5] RFC: switch augeas APIs to OCaml
This synchronizes the embedded ocaml-augeas copy, and reimplements the augeas APIs using it (dropping all the C code). The behaviour seems unchanged, although I may have not tested all the various corner cases. Pino Toscano (5): common/mlaugeas: Synchronize with latest ocaml-augeas daemon: fix/enhance error reporting of Augeas exceptions Revert "Revert "daemon: implement
2017 Jul 21
0
[PATCH v2 01/23] daemon: Allow parts of the daemon and APIs to be written in OCaml.
...ives/caml-list/2006/05/097f63cfb39a80418f95c70c3c520aa8.en.html + * http://caml.inria.fr/pub/ml-archives/caml-list/2009/06/797e2f797f57b8ea2a2c0e431a2df312.en.html + */ + if (Tag_val (Field (exn, 0)) == String_tag) + /* For End_of_file and a few other constant exceptions. */ + exn_name = String_val (Field (exn, 0)); + else + /* For most exceptions. */ + exn_name = String_val (Field (Field (exn, 0), 0)); + + if (verbose) + fprintf (stderr, "ocaml_exn: '%s' raised '%s' exception\n", + func, exn_name); + + if (STREQ (exn_name, "Unix.Unix_err...
2020 Sep 01
0
[nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + /* Convert exports list into calls to nbdkit_add_export. */ + while (rv != Val_int (0)) { + const char *name, *desc; + + v = Field (rv, 0); /* export struct */ + name = String_val (Field (v, 0)); + desc = String_val (Field (v, 1)); + if (nbdkit_add_export (exports, name, desc) == -1) { + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + rv = Field (rv, 1); + } + + caml_enter_blocking_section (); + CAMLreturnT (int, 0); +} + +static con...
2020 Sep 21
0
[nbdkit PATCH v3 14/14] ocaml: Implement .list_exports and friends
...(Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + /* Convert exports list into calls to nbdkit_add_export. */ + while (rv != Val_emptylist) { + const char *name, *desc = NULL; + + v = Field (rv, 0); /* export struct */ + name = String_val (Field (v, 0)); + if (Is_block (Field (v, 1))) + desc = String_val (Field (Field (v, 1), 0)); + if (nbdkit_add_export (exports, name, desc) == -1) { + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + rv = Field (rv, 1); + } + + caml_enter_blocking_sectio...