POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/libc/strcmp.c
Go to the documentation of this file.
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00017 #if defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_PORTS_QUEUEING) || defined (POK_NEEDS_PORTS_SAMPLING)
00018 
00019 #include <libc.h>
00020 
00021 __attribute__ ((weak))
00022 int strcmp (const char *s1,
00023             const char *s2)
00024 {
00025    unsigned int i;
00026 
00027    for (i = 0; ; i++)
00028    {
00029       if (s1[i] == '\0' && s2[i] == '\0')
00030       {
00031          return 0;
00032       }
00033       if (s1[i] < s2[i])
00034       {
00035          return -1;
00036       }
00037       if (s1[i] > s2[i])
00038       {
00039          return 1;
00040       }
00041    }
00042 }
00043 
00044 __attribute__ ((weak))
00045 int strncmp (const char *s1,
00046              const char *s2,
00047              size_t size)
00048 {
00049    unsigned int i;
00050 
00051    for (i = 0; i < size; i++)
00052    {
00053       if (s1[i] == '\0' && s2[i] == '\0')
00054       {
00055          return 0;
00056       }
00057       if (s1[i] < s2[i])
00058       {
00059          return -1;
00060       }
00061       if (s1[i] > s2[i])
00062       {
00063          return 1;
00064       }
00065    }
00066    return 0;
00067 }
00068 
00069 #endif
00070