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

Script thread utility functions. More...

#include "compile_time.h"
#include "src/scripts/util.h"
#include "src/lib/api.h"
#include "src/lib/config_def.h"
#include "src/lib/list.h"
#include "src/lib/log.h"
#include "src/lib/mem.h"
#include "src/lib/sds_extras.h"
#include "src/scripts/api_tmp.h"
#include "src/scripts/api_vars.h"
#include <time.h>
Include dependency graph for util.c:

Functions

static const char * lua_err_to_str (int rc)
 
void scripts_state_save (struct t_scripts_state *scripts_state, bool free_data)
 
void scripts_state_default (struct t_scripts_state *scripts_state, struct t_config *config)
 
void list_free_cb_script_list_user_data (struct t_list_node *current)
 
void scripts_state_free (struct t_scripts_state *scripts_state)
 
void free_t_script_thread_arg (struct t_script_thread_arg *script_thread_arg)
 
sds script_get_result (lua_State *lua_vm, int rc)
 
void send_script_raw_response (unsigned long conn_id, const char *partition, sds data)
 
void send_script_raw_error (unsigned long conn_id, const char *partition, const char *data)
 

Detailed Description

Script thread utility functions.

Function Documentation

◆ free_t_script_thread_arg()

void free_t_script_thread_arg ( struct t_script_thread_arg script_thread_arg)

Frees the t_script_thread_arg struct

Parameters
script_thread_argpointer to the struct to free

◆ list_free_cb_script_list_user_data()

void list_free_cb_script_list_user_data ( struct t_list_node current)

Callback function to free script_list user_data.

Parameters
currentlist node

◆ lua_err_to_str()

static const char * lua_err_to_str ( int  rc)
static

Returns a phrase for lua errors

Parameters
rcreturn code of the lua script
Returns
error string literal

◆ script_get_result()

sds script_get_result ( lua_State *  lua_vm,
int  rc 
)

Gets the result from script loading or execution

Parameters
lua_vmlua instance
rcreturn code
Returns
newly allocated sds string with script return value or error string

◆ scripts_state_default()

void scripts_state_default ( struct t_scripts_state scripts_state,
struct t_config config 
)

Sets scripts_state defaults.

Parameters
scripts_statepointer to central scripts state
configpointer to static config

◆ scripts_state_free()

void scripts_state_free ( struct t_scripts_state scripts_state)

Frees the scripts_state.

Parameters
scripts_statepointer to central scripts state

◆ scripts_state_save()

void scripts_state_save ( struct t_scripts_state scripts_state,
bool  free_data 
)

Saves in-memory states to disc. This is done on shutdown and on SIGHUP.

Parameters
scripts_statepointer to central scripts state
free_datatrue=free the struct, else not

◆ send_script_raw_error()

void send_script_raw_error ( unsigned long  conn_id,
const char *  partition,
const char *  data 
)

Sends the scripts raw error to the webserver queue

Parameters
conn_idmongoose connection id
partitionMPD partition
dataraw http response to send

◆ send_script_raw_response()

void send_script_raw_response ( unsigned long  conn_id,
const char *  partition,
sds  data 
)

Sends the scripts raw response to the webserver queue

Parameters
conn_idmongoose connection id
partitionMPD partition
dataraw http response to send