|
myMPD
Internal API documentation
|
Webserver utility functions. More...
#include "compile_time.h"#include "src/webserver/utility.h"#include "src/lib/cache/cache_disk_images.h"#include "src/lib/config_def.h"#include "src/lib/filehandler.h"#include "src/lib/log.h"#include "src/lib/mimetype.h"#include "src/lib/sds_extras.h"#include "src/lib/utility.h"#include "src/webserver/response.h"
Functions | |
| bool | webserver_enforce_acl (struct mg_connection *nc, sds acl) |
| bool | webserver_enforce_conn_limit (struct mg_connection *nc, int connection_count) |
| struct mg_connection * | get_nc_by_id (struct mg_mgr *mgr, unsigned long id) |
| struct t_list * | webserver_parse_arguments (struct mg_http_message *hm) |
| sds | print_ip (sds s, struct mg_addr *addr) |
| sds | get_uri_param (struct mg_str *query, const char *name) |
| bool | get_partition_from_uri (struct mg_connection *nc, struct mg_http_message *hm, struct t_frontend_nc_data *frontend_nc_data) |
| bool | check_imagescache (struct mg_connection *nc, struct mg_http_message *hm, struct t_mg_user_data *mg_user_data, const char *type, sds uri_decoded, int offset) |
| sds | webserver_find_image_file (sds basefilename) |
| bool | find_image_in_folder (sds *coverfile, sds music_directory, sds path, sds *names, int names_len) |
| void | webserver_handle_connection_close (struct mg_connection *nc) |
Variables | |
| static const char * | image_file_extensions [] |
Webserver utility functions.
| bool check_imagescache | ( | struct mg_connection * | nc, |
| struct mg_http_message * | hm, | ||
| struct t_mg_user_data * | mg_user_data, | ||
| const char * | type, | ||
| sds | uri_decoded, | ||
| int | offset | ||
| ) |
Checks the covercache and serves the image
| nc | mongoose connection |
| hm | http message |
| mg_user_data | pointer to mongoose configuration |
| type | cache type: cover or thumbs |
| uri_decoded | image uri |
| offset | embedded image offset |
| bool find_image_in_folder | ( | sds * | coverfile, |
| sds | music_directory, | ||
| sds | path, | ||
| sds * | names, | ||
| int | names_len | ||
| ) |
Finds an image in a specific subdir in dir
| coverfile | pointer to already allocated sds string to append the found image path |
| music_directory | parent directory |
| path | subdirectory |
| names | sds array of names |
| names_len | length of sds array |
| struct mg_connection * get_nc_by_id | ( | struct mg_mgr * | mgr, |
| unsigned long | id | ||
| ) |
Returns the mongoose connection by id
| mgr | mongoose mgr |
| id | connection id |
| bool get_partition_from_uri | ( | struct mg_connection * | nc, |
| struct mg_http_message * | hm, | ||
| struct t_frontend_nc_data * | frontend_nc_data | ||
| ) |
Sets the partition from uri and handles errors
| nc | mongoose connection |
| hm | http message |
| frontend_nc_data | frontend nc data |
| sds get_uri_param | ( | struct mg_str * | query, |
| const char * | name | ||
| ) |
Gets and decodes an url parameter. The key will not be url decoded before matching.
| query | query string to parse |
| name | name to get, you must append "=" to the name |
| sds print_ip | ( | sds | s, |
| struct mg_addr * | addr | ||
| ) |
Prints the ip address from a mg_addr struct
| s | already allocated sds string to append the ip |
| addr | pointer to struct mg_addr |
| bool webserver_enforce_acl | ( | struct mg_connection * | nc, |
| sds | acl | ||
| ) |
Public functions Matches the acl against the client ip and sends an error response / drains the connection if acl is not matched
| nc | mongoose connection |
| acl | acl string to check |
| bool webserver_enforce_conn_limit | ( | struct mg_connection * | nc, |
| int | connection_count | ||
| ) |
Enforces the connection limit
| nc | mongoose connection |
| connection_count | connection count |
| sds webserver_find_image_file | ( | sds | basefilename | ) |
Finds the first image with basefilename by trying out extensions
| basefilename | basefilename to append extensions |
| void webserver_handle_connection_close | ( | struct mg_connection * | nc | ) |
Drains the connection if connection is set to close
| nc | mongoose connection |
| struct t_list * webserver_parse_arguments | ( | struct mg_http_message * | hm | ) |
Extract arguments from query parameters
| hm | Http message |
|
static |
Image file extensions to detect