From 4c034f8d2e17a35b8f94408996a0bd1de4a2533a Mon Sep 17 00:00:00 2001 From: Andre Date: Fri, 19 Jan 2007 19:53:52 +0100 Subject: [PATCH] add command utilitly and some .cmd files --- audiod.cmd | 57 ++++++++ command_util.sh | 190 +++++++++++++++++++++++++++ mysql_selector.cmd | 316 +++++++++++++++++++++++++++++++++++++++++++++ server.cmd | 139 ++++++++++++++++++++ 4 files changed, 702 insertions(+) create mode 100644 audiod.cmd create mode 100755 command_util.sh create mode 100644 mysql_selector.cmd create mode 100644 server.cmd diff --git a/audiod.cmd b/audiod.cmd new file mode 100644 index 00000000..a5f9efdb --- /dev/null +++ b/audiod.cmd @@ -0,0 +1,57 @@ +N: cycle +D: switch to next mode +S: cycle +H: on -> standby -> off -> on +--- +N: grab +D: grab the audio stream +L: +S: -- grab [grab_options] +H: grab ('splice') the audio stream at any position in the filter +H: chain and send that data back to the client. Try +H: para_audioc -- grab -h +H: for the list of available options. +--- +N: help +D: display command list or help for given command +S: help [command] +H: When I was younger, so much younger than today, I never needed anybody's help +H: in any way. But now these days are gone, I'm not so self assured. Now I find +H: I've changed my mind and opened up the doors. +H: -- Beatles: Help +--- +N: kill +D: kill an active audiod task +S: kill task_id [task_id ...] +H: call sched_unregister() and the event_handler of the given task(s) +--- +N: off +D: deactivate para_audiod +S: off +H: Close connection to para_server and stop all decoders. +--- +N: on +D: activate para_audiod +S: on +H: Establish connection to para_server, retrieve para_server's current status. If +H: playing, start corresponding decoder. Otherwise stop all decoders. +--- +N: sb +D: enter standby mode +S: sb +H: Stop all decoders but leave connection to para_server open. +--- +N: stat +D: print status information +S: stat [item1 ...] +H: Dump given status items (all if none given) to stdout. +--- +N: tasks +D: list current tasks +S: tasks +H: print the list of task ids together with the status of each task +--- +N: term +D: terminate audiod +S: term +H: Stop all decoders, shut down connection to para_server and exit. diff --git a/command_util.sh b/command_util.sh new file mode 100755 index 00000000..0e67af1a --- /dev/null +++ b/command_util.sh @@ -0,0 +1,190 @@ +#!/bin/bash + + +dump_array_member() +{ + echo '{' + echo ".name = \"$name_txt\"," + if test $line_handler -eq 0; then + echo ".handler = com_$name_txt," + else + echo ".line_handler = com_$name_txt," + fi + if test -n "$perms_txt"; then + echo ".perms = $perms_txt," + fi + echo ".description = \"$desc_txt\"," + echo ".synopsis = \"$syn_txt\"," + echo ".help = " + echo "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' + echo '},' +} + + +read_one_command() +{ + local line + + name_txt="" + desc_txt="" + syn_txt="" + help_txt="" + perms_txt="" + line_handler=0 + mkdir -p man/man1 + while read key value; do + case "$key" in + ---) + break + ;; + N:) + name_txt="$value" + ;; + P:) + perms_txt="$value" + ;; + D:) + desc_txt="$value" + ;; + L:) + line_handler=1 + ;; + S:) + syn_txt="$value" + ;; + H:) + help_txt="${value}" + while read line; do + if test "$line" = "---"; then + break; + fi + line=${line#H:} + help_txt="$help_txt +${line# }" + done + break + ;; + esac + done + if test -n "$name_txt" -a -n "$desc_txt" -a -n "$syn_txt" \ + -a -n "$help_txt"; then + ret=1 + return + fi + if test -z "$name_txt" -a -z "$desc_txt" -a -z "$syn_txt" \ + -a -z "$help_txt"; then + ret=0 + return + fi + ret=-1 + return + echo "!ERROR!" + echo "N: $name_txt" + echo "D: $desc_txt" + echo "S: $syn_txt" + echo "P: $perms_txt" + echo "H: $help_txt" +} + +dump_man() +{ + echo "NAME" + printf "\t$name_txt - $desc_txt\n" + echo "SYNOPSIS" + printf "\t$syn_txt\n" + echo "DESCRIPTION" + echo "$help_txt" + if test -n "$perms_txt"; then + echo "PERMISSIONS" + if test "$perms_txt" = "0"; then + printf "\t(none)\n" + else + printf "\t$perms_txt\n" + fi + fi + +} + + +com_man() +{ + local cn="$(grep ^codename Makefile.in)" + local ver="$(grep ^AC_INIT configure.ac \ + | cut -f 2 -d ',')" + cn=${cn#*=} + ver=${ver# *[} + ver=${ver%]} + echo "r=paraslash-$ver (cn: $cn)" + local n + local txtdir=txt + local mandir=man/man1 + local htmldir=html + local pfx="$1" + mkdir -p $txtdir $mandir $htmldir || exit 1 + while : ; do + read_one_command + if test $ret -lt 0; then + exit 1 + fi + if test $ret -eq 0; then + break + fi + n=$pfx-$name_txt + echo "pfx: $pfx, name: $n" + dump_man > $txtdir/$n.txt + txt2man -t "$n" -r "$r" < $txtdir/$n.txt \ + | sed -e 1d > $mandir/$n.1 + man2html $mandir/$n.1 > $htmldir/$n.html + done +} + +com_array() +{ + while : ; do + read_one_command + if test $ret -lt 0; then + exit 1 + fi + if test $ret -eq 0; then + break + fi + dump_array_member + done +} + +dump_proto() +{ + if test $line_handler -eq 0; then + echo "static int com_$name_txt(int, int, char **);" + else + echo "static int com_$name_txt(int, char *);" + fi +} + +com_proto() +{ + while : ; do + read_one_command + if test $ret -lt 0; then + exit 1 + fi + if test $ret -eq 0; then + break + fi + dump_proto + done +} + +arg="$1" +shift +case "$arg" in + "array") + com_array + ;; + "proto") + com_proto + ;; + "man") + com_man $* + ;; +esac diff --git a/mysql_selector.cmd b/mysql_selector.cmd new file mode 100644 index 00000000..0144c43d --- /dev/null +++ b/mysql_selector.cmd @@ -0,0 +1,316 @@ +N: cam +P: DB_READ | DB_WRITE +D: copy all metadata +S: cam source dest1 [dest2 ...] +H: Copy attributes and other meta data from source file to destination +H: file(s). Useful for files that have been renamed. +--- +N: cdb +P: DB_READ | DB_WRITE +D: create database +S: cdb [name] +H: +H: Create database name containing the initial columns for basic +H: interoperation with server. This command has to be used only once +H: when you use the mysql audio file selector for the very first time. +H: +H: The optional name defaults to 'paraslash' if not given. +--- +N: clean +P: DB_READ | DB_WRITE +D: nuke invalid entries in database +S: clean +H: If the vrfy command shows you any invalid entries in your database, +H: you can get rid of them with clean. Always run 'upd' and 'vrfy' +H: before running this command. Use with caution! +--- +N: cs +P: VSS_WRITE | DB_READ | DB_WRITE +D: change stream +S: cs [s] +H: Selects stream s or prints current stream when s was not given. +--- +N: csp +P: VSS_WRITE | DB_READ +D: change stream and play +S: csp s +H: Select stream s and start playing. If this results in a +H: stream-change, skip rest of current audio file. +--- +N: da +P: DB_READ | DB_WRITE +D: drop attribute from database +S: da att +H: Use with caution. All info on attribute att will be lost. +--- +N: hist +P: DB_READ +D: print history +S: hist +H: Print list of all audio files together with number of days since +H: each file was last played. +--- +N: info +P: DB_READ +D: print database info +S: info [af] +H: print database informations for audio file af. Current audio file +H: is used if af is not given. +--- +N: la +P: DB_READ +D: list attributes +S: la [af] +H: List attributes of audio file af or of current audio file when +H: invoked without arguments. +--- +N: laa +P: DB_READ +D: list available attributes +S: laa +H: print list of all attributes defined in the database +--- +N: last +P: DB_READ +D: print list of audio files, ordered by lastplayed time +S: last [n] +H: The optional number n defaults to 10 if not specified. +--- +N: ls +P: DB_READ +D: list all audio files that match a LIKE pattern +S: ls [pattern] +H: If pattern was not given, print list of all audio files known +H: to the mysql selector. See the documentation of mysql +H: for the definition of LIKE patterns. +--- +N: mbox +P: DB_READ +D: dump audio file list in mbox format +S: mbox [p] +H: Dump list of audio files in mbox format (email) to stdout. If +H: the optional pattern p is given, only those audio files, +H: whose basename match p are going to be included. Otherwise, +H: all files are selected. +H: +H: EXAMPLE +H: The mbox command can be used together with your favorite +H: mailer (this example uses mutt) for browsing the audio file +H: collection: +H: +H: para_client mbox > ~/para_mbox +H: +H: mutt -F ~/.muttrc.para -f ~/para_mbox +H: +H: For playlists, you can use mutt's powerful pattern matching +H: language to select files. If you like to tag all files +H: containing the pattern 'foo', type 'T', then '~s foo'. +H: +H: When ready with the list, type ';|' (i.e., hit the semicolon +H: key to apply the next mutt command to all tagged messages, +H: then the pipe key) to pipe the selected \"mails\" to a +H: suitable script which adds a paraslash stream where exactly +H: these files are admissable or does whatever thou wilt. +--- +N: mv +P: DB_READ | DB_WRITE +D: rename entry in database +S: mv oldname newname +H: Rename oldname to newname. This updates the data table to reflect +H: the new name. All internal data (numplayed, lastplayed, picid,..) +H: is kept. If newname is a full path, the dir table is updated as +H: well. +--- +N: na +P: DB_READ | DB_WRITE +D: add new attribute to database +S: na att +H: This adds a column named att to your mysql database. att should +H: only contain letters and numbers, in paricular, '+' and '-' are +H: not allowed. +--- +N: ne +P: DB_READ | DB_WRITE +D: add new database entries +S: ne file1 [file2 [...]] +H: Add the given filename(s) to the database, where file1,... must +H: be full path names. This command might be much faster than 'upd' +H: if the number of given files is small. +--- +N: ns +P: VSS_WRITE | DB_READ | DB_WRITE +D: change to next stream +S: ns +H: Cycle forwards through stream list. +--- +N: pic +P: DB_READ +D: get picture by name or by identifier +S: pic [name] +H: Dump jpg image that is associated to given audio file (current +H: audio file if not specified) to stdout. If name starts with +H: '#' it is interpreted as an identifier instead and the picture +H: having that identifier is dumped to stdout. +H: +H: EXAMPLE +H: +H: para_client pic '#123' > pic123.jpg +--- +N: picadd +P: DB_READ | DB_WRITE +D: add picture to database +S: picadd [picname] +H: Read jpeg file from stdin and store it as picname in database. +H: +H: EXAMPLE +H: +H: para_client picadd foo.jpg < foo.jpg +--- +N: picass +P: DB_READ | DB_WRITE +D: associate a picture to file(s) +S: picass pic_id file1 [file2...] +H: Associate the picture given by pic_id to all given files. +--- +N: picch +P: DB_READ | DB_WRITE +D: change name of picture +S: picch id new_name +H: Asign new_name to picture with identifier id. +--- +N: picdel +P: DB_READ | DB_WRITE +D: delete picture from database +S: picdel id1 [id2...] +H: Delete each given picture from database. +--- +N: piclist +P: DB_READ +D: print list of pictures +S: piclist +H: Print id, name and length of each picture contained in the +H: database. +--- +N: ps +P: VSS_WRITE | DB_READ | DB_WRITE +D: change to previous stream +S: ps +H: Cycle backwards through stream list. +--- +N: rm +P: DB_READ | DB_WRITE +D: remove entries from database +S: rm name1 [name2 [...]] +H: Remove name1, name2, ... from the data table. Use with caution. +--- +N: sa +P: DB_READ | DB_WRITE +D: set/unset attributes +S: sa at1<'+' | '-'> [at2<'+' | '-'> ] [af1 ...] +H: Set ('+') or unset ('-') attribute at1, at2 etc. for given list of +H: audio files. If no audio files were given the current audio file is +H: used. Example: +H: +H: sa rock+ punk+ classic- LZ__Waldsterben.mp3 +H: +H: sets the 'rock' and the 'punk' attribute but unsets the 'classic' +H: attribute. +--- +N: skip +P: DB_READ | DB_WRITE +D: skip subsequent audio files(s) +S: skip n [s] +H: Skip the next n audio files of stream s. This is equivalent to the +H: command 'sl n s', followed by 'us name' for each name the output of +H: sl. +--- +N: sl +P: DB_READ +D: print score list +S: sl n [s] +H: Print sorted list of maximal n lines. Each line is an admissible +H: entry with respect to stream s. The list is sorted by score-value +H: which is given by the definition of s. If s is not given, the +H: current stream is used. Example: +H: +H: sl 1 +H: +H: shows you the audio file the server would select right now. +--- +N: snp +P: DB_READ | DB_WRITE +D: set numplayed +S: snp number af1 [af2 ...] +H: Update the numplayed field in the data table for all given audio +H: files. +--- +N: stradd +P: DB_READ | DB_WRITE +D: add stream +S: stradd s +H: Add stream s to the list of available streams. The stream +H: definition for s is read from stdin and is then sent to +H: para_server. Example: +H: +H: echo 'deny: NAME_LIKE(%Madonna%)' | para_client stradd no_madonna +H: +H: adds the new stream 'no_madonna' to the list of available streams. +H: A given audio file is admissible for this stream iff its basename +H: does not contain the string 'Madonna'. +--- +N: strdel +P: DB_READ | DB_WRITE +D: delete stream +S: strdel s +H: Remove stream s from database. +--- +N: streams +P: DB_READ +D: list streams +S: streams +H: Print list of available streams. Use 'cs' to switch to any of +H: these. +--- +N: strq +P: DB_READ +D: query stream definition +S: strq [s] +H: Print definition of stream s to stdout. Use current stream if s was +H: not given. +--- +N: summary +P: DB_READ +D: list attributes +S: summary +H: Print a list of attributes together with number of audio +H: files having that attribute set. +--- +N: upd +P: DB_READ | DB_WRITE +D: update database +S: upd +H: This command uses the --audio_file_dir option of para_server to +H: locate your audio files. New files are then added to the mysql +H: database. Use this command if you got new files or if you have +H: moved some files around. +--- +N: us +P: DB_READ | DB_WRITE +D: update lastplayed time +S: us name +H: Update lastplayed time without actually playing the thing. +--- +N: verb +P: DB_READ | DB_WRITE +D: send verbatim sql query +S: verb cmd +H: Send cmd to mysql server. For expert/debugging only. Note that cmd +H: usually must be escaped. Use only if you know what you are doing! +--- +N: vrfy +P: DB_READ +D: list invalid entries in database +S: vrfy +H: Show what clean would delete. Run 'upd' before this command to make +H: sure your database is up to date. +--- diff --git a/server.cmd b/server.cmd new file mode 100644 index 00000000..36553542 --- /dev/null +++ b/server.cmd @@ -0,0 +1,139 @@ +N: chs +P: DB_READ | DB_WRITE +D: change the current audio file selector +S: chs [new_selector] +H: Shutdown the current selector and activate new_selector. If no +H: argument was given, print the name of the current selector. +--- +N: ff: +P: VSS_READ | VSS_WRITE +D: jmp amount of time forwards or backwards in current audio file +S: ff n[-] +H: Set the 'R' (reposition request) bit of the vss status flags +H: and enqueue a request to jump n seconds forwards or backwards +H: in the current audio file. +H: +H: EXAMPLE +H: +H: ff 30- +H: +H: jumps 30 seconds backwards. +--- +N: help +P: 0 +D: print help text +S: help [command] +H: Without any arguments, help prints a list of availible commands. When +H: issued with a command name as first argument, print out a description +H: for that command. +--- +N: hup +P: VSS_WRITE +D: force reload of config file and log file +S: hup +H: After rereading the config file, a signal is sent to all children +H: which forces them to close/reopen the log file. +--- +N: jmp +P: VSS_READ | VSS_WRITE +D: mp to given position in current audio file +S: jmp [n] +H: Set the 'R' (reposition request) bit of the vss status flags +H: and enqueue a request to jump to n% of the current audio file, +H: where 0 <= n <= 100. +--- +N: next +P: VSS_READ | VSS_WRITE +D: skip rest of current audio file +S: next +H: Set the 'N' (next audio file) bit of the vss status flags. When +H: playing, change audio file immediately. Equivalent to stop +H: if paused, NOP if stopped. +--- +N: nomore +P: VSS_READ | VSS_WRITE +D: stop playing after current audio file +S: nomore +H: Set the 'O' (no more) bit of the vss status flags. This instructs +H: para_server to clear the 'P' (playing) bit as soon as it encounters +H: the 'N' (next audio file) bit being set. +H: Use this command instead of stop if you don't like +H: sudden endings. +--- +N: pause +P: VSS_READ | VSS_WRITE +D: pause current audio file +S: pause +H: Clear the 'P' (playing) bit of the vss status flags. +--- +N: play +P: VSS_READ | VSS_WRITE, +D: start playing or resume playing when paused +S: play +H: Set the 'P' (playing) bit of the vss status flags. This +H: results in starting/continuing to stream. +--- +N: sb +P: VSS_READ +D: print status bar for current audio file +S: sb [n] +H: Without any arguments, sb continuously prints a status bar of the +H: form +H: +H: 12:34 [56:12] (56%) filename +H: +H: indicating playing time, remaining time, percentage and the name of +H: the file being streamed. Use the optional number n to let stat exit +H: after having displayed the status bar n times. +--- +N: sc +P: VSS_READ +D: print name of audio file whenever it changes +S: sc [n] +H: sc prints exactly one line (the filename of the audio file +H: being played) whenever the audio file changes. Stops after +H: n iterations, or never if n is not specified. +--- +N: sender +P: VSS_READ | VSS_WRITE +D: control paraslash internal senders +S: sender [s cmd [arguments]] +H: send command cmd to sender s. cmd may be one of the following: +H: help, on, off, add, delete, allow, or deny. Note that not all senders +H: support each command. Try e.g. 'para_client sender http help' for +H: more information about the http sender. If no argument is given, +H: print out a list of all senders that are compiled in. +--- +N: si +P: 0 +D: print server info +S: si +H: Print server uptime and other information. +--- +N: stat +P: VSS_READ +D: print status info for current audio file +S: stat [n] +H: Without any arguments, stat continuously prints status messages +H: about the audio file being streamed. Use the optional number n +H: to let stat exit after having displayed status n times. +--- +N: stop +P: VSS_READ | VSS_WRITE +D: stop playing +S: stop +H: Clear the 'P' (play) bit and set the 'N' bit of the vss status +H: flags. +--- +N: term +P: VSS_READ | VSS_WRITE +D: terminate para_server +S: term +H: Shuts down the server. Instead of this command, you can also send +H: SIGINT or SIGTERM. It should never be necessary to send SIGKILL. +--- +N: version +P: 0 +D: print server's version +S: version +H: Show version and other info -- 2.30.2