summaryrefslogtreecommitdiff
path: root/src/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c
index 6aa46ef..9be5e43 100644
--- a/src/string.c
+++ b/src/string.c
@@ -40,3 +40,33 @@ size_t strlen( const char *s )
return len;
}
+
+int strcmp( const char *s1, const char *s2 )
+{
+ while( *s1 && *s2 && *s1 == *s2 ) {
+ s1++;
+ s2++;
+ }
+
+ return *s1 - *s2;
+}
+
+size_t strlcpy( char *d, const char *s, size_t n )
+{
+ size_t len = 0;
+
+ while( len < n && s[len] ) {
+ d[len] = s[len];
+ len++;
+ }
+
+ while( s[len] ) {
+ len++;
+ }
+
+ if( len >= n ) {
+ d[n-1] = '\0';
+ }
+
+ return len;
+}