File: example-debug-flag.c

package info (click to toggle)
nbdkit 1.42.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,696 kB
  • sloc: ansic: 59,224; sh: 16,793; makefile: 6,463; python: 1,837; cpp: 1,116; ml: 504; perl: 502; 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);
}