From: Marco Sirabella Date: Mon, 25 Jun 2018 19:10:23 +0000 (-0400) Subject: Distinguish between strings, paths and commands X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c95290dc425770cf95f1dd72730a81e47f29a51;p=neomutt Distinguish between strings, paths and commands --- diff --git a/doc/makedoc.c b/doc/makedoc.c index f8e5ae9ea..96a4b3d53 100644 --- a/doc/makedoc.c +++ b/doc/makedoc.c @@ -959,7 +959,8 @@ enum DataType DT_MAGIC, DT_SYNONYM, DT_ADDRESS, - DT_MBTABLE + DT_MBTABLE, + DT_COMMAND, }; struct VariableTypes @@ -980,6 +981,7 @@ struct VariableTypes { "DT_SYNONYM", NULL }, { "DT_ADDRESS", "e-mail address" }, { "DT_MBTABLE", "string" }, + { "DT_COMMAND", "command" }, { NULL, NULL }, }; @@ -1051,6 +1053,7 @@ static void pretty_default(char *t, size_t l, const char *s, int type) case DT_REGEX: case DT_ADDRESS: case DT_PATH: + case DT_COMMAND: case DT_MBTABLE: { if (strcmp(s, "0") == 0) @@ -1171,7 +1174,7 @@ static void print_confline(const char *varname, int type, const char *val, FILE case F_CONF: { if (type == DT_STRING || type == DT_REGEX || type == DT_ADDRESS || - type == DT_PATH || type == DT_MBTABLE) + type == DT_PATH || type == DT_MBTABLE || type == DT_COMMAND) { fprintf(out, "\n# set %s=\"", varname); conf_print_strval(val, out); @@ -1183,7 +1186,7 @@ static void print_confline(const char *varname, int type, const char *val, FILE fprintf(out, "\n#\n# Name: %s", varname); fprintf(out, "\n# Type: %s", type2human(type)); if (type == DT_STRING || type == DT_REGEX || type == DT_ADDRESS || - type == DT_PATH || type == DT_MBTABLE) + type == DT_PATH || type == DT_MBTABLE || type == DT_COMMAND) { fputs("\n# Default: \"", out); conf_print_strval(val, out); @@ -1203,7 +1206,7 @@ static void print_confline(const char *varname, int type, const char *val, FILE fputs(".nf\n", out); fprintf(out, "Type: %s\n", type2human(type)); if (type == DT_STRING || type == DT_REGEX || type == DT_ADDRESS || - type == DT_PATH || type == DT_MBTABLE) + type == DT_PATH || type == DT_MBTABLE || type == DT_COMMAND) { fputs("Default: \"", out); man_print_strval(val, out); @@ -1231,7 +1234,7 @@ static void print_confline(const char *varname, int type, const char *val, FILE fprintf(out, "\nType: %s", type2human(type)); if (type == DT_STRING || type == DT_REGEX || type == DT_ADDRESS || - type == DT_PATH || type == DT_MBTABLE) + type == DT_PATH || type == DT_MBTABLE || type == DT_COMMAND) { if (val && *val) { diff --git a/init.c b/init.c index 00f98991f..ac49cd4b0 100644 --- a/init.c +++ b/init.c @@ -477,6 +477,7 @@ static void free_opt(struct Option *p) mutt_regex_free((struct Regex **) p->var); break; case DT_PATH: + case DT_COMMAND: case DT_STRING: FREE((char **) p->var); break; @@ -1067,6 +1068,7 @@ static void restore_default(struct Option *p) switch (DTYPE(p->type)) { case DT_STRING: + case DT_COMMAND: mutt_str_replace((char **) p->var, (char *) p->initial); break; case DT_MBTABLE: @@ -1166,6 +1168,7 @@ static void set_default(struct Option *p) switch (DTYPE(p->type)) { case DT_STRING: + case DT_COMMAND: if (!p->initial && *((char **) p->var)) p->initial = (unsigned long) mutt_str_strdup(*((char **) p->var)); break; @@ -2097,6 +2100,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data, } else if (myvar || ((idx >= 0) && ((DTYPE(MuttVars[idx].type) == DT_STRING) || (DTYPE(MuttVars[idx].type) == DT_PATH) || + (DTYPE(MuttVars[idx].type) == DT_COMMAND) || (DTYPE(MuttVars[idx].type) == DT_ADDRESS) || (DTYPE(MuttVars[idx].type) == DT_MBTABLE)))) { @@ -2197,7 +2201,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data, *((char **) MuttVars[idx].var) = mutt_str_strdup(scratch); } } - else if ((idx >= 0) && (DTYPE(MuttVars[idx].type) == DT_STRING)) + else if ((idx >= 0) && ((DTYPE(MuttVars[idx].type) == DT_STRING) || (DTYPE(MuttVars[idx].type) == DT_COMMAND))) { if ((strstr(MuttVars[idx].name, "charset") && check_charset(&MuttVars[idx], buf->data) < 0) | @@ -4223,6 +4227,7 @@ int mutt_option_set(const struct Option *val, struct Buffer *err) break; } case DT_STRING: + case DT_COMMAND: { /* MuttVars[idx].var is already 'char**' (or some 'void**') or... * so cast to 'void*' is okay */ diff --git a/init.h b/init.h index 4691cd16d..306ba8eb6 100644 --- a/init.h +++ b/init.h @@ -761,7 +761,7 @@ struct Option MuttVars[] = { ** If this option is \fIset\fP, NeoMutt's received-attachments menu will not show the subparts of ** individual messages in a multipart/digest. To see these subparts, press ``v'' on that menu. */ - { "display_filter", DT_PATH, R_PAGER, &DisplayFilter, 0 }, + { "display_filter", DT_COMMAND, R_PAGER, &DisplayFilter, 0 }, /* ** .pp ** When set, specifies a command used to filter messages. When a message @@ -842,7 +842,7 @@ struct Option MuttVars[] = { ** \fBNote\fP that changes made to the References: and Date: headers are ** ignored for interoperability reasons. */ - { "editor", DT_PATH, R_NONE, &Editor, IP "vi" }, + { "editor", DT_COMMAND, R_NONE, &Editor, IP "vi" }, /* ** .pp ** This variable specifies which editor is used by NeoMutt. @@ -1645,7 +1645,7 @@ struct Option MuttVars[] = { ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too. */ #ifdef USE_NNTP - { "inews", DT_PATH, R_NONE, &Inews, 0 }, + { "inews", DT_COMMAND, R_NONE, &Inews, 0 }, /* ** .pp ** If set, specifies the program and arguments used to deliver news posted @@ -1666,7 +1666,7 @@ struct Option MuttVars[] = { ** .te */ #endif - { "ispell", DT_PATH, R_NONE, &Ispell, IP ISPELL }, + { "ispell", DT_COMMAND, R_NONE, &Ispell, IP ISPELL }, /* ** .pp ** How to invoke ispell (GNU's spell-checking software). @@ -1935,7 +1935,7 @@ struct Option MuttVars[] = { ** is Usenet article, because MIME for news is nonstandard feature. */ #endif - { "mime_type_query_command", DT_STRING, R_NONE, &MimeTypeQueryCommand, 0 }, + { "mime_type_query_command", DT_COMMAND, R_NONE, &MimeTypeQueryCommand, 0 }, /* ** .pp ** This specifies a command to run, to determine the mime type of a @@ -1975,7 +1975,7 @@ struct Option MuttVars[] = { ** .dt %s .dd The remailer's short name ** .de */ - { "mixmaster", DT_PATH, R_NONE, &Mixmaster, IP MIXMASTER }, + { "mixmaster", DT_COMMAND, R_NONE, &Mixmaster, IP MIXMASTER }, /* ** .pp ** This variable contains the path to the Mixmaster binary on your @@ -2008,7 +2008,7 @@ struct Option MuttVars[] = { ** See also $$read_inc, $$write_inc and $$net_inc. */ #endif - { "new_mail_command", DT_PATH, R_NONE, &NewMailCommand, 0 }, + { "new_mail_command", DT_COMMAND, R_NONE, &NewMailCommand, 0 }, /* ** .pp ** If \fIset\fP, NeoMutt will call this command after a new message is received. @@ -2189,7 +2189,7 @@ struct Option MuttVars[] = { ** connect to news server. */ #endif - { "pager", DT_PATH, R_NONE, &Pager, IP "builtin" }, + { "pager", DT_COMMAND, R_NONE, &Pager, IP "builtin" }, /* ** .pp ** This variable specifies which pager you would like to use to view @@ -2296,7 +2296,7 @@ struct Option MuttVars[] = { ** against $$pgp_decryption_okay. ** (PGP only) */ - { "pgp_clearsign_command", DT_STRING, R_NONE, &PgpClearsignCommand, 0 }, + { "pgp_clearsign_command", DT_COMMAND, R_NONE, &PgpClearsignCommand, 0 }, /* ** .pp ** This format is used to create an old-style ``clearsigned'' PGP @@ -2307,7 +2307,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (PGP only) */ - { "pgp_decode_command", DT_STRING, R_NONE, &PgpDecodeCommand, 0 }, + { "pgp_decode_command", DT_COMMAND, R_NONE, &PgpDecodeCommand, 0 }, /* ** .pp ** This format strings specifies a command which is used to decode @@ -2331,7 +2331,7 @@ struct Option MuttVars[] = { ** alongside the documentation. ** (PGP only) */ - { "pgp_decrypt_command", DT_STRING, R_NONE, &PgpDecryptCommand, 0 }, + { "pgp_decrypt_command", DT_COMMAND, R_NONE, &PgpDecryptCommand, 0 }, /* ** .pp ** This command is used to decrypt a PGP encrypted message. @@ -2366,7 +2366,7 @@ struct Option MuttVars[] = { ** variable, and should no longer be used. ** (PGP only) */ - { "pgp_encrypt_only_command", DT_STRING, R_NONE, &PgpEncryptOnlyCommand, 0 }, + { "pgp_encrypt_only_command", DT_COMMAND, R_NONE, &PgpEncryptOnlyCommand, 0 }, /* ** .pp ** This command is used to encrypt a body part without signing it. @@ -2375,7 +2375,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (PGP only) */ - { "pgp_encrypt_sign_command", DT_STRING, R_NONE, &PgpEncryptSignCommand, 0 }, + { "pgp_encrypt_sign_command", DT_COMMAND, R_NONE, &PgpEncryptSignCommand, 0 }, /* ** .pp ** This command is used to both sign and encrypt a body part. @@ -2405,7 +2405,7 @@ struct Option MuttVars[] = { ** .pp ** (PGP only) */ - { "pgp_export_command", DT_STRING, R_NONE, &PgpExportCommand, 0 }, + { "pgp_export_command", DT_COMMAND, R_NONE, &PgpExportCommand, 0 }, /* ** .pp ** This command is used to export a public key from the user's @@ -2415,7 +2415,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (PGP only) */ - { "pgp_getkeys_command", DT_STRING, R_NONE, &PgpGetkeysCommand, 0 }, + { "pgp_getkeys_command", DT_COMMAND, R_NONE, &PgpGetkeysCommand, 0 }, /* ** .pp ** This command is invoked whenever NeoMutt needs to fetch the public key associated with @@ -2442,7 +2442,7 @@ struct Option MuttVars[] = { ** if you want to play interesting key selection games. ** (PGP only) */ - { "pgp_import_command", DT_STRING, R_NONE, &PgpImportCommand, 0 }, + { "pgp_import_command", DT_COMMAND, R_NONE, &PgpImportCommand, 0 }, /* ** .pp ** This command is used to import a key from a message into @@ -2452,7 +2452,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (PGP only) */ - { "pgp_list_pubring_command", DT_STRING, R_NONE, &PgpListPubringCommand, 0 }, + { "pgp_list_pubring_command", DT_COMMAND, R_NONE, &PgpListPubringCommand, 0 }, /* ** .pp ** This command is used to list the public key ring's contents. The @@ -2469,7 +2469,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (PGP only) */ - { "pgp_list_secring_command", DT_STRING, R_NONE, &PgpListSecringCommand, 0 }, + { "pgp_list_secring_command", DT_COMMAND, R_NONE, &PgpListSecringCommand, 0 }, /* ** .pp ** This command is used to list the secret key ring's contents. The @@ -2564,7 +2564,7 @@ struct Option MuttVars[] = { ** to specify your key (e.g. \fC0x00112233\fP). ** (PGP only) */ - { "pgp_sign_command", DT_STRING, R_NONE, &PgpSignCommand, 0 }, + { "pgp_sign_command", DT_COMMAND, R_NONE, &PgpSignCommand, 0 }, /* ** .pp ** This command is used to create the detached PGP signature for a @@ -2614,7 +2614,7 @@ struct Option MuttVars[] = { ** NeoMutt no longer verifies if the agent is running. ** (PGP only) */ - { "pgp_verify_command", DT_STRING, R_NONE, &PgpVerifyCommand, 0 }, + { "pgp_verify_command", DT_COMMAND, R_NONE, &PgpVerifyCommand, 0 }, /* ** .pp ** This command is used to verify PGP signatures. @@ -2623,7 +2623,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (PGP only) */ - { "pgp_verify_key_command", DT_STRING, R_NONE, &PgpVerifyKeyCommand, 0 }, + { "pgp_verify_key_command", DT_COMMAND, R_NONE, &PgpVerifyKeyCommand, 0 }, /* ** .pp ** This command is used to verify key information from the key selection @@ -2819,7 +2819,7 @@ struct Option MuttVars[] = { ** This is set to ``ask-no'' by default, because some people ** accidentally hit ``p'' often. */ - { "print_command", DT_PATH, R_NONE, &PrintCommand, IP "lpr" }, + { "print_command", DT_COMMAND, R_NONE, &PrintCommand, IP "lpr" }, /* ** .pp ** This specifies the command pipe that should be used to print messages. @@ -2856,7 +2856,7 @@ struct Option MuttVars[] = { ** than returning to the index menu. If \fIunset\fP, NeoMutt will return to the ** index menu when the external pager exits. */ - { "query_command", DT_PATH, R_NONE, &QueryCommand, 0 }, + { "query_command", DT_COMMAND, R_NONE, &QueryCommand, 0 }, /* ** .pp ** This specifies the command NeoMutt will use to make external address @@ -3220,7 +3220,7 @@ struct Option MuttVars[] = { ** In case the text cannot be converted into one of these exactly, ** NeoMutt uses $$charset as a fallback. */ - { "sendmail", DT_PATH, R_NONE, &Sendmail, IP SENDMAIL " -oem -oi" }, + { "sendmail", DT_COMMAND, R_NONE, &Sendmail, IP SENDMAIL " -oem -oi" }, /* ** .pp ** Specifies the program and arguments used to deliver mail sent by NeoMutt. @@ -3247,7 +3247,7 @@ struct Option MuttVars[] = { ** process will be put in a temporary file. If there is some error, you ** will be informed as to where to find the output. */ - { "shell", DT_PATH, R_NONE, &Shell, 0 }, + { "shell", DT_COMMAND, R_NONE, &Shell, 0 }, /* ** .pp ** Command to use when spawning a subshell. @@ -3528,7 +3528,7 @@ struct Option MuttVars[] = { ** the location of the certificates. ** (S/MIME only) */ - { "smime_decrypt_command", DT_STRING, R_NONE, &SmimeDecryptCommand, 0 }, + { "smime_decrypt_command", DT_COMMAND, R_NONE, &SmimeDecryptCommand, 0 }, /* ** .pp ** This format string specifies a command which is used to decrypt @@ -3581,7 +3581,7 @@ struct Option MuttVars[] = { ** variable, and should no longer be used. ** (S/MIME only) */ - { "smime_encrypt_command", DT_STRING, R_NONE, &SmimeEncryptCommand, 0 }, + { "smime_encrypt_command", DT_COMMAND, R_NONE, &SmimeEncryptCommand, 0 }, /* ** .pp ** This command is used to create encrypted S/MIME messages. @@ -3602,7 +3602,7 @@ struct Option MuttVars[] = { ** Valid choices are ``aes128'', ``aes192'', ``aes256'', ``des'', ``des3'', ``rc2-40'', ``rc2-64'', ``rc2-128''. ** (S/MIME only) */ - { "smime_get_cert_command", DT_STRING, R_NONE, &SmimeGetCertCommand, 0 }, + { "smime_get_cert_command", DT_COMMAND, R_NONE, &SmimeGetCertCommand, 0 }, /* ** .pp ** This command is used to extract X509 certificates from a PKCS7 structure. @@ -3611,7 +3611,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (S/MIME only) */ - { "smime_get_cert_email_command", DT_STRING, R_NONE, &SmimeGetCertEmailCommand, 0 }, + { "smime_get_cert_email_command", DT_COMMAND, R_NONE, &SmimeGetCertEmailCommand, 0 }, /* ** .pp ** This command is used to extract the mail address(es) used for storing @@ -3622,7 +3622,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (S/MIME only) */ - { "smime_get_signer_cert_command", DT_STRING, R_NONE, &SmimeGetSignerCertCommand, 0 }, + { "smime_get_signer_cert_command", DT_COMMAND, R_NONE, &SmimeGetSignerCertCommand, 0 }, /* ** .pp ** This command is used to extract only the signers X509 certificate from a S/MIME @@ -3633,7 +3633,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (S/MIME only) */ - { "smime_import_cert_command", DT_STRING, R_NONE, &SmimeImportCertCommand, 0 }, + { "smime_import_cert_command", DT_COMMAND, R_NONE, &SmimeImportCertCommand, 0 }, /* ** .pp ** This command is used to import a certificate via smime_keys. @@ -3664,7 +3664,7 @@ struct Option MuttVars[] = { ** edited. This option points to the location of the private keys. ** (S/MIME only) */ - { "smime_pk7out_command", DT_STRING, R_NONE, &SmimePk7outCommand, 0 }, + { "smime_pk7out_command", DT_COMMAND, R_NONE, &SmimePk7outCommand, 0 }, /* ** .pp ** This command is used to extract PKCS7 structures of S/MIME signatures, @@ -3688,7 +3688,7 @@ struct Option MuttVars[] = { ** to the signing key. Most people will only need to set $$smime_default_key. ** (S/MIME only) */ - { "smime_sign_command", DT_STRING, R_NONE, &SmimeSignCommand, 0 }, + { "smime_sign_command", DT_COMMAND, R_NONE, &SmimeSignCommand, 0 }, /* ** .pp ** This command is used to created S/MIME signatures of type @@ -3712,7 +3712,7 @@ struct Option MuttVars[] = { ** not used. ** (S/MIME only) */ - { "smime_verify_command", DT_STRING, R_NONE, &SmimeVerifyCommand, 0 }, + { "smime_verify_command", DT_COMMAND, R_NONE, &SmimeVerifyCommand, 0 }, /* ** .pp ** This command is used to verify S/MIME signatures of type \fCmultipart/signed\fP. @@ -3721,7 +3721,7 @@ struct Option MuttVars[] = { ** possible \fCprintf(3)\fP-like sequences. ** (S/MIME only) */ - { "smime_verify_opaque_command", DT_STRING, R_NONE, &SmimeVerifyOpaqueCommand, 0 }, + { "smime_verify_opaque_command", DT_COMMAND, R_NONE, &SmimeVerifyOpaqueCommand, 0 }, /* ** .pp ** This command is used to verify S/MIME signatures of type @@ -4356,7 +4356,7 @@ struct Option MuttVars[] = { ** virtual-mailboxes) as a spool file. */ #endif - { "visual", DT_PATH, R_NONE, &Visual, IP "vi" }, + { "visual", DT_COMMAND, R_NONE, &Visual, IP "vi" }, /* ** .pp ** Specifies the visual editor to invoke when the ``\fC~v\fP'' command is diff --git a/mutt_lua.c b/mutt_lua.c index 2c05ab160..a40d84c3d 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -142,6 +142,7 @@ static int lua_mutt_set(lua_State *l) case DT_MBTABLE: case DT_REGEX: case DT_PATH: + case DT_COMMAND: case DT_SORT: case DT_STRING: opt.var = mutt_str_strdup(lua_tostring(l, -1)); @@ -225,6 +226,7 @@ static int lua_mutt_get(lua_State *l) return 1; } case DT_PATH: + case DT_COMMAND: case DT_STRING: if (mutt_str_strncmp("my_", param, 3) == 0) { diff --git a/mutt_options.h b/mutt_options.h index 20ce047c1..05209caf2 100644 --- a/mutt_options.h +++ b/mutt_options.h @@ -42,6 +42,7 @@ struct Buffer; #define DT_MBTABLE 11 /**< multibyte char table */ #define DT_LONG 12 /* a number (long) */ #define DT_HCACHE 13 /**< header cache backend */ +#define DT_COMMAND 14 /**< A command*/ #define DTYPE(x) ((x) &DT_MASK)