File: smsd.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 (46 lines) | stat: -rw-r--r-- 1,171 bytes parent folder | download | duplicates (8)
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
/* Simple C program to start SMSD without all magic normal gammu-smsd does */
#include <gammu-smsd.h>
#include <assert.h>

int main(int argc UNUSED, char **argv UNUSED)
{
	GSM_SMSDConfig *config;
    GSM_Error error;
    char *config_file = NULL; /* Use default compiled in path */

	/*
	 * We don't need gettext, but need to set locales so that
	 * charset conversion works.
	 */
	GSM_InitLocales(NULL);

    /* Initalize configuration with program name */
	config = SMSD_NewConfig("smsd-example");
	assert(config != NULL);

    /* Read configuration file */
	error = SMSD_ReadConfig(config_file, config, TRUE);
	if (error != ERR_NONE) {
		printf("Failed to read config!\n");
		SMSD_FreeConfig(config);
		return 2;
	}

    /* Start main SMSD loop which processes messages */
    /*
     * This normally never terminates, you need to signal it
     * by SMSD_Shutdown(config); (for example from signal handler)
     * to make it stop.
     */
	error = SMSD_MainLoop(config, FALSE, 0);
	if (error != ERR_NONE) {
		printf("Failed to run SMSD!\n");
		SMSD_FreeConfig(config);
		return 2;
	}

    /* Free configuration structure */
	SMSD_FreeConfig(config);

    return 0;
}