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;
}
|