File indexing completed on 2024-04-14 03:40:18

0001 /*
0002     SPDX-FileCopyrightText: 2004 Thomas Nagy <tnagy2^8@yahoo.fr>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include <stdio.h>
0008 #include <string.h>
0009 
0010 #include <caml/alloc.h>
0011 #include <caml/callback.h>
0012 #include <caml/mlvalues.h>
0013 
0014 char *solve_equation(const char *eq)
0015 {
0016     static value *solve_equation_closure = NULL;
0017     if (solve_equation_closure == NULL) {
0018         solve_equation_closure = caml_named_value("solve_equation");
0019     }
0020 
0021     value v = caml_copy_string(eq);
0022     return strdup(String_val(caml_callback(*solve_equation_closure, v)));
0023 }