forked from hkc/sfxd
1
0
Fork 0

Added "help" command to the daemon

This commit is contained in:
Casey 2024-04-22 16:06:03 +03:00
parent 751dc4ee66
commit 2dfbf934f4
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 14 additions and 0 deletions

View File

@ -52,6 +52,7 @@ ssize_t send_data(struct msg_target tgt, const void *data, ssize_t len);
ssize_t send_txt(struct msg_target tgt, const char *fmt, ...); ssize_t send_txt(struct msg_target tgt, const char *fmt, ...);
void execute_command(struct msg_target tgt, const char *command, const char *params); void execute_command(struct msg_target tgt, const char *command, const char *params);
bool execute_file(struct msg_target tgt, const char *path, int depth); bool execute_file(struct msg_target tgt, const char *path, int depth);
void send_help(struct msg_target tgt);
bool ipc_init(const char *sock_path); bool ipc_init(const char *sock_path);
void ipc_loop(void); void ipc_loop(void);
@ -305,12 +306,25 @@ void execute_command(struct msg_target tgt, const char *command, const char *par
send_txt(tgt, ".pool.use = %d\n", sounds_pool.use); send_txt(tgt, ".pool.use = %d\n", sounds_pool.use);
send_txt(tgt, ".pool.cap = %d\n", sounds_pool.cap); send_txt(tgt, ".pool.cap = %d\n", sounds_pool.cap);
#endif #endif
} else if (0 == strcmp(command, "help")) {
send_help(tgt);
} else if (0 == strcmp(command, "meow")) {
send_txt(tgt, "mrr~\n");
} else if (0 == strcmp(command, "")) { } else if (0 == strcmp(command, "")) {
} else { } else {
send_txt(tgt, "ERR: unknown command: %s\n", command); send_txt(tgt, "ERR: unknown command: %s\n", command);
} // commands } // commands
} }
void send_help(struct msg_target tgt) {
send_txt(tgt, "load NAME PATH load PATH sound as NAME\n");
send_txt(tgt, "play NAME play previously loaded NAME\n");
send_txt(tgt, "play:rs NAME play _ _ _ with random pitch\n");
send_txt(tgt, "set:pitch NAME MIN MAX set pitch range for NAME\n");
send_txt(tgt, "set:volume NAME VOLUME set loudness for NAME\n");
send_txt(tgt, "source PATH load instructions from PATH\n");
}
static char buffer_exec_file[BUFFER_SIZE]; static char buffer_exec_file[BUFFER_SIZE];
bool execute_file(struct msg_target tgt, const char *path, int depth) { bool execute_file(struct msg_target tgt, const char *path, int depth) {
send_txt(tgt, "DBG: soucing file %s at depth %d\n", path, depth); send_txt(tgt, "DBG: soucing file %s at depth %d\n", path, depth);