POK(kernelpart)
strcmp.c
Go to the documentation of this file.
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 #if defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_PORTS_QUEUEING) || defined (POK_NEEDS_PORTS_SAMPLING)
18 
19 #include <libc.h>
20 
21 __attribute__ ((weak))
22 int strcmp (const char *s1,
23  const char *s2)
24 {
25  unsigned int i;
26 
27  for (i = 0; ; i++)
28  {
29  if (s1[i] == '\0' && s2[i] == '\0')
30  {
31  return 0;
32  }
33  if (s1[i] < s2[i])
34  {
35  return -1;
36  }
37  if (s1[i] > s2[i])
38  {
39  return 1;
40  }
41  }
42 }
43 
44 __attribute__ ((weak))
45 int strncmp (const char *s1,
46  const char *s2,
47  size_t size)
48 {
49  unsigned int i;
50 
51  for (i = 0; i < size; i++)
52  {
53  if (s1[i] == '\0' && s2[i] == '\0')
54  {
55  return 0;
56  }
57  if (s1[i] < s2[i])
58  {
59  return -1;
60  }
61  if (s1[i] > s2[i])
62  {
63  return 1;
64  }
65  }
66  return 0;
67 }
68 
69 #endif
70