Browse code

modules_k/*: moved k modules in directory modules/

Daniel-Constantin Mierla authored on 20/01/2013 11:57:52
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,183 +0,0 @@
1
-/* $Id$
2
- *
3
- * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4
- *
5
- * This file is part of Kamailio, a free SIP server.
6
- *
7
- * Kamailio is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version
11
- *
12
- * Kamailio is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License 
18
- * along with this program; if not, write to the Free Software 
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
- */
21
-
22
-
23
-#include <string.h>
24
-
25
-#include "cluster.h"
26
-#include "seas.h"
27
-#include "../../dprint.h"
28
-#include "../../mem/mem.h"
29
-
30
-char *cluster_cfg;
31
-
32
-#define eat_spaces(_p) \
33
-	while( *(_p)==' ' || *(_p)=='\t' ){\
34
-	(_p)++;}
35
-
36
-
37
-/**
38
- * Parses the PING configuration string. Its format is 
39
- * "ping_period:pings_lost:ping_timeout"
40
- * ping_period : time between pings
41
- * pings_lost: number of lost pings before failure
42
- * ping_timeout: time to consider a ping failed
43
- *
44
- * returns 
45
- * 0 if no clusters present
46
- * -1 if config is malformed (unable to parse);
47
- *  1 if config is successfully set
48
- */
49
-int parse_cluster_cfg(void)
50
-{
51
-   char *p,*start;
52
-   int n,k;
53
-   struct as_entry **entry,*tmp,*tmp2;
54
-
55
-   if((p=cluster_cfg)==0 || *cluster_cfg==0){
56
-      return 0;
57
-   }
58
-   entry=&as_list;
59
-
60
-   while (*p)
61
-   {
62
-      eat_spaces(p);
63
-      /*get cluster name*/
64
-      start = p;
65
-      while (*p!=' ' && *p!='\t' && *p!='[' && *p!=0)
66
-	 p++;
67
-      if ( p==start || *p==0 ){
68
-	 LM_ERR("cluster names must only contain alphanumeric chars\n");
69
-	 goto error;
70
-      }
71
-      if (!((*entry)=(struct as_entry*)shm_malloc(sizeof(struct as_entry)))) {
72
-	 LM_ERR("Out of shm mem for as_entry\n");
73
-	 goto error;
74
-      }
75
-      memset(*entry,0,sizeof(struct as_entry));
76
-      if (!((*entry)->name.s=shm_malloc(p-start))) {
77
-	 LM_ERR("Out of shm malloc for cluster name\n");
78
-	 goto error;
79
-      }
80
-      memcpy((*entry)->name.s, start, p-start);
81
-      (*entry)->name.len=p-start;
82
-      (*entry)->connected=0;
83
-      (*entry)->type=CLUSTER_TYPE;
84
-      (*entry)->u.cs.name=(*entry)->name;
85
-      /*get as names*/
86
-      eat_spaces(p);
87
-      if (*p!='['){
88
-	 LM_ERR("Malformed cluster cfg string %s\n",cluster_cfg);
89
-	 goto error;
90
-      }
91
-      p++;
92
-      n=0;
93
-      while (*p!=']')
94
-      {
95
-	 eat_spaces(p);
96
-	 start = p;
97
-	 while(*p!=' ' && *p!='\t' && *p!=']' && *p!=',' && *p!=0)
98
-	    p++;
99
-	 if ( p==start || *p==0 )
100
-	    goto error;
101
-	 if (!((*entry)->u.cs.as_names[n].s=shm_malloc(p-start))) {
102
-	    LM_ERR("Out of shm_mem for AS name in cluster\n");
103
-	    goto error;
104
-	 }
105
-	 (*entry)->u.cs.as_names[n].len=p-start;
106
-	 memcpy((*entry)->u.cs.as_names[n].s,start,p-start);
107
-	 n++;
108
-	 if(n>=MAX_AS_PER_CLUSTER){
109
-	    LM_ERR("too many AS per cluster\n");
110
-	    goto error;
111
-	 }
112
-	 eat_spaces(p);
113
-	 if (*p==',') {
114
-	    p++;
115
-	    eat_spaces(p);
116
-	 }
117
-      }
118
-      p++;
119
-      (*entry)->u.cs.num=n;
120
-      /* end of element */
121
-      eat_spaces(p);
122
-      if (*p==',')
123
-	 p++;
124
-      eat_spaces(p);
125
-      entry=&((*entry)->next);
126
-   }
127
-   for (tmp=as_list;tmp->next;tmp=tmp->next){
128
-      LM_DBG("%.*s\n",tmp->name.len,tmp->name.s);
129
-   }
130
-   LM_DBG("%.*s\n",tmp->name.len,tmp->name.s);
131
-   entry=&(tmp->next);
132
-   for(tmp=as_list;tmp;tmp=tmp->next){
133
-      if (tmp->type!=CLUSTER_TYPE) 
134
-	 continue;
135
-      LM_DBG("cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
136
-      for(k=0;k<tmp->u.cs.num;k++){
137
-	 LM_DBG("\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
138
-	 for (tmp2=as_list;tmp2;tmp2=tmp2->next) {
139
-	    if (tmp2->type== AS_TYPE && tmp->u.cs.as_names[k].len == tmp2->name.len && 
140
-		  !memcmp(tmp->u.cs.as_names[k].s,tmp2->name.s,tmp2->name.len)) {
141
-	       tmp->u.cs.servers[k]=&tmp2->u.as;
142
-	       break;
143
-	    }
144
-	 }
145
-	 if(tmp2)
146
-	    continue;
147
-	 if (!((*entry)=shm_malloc(sizeof(struct as_entry)))) {
148
-	    LM_ERR("Out of shm mem \n");
149
-	    goto error;
150
-	 }
151
-	 memset(*entry,0,sizeof(struct as_entry));
152
-	 (*entry)->type=AS_TYPE;
153
-	 if (!((*entry)->name.s=shm_malloc(tmp->u.cs.as_names[k].len))) {
154
-	    LM_ERR("out of shm mem\n");
155
-	    goto error;
156
-	 }
157
-	 memcpy((*entry)->name.s,tmp->u.cs.as_names[k].s,tmp->u.cs.as_names[k].len);
158
-	 (*entry)->name.len=tmp->u.cs.as_names[k].len;
159
-	 (*entry)->u.as.name=(*entry)->name;
160
-	 tmp->u.cs.servers[k]=&(*entry)->u.as;
161
-	 entry=&((*entry)->next);
162
-      }
163
-   }
164
-   for(tmp=as_list;tmp;tmp=tmp->next){
165
-      LM_DBG("%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
166
-   }
167
-   return 1;
168
-error:
169
-   tmp=as_list;
170
-   while(tmp){
171
-      for(k=0;k<tmp->u.cs.num;k++){
172
-	 if(tmp->u.cs.as_names[k].s)
173
-	    shm_free(tmp->u.cs.as_names[k].s);
174
-      }
175
-      if(tmp->name.s)
176
-	 shm_free(tmp->name.s);
177
-      tmp2=tmp;
178
-      tmp=tmp->next;
179
-      shm_free(tmp2);
180
-   }
181
-   as_list=(struct as_entry *)0;
182
-   return -1;
183
-}
Browse code

- change name in copyright headers

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4518 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 28/07/2008 15:39:28
Showing 1 changed files
... ...
@@ -2,14 +2,14 @@
2 2
  *
3 3
  * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4 4
  *
5
- * This file is part of openser, a free SIP server.
5
+ * This file is part of Kamailio, a free SIP server.
6 6
  *
7
- * openser is free software; you can redistribute it and/or modify
7
+ * Kamailio is free software; you can redistribute it and/or modify
8 8
  * it under the terms of the GNU General Public License as published by
9 9
  * the Free Software Foundation; either version 2 of the License, or
10 10
  * (at your option) any later version
11 11
  *
12
- * openser is distributed in the hope that it will be useful,
12
+ * Kamailio is distributed in the hope that it will be useful,
13 13
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 15
  * GNU General Public License for more details.
Browse code

- changed LOG with LM_*

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2943 689a6050-402a-0410-94f2-e92a70836424

Anca Vamanu authored on 19/10/2007 15:15:01
Showing 1 changed files
... ...
@@ -65,16 +65,16 @@ int parse_cluster_cfg(void)
65 65
       while (*p!=' ' && *p!='\t' && *p!='[' && *p!=0)
66 66
 	 p++;
67 67
       if ( p==start || *p==0 ){
68
-	 LOG(L_ERR,"ERROR: cluster names must only contain alphanumeric chars\n");
68
+	 LM_ERR("cluster names must only contain alphanumeric chars\n");
69 69
 	 goto error;
70 70
       }
71 71
       if (!((*entry)=(struct as_entry*)shm_malloc(sizeof(struct as_entry)))) {
72
-	 LOG(L_ERR,"Out of shm mem for as_entry\n");
72
+	 LM_ERR("Out of shm mem for as_entry\n");
73 73
 	 goto error;
74 74
       }
75 75
       memset(*entry,0,sizeof(struct as_entry));
76 76
       if (!((*entry)->name.s=shm_malloc(p-start))) {
77
-	 LOG(L_ERR,"Out of shm malloc for cluster name\n");
77
+	 LM_ERR("Out of shm malloc for cluster name\n");
78 78
 	 goto error;
79 79
       }
80 80
       memcpy((*entry)->name.s, start, p-start);
... ...
@@ -85,7 +85,7 @@ int parse_cluster_cfg(void)
85 85
       /*get as names*/
86 86
       eat_spaces(p);
87 87
       if (*p!='['){
88
-	 LOG(L_ERR,"Malformed cluster cfg string %s\n",cluster_cfg);
88
+	 LM_ERR("Malformed cluster cfg string %s\n",cluster_cfg);
89 89
 	 goto error;
90 90
       }
91 91
       p++;
... ...
@@ -99,14 +99,14 @@ int parse_cluster_cfg(void)
99 99
 	 if ( p==start || *p==0 )
100 100
 	    goto error;
101 101
 	 if (!((*entry)->u.cs.as_names[n].s=shm_malloc(p-start))) {
102
-	    LOG(L_ERR,"Out of shm_mem for AS name in cluster\n");
102
+	    LM_ERR("Out of shm_mem for AS name in cluster\n");
103 103
 	    goto error;
104 104
 	 }
105 105
 	 (*entry)->u.cs.as_names[n].len=p-start;
106 106
 	 memcpy((*entry)->u.cs.as_names[n].s,start,p-start);
107 107
 	 n++;
108 108
 	 if(n>=MAX_AS_PER_CLUSTER){
109
-	    LOG(L_ERR,"ERROR: too many AS per cluster\n");
109
+	    LM_ERR("too many AS per cluster\n");
110 110
 	    goto error;
111 111
 	 }
112 112
 	 eat_spaces(p);
... ...
@@ -125,16 +125,16 @@ int parse_cluster_cfg(void)
125 125
       entry=&((*entry)->next);
126 126
    }
127 127
    for (tmp=as_list;tmp->next;tmp=tmp->next){
128
-      LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
128
+      LM_DBG("%.*s\n",tmp->name.len,tmp->name.s);
129 129
    }
130
-   LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
130
+   LM_DBG("%.*s\n",tmp->name.len,tmp->name.s);
131 131
    entry=&(tmp->next);
132 132
    for(tmp=as_list;tmp;tmp=tmp->next){
133 133
       if (tmp->type!=CLUSTER_TYPE) 
134 134
 	 continue;
135
-      LOG(L_DBG,"cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
135
+      LM_DBG("cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
136 136
       for(k=0;k<tmp->u.cs.num;k++){
137
-	 LOG(L_DBG,"\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
137
+	 LM_DBG("\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
138 138
 	 for (tmp2=as_list;tmp2;tmp2=tmp2->next) {
139 139
 	    if (tmp2->type== AS_TYPE && tmp->u.cs.as_names[k].len == tmp2->name.len && 
140 140
 		  !memcmp(tmp->u.cs.as_names[k].s,tmp2->name.s,tmp2->name.len)) {
... ...
@@ -145,13 +145,13 @@ int parse_cluster_cfg(void)
145 145
 	 if(tmp2)
146 146
 	    continue;
147 147
 	 if (!((*entry)=shm_malloc(sizeof(struct as_entry)))) {
148
-	    LOG(L_ERR,"ERROR:Out of shm mem \n");
148
+	    LM_ERR("Out of shm mem \n");
149 149
 	    goto error;
150 150
 	 }
151 151
 	 memset(*entry,0,sizeof(struct as_entry));
152 152
 	 (*entry)->type=AS_TYPE;
153 153
 	 if (!((*entry)->name.s=shm_malloc(tmp->u.cs.as_names[k].len))) {
154
-	    LOG(L_ERR,"ERROR:out of shm mem\n");
154
+	    LM_ERR("out of shm mem\n");
155 155
 	    goto error;
156 156
 	 }
157 157
 	 memcpy((*entry)->name.s,tmp->u.cs.as_names[k].s,tmp->u.cs.as_names[k].len);
... ...
@@ -162,7 +162,7 @@ int parse_cluster_cfg(void)
162 162
       }
163 163
    }
164 164
    for(tmp=as_list;tmp;tmp=tmp->next){
165
-      LOG(L_DBG,"%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
165
+      LM_DBG("%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
166 166
    }
167 167
    return 1;
168 168
 error:
Browse code

- add -Wold-style-definition to Makefile.defs, to warn about ancient C syntax - fix old definitions in core and default modules (mostly add missing void) - change really old syntax in md5.c - increase devel version

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2657 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 28/08/2007 15:03:09
Showing 1 changed files
... ...
@@ -46,7 +46,7 @@ char *cluster_cfg;
46 46
  * -1 if config is malformed (unable to parse);
47 47
  *  1 if config is successfully set
48 48
  */
49
-int parse_cluster_cfg()
49
+int parse_cluster_cfg(void)
50 50
 {
51 51
    char *p,*start;
52 52
    int n,k;
Browse code

- added license and copyright

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1819 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 11/03/2007 19:20:59
Showing 1 changed files
... ...
@@ -1,4 +1,24 @@
1
-/* $Id$ */
1
+/* $Id$
2
+ *
3
+ * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4
+ *
5
+ * This file is part of openser, a free SIP server.
6
+ *
7
+ * openser is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * openser is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License 
18
+ * along with this program; if not, write to the Free Software 
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
+ */
21
+
2 22
 
3 23
 #include <string.h>
4 24
 
Browse code

reverted to old logging system. fixed a couple of warnings regarding printf("%d",(int)sizeof(something))

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1767 689a6050-402a-0410-94f2-e92a70836424

Elias Baixas authored on 08/03/2007 11:08:03
Showing 1 changed files
... ...
@@ -45,16 +45,16 @@ int parse_cluster_cfg()
45 45
       while (*p!=' ' && *p!='\t' && *p!='[' && *p!=0)
46 46
 	 p++;
47 47
       if ( p==start || *p==0 ){
48
-	 SLOG(L_ERR,"ERROR: cluster names must only contain alphanumeric chars\n");
48
+	 LOG(L_ERR,"ERROR: cluster names must only contain alphanumeric chars\n");
49 49
 	 goto error;
50 50
       }
51 51
       if (!((*entry)=(struct as_entry*)shm_malloc(sizeof(struct as_entry)))) {
52
-	 SLOG(L_ERR,"Out of shm mem for as_entry\n");
52
+	 LOG(L_ERR,"Out of shm mem for as_entry\n");
53 53
 	 goto error;
54 54
       }
55 55
       memset(*entry,0,sizeof(struct as_entry));
56 56
       if (!((*entry)->name.s=shm_malloc(p-start))) {
57
-	 SLOG(L_ERR,"Out of shm malloc for cluster name\n");
57
+	 LOG(L_ERR,"Out of shm malloc for cluster name\n");
58 58
 	 goto error;
59 59
       }
60 60
       memcpy((*entry)->name.s, start, p-start);
... ...
@@ -65,7 +65,7 @@ int parse_cluster_cfg()
65 65
       /*get as names*/
66 66
       eat_spaces(p);
67 67
       if (*p!='['){
68
-	 SLOG(L_ERR,"Malformed cluster cfg string %s\n",cluster_cfg);
68
+	 LOG(L_ERR,"Malformed cluster cfg string %s\n",cluster_cfg);
69 69
 	 goto error;
70 70
       }
71 71
       p++;
... ...
@@ -79,14 +79,14 @@ int parse_cluster_cfg()
79 79
 	 if ( p==start || *p==0 )
80 80
 	    goto error;
81 81
 	 if (!((*entry)->u.cs.as_names[n].s=shm_malloc(p-start))) {
82
-	    SLOG(L_ERR,"Out of shm_mem for AS name in cluster\n");
82
+	    LOG(L_ERR,"Out of shm_mem for AS name in cluster\n");
83 83
 	    goto error;
84 84
 	 }
85 85
 	 (*entry)->u.cs.as_names[n].len=p-start;
86 86
 	 memcpy((*entry)->u.cs.as_names[n].s,start,p-start);
87 87
 	 n++;
88 88
 	 if(n>=MAX_AS_PER_CLUSTER){
89
-	    SLOG(L_ERR,"ERROR: too many AS per cluster\n");
89
+	    LOG(L_ERR,"ERROR: too many AS per cluster\n");
90 90
 	    goto error;
91 91
 	 }
92 92
 	 eat_spaces(p);
... ...
@@ -105,16 +105,16 @@ int parse_cluster_cfg()
105 105
       entry=&((*entry)->next);
106 106
    }
107 107
    for (tmp=as_list;tmp->next;tmp=tmp->next){
108
-      SLOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
108
+      LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
109 109
    }
110
-   SLOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
110
+   LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
111 111
    entry=&(tmp->next);
112 112
    for(tmp=as_list;tmp;tmp=tmp->next){
113 113
       if (tmp->type!=CLUSTER_TYPE) 
114 114
 	 continue;
115
-      SLOG(L_DBG,"cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
115
+      LOG(L_DBG,"cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
116 116
       for(k=0;k<tmp->u.cs.num;k++){
117
-	 SLOG(L_DBG,"\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
117
+	 LOG(L_DBG,"\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
118 118
 	 for (tmp2=as_list;tmp2;tmp2=tmp2->next) {
119 119
 	    if (tmp2->type== AS_TYPE && tmp->u.cs.as_names[k].len == tmp2->name.len && 
120 120
 		  !memcmp(tmp->u.cs.as_names[k].s,tmp2->name.s,tmp2->name.len)) {
... ...
@@ -125,13 +125,13 @@ int parse_cluster_cfg()
125 125
 	 if(tmp2)
126 126
 	    continue;
127 127
 	 if (!((*entry)=shm_malloc(sizeof(struct as_entry)))) {
128
-	    SLOG(L_ERR,"ERROR:Out of shm mem \n");
128
+	    LOG(L_ERR,"ERROR:Out of shm mem \n");
129 129
 	    goto error;
130 130
 	 }
131 131
 	 memset(*entry,0,sizeof(struct as_entry));
132 132
 	 (*entry)->type=AS_TYPE;
133 133
 	 if (!((*entry)->name.s=shm_malloc(tmp->u.cs.as_names[k].len))) {
134
-	    SLOG(L_ERR,"ERROR:out of shm mem\n");
134
+	    LOG(L_ERR,"ERROR:out of shm mem\n");
135 135
 	    goto error;
136 136
 	 }
137 137
 	 memcpy((*entry)->name.s,tmp->u.cs.as_names[k].s,tmp->u.cs.as_names[k].len);
... ...
@@ -142,7 +142,7 @@ int parse_cluster_cfg()
142 142
       }
143 143
    }
144 144
    for(tmp=as_list;tmp;tmp=tmp->next){
145
-      SLOG(L_DBG,"%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
145
+      LOG(L_DBG,"%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
146 146
    }
147 147
    return 1;
148 148
 error:
Browse code

Changed the logging system

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1725 689a6050-402a-0410-94f2-e92a70836424

Elias Baixas authored on 01/03/2007 17:25:55
Showing 1 changed files
... ...
@@ -45,16 +45,16 @@ int parse_cluster_cfg()
45 45
       while (*p!=' ' && *p!='\t' && *p!='[' && *p!=0)
46 46
 	 p++;
47 47
       if ( p==start || *p==0 ){
48
-	 LOG(L_ERR,"ERROR: cluster names must only contain alphanumeric chars\n");
48
+	 SLOG(L_ERR,"ERROR: cluster names must only contain alphanumeric chars\n");
49 49
 	 goto error;
50 50
       }
51 51
       if (!((*entry)=(struct as_entry*)shm_malloc(sizeof(struct as_entry)))) {
52
-	 LOG(L_ERR,"Out of shm mem for as_entry\n");
52
+	 SLOG(L_ERR,"Out of shm mem for as_entry\n");
53 53
 	 goto error;
54 54
       }
55 55
       memset(*entry,0,sizeof(struct as_entry));
56 56
       if (!((*entry)->name.s=shm_malloc(p-start))) {
57
-	 LOG(L_ERR,"Out of shm malloc for cluster name\n");
57
+	 SLOG(L_ERR,"Out of shm malloc for cluster name\n");
58 58
 	 goto error;
59 59
       }
60 60
       memcpy((*entry)->name.s, start, p-start);
... ...
@@ -65,7 +65,7 @@ int parse_cluster_cfg()
65 65
       /*get as names*/
66 66
       eat_spaces(p);
67 67
       if (*p!='['){
68
-	 LOG(L_ERR,"Malformed cluster cfg string %s\n",cluster_cfg);
68
+	 SLOG(L_ERR,"Malformed cluster cfg string %s\n",cluster_cfg);
69 69
 	 goto error;
70 70
       }
71 71
       p++;
... ...
@@ -79,14 +79,14 @@ int parse_cluster_cfg()
79 79
 	 if ( p==start || *p==0 )
80 80
 	    goto error;
81 81
 	 if (!((*entry)->u.cs.as_names[n].s=shm_malloc(p-start))) {
82
-	    LOG(L_ERR,"Out of shm_mem for AS name in cluster\n");
82
+	    SLOG(L_ERR,"Out of shm_mem for AS name in cluster\n");
83 83
 	    goto error;
84 84
 	 }
85 85
 	 (*entry)->u.cs.as_names[n].len=p-start;
86 86
 	 memcpy((*entry)->u.cs.as_names[n].s,start,p-start);
87 87
 	 n++;
88 88
 	 if(n>=MAX_AS_PER_CLUSTER){
89
-	    LOG(L_ERR,"ERROR: too many AS per cluster\n");
89
+	    SLOG(L_ERR,"ERROR: too many AS per cluster\n");
90 90
 	    goto error;
91 91
 	 }
92 92
 	 eat_spaces(p);
... ...
@@ -105,16 +105,16 @@ int parse_cluster_cfg()
105 105
       entry=&((*entry)->next);
106 106
    }
107 107
    for (tmp=as_list;tmp->next;tmp=tmp->next){
108
-      LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
108
+      SLOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
109 109
    }
110
-   LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
110
+   SLOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
111 111
    entry=&(tmp->next);
112 112
    for(tmp=as_list;tmp;tmp=tmp->next){
113 113
       if (tmp->type!=CLUSTER_TYPE) 
114 114
 	 continue;
115
-      LOG(L_DBG,"cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
115
+      SLOG(L_DBG,"cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
116 116
       for(k=0;k<tmp->u.cs.num;k++){
117
-	 LOG(L_DBG,"\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
117
+	 SLOG(L_DBG,"\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
118 118
 	 for (tmp2=as_list;tmp2;tmp2=tmp2->next) {
119 119
 	    if (tmp2->type== AS_TYPE && tmp->u.cs.as_names[k].len == tmp2->name.len && 
120 120
 		  !memcmp(tmp->u.cs.as_names[k].s,tmp2->name.s,tmp2->name.len)) {
... ...
@@ -125,13 +125,13 @@ int parse_cluster_cfg()
125 125
 	 if(tmp2)
126 126
 	    continue;
127 127
 	 if (!((*entry)=shm_malloc(sizeof(struct as_entry)))) {
128
-	    LOG(L_ERR,"ERROR:Out of shm mem \n");
128
+	    SLOG(L_ERR,"ERROR:Out of shm mem \n");
129 129
 	    goto error;
130 130
 	 }
131 131
 	 memset(*entry,0,sizeof(struct as_entry));
132 132
 	 (*entry)->type=AS_TYPE;
133 133
 	 if (!((*entry)->name.s=shm_malloc(tmp->u.cs.as_names[k].len))) {
134
-	    LOG(L_ERR,"ERROR:out of shm mem\n");
134
+	    SLOG(L_ERR,"ERROR:out of shm mem\n");
135 135
 	    goto error;
136 136
 	 }
137 137
 	 memcpy((*entry)->name.s,tmp->u.cs.as_names[k].s,tmp->u.cs.as_names[k].len);
... ...
@@ -142,7 +142,7 @@ int parse_cluster_cfg()
142 142
       }
143 143
    }
144 144
    for(tmp=as_list;tmp;tmp=tmp->next){
145
-      LOG(L_DBG,"%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
145
+      SLOG(L_DBG,"%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
146 146
    }
147 147
    return 1;
148 148
 error:
Browse code

Added code files for SEAS module

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1448 689a6050-402a-0410-94f2-e92a70836424

Elias Baixas authored on 22/12/2006 17:07:44
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,163 @@
1
+/* $Id$ */
2
+
3
+#include <string.h>
4
+
5
+#include "cluster.h"
6
+#include "seas.h"
7
+#include "../../dprint.h"
8
+#include "../../mem/mem.h"
9
+
10
+char *cluster_cfg;
11
+
12
+#define eat_spaces(_p) \
13
+	while( *(_p)==' ' || *(_p)=='\t' ){\
14
+	(_p)++;}
15
+
16
+
17
+/**
18
+ * Parses the PING configuration string. Its format is 
19
+ * "ping_period:pings_lost:ping_timeout"
20
+ * ping_period : time between pings
21
+ * pings_lost: number of lost pings before failure
22
+ * ping_timeout: time to consider a ping failed
23
+ *
24
+ * returns 
25
+ * 0 if no clusters present
26
+ * -1 if config is malformed (unable to parse);
27
+ *  1 if config is successfully set
28
+ */
29
+int parse_cluster_cfg()
30
+{
31
+   char *p,*start;
32
+   int n,k;
33
+   struct as_entry **entry,*tmp,*tmp2;
34
+
35
+   if((p=cluster_cfg)==0 || *cluster_cfg==0){
36
+      return 0;
37
+   }
38
+   entry=&as_list;
39
+
40
+   while (*p)
41
+   {
42
+      eat_spaces(p);
43
+      /*get cluster name*/
44
+      start = p;
45
+      while (*p!=' ' && *p!='\t' && *p!='[' && *p!=0)
46
+	 p++;
47
+      if ( p==start || *p==0 ){
48
+	 LOG(L_ERR,"ERROR: cluster names must only contain alphanumeric chars\n");
49
+	 goto error;
50
+      }
51
+      if (!((*entry)=(struct as_entry*)shm_malloc(sizeof(struct as_entry)))) {
52
+	 LOG(L_ERR,"Out of shm mem for as_entry\n");
53
+	 goto error;
54
+      }
55
+      memset(*entry,0,sizeof(struct as_entry));
56
+      if (!((*entry)->name.s=shm_malloc(p-start))) {
57
+	 LOG(L_ERR,"Out of shm malloc for cluster name\n");
58
+	 goto error;
59
+      }
60
+      memcpy((*entry)->name.s, start, p-start);
61
+      (*entry)->name.len=p-start;
62
+      (*entry)->connected=0;
63
+      (*entry)->type=CLUSTER_TYPE;
64
+      (*entry)->u.cs.name=(*entry)->name;
65
+      /*get as names*/
66
+      eat_spaces(p);
67
+      if (*p!='['){
68
+	 LOG(L_ERR,"Malformed cluster cfg string %s\n",cluster_cfg);
69
+	 goto error;
70
+      }
71
+      p++;
72
+      n=0;
73
+      while (*p!=']')
74
+      {
75
+	 eat_spaces(p);
76
+	 start = p;
77
+	 while(*p!=' ' && *p!='\t' && *p!=']' && *p!=',' && *p!=0)
78
+	    p++;
79
+	 if ( p==start || *p==0 )
80
+	    goto error;
81
+	 if (!((*entry)->u.cs.as_names[n].s=shm_malloc(p-start))) {
82
+	    LOG(L_ERR,"Out of shm_mem for AS name in cluster\n");
83
+	    goto error;
84
+	 }
85
+	 (*entry)->u.cs.as_names[n].len=p-start;
86
+	 memcpy((*entry)->u.cs.as_names[n].s,start,p-start);
87
+	 n++;
88
+	 if(n>=MAX_AS_PER_CLUSTER){
89
+	    LOG(L_ERR,"ERROR: too many AS per cluster\n");
90
+	    goto error;
91
+	 }
92
+	 eat_spaces(p);
93
+	 if (*p==',') {
94
+	    p++;
95
+	    eat_spaces(p);
96
+	 }
97
+      }
98
+      p++;
99
+      (*entry)->u.cs.num=n;
100
+      /* end of element */
101
+      eat_spaces(p);
102
+      if (*p==',')
103
+	 p++;
104
+      eat_spaces(p);
105
+      entry=&((*entry)->next);
106
+   }
107
+   for (tmp=as_list;tmp->next;tmp=tmp->next){
108
+      LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
109
+   }
110
+   LOG(L_DBG,"%.*s\n",tmp->name.len,tmp->name.s);
111
+   entry=&(tmp->next);
112
+   for(tmp=as_list;tmp;tmp=tmp->next){
113
+      if (tmp->type!=CLUSTER_TYPE) 
114
+	 continue;
115
+      LOG(L_DBG,"cluster:[%.*s]\n",tmp->name.len,tmp->name.s);
116
+      for(k=0;k<tmp->u.cs.num;k++){
117
+	 LOG(L_DBG,"\tAS:[%.*s]\n",tmp->u.cs.as_names[k].len,tmp->u.cs.as_names[k].s);
118
+	 for (tmp2=as_list;tmp2;tmp2=tmp2->next) {
119
+	    if (tmp2->type== AS_TYPE && tmp->u.cs.as_names[k].len == tmp2->name.len && 
120
+		  !memcmp(tmp->u.cs.as_names[k].s,tmp2->name.s,tmp2->name.len)) {
121
+	       tmp->u.cs.servers[k]=&tmp2->u.as;
122
+	       break;
123
+	    }
124
+	 }
125
+	 if(tmp2)
126
+	    continue;
127
+	 if (!((*entry)=shm_malloc(sizeof(struct as_entry)))) {
128
+	    LOG(L_ERR,"ERROR:Out of shm mem \n");
129
+	    goto error;
130
+	 }
131
+	 memset(*entry,0,sizeof(struct as_entry));
132
+	 (*entry)->type=AS_TYPE;
133
+	 if (!((*entry)->name.s=shm_malloc(tmp->u.cs.as_names[k].len))) {
134
+	    LOG(L_ERR,"ERROR:out of shm mem\n");
135
+	    goto error;
136
+	 }
137
+	 memcpy((*entry)->name.s,tmp->u.cs.as_names[k].s,tmp->u.cs.as_names[k].len);
138
+	 (*entry)->name.len=tmp->u.cs.as_names[k].len;
139
+	 (*entry)->u.as.name=(*entry)->name;
140
+	 tmp->u.cs.servers[k]=&(*entry)->u.as;
141
+	 entry=&((*entry)->next);
142
+      }
143
+   }
144
+   for(tmp=as_list;tmp;tmp=tmp->next){
145
+      LOG(L_DBG,"%.*s %s",tmp->name.len,tmp->name.s,tmp->next?"":"\n");
146
+   }
147
+   return 1;
148
+error:
149
+   tmp=as_list;
150
+   while(tmp){
151
+      for(k=0;k<tmp->u.cs.num;k++){
152
+	 if(tmp->u.cs.as_names[k].s)
153
+	    shm_free(tmp->u.cs.as_names[k].s);
154
+      }
155
+      if(tmp->name.s)
156
+	 shm_free(tmp->name.s);
157
+      tmp2=tmp;
158
+      tmp=tmp->next;
159
+      shm_free(tmp2);
160
+   }
161
+   as_list=(struct as_entry *)0;
162
+   return -1;
163
+}