myMPD
Internal API documentation
Loading...
Searching...
No Matches
utility.c File Reference

Utility functions. More...

#include "src/lib/utility.h"
#include "src/lib/log.h"
#include "src/lib/sds/sds_extras.h"
#include <errno.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
Include dependency graph for utility.c:

Data Structures

struct  t_mympd_uris

Functions

static sds get_mympd_host (sds mpd_host, sds http_host)
static sds get_local_ip (void)
void my_msleep (int msec)
bool is_virtual_cuedir (sds music_directory, sds filename)
bool is_streamuri (const char *uri)
const char * get_extension_from_filename (const char *filename)
sds resolv_mympd_uri (sds uri, sds mpd_host, struct t_config *config, bool prefer_ssl)
bool get_ipv6_support (void)

Variables

static const struct t_mympd_uris mympd_uris []

Detailed Description

Utility functions.

Function Documentation

◆ get_extension_from_filename()

const char * get_extension_from_filename ( const char * filename)

Gets the extension of a filename

Parameters
filenamefilename to get extension from
Returns
pointer to the extension

◆ get_ipv6_support()

bool get_ipv6_support ( void )

Checks for IPv6 support by searching for an IPv6 address on all interfaces

Returns
true on IPv6 support, else false

◆ get_local_ip()

sds get_local_ip ( void )
static

Gets the ip address of the first interface

Returns
ip address as sds string

◆ get_mympd_host()

sds get_mympd_host ( sds mpd_host,
sds http_host )
static

Private definitions

Private functions Gets the listening address of the embedded webserver

Parameters
mpd_hostmpd_host config setting
http_hosthttp_host config setting
Returns
address of the embedded webserver as sds string

◆ is_streamuri()

bool is_streamuri ( const char * uri)

Checks if uri is a remote uri or a local file

Parameters
uriuri to check
Returns
true it is a uri else false

◆ is_virtual_cuedir()

bool is_virtual_cuedir ( sds music_directory,
sds filename )

Checks if the filename is a mpd virtual cue sheet directory MPD uses the cue filename as path, we simply check if the filename is a file or not

Parameters
music_directorympd music directory
filenamefilename to check
Returns
true if it is a cue file else false

◆ my_msleep()

void my_msleep ( int msec)

Public functions Sleep function that is interruptible

Parameters
msecmilliseconds to sleep

◆ resolv_mympd_uri()

sds resolv_mympd_uri ( sds uri,
sds mpd_host,
struct t_config * config,
bool prefer_ssl )

Resolves mympd:// uris to the real myMPD host address and respects the mympd_uri config option

Parameters
uriuri to resolv
mpd_hostmpd host
configpointer to config struct
prefer_sslPrefer https over http
Returns
resolved uri

Variable Documentation

◆ mympd_uris

const struct t_mympd_uris mympd_uris[]
static
Initial value:
= {
{"mympd://webradio/", "/webradio?uri=" },
{"mympd://", "/"},
{NULL, NULL}
}

Struct for mapping the special mympd:// uris