C and C++ web framework. http://rapida.vilor.one/docs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

72 lines
1.6 KiB

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright 2022 Ivan Polyakov */
/*!
* \file url.h
* \brief Processing URLs.
*/
#ifndef RAPIDA_URL_H_ENTRY
#define RAPIDA_URL_H_ENTRY
#include "keyval.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \brief URL.
*/
typedef struct {
/*! An array of URL parts. */
char **parts;
int parts_len; /**< The length of rpd_url::parts. */
} rpd_url;
/*!
* \brief Parses URL.
*
* If your rpd_url instance was already filled, first free it **fields**.
* rpd_url_parse::src will be dupblicated using the `strdup`,
* so you can free source string.
*
* \param dest rpd_url instance where parsed data will be placed.
* \param src Source URL string.
*
* \return Status code. A non-zero value is an error.
*/
int rpd_url_parse(rpd_url *dest, const char *src);
/*!
* \brief Cleanup URL instance.
*
* \param url URL instance.
*/
void rpd_url_cleanup(rpd_url *url);
/*!
* \brief Parse dynamic parameters keys into key-value pairs.
*
* \param dest Key-value storage instance.
* \param tpl URL with dynamic parameters identifiers.
*
* \return Status. 0 is success.
*/
int rpd_url_params_parse_keys(rpd_keyval *dest, const rpd_url *tpl);
/*!
* \brief Parse dynamic parameters values into key-value pairs.
*
* \param dest Key-value storage with parsed keys.
* \param url URL.
* \param tpl URL with dynamic parameters identifiers.
*
* \return Status. 0 is success.
*/
int rpd_url_params_parse_vals(rpd_keyval *dest, const rpd_url *url, const rpd_url *tpl);
#ifdef __cplusplus
}
#endif
#endif /* RAPIDA_URL_H_ENTRY */