#if !defined(lint) && !defined(DOS) static char rcsid[] = "$Id: arg.c 900 2008-01-05 01:13:26Z hubert@u.washington.edu $"; #endif /* * ======================================================================== * Copyright 2013-2021 Eduardo Chappa * Copyright 2006-2008 University of Washington * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * ======================================================================== */ /*====================================================================== Command line argument parsing functions ====*/ #include "headers.h" #include "../pith/state.h" #include "../pith/init.h" #include "../pith/conf.h" #include "../pith/list.h" #include "../pith/util.h" #include "../pith/help.h" #include "imap.h" #include "arg.h" #include "xoauth2conf.h" int process_debug_str(char *); void args_add_attach(PATMT **, char *, int); int pinerc_cmdline_opt(char *); void display_config_options(char *, char *); extern char configoptions[]; /* * Name started as to invoke function key mode */ #define ALPINE_FKEY_NAME "alpinef" /* * Various error and informational strings.. */ /* TRANSLATORS: This is a list of errors printed when something goes wrong early on with the argument list. Be careful not to change literal option names mentioned in the strings. */ static char args_err_missing_pinerc[] = N_("missing argument for option \"-pinerc\" (use - for standard out)"); #if defined(DOS) || defined(OS2) static char args_err_missing_aux[] = N_("missing argument for option \"-aux\""); #endif #ifdef SMIME static char args_err_missing_smimedir[] = N_("missing argument for option \"-smimedir\""); static char args_err_non_abs_smimedir[] = N_("argument to \"-smimedir\" should be fully-qualified"); #endif /* SMIME */ #ifdef PASSFILE static char args_err_missing_passfile[] = N_("missing argument for option \"-passfile\""); static char args_err_non_abs_passfile[] = N_("argument to \"-passfile\" should be fully-qualified"); #ifdef SMIME static char args_err_missing_pwdcertdir[] = N_("missing argument for option \"-pwdcertdir\""); static char args_err_non_abs_pwdcertdir[] = N_("argument to \"-pwdcertdir\" should be fully-qualified"); #endif /* SMIME inside PASSFILE */ #endif static char args_err_missing_sort[] = N_("missing argument for option \"-sort\""); static char args_err_missing_flag_arg[] = N_("missing argument for flag \"%c\""); static char args_err_missing_flag_num[] = N_("Non numeric argument for flag \"%c\""); static char args_err_missing_debug_num[] = N_("Non numeric argument for \"%s\""); static char args_err_missing_url[] = N_("missing URL for \"-url\""); static char args_err_missing_attachment[] = N_("missing attachment for \"%s\""); static char args_err_conflict[] = N_("conflicting action: \"%s\""); static char args_err_unknown[] = N_("unknown flag \"%c\""); static char args_err_I_error[] = N_("-I argument \"%s\": %s"); static char args_err_d_error[] = N_("-d argument \"%s\": %s"); static char args_err_internal[] = "%s"; static char args_err_missing_copyprc[] = N_("missing argument for option \"-copy_pinerc\"\nUsage: pine -copy_pinerc "); static char args_err_missing_copyabook[] = N_("missing argument for option \"-copy_abook\"\nUsage: pine -copy_abook "); static char args_err_missing_server_name[] = N_("missing server name. Example: -xoauth2-server Gmail"); static char args_err_missing_client_id[] = N_("missing client-id name. Example: -xoauth2-client-id 760.someserver.com"); static char args_err_missing_client_secret[] = N_("missing client-secret name. Example: -xoauth2-client-secret V56i0fa_"); static char args_err_missing_tenant[] = N_("missing tenant value. Example: -xoauth2-tenant common"); static char args_err_missing_user[] = N_("missing username value. Example: -xoauth2-user user@example.com"); static char args_err_missing_xoauth_option[] = N_("at least one of the arguments -xoauth2-server, or -xoauth2-client-id, xoauth2-tenant, or -xoauth2-client-secret is missing."); static char *args_pine_args[] = { N_("Possible Starting Arguments for Alpine program:"), "", N_(" Argument\tMeaning"), N_(" ...\tGo directly into composer sending to given address"), N_("\t\tList multiple addresses with a single space between them."), N_("\t\tStandard input redirection is allowed with addresses."), N_("\t\tNote: Places addresses in the \"To\" field only."), N_(" -attach \tGo directly into composer with given file"), N_(" -attachlist "), N_(" -attach_and_delete "), N_("\t\tGo to composer, attach file, delete when finished"), N_("\t\tNote: Attach options can't be used if -f, -F"), N_("\t\tadded to Attachment list. Attachlist must be the last"), N_("\t\toption on the command line"), N_(" -bail\t\tExit if pinerc file doesn't already exist"), #ifdef DEBUG N_(" -d n\t\tDebug - set debug level to 'n', or use the following:"), N_(" -d keywords...\tflush,timestamp,imap=0..4,tcp,http,numfiles=0..31,verbose=0..9"), #endif N_(" -f \tFolder - give folder name to open"), N_(" -c \tContext - which context to apply to -f arg"), N_(" -F \tFile - give file name to open and page through and"), N_("\t\tforward as email."), N_(" -h \t\tHelp - give this list of options"), N_(" -k \t\tKeys - Force use of function keys"), N_(" -z \t\tSuspend - allow use of ^Z suspension"), N_(" -r \t\tRestricted - can only send mail to oneself"), N_(" -sort \tSort - Specify sort order of folder:"), N_("\t\t\tarrival, subject, threaded, orderedsubject, date,"), N_("\t\t\tfrom, size, score, to, cc, /reverse"), N_(" -i\t\tIndex - Go directly to index, bypassing main menu"), N_(" -I Initial keystrokes to be executed"), N_(" -n \tEntry in index to begin on"), N_(" -o \t\tReadOnly - Open first folder read-only"), N_(" -conf\t\tConfiguration - Print out fresh global configuration. The"), N_("\t\tvalues of your global configuration affect all Alpine users"), N_("\t\ton your system unless they have overridden the values in their"), N_("\t\tpinerc files."), N_(" -pinerc \tConfiguration - Put fresh pinerc configuration in "), N_(" -p \tUse alternate .pinerc file"), #if !defined(DOS) && !defined(OS2) N_(" -P \tUse alternate pine.conf file"), #else N_(" -aux \tUse this with remote pinerc"), N_(" -P \tUse pine.conf file for default settings"), N_(" -nosplash \tDisable the PC-Alpine splash screen"), #endif #if defined(APPLEKEYCHAIN) || (WINCRED > 0) N_(" -erase_stored_passwords\tEliminate any stored passwords"), #endif #ifdef SMIME N_(" -smimedir \tdirectory where smime personal certificates are saved"), #endif /* SMIME */ #ifdef PASSFILE N_(" -passfile \tSet the password file to something other"), N_("\t\tthan the default"), #ifdef SMIME N_(" -pwdcertdir \tSet the directory to store a personal"), N_("\t\tkey and certificate to encrypt and decrypt your password file."), #endif /* SMIME inside PASSFILE */ #endif /* PASSFILE */ #ifdef LOCAL_PASSWD_CACHE N_(" -nowrite_password_cache\tRead from a password cache if there is one, but"), N_("\t\t\t\tnever offer to write a password to the cache"), #endif /* LOCAL_PASSWD_CACHE */ N_(" -x \tUse configuration exceptions in ."), N_("\t\tExceptions are used to override your default pinerc"), N_("\t\tsettings for a particular platform, can be a local file or"), N_("\t\ta remote folder."), N_(" -v \t\tVersion - show version information"), N_(" -version\tVersion - show version information"), N_(" -supported\tList supported options"), N_(" -url \tOpen the given URL"), N_("\t\tNote: Can't be used if -f, -F"), N_("\t\tStandard input redirection is not allowed with URLs."), N_("\t\tFor mailto URLs, 'body='text should be used in place of"), N_("\t\tinput redirection."), N_(" -copy_pinerc copy local pinerc to remote"), N_(" -copy_abook copy local addressbook to remote"), N_(" -convert_sigs -p convert signatures to literal signatures"), #if defined(_WINDOWS) N_(" -install \tPrompt for some basic setup information"), N_(" -uninstall \tRemove traces of Alpine from Windows system settings"), N_(" -registry \tWhere cmd is set,noset,clear,clearsilent,dump"), #endif N_(" -xoauth2-server "), N_(" -xoauth2-client-id "), N_(" -xoauth2-client-secret "), N_("\tNote: All of -xoauth options above must be used, if any of them is used"), " -