Free conditions

This commit is contained in:
dcp1990 2005-06-12 18:51:06 +00:00
parent fc1f25abf7
commit 7395fd9f23
3 changed files with 40 additions and 3 deletions

View file

@ -3,7 +3,7 @@
* (C)2005, Dan Ponte * (C)2005, Dan Ponte
* BSDL w/ advert. * BSDL w/ advert.
*/ */
/* $Amigan: phoned/include/phoned.h,v 1.5 2005/06/12 16:30:53 dcp1990 Exp $ */ /* $Amigan: phoned/include/phoned.h,v 1.6 2005/06/12 18:51:06 dcp1990 Exp $ */
#include <pcre.h> /* fugly, I know... */ #include <pcre.h> /* fugly, I know... */
#define VERSION "0.1" #define VERSION "0.1"
#define LOGFILE "/var/log/phoned.log" #define LOGFILE "/var/log/phoned.log"
@ -66,6 +66,13 @@ typedef struct c_t {
#define CTACT_ANS 0x10 #define CTACT_ANS 0x10
#define CTACT_PLAY 0x20 #define CTACT_PLAY 0x20
#define CTACT_REC 0x40 #define CTACT_REC 0x40
#define SCTACT_IGN "\1"
#define SCTACT_HUP "\2"
#define SCTACT_RNOT "\3"
#define SCTACT_ANS "\4"
#define SCTACT_PLAY "\5"
#define SCTACT_REC "\6"
struct af { struct af {
char* not_email; char* not_email;
char* play_file; char* play_file;
@ -118,3 +125,4 @@ void addtoaddrs(const char* par);
void modem_hread(char* cbuf); void modem_hread(char* cbuf);
void cid_log(cid_t* c); void cid_log(cid_t* c);
cond_t* add_condition(char* filtname, char* nameregex, char* numregex, int action); cond_t* add_condition(char* filtname, char* nameregex, char* numregex, int action);
void free_condition(cond_t* h, short traverse);

View file

@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
/* $Amigan: phoned/phoned/filters.c,v 1.4 2005/06/12 18:35:44 dcp1990 Exp $ */ /* $Amigan: phoned/phoned/filters.c,v 1.5 2005/06/12 18:51:07 dcp1990 Exp $ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -37,8 +37,35 @@
cond_t* topcond = 0x0; cond_t* topcond = 0x0;
pthread_mutex_t condmx = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t condmx = PTHREAD_MUTEX_INITIALIZER;
void free_cond_elms(cond)
cond_t* cond;
{
free(cond->name);
free(cond->number);
free(cond->filtname);
free(cond->namex.prex);
}
void free_condition(h, traverse)
cond_t* h;
short traverse;
{
cond_t *ls, *c, *tp;
tp = h;
if(tp == 0x0) return;
if(traverse) {
c = tp;
while(c > 0x0) {
free_cond_elms(c);
ls = c;
c = c->next;
free(ls);
}
} else {
free_cond_elms(tp);
free(tp);
}
}
/* BROKEN! Do not use! */
cond_t* add_condition(filtname, nameregex, numregex, action) cond_t* add_condition(filtname, nameregex, numregex, action)
char* filtname; char* filtname;
char* nameregex; char* nameregex;

View file

@ -13,12 +13,14 @@
extern FILE* logf; extern FILE* logf;
extern short difflog; extern short difflog;
extern struct conf cf; extern struct conf cf;
extern cond_t* topcond;
void shutd(void) void shutd(void)
{ {
lprintf(fatal, "phoned shutting down...\n"); lprintf(fatal, "phoned shutting down...\n");
close_modem(cf.modemdev); close_modem(cf.modemdev);
flush_lists(); flush_lists();
free_condition(topcond, 0x1);
fclose(logf); fclose(logf);
unlink(SOCKETFILE); unlink(SOCKETFILE);
} }