Added 'send_events' boolean argument to the function
authorPekka Riikonen <priikone@silcnet.org>
Sun, 20 Oct 2002 16:57:55 +0000 (16:57 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 20 Oct 2002 16:57:55 +0000 (16:57 +0000)
which sends the set events to the application explicitly if set
to TRUE.  Default action should be FALSE.i

CHANGES
apps/irssi/docs/faq.txt
apps/silcd/server_internal.h
lib/silcclient/client.c
lib/silcclient/client_ftp.c
lib/silcclient/client_internal.h
lib/silcclient/client_keyagr.c
lib/silcsftp/tests/sftp_client.c
lib/silcsftp/tests/sftp_server.c
lib/silcutil/silcschedule.c
lib/silcutil/silcschedule.h

diff --git a/CHANGES b/CHANGES
index 5537770f0e6ad7c05fa52f18d998a48d9099f953..bb2f48f882925b908ceab3c1ed5f17f145c8dfce 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+Sun Oct 20 19:54:55 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Added 'send_events' boolean argument to the function
+         silc_schedule_set_listen_fd which sends the set events to
+         the application explicitly if set to TRUE.  Default action
+         should be FALSE.  Affected file lib/silcutil/silcschedule.[ch],
+         lib/silcclient/client_internal.h and silcd/server_internal.h.
+
 Sun Oct 20 14:12:24 CEST 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * Merged with irssi.org CVS.
index 499f243bfaff722bd5ed62deb1b5359e357c6872..dca3c35e69f1bbfaaf5cb56b2652a8bb7b10586c 100644 (file)
@@ -1,11 +1,11 @@
    FAQ
 
 Q: Why doesn't irssi display colors even when ircii etc. displays them?
-A:  They  force  ANSI colors even if terminal doesn't support them. By
-   default,  irssi  uses  colors  only  if  terminfo/termcap so says. The
-   correct  way to fix this would be to change your TERM environment to a
-   value   where  colors  work,  like  xterm-color  or  color_xterm  (eg.
-   TERM=xterm-color  irssi).  If this doesn't help, then use the evil way
+A: They force ANSI colors even if terminal doesn't support them. By
+   default, irssi uses colors only if terminfo/termcap so says. The
+   correct way to fix this would be to change your TERM environment to a
+   value where colors work, like xterm-color or color_xterm (eg.
+   TERM=xterm-color irssi). If this doesn't help, then use the evil way
    of /SET term_force_colors ON.
 
 Q: How do I easily write text to channel that starts with '/' character?
@@ -13,17 +13,17 @@ A: / /text
 
 Q: Why doesn't irssi update my realname (or whatever) after I change it with
    /SET realname and reconnect with /RECONNECT or /SERVER?
-A:  Irssi is trying to be too smart. This will be fixed in future, but
+A: Irssi is trying to be too smart. This will be fixed in future, but
    for now you should use /DISCONNECT and /CONNECT.
 
 Q: I connected to some server which isn't responding but now irssi tries to
    connect back to it all the time! How can I stop it?
-A:  Two  ways.  The "good way" to do it is with /DISCONNECT. Check the
-   server  tags  first  with  /SERVER  without  giving it any parameters,
-   reconnections  are  those that have tag starting with "recon" text. So
+A: Two ways. The "good way" to do it is with /DISCONNECT. Check the
+   server tags first with /SERVER without giving it any parameters,
+   reconnections are those that have tag starting with "recon" text. So
    most probably you're going to do /DISCONNECT recon-1. The other way is
    to remove all the reconnections with /RMRECONNS, easier but may remove
-   some  connections  you  actually  wanted  to  reconnect  (if  you used
+   some connections you actually wanted to reconnect (if you used
    multiple servers..).
 
 Q: How do I add seconds to timestamp?
@@ -32,16 +32,16 @@ A: /FORMAT timestamp {timestamp %%H:%%M:%%S} - and remember to add the
 
 Q: Why does irssi say "Irssi: Channel not fully synchronized yet, try again
    after a while" when I try to use /BAN etc?
-A:  Possibly  a bug in irssi, or ircd you're using does something that
-   irssi  didn't  really notice. The new code should make this happen far
-   less  often  than  before, but one known reason for this is when irssi
-   doesn't  notice  that  you were unable to join some channel. Currently
+A: Possibly a bug in irssi, or ircd you're using does something that
+   irssi didn't really notice. The new code should make this happen far
+   less often than before, but one known reason for this is when irssi
+   doesn't notice that you were unable to join some channel. Currently
    however I don't know of any such events irssi doesn't know about.
 
-   Anyway,  if  this  does  happen,  do  /RAWLOG SAVE ~/rawlog soon after
-   joining  to  channel,  and either try to figure out yourself why irssi
-   didn't   get   reply  to  WHO  request,  or  send  the  whole  log  to
-   cras@irssi.org.  Note that the rawlog is by default only 200 lines and
+   Anyway, if this does happen, do /RAWLOG SAVE ~/rawlog soon after
+   joining to channel, and either try to figure out yourself why irssi
+   didn't get reply to WHO request, or send the whole log to
+   cras@irssi.org. Note that the rawlog is by default only 200 lines and
    it may not be enough to show all needed information, so you might want
    to do /SET rawlog_lines 1000 or so.
 
@@ -51,67 +51,56 @@ Q: Where's the GUI version?
 A: Read http://irssi.org/?page=about
 
 Q: How do I autorejoin channels after being kicked?
-A:  That's evil and you shouldn't do it. If you get kicked, you should
-   stay  out,  at  least  until  the  channel  forgot you existed :) Most
-   channels  I've  joined  just  ban you if you autorejoin after kick. If
-   you're  joined  to  channels  who  kick  people  for fun, try changing
+A: That's evil and you shouldn't do it. If you get kicked, you should
+   stay out, at least until the channel forgot you existed :) Most
+   channels I've joined just ban you if you autorejoin after kick. If
+   you're joined to channels who kick people for fun, try changing
    channels or something.
 
