michael@427: // michael@427: // Stubfunc - Stubs to replace missing functions in third party projects michael@427: // Copyright © 2012 Michael Schloh von Bennewitz michael@427: // michael@427: // Stubfunc is free software: you can redistribute it and/or modify michael@427: // it under the terms of the GNU General Public License as published michael@427: // by the Free Software Foundation, either version 3 of the License, michael@427: // or (at your option) any later version. michael@427: // michael@427: // Stubfunc is distributed in the hope that it will be useful, michael@427: // but WITHOUT ANY WARRANTY; without even the implied warranty michael@427: // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See michael@427: // the GNU General Public License for more details. michael@427: // michael@427: // You should have received a copy of the GNU General Public License michael@427: // along with Stubfunc. If not, see . michael@427: // michael@427: // This file implements a stub function and is part of a larger project, michael@427: // explanations of which can be found at http://dev.europalab.com/. michael@427: // michael@427: // rplstrnlen.c: ISO C99 implementation michael@427: // michael@427: michael@427: #include michael@427: michael@427: michael@427: ///* replacement for strnlen(3), missing in some POSIX distributions */ michael@427: //status size_t strnlen(const char *pckInstring, size_t Maxsize) { michael@427: // register const char *prckIdx; michael@427: // for(prckIdx = pckInstring; *prckIdx && Maxsize--; ++prckIdx); michael@427: // return(prckIdx - pckInstring); michael@427: //} michael@427: michael@427: /* replacement for strnlen(3), missing in some POSIX distributions */ michael@427: extern size_t rpl_strnlen(const char *pckInstring, size_t Maxsize) { michael@427: register const char *prckIdx; michael@427: for(prckIdx = pckInstring; *prckIdx && Maxsize--; ++prckIdx); michael@427: return(prckIdx - pckInstring); michael@427: }