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,194 +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
- * =====================================================================================
24
- * 
25
- *        Filename:  utils.c
26
- * 
27
- *     Description:  
28
- * 
29
- *         Version:  1.0
30
- *         Created:  19/01/06 15:50:33 CET
31
- *        Revision:  none
32
- *        Compiler:  gcc
33
- * 
34
- *          Author:  Elias Baixas (EB), elias@conillera.net
35
- *         Company:  VozTele.com
36
- * 
37
- * =====================================================================================
38
- */
39
-#include <sys/types.h>
40
-#include <sys/stat.h>
41
-#include <fcntl.h>
42
-#include <unistd.h>
43
-#include <stdlib.h>
44
-#define _GNU_SOURCE
45
-#include <stdio.h>
46
-#include <syslog.h>
47
-#include <string.h>
48
-
49
-#include "../../parser/msg_parser.h"
50
-#include "../../parser/parse_via.h"
51
-#include "../../parser/parse_uri.h"
52
-#include "../../parser/parse_from.h"
53
-#include "../../mem/mem.h"
54
-#include "../../dprint.h"
55
-#include "encode_header.h"
56
-#include "encode_msg.h"
57
-#include "utils.h"
58
-
59
-#define MAX_ERROR 32
60
-
61
-static inline int memstr(char *haystack,int hlen,char *needle,int nlen);
62
-
63
-int buffered_printer(FILE* infd)
64
-{
65
-   int i,k=0,retval;
66
-   char *missatge=0,*myerror="";
67
-   struct sip_msg msg;
68
-   static char mybuffer[1400];
69
-   static int end=0,last=0;
70
-
71
-   while((i=fread(&mybuffer[last],1,1400-last,infd))==1400-last){
72
-      if((end=memstr(mybuffer,last+i,"\n\n\n",3))<0){
73
-	 last+=i;
74
-	 return 0;
75
-      }else{
76
-	 end+=3;
77
-	 while(end<1400 && (mybuffer[end]=='\n' || mybuffer[end]=='.' || mybuffer[end]=='\r'))
78
-	    end++;
79
-	 if((missatge=pkg_malloc(end))==0){
80
-	    myerror="Out of memory !!\n";
81
-	    goto error;
82
-	 }
83
-	 memset(missatge,0,end);
84
-	 memcpy(missatge,mybuffer,end);
85
-	 memset(&msg,0,sizeof(struct sip_msg));
86
-	 msg.buf=missatge;
87
-	 msg.len=end;
88
-	 if(!parse_msg(msg.buf,msg.len,&msg))
89
-	    print_msg_info(stdout,&msg);
90
-	 printf("PARSED:%d,last=%d,end=%d\n",k++,last,end);
91
-	 free_sip_msg(&msg);
92
-	 pkg_free(missatge);
93
-	 memmove(mybuffer,&mybuffer[end],1400-end);
94
-	 last=1400-end;
95
-      }
96
-   }
97
-   retval=0;
98
-   goto exit;
99
-error:
100
-   printf("Error on %s",myerror);
101
-   retval=1;
102
-exit:
103
-   if(missatge)
104
-      pkg_free(missatge);
105
-   return retval;
106
-}
107
-
108
-int coded_buffered_printer(FILE* infd)
109
-{
110
-   int i,lastlast;
111
-   char spaces[50];
112
-   static char mybuffer[1500];
113
-   static int size=0,last=0;
114
-
115
-   memcpy(spaces," ",2);
116
-
117
-   do{
118
-      lastlast=1500-last;
119
-      i=fread(&mybuffer[last],1,lastlast,infd);
120
-      printf("read i=%d\n",i);
121
-      if(i==0)
122
-	 break;
123
-      if(size==0){
124
-	 size=GET_PAY_SIZE(mybuffer);
125
-	 printf("size=%d\n",size);
126
-	 last+=i;
127
-      }
128
-      if(last>=size){
129
-	 printf("should print message: last=%d, size=%d\n",last,size);
130
-	 if(print_encoded_msg(stdout,mybuffer,spaces)<0){
131
-	    printf("Unable to print encoded msg\n");
132
-	    return -1;
133
-	 }
134
-	 if(last>size){
135
-	    memmove(mybuffer,&mybuffer[size],last-size);
136
-	    last=last-size;
137
-	 }else
138
-	    last=0;
139
-	 size=0;
140
-      }
141
-   }while(i>0 && i==lastlast);
142
-
143
-   if(i==0)
144
-      return 0;
145
-   else
146
-      return 1;
147
-}
148
-
149
-int print_msg_info(FILE* fd,struct sip_msg* msg)
150
-{
151
-   char *payload=0;
152
-   char *prefix=0;
153
-   int retval=-1;
154
-   if((prefix=pkg_malloc(500))==0){
155
-      printf("OUT OF MEMORY !!!\n");
156
-      return -1;
157
-   }
158
-   memset(prefix,0,500);
159
-   strcpy(prefix,"  ");
160
-
161
-   if(parse_headers(msg,HDR_EOH_F,0)<0)
162
-      goto error;
163
-   if(!(payload=pkg_malloc(MAX_ENCODED_MSG + MAX_MESSAGE_LEN)))
164
-      goto error;
165
-   if(encode_msg(msg,payload,MAX_ENCODED_MSG + MAX_MESSAGE_LEN)<0){
166
-      printf("Unable to encode msg\n");
167
-      goto error;
168
-   }
169
-   if(print_encoded_msg(fd,payload,prefix)<0){
170
-      printf("Unable to print encoded msg\n");
171
-      pkg_free(payload);
172
-      goto error;
173
-   }
174
-   pkg_free(payload);
175
-   retval =0;
176
-error:
177
-   if(prefix)
178
-      pkg_free(prefix);
179
-   return retval;
180
-}
181
-
182
-static inline int memstr(char *haystack,int hlen,char *needle,int nlen)
183
-{
184
-   int i=0;
185
-
186
-   if(nlen>hlen)
187
-      return -1;
188
-   while(i<=(hlen-nlen) && (haystack[i]!=needle[0] || memcmp(&haystack[i],needle,nlen)))
189
-      i++;
190
-   if(i>(hlen-nlen))
191
-      return -1;
192
-   else
193
-      return i;
194
-}
Browse code

