libc - Fixed an embarrasing bug in strchr :|
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / lib.c
index d327213..28fb467 100644 (file)
@@ -1,30 +1,62 @@
-/*\r
- AcessOS 1\r
- Dynamic Loader\r
- By thePowersGang\r
-*/\r
-#include "common.h"\r
-\r
-// === CODE ===\r
-void strcpy(char *dest, char *src)\r
-{\r
-       while(*src) {\r
-               *dest = *src;\r
-               src ++; dest ++;\r
-       }\r
-       *dest = '\0';\r
+/*
+ AcessOS 1
+ Dynamic Loader
+ By thePowersGang
+*/
+#include "common.h"
+
+// === CODE ===
+char *strcpy(char *dest, const char *src)
+{
+       char    *ret = dest;
+       while(*src) {
+               *dest = *src;
+               src ++; dest ++;
+       }
+       *dest = '\0';
+       return ret;
+}
+
+char *strcat(char *dest, const char *src)
+{
+       char    *ret = dest;
+       while(*dest)    dest++;
+       while(*src)             *dest++ = *src++;
+       *dest = '\0';
+       return ret;
 }
 
-int strcmp(char *s1, char *s2)
+/**
+ * \fn int strcmp(const char *s1, const char *s2)
+ * \brief Compare two strings
+ */
+int strcmp(const char *s1, const char *s2)
 {
-       while(*s1 == *s2 && *s1 != 0) s1++,s2++;
+       while(*s1 && *s1 == *s2) s1++,s2++;
        return *s1-*s2;
-}\r
-\r
-int strlen(char *str)\r
-{\r
-        int    len = 0;\r
-       while(*str)     len++,str++;\r
-       return len;\r
 }
 
+/**
+ * \fn int strlen(const char *str)
+ * \brief 
+ */
+int strlen(const char *str)
+{
+        int    len = 0;
+       while(*str)     len++,str++;
+       return len;
+}
+
+/**
+ * \fn int file_exists(char *filename)
+ * \brief Checks if a file exists
+ */
+int file_exists(char *filename)
+{
+        int    fd;
+        //fd = open(filename, OPENFLAG_READ);
+        fd = open(filename, 0);
+        if(fd == -1)   return 0;
+        close(fd);
+        return 1;
+}

UCC git Repository :: git.ucc.asn.au