Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers uriqueryparser.h Source File

uriqueryparser.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2017 ARM Limited. All rights reserved.
00003  * SPDX-License-Identifier: Apache-2.0
00004  * Licensed under the Apache License, Version 2.0 (the License); you may
00005  * not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 #ifndef URIQUERYPARSER_H_
00022 #define URIQUERYPARSER_H_
00023 
00024 /*! \file uriqueryparser.h
00025  *  \brief Provides helper functions for parsing URI query parameters.
00026  */
00027 
00028 /**
00029  * @brief Parse a query parameter from URI and return the size of the parameter value and a pointer to the value within
00030  *        the URI.
00031  *
00032  * **Example usage:**
00033  * @code{.cpp}
00034  * char *value_ptr = NULL;
00035  * ssize_t value_len = parse_query_parameter_value_from_uri("http://www.myquery.com?someparameter=value", "someparameter", &value_ptr);
00036  * @endcode
00037  * will result in value_len = 5 and value_ptr = "value"
00038  *
00039  * @param uri The URI to parse.
00040  * @param parameter_name The parameter name to parse from query.
00041  * @param[out] parameter_value A pointer to the parameter value, NULL if parameter does not exist.
00042  * @return The size of the parameter value, -1 if parameter does not exist in the URI.
00043  */
00044 int parse_query_parameter_value_from_uri(const char *uri, const char *parameter_name, const char **parameter_value);
00045 
00046 /**
00047  * @brief Parse a query parameter from a query and return the size of the parameter value and a pointer to the value within
00048  *        the query.
00049  *
00050  * **Example usage:**
00051  * @code{.cpp}
00052  * char *value_ptr = NULL;
00053  * ssize_t value_len = parse_query_parameter_value("someparameter=value&param2=second", "param2", &value_ptr);
00054  * @endcode
00055  * will result in value_len = 6 and value_ptr = "second"
00056  *
00057  * @param query The query to parse.
00058  * @param parameter_name The parameter name to parse from the query.
00059  * @param[out] parameter_value A pointer to the parameter value, NULL if parameter does not exist.
00060  * @return The size of the parameter value, -1 if parameter does not exist in the query.
00061  */
00062 int parse_query_parameter_value_from_query(const char *query, const char *parameter_name, const char **parameter_value);
00063 
00064 
00065 #endif /* URIQUERYPARSER_H_ */
00066 
00067 #ifdef __cplusplus
00068 }
00069 #endif