-   Anyway,  if you REALLY want to do that, and you understand that you're
-   doing  evilness,  you can use the autorejoin.pl script that comes with
-   irssi.  You'll  still  need to specify the channels you wish to rejoin
+   Anyway, if you REALLY want to do that, and you understand that you're
+   doing evilness, you can use the autorejoin.pl script that comes with
+   irssi. You'll still need to specify the channels you wish to rejoin
    with /SET autorejoin_channels #chan1 #chan2 ...
 
 Q: How do I announce that I'm away/back in all channels I've joined? Or how
    do I change my nick when setting myself away/back?
-A:  That's  even  worse than autorejoin. Who could possibly care every
-   time  you come and go? Many channels will kick you for using this, and
-   I  for  example  have  added  several ignores so I'd never need to see
-   these  messages.  Learn  to  use  /AWAY command properly and tell it's
-   existence  to people who don't know about it. /WII yournick shows your
+A: That's even worse than autorejoin. Who could possibly care every
+   time you come and go? Many channels will kick you for using this, and
+   I for example have added several ignores so I'd never need to see
+   these messages. Learn to use /AWAY command properly and tell it's
+   existence to people who don't know about it. /WII yournick shows your
    away reason much better for people who actually want to know if you're
    there or not.
 
-   You  can  script these behaviours if you really wish to of course. But
-   currently  there's no public scripts for either of these, and the only
-   way  I'm  going  to  add such to irssi.org is if the script contains a
+   You can script these behaviours if you really wish to of course. But
+   currently there's no public scripts for either of these, and the only
+   way I'm going to add such to irssi.org is if the script contains a
    setting to specify which specific channels the announcement is sent.
 
 Q: Why does irssi autojoin on invite by default?
-A:  The  setting is /SET join_auto_chans_on_invite - it's not the same
+A: The setting is /SET join_auto_chans_on_invite - it's not the same
    as regular autojoin-on-invite, which irssi doesn't even have. The only
-   channels  that  are  joined  on  invite,  are the ones you've added to
-   config  with  /CHANNEL ADD -auto. This is very useful with +i channels
-   when  you  need  to first send an invite request to bot, or if you get
-   accidentally  kicked  from  channel,  the  kicker  can invite you back
+   channels that are joined on invite, are the ones you've added to
+   config with /CHANNEL ADD -auto. This is very useful with +i channels
+   when you need to first send an invite request to bot, or if you get
+   accidentally kicked from channel, the kicker can invite you back
    immediately.
 
