Toyomasa Watarai
/
Mbed-example-WS-W27
Mbed Cloud example program for workshop in W27 2018.
Embed:
(wiki syntax)
Show/hide line numbers
uriqueryparser.cpp
00001 // ---------------------------------------------------------------------------- 00002 // Copyright 2016-2017 ARM Ltd. 00003 // 00004 // SPDX-License-Identifier: Apache-2.0 00005 // 00006 // Licensed under the Apache License, Version 2.0 (the "License"); 00007 // you may not use this file except in compliance with the License. 00008 // You may obtain a copy of the License at 00009 // 00010 // http://www.apache.org/licenses/LICENSE-2.0 00011 // 00012 // Unless required by applicable law or agreed to in writing, software 00013 // distributed under the License is distributed on an "AS IS" BASIS, 00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 // See the License for the specific language governing permissions and 00016 // limitations under the License. 00017 // ---------------------------------------------------------------------------- 00018 00019 #include <string.h> 00020 #include "include/uriqueryparser.h" 00021 00022 char* query_string(char* uri) 00023 { 00024 char* query = strchr((char*)uri, '?'); 00025 if (query != NULL) { 00026 query++; 00027 if (*query == '\0') { 00028 return NULL; 00029 } else { 00030 return query; 00031 } 00032 } else { 00033 return NULL; 00034 } 00035 } 00036 00037 int8_t query_param_count(char* query) 00038 { 00039 int param_count = 0; 00040 while (NULL != (query = strchr(query, '='))) { 00041 param_count++; 00042 ++query; 00043 } 00044 return param_count; 00045 } 00046 00047 bool uri_query_parameters(char* query, char *uri_query_parameters[], int index) 00048 { 00049 if (query == NULL || *query == '\0' || index < 0) { 00050 return false; 00051 } 00052 00053 uri_query_parameters[index++] = query; 00054 while (NULL != (query = strchr(query, '&'))) { 00055 *query = '\0'; 00056 uri_query_parameters[index] = ++query; 00057 index++; 00058 } 00059 00060 return true; 00061 }
Generated on Tue Jul 12 2022 16:22:13 by 1.7.2