gsm improvements
[lcr.git] / join.cpp
1 /*****************************************************************************\
2 **                                                                           **
3 ** PBX4Linux                                                                 **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** join functions                                                            **
9 **                                                                           **
10 \*****************************************************************************/ 
11
12 #include "main.h"
13 //#define __u8 unsigned char
14 //#define __u16 unsigned short
15 //#define __u32 unsigned int
16
17 unsigned int join_serial = 1; /* must be 1, because 0== no join */
18
19 //JOIN_STATES
20
21 class Join *join_first = NULL;
22
23 /*
24  * find the join with join_id
25  */ 
26 class Join *find_join_id(unsigned int join_id)
27 {
28         class Join *join = join_first;
29
30         while(join)
31         {
32 //printf("comparing: '%s' with '%s'\n", name, join->j_name);
33                 if (join->j_serial == join_id)
34                         return(join);
35                 join = join->next;
36         }
37
38         return(NULL);
39 }
40
41
42 /*
43  * constructor for a new join 
44  */
45 Join::Join(void)
46 {
47         class Join **joinp;
48
49         j_serial = join_serial++;
50         j_type = JOIN_TYPE_NONE;
51
52         /* attach to chain */
53         next = NULL;
54         joinp = &join_first;
55         while(*joinp)
56                 joinp = &((*joinp)->next);
57         *joinp = this;
58
59         classuse++;
60 }
61
62
63 /*
64  * join descructor
65  */
66 Join::~Join()
67 {
68         class Join *cl, **clp;
69
70         classuse--;
71
72         cl = join_first;
73         clp = &join_first;
74         while(cl)
75         {
76                 if (cl == this)
77                         break;
78                 clp = &cl->next;
79                 cl = cl->next;
80         }
81         if (!cl)
82                 FATAL("software error, join not in chain!\n");
83         *clp = cl->next; /* detach from chain */
84 }
85
86
87
88 /* epoint sends a message to a join
89  *
90  */
91 void Join::message_epoint(unsigned int epoint_id, int message_type, union parameter *param)
92 {
93 }
94
95
96 /* join process is called from the main loop
97  * it processes the current calling state.
98  * returns 0 if nothing was done
99  */
100 int Join::handler(void)
101 {
102         return(0);
103 }
104
105 /* free all join structures */
106 void join_free(void)
107 {
108
109         if (!join_first)
110         {
111                 PDEBUG(DEBUG_JOIN, "no more pending join(s), done!\n");
112                 return;
113         }
114         while(join_first)
115         {
116                 if (options.deb & DEBUG_JOIN)
117                 {
118                         PDEBUG(DEBUG_JOIN, "freeing pending join\n");
119                 }
120
121                 delete join_first;
122         }
123 }
124
125
126