irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit 01d7656a4b49aae5789f16db53b6dfe5695d4618
parent edddeb9110cb729925e1ebc4bb6a148e0784c1db
Author: Antoine Amarilli <ant.amarilli@free.fr>
Date:   Sun, 16 Jan 2011 03:31:31 +0100

use isatty

Diffstat:
irctk.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -47,6 +47,9 @@ #define E_CONNECT 2 #define E_THREAD 3 +#define DEFAULT_FIRST 0 +#define DEFAULT_LAST_IN 1 +#define DEFAULT_LAST_OUT 2 // TODO #define MAX_LEN 1024 @@ -79,7 +82,7 @@ static struct argp_option options[] = { {"own", 'o', 0, 0, "Also display messages posted by self" }, {"interval", 'i', "secs", 0, - "Wait delay between posted messages (default: 1)" }, + "Wait delay between posted messages (default: 0 for tty stdin, 1 for file/pipe)" }, /* TODO detect if stdin is a tty for delay configuration */ {"default-always-first", 'f', 0, 0, "Post messages to the first specified channel by default" }, @@ -119,6 +122,7 @@ struct arguments char ready; char last_chan_in[MAX_LEN]; char last_chans_out[MAX_LEN]; + int default_destination; }; @@ -129,11 +133,10 @@ struct arguments args; void initialize_args() { - /* TODO move to separate fun */ args.n_channels = 0; args.channels = (char**) NULL; args.verbose = 0; - args.interval = 1; + args.interval = isatty(fileno(stdin))?0:1; args.own = 0; args.nick = "irctk"; args.port = 6667; @@ -607,11 +610,12 @@ int main (int argc, char **argv) /* Default values. */ initialize_args(); + debug ("isatty? %s\n", isatty(fileno(stdin))?"yes":"no"); /* Parse our arguments; every option seen by parse_opt will be reflected in arguments. */ argp_parse (&argp, argc, argv, 0, 0, &args); - if (args.n_channels) + if (!args.n_channels) { strcpy(args.last_chan_in, args.nick); strcpy(args.last_chans_out, args.nick);