-
Notifications
You must be signed in to change notification settings - Fork 0
mdlv API reference
Refer to server.c and web_root/script.js for working server and browser client implementation.
typedef struct mdlv_script {
char* name; // Name of script
cdlv* instance; // cdlv instance handling this script
struct mdlv_script* next; // Pointer to next struct in linked list
} mdlv_script_t;Linked list holding cdlv instances with scripts found by mdlv.
typedef struct mdlv {
char* host; // Host URL
char* path; // Path to scripts files
char* web_root; // Path to web_root
mdlv_script_t* scripts; // Scripts list
struct mg_mgr manager; // Mongoose HTTP server manager
} mdlv;cdlv_error mdlv_init(mdlv* base);Initialize mdlv server, scripts found within mdlv->path and start listening on mdlv->host.
Parameters:
-
base- a pointer tomdlvbase
void mdlv_free(mdlv* base);Free all resources.
Parameters:
-
base- a pointer tomdlvbase
All responses have Content-Type; application/json (unless specified otherwise).
Lists loaded and parsed scripts.
Parameters:
- None
Response:
-
200- OK
Example:
curl http://localhost:8080/list{"type": "list", "files": ["test.cdlv","sample.cdlv"]}Get script file data.
Parameters:
-
filename- one of filenames listed infilesarray from/list
Response:
-
200- OK -
400-filenamewas not sent by user or wrong file specified -
500- File could not loaded or JSON error
Example:
curl http://localhost:8080/script -d '{"filename":"test.cdlv"}'{"type":"script","global_resources":[],"scenes":[{"name":"one","resources":[{"1":"../res/sample/images/scene/1.png"}],"resources_path":"../res/sample/images/scene/","script":["@bg 1","I just displayed empty background.","dXd"]},{"name":"two","resources":[],"resources_path":"../res/sample/images/scene/","script":["@bg 2.png","It's another scene.","Aand it's working!!"]}]}curl http://localhost:8080/script{"type": "error", "msg": "No filename found"}Get video as a response with Content-Type: video/mp4 on 200. Other responses return Content-Type: application/json.
Parameters:
-
filename- one of filenames listed in resources withresource_pathappended
Response:
-
200- OK -
400-filenamewas not sent by user -
500- File could not be read
Example:
curl http://localhost:8080/anim -d '{"filename":"../res/sample/images/scene/anim.mp4"}' -o anim.mp4Get image as a response with Content-Type: image/jpeg on 200. Other responses return Content-Type: application/json.
Parameters:
-
filename- one of filenames listed in resources
Response:
-
200- OK -
400-filenamewas not sent by user -
500- File could not be read
Example:
curl http://localhost:8080/bg -d '{"filename":"../res/sample/images/white.png"}' -o white.png