source: trunk/kernel/libk/string.h @ 160

Last change on this file since 160 was 23, checked in by alain, 7 years ago

Introduce syscalls.

File size: 6.1 KB
RevLine 
[1]1/*
2 * string.h - string related helper functions definition.
3 *
4 * Authors      Ghassan Almaless (2007,2009,2010,2011,2012)
5 *              Alain Greiner (2017)
6 *
7 * Copyright (c) UPMC Sorbonne Universites
8 *
9 * This file is part of ALMOS-MKH.
10 *
11 * ALMOS-MKH is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2.0 of the License.
14 *
15 * ALMOS-MKH is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#ifndef _STRING_H_
26#define _STRING_H_
27
28#include <hal_types.h>
29
30
31/********************************************************************************************
32 * This function returns the length of a character string.
33 ********************************************************************************************
34 * @ s     : pointer on the string.
35 * @ return the number of characters preceding the NUL character.
36 *******************************************************************************************/
37uint32_t strlen( const char * s );
38
39/********************************************************************************************
40 * This function attempts to compute the length of a string, but never scans beyond
41 * <maxlen> characters.
42 ********************************************************************************************
43 * @ s     : pointer on the string.
44 * returns min( maxlen , number of characters preceding the NUL character).
45 *******************************************************************************************/
46uint32_t strnlen( const char * str, 
47                  uint32_t     maxlen );
48
49/********************************************************************************************
50 * This function compares lexicographically the strind s1 and s2.
51 * characters are considered unsigned.
52 * I does not compare characters after the first NUL character.
53 ********************************************************************************************
54 * @ s1   : pointer on string.
55 * @ s2   : pointer on string.
56 * @ return 0 if s1 == s2 / return 1 if s1 > s2 / return -1 if s1 < s2
57 *******************************************************************************************/
58int strcmp ( const char * s1, 
59             const char * s2 );
60
61/********************************************************************************************
62 * This function compares lexicographically the strind s1 and s2.
63 * I does not compare than <n> characters and stops after the first NUL character.
64 ********************************************************************************************
65 * @ s1   : pointer on string.
66 * @ s2   : pointer on string.
67 * @ n    : max number of compared characters.
68 * @ return 0 if s1 == s2 / return 1 if s1 > s2 / return -1 if s1 < s2
69 *******************************************************************************************/
70int strncmp ( const char * s1,
71              const char * s2,
72              uint32_t     n );
73
74/********************************************************************************************
75 * This function compares lexicographically the strind s1 and s2, ignoring case.
76 ********************************************************************************************
77 * @ s1   : pointer on string.
78 * @ s2   : pointer on string.
79 * @ return 0 if s1 == s2 / return 1 if s1 > s2 / return -1 if s1 < s2
80 *******************************************************************************************/
81int strcasecmp ( const char * s1,
82                 const char * s2 );
83
84/********************************************************************************************
[23]85 * this function copies the <src> buffer to the <dst> buffer, including the terminating NUL.
[1]86 ********************************************************************************************
[23]87 * @ dst   : pointer on destination buffer.
88 * @ src   : pointer on source buffer.
[1]89 *******************************************************************************************/
[23]90char * strcpy ( char * dst, 
[1]91                char * src );
92
93/********************************************************************************************
[23]94 * This function copies <n> characters from the <sr> buffer to the <dst> buffer.
[1]95 ********************************************************************************************
[23]96 * @ dst   : pointer on destination buffer.
97 * @ src   : pointer on source buffer.
98 * @ n     : number of characters to be copied.
[1]99 *******************************************************************************************/
[23]100char * strncpy ( char    * dst,
[1]101                 char    * src,
102                 uint32_t  n );
103
104/********************************************************************************************
[23]105 * This function locates the first occurence of the <c> character in the <s> string.
[1]106 ********************************************************************************************
[23]107 * @ s     : string to be analysed.
108 * @ c     : searched character value (casted to a char)
109 * @ return pointer on the found character / return NULL if not found.
[1]110 *******************************************************************************************/
111char * strchr ( const char * s,
112                int          c );
113
114/********************************************************************************************
[23]115 * This function locates the last occurence of the <c> character in the <s> string.
[1]116 ********************************************************************************************
[23]117 * @ s     : string to be analysed.
118 * @ c     : searched character value (casted to a char)
119 * @ return pointer on the found character / return NULL if not found.
[1]120 *******************************************************************************************/
121char * strrchr ( const char * t,
122                 int          c );
123
124#endif  /* _STRING_H_ */
Note: See TracBrowser for help on using the repository browser.