1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
30 * Duplicates the source string and returns it.
32 * @note Caller needs to release this memory by calling OICFree().
34 * @param str Original valid string which needs to be duplicated.
36 * @return a pointer to the duplicated string
38 char *OICStrdup(const char *str);
41 * Copies a C string into destination buffer. Ensures that the destination
44 * @param dest Destination C buffer.
45 * @param destSize The allocated size of the destination parameter.
46 * @param source Source C string.
49 * returns a pointer to the passed in 'dest' parameter
51 char* OICStrcpy(char* dest, size_t destSize, const char* source);
54 * Appends a C string into a previously allocated and initialized C string in a buffer. dest
55 * parameter is guaranteed to be null-terminated.
57 * @param dest Destination C buffer containing initial string.
58 * @param destSize The allocated size of the destination parameter.
59 * @param source Source C string.
62 * returns a pointer to the passed in 'dest' parameter
64 char* OICStrcat(char* dest, size_t destSize, const char* source);
67 * Copies a partial C string into destination buffer.
68 * Ensures that the destination is null terminated.
70 * @param dest Destination C buffer.
71 * @param destSize The allocated size of the destination parameter.
72 * @param source Source C string.
73 * @param sourceLen maximum number of characters to copy.
76 * returns a pointer to the passed in 'dest' parameter
78 char* OICStrcpyPartial(char* dest, size_t destSize, const char* source, size_t sourceLen);
81 * Appends a C string into a previously allocated and initialized C string in a buffer. dest
82 * parameter is guaranteed to be null-terminated.
84 * @param dest Destination C buffer containing initial string.
85 * @param destSize The allocated size of the destination parameter.
86 * @param source Source C string.
87 * @param sourceLen maximum number of characters to append, not including null termination
90 * returns a pointer to the passed in 'dest' parameter
92 char* OICStrcatPartial(char* dest, size_t destSize, const char* source, size_t sourceLen);
97 #endif // OIC_STRING_H_