// We'll try to parse the data from the form, and store it in the variables // that have been defined by the user in the 'form_variable_table'. char* cyg_httpd_store_form_data(char *p) { char *p2; cyg_int32 var_length; cyg_httpd_fvars_table_entry *entry = cyg_httpd_fvars_table; // We'll clear all the variables first, to avoid stale data. while (entry != cyg_httpd_fvars_table_end) { entry->buf[0] = '\0'; entry++; } if (!p) // No form data? just return after clearing variables. return NULL; while (*p && *p != ' ') { if (!(p2 = strchr(p, '='))) return NULL; // Malformed post? var_length = (cyg_int32)p2 - (cyg_int32)p; entry = cyg_httpd_fvars_table; while (entry != cyg_httpd_fvars_table_end) { // Compare both lenght and name. // If we do not compare the lenght of the variables as well we // risk the the case where, for instance, the variable name 'foo' // hits a match with a variable name 'foobar' because the first // 3 letters of the latter are the same as the former. if ((strlen(entry->name) == var_length) && (strncmp((const char*)p, entry->name, var_length ) == 0)) break; entry++; } if (entry == cyg_httpd_fvars_table_end) { // No such variable. Run through the data. while ((*p != '&') && (*p && *p != ' ')) p++; if(*p == '&') p++; continue; } // Found the variable, store the name. p = cyg_httpd_store_form_variable(++p2, entry); ATHTTPD_DEBUG_2("Stored form variable: %s Value: %s\n", entry->name, entry->buf); if (*p == '&') p++; } return p; }
// We'll try to parse the data from the form, and store it in the variables // that have been defined by the user in the 'form_variable_table'. char* cyg_httpd_store_form_data(char *p) { char *p2; cyg_int32 var_length; cyg_httpd_fvars_table_entry *entry = cyg_httpd_fvars_table; // We'll clear all the variables first, to avoid stale data. while (entry != cyg_httpd_fvars_table_end) { entry->buf[0] = '\0'; entry++; } if (!p) /* No form data? just return after clearing variables */ return NULL; while (*p && *p != ' ') { if (!(p2 = strchr(p, '='))) return NULL; /* Malformed post? */ var_length = (cyg_int32)p2 - (cyg_int32)p; entry = cyg_httpd_fvars_table; while (entry != cyg_httpd_fvars_table_end) { if (!strncmp((const char*)p, entry->name, var_length )) break; entry++; } if (entry == cyg_httpd_fvars_table_end) { // No such variable. Run through the data. while ((*p != '&') && (*p && *p != ' ')) p++; if(*p == '&') p++; continue; } // Found the variable, store the name. p = cyg_httpd_store_form_variable(++p2, entry); #if CYGOPT_NET_ATHTTPD_DEBUG_LEVEL > 1 diag_printf("Stored form variable: %s Value: %s\n", entry->name, entry->buf); #endif if (*p == '&') p++; } return p; }