summaryrefslogtreecommitdiff
path: root/ext/-test-/bug_reporter/bug_reporter.c
blob: 1ca9d02bc441d53475d9d2c7d7ee327cea58c16a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <ruby.h>
#include <stdio.h>

int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);

static void
sample_bug_reporter(FILE *out, void *ptr)
{
    int n = (int)ptr;
    fprintf(out, "Sample bug reporter: %d\n", n);
}

static VALUE
register_sample_bug_reporter(VALUE self, VALUE obj)
{
    rb_bug_reporter_add(sample_bug_reporter, (void *)NUM2INT(obj));
    return Qnil;
}

void
Init_bug_reporter(void)
{
    rb_define_global_function("register_sample_bug_reporter", register_sample_bug_reporter, 1);
}