aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/ddll_SUITE_data/echo_drv_fail_init.c
blob: 3b2a44d9071e55dcef1ef26e566594e408f2afe8 (plain) (blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include "erl_driver.h"

static ErlDrvPort erlang_port;
static ErlDrvData echo_start(ErlDrvPort, char *);
static void from_erlang(ErlDrvData, char*, int);
static int echo_call(ErlDrvData drv_data, unsigned int command, char *buf, 
		     int len, char **rbuf, int rlen, unsigned *ret_flags);
static int echo_failing_init(void);

static ErlDrvEntry echo_driver_entry = { 
    echo_failing_init,
    echo_start,
    NULL,			/* Stop */
    from_erlang,
    NULL,			/* Ready input */
    NULL,			/* Ready output */
    "echo_drv",
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    echo_call
};

DRIVER_INIT(echo_drv)
{
    return &echo_driver_entry;
}

static int echo_failing_init(void)
{
    return -1;
}

static ErlDrvData
echo_start(ErlDrvPort port, char *buf)
{
    return (ErlDrvData) port;
}

static void
from_erlang(ErlDrvData data, char *buf, int count)
{
    driver_output((ErlDrvPort) data, buf, count);
}

static int 
echo_call(ErlDrvData drv_data, unsigned int command, char *buf, 
	  int len, char **rbuf, int rlen, unsigned *ret_flags) 
{
    *rbuf = buf;
    *ret_flags |= DRIVER_CALL_KEEP_BUFFER;
    return len;
}