⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 string.c

📁 freedos32的源代码
💻 C
字号:
/* Project:     OSLib * Description: The OS Construction Kit * Date:                1.6.2000 * Idea by:             Luca Abeni & Gerardo Lamastra * * OSLib is an SO project aimed at developing a common, easy-to-use * low-level infrastructure for developing OS kernels and Embedded * Applications; it partially derives from the HARTIK project but it * currently is independently developed. * * OSLib is distributed under GPL License, and some of its code has * been derived from the Linux kernel source; also some important * ideas come from studying the DJGPP go32 extender. * * We acknowledge the Linux Community, Free Software Foundation, * D.J. Delorie and all the other developers who believe in the * freedom of software and ideas. * * For legalese, check out the included GPL license. */#include <ll/i386/string.h>FILE(string);char *strcpy(char *dst,const char *src){    char *retval = dst;    while (*src != 0) *dst++ = *src++;    *dst = 0;    return(retval);}char *strncpy(char *dst, const char *src, int n){    char *p;    p = dst;    while (n > 0) {        if (*src != 0) {	    *p++ = *src++;        } else {	    *p++ = 0;        }        n--;    }        return dst;}int strcmp(const char *s1,const char *s2){    while (*s1 == *s2) {	if (*s1 == 0) return 0;	s1++;	s2++;    }    return *(unsigned const char *)s1 - *(unsigned const char *)(s2);}int strncmp(const char *s1,const char *s2,int n){    if (n == 0) return 0;    do {	if (*s1 != *s2++)	    return *(unsigned const char *)s1 - *(unsigned const char *)--s2;	if (*s1++ == 0) break;    } while (--n != 0);    return 0;}char *strupr(char *s){    char *base = s;    while (*s != 0) {	if (*s >= 'a' && *s <= 'z')           *s = *s + 'A' -'a';	s++;    }    return(base);}char *strlwr(char *s){    char *base = s;    while (*s != 0) {	if (*s >= 'A' && *s <= 'Z')	   *s = *s + 'a' -'A';	s++;    }    return(base);}int strlen(const char *s){    register int result = 0;    while (*s != 0) s++ , result++;    return(result);}char *strcat(char *dst,char *src){    char *base = dst;    while (*dst != 0) dst++;    while (*src != 0) *dst++ = *src++;    *dst = 0;    return(base);}char *strscn(char *s,char *pattern){    char *scan;    while (*s != 0) {    	scan = pattern;    	while (*scan != 0) {	    if (*s == *scan) return(s);	    else scan++;	}	s++;    }    return(NULL);}char *strchr(char *s,int c){    while (*s != 0) {	if (*s == (char)(c)) return(s);	else s++;    }    if (c == 0) {        return s;    }    return(NULL);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -