Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* Project: OSLib |
2 | * Description: The OS Construction Kit |
||
3 | * Date: 1.6.2000 |
||
4 | * Idea by: Luca Abeni & Gerardo Lamastra |
||
5 | * |
||
6 | * OSLib is an SO project aimed at developing a common, easy-to-use |
||
7 | * low-level infrastructure for developing OS kernels and Embedded |
||
8 | * Applications; it partially derives from the HARTIK project but it |
||
9 | * currently is independently developed. |
||
10 | * |
||
11 | * OSLib is distributed under GPL License, and some of its code has |
||
12 | * been derived from the Linux kernel source; also some important |
||
13 | * ideas come from studying the DJGPP go32 extender. |
||
14 | * |
||
15 | * We acknowledge the Linux Community, Free Software Foundation, |
||
16 | * D.J. Delorie and all the other developers who believe in the |
||
17 | * freedom of software and ideas. |
||
18 | * |
||
19 | * For legalese, check out the included GPL license. |
||
20 | */ |
||
21 | |||
22 | #include <ll/i386/string.h> |
||
23 | |||
24 | FILE(string); |
||
25 | |||
26 | char *strcpy(char *dst,const char *src) |
||
27 | { |
||
28 | char *retval = dst; |
||
29 | while (*src != 0) *dst++ = *src++; |
||
30 | *dst = 0; |
||
31 | return(retval); |
||
32 | } |
||
33 | |||
34 | char *strncpy(char *dst,const char *src,int n) |
||
35 | { |
||
36 | char *retval = dst; |
||
37 | while (*src != 0 && n-- > 0) *dst++ = *src++; |
||
38 | *dst = 0; |
||
39 | return(retval); |
||
40 | } |
||
41 | |||
42 | int strcmp(const char *s1,const char *s2) |
||
43 | { |
||
44 | while (*s1 == *s2) { |
||
45 | if (*s1 == 0) return 0; |
||
46 | s1++; |
||
47 | s2++; |
||
48 | } |
||
49 | return *(unsigned const char *)s1 - *(unsigned const char *)(s2); |
||
50 | } |
||
51 | |||
52 | int strncmp(const char *s1,const char *s2,int n) |
||
53 | { |
||
54 | if (n == 0) return 0; |
||
55 | do { |
||
56 | if (*s1 != *s2++) |
||
57 | return *(unsigned const char *)s1 - *(unsigned const char *)--s2; |
||
58 | if (*s1++ == 0) break; |
||
59 | } while (--n != 0); |
||
60 | return 0; |
||
61 | } |
||
62 | |||
63 | char *strupr(char *s) |
||
64 | { |
||
65 | char *base = s; |
||
66 | while (*s != 0) { |
||
67 | if (*s >= 'a' && *s <= 'z') |
||
68 | *s = *s + 'A' -'a'; |
||
69 | s++; |
||
70 | } |
||
71 | return(base); |
||
72 | } |
||
73 | |||
74 | char *strlwr(char *s) |
||
75 | { |
||
76 | char *base = s; |
||
77 | while (*s != 0) { |
||
78 | if (*s >= 'A' && *s <= 'Z') |
||
79 | *s = *s + 'a' -'A'; |
||
80 | s++; |
||
81 | } |
||
82 | return(base); |
||
83 | } |
||
84 | |||
85 | int strlen(const char *s) |
||
86 | { |
||
87 | register int result = 0; |
||
88 | while (*s != 0) s++ , result++; |
||
89 | return(result); |
||
90 | } |
||
91 | |||
92 | char *strcat(char *dst,char *src) |
||
93 | { |
||
94 | char *base = dst; |
||
95 | while (*dst != 0) dst++; |
||
96 | while (*src != 0) *dst++ = *src++; |
||
97 | *dst = 0; |
||
98 | return(base); |
||
99 | } |
||
100 | |||
101 | char *strscn(char *s,char *pattern) |
||
102 | { |
||
103 | char *scan; |
||
104 | while (*s != 0) { |
||
105 | scan = pattern; |
||
106 | while (*scan != 0) { |
||
107 | if (*s == *scan) return(s); |
||
108 | else scan++; |
||
109 | } |
||
110 | s++; |
||
111 | } |
||
112 | return(NULL); |
||
113 | } |
||
114 | |||
115 | char *strchr(char *s,int c) |
||
116 | { |
||
117 | while (*s != 0) { |
||
118 | if (*s == (char)(c)) return(s); |
||
119 | else s++; |
||
120 | } |
||
121 | return(NULL); |
||
122 | } |