Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,174 +0,0 @@
1
-/*
2
- * Handling of the q value
3
- *
4
- * Copyright (C) 2004 FhG FOKUS
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
20
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
- *
22
- */
23
-/*!
24
- * \file
25
- * \brief Kamailio core :: Handling of the Q value
26
- * \author janakj
27
- * \ingroup core
28
- * Module: \ref core
29
- */
30
-
31
-#ifndef _QVALUE_H
32
-#define _QVALUE_H 1
33
-
34
-#include <string.h>
35
-
36
-/*
37
- * The q value expresses the priority of a URI within a set of URIs 
38
- * (Contact header field in the same SIP message or dset array in 
39
- * ser. The higher is the q value of a URI the higher is the priority 
40
- * of the URI.
41
- *
42
- * The q value is usually expressed as a floating point number with 
43
- * limited number of decimal digits, for example 0.346. RFC3261 allows 
44
- * 0-3 decimal digits.
45
- *
46
- * To speed things up we represent the q value as integer number, it 
47
- * is then easier to handle/print the value. To convert float into 
48
- * integer we multiply the q value by 1000, i.e. 
49
- * (float)0.567 == (int)567. In the opposite direction, values 
50
- * higher or equal to 1000 are converted to 1.0 and values below or 
51
- * equal to 0 are converted to 0.
52
- *
53
- * Value Q_UNSPECIFIED (which is in fact -1) has a special meaning, it 
54
- * means that the q value is not known and the parameter should not be 
55
- * printed when printing Contacts, implementations will then use 
56
- * implementation specific pre-defined values.
57
- */
58
-
59
-typedef int qvalue_t;
60
-
61
-/*
62
- * Use this if the value of q is not specified
63
- */
64
-#define Q_UNSPECIFIED ((qvalue_t)-1)
65
-
66
-
67
-#define MAX_Q ((qvalue_t)1000)
68
-#define MIN_Q ((qvalue_t)0)
69
-
70
-#define MAX_Q_STR "1"
71
-#define MAX_Q_STR_LEN (sizeof(MAX_Q_STR) - 1)
72
-
73
-#define MIN_Q_STR "0"
74
-#define MIN_Q_STR_LEN (sizeof(MIN_Q_STR) - 1)
75
-
76
-#define Q_PREFIX "0."
77
-#define Q_PREFIX_LEN (sizeof(Q_PREFIX) - 1)
78
-
79
-
80
-
81
-/*
82
- * Calculate the length of printed q
83
- */
84
-static inline size_t len_q(qvalue_t q)
85
-{
86
-	if (q == Q_UNSPECIFIED) {
87
-		return 0;
88
-	} else if (q >= MAX_Q) {
89
-		return MAX_Q_STR_LEN;
90
-	} else if (q <= MIN_Q) {
91
-		return MIN_Q_STR_LEN;
92
-	} else if (q % 100 == 0) {
93
-		return Q_PREFIX_LEN + 1;
94
-	} else if (q % 10 == 0) {
95
-		return Q_PREFIX_LEN + 2;
96
-	} else {
97
-		return Q_PREFIX_LEN + 3;
98
-	}
99
-}
100
-
101
-
102
-/*
103
- * Convert qvalue_t to double
104
- */
105
-static inline double q2double(qvalue_t q)
106
-{
107
-	if (q == Q_UNSPECIFIED) {
108
-		return -1;
109
-	} else {
110
-		return (double)((double)q / (double)1000);
111
-	}
112
-}
113
-
114
-
115
-/*
116
- * Convert double to qvalue_t
117
- */
118
-static inline qvalue_t double2q(double q)
119
-{
120
-	if (q == -1) {
121
-		return Q_UNSPECIFIED;
122
-	} else {
123
-		return q * 1000;
124
-	}
125
-}
126
-
127
-
128
-/*
129
- * Convert q value to string
130
- */
131
-static inline char* q2str(qvalue_t q, unsigned int* len)
132
-{
133
-	static char buf[sizeof("0.123")];
134
-	char* p;
135
-
136
-	p = buf;
137
-	if (q == Q_UNSPECIFIED) {
138
-		     /* Do nothing */
139
-	} else if (q >= MAX_Q) {
140
-		memcpy(p, MAX_Q_STR, MAX_Q_STR_LEN);
141
-		p += MAX_Q_STR_LEN;
142
-	} else if (q <= MIN_Q) {
143
-		memcpy(p, MIN_Q_STR, MIN_Q_STR_LEN);
144
-		p += MIN_Q_STR_LEN;
145
-	} else {
146
-		memcpy(p, Q_PREFIX, Q_PREFIX_LEN);
147
-		p += Q_PREFIX_LEN;
148
-		
149
-		*p++ = q / 100 + '0';
150
-		q %= 100;
151
-		if (!q) goto end;
152
-
153
-		*p++ = q / 10 + '0';
154
-		q %= 10;
155
-		if (!q) goto end;
156
-
157
-		*p++ = q + '0';
158
-	}
159
- end:
160
-	*p = '\0';
161
-	if (len) {
162
-		*len = p - buf;
163
-	}
164
-	return buf;
165
-}
166
-
167
-
168
-/*
169
- * Convert string representation of q parameter in qvalue_t
170
- */
171
-int str2q(qvalue_t* q, char* s, int len);
172
-
173
-
174
-#endif /* _QVALUE_H */
Browse code

