File: example-debug-flag.c

package info (click to toggle)
nbdkit 1.46.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,504 kB
  • sloc: ansic: 63,658; sh: 18,717; makefile: 6,814; python: 1,848; cpp: 1,143; perl: 504; ml: 504; tcl: 62
file content (25 lines) | stat: -rw-r--r-- 682 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Example OCaml plugin.

   This example can be freely copied and used for any purpose.

   This shows how to use debug flags with OCaml plugins.  For
   a description of debug flags see "Debug Flags" in nbdkit-plugin(3). */

#include <caml/mlvalues.h>
#define NBDKIT_API_VERSION 2
#include "nbdkit-plugin.h"

/* This is the debug flag.
 *
 * The debug flag is set by nbdkit when you use '-D ocamlexample.foo=<N>'.
 */
NBDKIT_DLL_PUBLIC int ocamlexample_debug_foo = 0;

/* To fetch the value of the debug flag from OCaml code we call this.
 * NB: noalloc function.
 */
NBDKIT_DLL_PUBLIC value
get_ocamlexample_debug_foo (value unitv)
{
  return Val_int (ocamlexample_debug_foo);
}