-   I  don't  see  any  bad  side effects with this feature, so it's ON by
+   I don't see any bad side effects with this feature, so it's ON by
    default. I guess someone could start kicking/inviting you all the time
-   but  server  connection  shouldn't  drop  because  of  that,  and  you
+   but server connection shouldn't drop because of that, and you
    shouldn't join channels whose operators are that evil.
 
 Q: How to make UTF-8 support work with irssi?
 A: xterm -u8, screen -U, /SET term_type utf-8
 
 Q: Will there be /DETACH-like feature?
-A:  Maybe. Detach code already is there, attach is just missing :) But
+A: Maybe. Detach code already is there, attach is just missing :) But
    I don't have much interest in coding it, and screen works just fine so
    why bother?
 
 Q: How do I run scripts automatically at startup?
-A:  Put them into ~/.irssi/scripts/autorun/ directory. Or better would
-   be  if  you  placed  them in ~/.irssi/scripts/ and created symlinks to
-   autorun   directory   (eg.   cd   ~/.irssi/scripts/autorun/  ;  ln  -s
+A: Put them into ~/.irssi/scripts/autorun/ directory. Or better would
+   be if you placed them in ~/.irssi/scripts/ and created symlinks to
+   autorun directory (eg. cd ~/.irssi/scripts/autorun/ ; ln -s
    ../script.pl .)
-
-Q: How do I easily edit existing topic?
-A: /TOPIC <tab>
-
-Q: How can I have /WHOIS replies to active window?
-A:  Currently there's no other way than to close the status window, or
-   at least do /WINDOW LEVEL -CRAP in it, but that would make a lot other
-   messages  show  up  in active window too. I don't have many good ideas
-   how  this  could be easily fixed inside irssi (no, kludging it to only
-   work  with  whois isn't a "fix") - it'd be possible to create a script
-   do this though but currently it doesn't exist.
index e521db68fedfec1bb0d829b58cb716f3da73fa7c..2e7024f9fa87690ac91617ca08ac7beb4c438174 100644 (file)
@@ -181,14 +181,15 @@ do {                                                      \
                         SILC_TASK_PRI_NORMAL);         \
 } while(0)
 
-#define SILC_SET_CONNECTION_FOR_INPUT(s, fd)                   \
-do {                                                           \
-  silc_schedule_set_listen_fd((s), (fd), SILC_TASK_READ);      \
+#define SILC_SET_CONNECTION_FOR_INPUT(s, fd)                           \
+do {                                                                   \
+  silc_schedule_set_listen_fd((s), (fd), SILC_TASK_READ, FALSE);       \
 } while(0)
      
-#define SILC_SET_CONNECTION_FOR_OUTPUT(s, fd)                                \
-do {                                                                         \
-  silc_schedule_set_listen_fd((s), (fd), (SILC_TASK_READ | SILC_TASK_WRITE)); \
+#define SILC_SET_CONNECTION_FOR_OUTPUT(s, fd)                               \
+do {                                                                        \
+  silc_schedule_set_listen_fd((s), (fd), (SILC_TASK_READ | SILC_TASK_WRITE), \
+                             FALSE);                                        \
 } while(0)
 
 #define SILC_OPER_STATS_UPDATE(c, type, mod)   \
index e5ad7feda4699575e5cf7b9bfd1316316bbc64b0..d8f7dbdea3f6e7633bc04e99fda198fd0db8ebdf 100644 (file)
@@ -325,7 +325,8 @@ silc_client_connect_to_server_internal(SilcClientInternalConnectContext *ctx)
                                     (void *)ctx, 0, 0, 
                                     SILC_TASK_FD,
                                     SILC_TASK_PRI_NORMAL);
-  silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE);
+  silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE,
+                             FALSE);
 
   ctx->sock = sock;
 
index 7aac6b32f423b90a095385f5d33794b4625ef2a8..5d981a236236db35cd7213d0fea9664eee07e56d 100644 (file)
@@ -131,7 +131,8 @@ silc_client_connect_to_client_internal(SilcClientInternalConnectContext *ctx)
                                     (void *)ctx, 0, 0, 
                                     SILC_TASK_FD,
                                     SILC_TASK_PRI_NORMAL);
