r6603 - packages/trunk/biniax2/debian/patches
Miriam Ruiz
baby-guest at alioth.debian.org
Thu Apr 17 12:00:00 UTC 2008
Author: baby-guest
Date: 2008-04-17 12:00:00 +0000 (Thu, 17 Apr 2008)
New Revision: 6603
Modified:
packages/trunk/biniax2/debian/patches/sound.patch
Log:
Save configuration files in user home
Modified: packages/trunk/biniax2/debian/patches/sound.patch
===================================================================
--- packages/trunk/biniax2/debian/patches/sound.patch 2008-04-17 11:44:56 UTC (rev 6602)
+++ packages/trunk/biniax2/debian/patches/sound.patch 2008-04-17 12:00:00 UTC (rev 6603)
@@ -3,8 +3,8 @@
Index: biniax2/biniax.c
===================================================================
---- biniax2.orig/biniax.c 2008-04-17 11:40:14.000000000 +0000
-+++ biniax2/biniax.c 2008-04-17 11:40:59.000000000 +0000
+--- biniax2.orig/biniax.c 2008-04-17 11:57:46.000000000 +0000
++++ biniax2/biniax.c 2008-04-17 11:57:46.000000000 +0000
@@ -100,13 +100,27 @@
cfgInit();
hofInit();
@@ -36,8 +36,8 @@
SHOW INITIAL WELCOME SCREEN
Index: biniax2/desktop/cfg.c
===================================================================
---- biniax2.orig/desktop/cfg.c 2008-04-17 11:40:14.000000000 +0000
-+++ biniax2/desktop/cfg.c 2008-04-17 11:44:55.000000000 +0000
+--- biniax2.orig/desktop/cfg.c 2008-04-17 11:57:46.000000000 +0000
++++ biniax2/desktop/cfg.c 2008-04-17 11:59:09.000000000 +0000
@@ -30,6 +30,17 @@
#include "inc.h"
@@ -79,9 +79,9 @@
+ fprintf(stderr, "$HOME is excessively long.n");
+ return BNX_FALSE;
+ }
-+ snprintf(file, sizeof(file), "%s/.biniax2", home);
-+ mkdir(file, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0;
-+ strncat(file, "/config", sizeof(file)-1);
++ snprintf(filename, sizeof(filename), "%s/.biniax2", home);
++ mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++ strncat(filename, "/config", sizeof(filename)-1);
+#else
+ char filename[] = "./config.bnx2";
+#endif
@@ -140,8 +140,8 @@
+}
Index: biniax2/desktop/cfg.h
===================================================================
---- biniax2.orig/desktop/cfg.h 2008-04-17 11:40:14.000000000 +0000
-+++ biniax2/desktop/cfg.h 2008-04-17 11:40:59.000000000 +0000
+--- biniax2.orig/desktop/cfg.h 2008-04-17 11:57:46.000000000 +0000
++++ biniax2/desktop/cfg.h 2008-04-17 11:57:46.000000000 +0000
@@ -43,4 +43,8 @@
BNX_BOOL cfgGetMusic();
BNX_BOOL cfgGetFullscreen();
@@ -151,3 +151,89 @@
+void cfgSetFullscreen(BNX_BOOL);
+
#endif
+Index: biniax2/hof.c
+===================================================================
+--- biniax2.orig/hof.c 2008-04-17 11:57:46.000000000 +0000
++++ biniax2/hof.c 2008-04-17 11:59:17.000000000 +0000
+@@ -31,6 +31,18 @@
+
+ #include "inc.h"
+
++#ifndef _WIN32
++#include <stdlib.h>
++#include <stdio.h>
++#include <string.h>
++#include <unistd.h>
++#include <limits.h>
++#include <pwd.h>
++#include <fcntl.h>
++#include <sys/stat.h>
++#include <sys/types.h>
++#endif
++
+ #define chCursor '_'
+ #define chSpace ' '
+
+@@ -82,6 +94,37 @@
+ }
+ }
+
++static const char *hofFileName()
++{
++#ifndef _WIN32
++ static char filename[PATH_MAX] = "";
++ char *home;
++ struct passwd *passwd;
++ if (*filename)
++ return filename;
++ if (!getuid() || !(home = getenv("HOME")))
++ {
++ passwd = getpwuid (getuid());
++ home=passwd->pw_dir;
++ if (!home)
++ {
++ fprintf(stderr, "$HOME is not defined.n");
++ return BNX_FALSE;
++ }
++ }
++ if (strlen(home) > PATH_MAX - sizeof("/.biniax2/config"))
++ {
++ fprintf(stderr, "$HOME is excessively long.n");
++ return BNX_FALSE;
++ }
++ snprintf(filename, sizeof(filename), "%s/.biniax2", home);
++ mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++ strncat(filename, "/hof", sizeof(filename)-1);
++ return filename;
++#else
++ return "./hof.bnx2";
++#endif
++}
+
+ BNX_BOOL hofInit()
+ {
+@@ -98,7 +141,7 @@
+ Hof.tactic[ i ].score = (cHofEntries - i) * cHofInitScore;
+ }
+
+- file = fopen( "hof.bnx2", "rb" );
++ file = fopen( hofFileName(), "rb" );
+
+ if ( file == (FILE *) NULL )
+ return BNX_FALSE;
+@@ -114,7 +157,7 @@
+ {
+ FILE *file;
+
+- file = fopen( "hof.bnx2", "wb" );
++ file = fopen( hofFileName(), "wb" );
+
+ if ( file == (FILE *) NULL )
+ return BNX_FALSE;
+@@ -246,4 +289,4 @@
+ BNX_HALL *hofGet()
+ {
+ return (BNX_HALL *) &Hof;
+-}
+\ No newline at end of file
++}
More information about the Pkg-games-commits
mailing list