/*
* getcgivars.c - routine to read CGI input variables into an array.
*
- * Jonathan McDowell <noodles@earth.li>
+ * Copyright 2002 Jonathan McDowell <noodles@earth.li>
*
* The x2c() and unescape_url() routines were lifted directly
* from NCSA's sample program util.c, packaged with their HTTPD.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
for(i=0; cgiinput[i]; i++) if (cgiinput[i]=='+') cgiinput[i] = ' ';
/* First, split on "&" to extract the name-value pairs into pairlist */
- pairlist=(char **) malloc(256*sizeof(char **));
+ pairlist= malloc(256*sizeof(char *));
paircount=0;
nvpair=strtok(cgiinput, "&");
while (nvpair) {
pairlist[paircount++]= strdup(nvpair) ;
if (!(paircount%256)) {
- pairlist=(char **) realloc(pairlist,
- (paircount+256)*sizeof(char **));
+ pairlist= realloc(pairlist,
+ (paircount+256)*sizeof(char *));
}
nvpair=strtok(NULL, "&") ;
}
/* Then, from the list of pairs, extract the names and values */
- cgivars=(char **) malloc((paircount*2+1)*sizeof(char **));
+ cgivars= malloc((paircount*2+1)*sizeof(char *));
for (i=0; i<paircount; i++) {
if ((eqpos=strchr(pairlist[i], '='))!=NULL) {