From 38f84edc01741e6f08c27efded1f43acb7db2bec Mon Sep 17 00:00:00 2001 From: nohar Date: Mon, 25 Sep 2006 12:08:31 +0000 Subject: [PATCH] Debug away msg when no client on. --- ChangeLog | 6 +++++- TODO | 8 -------- src/bip.c | 21 ++++++--------------- src/conf.y | 2 ++ src/irc.c | 17 ++++++++++++----- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index f26f2d4..f6dba9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-09-25 Arnaud Cornet + + * *: Debug no_client_away_msg. + 2006-09-23 Arnaud Cornet * src/irc.c: Untested oidentd IPV6 support. @@ -6,7 +10,7 @@ * src/bip.c: umask for better permissions when using in system mode. * src/irc.c: added no_client_away_msg configuration directive and - code. + code as well as support for multiple on_connect_send. 2006-07-02 Arnaud Cornet diff --git a/TODO b/TODO index aa810f3..34806e6 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ - uid, gid -- multiple on_connect_send - keep invites when detached ? - allow global (or per net ?) IP filtering - more /bip commands @@ -23,10 +22,3 @@ Thanks a lot for your help. Best regards, Whoopie -- -Donner des droits plus méchants au log global - -DONE: - -11:23 < KiBi> Un /away truc chose automatique quand plus aucun client n'est - attaché. -- in english: automatic command when no more client is connected diff --git a/src/bip.c b/src/bip.c index e163532..141a59e 100644 --- a/src/bip.c +++ b/src/bip.c @@ -395,6 +395,8 @@ void c_connection_free(struct c_connection *c) } free(c->away_nick); + free(c->no_client_away_msg); + char *s; while ((s = list_remove_first(&c->on_connect_send))) free(s); @@ -457,8 +459,10 @@ static int add_connection(list_t *connectionl, list_t *data, case LEX_AWAY_NICK: c->away_nick = t->pdata; break; + case LEX_NO_CLIENT_AWAY_MSG: + c->no_client_away_msg = t->pdata; + break; case LEX_ON_CONNECT_SEND: - printf("lex: %s\n", t->pdata); list_add_last(&c->on_connect_send, t->pdata); break; default: @@ -816,13 +820,6 @@ void ircize(list_t *ll) link->follow_nick = c->follow_nick; link->ignore_first_nick = c->ignore_first_nick; - list_iterator_t ocsit; - for (list_it_init(&c->on_connect_send, &ocsit); - list_it_item(&ocsit); - list_it_next(&ocsit)) { - printf("yo:%s\n", list_it_item(&ocsit)); - } - char *s; while ((s = list_remove_first( &link->on_connect_send))) { @@ -831,12 +828,6 @@ void ircize(list_t *ll) list_append(&c->on_connect_send, &link->on_connect_send); - for (list_it_init(&link->on_connect_send, &ocsit); - list_it_item(&ocsit); - list_it_next(&ocsit)) { - printf("fin:%s\n", (char *)list_it_item(&ocsit)); - } - link->away_nick = strmaydup(c->away_nick); link->no_client_away_msg = @@ -1063,7 +1054,7 @@ int ssl_check_trust(struct link_client *ic) if(!LINK(ic)->untrusted_certs || sk_X509_num(LINK(ic)->untrusted_certs) <= 0) return 0; - + trustcert = sk_X509_value(LINK(ic)->untrusted_certs, 0); strcpy(subject, "Subject: "); strcpy(issuer, "Issuer: "); diff --git a/src/conf.y b/src/conf.y index c71ceb8..2add572 100644 --- a/src/conf.y +++ b/src/conf.y @@ -187,6 +187,8 @@ con_command: LEX_CHANNEL, $3); } | LEX_ON_CONNECT_SEND LEX_EQ LEX_STRING { $$ = tuple_s_new( LEX_ON_CONNECT_SEND, $3); } + | LEX_NO_CLIENT_AWAY_MSG LEX_EQ LEX_STRING { $$ = tuple_s_new( + LEX_NO_CLIENT_AWAY_MSG, $3); } channel: { $$ = list_new(NULL); } | channel cha_command LEX_SEMICOLON { list_add_last($1, $2); $$ = $1; } diff --git a/src/irc.c b/src/irc.c index 4e14772..c22d228 100644 --- a/src/irc.c +++ b/src/irc.c @@ -321,10 +321,19 @@ static void irc_server_connected(struct link_server *server) list_it_item(&itocs); list_it_next(&itocs)) { ssize_t len = strlen(list_it_item(&itocs)) + 2; char *str = malloc(len + 1); - sprintf(str, "%s\r\n", list_it_item(&itocs)); + sprintf(str, "%s\r\n", (char *)list_it_item(&itocs)); write_line(CONN(server), str); free(str); } + + if (LINK(server)->l_clientc == 0) { + if (LINK(server)->away_nick) + WRITE_LINE1(CONN(server), NULL, "NICK", + LINK(server)->away_nick); + if (LINK(server)->no_client_away_msg) + WRITE_LINE1(CONN(server), NULL, "AWAY", + LINK(server)->no_client_away_msg); + } } static int who_arg_to_ovmask(char *str) @@ -829,10 +838,8 @@ static int irc_cli_startup(struct link_client *ic, struct line *line, LINK(server)->connect_nick); /* change away status */ - if (LINK(ic)->l_clientc == 0) { - if (server && LINK(ic)->no_client_away_msg) - WRITE_LINE0(CONN(server), NULL, "AWAY"); - } + if (server && LINK(ic)->no_client_away_msg) + WRITE_LINE0(CONN(server), NULL, "AWAY"); } free(initmask);