From e7d900d9b731fec4b3828012c7a298ec494f88d2 Mon Sep 17 00:00:00 2001 From: Sergey Popov Date: Mon, 19 Dec 2011 11:08:19 +0400 Subject: [PATCH] some code exports reorganization and cleanups --- yasnd-gammu.c | 6 ++++++ yasnd-ipc.c | 1 + yasnd.c | 5 +---- yasnd.h | 9 +++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/yasnd-gammu.c b/yasnd-gammu.c index f2dce8b..149876e 100644 --- a/yasnd-gammu.c +++ b/yasnd-gammu.c @@ -1,3 +1,4 @@ +#include #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) { diff --git a/yasnd-ipc.c b/yasnd-ipc.c index 9571359..afbc291 100644 --- a/yasnd-ipc.c +++ b/yasnd-ipc.c @@ -4,6 +4,7 @@ #include "yasnd.h" pid_t ipc_clone_pid; +int qid=-1; // IPC queue id int open_queue() { diff --git a/yasnd.c b/yasnd.c index 964459f..016fcfb 100644 --- a/yasnd.c +++ b/yasnd.c @@ -1,7 +1,5 @@ #include #include -#include -#include #include #include #include @@ -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); diff --git a/yasnd.h b/yasnd.h index 0010412..d0b7185 100644 --- a/yasnd.h +++ b/yasnd.h @@ -5,12 +5,13 @@ #define DEBUG_BASE 1 #define DEBUG_ALL 2 +#include +#include #include #include #include #include #include -#include #define _GNU_SOURCE #include @@ -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