diff --git a/Common/Context.h b/Common/Context.h index 8d4ab4e8c720eefdd9d32f27c35df9b7ff6ff392..f8381d46c4daff159dc319bf0e72bc393f5a0cbe 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -39,6 +39,7 @@ public : char *display; // forced display host:0.0 under X11 int terminal; // show we print to the terminal console? char *editor; // text editor command (with included '%s') + char home_dir[NAME_STR_L]; // the home directory int position[2]; // position of the menu window on the screen int gl_position[2]; // position of the graphic window on the screen diff --git a/Common/Options.cpp b/Common/Options.cpp index 73772ed9091a39ba453398953ebdc6adfaabe27d..8ba08830017b65d73f0d53139db8441a6f8362de 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.19 2001-05-20 19:24:53 geuzaine Exp $ +// $Id: Options.cpp,v 1.20 2001-05-21 13:01:13 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -19,6 +19,20 @@ extern GUI *WID ; // ************** General routines **************************************** void Init_Options(int num){ + char *tmp; + + // Home directory + if((tmp = getenv("HOME"))) strcpy(CTX.home_dir, tmp); + else if((tmp = getenv("TMP"))) strcpy(CTX.home_dir, tmp); + else if((tmp = getenv("TEMP"))) strcpy(CTX.home_dir, tmp); + else strcpy(CTX.home_dir, ""); + if(strlen(CTX.home_dir)){ +#if defined(WIN32) && !defined(__CYGWIN__) + strcat(CTX.home_dir, "\\"); +#else + strcat(CTX.home_dir, "/"); +#endif + } // Reference view storing default options Post_ViewReference = (Post_View*)Malloc(sizeof(Post_View)) ; @@ -414,20 +428,6 @@ int Get_ColorForString(StringX4Int SX4I[], int alpha, } \ } -#if defined(WIN32) && !defined(__CYGWIN__) -#define SLASH "\\" -#else -#define SLASH "/" -#endif - -#define GET_PATH(path_val) \ - char *tmp; \ - if ((tmp = getenv("HOME"))) strcpy(path_val, tmp); \ - else if((tmp = getenv("TMP"))) strcpy(path_val, tmp); \ - else if((tmp = getenv("TEMP"))) strcpy(path_val, tmp); \ - else strcpy(path_val, ""); \ - if(strlen(path_val)) strcat(path_val, SLASH); - char * opt_general_display(OPT_ARGS_STR){ if(action & GMSH_SET) CTX.display = val; return CTX.display; @@ -459,7 +459,7 @@ char * opt_general_error_filename(OPT_ARGS_STR){ char * opt_general_session_filename(OPT_ARGS_STR){ if(action & GMSH_SET){ CTX.session_filename = val; - GET_PATH(CTX.sessionrc_filename); + strcpy(CTX.sessionrc_filename, CTX.home_dir); strcat(CTX.sessionrc_filename, CTX.session_filename); } return CTX.session_filename; @@ -467,7 +467,7 @@ char * opt_general_session_filename(OPT_ARGS_STR){ char * opt_general_options_filename(OPT_ARGS_STR){ if(action & GMSH_SET){ CTX.options_filename = val; - GET_PATH(CTX.optionsrc_filename); + strcpy(CTX.optionsrc_filename, CTX.home_dir); strcat(CTX.optionsrc_filename, CTX.options_filename); } #ifdef _FLTK diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp index 5f0321d9d14b346dd14ff94528d7b54b7eece5fe..3e360ef2f8abb14db39256d9cf03023ff4384c47 100644 --- a/Fltk/Main.cpp +++ b/Fltk/Main.cpp @@ -1,4 +1,4 @@ -// $Id: Main.cpp,v 1.24 2001-05-07 06:25:26 geuzaine Exp $ +// $Id: Main.cpp,v 1.25 2001-05-21 13:01:13 geuzaine Exp $ #include <signal.h> @@ -124,6 +124,7 @@ int main(int argc, char *argv[]){ Msg(LOG_INFO, gmsh_date); Msg(LOG_INFO, gmsh_host); Msg(LOG_INFO, gmsh_packager); + Msg(LOG_INFO, "Home directory : '%s'", CTX.home_dir); Msg(LOG_INFO, "-------------------------------------------------------"); // Display the GUI immediately to have a quick "a la Windows" launch time diff --git a/Fltk/Socket.cpp b/Fltk/Socket.cpp index 2d031e455cd9290b0d1c1404cd8d53692fe35f47..625f78ce977288e7e68f35f303fd4f02008054e7 100644 --- a/Fltk/Socket.cpp +++ b/Fltk/Socket.cpp @@ -1,4 +1,4 @@ -/* $Id: Socket.cpp,v 1.10 2001-05-07 07:55:00 geuzaine Exp $ */ +/* $Id: Socket.cpp,v 1.11 2001-05-21 13:01:13 geuzaine Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -119,7 +119,7 @@ int Socket_StartProgram(char *progname, char *sockname){ strcpy(addr.sun_path, sockname); addr.sun_family = AF_UNIX; if(bind(s, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0) { - Msg(GERROR, "Couldn't bind socket to name"); + Msg(GERROR, "Couldn't bind socket to name '%s'", sockname); return -1; } @@ -158,7 +158,8 @@ int Socket_StartProgram(char *progname, char *sockname){ } int Socket_StopProgram(char *progname, char *sockname, int sock){ - if(Socket_UnlinkName(sockname)==-1) Msg(WARNING, "Impossible to unlink the socket"); + if(Socket_UnlinkName(sockname)==-1) + Msg(WARNING, "Impossible to unlink the socket '%s'", sockname); close(sock); return 0; } diff --git a/Fltk/Solvers.cpp b/Fltk/Solvers.cpp index fd54c8f007db00a60011b082bd739801d087b223..36850d2b11853d1fc66a48c247aaa819f37dc1ba 100644 --- a/Fltk/Solvers.cpp +++ b/Fltk/Solvers.cpp @@ -1,4 +1,4 @@ -// $Id: Solvers.cpp,v 1.6 2001-05-17 13:14:15 geuzaine Exp $ +// $Id: Solvers.cpp,v 1.7 2001-05-21 13:01:13 geuzaine Exp $ #include "Gmsh.h" @@ -11,33 +11,16 @@ #include "Socket.h" #include "OpenFile.h" #include "Solvers.h" - #include "GmshUI.h" #include "GUI.h" #include "Mesh.h" #include "Draw.h" +#include "Context.h" - +extern Context_T CTX; extern GUI *WID; -#if defined(WIN32) && !defined(__CYGWIN__) -#define SLASH "\\" -#else -#define SLASH "/" -#endif - -#define GET_PATH(path_val) \ - char *tmp; \ - if ((tmp = getenv("HOME"))) strcpy(path_val, tmp); \ - else if((tmp = getenv("TMP"))) strcpy(path_val, tmp); \ - else if((tmp = getenv("TEMP"))) strcpy(path_val, tmp); \ - else strcpy(path_val, ""); \ - if(strlen(path_val)) strcat(path_val, SLASH); - - - - // interface to GetDP _GetDP_Info GetDP_Info ; @@ -46,7 +29,7 @@ int GetDP(char *args){ int sock, type, i, n; char progname[1000], sockname[1000], str[1000]; - GET_PATH(sockname); + strcpy(sockname, CTX.home_dir); strcat(sockname, ".gmshsock"); sprintf(progname, "%s %s", GetDP_Info.command, args);