Skip to content
Snippets Groups Projects
Commit 9981bf30 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

Home dir

parent 51fedc7b
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ public : ...@@ -39,6 +39,7 @@ public :
char *display; // forced display host:0.0 under X11 char *display; // forced display host:0.0 under X11
int terminal; // show we print to the terminal console? int terminal; // show we print to the terminal console?
char *editor; // text editor command (with included '%s') 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 position[2]; // position of the menu window on the screen
int gl_position[2]; // position of the graphic window on the screen int gl_position[2]; // position of the graphic window on the screen
......
// $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 "Gmsh.h"
#include "GmshUI.h" #include "GmshUI.h"
...@@ -19,6 +19,20 @@ extern GUI *WID ; ...@@ -19,6 +19,20 @@ extern GUI *WID ;
// ************** General routines **************************************** // ************** General routines ****************************************
void Init_Options(int num){ 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 // Reference view storing default options
Post_ViewReference = (Post_View*)Malloc(sizeof(Post_View)) ; Post_ViewReference = (Post_View*)Malloc(sizeof(Post_View)) ;
...@@ -414,20 +428,6 @@ int Get_ColorForString(StringX4Int SX4I[], int alpha, ...@@ -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){ char * opt_general_display(OPT_ARGS_STR){
if(action & GMSH_SET) CTX.display = val; if(action & GMSH_SET) CTX.display = val;
return CTX.display; return CTX.display;
...@@ -459,7 +459,7 @@ char * opt_general_error_filename(OPT_ARGS_STR){ ...@@ -459,7 +459,7 @@ char * opt_general_error_filename(OPT_ARGS_STR){
char * opt_general_session_filename(OPT_ARGS_STR){ char * opt_general_session_filename(OPT_ARGS_STR){
if(action & GMSH_SET){ if(action & GMSH_SET){
CTX.session_filename = val; CTX.session_filename = val;
GET_PATH(CTX.sessionrc_filename); strcpy(CTX.sessionrc_filename, CTX.home_dir);
strcat(CTX.sessionrc_filename, CTX.session_filename); strcat(CTX.sessionrc_filename, CTX.session_filename);
} }
return CTX.session_filename; return CTX.session_filename;
...@@ -467,7 +467,7 @@ char * opt_general_session_filename(OPT_ARGS_STR){ ...@@ -467,7 +467,7 @@ char * opt_general_session_filename(OPT_ARGS_STR){
char * opt_general_options_filename(OPT_ARGS_STR){ char * opt_general_options_filename(OPT_ARGS_STR){
if(action & GMSH_SET){ if(action & GMSH_SET){
CTX.options_filename = val; CTX.options_filename = val;
GET_PATH(CTX.optionsrc_filename); strcpy(CTX.optionsrc_filename, CTX.home_dir);
strcat(CTX.optionsrc_filename, CTX.options_filename); strcat(CTX.optionsrc_filename, CTX.options_filename);
} }
#ifdef _FLTK #ifdef _FLTK
......
// $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> #include <signal.h>
...@@ -124,6 +124,7 @@ int main(int argc, char *argv[]){ ...@@ -124,6 +124,7 @@ int main(int argc, char *argv[]){
Msg(LOG_INFO, gmsh_date); Msg(LOG_INFO, gmsh_date);
Msg(LOG_INFO, gmsh_host); Msg(LOG_INFO, gmsh_host);
Msg(LOG_INFO, gmsh_packager); Msg(LOG_INFO, gmsh_packager);
Msg(LOG_INFO, "Home directory : '%s'", CTX.home_dir);
Msg(LOG_INFO, "-------------------------------------------------------"); Msg(LOG_INFO, "-------------------------------------------------------");
// Display the GUI immediately to have a quick "a la Windows" launch time // Display the GUI immediately to have a quick "a la Windows" launch time
......
/* $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 <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -119,7 +119,7 @@ int Socket_StartProgram(char *progname, char *sockname){ ...@@ -119,7 +119,7 @@ int Socket_StartProgram(char *progname, char *sockname){
strcpy(addr.sun_path, sockname); strcpy(addr.sun_path, sockname);
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
if(bind(s, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0) { 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; return -1;
} }
...@@ -158,7 +158,8 @@ int Socket_StartProgram(char *progname, char *sockname){ ...@@ -158,7 +158,8 @@ int Socket_StartProgram(char *progname, char *sockname){
} }
int Socket_StopProgram(char *progname, char *sockname, int sock){ 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); close(sock);
return 0; return 0;
} }
......
// $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" #include "Gmsh.h"
...@@ -11,33 +11,16 @@ ...@@ -11,33 +11,16 @@
#include "Socket.h" #include "Socket.h"
#include "OpenFile.h" #include "OpenFile.h"
#include "Solvers.h" #include "Solvers.h"
#include "GmshUI.h" #include "GmshUI.h"
#include "GUI.h" #include "GUI.h"
#include "Mesh.h" #include "Mesh.h"
#include "Draw.h" #include "Draw.h"
#include "Context.h"
extern Context_T CTX;
extern GUI *WID; 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 // interface to GetDP
_GetDP_Info GetDP_Info ; _GetDP_Info GetDP_Info ;
...@@ -46,7 +29,7 @@ int GetDP(char *args){ ...@@ -46,7 +29,7 @@ int GetDP(char *args){
int sock, type, i, n; int sock, type, i, n;
char progname[1000], sockname[1000], str[1000]; char progname[1000], sockname[1000], str[1000];
GET_PATH(sockname); strcpy(sockname, CTX.home_dir);
strcat(sockname, ".gmshsock"); strcat(sockname, ".gmshsock");
sprintf(progname, "%s %s", GetDP_Info.command, args); sprintf(progname, "%s %s", GetDP_Info.command, args);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment