libc - Fixed an embarrasing bug in strchr :|
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / lib.c
1 /*
2  AcessOS 1
3  Dynamic Loader
4  By thePowersGang
5 */
6 #include "common.h"
7
8 // === CODE ===
9 char *strcpy(char *dest, const char *src)
10 {
11         char    *ret = dest;
12         while(*src) {
13                 *dest = *src;
14                 src ++; dest ++;
15         }
16         *dest = '\0';
17         return ret;
18 }
19
20 char *strcat(char *dest, const char *src)
21 {
22         char    *ret = dest;
23         while(*dest)    dest++;
24         while(*src)             *dest++ = *src++;
25         *dest = '\0';
26         return ret;
27 }
28
29 /**
30  * \fn int strcmp(const char *s1, const char *s2)
31  * \brief Compare two strings
32  */
33 int strcmp(const char *s1, const char *s2)
34 {
35         while(*s1 && *s1 == *s2) s1++,s2++;
36         return *s1-*s2;
37 }
38
39 /**
40  * \fn int strlen(const char *str)
41  * \brief 
42  */
43 int strlen(const char *str)
44 {
45          int    len = 0;
46         while(*str)     len++,str++;
47         return len;
48 }
49
50 /**
51  * \fn int file_exists(char *filename)
52  * \brief Checks if a file exists
53  */
54 int file_exists(char *filename)
55 {
56          int    fd;
57          //fd = open(filename, OPENFLAG_READ);
58          fd = open(filename, 0);
59          if(fd == -1)   return 0;
60          close(fd);
61          return 1;
62 }

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