Replaced dprintf for fprintf (dprintf is somewhat gnu-specific and does not compile on Mac). even though it was just used for debugging (not on the module) it prevented compilation

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

Elias Baixas authored on 13/11/2008 10:18:48
Showing 1 changed files
... ...
@@ -60,7 +60,7 @@
60 60
 
61 61
 static inline int memstr(char *haystack,int hlen,char *needle,int nlen);
62 62
 
63
-int buffered_printer(int infd)
63
+int buffered_printer(FILE* infd)
64 64
 {
65 65
    int i,k=0,retval;
66 66
    char *missatge=0,*myerror="";
... ...
@@ -68,7 +68,7 @@ int buffered_printer(int infd)
68 68
    static char mybuffer[1400];
69 69
    static int end=0,last=0;
70 70
 
71
-   while((i=read(infd,&mybuffer[last],1400-last))==1400-last){
71
+   while((i=fread(&mybuffer[last],1,1400-last,infd))==1400-last){
72 72
       if((end=memstr(mybuffer,last+i,"\n\n\n",3))<0){
73 73
 	 last+=i;
74 74
 	 return 0;
... ...
@@ -86,7 +86,7 @@ int buffered_printer(int infd)
86 86
 	 msg.buf=missatge;
87 87
 	 msg.len=end;
88 88
 	 if(!parse_msg(msg.buf,msg.len,&msg))
89
-	    print_msg_info(1,&msg);
89
+	    print_msg_info(stdout,&msg);
90 90
 	 printf("PARSED:%d,last=%d,end=%d\n",k++,last,end);
91 91
 	 free_sip_msg(&msg);
92 92
 	 pkg_free(missatge);
... ...
@@ -105,7 +105,7 @@ exit:
105 105
    return retval;
106 106
 }
107 107
 
108
-int coded_buffered_printer(int infd)
108
+int coded_buffered_printer(FILE* infd)
109 109
 {
110 110
    int i,lastlast;
111 111
    char spaces[50];
... ...
@@ -116,7 +116,7 @@ int coded_buffered_printer(int infd)
116 116
 
117 117
    do{
118 118
       lastlast=1500-last;
119
-      i=read(infd,&mybuffer[last],lastlast);
119
+      i=fread(&mybuffer[last],1,lastlast,infd);
120 120
       printf("read i=%d\n",i);
121 121
       if(i==0)
122 122
 	 break;
... ...
@@ -127,7 +127,7 @@ int coded_buffered_printer(int infd)
127 127
       }
128 128
       if(last>=size){
129 129
 	 printf("should print message: last=%d, size=%d\n",last,size);
130
-	 if(print_encoded_msg(1,mybuffer,spaces)<0){
130
+	 if(print_encoded_msg(stdout,mybuffer,spaces)<0){
131 131
 	    printf("Unable to print encoded msg\n");
132 132
 	    return -1;
133 133
 	 }
... ...
@@ -146,7 +146,7 @@ int coded_buffered_printer(int infd)
146 146
       return 1;
147 147
 }
148 148
 
149
-int print_msg_info(int fd,struct sip_msg* msg)
149
+int print_msg_info(FILE* fd,struct sip_msg* msg)
150 150
 {
151 151
    char *payload=0;
152 152
    char *prefix=0;
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

- 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
  * =====================================================================================
4 24
  * 
Browse code

fixed several warning and incomplete initializers

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

Bogdan-Andrei Iancu authored on 10/03/2007 17:36:19
Showing 1 changed files
... ...
@@ -131,7 +131,7 @@ int print_msg_info(int fd,struct sip_msg* msg)
131 131
    char *payload=0;
132 132
    char *prefix=0;
133 133
    int retval=-1;
134
-   if((prefix=pkg_malloc(500))<=0){
134
+   if((prefix=pkg_malloc(500))==0){
135 135
       printf("OUT OF MEMORY !!!\n");
136 136
       return -1;
137 137
    }
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,174 @@
1
+/* $Id$ */
2
+/*
3
+ * =====================================================================================
4
+ * 
5
+ *        Filename:  utils.c
6
+ * 
7
+ *     Description:  
8
+ * 
9
+ *         Version:  1.0
10
+ *         Created:  19/01/06 15:50:33 CET
11
+ *        Revision:  none
12
+ *        Compiler:  gcc
13
+ * 
14
+ *          Author:  Elias Baixas (EB), elias@conillera.net
15
+ *         Company:  VozTele.com
16
+ * 
17
+ * =====================================================================================
18
+ */
19
+#include <sys/types.h>
20
+#include <sys/stat.h>
21
+#include <fcntl.h>
22
+#include <unistd.h>
23
+#include <stdlib.h>
24
+#define _GNU_SOURCE
25
+#include <stdio.h>
26
+#include <syslog.h>
27
+#include <string.h>
28
+
29
+#include "../../parser/msg_parser.h"
30
+#include "../../parser/parse_via.h"
31
+#include "../../parser/parse_uri.h"
32
+#include "../../parser/parse_from.h"
33
+#include "../../mem/mem.h"
34
+#include "../../dprint.h"
35
+#include "encode_header.h"
36
+#include "encode_msg.h"
37
+#include "utils.h"
38
+
39
+#define MAX_ERROR 32
40
+
41
+static inline int memstr(char *haystack,int hlen,char *needle,int nlen);
42
+
43
+int buffered_printer(int infd)
44
+{
45
+   int i,k=0,retval;
46
+   char *missatge=0,*myerror="";
47
+   struct sip_msg msg;
48
+   static char mybuffer[1400];
49
+   static int end=0,last=0;
50
+
51
+   while((i=read(infd,&mybuffer[last],1400-last))==1400-last){
52
+      if((end=memstr(mybuffer,last+i,"\n\n\n",3))<0){
53
+	 last+=i;
54
+	 return 0;
55
+      }else{
56
+	 end+=3;
57
+	 while(end<1400 && (mybuffer[end]=='\n' || mybuffer[end]=='.' || mybuffer[end]=='\r'))
58
+	    end++;
59
+	 if((missatge=pkg_malloc(end))==0){
60
+	    myerror="Out of memory !!\n";
61
+	    goto error;
62
+	 }
63
+	 memset(missatge,0,end);
64
+	 memcpy(missatge,mybuffer,end);
65
+	 memset(&msg,0,sizeof(struct sip_msg));
66
+	 msg.buf=missatge;
67
+	 msg.len=end;
68
+	 if(!parse_msg(msg.buf,msg.len,&msg))
69
+	    print_msg_info(1,&msg);
70
+	 printf("PARSED:%d,last=%d,end=%d\n",k++,last,end);
71
+	 free_sip_msg(&msg);
72
+	 pkg_free(missatge);
73
+	 memmove(mybuffer,&mybuffer[end],1400-end);
74
+	 last=1400-end;
75
+      }
76
+   }
77
+   retval=0;
78
+   goto exit;
79
+error:
80
+   printf("Error on %s",myerror);
81
+   retval=1;
82
+exit:
83
+   if(missatge)
84
+      pkg_free(missatge);
85
+   return retval;
86
+}
87
+
88
+int coded_buffered_printer(int infd)
89
+{
90
+   int i,lastlast;
91
+   char spaces[50];
92
+   static char mybuffer[1500];
93
+   static int size=0,last=0;
94
+
95
+   memcpy(spaces," ",2);
96
+
97
+   do{
98
+      lastlast=1500-last;
99
+      i=read(infd,&mybuffer[last],lastlast);
100
+      printf("read i=%d\n",i);
101
+      if(i==0)
102
+	 break;
103
+      if(size==0){
104
+	 size=GET_PAY_SIZE(mybuffer);
105
+	 printf("size=%d\n",size);
106
+	 last+=i;
107
+      }
108
+      if(last>=size){
109
+	 printf("should print message: last=%d, size=%d\n",last,size);
110
+	 if(print_encoded_msg(1,mybuffer,spaces)<0){
111
+	    printf("Unable to print encoded msg\n");
112
+	    return -1;
113
+	 }
114
+	 if(last>size){
115
+	    memmove(mybuffer,&mybuffer[size],last-size);
116
+	    last=last-size;
117
+	 }else
118
+	    last=0;
119
+	 size=0;
120
+      }
121
+   }while(i>0 && i==lastlast);
122
+
123
+   if(i==0)
124
+      return 0;
125
+   else
126
+      return 1;
127
+}
128
+
129
+int print_msg_info(int fd,struct sip_msg* msg)
130
+{
131
+   char *payload=0;
132
+   char *prefix=0;
133
+   int retval=-1;
134
+   if((prefix=pkg_malloc(500))<=0){
135
+      printf("OUT OF MEMORY !!!\n");
136
+      return -1;
137
+   }
138
+   memset(prefix,0,500);
139
+   strcpy(prefix,"  ");
140
+
141
+   if(parse_headers(msg,HDR_EOH_F,0)<0)
142
+      goto error;
143
+   if(!(payload=pkg_malloc(MAX_ENCODED_MSG + MAX_MESSAGE_LEN)))
144
+      goto error;
145
+   if(encode_msg(msg,payload,MAX_ENCODED_MSG + MAX_MESSAGE_LEN)<0){
146
+      printf("Unable to encode msg\n");
147
+      goto error;
148
+   }
149
+   if(print_encoded_msg(fd,payload,prefix)<0){
150
+      printf("Unable to print encoded msg\n");
151
+      pkg_free(payload);
152
+      goto error;
153
+   }
154
+   pkg_free(payload);
155
+   retval =0;
156
+error:
157
+   if(prefix)
158
+      pkg_free(prefix);
159
+   return retval;
160
+}
161
+
162
+static inline int memstr(char *haystack,int hlen,char *needle,int nlen)
163
+{
164
+   int i=0;
165
+
166
+   if(nlen>hlen)
167
+      return -1;
168
+   while(i<=(hlen-nlen) && (haystack[i]!=needle[0] || memcmp(&haystack[i],needle,nlen)))
169
+      i++;
170
+   if(i>(hlen-nlen))
171
+      return -1;
172
+   else
173
+      return i;
174
+}