>From 2b4d1e77fa60ca77e35994ecb30185d2682db6d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 20 Aug 2012 20:28:45 +0200
Subject: [PATCH 04/12] wmbutton: Support for global conf file

This patch is based in the code wrote by Christian Aichinger
for the Debian distribution.

The patch includes the /etc/wmbutton.conf as global configuration
file. This file is readed if $home/.wmbutton don't exists.
---
 wmbutton/wmb_libs.c |    7 +++++--
 wmbutton/wmbutton.h |    3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/wmbutton/wmb_libs.c b/wmbutton/wmb_libs.c
index c9ea4c8..3661f03 100644
--- a/wmbutton/wmb_libs.c
+++ b/wmbutton/wmb_libs.c
@@ -151,7 +151,9 @@ void err_mess(int err, char *str) {
     fprintf(stderr,"Fail: XCreateGC\n");       
     exit(err);
   case FAILCONF:
-    fprintf(stderr, "Fail: Can't Find configuration file %s\n",str);
+    fprintf(stderr, "Fail: Can't Find user or system configuration file.\n");
+    fprintf(stderr, "Fail: User Config: '%s'\n", str);
+    fprintf(stderr, "Fail: System Config: '%s'\n", CONFIGGLOBAL);
     exit(err);
   case FAILTMPL:
     fprintf(stderr, "Fail: Can't Create 'template' Pixmap\n");
@@ -200,7 +202,8 @@ char *Parse(int app) {
   char *Ptr;
 
   if ((fp = fopen(Config.configfile, "r")) == NULL)
-    err_mess(FAILCONF,Config.configfile);
+    if ((fp = fopen(CONFIGGLOBAL, "r")) == NULL)
+      err_mess(FAILCONF,Config.configfile);
 
   while ((Ptr = fgets(Buf, BUFFER_SIZE, fp))) {
     if (atoi(Buf) == app)
diff --git a/wmbutton/wmbutton.h b/wmbutton/wmbutton.h
index 5c721af..1b99abf 100644
--- a/wmbutton/wmbutton.h
+++ b/wmbutton/wmbutton.h
@@ -16,9 +16,10 @@
 
 /******  Define Config File Info  ***************************************/
 #define CONFFILENAME  "/.wmbutton"   /* Default conf filename $HOME/.wmbutton 
*/
+#define CONFIGGLOBAL "/etc/wmbutton.conf" /* system configuration */
 #define BUTTONFILENAME "/.wmbutton.xpm"
 
-/******  Version / Release Number ***************************************/
+/******  Version Number *************************************************/
 #define VER           0     /* Version Number */     
 #define REL           6     /* Release Number */
 
-- 
1.7.10.4

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 2b4d1e77fa60ca77e35994ecb30185d2682db6d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 20 Aug 2012 20:28:45 +0200
Subject: [PATCH 04/12] wmbutton: Support for global conf file

This patch is based in the code wrote by Christian Aichinger
for the Debian distribution.

The patch includes the /etc/wmbutton.conf as global configuration
file. This file is readed if $home/.wmbutton don't exists.
---
 wmbutton/wmb_libs.c |    7 +++++--
 wmbutton/wmbutton.h |    3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/wmbutton/wmb_libs.c b/wmbutton/wmb_libs.c
index c9ea4c8..3661f03 100644
--- a/wmbutton/wmb_libs.c
+++ b/wmbutton/wmb_libs.c
@@ -151,7 +151,9 @@ void err_mess(int err, char *str) {
     fprintf(stderr,"Fail: XCreateGC\n");	
     exit(err);
   case FAILCONF:
-    fprintf(stderr, "Fail: Can't Find configuration file %s\n",str);
+    fprintf(stderr, "Fail: Can't Find user or system configuration file.\n");
+    fprintf(stderr, "Fail: User Config: '%s'\n", str);
+    fprintf(stderr, "Fail: System Config: '%s'\n", CONFIGGLOBAL);
     exit(err);
   case FAILTMPL:
     fprintf(stderr, "Fail: Can't Create 'template' Pixmap\n");
@@ -200,7 +202,8 @@ char *Parse(int app) {
   char *Ptr;
 
   if ((fp = fopen(Config.configfile, "r")) == NULL)
-    err_mess(FAILCONF,Config.configfile);
+    if ((fp = fopen(CONFIGGLOBAL, "r")) == NULL)
+      err_mess(FAILCONF,Config.configfile);
 
   while ((Ptr = fgets(Buf, BUFFER_SIZE, fp))) {
     if (atoi(Buf) == app)
diff --git a/wmbutton/wmbutton.h b/wmbutton/wmbutton.h
index 5c721af..1b99abf 100644
--- a/wmbutton/wmbutton.h
+++ b/wmbutton/wmbutton.h
@@ -16,9 +16,10 @@
 
 /******  Define Config File Info  ***************************************/
 #define CONFFILENAME  "/.wmbutton"   /* Default conf filename $HOME/.wmbutton */
+#define CONFIGGLOBAL "/etc/wmbutton.conf" /* system configuration */
 #define BUTTONFILENAME "/.wmbutton.xpm"
 
-/******  Version / Release Number ***************************************/
+/******  Version Number *************************************************/
 #define VER           0     /* Version Number */     
 #define REL           6     /* Release Number */
 
-- 
1.7.10.4

Reply via email to