*
* This file is part of Trivial IP Encryption (TrIPE).
*
- * TrIPE is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * TrIPE is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
*
- * TrIPE is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * TrIPE is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
*
* You should have received a copy of the GNU General Public License
- * along with TrIPE; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with TrIPE. If not, see <https://www.gnu.org/licenses/>.
*/
/*----- Header files ------------------------------------------------------*/
static const char *logname = 0;
static FILE *logfp = 0;
static unsigned f = 0;
+static const char *watch = 0;
static int fd;
static const char *bgtag = 0;
-f, --logfile=FILE Log messages to FILE.\n\
-t, --no-timestamp When logging to a file, don't emit timestamps.\n\
-w, --warnings Show warnings when running commands.\n\
+-W, --watch=THINGS Watch for THINGS after connecting.\n\
", fp);
}
{ "logfile", OPTF_ARGREQ, 0, 'f' },
{ "no-timestamp", 0, 0, 't' },
{ "warnings", 0, 0, 'w' },
+ { "watch", OPTF_ARGREQ, 0, 'W' },
{ "pidfile", OPTF_ARGREQ, 0, 'P' },
{ 0, 0, 0, 0 }
};
- i = mdwopt(argc, argv, "+hvuDU:G:d:a:sp:S:lwf:nP:t", opts, 0, 0, 0);
+ i = mdwopt(argc, argv, "+hvuDU:G:d:a:sp:S:lwW:f:nP:t", opts, 0, 0, 0);
if (i < 0)
break;
switch (i) {
case 'w':
f |= f_warn;
break;
+ case 'W':
+ watch = optarg;
+ break;
case 'f':
logname = optarg;
f |= f_noinput;
/* --- If we're meant to be interactive, do that --- */
- if (optind == argc)
- setup("WATCH -A+tw");
+ if (optind == argc) {
+ DRESET(&d);
+ dstr_puts(&d, "watch");
+ u_quotify(&d, watch ? watch : "-A+tw");
+ setup(d.buf);
+ }
if (!(f & f_noinput) && optind == argc) {
selbuf_init(&bu, &sel, STDIN_FILENO, uline, &bu);
selbuf_init(&bs, &sel, fd, sline, &bs);
/* --- If there's a command, submit it --- */
if (optind < argc) {
- setup((f & f_warn) ? "WATCH -A+w" : "WATCH -A");
+ DRESET(&d);
+ dstr_puts(&d, "watch");
+ u_quotify(&d, watch ? watch : (f & f_warn) ? "-A+w" : "-A");
+ setup(d.buf);
+ DRESET(&d);
while (optind < argc)
u_quotify(&d, argv[optind++]);
dstr_putc(&d, '\n');