- 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)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,101 +0,0 @@ |
1 |
-/* |
|
2 |
- * |
|
3 |
- * Copyright (C) 2015 kamailio.org |
|
4 |
- * Copyright (C) 2014 Victor Seva <vseva@sipwise.com> |
|
5 |
- * |
|
6 |
- * This file is part of kamailio, a free SIP server. |
|
7 |
- * |
|
8 |
- * Permission to use, copy, modify, and distribute this software for any |
|
9 |
- * purpose with or without fee is hereby granted, provided that the above |
|
10 |
- * copyright notice and this permission notice appear in all copies. |
|
11 |
- * |
|
12 |
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
13 |
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
14 |
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
15 |
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
16 |
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
17 |
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
18 |
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
19 |
- */ |
|
20 |
-/*! |
|
21 |
- * \file |
|
22 |
- * \brief Kamailio core :: Append to str data |
|
23 |
- * \ingroup core |
|
24 |
- * Module: \ref core |
|
25 |
- */ |
|
26 |
- |
|
27 |
-#include <string.h> |
|
28 |
-#include "str.h" |
|
29 |
-#include "mem/mem.h" |
|
30 |
- |
|
31 |
-int str_append(str *orig, str *suffix, str *dest) |
|
32 |
-{ |
|
33 |
- if(orig == NULL || suffix == NULL || suffix->len == 0 || dest == NULL) |
|
34 |
- { |
|
35 |
- LM_ERR("wrong parameters\n"); |
|
36 |
- return -1; |
|
37 |
- } |
|
38 |
- dest->len = orig->len + suffix->len; |
|
39 |
- dest->s = pkg_malloc(sizeof(char)*dest->len); |
|
40 |
- if(dest->s==NULL) |
|
41 |
- { |
|
42 |
- LM_ERR("memory allocation failure\n"); |
|
43 |
- return -1; |
|
44 |
- } |
|
45 |
- if(orig->len>0) |
|
46 |
- { |
|
47 |
- memcpy(dest->s, orig->s, orig->len); |
|
48 |
- } |
|
49 |
- memcpy(dest->s+orig->len, suffix->s, suffix->len); |
|
50 |
- return 0; |
|
51 |
-} |
|
52 |
- |
|
53 |
-/* |
|
54 |
-* Find the first occurrence of find in s, where the search is limited to the |
|
55 |
-* first slen characters of s. |
|
56 |
-*/ |
|
57 |
-char * _strnstr(const char* s, const char* find, size_t slen) |
|
58 |
-{ |
|
59 |
- char c, sc; |
|
60 |
- size_t len; |
|
61 |
- |
|
62 |
- if ((c = *find++) != '\0') { |
|
63 |
- len = strlen(find); |
|
64 |
- do { |
|
65 |
- do { |
|
66 |
- if (slen-- < 1 || (sc = *s++) == '\0') |
|
67 |
- return (NULL); |
|
68 |
- } while (sc != c); |
|
69 |
- if (len > slen) |
|
70 |
- return (NULL); |
|
71 |
- } while (strncmp(s, find, len) != 0); |
|
72 |
- s--; |
|
73 |
- } |
|
74 |
- return ((char *)s); |
|
75 |
-} |
|
76 |
- |
|
77 |
-/* |
|
78 |
- * Find the first case insensitive occurrence of find in s, where the |
|
79 |
- * search is limited to the first slen characters of s. |
|
80 |
- * Based on FreeBSD strnstr. |
|
81 |
- */ |
|
82 |
-char* _strnistr(const char *s, const char *find, size_t slen) |
|
83 |
-{ |
|
84 |
- char c, sc; |
|
85 |
- size_t len; |
|
86 |
- |
|
87 |
- if ((c = *find++) != '\0') { |
|
88 |
- len = strlen(find); |
|
89 |
- do { |
|
90 |
- do { |
|
91 |
- if ((sc = *s++) == '\0' || slen-- < 1) |
|
92 |
- return (NULL); |
|
93 |
- } while (sc != c); |
|
94 |
- if (len > slen) |
|
95 |
- return (NULL); |
|
96 |
- } while (strncasecmp(s, find, len) != 0); |
|
97 |
- s--; |
|
98 |
- } |
|
99 |
- return ((char *)s); |
|
100 |
-} |
|
101 |
- |
- alternative to strnstr() which is not in all OSes, pluse the
insensitive option
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
/* |
2 | 2 |
* |
3 |
+ * Copyright (C) 2015 kamailio.org |
|
3 | 4 |
* Copyright (C) 2014 Victor Seva <vseva@sipwise.com> |
4 | 5 |
* |
5 | 6 |
* This file is part of kamailio, a free SIP server. |
... | ... |
@@ -48,3 +49,53 @@ int str_append(str *orig, str *suffix, str *dest) |
48 | 49 |
memcpy(dest->s+orig->len, suffix->s, suffix->len); |
49 | 50 |
return 0; |
50 | 51 |
} |
52 |
+ |
|
53 |
+/* |
|
54 |
+* Find the first occurrence of find in s, where the search is limited to the |
|
55 |
+* first slen characters of s. |
|
56 |
+*/ |
|
57 |
+char * _strnstr(const char* s, const char* find, size_t slen) |
|
58 |
+{ |
|
59 |
+ char c, sc; |
|
60 |
+ size_t len; |
|
61 |
+ |
|
62 |
+ if ((c = *find++) != '\0') { |
|
63 |
+ len = strlen(find); |
|
64 |
+ do { |
|
65 |
+ do { |
|
66 |
+ if (slen-- < 1 || (sc = *s++) == '\0') |
|
67 |
+ return (NULL); |
|
68 |
+ } while (sc != c); |
|
69 |
+ if (len > slen) |
|
70 |
+ return (NULL); |
|
71 |
+ } while (strncmp(s, find, len) != 0); |
|
72 |
+ s--; |
|
73 |
+ } |
|
74 |
+ return ((char *)s); |
|
75 |
+} |
|
76 |
+ |
|
77 |
+/* |
|
78 |
+ * Find the first case insensitive occurrence of find in s, where the |
|
79 |
+ * search is limited to the first slen characters of s. |
|
80 |
+ * Based on FreeBSD strnstr. |
|
81 |
+ */ |
|
82 |
+char* _strnistr(const char *s, const char *find, size_t slen) |
|
83 |
+{ |
|
84 |
+ char c, sc; |
|
85 |
+ size_t len; |
|
86 |
+ |
|
87 |
+ if ((c = *find++) != '\0') { |
|
88 |
+ len = strlen(find); |
|
89 |
+ do { |
|
90 |
+ do { |
|
91 |
+ if ((sc = *s++) == '\0' || slen-- < 1) |
|
92 |
+ return (NULL); |
|
93 |
+ } while (sc != c); |
|
94 |
+ if (len > slen) |
|
95 |
+ return (NULL); |
|
96 |
+ } while (strncasecmp(s, find, len) != 0); |
|
97 |
+ s--; |
|
98 |
+ } |
|
99 |
+ return ((char *)s); |
|
100 |
+} |
|
101 |
+ |
... | ... |
@@ -1,5 +1,4 @@ |
1 |
-/** |
|
2 |
- * $Id$ |
|
1 |
+/* |
|
3 | 2 |
* |
4 | 3 |
* Copyright (C) 2014 Victor Seva <vseva@sipwise.com> |
5 | 4 |
* |
... | ... |
@@ -17,6 +16,12 @@ |
17 | 16 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
18 | 17 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
19 | 18 |
*/ |
19 |
+/*! |
|
20 |
+ * \file |
|
21 |
+ * \brief Kamailio core :: Append to str data |
|
22 |
+ * \ingroup core |
|
23 |
+ * Module: \ref core |
|
24 |
+ */ |
|
20 | 25 |
|
21 | 26 |
#include <string.h> |
22 | 27 |
#include "str.h" |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,45 @@ |
1 |
+/** |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * Copyright (C) 2014 Victor Seva <vseva@sipwise.com> |
|
5 |
+ * |
|
6 |
+ * This file is part of kamailio, a free SIP server. |
|
7 |
+ * |
|
8 |
+ * Permission to use, copy, modify, and distribute this software for any |
|
9 |
+ * purpose with or without fee is hereby granted, provided that the above |
|
10 |
+ * copyright notice and this permission notice appear in all copies. |
|
11 |
+ * |
|
12 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
13 |
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
14 |
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
15 |
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
16 |
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
17 |
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
18 |
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#include <string.h> |
|
22 |
+#include "str.h" |
|
23 |
+#include "mem/mem.h" |
|
24 |
+ |
|
25 |
+int str_append(str *orig, str *suffix, str *dest) |
|
26 |
+{ |
|
27 |
+ if(orig == NULL || suffix == NULL || suffix->len == 0 || dest == NULL) |
|
28 |
+ { |
|
29 |
+ LM_ERR("wrong parameters\n"); |
|
30 |
+ return -1; |
|
31 |
+ } |
|
32 |
+ dest->len = orig->len + suffix->len; |
|
33 |
+ dest->s = pkg_malloc(sizeof(char)*dest->len); |
|
34 |
+ if(dest->s==NULL) |
|
35 |
+ { |
|
36 |
+ LOG(L_ERR, "memory allocation failure\n"); |
|
37 |
+ return -1; |
|
38 |
+ } |
|
39 |
+ if(orig->len>0) |
|
40 |
+ { |
|
41 |
+ memcpy(dest->s, orig->s, orig->len); |
|
42 |
+ } |
|
43 |
+ memcpy(dest->s+orig->len, suffix->s, suffix->len); |
|
44 |
+ return 0; |
|
45 |
+} |