Core Update of doxygen, removal of history, changing "ser" to "kamailio"

Olle E. Johansson authored on 03/01/2015 14:03:24
Showing 1 changed files
... ...
@@ -1,23 +1,16 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Handling of the q value
5 3
  *
6 4
  * Copyright (C) 2004 FhG FOKUS
7 5
  *
8
- * This file is part of ser, a free SIP server.
6
+ * This file is part of Kamailio, a free SIP server.
9 7
  *
10
- * ser is free software; you can redistribute it and/or modify
8
+ * Kamailio is free software; you can redistribute it and/or modify
11 9
  * it under the terms of the GNU General Public License as published by
12 10
  * the Free Software Foundation; either version 2 of the License, or
13 11
  * (at your option) any later version
14 12
  *
15
- * For a license to use the ser software under conditions
16
- * other than those described here, or to purchase support for this
17
- * software, please contact iptel.org by e-mail at the following addresses:
18
- *    info@iptel.org
19
- *
20
- * ser is distributed in the hope that it will be useful,
13
+ * Kamailio is distributed in the hope that it will be useful,
21 14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 16
  * GNU General Public License for more details.
... ...
@@ -26,9 +19,13 @@
26 19
  * along with this program; if not, write to the Free Software 
27 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 21
  *
29
- * History
30
- * ------
31
- * 2004-04-25 created (janakj)
22
+ */
23
+/*!
24
+ * \file
25
+ * \brief Kamailio core :: Handling of the Q value
26
+ * \author janakj
27
+ * \ingroup core
28
+ * Module: \ref core
32 29
  */
33 30
 
34 31
 #ifndef _QVALUE_H
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@
24 24
  *
25 25
  * You should have received a copy of the GNU General Public License 
26 26
  * along with this program; if not, write to the Free Software 
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 28
  *
29 29
  * History
30 30
  * ------
Browse code

q2double and double2q added

Jan Janak authored on 27/04/2004 14:52:57
Showing 1 changed files
... ...
@@ -80,6 +80,7 @@ typedef int qvalue_t;
80 80
 #define Q_PREFIX_LEN (sizeof(Q_PREFIX) - 1)
81 81
 
82 82
 
83
+
83 84
 /*
84 85
  * Calculate the length of printed q
85 86
  */
... ...
@@ -101,6 +102,32 @@ static inline size_t len_q(qvalue_t q)
101 102
 }
102 103
 
103 104
 
105
+/*
106
+ * Convert qvalue_t to double
107
+ */
108
+static inline double q2double(qvalue_t q)
109
+{
110
+	if (q == Q_UNSPECIFIED) {
111
+		return -1;
112
+	} else {
113
+		return (double)((double)q / (double)1000);
114
+	}
115
+}
116
+
117
+
118
+/*
119
+ * Convert double to qvalue_t
120
+ */
121
+static inline qvalue_t double2q(double q)
122
+{
123
+	if (q == -1) {
124
+		return Q_UNSPECIFIED;
125
+	} else {
126
+		return q * 1000;
127
+	}
128
+}
129
+
130
+
104 131
 /*
105 132
  * Convert q value to string
106 133
  */
