From e2fe9dcd79fa5e0bae2f65d2e7a63448d49984df Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 27 Dec 2008 11:43:03 +0000 Subject: [PATCH] Added some pathes for AROS operating system. We need someone to test it out now :) Also, there is a realpath implementation there wich may be useful for BeOS too git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@421 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- Makefile | 13 ++++++++ Makefile.dep | 3 +- aide.c | 1 + files.c | 2 +- init.c | 4 +-- main.c | 2 ++ realpath.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ realpath.h | 6 ++++ setup.c | 6 ++-- 9 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 realpath.c create mode 100644 realpath.h diff --git a/Makefile b/Makefile index ea877edb..b969de91 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,19 @@ else NOTTF = 1 else + #AROS specific + ifeq ($(PLATFORM),AROS) + DELCOMMAND = rm -rf + MKDIR = mkdir -p + RMDIR = rmdir + CP = cp + BIN = grafx2 + CFGBIN = gfxcfg + COPT = -Wall _c _g `i386-linux-aros-sdl-config --cflags` $(TTFCOPT) + LOPT = -lSDL_image `i386-linux-aros-sdl-config --libs` -lpng -ljpeg -lz $(TTFLOPT) + CC = i386-linux-aros-gcc + OBJDIR = obj/aros + #BeOS specific ifeq ($(PLATFORM),BeOS) DELCOMMAND = rm -rf diff --git a/Makefile.dep b/Makefile.dep index d9cdcb8a..68ba643f 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -23,7 +23,7 @@ $(OBJDIR)/loadsave.o: loadsave.c const.h struct.h global.h loadsave.h graph.h \ divers.h pages.h op_c.h boutons.h erreurs.h io.h sdlscreen.h windows.h $(OBJDIR)/main.o: main.c const.h struct.h global.h loadsave.h graph.h divers.h \ init.h boutons.h moteur.h pages.h files.h sdlscreen.h erreurs.h \ - readini.h saveini.h io.h texte.h setup.h windows.h brush.h + readini.h saveini.h io.h texte.h setup.h windows.h brush.h realpath.h $(OBJDIR)/moteur.o: moteur.c const.h struct.h global.h loadsave.h graph.h divers.h \ special.h boutons.h operatio.h shade.h erreurs.h sdlscreen.h windows.h brush.h $(OBJDIR)/op_c.o: op_c.c op_c.h struct.h const.h erreurs.h graph.h @@ -43,6 +43,7 @@ $(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h loadsave.h sdlscreen.h \ $(OBJDIR)/readini.o: readini.c const.h global.h struct.h loadsave.h graph.h divers.h $(OBJDIR)/readline.o: readline.c const.h struct.h global.h loadsave.h graph.h \ divers.h erreurs.h sdlscreen.h readline.h windows.h +$(OBJDIR)/realpath.o: realpath.c $(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h loadsave.h readini.h io.h \ erreurs.h graph.h divers.h $(OBJDIR)/sdlscreen.o: sdlscreen.c global.h struct.h const.h loadsave.h sdlscreen.h \ diff --git a/aide.c b/aide.c index 3e45296b..346da7fa 100644 --- a/aide.c +++ b/aide.c @@ -417,6 +417,7 @@ void Bouton_Stats(void) } #else // Free disk space is only for shows. Other platforms can display 0. + Taille=0; #endif if(Taille > (100ULL*1024*1024*1024)) diff --git a/files.c b/files.c index 439e44a4..ccff9eb1 100644 --- a/files.c +++ b/files.c @@ -29,7 +29,7 @@ #include #include -#if defined(__amigaos4__) +#if defined(__amigaos4__) || defined(__AROS__) #include #include #define isHidden(Enreg) (0) diff --git a/init.c b/init.c index a8d48252..2fbf5ff2 100644 --- a/init.c +++ b/init.c @@ -69,7 +69,7 @@ void Ajouter_lecteur(char Lettre, byte Type, char *Chemin) // Rechercher la liste et le type des lecteurs de la machine void Rechercher_drives(void) { - #if defined(__amigaos4__) + #if defined(__amigaos4__) || defined(__AROS__) // No icons by default. // It's possible to add some here. @@ -124,7 +124,7 @@ void Rechercher_drives(void) #if defined(__BEOS__) || defined(__HAIKU__) char * Home = getenv("$HOME"); #else - char * Home = getenv("HOME"); + char * Home = getenv("HOME"); #endif Ajouter_lecteur('/', LECTEUR_HDD, "/"); Ajouter_lecteur('~', LECTEUR_HDD, Home ? Home : ""); diff --git a/main.c b/main.c index d8553be7..6b30a1e0 100644 --- a/main.c +++ b/main.c @@ -58,6 +58,8 @@ #elif defined(__macosx__) #import #import +#elif defined(__AROS__) || defined(__BEOS__) + #include "realpath.h" #endif byte Ancien_nb_lignes; // Ancien nombre de lignes de l'écran diff --git a/realpath.c b/realpath.c new file mode 100644 index 00000000..4475d43d --- /dev/null +++ b/realpath.c @@ -0,0 +1,86 @@ +/* Found in: + http://amiga.sourceforge.net/amigadevhelp/FUNCTIONS/GeekGadgets/realpath/ex02_realpath.c +*/ + +#include +#include +#include +#include +#include +#include + +static char *sep(char *path) +{ + char *tmp, c; + + tmp = strrchr(path, '/'); + if(tmp) { + c = tmp[1]; + tmp[1] = 0; + if (chdir(path)) { + return NULL; + } + tmp[1] = c; + + return tmp + 1; + } + + return path; + +} + +char *realpath(const char *_path, char *resolved_path) +{ + int fd = open(".", O_RDONLY), l; + char path[PATH_MAX], lnk[PATH_MAX], *tmp = (char *)""; + char tmp2[PATH_MAX]; + + if (fd < 0) { + return NULL; + } + strncpy(path, _path, PATH_MAX); + + if (chdir(path)) { + if (errno == ENOTDIR) { + l = readlink(path, lnk, PATH_MAX); + if (!(tmp = sep(path))) { + resolved_path = NULL; + goto abort; + } + if (l < 0) { + if (errno != EINVAL) { + resolved_path = NULL; + goto abort; + } + } else { + lnk[l] = 0; + if (!(tmp = sep(lnk))) { + resolved_path = NULL; + goto abort; + } + } + } else { + resolved_path = NULL; + goto abort; + } + } + + if(resolved_path==NULL) // if we called realpath with null as a 2nd arg + resolved_path = (char*) malloc( PATH_MAX ); + + if (!getcwd(resolved_path, PATH_MAX)) { + resolved_path = NULL; + goto abort; + } + + if(strcmp(resolved_path, "/") && *tmp) { + strcat(resolved_path, "/"); + } + + strcat(resolved_path, tmp); + abort: + fchdir(fd); + close(fd); + return resolved_path; +} + diff --git a/realpath.h b/realpath.h new file mode 100644 index 00000000..3f73679e --- /dev/null +++ b/realpath.h @@ -0,0 +1,6 @@ +#ifndef _REALPATH_H +#define _REALPATH_H + +char *realpath(const char *_path, char *resolved_path); + +#endif diff --git a/setup.c b/setup.c index 61059e5f..3d16b3f3 100644 --- a/setup.c +++ b/setup.c @@ -49,7 +49,7 @@ int Create_ConfigDirectory(char * Config_Dir) #endif } -#if defined(__macosx__) || defined(__amigaos4__) +#if defined(__macosx__) || defined(__amigaos4__) || defined(__AROS__) #define ARG_UNUSED __attribute__((unused)) #else #define ARG_UNUSED @@ -70,7 +70,7 @@ void Set_Program_Directory(ARG_UNUSED const char * argv0,char * Program_Dir) strcat(Program_Dir ,"/"); // AmigaOS4: hard-coded volume name. - #elif defined(__amigaos4__) + #elif defined(__amigaos4__) || defined(__AROS__) strcpy(Program_Dir,"PROGDIR:"); // Others: The part of argv[0] before the executable name. @@ -113,7 +113,7 @@ void Set_Config_Directory(const char * Program_Dir, char * Config_Dir) strcpy(Config_Dir,Program_Dir); strcat(Config_Dir,"Contents/Resources/"); // AmigaOS4 - #elif defined(__amigaos4__) + #elif defined(__amigaos4__) || defined(__AROS__) strcpy(Config_Dir,"PROGDIR:"); #else char FileName[TAILLE_CHEMIN_FICHIER];