xref: /dflybsd-src/contrib/grep/lib/strnlen1.h (revision 91b9ed38d3db6a8a8ac5b66da1d43e6e331e259a)
195b7b453SJohn Marino /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
2*09d4459fSDaniel Fojt    Copyright (C) 2005, 2009-2020 Free Software Foundation, Inc.
395b7b453SJohn Marino 
495b7b453SJohn Marino    This program is free software: you can redistribute it and/or modify
595b7b453SJohn Marino    it under the terms of the GNU General Public License as published by
695b7b453SJohn Marino    the Free Software Foundation; either version 3 of the License, or
795b7b453SJohn Marino    (at your option) any later version.
895b7b453SJohn Marino 
995b7b453SJohn Marino    This program is distributed in the hope that it will be useful,
1095b7b453SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
1195b7b453SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1295b7b453SJohn Marino    GNU General Public License for more details.
1395b7b453SJohn Marino 
1495b7b453SJohn Marino    You should have received a copy of the GNU General Public License
15*09d4459fSDaniel Fojt    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
1695b7b453SJohn Marino 
1795b7b453SJohn Marino #ifndef _STRNLEN1_H
1895b7b453SJohn Marino #define _STRNLEN1_H
1995b7b453SJohn Marino 
2095b7b453SJohn Marino #include <stddef.h>
2195b7b453SJohn Marino 
2295b7b453SJohn Marino 
2395b7b453SJohn Marino #ifdef __cplusplus
2495b7b453SJohn Marino extern "C" {
2595b7b453SJohn Marino #endif
2695b7b453SJohn Marino 
2795b7b453SJohn Marino 
2895b7b453SJohn Marino /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
2995b7b453SJohn Marino    If no '\0' terminator is found in that many characters, return MAXLEN.  */
3095b7b453SJohn Marino /* This is the same as strnlen (string, maxlen - 1) + 1.  */
31cf28ed85SJohn Marino extern size_t strnlen1 (const char *string, size_t maxlen)
32cf28ed85SJohn Marino   _GL_ATTRIBUTE_PURE;
3395b7b453SJohn Marino 
3495b7b453SJohn Marino 
3595b7b453SJohn Marino #ifdef __cplusplus
3695b7b453SJohn Marino }
3795b7b453SJohn Marino #endif
3895b7b453SJohn Marino 
3995b7b453SJohn Marino 
4095b7b453SJohn Marino #endif /* _STRNLEN1_H */
41