... ...
@@ -130,12 +157,13 @@ static inline char* q2str(qvalue_t q, unsigned int* len)
130 157
 		q %= 10;
131 158
 		if (!q) goto end;
132 159
 
133
-		*p = q + '0';
134
-		*len = Q_PREFIX_LEN + 3;
160
+		*p++ = q + '0';
135 161
 	}
136 162
  end:
137 163
 	*p = '\0';
138
-	*len = p - buf;
164
+	if (len) {
165
+		*len = p - buf;
166
+	}
139 167
 	return buf;
140 168
 }
141 169
 
Browse code

print_q -> q2str and it's interface aligned to other similar functions.

Jan Janak authored on 26/04/2004 19:19:28
Showing 1 changed files
... ...
@@ -102,31 +102,41 @@ static inline size_t len_q(qvalue_t q)
102 102
 
103 103
 
104 104
 /*
105
- * Print the q parameter
105
+ * Convert q value to string
106 106
  */
107
-static inline size_t print_q(char* p, qvalue_t q)
107
+static inline char* q2str(qvalue_t q, unsigned int* len)
108 108
 {
109
+	static char buf[sizeof("0.123")];
110
+	char* p;
111
+
112
+	p = buf;
109 113
 	if (q == Q_UNSPECIFIED) {
110
-		return 0;
114
+		     /* Do nothing */
111 115
 	} else if (q >= MAX_Q) {
112 116
 		memcpy(p, MAX_Q_STR, MAX_Q_STR_LEN);
113
-		return MAX_Q_STR_LEN;
117
+		p += MAX_Q_STR_LEN;
114 118
 	} else if (q <= MIN_Q) {
115 119
 		memcpy(p, MIN_Q_STR, MIN_Q_STR_LEN);
116
-		return MIN_Q_STR_LEN;
120
+		p += MIN_Q_STR_LEN;
121
+	} else {
122
+		memcpy(p, Q_PREFIX, Q_PREFIX_LEN);
123
+		p += Q_PREFIX_LEN;
124
+		
125
+		*p++ = q / 100 + '0';
126
+		q %= 100;
127
+		if (!q) goto end;
128
+
129
+		*p++ = q / 10 + '0';
130
+		q %= 10;
131
+		if (!q) goto end;
132
+
133
+		*p = q + '0';
134
+		*len = Q_PREFIX_LEN + 3;
117 135
 	}
118
-	
119
-	memcpy(p, Q_PREFIX, Q_PREFIX_LEN);
120
-	p += Q_PREFIX_LEN;
121
-
122
-	*p++ = q / 100 + '0';
123
-	q %= 100;
124
-	if (!q) return Q_PREFIX_LEN + 1;
125
-	*p++ = q / 10 + '0';
126
-	q %= 10;
127
-	if (!q) return Q_PREFIX_LEN + 2;
128
-	*p = q + '0';
129
-	return Q_PREFIX_LEN + 3;
136
+ end:
137
+	*p = '\0';
138
+	*len = p - buf;
139
+	return buf;
130 140
 }
131 141
 
132 142
 
Browse code

str2q implemented append_branch("sip:a@iptel.org", "0.23") implemented append_branch("sip:a@iptel.org", 230) removed (it was not very intuitive)

Jan Janak authored on 26/04/2004 17:11:55
Showing 1 changed files
... ...
@@ -129,4 +129,11 @@ static inline size_t print_q(char* p, qvalue_t q)
129 129
 	return Q_PREFIX_LEN + 3;
130 130
 }
131 131
 
132
+
133
+/*
134
+ * Convert string representation of q parameter in qvalue_t
135
+ */
136
+int str2q(qvalue_t* q, char* s, int len);
137
+
138
+
132 139
 #endif /* _QVALUE_H */
Browse code

qvalue related functions and types.

