Development of CoAP-HTTP Proxy
[platform/upstream/iotivity.git] / resource / c_common / oic_string / include / oic_string.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20 #ifndef OIC_STRING_H_
21 #define OIC_STRING_H_
22
23 #include <stddef.h>
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif // __cplusplus
28
29 /**
30  * Duplicates the source string and returns it.
31  *
32  * @note Caller needs to release this memory by calling OICFree().
33  *
34  * @param str Original valid string which needs to be duplicated.
35  *
36  * @return a pointer to the duplicated string
37  */
38 char *OICStrdup(const char *str);
39
40 /**
41  * Convert source string to lower case characters.
42  *
43  * @param str Original valid string which needs to be converted.
44  *
45  */
46 void OICStringToLower(char* str);
47
48 /**
49  * Copies a C string into destination buffer.  Ensures that the destination
50  * is null terminated.
51  *
52  * @param dest Destination C buffer.
53  * @param destSize The allocated size of the destination parameter.
54  * @param source Source C string.
55  *
56  * @return
57  *      returns a pointer to the passed in 'dest' parameter
58  */
59 char* OICStrcpy(char* dest, size_t destSize, const char* source);
60
61 /**
62  * Appends a C string into a previously allocated and initialized C string in a buffer. dest
63  * parameter is guaranteed to be null-terminated.
64  *
65  * @param dest Destination C buffer containing initial string.
66  * @param destSize The allocated size of the destination parameter.
67  * @param source Source C string.
68  *
69  * @return
70  *      returns a pointer to the passed in 'dest' parameter
71  */
72 char* OICStrcat(char* dest, size_t destSize, const char* source);
73
74 /**
75  * Copies a partial C string into destination buffer.
76  * Ensures that the destination is null terminated.
77  *
78  * @param dest Destination C buffer.
79  * @param destSize The allocated size of the destination parameter.
80  * @param source Source C string.
81  * @param sourceLen maximum number of characters to copy.
82  *
83  * @return
84  *      returns a pointer to the passed in 'dest' parameter
85  */
86 char* OICStrcpyPartial(char* dest, size_t destSize, const char* source, size_t sourceLen);
87
88 /**
89  * Appends a C string into a previously allocated and initialized C string in a buffer. dest
90  * parameter is guaranteed to be null-terminated.
91  *
92  * @param dest Destination C buffer containing initial string.
93  * @param destSize The allocated size of the destination parameter.
94  * @param source Source C string.
95  * @param sourceLen maximum number of characters to append, not including null termination
96  *
97  * @return
98  *      returns a pointer to the passed in 'dest' parameter
99  */
100 char* OICStrcatPartial(char* dest, size_t destSize, const char* source, size_t sourceLen);
101
102 #ifdef __cplusplus
103 }
104 #endif // __cplusplus
105 #endif // OIC_STRING_H_