updates. silc.client.0.8.5
authorPekka Riikonen <priikone@silcnet.org>
Sat, 30 Mar 2002 17:05:58 +0000 (17:05 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 30 Mar 2002 17:05:58 +0000 (17:05 +0000)
CHANGES
apps/irssi/src/core/core.c
apps/irssi/src/core/misc.c
apps/irssi/src/core/misc.h
apps/irssi/src/silc/core/silc-core.c
lib/silcutil/unix/silcunixutil.c

diff --git a/CHANGES b/CHANGES
index f355f383b75c96deb79d8a47c93865db09602fbd..ffc89f056b14516710b5d5cfb0e83fd08227b4aa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,18 @@
+Sat Mar 30 18:15:55 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Changed the silc_get_username and silc_get_real_name to
+         never fail.  Affected file lib/silcutil/unix/silcunixutil.c.
+
+       * Fixed the Irssi SILC Client to use the silc_get_username and
+         silc_get_real_name insted of glib routines since the glib
+         routines only corrupt stack.  Fixes the Irssi SILC to work in
+         Cygwin.  Affected file irssi/src/silc/core/silc-core.c.
+
+       * Fixed the Irssi to not use g_get_home_dir since it crashes
+         or returns garbage on cygwin and corrupts stack.  Added function
+         get_home_dir to Irssi routines.  Affected files are
+         irssi/src/core/misc.[ch] and irssi/src/core/core.c.
+
 Fri Mar 29 10:41:07 EET 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * And yet again reverted back the config thing since Johnny
index b11064cb6b9c7b1dcd5f718ad492de665cfc1c2e..0deb5090f6b8ce73eec8947bd138f8768becc7ac 100644 (file)
@@ -192,9 +192,10 @@ void core_init_paths(int argc, char *argv[])
        args_register(options);
 
         if (irssi_dir == NULL)
-               irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, g_get_home_dir());
+               irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, get_home_dir());
        if (irssi_config_file == NULL)
-               irssi_config_file = g_strdup_printf("%s/"IRSSI_HOME_CONFIG, irssi_dir);
+               irssi_config_file = g_strdup_printf("%s/"IRSSI_HOME_CONFIG, 
+                                                   irssi_dir);
 
        session_set_binary(argv[0]);
 }
index 6bf871779a7a6b061f5d9d304db47cf9326c6972..93612d6bb5ab7704f786fa2dc51fd21e5ee4fbf7 100644 (file)
@@ -26,6 +26,7 @@
 #ifdef HAVE_REGEX_H
 #  include <regex.h>
 #endif
+#include <pwd.h>
 
 typedef struct {
        int condition;
@@ -448,11 +449,24 @@ int mkpath(const char *path, int mode)
        return 0;
 }
 
+/* Get home directory */
+const char *get_home_dir(void)
+{
+       struct passwd *pw = getpwuid(getuid());
+       if (!pw) {
+        if (g_getenv("HOME"))
+          return g_getenv("HOME");
+        else
+          return ".";
+       }
+       return pw->pw_dir;
+}
+
 /* convert ~/ to $HOME */
 char *convert_home(const char *path)
 {
        return *path == '~' && (*(path+1) == '/' || *(path+1) == '\0') ?
-               g_strconcat(g_get_home_dir(), path+1, NULL) :
+               g_strconcat((char *)get_home_dir, path+1, NULL) :
                g_strdup(path);
 }
 
index 804cffc2a9c2a63dbb422cb6f978dac5cc697887..a321bdfca8187c515e9164e1e9fb8bd4ec3e097f 100644 (file)
@@ -61,6 +61,10 @@ int regexp_match(const char *str, const char *regexp);
 
 /* Create the directory and all it's parent directories */
 int mkpath(const char *path, int mode);
+
+/* Get home directory */
+const char *get_home_dir(void);
+
 /* convert ~/ to $HOME */
 char *convert_home(const char *path);
 
index a58a1ec3a2d9e92b8ec75899bcd7a7de2459887b..6c9c7f2a2193dfe8e762a4e176215e4807841339 100644 (file)
@@ -100,7 +100,7 @@ static void silc_init_userinfo(void)
     if (!str)
       str = g_getenv("IRCNAME");
     settings_set_str("real_name",
-                    str != NULL ? str : g_get_real_name());
+                    str != NULL ? str : silc_get_real_name());
   }
  
   /* username */
@@ -110,8 +110,8 @@ static void silc_init_userinfo(void)
     if (!str)
       str = g_getenv("IRCUSER");
     settings_set_str("user_name",
-                    str != NULL ? str : g_get_user_name());
-    
+                    str != NULL ? str : silc_get_username());
+
     user_name = settings_get_str("user_name");
   }
 
@@ -129,12 +129,7 @@ static void silc_init_userinfo(void)
   /* alternate nick */
   set = settings_get_str("alternate_nick");
   if (set == NULL || *set == '\0') {
-    if (strlen(nick) < 9)
-      str = g_strconcat(nick, "_", NULL);
-    else { 
-      str = g_strdup(nick);
-      str[strlen(str)-1] = '_';
-    }
+    str = g_strconcat(nick, "_", NULL);
     settings_set_str("alternate_nick", str);
     g_free(str);
   }
index 8cb6a723f10db57e57b256888d35e5f8aa600ef1..42b6edace41826d5857a2355067cc547d682899e 100644 (file)
@@ -140,11 +140,9 @@ char *silc_get_username()
       struct passwd *pw;
 
       pw = getpwuid(getuid());
-      if (!pw) {
-       fprintf(stderr, "silc_get_username: %s\n", strerror(errno));
-       return NULL;
-      }
-      
+      if (!pw)
+       return strdup("foo");
+
       logname = pw->pw_name;
     }
   }
@@ -160,10 +158,8 @@ char *silc_get_real_name()
   struct passwd *pw;
     
   pw = getpwuid(getuid());
-  if (!pw) {
-    fprintf(stderr, "silc_get_username: %s\n", strerror(errno));
-    return NULL;
-  }
+  if (!pw)
+     return strdup("Foo T. Bar");
 
   if (strchr(pw->pw_gecos, ','))
     *strchr(pw->pw_gecos, ',') = 0;