is the output of a command-line (it s a mix of 'attach' and 'program'). The first line of the
command-line output is taken into account, trailing newline being stripped down.
Like 'attach', if the filename is not found or not accessible, CM will raise an error. Like
'program', if the command-line fails, no error raises but the standard output of CM shows it.
"|program{<span style=\"oblique\">sub_expr</span>}\n(|p{<span style=\"oblique\">sub_expr</span>})\n", N_("insert program output:\n<span style=\"oblique\">sub_expr</span> is evaluated as a command-line to get\nthe output from"), /* insert program output */
"|input{<span style=\"oblique\">sub_expr</span>}\n(|i{<span style=\"oblique\">sub_expr</span>})\n", N_("insert user input:\n<span style=\"oblique\">sub_expr</span> is a variable to be replaced by\nuser-entered text"), /* insert user input */
"|attach{<span style=\"oblique\">sub_expr</span>}\n(|a{<span style=\"oblique\">sub_expr</span>})", N_("attach file:\n<span style=\"oblique\">sub_expr</span> is evaluated as the path of the file to attach"), /* attach file */
+ "|attach_output{<span style=\"oblique\">sub_expr</span>}\n(|A{<span style=\"oblique\">sub_expr</span>})", N_("attach file:\n<span style=\"oblique\">sub_expr</span> is evaluated as a command-line to get\nthe filename from"), /* attach file whose name's got from program output */
"", NULL,
N_("<span weight=\"bold\">definition of terms:</span>"), NULL,
"<span style=\"oblique\">expr</span>\n", N_("text that can contain any of the symbols or\ncommands above"),
("|p"|"|program") /* insert program output */ return INSERT_PROGRAMOUTPUT;
("|i"|"|input") /* insert user input */ return INSERT_USERINPUT;
("|a"|"|attach") /* attach file */ return ATTACH_FILE;
+("|A"|"|attach_program") /* file whose name's got from program output */ return ATTACH_PROGRAMOUTPUT;
<S_DATE>"{" return OPARENT;
<S_DATE>"}" { BEGIN S_NORMAL; return CPARENT; }
<S_NORMAL>"{" return OPARENT;
attachments = g_list_append(attachments, g_strdup(filename));
}
+static void quote_fmt_attach_file_program_output(const gchar *progname)
+{
+ FILE *file;
+ char buffer[PATH_MAX];
+
+ if ((file = popen(progname, "r")) != NULL) {
+ /* get first line only */
+ if (fgets(buffer, sizeof(buffer), file)) {
+ /* trim trailing CR/LF */
+ strretchomp(buffer);
+ attachments = g_list_append(attachments, g_strdup(buffer));
+ }
+ pclose(file);
+ }
+}
+
static gchar *quote_fmt_complete_address(const gchar *addr)
{
gint count;
%token QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK
/* other tokens */
%token INSERT_FILE INSERT_PROGRAMOUTPUT INSERT_USERINPUT
-%token ATTACH_FILE
+%token ATTACH_FILE ATTACH_PROGRAMOUTPUT
%token OPARENT CPARENT
%token CHARACTER
%token SHOW_DATE_EXPR
if (!dry_run) {
quote_fmt_attach_file(sub_expr.buffer);
}
+ }
+ | ATTACH_PROGRAMOUTPUT
+ {
+ current = &sub_expr;
+ clear_buffer();
+ }
+ OPARENT sub_expr CPARENT
+ {
+ current = &main_expr;
+ if (!dry_run) {
+ quote_fmt_attach_file_program_output(sub_expr.buffer);
+ }
};
+;