myMPD
Internal API documentation
Loading...
Searching...
No Matches
api_scripts.h File Reference

Scripts API functions. More...

#include "dist/sds/sds.h"
#include "src/lib/list.h"
#include "src/scripts/util.h"
#include <stdbool.h>
Include dependency graph for api_scripts.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool scripts_file_reload (struct t_scripts_state *scripts_state)
 
bool scripts_file_read (struct t_scripts_state *scripts_state)
 
bool script_save (struct t_scripts_state *scripts_state, sds scriptname, sds oldscript, sds file, int order, int version, sds content, struct t_list *arguments, sds *error)
 
bool script_delete (struct t_scripts_state *scripts_state, sds scriptname)
 
sds script_get (struct t_list *script_list, sds buffer, unsigned request_id, sds scriptname)
 
sds script_list (struct t_list *script_list, sds buffer, unsigned request_id, bool all)
 

Detailed Description

Scripts API functions.

Function Documentation

◆ script_delete()

bool script_delete ( struct t_scripts_state scripts_state,
sds  scriptname 
)

Deletes a script

Parameters
scripts_statepointer to scripts_state
scriptnamescript to delete (name without extension)
Returns
true on success, else false

◆ script_get()

sds script_get ( struct t_list script_list,
sds  buffer,
unsigned  request_id,
sds  scriptname 
)

Gets the script and its details

Parameters
script_listlist of scripts
bufferalready allocated sds string to append the response
request_idjsonrpc request id
scriptnamescriptname to read from filesystem
Returns
pointer to buffer

◆ script_list()

sds script_list ( struct t_list script_list,
sds  buffer,
unsigned  request_id,
bool  all 
)

Lists scripts

Parameters
script_listlist of scripts
bufferalready allocated sds string to append the response
request_idjsonrpc request id
alltrue = print all scripts, false = print only scripts with order > 0
Returns
pointer to buffer

◆ script_save()

bool script_save ( struct t_scripts_state scripts_state,
sds  scriptname,
sds  oldscript,
sds  file,
int  order,
int  version,
sds  content,
struct t_list arguments,
sds *  error 
)

Saves a script

Parameters
scripts_statepointer to scripts_state
scriptnamescriptname
oldscriptold scriptname (leave empty for a new script)
fileimported script filename (empty for local scripts)
orderscript list is ordered by this value
versionimported script version (0 for local scripts)
contentscript content
argumentsarguments for the script
erroralready allocated sds string to hold the error message
Returns
true on success, else false

◆ scripts_file_read()

bool scripts_file_read ( struct t_scripts_state scripts_state)

Reads the scripts from the scripts directory

Parameters
scripts_statepointer to scripts_state
Returns
true on success, else false

◆ scripts_file_reload()

bool scripts_file_reload ( struct t_scripts_state scripts_state)

Public functions Reload the scripts from disk.

Parameters
scripts_statepointer to scripts_state
Returns
true on success, else false