r7907 - packages/trunk/reminiscence/debian/patches
Benoît TUDURI
bent-guest at alioth.debian.org
Sun Aug 10 08:00:59 UTC 2008
Author: bent-guest
Date: 2008-08-10 08:00:59 +0000 (Sun, 10 Aug 2008)
New Revision: 7907
Added:
packages/trunk/reminiscence/debian/patches/03_launchinroot_function.patches
packages/trunk/reminiscence/debian/patches/04_data_and_save_path_directories_creation.patches
Modified:
packages/trunk/reminiscence/debian/patches/series
Log:
Add the path for data and save.
Added: packages/trunk/reminiscence/debian/patches/03_launchinroot_function.patches
===================================================================
--- packages/trunk/reminiscence/debian/patches/03_launchinroot_function.patches (rev 0)
+++ packages/trunk/reminiscence/debian/patches/03_launchinroot_function.patches 2008-08-10 08:00:59 UTC (rev 7907)
@@ -0,0 +1,40 @@
+Index: reminiscence-0.1.9/main.cpp
+===================================================================
+--- reminiscence-0.1.9.orig/main.cpp 2008-08-10 08:16:22.000000000 +0200
++++ reminiscence-0.1.9/main.cpp 2008-08-10 08:20:02.000000000 +0200
+@@ -19,6 +19,9 @@
+ #include "file.h"
+ #include "game.h"
+ #include "systemstub.h"
++#include <unistd.h>
++#include <sys/types.h>
++#include <stdio.h>
+
+ static const char *USAGE =
+ "REminiscence - Flashback Interpreter\n"
+@@ -26,6 +29,11 @@
+ " --datapath=PATH Path to data files (default 'DATA')\n"
+ " --savepath=PATH Path to save files (default '.')";
+
++static bool launchinroot()
++{
++ return ((getuid()==0)?true:false);
++}
++
+ static bool parseOption(const char *arg, const char *longCmd, const char **opt) {
+ bool handled = false;
+ if (arg[0] == '-' && arg[1] == '-') {
+@@ -61,6 +69,13 @@
+ int main(int argc, char *argv[]) {
+ const char *dataPath = "DATA";
+ const char *savePath = ".";
++
++ if (launchinroot())
++ {
++ fprintf(stderr,"You cannot execute REminiscence with root priviledge\n");
++ return 0;
++ }
++
+ for (int i = 1; i < argc; ++i) {
+ bool opt = false;
+ if (strlen(argv[i]) >= 2) {
Added: packages/trunk/reminiscence/debian/patches/04_data_and_save_path_directories_creation.patches
===================================================================
--- packages/trunk/reminiscence/debian/patches/04_data_and_save_path_directories_creation.patches (rev 0)
+++ packages/trunk/reminiscence/debian/patches/04_data_and_save_path_directories_creation.patches 2008-08-10 08:00:59 UTC (rev 7907)
@@ -0,0 +1,274 @@
+Index: reminiscence-0.1.9/main.cpp
+===================================================================
+--- reminiscence-0.1.9.orig/main.cpp 2008-08-10 08:24:25.000000000 +0200
++++ reminiscence-0.1.9/main.cpp 2008-08-10 09:48:55.000000000 +0200
+@@ -21,19 +21,208 @@
+ #include "systemstub.h"
+ #include <unistd.h>
+ #include <sys/types.h>
++#include <sys/stat.h>
+ #include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
+
++/* deleted because the data and save path
++ * will found in $HOME/.reminiscence
++ */
++#if false
+ static const char *USAGE =
+ "REminiscence - Flashback Interpreter\n"
+ "Usage: rs [OPTIONS]...\n"
+ " --datapath=PATH Path to data files (default 'DATA')\n"
+ " --savepath=PATH Path to save files (default '.')";
++#endif
++
++typedef struct datasave_s datasave_t;
++
++struct datasave_s
++{
++ char *datapath;
++ char *savepath;
++};
++
++static void datasave_strings_destroy(datasave_t **p)
++{
++ if (*p == NULL)
++ return;
++ if ((*p)->datapath != (char *)NULL)
++ free((*p)->datapath);
++ if ((*p)->savepath != (char *)NULL)
++ free((*p)->savepath);
++
++ free(*p);
++}
++
++static void make_folders(char *s)
++{
++ char *t;
++ char *p;
++
++ t = (char *) NULL;
++ p = (char *) NULL;
++
++ if (s != (char *)NULL || *s == '\0')
++ exit(EXIT_FAILURE);
++
++ t = getenv("HOME");
++
++ if (t != (char *)NULL)
++ exit(EXIT_FAILURE);
++
++ p = s;
++
++ while (*p++ == *t++);
++
++ while(*p)
++ {
++ if(*p == '/')
++ {
++ *p = '\0';
++ mkdir(s, 0700);
++ *p = '/';
++ }
++
++ p++;
++ }
++ mkdir(s, 0700);
++}
++
++static void datasave_path_create(datasave_t *p)
++{
++ if (p == (datasave_t *)NULL)
++ exit(EXIT_FAILURE);
++
++ make_folders(p->datapath);
++ make_folders(p->savepath);
++}
++
++static datasave_t *datasave_strings_create(const char *s)
++{
++ datasave_t *p;
++ const char datapath[] = "DATA";
++ const char savepath[] = "save";
++ const char home_reminiscence[] = ".reminiscence";
++ size_t datapath_length;
++ size_t savepath_length;
++ size_t home_reminiscence_length;
++ size_t s_length;
++
++ p = (datasave_t *) NULL;
++
++ if (s == (const char *) NULL || (*s == '\0'))
++ return 0;
++
++ s_length = strlen(s);
++
++ if (s_length < 1)
++ return 0;
++
++ p = (datasave_t *) malloc(sizeof(datasave_t *));
++
++ if (p == (datasave_t *) NULL)
++ {
++ perror("malloc");
++ return 0;
++ }
++
++ datapath_length = strlen(datapath);
++ savepath_length = strlen(savepath);
++ home_reminiscence_length = strlen(home_reminiscence);
++
++ p->datapath = (char *) NULL;
++
++ /* + 3 due to path separator / */
++ p->datapath = (char *) malloc(s_length +
++ home_reminiscence_length +
++ datapath_length + 3 + 1);
++
++ if (p->datapath == (char*) NULL)
++ {
++ if (p != (datasave_t *) NULL)
++ free(p);
++
++ perror("malloc");
++ return 0;
++ }
++
++ strncpy(p->datapath, s, s_length);
++ strncat(p->datapath, "/", 1);
++ strncat(p->datapath, home_reminiscence, home_reminiscence_length);
++ strncat(p->datapath, "/", 1);
++ strncat(p->datapath, datapath, datapath_length);
++ strncat(p->datapath, "/", 1);
++
++ p->savepath = (char *) NULL;
++
++ /* + 3 due to path separator / */
++ p->savepath = (char *) malloc(s_length +
++ home_reminiscence_length +
++ savepath_length + 3 + 1);
++
++ if (p->savepath == (char *) NULL)
++ {
++ if (p->datapath != (char *) NULL)
++ free(p->datapath);
++
++ if (p != (datasave_t *)NULL)
++ free(p);
++
++ perror("malloc");
++ return 0;
++ }
++
++ strncpy(p->savepath, s, s_length);
++ strncat(p->savepath, "/", 1);
++ strncat(p->savepath, home_reminiscence, home_reminiscence_length);
++ strncat(p->savepath, "/", 1);
++ strncat(p->savepath, savepath, savepath_length);
++ strncat(p->savepath, "/", 1);
++
++ return p;
++}
++
++static datasave_t *datasave_strings_creation()
++{
++ datasave_t *p;
++ char *home_directory;
++
++
++ p = (datasave_t *) NULL;
++
++ home_directory = (char *) NULL;
++
++ home_directory = getenv("HOME");
++
++ if (home_directory == (char *)NULL)
++ {
++ fprintf(stderr,"I'm can not find your HOME directory.\n");
++ return (datasave_t *)NULL;
++ }
++
++ p = datasave_strings_create(home_directory);
++
++ if (p == (datasave_t *) NULL)
++ {
++ fprintf(stderr,"stuct allocation failed !\n");
++ return (datasave_t *) NULL;
++ }
++
++ return p;
++}
+
+ static bool launchinroot()
+ {
+ return ((getuid()==0)?true:false);
+ }
+
++/* deleted because the data and save path
++ * will found in $HOME/.reminiscence
++ */
++#if false
+ static bool parseOption(const char *arg, const char *longCmd, const char **opt) {
+ bool handled = false;
+ if (arg[0] == '-' && arg[1] == '-') {
+@@ -44,6 +233,7 @@
+ }
+ return handled;
+ }
++#endif
+
+ static Version detectVersion(const char *dataPath) {
+ static struct {
+@@ -67,15 +257,28 @@
+
+ #undef main
+ int main(int argc, char *argv[]) {
++
++/* deleted because the data and save path
++ * will found in $HOME/.reminiscence
++ */
++#if false
+ const char *dataPath = "DATA";
+ const char *savePath = ".";
++#endif
++ datasave_t *p;
+
++ p = (datasave_t *) NULL;
++
+ if (launchinroot())
+ {
+ fprintf(stderr,"You cannot execute REminiscence with root priviledge\n");
+ return 0;
+ }
+
++/* deleted because the data and save path
++ * will found in $HOME/.reminiscence
++ */
++#if false
+ for (int i = 1; i < argc; ++i) {
+ bool opt = false;
+ if (strlen(argv[i]) >= 2) {
+@@ -87,12 +290,21 @@
+ return 0;
+ }
+ }
+- Version ver = detectVersion(dataPath);
++#endif
++ p = datasave_strings_creation();
++
++ if (p == (datasave_t *)NULL)
++ return 0;
++
++ datasave_path_create(p);
++
++ Version ver = detectVersion(p->datapath);
+ g_debugMask = DBG_INFO; // DBG_CUT | DBG_VIDEO | DBG_RES | DBG_MENU | DBG_PGE | DBG_GAME | DBG_UNPACK | DBG_COL | DBG_MOD | DBG_SFX;
+ SystemStub *stub = SystemStub_SDL_create();
+- Game *g = new Game(stub, dataPath, savePath, ver);
++ Game *g = new Game(stub, p->datapath, p->savepath, ver);
+ g->run();
+ delete g;
+ delete stub;
++ datasave_strings_destroy(&p);
+ return 0;
+ }
Modified: packages/trunk/reminiscence/debian/patches/series
===================================================================
--- packages/trunk/reminiscence/debian/patches/series 2008-08-09 20:42:54 UTC (rev 7906)
+++ packages/trunk/reminiscence/debian/patches/series 2008-08-10 08:00:59 UTC (rev 7907)
@@ -1,2 +1,4 @@
+03_launchinroot_function.patches
01_updating_to_gcc_4.3_compiler.patches
02_adding_rs_to_clean_target.patches
+04_data_and_save_path_directories_creation.patches
More information about the Pkg-games-commits
mailing list