mhd_has_param.h (1727B)
1 /* 2 This file is part of libmicrohttpd 3 Copyright (C) 2016-2022 Karlson2k (Evgeny Grin) 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 /** 21 * @file testcurl/mhd_has_param.h 22 * @brief Static functions and macros helpers for testsuite. 23 * @author Karlson2k (Evgeny Grin) 24 */ 25 26 #include <string.h> 27 28 29 /** 30 * Check whether one of strings in array is equal to @a param. 31 * String @a argv[0] is ignored. 32 * @param argc number of strings in @a argv, as passed to main function 33 * @param argv array of strings, as passed to main function 34 * @param param parameter to look for. 35 * @return zero if @a argv is NULL, @a param is NULL or empty string, 36 * @a argc is less then 2 or @a param is not found in @a argv, 37 * non-zero if one of strings in @a argv is equal to @a param. 38 */ 39 static int 40 has_param (int argc, char *const argv[], const char *param) 41 { 42 int i; 43 if (! argv || ! param || ! param[0]) 44 return 0; 45 46 for (i = 1; i < argc; i++) 47 { 48 if (argv[i] && (strcmp (argv[i], param) == 0) ) 49 return ! 0; 50 } 51 52 return 0; 53 }