changeset 1155:3b9bbf6c4c93

Added hlog_get_log_jid(): returns the value of a symlinked history file or NULL if it isn't symlinked
author Frank Zschockelt
date Wed, 14 Feb 2007 13:24:53 +0100
parents f746d91c5d3b
children cae430fcd385
files mcabber/src/histolog.c mcabber/src/histolog.h
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/histolog.c	Tue Feb 13 21:48:17 2007 +0100
+++ b/mcabber/src/histolog.c	Wed Feb 14 13:24:53 2007 +0100
@@ -61,6 +61,33 @@
   return filename;
 }
 
+char *hlog_get_log_jid(const char *bjid)
+{
+  struct stat bufstat;
+  char *path;
+  char *log_jid = NULL;
+  
+  path = user_histo_file(bjid);
+  do {  
+    /*scr_LogPrint(LPRINT_NORMAL, "path=%s", path);*/
+    if(lstat(path, &bufstat) != 0)
+      break;
+    if(S_ISLNK(bufstat.st_mode)) {
+      g_free(log_jid);
+      log_jid = g_new(char, bufstat.st_size+1);
+      readlink(path, log_jid, bufstat.st_size);
+      g_free(path);
+      log_jid[bufstat.st_size] = '\0';
+      path = user_histo_file(log_jid);
+    } else {
+      g_free(path);
+      path = NULL;
+    }
+  } while( path );
+
+  return log_jid;
+}
+
 //  write_histo_line()
 // Adds a history (multi-)line to the jid's history logfile
 static void write_histo_line(const char *bjid,
--- a/mcabber/src/histolog.h	Tue Feb 13 21:48:17 2007 +0100
+++ b/mcabber/src/histolog.h	Wed Feb 14 13:24:53 2007 +0100
@@ -6,6 +6,7 @@
 #include "jabglue.h"
 
 void hlog_enable(guint enable, const char *root_dir, guint loadfile);
+char *hlog_get_log_jid(const char *bjid);
 void hlog_read_history(const char *bjid, GList **p_buddyhbuf, guint width);
 inline void hlog_write_message(const char *bjid, time_t timestamp, int sent,
         const char *msg);