const char *DINO_EXPORT params_get(DHANDLE dhandle, const char *key) { dino_http_request_t *request = cast_dhandle_request(dhandle); if (NULL != request) { return dino_strmap_get_value(request->params_map, key); } return ""; }
bool dino_strmap_add(str_map_t *map, const char *key, const char *value) { if (NULL == map || NULL == key || NULL == value) { return false; } size_t length = strlen(value); // If it an empty string, just ignore it. // if (0 == length) { return true; } // Create a local copy // char *local_value = alloca(length + 1); strcpy(local_value, value); // Trim out the "white space" // local_value = trim_whitespace(local_value); // Is there anything left? // if (0 == strlen(local_value)) { return true; } // Check to see if it exists. // if (dino_strmap_exists(map, key)) { // Get the current value // char *new_value = NULL; asprintf(&new_value, "%s, %s", dino_strmap_get_value(map, key), local_value); bool result = false; if (new_value) { result = dino_strmap_put(map, key, new_value); free(new_value); } return result; } return dino_strmap_put(map, key, value); }