From cc9d2eb79d4e4b7b46204b161bce25ccc685f600 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 17 Nov 2001 23:34:28 +0000 Subject: [PATCH] updates. --- CHANGES | 7 ++++++ apps/silcd/command.c | 13 ----------- includes/silcincludes.h | 2 ++ lib/silcclient/client_channel.c | 39 ++++++++++++++++++++++++++++----- lib/silcutil/silcbuffer.h | 10 ++++----- 5 files changed, 48 insertions(+), 23 deletions(-) diff --git a/CHANGES b/CHANGES index cdb6e907..e37638fd 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +Sun Nov 18 01:34:41 EET 2001 Pekka Riikonen + + * Fixed silc_client_channel_message to not try to decrypt + the message twice if it resolved the destination client + information. This could cause of dropping one channel + message. Affected file lib/silcclient/client_channel.c. + Wed Nov 14 23:44:56 EET 2001 Pekka Riikonen * Added silc_client_run_one into lib/silcclient/silcapi.h and diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 64fa02a2..80e4ed36 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -1937,22 +1937,9 @@ static int silc_server_command_bad_chars(char *nick) return TRUE; if (nick[i] <= 32) return TRUE; if (nick[i] == ' ') return TRUE; - if (nick[i] == '\\') return TRUE; - if (nick[i] == '\"') return TRUE; if (nick[i] == '*') return TRUE; if (nick[i] == '?') return TRUE; if (nick[i] == ',') return TRUE; - if (nick[i] == '@') return TRUE; - if (nick[i] == ':') return TRUE; - if (nick[i] == '/') return TRUE; - if (nick[i] == '[') return TRUE; - if (nick[i] == '[') return TRUE; - if (nick[i] == '(') return TRUE; - if (nick[i] == ')') return TRUE; - if (nick[i] == '{') return TRUE; - if (nick[i] == '}') return TRUE; - if (nick[i] == '<') return TRUE; - if (nick[i] == '>') return TRUE; } return FALSE; diff --git a/includes/silcincludes.h b/includes/silcincludes.h index 4484d576..3520afd1 100644 --- a/includes/silcincludes.h +++ b/includes/silcincludes.h @@ -211,8 +211,10 @@ typedef uint32 * void *; #endif #ifndef bool +#ifndef CXX #define bool unsigned char #endif +#endif /* Generic global SILC includes */ #include "bitmove.h" diff --git a/lib/silcclient/client_channel.c b/lib/silcclient/client_channel.c index 440c6999..aeb0ed85 100644 --- a/lib/silcclient/client_channel.c +++ b/lib/silcclient/client_channel.c @@ -155,17 +155,41 @@ void silc_client_send_channel_message(SilcClient client, silc_free(id_string); } +typedef struct { + SilcChannelMessagePayload payload; + SilcChannelID *channel_id; +} *SilcChannelClientResolve; + static void silc_client_channel_message_cb(SilcClient client, SilcClientConnection conn, SilcClientEntry *clients, uint32 clients_count, void *context) { - SilcPacketContext *packet = (SilcPacketContext *)context; + SilcChannelClientResolve res = (SilcChannelClientResolve)context; + + if (clients_count == 1) { + SilcIDCacheEntry id_cache = NULL; + SilcChannelEntry channel; + unsigned char *message; - if (clients) - silc_client_channel_message(client, conn->sock, packet); - silc_packet_context_free(packet); + if (!silc_idcache_find_by_id_one(conn->channel_cache, res->channel_id, + &id_cache)) + goto out; + + channel = (SilcChannelEntry)id_cache->context; + message = silc_channel_message_get_data(res->payload, NULL); + + /* Pass the message to application */ + client->ops->channel_message(client, conn, clients[0], channel, + silc_channel_message_get_flags(res->payload), + message); + } + + out: + silc_channel_message_payload_free(res->payload); + silc_free(res->channel_id); + silc_free(res); } /* Process received message to a channel (or from a channel, really). This @@ -257,9 +281,14 @@ void silc_client_channel_message(SilcClient client, if (!found) { /* Resolve the client info */ + SilcChannelClientResolve res = silc_calloc(1, sizeof(*res)); + res->payload = payload; + res->channel_id = id; silc_client_get_client_by_id_resolve(client, conn, client_id, silc_client_channel_message_cb, - silc_packet_context_dup(packet)); + res); + payload = NULL; + id = NULL; goto out; } diff --git a/lib/silcutil/silcbuffer.h b/lib/silcutil/silcbuffer.h index a6ca1897..9b35e922 100644 --- a/lib/silcutil/silcbuffer.h +++ b/lib/silcutil/silcbuffer.h @@ -196,7 +196,7 @@ unsigned char *silc_buffer_pull(SilcBuffer sb, uint32 len) unsigned char *old_data = sb->data; #ifdef SILC_DEBUG - assert(len <= (sb->tail - sb->data)); + assert(len <= (uint32)(sb->tail - sb->data)); #endif sb->data += len; @@ -260,7 +260,7 @@ unsigned char *silc_buffer_pull_tail(SilcBuffer sb, uint32 len) unsigned char *old_tail = sb->tail; #ifdef SILC_DEBUG - assert((sb->end - sb->tail) >= len); + assert((uint32)(sb->end - sb->tail) >= len); #endif sb->tail += len; @@ -318,7 +318,7 @@ unsigned char *silc_buffer_put_head(SilcBuffer sb, uint32 len) { #ifdef SILC_DEBUG - assert((sb->data - sb->head) >= len); + assert((uint32)(sb->data - sb->head) >= len); #endif return (unsigned char *)memcpy(sb->head, data, len); } @@ -340,7 +340,7 @@ unsigned char *silc_buffer_put(SilcBuffer sb, uint32 len) { #ifdef SILC_DEBUG - assert((sb->tail - sb->data) >= len); + assert((uint32)(sb->tail - sb->data) >= len); #endif return (unsigned char *)memcpy(sb->data, data, len); } @@ -362,7 +362,7 @@ unsigned char *silc_buffer_put_tail(SilcBuffer sb, uint32 len) { #ifdef SILC_DEBUG - assert((sb->end - sb->tail) >= len); + assert((uint32)(sb->end - sb->tail) >= len); #endif return (unsigned char *)memcpy(sb->tail, data, len); } -- 2.24.0