File: statemachine-init.c

package info (click to toggle)
gammu 1.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 21,972 kB
  • ctags: 8,504
  • sloc: ansic: 104,965; pascal: 7,209; cpp: 4,023; python: 3,639; php: 1,622; sh: 1,534; sql: 450; cs: 260; makefile: 192; perl: 107; asm: 31
file content (81 lines) | stat: -rw-r--r-- 2,219 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <gammu.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "common.h"

#ifdef WIN32
# define NUL "NUL"
#else
# define NUL "/dev/null"
#endif

GSM_StateMachine *s;

void single_check(const char *device, const char *connection, const char *model, GSM_Error expected)
{
	GSM_Config *smcfg;
	GSM_Error error;
	GSM_Debug_Info *debug_info;

	/* Allocates state machine */
	s = GSM_AllocStateMachine();
	test_result(s != NULL);

	debug_info = GSM_GetDebug(s);
	GSM_SetDebugGlobal(TRUE, debug_info);

	smcfg = GSM_GetConfig(s, 0);
	strcpy(smcfg->Model, model);
	smcfg->Device = strdup(device);
	smcfg->UseGlobalDebugFile = TRUE;
	smcfg->Connection = strdup(connection);
	smcfg->PhoneFeatures[0] = F_PBK_ENCODENUMBER;
	smcfg->PhoneFeatures[1] = 0;
	GSM_SetConfigNum(s, 1);

	error = GSM_InitConnection(s, 3);
	test_result(error == expected);

	/* Free state machine */
	GSM_FreeStateMachine(s);
}

int main(int argc UNUSED, char **argv UNUSED)
{
	GSM_Debug_Info *debug_info;

	debug_info = GSM_GetGlobalDebug();
	GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
	GSM_SetDebugLevel("textall", debug_info);

	single_check("/NONEXISTING/DEVICE/NODE", "NONSENSE", "", ERR_UNKNOWNCONNECTIONTYPESTRING);
#ifdef GSM_ENABLE_AT
	single_check("/NONEXISTING/DEVICE/NODE", "at", "", ERR_DEVICENOTEXIST);
	single_check("/NONEXISTING/DEVICE/NODE", "at-nodtr", "", ERR_DEVICENOTEXIST);
	single_check("/NONEXISTING/DEVICE/NODE", "at19200-nopower", "", ERR_DEVICENOTEXIST);
	single_check("/NONEXISTING/DEVICE/NODE", "at", "at", ERR_DEVICENOTEXIST);
	single_check("/NONEXISTING/DEVICE/NODE", "at", "atobex", ERR_DEVICENOTEXIST);
	single_check(NUL, "at", "", ERR_DEVICEREADERROR);
	single_check(NUL, "at ", "", ERR_DEVICEREADERROR);
#endif
#ifdef GSM_ENABLE_FBUS2DLR3
	single_check("/NONEXISTING/DEVICE/NODE", "dlr3", "", ERR_DEVICENOTEXIST);
#ifndef WIN32
	single_check("/dev/null ", "dlr3", "", ERR_DEVICEREADERROR);
#endif
#endif
#ifdef GSM_ENABLE_DKU5FBUS2
	single_check("/NONEXISTING/DEVICE/NODE", "dku5", "", ERR_DEVICENOTEXIST);
#ifndef WIN32
	single_check("/dev/null ", "dku5", "", ERR_DEVICEREADERROR);
#endif
#endif

	return 0;
}

/* Editor configuration
 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72:
 */