some code exports reorganization and cleanups

This commit is contained in:
Sergey Popov 2011-12-19 11:08:19 +04:00
parent 989ca201e4
commit e7d900d9b7
4 changed files with 11 additions and 10 deletions

View File

@ -1,3 +1,4 @@
#include <gammu.h>
#include "yasnd.h"
GSM_Error error; // structure to store possible gammu errors
@ -34,6 +35,11 @@ bool gammu_init()
return true;
}
void gammu_free()
{
GSM_FreeStateMachine(state_machine);
}
/* Handler for SMS send reply */
void send_sms_callback (GSM_StateMachine *sm, int status, int MessageReference, void * user_data)
{

View File

@ -4,6 +4,7 @@
#include "yasnd.h"
pid_t ipc_clone_pid;
int qid=-1; // IPC queue id
int open_queue()
{

View File

@ -1,7 +1,5 @@
#include <sys/stat.h>
#include <sys/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
@ -13,7 +11,6 @@
cfg_t *cfg; // pointer to configuration structure
host_decl* hosts=NULL; // structure with hosts' definitions
int hosts_count=0; // count of hosts
int qid=-1; // IPC queue id
int debug_flag=0;
bool sms_send_enable=false; // send or not send alerts via SMS
char* phone_device=NULL; // phone device for gammu, for example: "/dev/ttyACM0"
@ -236,7 +233,7 @@ void signal_handler(int signum)
// free config structure
cfg_free(cfg);
// free gammu structure
GSM_FreeStateMachine(state_machine);
gammu_free();
// free hosts structures memory
if (hosts!=NULL)
free(hosts);

View File

@ -5,12 +5,13 @@
#define DEBUG_BASE 1
#define DEBUG_ALL 2
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdbool.h>
#include <string.h>
#include <gammu.h>
#define _GNU_SOURCE
#include <sched.h>
@ -32,23 +33,19 @@ typedef struct {
extern void log_event(const char *message);
extern void log_debug(const char *message,int verbosity);
extern void* allocate_memory(int bytes);
extern bool check_gammu_error(GSM_Error err);
extern bool gammu_init();
extern bool gammu_send_sms(const char* message);
extern void ipc_init();
extern void ipc_free();
extern int send_message(int qid, mymsgbuf* qbuf);
extern void gammu_free();
// External variables
extern int hosts_count; // count of hosts
extern int debug_flag;
extern GSM_Error error; // structure to store possible gammu errors
extern GSM_StateMachine *state_machine; // structure to interact with mobile phones
extern char* recipient_number;
extern char* phone_device; // phone device for gammu, for example: "/dev/ttyACM0"
extern char* phone_model; // gammu phone model, for example: "at"
extern char* phone_connection; // gammu phone connection type, for example: "at"
extern int qid;
extern pid_t ipc_clone_pid;
#endif