Jan Janak authored on 25/04/2004 15:29:31
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,132 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Handling of the q value
5
+ *
6
+ * Copyright (C) 2004 FhG FOKUS
7
+ *
8
+ * This file is part of ser, a free SIP server.
9
+ *
10
+ * ser is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version
14
+ *
15
+ * For a license to use the ser software under conditions
16
+ * other than those described here, or to purchase support for this
17
+ * software, please contact iptel.org by e-mail at the following addresses:
18
+ *    info@iptel.org
19
+ *
20
+ * ser is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License 
26
+ * along with this program; if not, write to the Free Software 
27
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
+ *
29
+ * History
30
+ * ------
31
+ * 2004-04-25 created (janakj)
32
+ */
33
+
34
+#ifndef _QVALUE_H
35
+#define _QVALUE_H 1
36
+
37
+#include <string.h>
38
+
39
+/*
40
+ * The q value expresses the priority of a URI within a set of URIs 
41
+ * (Contact header field in the same SIP message or dset array in 
42
+ * ser. The higher is the q value of a URI the higher is the priority 
43
+ * of the URI.
44
+ *
45
+ * The q value is usually expressed as a floating point number with 
46
+ * limited number of decimal digits, for example 0.346. RFC3261 allows 
47
+ * 0-3 decimal digits.
48
+ *
49
+ * To speed things up we represent the q value as integer number, it 
50
+ * is then easier to handle/print the value. To convert float into 
51
+ * integer we multiply the q value by 1000, i.e. 
52
+ * (float)0.567 == (int)567. In the opposite direction, values 
53
+ * higher or equal to 1000 are converted to 1.0 and values below or 
54
+ * equal to 0 are converted to 0.
55
+ *
56
+ * Value Q_UNSPECIFIED (which is in fact -1) has a special meaning, it 
57
+ * means that the q value is not known and the parameter should not be 
58
+ * printed when printing Contacts, implementations will then use 
59
+ * implementation specific pre-defined values.
60
+ */
61
+
62
+typedef int qvalue_t;
63
+
64
+/*
65
+ * Use this if the value of q is not specified
66
+ */
67
+#define Q_UNSPECIFIED ((qvalue_t)-1)
68
+
69
+
70
+#define MAX_Q ((qvalue_t)1000)
71
+#define MIN_Q ((qvalue_t)0)
72
+
73
+#define MAX_Q_STR "1"
74
+#define MAX_Q_STR_LEN (sizeof(MAX_Q_STR) - 1)
75
+
76
+#define MIN_Q_STR "0"
77
+#define MIN_Q_STR_LEN (sizeof(MIN_Q_STR) - 1)
78
+
79
+#define Q_PREFIX "0."
80
+#define Q_PREFIX_LEN (sizeof(Q_PREFIX) - 1)
81
+
82
+
83
+/*
84
+ * Calculate the length of printed q
85
+ */
86
+static inline size_t len_q(qvalue_t q)
87
+{
88
+	if (q == Q_UNSPECIFIED) {
89
+		return 0;
90
+	} else if (q >= MAX_Q) {
91
+		return MAX_Q_STR_LEN;
92
+	} else if (q <= MIN_Q) {
93
+		return MIN_Q_STR_LEN;
94
+	} else if (q % 100 == 0) {
95
+		return Q_PREFIX_LEN + 1;
96
+	} else if (q % 10 == 0) {
97
+		return Q_PREFIX_LEN + 2;
98
+	} else {
99
+		return Q_PREFIX_LEN + 3;
100
+	}
101
+}
102
+
103
+
104
+/*
105
+ * Print the q parameter
106
+ */
107
+static inline size_t print_q(char* p, qvalue_t q)
108
+{
109
+	if (q == Q_UNSPECIFIED) {
110
+		return 0;
111
+	} else if (q >= MAX_Q) {
112
+		memcpy(p, MAX_Q_STR, MAX_Q_STR_LEN);
113
+		return MAX_Q_STR_LEN;
114
+	} else if (q <= MIN_Q) {
115
+		memcpy(p, MIN_Q_STR, MIN_Q_STR_LEN);
116
+		return MIN_Q_STR_LEN;
117
+	}
118
+	
119
+	memcpy(p, Q_PREFIX, Q_PREFIX_LEN);
120
+	p += Q_PREFIX_LEN;
121
+
122
+	*p++ = q / 100 + '0';
123
+	q %= 100;
124
+	if (!q) return Q_PREFIX_LEN + 1;
125
+	*p++ = q / 10 + '0';
126
+	q %= 10;
127
+	if (!q) return Q_PREFIX_LEN + 2;
128
+	*p = q + '0';
129
+	return Q_PREFIX_LEN + 3;
130
+}
131
+
132
+#endif /* _QVALUE_H */