diff --git a/gen_help_format.sh b/gen_help_format.sh index 256da27..538980c 100755 --- a/gen_help_format.sh +++ b/gen_help_format.sh @@ -1,11 +1,38 @@ FORMAT_FOLDER=help_format IDIR=include -cp $FORMAT_FOLDER/help_template_head $IDIR/help.h +SLASHSCRIPT='s|\\|\\\\|g;s|\"|\\\"|g' +NEWLINESCRIPT=':a;N;$!ba;s/\n/\\n/g;' -echo "#define ZFD_FORMAT \"zmidimap$(sed -n -e 'H;${x;s/\n/\\n/g;s/^,//;p;}' $FORMAT_FOLDER/zfd-format)\"" >> $IDIR/help.h -echo "#define MIM_FORMAT \"zmidimap$(sed -n -e 'H;${x;s/\n/\\n/g;s/^,//;p;}' $FORMAT_FOLDER/mim-format)\"" >> $IDIR/help.h -echo "#define SHELL_FORMAT \"zmidimap$(sed -n -e 'H;${x;s/\n/\\n/g;s/^,//;p;}' $FORMAT_FOLDER/shell-format)\"" >> $IDIR/help.h -echo "#define COMMAND_TAGS \"zmidimap$(sed -n -e 'H;${x;s/\n/\\n/g;s/^,//;p;}' $FORMAT_FOLDER/command-tags)\"" >> $IDIR/help.h +filetocstr() +{ + sed -e $SLASHSCRIPT "$1" | sed $NEWLINESCRIPT +} -cat $FORMAT_FOLDER/help_template_tail >> $IDIR/help.h +gen_line() +{ + name="$(basename "$1")" + echo "#define $(echo "$name" | tr '[:lower:]' '[:upper:]') \"$(filetocstr "$1")\"" +} + +help_header() +{ + echo '#ifndef HELP_H +#define HELP_ +' +} + +help_footer() +{ + echo ' +#endif //HELP_H' +} + +help_header > "$IDIR/help.h" + +for I in help_format/* +do + gen_line "$I" >> "$IDIR/help.h" +done + +help_footer >> "$IDIR/help.h" diff --git a/help_format/command-tags b/help_format/command_tags similarity index 100% rename from help_format/command-tags rename to help_format/command_tags diff --git a/help_format/help_template_head b/help_format/help_template_head deleted file mode 100644 index ca17dac..0000000 --- a/help_format/help_template_head +++ /dev/null @@ -1,2 +0,0 @@ -#ifndef HELP_H -#define HELP_H diff --git a/help_format/help_template_tail b/help_format/help_template_tail deleted file mode 100644 index 3fc5c66..0000000 --- a/help_format/help_template_tail +++ /dev/null @@ -1 +0,0 @@ -#endif //HELP_H diff --git a/help_format/mim-format b/help_format/mim_format similarity index 91% rename from help_format/mim-format rename to help_format/mim_format index 4a87ddd..a3e122e 100644 --- a/help_format/mim-format +++ b/help_format/mim_format @@ -20,7 +20,7 @@ Device *shell: shell command to be executed > mandatory -Shell command can be concatenated with \"\" or '' +Shell commands can be concatenated with "" or '' Comments are written with // or # and end at end of line Multiple tags can be put on the same line by separating them with ; See --command-tags for optional command tags diff --git a/help_format/shell-format b/help_format/shell_format similarity index 100% rename from help_format/shell-format rename to help_format/shell_format diff --git a/help_format/zfd-format b/help_format/zfd_format similarity index 91% rename from help_format/zfd-format rename to help_format/zfd_format index b1099f5..4ce70c0 100644 --- a/help_format/zfd-format +++ b/help_format/zfd_format @@ -26,5 +26,5 @@ ZFD format: http://zawz.net/doc/ztd/zfd.html *shell: shell command to be executed > mandatory -Shell command can be concatenated with \"\" or '' +Shell commands can be concatenated with "" or '' see --command-tags for optional command tags diff --git a/include/help.h b/include/help.h index 5a68182..df3a4b4 100644 --- a/include/help.h +++ b/include/help.h @@ -1,7 +1,9 @@ #ifndef HELP_H -#define HELP_H -#define ZFD_FORMAT "zmidimap\n-- [ZFD FILE FORMAT] --\n\nZFD format: http://zawz.net/doc/ztd/zfd.html\n\n[,]\n\n-- format --\n {\n name=\n commands=[,]\n }\n--\n*name: string referring to client name of the device\n\n format\n {\n type=\n shell=\n =\n =\n ...\n }\n--\n*type: type of the signal: note/controller/pitch/system/connect/disconnect\n > mandatory\n*shell: shell command to be executed\n > mandatory\n\nShell command can be concatenated with \"\" or ''\nsee --command-tags for optional command tags" -#define MIM_FORMAT "zmidimap\n-- [MIM FILE FORMAT] --\n\nDevice \n Command \n shell=\n =\n =\n ...\n Command \n ...\n\nDevice \n...\n\n--\n*name: string referring to client name of the device\n > mandatory\n*type: type of the signal: note/controller/pitch/system/connect/disconnect\n > mandatory\n*shell: shell command to be executed\n > mandatory\n\nShell command can be concatenated with \"\" or ''\nComments are written with // or # and end at end of line\nMultiple tags can be put on the same line by separating them with ;\nSee --command-tags for optional command tags" -#define SHELL_FORMAT "zmidimap\n-- [SHELL FORMAT] --\n\nShell command follows regular shell format\n\n-- [Environment] --\n\n[Note]\n $id: id of the note\n $channel: channel of the note\n $velocity: velocity of the note\n\n[Controller]\n $value: value of the controller (remapped)\n $id: id of the controller\n $channel: channel of the controller\n $rawvalue: original value of the controller\n\n[Pitch]\n $value: value of the bend (remapped)\n $rawvalue: original value of the bend\n\n[System]\n $code: hexadecimal code of the system signal" -#define COMMAND_TAGS "zmidimap\n-- [COMMAND TAGS] --\n\n[Note tags]\n id=\n channel=\n trigger=\n--\n *id: note id from 0 to 127\n > optional, default 0:127\n *channel: value from 0 to 16 for channel, * for any channel\n > optional, default *\n *trigger: note velocity from 0 to 127 that triggers the command\n > optional, default 1:127\n\n[Controller tags]\n id=\n channel=\n range=\n remap=\n float=\n--\n *id: controller id from 0 to 127\n > optional, default 0:127\n *channel: value from 0 to 16 for channel, * for any channel\n > optional, default *\n *range: controller value from 0 to 127 that triggers command\n > optional, default 0:127\n *remap: remaps the range to given interval\n > optional, default same as range\n *float: boolean value defining if output is a floating point value\n > optional, default false\n\n[Pitch bend tags]\n range=\n remap=\n float=\n--\n *range: controller value from -8192 to 8191 that triggers command\n > optional, default -8192:8191\n *remap: remaps the range to given interval\n > optional, default same as range\n *float: boolean value defining if output is a floating point value\n > optional, default false\n\n[Interval Format]\n x:y range from x to y\n x single value x\n * all possible values" +#define HELP_ + +#define COMMAND_TAGS "-- [COMMAND TAGS] --\n\n[Note tags]\n id=\n channel=\n trigger=\n--\n *id: note id from 0 to 127\n > optional, default 0:127\n *channel: value from 0 to 16 for channel, * for any channel\n > optional, default *\n *trigger: note velocity from 0 to 127 that triggers the command\n > optional, default 1:127\n\n[Controller tags]\n id=\n channel=\n range=\n remap=\n float=\n--\n *id: controller id from 0 to 127\n > optional, default 0:127\n *channel: value from 0 to 16 for channel, * for any channel\n > optional, default *\n *range: controller value from 0 to 127 that triggers command\n > optional, default 0:127\n *remap: remaps the range to given interval\n > optional, default same as range\n *float: boolean value defining if output is a floating point value\n > optional, default false\n\n[Pitch bend tags]\n range=\n remap=\n float=\n--\n *range: controller value from -8192 to 8191 that triggers command\n > optional, default -8192:8191\n *remap: remaps the range to given interval\n > optional, default same as range\n *float: boolean value defining if output is a floating point value\n > optional, default false\n\n[Interval Format]\n x:y range from x to y\n x single value x\n * all possible values" +#define MIM_FORMAT "-- [MIM FILE FORMAT] --\n\nDevice \n Command \n shell=\n =\n =\n ...\n Command \n ...\n\nDevice \n...\n\n--\n*name: string referring to client name of the device\n > mandatory\n*type: type of the signal: note/controller/pitch/system/connect/disconnect\n > mandatory\n*shell: shell command to be executed\n > mandatory\n\nShell commands can be concatenated with \"\" or ''\nComments are written with // or # and end at end of line\nMultiple tags can be put on the same line by separating them with ;\nSee --command-tags for optional command tags" +#define SHELL_FORMAT "-- [SHELL FORMAT] --\n\nShell command follows regular shell format\n\n-- [Environment] --\n\n[Note]\n $id: id of the note\n $channel: channel of the note\n $velocity: velocity of the note\n\n[Controller]\n $value: value of the controller (remapped)\n $id: id of the controller\n $channel: channel of the controller\n $rawvalue: original value of the controller\n\n[Pitch]\n $value: value of the bend (remapped)\n $rawvalue: original value of the bend\n\n[System]\n $code: hexadecimal code of the system signal" +#define ZFD_FORMAT "-- [ZFD FILE FORMAT] --\n\nZFD format: http://zawz.net/doc/ztd/zfd.html\n\n[,]\n\n-- format --\n {\n name=\n commands=[,]\n }\n--\n*name: string referring to client name of the device\n\n format\n {\n type=\n shell=\n =\n =\n ...\n }\n--\n*type: type of the signal: note/controller/pitch/system/connect/disconnect\n > mandatory\n*shell: shell command to be executed\n > mandatory\n\nShell commands can be concatenated with \"\" or ''\nsee --command-tags for optional command tags" + #endif //HELP_H