-  silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE);
+  silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE,
+                             FALSE);
   ctx->sock = sock;
   return sock;
 }
index 540795d524723cad25699e1c69f9fc3f6af30b84..40714fb8bc99ba884723f1a3fa405e9e479d403a 100644 (file)
@@ -102,15 +102,15 @@ do {                                                      \
                         SILC_TASK_PRI_NORMAL);         \
 } while(0)
 
-#define SILC_CLIENT_SET_CONNECTION_FOR_INPUT(s, fd)            \
-do {                                                           \
-  silc_schedule_set_listen_fd((s), (fd), SILC_TASK_READ);      \
+#define SILC_CLIENT_SET_CONNECTION_FOR_INPUT(s, fd)                    \
+do {                                                                   \
+  silc_schedule_set_listen_fd((s), (fd), SILC_TASK_READ, FALSE);       \
 } while(0)
      
-#define SILC_CLIENT_SET_CONNECTION_FOR_OUTPUT(s, fd)           \
-do {                                                           \
-  silc_schedule_set_listen_fd((s), (fd), (SILC_TASK_READ |     \
-                                         SILC_TASK_WRITE));    \
+#define SILC_CLIENT_SET_CONNECTION_FOR_OUTPUT(s, fd)                   \
+do {                                                                   \
+  silc_schedule_set_listen_fd((s), (fd), (SILC_TASK_READ |             \
+                                         SILC_TASK_WRITE), FALSE);     \
 } while(0)
 
 /* Finds socket connection object by file descriptor */
index 3e9efd5fd9375df0773e79db6d5f8002d9216abe..305c4b4bc7ef3c78ceee420f3f0845e2f7c9b1fb 100644 (file)
@@ -397,7 +397,8 @@ silc_client_connect_to_client_internal(SilcClientInternalConnectContext *ctx)
                                     (void *)ctx, 0, 0, 
                                     SILC_TASK_FD,
                                     SILC_TASK_PRI_NORMAL);
-  silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE);
+  silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE,
+                             FALSE);
 
   ctx->sock = sock;
 
index 0d6215cd1bbbf6c16556d3ca4a11b690e12fc2f2..f0c24d81852a67bd3e158f702853d5d0cabc1dab 100644 (file)
@@ -64,7 +64,7 @@ static void send_packet(SilcSocketConnection sock,
     return;
 
   silc_schedule_set_listen_fd(client->schedule, sock->sock, 
-                             (SILC_TASK_READ | SILC_TASK_WRITE));
+                             (SILC_TASK_READ | SILC_TASK_WRITE), FALSE);
   SILC_SET_OUTBUF_PENDING(sock);
 }
 
@@ -97,7 +97,7 @@ SILC_TASK_CALLBACK(packet_process)
     if (ret < 0)
       return;
 
-    silc_schedule_set_listen_fd(client->schedule, fd, SILC_TASK_READ);
+    silc_schedule_set_listen_fd(client->schedule, fd, SILC_TASK_READ, FALSE);
     SILC_UNSET_OUTBUF_PENDING(sock);
     silc_buffer_clear(sock->outbuf);
     return;
index bc5ac02e19d122408e936a5876763ceaee14e797..61e451cccafaf45e8f5079637234528bebe23c76 100644 (file)
@@ -51,7 +51,7 @@ static void send_packet(SilcSocketConnection sock,
     return;
 
   silc_schedule_set_listen_fd(server->schedule, sock->sock, 
-                             (SILC_TASK_READ | SILC_TASK_WRITE));
+                             (SILC_TASK_READ | SILC_TASK_WRITE), FALSE);
   SILC_SET_OUTBUF_PENDING(sock);
 }
 
@@ -87,7 +87,7 @@ SILC_TASK_CALLBACK(packet_process)
     if (ret < 0)
       return;
 
-    silc_schedule_set_listen_fd(server->schedule, fd, SILC_TASK_READ);
+    silc_schedule_set_listen_fd(server->schedule, fd, SILC_TASK_READ, FALSE);
     SILC_UNSET_OUTBUF_PENDING(sock);
     silc_buffer_clear(sock->outbuf);
     return;
