mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2024-11-24 05:43:08 +01:00
ctpvclear: add option to pass id as argument
This commit is contained in:
parent
ee85f98008
commit
6bc8da73ca
2
clear.sh
2
clear.sh
@ -1,3 +1,3 @@
|
|||||||
setup_fifo "" 1
|
setup_fifo "$1" 1
|
||||||
|
|
||||||
printf '{"action": "remove", "identifier": "preview"}\n' > "$fifo"
|
printf '{"action": "remove", "identifier": "preview"}\n' > "$fifo"
|
||||||
|
9
ctpv.c
9
ctpv.c
@ -136,9 +136,9 @@ static int server(char const *id_s)
|
|||||||
return server_listen(id_s);
|
return server_listen(id_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clear(void)
|
static int clear(char const *id_s)
|
||||||
{
|
{
|
||||||
return server_clear();
|
return server_clear(id_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int end(char const *id_s)
|
static int end(char const *id_s)
|
||||||
@ -264,7 +264,7 @@ int main(int argc, char *argv[])
|
|||||||
program = ctpv.ctpv_path ? ctpv.ctpv_path : "ctpv";
|
program = ctpv.ctpv_path ? ctpv.ctpv_path : "ctpv";
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt(argc, argv, "s:ce:lmC:")) != -1) {
|
while ((c = getopt(argc, argv, "s:c:e:lmC:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 's':
|
case 's':
|
||||||
ctpv.mode = MODE_SERVER;
|
ctpv.mode = MODE_SERVER;
|
||||||
@ -272,6 +272,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
ctpv.mode = MODE_CLEAR;
|
ctpv.mode = MODE_CLEAR;
|
||||||
|
ctpv.server_id_s = optarg;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
ctpv.mode = MODE_END;
|
ctpv.mode = MODE_END;
|
||||||
@ -304,7 +305,7 @@ int main(int argc, char *argv[])
|
|||||||
ret = server(ctpv.server_id_s);
|
ret = server(ctpv.server_id_s);
|
||||||
break;
|
break;
|
||||||
case MODE_CLEAR:
|
case MODE_CLEAR:
|
||||||
ret = clear();
|
ret = clear(ctpv.server_id_s);
|
||||||
break;
|
break;
|
||||||
case MODE_END:
|
case MODE_END:
|
||||||
ret = end(ctpv.server_id_s);
|
ret = end(ctpv.server_id_s);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
exec ctpv -c
|
[ -z "$id" ] && id="$1"
|
||||||
|
|
||||||
|
exec ctpv -c "$id"
|
||||||
|
@ -5,8 +5,8 @@ fifo_open() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup_fifo() {
|
setup_fifo() {
|
||||||
exit_code="${2:-127}"
|
|
||||||
fifo="$(printf '/tmp/ctpvfifo.%s' "${1:-$id}")"
|
fifo="$(printf '/tmp/ctpvfifo.%s' "${1:-$id}")"
|
||||||
|
exit_code="${2:-127}"
|
||||||
[ -e "$fifo" ] || exit "$exit_code"
|
[ -e "$fifo" ] || exit "$exit_code"
|
||||||
fifo_open "$fifo" || exit "$exit_code"
|
fifo_open "$fifo" || exit "$exit_code"
|
||||||
}
|
}
|
||||||
|
4
server.c
4
server.c
@ -148,9 +148,9 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int server_clear(void)
|
int server_clear(const char *id_s)
|
||||||
{
|
{
|
||||||
return run_script(scr_clear_sh, LEN(scr_clear_sh)-1, "");
|
return run_script(scr_clear_sh, LEN(scr_clear_sh)-1, (char *)id_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int server_end(const char *id_s)
|
int server_end(const char *id_s)
|
||||||
|
Loading…
Reference in New Issue
Block a user