gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-89


From: Pawel Kot
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-89-gd8e8bba
Date: Sat, 08 Jan 2011 18:18:55 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  d8e8bbac0f9571df9038f11562a8de3a19630b5b (commit)
      from  3aa947ca8969af818d2c42913a529f884b560595 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=d8e8bbac0f9571df9038f11562a8de3a19630b5b


commit d8e8bbac0f9571df9038f11562a8de3a19630b5b
Author: Pawel Kot <address@hidden>
Date:   Sat Jan 8 19:17:38 2011 +0100

    Change gnokii-errors location to:
     %APPDATA%\gnokii on Windows
     $HOME/Library/Logs/gnokii on MaxOS X
     $XDG_CACHE_HOME/gnokii ($HOME/.cache/gnokii) on others

diff --git a/ChangeLog b/ChangeLog
index d875f31..6101376 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -50,6 +50,9 @@
       Fixes https://bugs.launchpad.net/bugs/604947  (Daniele Forsi)
  * smsd updates
     o add SQLite3 backend module                   (Santeri Toikka)
+ * gnokii updates
+    o place gnokii-errors into the better location - freedesktop
+      compliant                                         (Paweł Kot)
 
 0.6.29
 ======
diff --git a/gnokii/gnokii.c b/gnokii/gnokii.c
index d2a20ba..7b9dc66 100644
--- a/gnokii/gnokii.c
+++ b/gnokii/gnokii.c
@@ -299,35 +299,70 @@ static void gnokii_error_logger(const char *fmt, va_list 
ap)
        }
 }
 
+#define MAX_PATH_LEN 255
 static int install_log_handler(void)
 {
-       char logname[256];
-       char *home;
-#ifdef WIN32
+       int retval = 0;
+       char logname[MAX_PATH_LEN];
+       char *path, *basepath;
        char *file = "gnokii-errors";
-#else
-       char *file = ".gnokii-errors";
+       int free_path = 0;
+#ifndef WIN32
+       struct stat buf;
+       int st;
+       int home = 0;
 #endif
 
-       if ((home = getenv("HOME")) == NULL) {
 #ifdef WIN32
-               home = ".";
+       basepath = getenv("APPDATA");
+#elif __MACH__
+       basepath = getenv("HOME");
 #else
-               fprintf(stderr, _("ERROR: Can't find HOME environment 
variable!\n"));
-               return -1;
+/* freedesktop.org compliancy: 
http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html */
+#define XDG_CACHE_HOME "/.cache" /* $HOME/.cache */
+       basepath = getenv("XDG_CACHE_HOME");
+       if (!basepath) {
+               basepath = getenv("HOME");
+               home = 1;
+       }
+#endif
+       if (!basepath)
+               path = ".";
+       else {
+               path = calloc(MAX_PATH_LEN, sizeof(char));
+               free_path = 1;
+#ifdef WIN32
+               snprintf(path, MAX_PATH_LEN, "%s\\gnokii", basepath);
+#elif __MACH__
+               snprintf(path, MAX_PATH_LEN, "%s/Library/Logs/gnokii", 
basepath);
+#else
+               if (home)
+                       snprintf(path, MAX_PATH_LEN, "%s%s/gnokii", basepath, 
XDG_CACHE_HOME);
+               else
+                       snprintf(path, MAX_PATH_LEN, "%s/gnokii", basepath);
 #endif
        }
 
-       snprintf(logname, sizeof(logname), "%s/%s", home, file);
+#ifndef WIN32
+       st = stat(path, &buf);
+       if (st)
+               mkdir(path, S_IRWXU);
+#endif
+
+       snprintf(logname, sizeof(logname), "%s/%s", path, file);
 
        if ((logfile = fopen(logname, "a")) == NULL) {
                fprintf(stderr, _("Cannot open logfile %s\n"), logname);
-               return -1;
+               retval = -1;
+               goto out;
        }
 
        gn_elog_handler = gnokii_error_logger;
 
-       return 0;
+out:
+       if (free_path)
+               free(path);
+       return retval;
 }
 
 /* businit is the generic function which waits for the FBUS link. The limit

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog       |    3 ++
 gnokii/gnokii.c |   59 +++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 50 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]