[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 | *******************************************************************************************/ |
---|
| 37 | uint32_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 | *******************************************************************************************/ |
---|
| 46 | uint32_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 | *******************************************************************************************/ |
---|
| 58 | int 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 | *******************************************************************************************/ |
---|
| 70 | int 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 | *******************************************************************************************/ |
---|
| 81 | int strcasecmp ( const char * s1, |
---|
| 82 | const char * s2 ); |
---|
| 83 | |
---|
| 84 | /******************************************************************************************** |
---|
| 85 | * TODO |
---|
| 86 | ******************************************************************************************** |
---|
| 87 | *******************************************************************************************/ |
---|
| 88 | char * strcpy ( char * dest, |
---|
| 89 | char * src ); |
---|
| 90 | |
---|
| 91 | /******************************************************************************************** |
---|
| 92 | * TODO |
---|
| 93 | ******************************************************************************************** |
---|
| 94 | *******************************************************************************************/ |
---|
| 95 | char * strncpy ( char * dest, |
---|
| 96 | char * src, |
---|
| 97 | uint32_t n ); |
---|
| 98 | |
---|
| 99 | /******************************************************************************************** |
---|
| 100 | * TODO |
---|
| 101 | ******************************************************************************************** |
---|
| 102 | *******************************************************************************************/ |
---|
| 103 | char * strchr ( const char * s, |
---|
| 104 | int c ); |
---|
| 105 | |
---|
| 106 | /******************************************************************************************** |
---|
| 107 | * TODO |
---|
| 108 | ******************************************************************************************** |
---|
| 109 | *******************************************************************************************/ |
---|
| 110 | char * strrchr ( const char * t, |
---|
| 111 | int c ); |
---|
| 112 | |
---|
| 113 | #endif /* _STRING_H_ */ |
---|