summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgary.li.wenchao.4 <[email protected]>2010-02-16 15:11:18 +0000
committergary.li.wenchao.4 <[email protected]>2010-02-16 15:11:18 +0000
commit6c82f5086f944f467f0a3ae86806fcbcc64d61ce (patch)
treeac6de947ea5b0fb89435a5ef516c7df8a45bd29d /src
parent6109cf575a7c3c44340adb1a4617371cf12a82e2 (diff)
add strlcpy
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@412 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'src')
-rw-r--r--src/kservice.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/kservice.c b/src/kservice.c
index 4a464b57dc..243d00cdfc 100644
--- a/src/kservice.c
+++ b/src/kservice.c
@@ -336,6 +336,26 @@ char *rt_strncpy(char *dest, const char *src, rt_ubase_t n)
}
/**
+ * This function will copy string no more than n bytes.
+ *
+ * @param dest the string to copy
+ * @param src the string to be copied
+ * @param n the maximum copied length
+ *
+ * @return the result with '\0' at the end
+ */
+char *rt_strlcpy(char *dest, const char *src, rt_ubase_t n)
+{
+ char *tmp = (char *) dest, *s = (char *) src;
+
+ while(n--)
+ *tmp++ = *s++;
+ *tmp = '\0';
+
+ return dest;
+}
+
+/**
* This function will compare two strings with specified maximum length
*
* @param cs the string to be compared