index af37e9fc10729166dfd591d78ed0d5e3bdae2d50..97005ca1911e1c75c96b5cd6a209fda56fbfc73f 100644 (file)
@@ -742,7 +742,7 @@ SilcTask silc_schedule_task_add(SilcSchedule schedule, SilcUInt32 fd,
 
          /* Add the fd to be listened, the task found now applies to this
             fd as well. */
-         silc_schedule_set_listen_fd(schedule, fd, SILC_TASK_READ);
+         silc_schedule_set_listen_fd(schedule, fd, SILC_TASK_READ, FALSE);
          return task;
        }
        
@@ -781,7 +781,7 @@ SilcTask silc_schedule_task_add(SilcSchedule schedule, SilcUInt32 fd,
   /* If the task is non-timeout task we have to tell the scheduler that we
      would like to have these tasks scheduled at some odd distant future. */
   if (type != SILC_TASK_TIMEOUT)
-    silc_schedule_set_listen_fd(schedule, fd, SILC_TASK_READ);
+    silc_schedule_set_listen_fd(schedule, fd, SILC_TASK_READ, FALSE);
 
   silc_mutex_lock(queue->lock);
 
@@ -882,8 +882,8 @@ void silc_schedule_task_del_by_context(SilcSchedule schedule, void *context)
    call this directly if wanted. This can be called multiple times for
    one file descriptor to set different iomasks. */
 
-void silc_schedule_set_listen_fd(SilcSchedule schedule,
-                                SilcUInt32 fd, SilcTaskEvent iomask)
+void silc_schedule_set_listen_fd(SilcSchedule schedule, SilcUInt32 fd,
+                                SilcTaskEvent mask, bool send_events)
 {
   int i;
   bool found = FALSE;
@@ -896,10 +896,14 @@ void silc_schedule_set_listen_fd(SilcSchedule schedule,
   for (i = 0; i < schedule->max_fd; i++)
     if (schedule->fd_list[i].fd == fd) {
       schedule->fd_list[i].fd = fd;
-      schedule->fd_list[i].events = iomask;
+      schedule->fd_list[i].events = mask;
       if (i > schedule->last_fd)
        schedule->last_fd = i;
       found = TRUE;
+      if (send_events) {
+       schedule->fd_list[i].revents = mask;
+       silc_schedule_dispatch_nontimeout(schedule);
+      }
       break;
     }
 
@@ -907,9 +911,13 @@ void silc_schedule_set_listen_fd(SilcSchedule schedule,
     for (i = 0; i < schedule->max_fd; i++)
       if (schedule->fd_list[i].events == 0) {
        schedule->fd_list[i].fd = fd;
-       schedule->fd_list[i].events = iomask;
+       schedule->fd_list[i].events = mask;
        if (i > schedule->last_fd)
          schedule->last_fd = i;
+       if (send_events) {
+         schedule->fd_list[i].revents = mask;
+         silc_schedule_dispatch_nontimeout(schedule);
+       }
        break;
       }
 
index b7704e2962c7d085fe211efcb0c9aa4743793fd0..c7a8697edce282a0c399c672896b88eb90d3e3c2 100644 (file)
@@ -563,7 +563,7 @@ void silc_schedule_task_del_by_context(SilcSchedule schedule, void *context);
  * SYNOPSIS
  *
  *    void silc_schedule_set_listen_fd(SilcSchedule schedule, SilcUInt32 fd,
- *                                     SilcTaskEvent mask);
+ *                                     SilcTaskEvent mask, bool send_events);
  *
  * DESCRIPTION
  *
@@ -576,9 +576,14 @@ void silc_schedule_task_del_by_context(SilcSchedule schedule, void *context);
  *    whenever you need to change the events. This can be called multiple
  *    times to change the events.
  *
+ *    If the `send_events' is TRUE then this function sends the events
+ *    in `mask' to the application.  If FALSE then they are sent only
+ *    after the event occurs in reality.  In normal cases the `send_events'
+ *    is set to FALSE.
+ *
  ***/
 void silc_schedule_set_listen_fd(SilcSchedule schedule, SilcUInt32 fd,
-                                SilcTaskEvent mask);
+                                SilcTaskEvent mask, bool send_events);
 
 /****f* silcutil/SilcScheduleAPI/silc_schedule_unset_listen_fd
  *