File: dynlib-test.c

package info (click to toggle)
mmlib 1.4.2-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,716 kB
  • sloc: ansic: 18,071; makefile: 431; sh: 135; python: 63
file content (58 lines) | stat: -rw-r--r-- 895 bytes parent folder | download
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
/*
   @mindmaze_header@
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif

#include "dynlib-api.h"

#include <string.h>

#define DYNLIB_DATA_INITIALIZER	{.intval = INITIAL_INTVAL, .str = INITIAL_STR}

static int internal_code;

API_EXPORTED_RELOCATABLE
struct dynlib_data libdata = DYNLIB_DATA_INITIALIZER;



static
void dynlib_set_data(int ival, const char* str)
{
	libdata.intval = ival;
	strncpy(libdata.str, str, sizeof(libdata.str)-1);
}


static
void dynlib_reset_data(void)
{
	libdata = (struct dynlib_data)DYNLIB_DATA_INITIALIZER;
}


static
int dynlib_read_internal_code(void)
{
	return internal_code;
}


static
void dynlib_set_internal_code(int val)
{
	internal_code = val;
}


API_EXPORTED
struct dynlib_vtab api = {
	.set_data = dynlib_set_data,
	.reset_data = dynlib_reset_data,
	.read_internal_code = dynlib_read_internal_code,
	.set_internal_code = dynlib_set_internal_code,
};