Ignore:
Timestamp:
Nov 16, 2006, 12:23:56 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Implemented strcmp() and strdup() and added an fflush() stub to the kernel code.
Location:
libcaca/trunk/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/kernel/kernel.c

    r1065 r1415  
    165165}
    166166
     167int strcmp(const char *s1, const char *s2)
     168{
     169    while(*s1 && *s1 == *s2)
     170    {
     171        s1++;
     172        s2++;
     173    }
     174
     175    return (int)*s1 - (int)*s2;
     176}
     177
    167178int strcasecmp(const char *s1, const char *s2)
    168179{
     
    190201}
    191202
     203char *strdup(const char *s)
     204{
     205    char *new;
     206    unsigned int len = strlen(s);
     207
     208    new = malloc(len + 1);
     209    memcpy(new, s, len + 1);
     210
     211    return new;
     212}
     213
    192214/* stdarg.h functions */
    193215int vsnprintf(char *str, size_t size, const char *format, va_list ap)
     
    234256
    235257int fprintf(FILE *stream, const char *format, ...)
     258{
     259    /* FIXME */
     260    return 0;
     261}
     262
     263int fflush(FILE *stream)
    236264{
    237265    /* FIXME */
  • libcaca/trunk/kernel/kernel.h

    r1065 r1415  
    8383void *memcpy(void *dest, const void *src, size_t n);
    8484size_t strlen(const char *s);
     85int strcmp(const char *s1, const char *s2);
    8586int strcasecmp(const char *s1, const char *s2);
    8687int memcmp(const void *s1, const void *s2, size_t n);
     88char *strdup(const char *s);
    8789
    8890/* stdarg.h functions */
     
    100102int printf(const char *format, ...);
    101103int fprintf(FILE *stream, const char *format, ...);
     104int fflush(FILE *stream);
    102105int sprintf(char *str, const char *format, ...);
    103106int sscanf(const char *str, const char *format, ...);
Note: See TracChangeset for help on using the changeset viewer.