SOURCES: snownews-home_etc.patch (NEW), snownews-home_etc_utils.pa...

qboosh qboosh at pld-linux.org
Sat Dec 23 21:26:35 CET 2006


Author: qboosh                       Date: Sat Dec 23 20:26:35 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- HOME_ETC support, from l00natyk

---- Files affected:
SOURCES:
   snownews-home_etc.patch (NONE -> 1.1)  (NEW), snownews-home_etc_utils.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/snownews-home_etc.patch
diff -u /dev/null SOURCES/snownews-home_etc.patch:1.1
--- /dev/null	Sat Dec 23 21:26:35 2006
+++ SOURCES/snownews-home_etc.patch	Sat Dec 23 21:26:30 2006
@@ -0,0 +1,298 @@
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/cookies.c snownews-1.5.7/cookies.c
+--- snownews-1.5.7.original/cookies.c	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/cookies.c	2005-09-03 21:46:12.000000000 +0200
+@@ -37,6 +37,7 @@
+ 
+ #include "config.h"
+ #include "ui-support.h"
++#include "etc_path.h"
+ 
+ void CookieCutter (struct feed * cur_ptr, FILE * cookies) {
+ 	char buf[4096];					/* File read buffer. */
+@@ -212,7 +213,7 @@
+ 	char file[512];					/* File locations. */
+ 	FILE *cookies;					/* Cookies file ptr. */
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/cookies", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/cookies", set_config_dir());
+ 	cookies = fopen (file, "r");
+ 	if (cookies == NULL) {
+ 		/* No cookies to load. */
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/dialog.c snownews-1.5.7/dialog.c
+--- snownews-1.5.7.original/dialog.c	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/dialog.c	2005-09-03 21:46:27.000000000 +0200
+@@ -42,6 +42,7 @@
+ #include "dialog.h"
+ #include "io-internal.h"
+ #include "conversions.h"
++#include "etc_path.h"
+ 
+ extern char *browser;
+ extern struct keybindings keybindings;
+@@ -293,9 +294,9 @@
+ 	centerx = COLS / 2;
+ 	
+ 	hashme = Hashify(current_feed->feedurl);
+-	len = (strlen(getenv("HOME")) + strlen(hashme) + 18);
++	len = (strlen(set_config_dir()) + strlen(hashme) + 18);
+ 	file = malloc (len);
+-	snprintf (file, len, "%s/.snownews/cache/%s", getenv("HOME"), hashme);
++	snprintf (file, len, "%s/.snownews/cache/%s", set_config_dir(), hashme);
+ 
+ 	UISupportDrawBox (5, 4, COLS-6, 13);
+ 	
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/etc_path.c snownews-1.5.7/etc_path.c
+--- snownews-1.5.7.original/etc_path.c	1970-01-01 01:00:00.000000000 +0100
++++ snownews-1.5.7/etc_path.c	2005-09-03 21:57:47.000000000 +0200
+@@ -0,0 +1,12 @@
++/*
++ * Set path for preferences. <l00natyk at gazeta.pl>
++ */
++
++#include <stdlib.h>
++
++char *set_config_dir(void) {
++	char *etc_dir;
++	if ((etc_dir = getenv("HOME_ETC")) != NULL) return etc_dir;
++	etc_dir = getenv("HOME");
++	return etc_dir;
++	}
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/etc_path.h snownews-1.5.7/etc_path.h
+--- snownews-1.5.7.original/etc_path.h	1970-01-01 01:00:00.000000000 +0100
++++ snownews-1.5.7/etc_path.h	2005-09-03 21:54:16.000000000 +0200
+@@ -0,0 +1,6 @@
++#ifndef ETC_PATH_H
++#define	ETC_PATH_H
++
++char *set_config_dir (void);
++
++#endif
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/interface.c snownews-1.5.7/interface.c
+--- snownews-1.5.7.original/interface.c	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/interface.c	2005-09-03 22:23:07.000000000 +0200
+@@ -48,6 +48,7 @@
+ #include "io-internal.h"
+ #include "os-support.h"
+ #include "support.h"
++#include "etc_path.h"
+ 
+ extern struct keybindings keybindings;
+ extern struct color color;
+@@ -1302,9 +1303,9 @@
+ 						
+ 						/* Remove cachefile from filesystem. */
+ 						hashme = Hashify(highlighted->feedurl);
+-						len = (strlen(getenv("HOME")) + strlen(hashme) + 18);
++						len = (strlen(set_config_dir()) + strlen(hashme) + 18);
+ 						file = malloc (len);
+-						snprintf (file, len, "%s/.snownews/cache/%s", getenv("HOME"), hashme);
++						snprintf (file, len, "%s/.snownews/cache/%s", set_config_dir(), hashme);
+ 						
+ 						/* Errors from unlink can be ignored. Worst thing that happens is that
+ 						   we delete a file that doesn't exist. */
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/io-internal.c snownews-1.5.7/io-internal.c
+--- snownews-1.5.7.original/io-internal.c	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/io-internal.c	2005-09-03 21:46:45.000000000 +0200
+@@ -46,6 +46,7 @@
+ #include "xmlparse.h"
+ #include "ui-support.h"
+ #include "io-internal.h"
++#include "etc_path.h"
+ 
+ extern char *browser;
+ 
+@@ -279,7 +280,7 @@
+ 		return 0;
+ 	
+ 	hashme = Hashify(cur_ptr->feedurl);
+-	snprintf (file, sizeof(file), "%s/.snownews/cache/%s", getenv("HOME"), hashme);
++	snprintf (file, sizeof(file), "%s/.snownews/cache/%s", set_config_dir(), hashme);
+ 	free (hashme);
+ 	cache = fopen (file, "r");
+ 	
+@@ -391,7 +392,7 @@
+ 	UIStatus (_("Saving settings ["), 0, 0);
+ 	titlestrlen = strlen (_("Saving settings ["));
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/browser", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/browser", set_config_dir());
+ 	configfile = fopen (file, "w+");
+ 	if (configfile == NULL) {
+ 		MainQuit (_("Save settings (browser)"), strerror(errno));
+@@ -399,12 +400,12 @@
+ 	fputs (browser, configfile);
+ 	fclose (configfile);
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/urls", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/urls", set_config_dir());
+ 	
+ 	/* Make a backup of urls. This approach is really broken! */
+ 	if ((stat (file, &filetest)) != -1) {
+ 		if ((filetest.st_mode & S_IFREG) == S_IFREG) {
+-			snprintf (syscall, sizeof(file), "cp -f %s/.snownews/urls %s/.snownews/urls.bak", getenv("HOME"), getenv("HOME"));
++			snprintf (syscall, sizeof(file), "cp -f %s/.snownews/urls %s/.snownews/urls.bak", set_config_dir(), set_config_dir());
+ 			system (syscall);
+ 		}
+ 	}
+@@ -463,7 +464,7 @@
+ 		 * Write cache.
+ 		 */
+ 		hashme = Hashify(cur_ptr->feedurl);
+-		snprintf (file, sizeof(file), "%s/.snownews/cache/%s", getenv("HOME"), hashme);
++		snprintf (file, sizeof(file), "%s/.snownews/cache/%s", set_config_dir(), hashme);
+ 		free (hashme);
+ 		cache = fopen (file, "w+");
+ 
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/Makefile snownews-1.5.7/Makefile
+--- snownews-1.5.7.original/Makefile	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/Makefile	2005-09-03 21:55:47.000000000 +0200
+@@ -8,15 +8,15 @@
+ include platform_settings
+ 
+ ### Object files ###
+-OBJFILES= main.o netio.o interface.o xmlparse.o updatecheck.o conversions.o dialog.o ui-support.o categories.o about.o cookies.o setup.o net-support.o digcalc.o md5.o filters.o io-internal.o os-support.o zlib_interface.o support.o
++OBJFILES= main.o netio.o interface.o xmlparse.o updatecheck.o conversions.o dialog.o ui-support.o categories.o about.o cookies.o setup.o net-support.o digcalc.o md5.o filters.o io-internal.o os-support.o zlib_interface.o support.o etc_path.o
+ 
+ VERSION= `grep VERSION version.h | sed s/\"//g | sed s/\#define\ VERSION\ //`
+ DISTDIR= snownews-$(VERSION)
+ DISTFILES = AUTHOR COPYING CREDITS Changelog README README.de README.patching INSTALL opml2snow snowsync \
+ 	Makefile platform_settings configure \
+ 	doc po scripts \
+-	main.c interface.c netio.c xmlparse.c updatecheck.c os-support.c conversions.c dialog.c ui-support.c categories.c about.c cookies.c setup.c net-support.c digcalc.c md5.c filters.c io-internal.c zlib_interface.c support.c \
+-	config.h version.h main.h interface.h netio.h xmlparse.h updatecheck.h os-support.h conversions.h dialog.h ui-support.h categories.h about.h cookies.h setup.h net-support.h digcalc.h md5.h filters.h io-internal.h zlib_interface.h support.h
++	main.c interface.c netio.c xmlparse.c updatecheck.c os-support.c conversions.c dialog.c ui-support.c categories.c about.c cookies.c setup.c net-support.c digcalc.c md5.c filters.c io-internal.c zlib_interface.c support.c etc_path.c\
++	config.h version.h main.h interface.h netio.h xmlparse.h updatecheck.h os-support.h conversions.h dialog.h ui-support.h categories.h about.h cookies.h setup.h net-support.h digcalc.h md5.h filters.h io-internal.h zlib_interface.h support.h etc_path.h
+ 
+ ### Translations ###
+ LOCALES= de es fr it nl ru sl zh_TW zh_CN pt_BR pl ja
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/setup.c snownews-1.5.7/setup.c
+--- snownews-1.5.7.original/setup.c	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/setup.c	2005-09-03 22:21:52.000000000 +0200
+@@ -43,6 +43,7 @@
+ #include "main.h"
+ #include "setup.h"
+ #include "io-internal.h"
++#include "etc_path.h"
+ 
+ struct feed *first_ptr = NULL;
+ struct entity *first_entity = NULL;
+@@ -558,7 +559,7 @@
+ 	/* 
+ 	 * Setup config directories.
+ 	 */
+-	snprintf (file, sizeof(file), "%s/.snownews", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews", set_config_dir());
+ 	if ((stat (file, &dirtest)) == -1 ) {
+ 		/* Create directory. */
+ 		if (mkdir (file, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0)
+@@ -571,7 +572,7 @@
+ 		}
+ 	}
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/cache", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/cache", set_config_dir());
+ 	if ((stat (file, &dirtest)) == -1) {
+ 		/* Create directory. */
+ 		if (mkdir (file, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0)
+@@ -585,20 +586,20 @@
+ 	
+ 	/* Redirect stderr to ~/.snownews/error.log
+ 	   Be sure to call _after_ the directory checks above! */
+-	snprintf (file, sizeof(file), "%s/.snownews/error.log", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/error.log", set_config_dir());
+ 	errorlog = fopen (file, "w+");
+ 	dup2 (fileno(errorlog), STDERR_FILENO);
+ 	
+ 	UIStatus (_("Reading configuration settings..."), 0, 0);
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/browser", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/browser", set_config_dir());
+ 	SetupBrowser (file);
+ 
+ 	/*************
+ 	 * Feed list *
+ 	 *************/
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/urls", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/urls", set_config_dir());
+ 	configfile = fopen (file, "r");
+ 	if (configfile == NULL) {
+ 		UIStatus (_("Creating new configfile."), 0, 0);
+@@ -693,13 +694,13 @@
+ 	}
+ 	fclose (configfile);
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/keybindings", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/keybindings", set_config_dir());
+ 	SetupKeybindings (file);
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/colors", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/colors", set_config_dir());
+ 	SetupColors (file);
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/html_entities", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/html_entities", set_config_dir());
+ 	SetupEntities (file);
+ 	
+ 	return numfeeds;
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/support.c snownews-1.5.7/support.c
+--- snownews-1.5.7.original/support.c	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/support.c	2005-09-03 22:18:04.000000000 +0200
+@@ -31,6 +31,7 @@
+ #include <sys/stat.h>
+ #include <sys/select.h>
+ #include <time.h>
++#include "etc_path.h"
+ 
+ int easterEgg (void) {
+ 	struct tm *t;
+@@ -42,7 +43,7 @@
+ 	tunix = time(0);
+ 	t = localtime(&tunix);
+ 	
+-	snprintf (file, sizeof(file), "%s/.snownews/santa_hunta", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/santa_hunta", set_config_dir());
+ 	if ((stat (file, &filetest) == 0) ||
+ 		((t->tm_mon == 11) && (t->tm_mday >= 24) && (t->tm_mday <= 26))) {
+ 		return 1;
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/ui-support.c snownews-1.5.7/ui-support.c
+--- snownews-1.5.7.original/ui-support.c	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/ui-support.c	2005-09-03 22:14:50.000000000 +0200
+@@ -35,6 +35,7 @@
+ #include "version.h"
+ #include "ui-support.h"
+ #include "io-internal.h"
++#include "etc_path.h"
+ 
+ extern struct color color;
+ extern char *browser;
+@@ -373,7 +374,7 @@
+ 	else
+ 		pager = strdup("less");
+ 	
+-	env = getenv("HOME");
++	env = set_config_dir();
+ 	snprintf (errorlog, sizeof(errorlog), "%s/.snownews/error.log", env);
+ 	
+ 	snprintf (command, sizeof(command), "%s %s", pager, errorlog);
+diff -u -r -N --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/updatecheck.c snownews-1.5.7/updatecheck.c
+--- snownews-1.5.7.original/updatecheck.c	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/updatecheck.c	2005-09-03 22:16:14.000000000 +0200
+@@ -38,7 +38,7 @@
+ #include "version.h"
+ #include "netio.h"
+ #include "io-internal.h"
+-
++#include "etc_path.h"
+ 
+ void AutoVersionCheck (void) {
+ 	struct feed *update;
+@@ -55,7 +55,7 @@
+ 	
+ 	/* We check once a week. */
+ 	snprintf (timestring, sizeof(timestring), "%d", (int) time(NULL));
+-	snprintf (file, sizeof(file), "%s/.snownews/updatecheck", getenv("HOME"));
++	snprintf (file, sizeof(file), "%s/.snownews/updatecheck", set_config_dir());
+ 	lastupdated = fopen (file, "r+");
+ 	if (lastupdated == NULL) {
+ 		lastupdated = fopen (file, "w+");

================================================================
Index: SOURCES/snownews-home_etc_utils.patch
diff -u /dev/null SOURCES/snownews-home_etc_utils.patch:1.1
--- /dev/null	Sat Dec 23 21:26:35 2006
+++ SOURCES/snownews-home_etc_utils.patch	Sat Dec 23 21:26:30 2006
@@ -0,0 +1,76 @@
+diff -u -r --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/opml2snow snownews-1.5.7/opml2snow
+--- snownews-1.5.7.original/opml2snow	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/opml2snow	2005-09-04 00:50:12.000000000 +0200
+@@ -29,6 +29,16 @@
+ use English;
+ 
+ #######################################################################
++# etc_path
++    my($ETC_PATH);    
++
++    if ($ENV{'HOME_ETC'}) {
++    $ETC_PATH = ("$ENV{'HOME_ETC'}");
++    } else {
++    $ETC_PATH = ($ENV{'HOME'});
++    }
++
++#######################################################################
+ # Help
+ if (index($ARGV[0], "-h") >= 0) {
+ 	print "Snownews opml2snow - subsription file import/export utility\n\n".
+@@ -80,7 +90,7 @@
+ 	if (defined($ARGV[1])) {
+ 		$inputfile = $ARGV[1];
+ 	} else {
+-		$inputfile = "$ENV{'HOME'}/.snownews/urls"
++		$inputfile = "$ETC_PATH/.snownews/urls"
+ 	}
+ 	open (URLS, "$inputfile");
+ 	my(@urls) = <URLS>;
+@@ -121,7 +131,7 @@
+ 		my($feed_script) = 4;
+ 		
+ 		my($parser) = XML::LibXML->new();
+-		my($feed_doc) = $parser->parse_file("$ENV{'HOME'}/.snownews/cache/$feed_url_hash");
++		my($feed_doc) = $parser->parse_file("$ETC_PATH/.snownews/cache/$feed_url_hash");
+ 		my($feed_root) = $feed_doc->documentElement();
+ 		$feed_root->setNamespace('http://purl.org/rss/1.0/', 'rss', 1);
+ 		
+diff -u -r --from-file=snownews-1.5.7.original/ snownews-1.5.7.original/snowsync snownews-1.5.7/snowsync
+--- snownews-1.5.7.original/snowsync	2005-06-05 11:50:22.000000000 +0200
++++ snownews-1.5.7/snowsync	2005-09-04 00:57:49.000000000 +0200
+@@ -34,6 +34,16 @@
+ use File::Copy;
+ 
+ #######################################################################
++# etc_path
++    my($ETC_PATH);    
++
++    if ($ENV{'HOME_ETC'}) {
++    $ETC_PATH = ("$ENV{'HOME_ETC'}");
++    } else {
++    $ETC_PATH = ($ENV{'HOME'});
++    }
++
++#######################################################################
+ 
+ my $fileversion = "version1";
+ my $debug = 0;
+@@ -60,7 +70,7 @@
+ my $tmpdir = "/tmp/snowsync-".$ENV{'USER'}.".$PID.".time();
+ 
+ # Default to Snownews
+-my $dot_dir = "$homedir/.snownews";
++my $dot_dir = "$ETC_PATH/.snownews";
+ my $config_loc = "$dot_dir/snowsync.conf";
+ my $log_loc = "$dot_dir/snowsync.log";
+ my $main_prog_name = "snownews";
+@@ -100,7 +110,7 @@
+ #######################################################################
+ # See if snownews is running. Works with snownews >= 1.5.6
+ sub checkRunning {
+-	my($pid_file) = $ENV{'HOME'}."/.snownews/pid";
++	my($pid_file) = $ETC_PATH."/.snownews/pid";
+ 	
+ 	open (PID, "$pid_file") or return;
+ 	my($my_pid) = <PID>;
================================================================


More information about the pld-cvs-commit mailing list