updates
authorPekka Riikonen <priikone@silcnet.org>
Tue, 29 Jan 2002 20:24:41 +0000 (20:24 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 29 Jan 2002 20:24:41 +0000 (20:24 +0000)
34 files changed:
CHANGES
Makefile.defines.pre
TODO
apps/irssi/src/core/nick-rec.h
apps/irssi/src/core/nicklist.c
apps/irssi/src/fe-text/screen.c
apps/irssi/src/fe-text/screen.h
apps/irssi/src/fe-text/silc.c
apps/irssi/src/silc/core/clientutil.c
apps/irssi/src/silc/core/silc-servers.c
apps/silcd/command.c
configure.in.pre
distributions
doc/CodingStyle
includes/silcincludes.h
lib/Makefile.am.pre
lib/silcclient/client.c
lib/silcclient/command.c
lib/silcclient/idlist.c
lib/silccrypt/silccipher.c
lib/silccrypt/silchash.c
lib/silccrypt/silcpkcs.c
lib/silccrypt/silcrng.c
lib/silcsftp/sftp_client.c
lib/silcutil/Makefile.am
lib/silcutil/silcbuffer.h
lib/silcutil/silcbufutil.h
lib/silcutil/silcdlist.h [new file with mode: 0644]
lib/silcutil/silclist.h [new file with mode: 0644]
prepare
prepare-clean
win32/Makefile.am
win32/libsilc/libsilc.def
win32/trq_conf.h [deleted file]

diff --git a/CHANGES b/CHANGES
index c6e15aca1b23f792fa3d6ae8c4e53fa240c093b9..c6eef9a96d805117101f94c5e7ca11c1460fbadf 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,15 @@
+Tue Jan 29 19:49:31 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Applied patches from cras:
+
+         Memory leak fixes around libaries, irssi window resize fix,
+         new silclist.h and silcdlist.h, all extern inline changed to
+         static inline.
+
+       * Removed dotconf from lib/dotconf, not needed anymore.
+
+       * Removed TRQ from lib/trq, not needed anymore.
+
 Tue Jan 29 10:35:03 CET 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * Fixed a crash in server related to channel announcements.
index af48710c8dd20f070a21d3251b1424ad723c2f2f..e85d49b625809a374c3ce3628e6eeaf708a0d043 100644 (file)
@@ -55,8 +55,7 @@ INCLUDES = $(ADD_INCLUDES) $(SILC_CFLAGS) \
        -I$(silc_top_srcdir)/lib/silcclient \
        -I$(silc_top_srcdir)/lib/contrib \
         -I$(silc_top_srcdir)/includes \
-        -I$(silc_top_srcdir)/doc \
-       -I$(silc_top_srcdir)/lib/trq
+        -I$(silc_top_srcdir)/doc
 
 #
 #includes-install: Makefile
diff --git a/TODO b/TODO
index 66182444f7510874d7294184b149d794da2fda67..d076aa66fb1a78779c3b997e9b4fd2388d9f4274 100644 (file)
--- a/TODO
+++ b/TODO
@@ -30,6 +30,9 @@ TODO/bugs in Irssi SILC client
 TODO/bugs In SILC Client Library
 ================================
 
+ o Rewrite the channel's user list thingy and cross list it to the
+   Client entry.
+
  o The PRIVATE_MESSAGE_KEY packet is not handled (it is implemented 
    though).  This should be added and perhaps new client operation
    should be added to notify application that it was received and
@@ -68,8 +71,7 @@ TODO/bugs In SILC Server
    each JOIN command will create and distribute the new channel key
    to everybody on the channel.
 
- o New configuration file format must be added.  The new one will be
-   done using the dotconf config library (lib/dotconf).  The following
+ o New configuration file format must be added.  The following
    tasks relates closely to this as well and must be done at the same time
    when adding the new config file format:
 
index 7dff6f32d606a96dbf66bc14b298ef232e7559ca..c4cd8bfd56fa79f2f52a87c4b5c4804677b66ffe 100644 (file)
@@ -20,8 +20,6 @@ unsigned int op:1;
 unsigned int halfop:1;
 unsigned int voice:1;
 
-GHashTable *module_data;
-
 void *unique_id; /* unique ID to use for comparing if one nick is in another channels,
                    or NULL = nicks are unique, just keep comparing them. */
 NICK_REC *next; /* support for multiple identically named nicks */
index f9539ff3f246fe1eaeeab43b1b9b90a0c9f84bf3..96f6a8ea2b870e7398d338d6506e06aa522f07d3 100644 (file)
@@ -76,8 +76,6 @@ static void nick_hash_remove(CHANNEL_REC *channel, NICK_REC *nick)
 /* Add new nick to list */
 void nicklist_insert(CHANNEL_REC *channel, NICK_REC *nick)
 {
-       MODULE_DATA_INIT(nick);
-
        nick->type = module_get_uniq_id("NICK", 0);
         nick->chat_type = channel->chat_type;
 
index 5378b5c9e48a7aa5004ea4408da5a7206ccda9cf..89a63613c7477d909639994fcbf9d9a210208279 100644 (file)
 static int scrx, scry;
 static int use_colors;
 static int freeze_refresh;
+static int resized;
 
 static int init_screen_int(void);
 static void deinit_screen_int(void);
 
 #ifdef SIGWINCH
-
 static void sig_winch(int p)
+{
+       resized = TRUE;
+}
+#endif
+
+void screen_check_resizes(void)
 {
 #if defined (TIOCGWINSZ) && defined (HAVE_CURSES_RESIZETERM)
        struct winsize ws;
@@ -73,8 +79,8 @@ static void sig_winch(int p)
 #endif
 
        mainwindows_resize(COLS, LINES);
+       resized = FALSE;
 }
-#endif
 
 static void read_signals(void)
 {
index c1449bfb1916502300e5e232492cdfa83d0383f5..700aba5c8d1643fc33ece2804da3cea9f43acfcb 100644 (file)
@@ -31,6 +31,8 @@
 #define is_big5(hi,lo) is_big5_hi(hi) && (is_big5_los(lo) || is_big5_lox(lo))
 #endif WANT_BIG5
 
+void screen_check_resizes(void);
+
 int init_screen(void); /* Initialize screen, detect screen length */
 void deinit_screen(void); /* Deinitialize screen */
 
index a4203e479468023cca5cd8cd9bf2ab530f759661..32ec6bd2082f7b281e2d5a72385c17b5515448ef 100644 (file)
@@ -83,7 +83,7 @@ static int display_firsttimer = FALSE;
 
 static void sig_exit(void)
 {
-       g_main_quit(main_loop);
+        quitting = TRUE;
 }
 
 /* redraw irssi's screen.. */
@@ -160,7 +160,6 @@ static void textui_finish_init(void)
 
 static void textui_deinit(void)
 {
-       quitting = TRUE;
        signal(SIGINT, SIG_DFL);
 
         screen_refresh_freeze();
@@ -280,6 +279,8 @@ int main(int argc, char **argv)
        textdomain(PACKAGE);
 #endif
 
+       quitting = FALSE;
+
        textui_init();
        args_execute(argc, argv);
        silc_init_finish();
@@ -289,7 +290,12 @@ int main(int argc, char **argv)
 
        textui_finish_init();
        main_loop = g_main_new(TRUE);
-       g_main_run(main_loop);
+
+       while (!quitting) {
+               g_main_iteration(TRUE);
+                screen_check_resizes();
+       }
+
        g_main_destroy(main_loop);
        textui_deinit();
 
index bd5594844df71947ae51bf7b23b455e461de630f..b6480e6abc3e9d1e871b749a96fb536e67cd2e85 100644 (file)
@@ -303,14 +303,16 @@ int silc_client_check_silc_dir()
   memset(file_public_key, 0, sizeof(file_public_key));
   memset(file_private_key, 0, sizeof(file_private_key));
 
+  identifier = silc_client_create_identifier();
+
   pw = getpwuid(getuid());
   if (!pw) {
     fprintf(stderr, "silc: %s\n", strerror(errno));
+    if (identifier)
+      silc_free(identifier);
     return FALSE;
   }
 
-  identifier = silc_client_create_identifier();
-
   /* We'll take home path from /etc/passwd file to be sure. */
   snprintf(filename, sizeof(filename) - 1, "%s/.silc/", pw->pw_dir);
   snprintf(servfilename, sizeof(servfilename) - 1, "%s/.silc/serverkeys", 
index e4e73933961c50b55af177ae69095900db4ba68b..ef0170b7f85992d7964d3e075df2ad99ba12c227 100644 (file)
@@ -203,6 +203,7 @@ static void sig_connected(SILC_SERVER_REC *server)
   fd = g_io_channel_unix_get_fd(net_sendbuffer_handle(server->handle));
   silc_client_start_key_exchange(silc_client, conn, fd);
 
+  server->ftp_sessions = silc_dlist_init();
   server->isnickflag = isnickflag_func;
   server->ischannel = ischannel_func;
   server->get_nick_flags = get_nick_flags;
@@ -213,7 +214,9 @@ static void sig_disconnected(SILC_SERVER_REC *server)
 {
   if (!IS_SILC_SERVER(server))
     return;
-  
+
+  silc_dlist_uninit(server->ftp_sessions);
+
   if (server->conn && server->conn->sock != NULL) {
     silc_client_close_connection(silc_client, NULL, server->conn);
     
@@ -249,8 +252,6 @@ SILC_SERVER_REC *silc_server_connect(SILC_SERVER_CONNECT_REC *conn)
     return NULL;
   }
 
-  server->ftp_sessions = silc_dlist_init();
-
   return server;
 }
 
index 62ada13ed4d422259ff453e8d02a59b1119bf01d..b0f3f98fb20320c5697ea76b5f3f18355e0ada01 100644 (file)
@@ -561,6 +561,8 @@ silc_server_command_whois_check(SilcServerCommandContext cmd,
   int i, k;
   bool no_res = TRUE;
 
+  SILC_LOG_DEBUG(("Start"));
+
   for (i = 0; i < clients_count; i++) {
     entry = clients[i];
     if (!entry)
index dc2d40bab503ca063aa2af659d78b32cd964a044..b7acfd23ff95cbb1a202c8e375e1be726ed7629d 100644 (file)
@@ -67,7 +67,7 @@ AC_HEADER_STAT
 
 # More header checking
 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
-AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h)
+AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
@@ -755,8 +755,6 @@ fi
 #
 # Other configure scripts
 #
-#AC_CONFIG_SUBDIRS(lib/dotconf)
-AC_CONFIG_SUBDIRS(lib/trq)
 AC_CONFIG_SUBDIRS(irssi)
 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
 #AC_CONFIG_SUBDIRS(lib/zlib)
index 0c1eb928140fafc7a3d50f7b004a1b0dceb3038e..ae8e787f31535cbbda5f37e43a766780e4d8d151 100644 (file)
@@ -57,14 +57,14 @@ toolkit_EXTRA_DIST=README.CVS README.WIN32 silcer
 
 # Irssi SILC Client distribution
 client_SUBDIRS=lib irssi doc includes
-client_SUBDIRS_lib=contrib silccore silccrypt silcsim silcmath silcske silcutil trq silcclient silcsftp
+client_SUBDIRS_lib=contrib silccore silccrypt silcsim silcmath silcske silcutil silcclient silcsftp
 client_SUBDIRS_doc=$(COMMONDIRS)
 client_DISTLABEL=SILC_DIST_CLIENT
 client_EXTRA_DIST=#
 
 # SILC Server distribution
 server_SUBDIRS=lib silcd doc includes
-server_SUBDIRS_lib=contrib silccore silccrypt silcsim silcmath silcske silcutil trq silcsftp
+server_SUBDIRS_lib=contrib silccore silccrypt silcsim silcmath silcske silcutil silcsftp
 server_SUBDIRS_doc=$(COMMONDIRS)
 server_DISTLABEL=SILC_DIST_SERVER
 server_EXTRA_DIST=#
@@ -72,7 +72,7 @@ server_EXTRA_DIST=#
 # Native WIN32 SILC library distribution (will include only the libraries)
 # XXX This is not really used at all!
 win32dll_SUBDIRS=lib doc includes
-win32dll_SUBDIRS_lib=silccore silccrypt silcsim silcmath silcske silcutil trq silcclient
+win32dll_SUBDIRS_lib=silccore silccrypt silcsim silcmath silcske silcutil silcclient
 win32dll_SUBDIRS_doc=$(COMMONDIRS)
 win32dll_DISTLABEL=SILC_DIST_WIN32DLL
 win32dll_EXTRA_DIST=README.CVS README.WIN32
index 3f34557f8d1af6cd0659ae085aef6be2f3603f6e..1a89142443bad5ecc04ff1d94f7f8b3fafd2c0fe 100644 (file)
@@ -576,9 +576,9 @@ Lists
 =====
 
 SILC has two different list API's.  The List API and the Dynamic List API.
-Both are based on the TRQ library.  For definitions of List API see
-lib/trq/silclist.h and for Dynamic List API see lib/trq/silcdlist.h. 
-Following short example of the List API.
+For definitions of List API see lib/silcutil/silclist.h and for Dynamic 
+List API see lib/silcutil/silcdlist.h.  Following short example of the 
+List API.
 
 List API
 
index 9117082c4a2525cb0438f0e75c1cf90e4d217dca..56e265398869b3d974007957750c024df2965c16 100644 (file)
 #include <pthread.h>
 #endif
 
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+
 #endif                         /* !SILC_WIN32 */
 
 #ifndef HAVE_GETOPT_LONG
 #define FALSE 0
 #endif
 
+/* Define offsetof */
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
 /* Define types. The types must be at least of the specified size */
 #undef uint8
 #undef uint16
@@ -237,6 +246,8 @@ typedef uint32 * void *;
 #include "silchashtable.h"
 #include "silclog.h"
 #include "silcmemory.h"
+#include "silclist.h"
+#include "silcdlist.h"
 #include "silcbuffer.h"
 #include "silcbufutil.h"
 #include "silcbuffmt.h"
@@ -258,10 +269,6 @@ typedef uint32 * void *;
 #include "silcauth.h"
 #include "silcprivate.h"
 
-/* TRQ (SilcList API and SilcDList API) */
-#include "silclist.h"
-#include "silcdlist.h"
-
 #ifdef SILC_SIM
 /* SILC Module library includes */
 #include "silcsim.h"
index d7770ce1443b9fda155b48ee7b61fbaf50f0ae99..6a256dbcfc61a363d0d4187b6baf514a123d8824 100644 (file)
@@ -27,9 +27,7 @@ COMMONDIRS = \
        silcske \
        silcutil \
        silcclient \
-       silcsftp \
-       trq
-#      dotconf
+       silcsftp
 #      zlib
 
 SUBDIRS = SILC_DISTRIBUTION_SUBDIRS
@@ -44,9 +42,7 @@ SILCLIB_DIRS = \
        silcmath \
        silcske \
        silcutil \
-       silcsftp \
-       trq
-#      dotconf
+       silcsftp
 
 # SILC Client Library dirs
 SILCCLIENTLIB_DIRS = \
index fd0e87bc759478fc464381dc7e555d0fdc60b252..964df1805065791a8bff40d9b1adec99310ecbfa 100644 (file)
@@ -457,6 +457,8 @@ SILC_TASK_CALLBACK(silc_client_connect_failure)
   SilcClient client = (SilcClient)ctx->client;
 
   client->internal->ops->connect(client, ctx->sock->user_data, FALSE);
+  if (ctx->packet)
+    silc_packet_context_free(ctx->packet);
   silc_free(ctx);
 }
 
@@ -1058,7 +1060,8 @@ void silc_client_packet_parse_type(SilcClient client,
        
        if (proto_ctx->packet)
          silc_packet_context_free(proto_ctx->packet);
-       
+        if (proto_ctx->dest_id)
+          silc_free(proto_ctx->dest_id);
        proto_ctx->packet = silc_packet_context_dup(packet);
        proto_ctx->dest_id_type = packet->src_id_type;
        proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_len,
@@ -1367,13 +1370,15 @@ void silc_client_close_connection(SilcClient client,
 
     /* Clear ID caches */
     if (conn->client_cache)
-      silc_idcache_del_all(conn->client_cache);
+      silc_idcache_free(conn->client_cache);
     if (conn->channel_cache)
-      silc_idcache_del_all(conn->channel_cache);
+      silc_idcache_free(conn->channel_cache);
     if (conn->server_cache)
-      silc_idcache_del_all(conn->server_cache);
+      silc_idcache_free(conn->server_cache);
 
     /* Free data (my ID is freed in above silc_client_del_client) */
+    if (conn->nickname)
+      silc_free(conn->nickname);
     if (conn->remote_host)
       silc_free(conn->remote_host);
     if (conn->local_id_data)
@@ -1504,7 +1509,7 @@ void silc_client_receive_new_id(SilcClient client,
   if (!conn->local_entry)
     conn->local_entry = silc_calloc(1, sizeof(*conn->local_entry));
 
-  conn->local_entry->nickname = conn->nickname;
+  conn->local_entry->nickname = strdup(conn->nickname);
   if (!conn->local_entry->username)
     conn->local_entry->username = strdup(client->username);
   if (!conn->local_entry->hostname)
index aebcf54e6effd58d839622362252e2fc4f999fe7..f91beae0dd1316bda8da09900d508787ba584b53 100644 (file)
@@ -2350,6 +2350,4 @@ void silc_client_commands_unregister(SilcClient client)
   SILC_CLIENT_CMDU(leave, LEAVE, "LEAVE");
   SILC_CLIENT_CMDU(users, USERS, "USERS");
   SILC_CLIENT_CMDU(getkey, GETKEY, "GETKEY");
-
-  silc_list_uninit(client->internal->commands);
 }
index 4cf7a5eee9089aac500092b800c52c3e64ed5fb7..0dd94e4ae9cc364d5c23bc20c4ad92733f047119 100644 (file)
@@ -649,6 +649,7 @@ void silc_client_del_client_entry(SilcClient client,
   silc_free(client_entry->nickname);
   silc_free(client_entry->username);
   silc_free(client_entry->realname);
+  silc_free(client_entry->hostname);
   silc_free(client_entry->server);
   silc_free(client_entry->id);
   silc_free(client_entry->fingerprint);
index 785cec1f5e07a99e26bc968871c4bae89269d456..70276c5144306df752f0a25b5c9fbc6bd4ffc18e 100644 (file)
@@ -128,6 +128,8 @@ bool silc_cipher_unregister(SilcCipherObject *cipher)
   while ((entry = silc_dlist_get(silc_cipher_list)) != SILC_LIST_END) {
     if (cipher == SILC_ALL_CIPHERS || entry == cipher) {
       silc_dlist_del(silc_cipher_list, entry);
+      silc_free(entry->name);
+      silc_free(entry);
 
       if (silc_dlist_count(silc_cipher_list) == 0) {
        silc_dlist_uninit(silc_cipher_list);
index 4ec556bcbba3d01420ac9ab752a509970c338033..f508c836e3bfa87898cd59ad7bbe0a87f96461b1 100644 (file)
@@ -209,13 +209,21 @@ void silc_hash_make(SilcHash hash, const unsigned char *data,
 char *silc_hash_fingerprint(SilcHash hash, const unsigned char *data,
                            uint32 data_len)
 {
+  SilcHash new_hash = NULL;
   unsigned char h[32];
+  char *ret;
 
-  if (!hash)
-    silc_hash_alloc("sha1", &hash);
+  if (!hash) {
+    silc_hash_alloc("sha1", &new_hash);
+    hash = new_hash;
+  }
 
   silc_hash_make(hash, data, data_len, h);
-  return silc_fingerprint(h, hash->hash->hash_len);
+  ret = silc_fingerprint(h, hash->hash->hash_len);
+
+  if (new_hash != NULL)
+    silc_hash_free(new_hash);
+  return ret;
 }
 
 static const char vo[]= "aeiouy";
@@ -229,13 +237,16 @@ static const char co[]= "bcdfghklmnprstvzx";
 char *silc_hash_babbleprint(SilcHash hash, const unsigned char *data,
                            uint32 data_len)
 {
+  SilcHash new_hash = NULL;
   char *babbleprint;
   unsigned char hval[32];
   unsigned int a, b, c, d, e, check;
   int i, k, out_len;
 
-  if (!hash)
-    silc_hash_alloc("sha1", &hash);
+  if (!hash) {
+    silc_hash_alloc("sha1", &new_hash);
+    hash = new_hash;
+  }
 
   /* Take fingerprint */
   silc_hash_make(hash, data, data_len, hval);
@@ -280,5 +291,7 @@ char *silc_hash_babbleprint(SilcHash hash, const unsigned char *data,
   }
   babbleprint[k + 3] = co[16];
 
+  if (new_hash != NULL)
+    silc_hash_free(new_hash);
   return babbleprint;
 }
index 6353a21936582f322b6fba7a43404319602e81d7..2f9699bb064bdeb51674a554f13b12f9c839d129 100644 (file)
@@ -1039,6 +1039,10 @@ int silc_pkcs_load_public_key(char *filename, SilcPublicKey *public_key,
       break;
     case SILC_PKCS_FILE_PEM:
       data = silc_decode_pem(data, len, &len);
+      memset(old, 0, data_len);
+      silc_free(old);
+      old = data; 
+      data_len = len;
       break;
     }
 
index 051e222cc847d5395a130eec45f8509f3ad35b8a..7bed81e138e9997fd34e502a42ce24e969f516a4 100644 (file)
@@ -350,7 +350,7 @@ static void silc_rng_exec_command(SilcRng rng, char *command)
   pclose(fd);
   
   /* Add the buffer into random pool */
-  silc_rng_add_noise(rng, buf, strlen(buf));
+  silc_rng_add_noise(rng, buf, i);
   memset(buf, 0, sizeof(buf));
 #endif
 }
index 0aa1b91cab7d1fafdccb0d43f01539c9e2a7c7c6..89cc6fc8bd113f2a6224d3a96d3f83e327494d45 100644 (file)
@@ -333,7 +333,6 @@ void silc_sftp_client_shutdown(SilcSFTP context)
 {
   SilcSFTPClient sftp = (SilcSFTPClient)context;
 
-  silc_list_uninit(sftp->requests);
   if (sftp->packet)
     silc_buffer_free(sftp->packet);
   silc_free(sftp);
index 93cd4a3b2591e883b0d9eb627ba7de8961af91f9..af1f7fb74c0a0426d9b9a3c6ec1ced7dd18cd0fe 100644 (file)
@@ -53,6 +53,8 @@ include_HEADERS =     \
        silcsockconn.h  \
        silcprotocol.h  \
        silcthread.h    \
+       silclist.h      \
+       silcdlist.h     \
        silcutil.h
 endif
 
index 8c822cd7354310842d4aea8e923a321d007c753d..b91d6cb67ad50f79b658818bddeea43ebd5a3d6e 100644 (file)
@@ -128,7 +128,7 @@ typedef struct {
 
 /* Inline functions */
 
-extern inline
+static inline
 SilcBuffer silc_buffer_alloc(uint32 len)
 {
   SilcBuffer sb;
@@ -150,7 +150,7 @@ SilcBuffer silc_buffer_alloc(uint32 len)
 
 /* Free's a SilcBuffer */
 
-extern inline
+static inline
 void silc_buffer_free(SilcBuffer sb)
 {
   if (sb) {
@@ -165,7 +165,7 @@ void silc_buffer_free(SilcBuffer sb)
    can be used to set the data to static buffer without needing any
    memory allocations. The `data' will not be copied to the buffer. */
 
-extern inline
+static inline
 void silc_buffer_set(SilcBuffer sb, unsigned char *data, uint32 data_len)
 {
   sb->data = sb->head = data;
@@ -190,7 +190,7 @@ void silc_buffer_set(SilcBuffer sb, unsigned char *data, uint32 data_len)
            ^
 */
 
-extern inline 
+static inline 
 unsigned char *silc_buffer_pull(SilcBuffer sb, uint32 len)
 {
   unsigned char *old_data = sb->data;
@@ -222,7 +222,7 @@ unsigned char *silc_buffer_pull(SilcBuffer sb, uint32 len)
               ^
 */
 
-extern inline 
+static inline 
 unsigned char *silc_buffer_push(SilcBuffer sb, uint32 len)
 {
   unsigned char *old_data = sb->data;
@@ -254,7 +254,7 @@ unsigned char *silc_buffer_push(SilcBuffer sb, uint32 len)
                         ^
 */
 
-extern inline 
+static inline 
 unsigned char *silc_buffer_pull_tail(SilcBuffer sb, uint32 len)
 {
   unsigned char *old_tail = sb->tail;
@@ -286,7 +286,7 @@ unsigned char *silc_buffer_pull_tail(SilcBuffer sb, uint32 len)
                             ^
 */
 
-extern inline
+static inline
 unsigned char *silc_buffer_push_tail(SilcBuffer sb, uint32 len)
 {
   unsigned char *old_tail = sb->tail;
@@ -312,7 +312,7 @@ unsigned char *silc_buffer_push_tail(SilcBuffer sb, uint32 len)
    Puts data to the head section. 
 */
 
-extern inline
+static inline
 unsigned char *silc_buffer_put_head(SilcBuffer sb, 
                                    const unsigned char *data,
                                    uint32 len)
@@ -334,7 +334,7 @@ unsigned char *silc_buffer_put_head(SilcBuffer sb,
            Puts data to the data section.
 */
 
-extern inline
+static inline
 unsigned char *silc_buffer_put(SilcBuffer sb, 
                               const unsigned char *data,
                               uint32 len)
@@ -356,7 +356,7 @@ unsigned char *silc_buffer_put(SilcBuffer sb,
                            Puts data to the tail section.
 */
 
-extern inline
+static inline
 unsigned char *silc_buffer_put_tail(SilcBuffer sb, 
                                    const unsigned char *data,
                                    uint32 len)
index 7016b71e6ab231607cbeef4e048fbb9e26abdcb7..ecf99e03c978ccd21e7c460342af912fca78bef2 100644 (file)
@@ -26,7 +26,7 @@
 /* Clears and initialiazes the buffer to the state as if it was just
    allocated by silc_buffer_alloc. */
 
-extern inline
+static inline
 void silc_buffer_clear(SilcBuffer sb)
 {
   memset(sb->head, 0, sb->truelen);
@@ -39,7 +39,7 @@ void silc_buffer_clear(SilcBuffer sb)
    currently valid data area, nothing more. Use silc_buffer_clone to
    copy entire buffer. */
 
-extern inline
+static inline
 SilcBuffer silc_buffer_copy(SilcBuffer sb)
 {
   SilcBuffer sb_new;
@@ -55,7 +55,7 @@ SilcBuffer silc_buffer_copy(SilcBuffer sb)
    everything from the source buffer. The result is exact clone of
    the original buffer. */
 
-extern inline
+static inline
 SilcBuffer silc_buffer_clone(SilcBuffer sb)
 {
   SilcBuffer sb_new;
@@ -74,7 +74,7 @@ SilcBuffer silc_buffer_clone(SilcBuffer sb)
    new SilcBuffer pointer. The buffer is exact clone of the old one
    except that there is now more space at the end of buffer. */
 
-extern inline
+static inline
 SilcBuffer silc_buffer_realloc(SilcBuffer sb, uint32 newsize)
 {
   SilcBuffer sb_new;
diff --git a/lib/silcutil/silcdlist.h b/lib/silcutil/silcdlist.h
new file mode 100644 (file)
index 0000000..ef4a9d6
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+
+  silcdlist.h
+
+  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+  Copyright (C) 2000 Pekka Riikonen
+
+  This program 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.
+  
+  This program 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.
+
+*/
+
+#ifndef SILDCLIST_H
+#define SILDCLIST_H
+
+#include "silclist.h"
+
+/*
+   SILC Dynamic List API
+
+   SILC Dynamic List API can be used to add opaque contexts to list that will
+   automatically allocate list entries.  Normal SILC List API cannot be used
+   for this purpose because in that case the context passed to the list must
+   be defined as list structure already.  This is not the case in SilcDList.
+
+   This is slower than SilcList because this requires one extra memory 
+   allocation when adding new entries to the list.  The context is probably
+   allocated already and the new list entry requires one additional memory 
+   allocation.  The memory allocation and free'ing is done automatically in
+   the API and does not show to the caller.
+
+   I left sorting functions out because I don't know whether we need them.
+   If needed, just copy them from silclist.h
+
+*/
+
+/* SilcDList object. This is the actual SilcDList object that is used by
+   application. Application defines this object and adds context's to this
+   list with functions defined below. */
+typedef struct {
+  SilcList list;
+} *SilcDList;
+
+/* SilcDListEntry structure, one entry in the list. This MUST NOT be used
+   directly by the application. */
+typedef struct SilcDListEntryStruct {
+  void *context;
+  struct SilcDListEntryStruct *next;
+} *SilcDListEntry;
+
+/* Initializes SilcDList. */
+
+static inline
+SilcDList silc_dlist_init()
+{
+  SilcDList list;
+
+  list = (SilcDList)silc_calloc(1, sizeof(*list));
+  silc_list_init(list->list, struct SilcDListEntryStruct, next);
+
+  return list;
+}
+
+/* Uninits and free's all memory. Must be called to free memory. Does NOT
+   free the contexts saved by caller. */
+
+static inline
+void silc_dlist_uninit(SilcDList list)
+{
+  if (list) {
+    SilcDListEntry e;
+    silc_list_start(list->list);
+    while ((e = (SilcDListEntry)silc_list_get(list->list)) != SILC_LIST_END) {
+      silc_list_del(list->list, e);
+      silc_free(e);
+    }
+    silc_free(list);
+  }
+}
+
+/* Return the number of entries in the list */
+
+static inline
+int silc_dlist_count(SilcDList list)
+{
+  return silc_list_count(list->list);
+}
+
+/* Set the start of the list. This prepares the list for traversing entries
+   from the start of the list. */
+
+static inline
+void silc_dlist_start(SilcDList list)
+{
+  silc_list_start(list->list);
+}
+
+/* Adds new entry to the list. This is the default function to add new
+   entries to the list. */
+
+static inline
+void silc_dlist_add(SilcDList list, void *context)
+{
+  SilcDListEntry e = (SilcDListEntry)silc_calloc(1, sizeof(*e));
+  e->context = context;
+  silc_list_add(list->list, e);
+}
+
+/* Remove entry from the list. Returns < 0 on error, 0 otherwise. */
+
+static inline
+void silc_dlist_del(SilcDList list, void *context)
+{
+  SilcDListEntry e;
+
+  silc_list_start(list->list);
+  while ((e = (SilcDListEntry)silc_list_get(list->list)) != SILC_LIST_END) {
+    if (e->context == context) {
+      silc_list_del(list->list, e);
+      silc_free(e);
+      break;
+    }
+  }
+}
+
+/* Returns current entry from the list and moves the list pointer forward
+   so that calling this next time returns the next entry from the list. This
+   can be used to traverse the list. Return SILC_LIST_END when the entire
+   list has ben traversed. Later, silc_list_start must be called again when 
+   re-starting list traversing. Example:
+
+   // Traverse the list from the beginning to the end 
+   silc_dlist_start(list)
+   while ((entry = silc_dlist_get(list)) != SILC_LIST_END) {
+     ...
+   }
+   
+*/
+static inline
+void *silc_dlist_get(SilcDList list)
+{
+  SilcDListEntry e = (SilcDListEntry)silc_list_get(list->list);
+  if (e != SILC_LIST_END)
+    return e->context;
+  return SILC_LIST_END;
+}
+
+#endif
diff --git a/lib/silcutil/silclist.h b/lib/silcutil/silclist.h
new file mode 100644 (file)
index 0000000..6f30934
--- /dev/null
@@ -0,0 +1,261 @@
+/*
+
+  silclist.h
+
+  Author: Timo Sirainen <tss@iki.fi>
+
+  Copyright (C) 2002 Timo Sirainen
+
+  This program 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.
+  
+  This program 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.
+
+*/
+
+/****h* silcutil/SilcList
+ *
+ * DESCRIPTION
+ *
+ * Implementation of the SilcList interface.  This interface provides
+ * simple linked list.
+ *
+ ***/
+
+#ifndef SILCLIST_H
+#define SILCLIST_H
+
+/****s* silcutil/SilcList/SilcList
+ *
+ * NAME
+ * 
+ *    typedef struct { ... } SilcList;
+ *
+ * DESCRIPTION
+ *
+ *    This is the SilcList context, and is initialized by calling the
+ *    function silc_list_init.
+ *
+ * EXAMPLE
+ *
+ *     SilcList list;
+ *     silc_list_init(list, struct SilcInternalEntryStruct, next);
+ *
+ ***/
+typedef struct {
+  void *head, *tail;
+  void *current;
+  int offset;
+} SilcList;
+
+/****d* silcutil/SilcList/SILC_LIST_END
+ *
+ * NAME
+ * 
+ *    #define SILC_LIST_END ...
+ *
+ * DESCRIPTION
+ *
+ *    Functions return this when the list is invalid or when traversing
+ *    the list there is no more entires in the list.
+ *
+ * SOURCE
+ */
+#define SILC_LIST_END NULL
+/***/
+
+/* Initializes SilcList object. Example:
+
+   SilcList list;
+
+   silc_list_init(list, struct SilcInternalEntryStruct, next);
+
+   Where `list' is the defined list, and second argument is the structure
+   of the entries in the list and last argument is the pointer in the entry
+   structure that is used as list member. SilcInternalEntry might be as 
+   follows:
+
+   struct SilcInternalEntryStruct {
+     char *dummy;
+     struct SilcInternalEntryStruct *next; // The list member pointer
+   };
+
+   The `next' pointer in the structure (or some other pointer for that matter)
+   is given for the silc_list_init as the last argument. This pointer is used
+   by the list routines to link the entries together in the list. Your code
+   should not touch the member pointer manually.
+*/
+
+/****f* silcutil/SilcList/silc_list_init
+ *
+ * SYNOPSIS
+ *
+ *    #define silc_list_init(list, type, field) ...
+ *
+ * DESCRIPTION
+ *
+ *    This macro initializes the SilcList list.  The `list' is the defined
+ *    list, second argument is the structure of the entries in the list,
+ *    and last argument is the pointer in the entry structure that is used
+ *    as list member.  When using SilcList, you should not touch the
+ *    structure member pointer (the `next' for example) manually.
+ *
+ * EXAMPLE
+ *
+ *    struct SilcInternalEntryStruct {
+ *      char *dummy;
+ *      struct SilcInternalEntryStruct *next; // The list member pointer
+ *    };
+ *
+ *    SilcList list;
+ *    silc_list_init(list, struct SilcInternalEntryStruct, next);
+ *
+ ***/
+#define silc_list_init(list, type, field) \
+  __silc_list_init(&(list), offsetof(type, field))
+
+static inline void __silc_list_init(SilcList *list, int offset)
+{
+  list->head = list->tail = list->current = SILC_LIST_END;
+  list->offset = offset;
+}
+
+#define list_next(list, pos) ((void **) ((char *) (pos) + (list)->offset))
+
+/****f* silcutil/SilcList/silc_list_count
+ *
+ * SYNOPSIS
+ *
+ *    #define silc_list_count(list) ...
+ *
+ * DESCRIPTION
+ *
+ *    Returns the number of entries in the list indicated by `list'.
+ *
+ ***/
+#define silc_list_count(list) __silc_list_count(&(list))
+static inline int __silc_list_count(SilcList *list)
+{
+  int count = 0;
+  void *pos;
+
+  for (pos = list->head; pos != NULL; pos = *list_next(list, pos))
+    count++;
+
+  return count;
+}
+
+/****f* silcutil/SilcList/silc_list_start
+ *
+ * SYNOPSIS
+ *
+ *    #define silc_list_start(list) ...
+ *
+ * DESCRIPTION
+ *
+ *    Sets the start of the list.  This prepares the list for traversing
+ *    the entries from the start of the list.
+ *
+ ***/
+#define silc_list_start(list) (list).current = (list).head;
+
+/****f* silcutil/SilcList/silc_list_add
+ *
+ * SYNOPSIS
+ *
+ *    #define silc_list_add(list, entry) ...
+ *
+ * DESCRIPTION
+ *
+ *    Adds new entry indicated by `entry' to the end of the list indicated 
+ *    by `list'.
+ *
+ ***/
+#define silc_list_add(list, entry) __silc_list_add(&(list), entry)
+static inline void __silc_list_add(SilcList *list, void *data)
+{
+  if (list->head == NULL)
+    list->head = data;
+  else
+    *list_next(list, list->tail) = data;
+
+  list->tail = data;
+  *list_next(list, data) = NULL;
+}
+
+/****f* silcutil/SilcList/silc_list_del
+ *
+ * SYNOPSIS
+ *
+ *    #define silc_list_del(list, entry) ...
+ *
+ * DESCRIPTION
+ *
+ *    Remove entry indicated by `entry' from the list indicated by `list'.
+ *
+ ***/
+#define silc_list_del(list, data) __silc_list_del(&(list), data)
+static inline void __silc_list_del(SilcList *list, void *data)
+{
+  void **pos, *prev;
+
+  prev = NULL;
+  for (pos = &list->head; *pos != NULL; pos = list_next(list, *pos)) {
+    if (*pos == data) {
+      *pos = *list_next(list, data);
+      if (list->current == data)
+        list->current = *pos;
+      break;
+    }
+
+    prev = *pos;
+  }
+
+  if (data == list->tail)
+    list->tail = prev;
+}
+
+/****f* silcutil/SilcList/silc_list_get
+ *
+ * SYNOPSIS
+ *
+ *    #define silc_list_get(list, entry) ...
+ *
+ * DESCRIPTION
+ *
+ *    Returns the current entry from the list indicated by `list' and
+ *    moves the list pointer forward so that calling this next time will
+ *    return the next entry from the list.  This can be used to traverse
+ *    the list.  Returns SILC_LIST_END when the entire list has been
+ *    tarversed and no additional entries exist in the list. Later,
+ *    silc_list_start must be called again when re-starting the list
+ *    tarversing.
+ *
+ * EXAMPLE
+ *
+ *    // Traverse the list from the beginning to the end 
+ *    silc_list_start(list)
+ *    while ((entry = silc_list_get(list)) != SILC_LIST_END) {
+ *      ...
+ *    }
+ *
+ ***/
+#define silc_list_get(x) __silc_list_get(&(x))
+
+static inline
+void *__silc_list_get(SilcList *list)
+{
+  void *pos;
+
+  pos = list->current;
+  if (pos != NULL)
+    list->current = *list_next(list, pos);
+  return pos;
+}
+
+#endif
diff --git a/prepare b/prepare
index 68c4a428f17597e69942f3d5358823704560e4ea..c3ab1ef9dc692fb8976cc2bc79c3d13a99bffffb 100755 (executable)
--- a/prepare
+++ b/prepare
@@ -130,14 +130,6 @@ autoconf
 autoheader >/dev/null 2>/dev/null
 automake
 
-echo "Preparing trq"
-cd lib/trq
-aclocal
-autoconf
-autoheader </dev/null 2>/dev/null
-automake >/dev/null 2>/dev/null
-cd ../..
-
 echo "Preparing mpi"
 cd lib/silcmath/mpi
 aclocal
index ee9567c6b42736048f77017efbdfcd74f5050757..a07ab1c6d852879b0cf704862729ef1ff6612582 100755 (executable)
@@ -39,8 +39,6 @@ echo "Cleaning entire SILC source tree..."
 echo "All errors and warnings may be safely ignored."
 $MAKE clean -k
 $MAKE distclean -k
-rm -f ltmain.sh
-rm -f ltconfig
 rm -f ltcf*
 rm -f Makefile.am
 rm -f Makefile.defines
@@ -72,8 +70,6 @@ rm -f lib/silcmath/Makefile.in
 rm -f lib/silcsim/Makefile.in
 rm -f lib/silcsim/modules/Makefile.in
 rm -f lib/silcske/Makefile.in
-rm -f lib/trq/tests/Makefile
-rm -f lib/trq/trq_test/Makefile
 rm -rf lib/silcmath/gmp/.deps
 rm -f silcd/Makefile.in silcd/log* silcd/*.log
 rm -f silc/Makefile.in silc/log* silc/*.log
index d00bf7967d50313adb3b016a18bf02a5655df81d..93cd235e1c71ba9ac9aa2d290b91b1128fd9e776 100644 (file)
@@ -20,6 +20,6 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign
 
 SUBDIRS = libsilc libsilcclient
 
-EXTRA_DIST = silcdefs.h trq_conf.h silc.dsw copy_dll
+EXTRA_DIST = silcdefs.h silc.dsw copy_dll
 
 include $(top_srcdir)/Makefile.defines.in
index cee9eacc8b80ea3210e97821a2c8955dd90c0f5e..43b1b2d99726f186502a83e5ecee4e285707ef9d 100644 (file)
@@ -505,71 +505,6 @@ EXPORTS
        silc_twofish_encrypt_cbc @ 718 ; 
        silc_twofish_set_key @ 719 ; 
        silc_twofish_set_key_with_string @ 720 ; 
-       trq_deque_bubblesort @ 724 ; 
-       trq_deque_clear___func @ 725 ; 
-       trq_deque_compatible___func @ 726 ; 
-       trq_deque_empty_p___func @ 727 ; 
-       trq_deque_find @ 728 ; 
-       trq_deque_get_head___func @ 729 ; 
-       trq_deque_get_nth @ 730 ; 
-       trq_deque_get_tail___func @ 731 ; 
-       trq_deque_in_order @ 732 ; 
-       trq_deque_init_with_offset___func @ 733 ; 
-       trq_deque_insert_head___func @ 734 ; 
-       trq_deque_insert_in_order @ 735 ; 
-       trq_deque_insert_nth @ 736 ; 
-       trq_deque_insert_tail___func @ 737 ; 
-       trq_deque_insertionsort @ 738 ; 
-       trq_deque_join_head @ 739 ; 
-       trq_deque_join_tail @ 740 ; 
-       trq_deque_length___func @ 741 ; 
-       trq_deque_mapcar @ 742 ; 
-       trq_deque_mapcar_reverse @ 743 ; 
-       trq_deque_member @ 744 ; 
-       trq_deque_mergesort @ 745 ; 
-       trq_deque_quicksort @ 746 ; 
-       trq_deque_remove @ 747 ; 
-       trq_deque_reverse___func @ 748 ; 
-       trq_deque_swap @ 749 ; 
-       trq_deque_to_list @ 750 ; 
-       trq_list_bubblesort @ 751 ; 
-       trq_list_bw @ 752 ; 
-       trq_list_clear___func @ 753 ; 
-       trq_list_compatible___func @ 754 ; 
-       trq_list_current___func @ 755 ; 
-       trq_list_end___func @ 756 ; 
-       trq_list_find @ 757 ; 
-       trq_list_fw @ 758 ; 
-       trq_list_get_bw___func @ 759 ; 
-       trq_list_get_fw___func @ 760 ; 
-       trq_list_get_head___func @ 761 ; 
-       trq_list_get_nth @ 762 ; 
-       trq_list_get_tail___func @ 763 ; 
-       trq_list_in_order @ 764 ; 
-       trq_list_insert_head___func @ 765 ; 
-       trq_list_insert_in_order @ 766 ; 
-       trq_list_insert_nth @ 767 ; 
-       trq_list_insert_tail___func @ 768 ; 
-       trq_list_insertionsort @ 769 ; 
-       trq_list_join_head @ 770 ; 
-       trq_list_join_tail @ 771 ; 
-       trq_list_length___func @ 772 ; 
-       trq_list_mapcar @ 773 ; 
-       trq_list_mapcar_reverse @ 774 ; 
-       trq_list_member @ 775 ; 
-       trq_list_mergesort @ 776 ; 
-       trq_list_pointer_invalidate___func @ 777 ; 
-       trq_list_pointer_valid___func @ 778 ; 
-       trq_list_put_after___func @ 779 ; 
-       trq_list_put_before___func @ 780 ; 
-       trq_list_quicksort @ 781 ; 
-       trq_list_remove___func @ 782 ; 
-       trq_list_reverse @ 783 ; 
-       trq_list_rewind___func @ 784 ; 
-       trq_list_rewind_find @ 785 ; 
-       trq_list_rewind_to @ 786 ; 
-       trq_list_swap @ 787 ; 
-       trq_list_to_deque @ 788 ; 
        silc_buffer_format_vp @ 789 ; 
        silc_buffer_unformat_vp @ 790 ; 
        silc_sftp_client_start @ 791 ;
diff --git a/win32/trq_conf.h b/win32/trq_conf.h
deleted file mode 100644 (file)
index 21c895f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*   -*- c -*-\r
- * \r
- *  ----------------------------------------------------------------------\r
- *  Deque for struct type with only one link pointer (x->next).\r
- *  ----------------------------------------------------------------------\r
- *  Created      : Fri Dec  5 11:19:37 1997 tri\r
- *  Last modified: Thu Apr 16 17:35:57 1998 tri\r
- *  ----------------------------------------------------------------------\r
- *  Copyright © 1995-1998\r
- *  Timo J. Rinne <tri@iki.fi>\r
- *  All rights reserved.  See file COPYRIGHT for details.\r
- * \r
- *  Address: Cirion oy, PO-BOX 250, 00121 Helsinki, Finland\r
- *  ----------------------------------------------------------------------\r
- *  Any express or implied warranties are disclaimed.  In no event\r
- *  shall the author be liable for any damages caused (directly or\r
- *  otherwise) by the use of this software.\r
- *\r
- *  Please, send your patches to <tri@iki.fi>.\r
- *  ----------------------------------------------------------------------\r
- *\r
- * $Id$\r
- *\r
- * $Log$
- * Revision 1.1  2001/07/23 11:07:56  priikone
- *     updates.
- *\r
- * Revision 1.1.1.1  2000/10/31 19:59:30  priikone\r
- *     Imported TRQ and SilList and SilcDList API's.\r
- *\r
- * Revision 1.1  1998/04/16 14:39:42  tri\r
- * Initial revision\r
- *\r
- *\r
- */\r
-#ifndef __TRQ_CONF__H__\r
-#define __TRQ_CONF__H__ 1\r
-\r
-/*\r
- * stddef.h is included here if such file exists.\r
- * offsetof should be defined there.\r
- */\r
-#include <stddef.h>\r
-\r
-/*\r
- * If compiler supports inline functions, __TRQ__INLINE__FUNCTION__\r
- * is defined to the correct keyword.  Usually this is defined\r
- * as inline, __inline__ or __inline.  If inline functions are\r
- * not supported, __TRQ__INLINE__FUNCTION__ is undefined.\r
- */\r
-#define __TRQ__INLINE__FUNCTION__ __inline\r
-\r
-typedef unsigned long trq_p_i_t; /* Integral type size of an pointer */\r
-\r
-#ifdef offsetof\r
-#define _Q_STRUCT_OFFSET(t, m) ((trq_p_i_t)(offsetof(t, m)))\r
-#else\r
-#define _Q_STRUCT_OFFSET(t, m) (((trq_p_i_t)(&(((t *)0)->m))))\r
-#endif\r
-\r
-#endif /* !__TRQ_CONF__H__ */\r
-/* eof (trq_conf.h) */\r