source: trunk/libs/mini-libc/string.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

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