Add -lncurses to LDD flags
[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 //printf("comparing: '%s' with '%s'\n", name, join->j_name);
32                 if (join->j_serial == join_id)
33                         return(join);
34                 join = join->next;
35         }
36
37         return(NULL);
38 }
39
40
41 /*
42  * constructor for a new join 
43  */
44 Join::Join(void)
45 {
46         class Join **joinp;
47
48         j_serial = join_serial++;
49         j_type = JOIN_TYPE_NONE;
50
51         /* attach to chain */
52         next = NULL;
53         joinp = &join_first;
54         while(*joinp)
55                 joinp = &((*joinp)->next);
56         *joinp = this;
57
58         classuse++;
59 }
60
61
62 /*
63  * join descructor
64  */
65 Join::~Join()
66 {
67         class Join *cl, **clp;
68
69         classuse--;
70
71         cl = join_first;
72         clp = &join_first;
73         while(cl) {
74                 if (cl == this)
75                         break;
76                 clp = &cl->next;
77                 cl = cl->next;
78         }
79         if (!cl)
80                 FATAL("software error, join not in chain!\n");
81         *clp = cl->next; /* detach from chain */
82 }
83
84
85
86 /* epoint sends a message to a join
87  *
88  */
89 void Join::message_epoint(unsigned int epoint_id, int message_type, union parameter *param)
90 {
91 }
92
93
94 /* free all join structures */
95 void join_free(void)
96 {
97
98         if (!join_first) {
99                 PDEBUG(DEBUG_JOIN, "no more pending join(s), done!\n");
100                 return;
101         }
102         while(join_first) {
103                 if (options.deb & DEBUG_JOIN) {
104                         PDEBUG(DEBUG_JOIN, "freeing pending join\n");
105                 }
106
107                 delete join_first;
108         }
109 }
110
111
112