diff --git a/Common/OS.cpp b/Common/OS.cpp index 410bae79ef24ee48b835bb22290f492154b4915c..6aa4666b5e7b643ef338cccae1cbaf7473de0b04 100644 --- a/Common/OS.cpp +++ b/Common/OS.cpp @@ -1,4 +1,4 @@ -// $Id: OS.cpp,v 1.9 2007-09-04 13:47:00 remacle Exp $ +// $Id: OS.cpp,v 1.10 2008-01-08 12:05:45 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -125,7 +125,7 @@ int GetProcessId() #endif } -int UnlinkFile(char *filename) +int UnlinkFile(const char *filename) { #if !defined(WIN32) || defined(__CYGWIN__) return unlink(filename); @@ -134,7 +134,7 @@ int UnlinkFile(char *filename) #endif } -int StatFile(char *filename) +int StatFile(const char *filename) { #if !defined(WIN32) || defined(__CYGWIN__) struct stat buf; @@ -160,7 +160,7 @@ int KillProcess(int pid) return 1; } -int SystemCall(char *command) +int SystemCall(const char *command) { #if defined(WIN32) STARTUPINFO suInfo; diff --git a/Common/OS.h b/Common/OS.h index 894bc1fae6a586b32d3b299e1ba0926eb13cc364..0432a08ec84d47d2d86f3856a43d837ddfa03cce 100644 --- a/Common/OS.h +++ b/Common/OS.h @@ -26,9 +26,9 @@ void GetResources(double *s, long *mem); void CheckResources(); double Cpu(); int GetProcessId(); -int UnlinkFile(char *name); -int StatFile(char *filename); +int UnlinkFile(const char *name); +int StatFile(const char *filename); int KillProcess(int pid); -int SystemCall(char *command); +int SystemCall(const char *command); #endif diff --git a/Common/Options.cpp b/Common/Options.cpp index ef5a7be785e59212871da7887fd2af9cd1e0ac4d..63dc290b8c1404663d934fc311d8cf07e4fea921 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.371 2007-12-07 20:49:05 geuzaine Exp $ +// $Id: Options.cpp,v 1.372 2008-01-08 12:05:45 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -249,7 +249,7 @@ void Print_ColorTable(int num, int diff, char *prefix, FILE *file) Msg(DIRECT, tmp); } -void Print_Options(int num, int level, int diff, int help, char *filename) +void Print_Options(int num, int level, int diff, int help, const char *filename) { FILE *file; diff --git a/Common/Options.h b/Common/Options.h index 91d48d4bca20b53f2915f142b04466d24ac6e8b7..f4daf5710669d8196974e901183ea268ae634d7a 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -770,7 +770,7 @@ typedef struct { void Init_Options(int num); void Init_Options_GUI(int num); void ReInit_Options(int num); -void Print_Options(int num, int level, int diff, int help, char *filename); +void Print_Options(int num, int level, int diff, int help, const char *filename); void Print_OptionsDoc(); StringXString * Get_StringOptionCategory(char * cat); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 8f7c95844da6400a9c40a09b0f14f903bac123ac..6de05405e46d4dbe8099180b3999fc00a57337d0 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.556 2008-01-07 23:16:18 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.557 2008-01-08 12:05:45 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -22,6 +22,7 @@ #include <signal.h> #include <time.h> #include <map> +#include <string> #include "Gmsh.h" #include "GmshUI.h" @@ -564,24 +565,24 @@ void file_new_cb(CALLBACK_ARGS) { test: if(file_chooser(0, 1, "New", "*")) { - char *name = file_chooser_get_name(1); - if(!StatFile(name)){ + std::string name = file_chooser_get_name(1); + if(!StatFile(name.c_str())){ if(fl_choice("File '%s' already exists.\n\nDo you want to erase it?", - "Cancel", "Erase", NULL, name)) - UnlinkFile(name); + "Cancel", "Erase", NULL, name.c_str())) + UnlinkFile(name.c_str()); else goto test; } - FILE *fp = fopen(name, "w"); + FILE *fp = fopen(name.c_str(), "w"); if(!fp){ - Msg(GERROR, "Unable to open file '%s'", name); + Msg(GERROR, "Unable to open file '%s'", name.c_str()); return; } time_t now; time(&now); fprintf(fp, "// Gmsh project created on %s", ctime(&now)); fclose(fp); - OpenProject(name); + OpenProject(name.c_str()); Draw(); } } @@ -630,7 +631,7 @@ void file_open_cb(CALLBACK_ARGS) { int n = PView::list.size(); if(file_chooser(0, 0, "Open", input_formats)) { - OpenProject(file_chooser_get_name(1)); + OpenProject(file_chooser_get_name(1).c_str()); Draw(); } if(n != (int)PView::list.size()) @@ -643,37 +644,37 @@ void file_merge_cb(CALLBACK_ARGS) int f = file_chooser(1, 0, "Merge", input_formats); if(f) { for(int i = 1; i <= f; i++) - MergeFile(file_chooser_get_name(i)); + MergeFile(file_chooser_get_name(i).c_str()); Draw(); } if(n != (int)PView::list.size()) WID->set_context(menu_post, 0); } -int _save_msh(char *name){ return msh_dialog(name); } -int _save_pos(char *name){ return pos_dialog(name); } -int _save_options(char *name){ return options_dialog(name); } -int _save_geo(char *name){ return geo_dialog(name); } -int _save_cgns(char *name){ CreateOutputFile(name, FORMAT_CGNS); return 1; } -int _save_unv(char *name){ return unv_dialog(name); } -int _save_med(char *name){ return generic_mesh_dialog(name, "MED Options", FORMAT_MED); } -int _save_mesh(char *name){ return generic_mesh_dialog(name, "MESH Options", FORMAT_MESH); } -int _save_bdf(char *name){ return bdf_dialog(name); } -int _save_p3d(char *name){ return generic_mesh_dialog(name, "P3D Options", FORMAT_P3D); } -int _save_stl(char *name){ return stl_dialog(name); } -int _save_vrml(char *name){ return generic_mesh_dialog(name, "VRML Options", FORMAT_VRML); } -int _save_eps(char *name){ return gl2ps_dialog(name, "EPS Options", FORMAT_EPS); } -int _save_gif(char *name){ return gif_dialog(name); } -int _save_jpeg(char *name){ return jpeg_dialog(name); } -int _save_tex(char *name){ return latex_dialog(name); } -int _save_pdf(char *name){ return gl2ps_dialog(name, "PDF Options", FORMAT_PDF); } -int _save_png(char *name){ return generic_bitmap_dialog(name, "PNG Options", FORMAT_PNG); } -int _save_ps(char *name){ return gl2ps_dialog(name, "PS Options", FORMAT_PS); } -int _save_ppm(char *name){ return generic_bitmap_dialog(name, "PPM Options", FORMAT_PPM); } -int _save_svg(char *name){ return gl2ps_dialog(name, "SVG Options", FORMAT_SVG); } -int _save_yuv(char *name){ return generic_bitmap_dialog(name, "YUV Options", FORMAT_YUV); } - -int _save_auto(char *name) +int _save_msh(const char *name){ return msh_dialog(name); } +int _save_pos(const char *name){ return pos_dialog(name); } +int _save_options(const char *name){ return options_dialog(name); } +int _save_geo(const char *name){ return geo_dialog(name); } +int _save_cgns(const char *name){ CreateOutputFile(name, FORMAT_CGNS); return 1; } +int _save_unv(const char *name){ return unv_dialog(name); } +int _save_med(const char *name){ return generic_mesh_dialog(name, "MED Options", FORMAT_MED); } +int _save_mesh(const char *name){ return generic_mesh_dialog(name, "MESH Options", FORMAT_MESH); } +int _save_bdf(const char *name){ return bdf_dialog(name); } +int _save_p3d(const char *name){ return generic_mesh_dialog(name, "P3D Options", FORMAT_P3D); } +int _save_stl(const char *name){ return stl_dialog(name); } +int _save_vrml(const char *name){ return generic_mesh_dialog(name, "VRML Options", FORMAT_VRML); } +int _save_eps(const char *name){ return gl2ps_dialog(name, "EPS Options", FORMAT_EPS); } +int _save_gif(const char *name){ return gif_dialog(name); } +int _save_jpeg(const char *name){ return jpeg_dialog(name); } +int _save_tex(const char *name){ return latex_dialog(name); } +int _save_pdf(const char *name){ return gl2ps_dialog(name, "PDF Options", FORMAT_PDF); } +int _save_png(const char *name){ return generic_bitmap_dialog(name, "PNG Options", FORMAT_PNG); } +int _save_ps(const char *name){ return gl2ps_dialog(name, "PS Options", FORMAT_PS); } +int _save_ppm(const char *name){ return generic_bitmap_dialog(name, "PPM Options", FORMAT_PPM); } +int _save_svg(const char *name){ return gl2ps_dialog(name, "SVG Options", FORMAT_SVG); } +int _save_yuv(const char *name){ return generic_bitmap_dialog(name, "YUV Options", FORMAT_YUV); } + +int _save_auto(const char *name) { switch(GuessFileFormatFromFileName(name)){ case FORMAT_MSH : return _save_msh(name); @@ -705,8 +706,8 @@ int _save_auto(char *name) } typedef struct{ - char *pat; - int (*func) (char *name); + const char *pat; + int (*func) (const char *name); } patXfunc; void file_save_as_cb(CALLBACK_ARGS) @@ -772,20 +773,20 @@ void file_save_as_cb(CALLBACK_ARGS) test: if(file_chooser(0, 1, "Save As", pat)) { - char *name = file_chooser_get_name(1); + std::string name = file_chooser_get_name(1); if(CTX.confirm_overwrite) { - if(!StatFile(name)) + if(!StatFile(name.c_str())) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name)) + "Cancel", "Replace", NULL, name.c_str())) goto test; } i = file_chooser_get_filter(); if(i >= 0 && i < nbformats){ - if(!formats[i].func(name)) + if(!formats[i].func(name.c_str())) goto test; } else // handle any additional automatic fltk filter - _save_auto(name); + _save_auto(name.c_str()); } } @@ -793,15 +794,15 @@ void file_rename_cb(CALLBACK_ARGS) { test: if(file_chooser(0, 1, "Rename", "*", CTX.filename)) { - char *name = file_chooser_get_name(1); + std::string name = file_chooser_get_name(1); if(CTX.confirm_overwrite) { - if(!StatFile(name)) + if(!StatFile(name.c_str())) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name)) + "Cancel", "Replace", NULL, name.c_str())) goto test; } - rename(CTX.filename, name); - OpenProject(name); + rename(CTX.filename, name.c_str()); + OpenProject(name.c_str()); Draw(); } } @@ -1907,14 +1908,14 @@ void message_save_cb(CALLBACK_ARGS) { test: if(file_chooser(0, 1, "Save", "*")) { - char *name = file_chooser_get_name(1); + std::string name = file_chooser_get_name(1); if(CTX.confirm_overwrite) { - if(!StatFile(name)) + if(!StatFile(name.c_str())) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name)) + "Cancel", "Replace", NULL, name.c_str())) goto test; } - WID->save_message(name); + WID->save_message(name.c_str()); } } @@ -4130,10 +4131,10 @@ void solver_file_open_cb(CALLBACK_ARGS) // We allow to create the .pro file... Or should we add a "New file" // button? if(file_chooser(0, 0, "Choose", tmp)) { - WID->solver[num].input[0]->value(file_chooser_get_name(1)); + WID->solver[num].input[0]->value(file_chooser_get_name(1).c_str()); if(SINFO[num].nboptions) { char file[1024]; - FixWindowsPath(file_chooser_get_name(1), file); + FixWindowsPath(file_chooser_get_name(1).c_str(), file); sprintf(tmp, "\"%s\"", file); sprintf(file, SINFO[num].name_command, tmp); sprintf(tmp, "%s %s", SINFO[num].option_command, file); @@ -4156,7 +4157,7 @@ void solver_choose_mesh_cb(CALLBACK_ARGS) { int num = (int)(long)data; if(file_chooser(0, 0, "Choose", "*")) - WID->solver[num].input[1]->value(file_chooser_get_name(1)); + WID->solver[num].input[1]->value(file_chooser_get_name(1).c_str()); } int nbs(char *str) @@ -4231,7 +4232,7 @@ void solver_choose_executable_cb(CALLBACK_ARGS) "*" #endif )){ - WID->solver[num].input[2]->value(file_chooser_get_name(1)); + WID->solver[num].input[2]->value(file_chooser_get_name(1).c_str()); solver_ok_cb(w, data); } } @@ -4368,14 +4369,14 @@ static void _view_save_as(int view_num, char *title, int format) test: if(file_chooser(0, 1, title, "*", (char*)view->getData()->getFileName().c_str())){ - char *name = file_chooser_get_name(1); + std::string name = file_chooser_get_name(1); if(CTX.confirm_overwrite) { - if(!StatFile(name)) + if(!StatFile(name.c_str())) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name)) + "Cancel", "Replace", NULL, name.c_str())) goto test; } - view->write(name, format); + view->write(name.c_str(), format); } } diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 38e471cb3c05a0cde15955e9b5b42fa1bb60ed64..7afdcdd95f10c603266ba40ef5aa1aff23c3d9a2 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.646 2007-12-07 20:49:05 geuzaine Exp $ +// $Id: GUI.cpp,v 1.647 2008-01-08 12:05:45 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -403,7 +403,7 @@ Fl_Menu_Item menu_font_names[] = { {0} }; -int GetFontIndex(char *fontname) +int GetFontIndex(const char *fontname) { if(fontname){ for(int i = 0; i < NUM_FONTS; i++) @@ -431,7 +431,7 @@ char *GetFontName(int index) return "Helvetica"; } -int GetFontAlign(char *alignstr) +int GetFontAlign(const char *alignstr) { if(alignstr){ if(!strcmp(alignstr, "BottomLeft") || !strcmp(alignstr, "Left") || @@ -1539,7 +1539,7 @@ void GUI::set_size(int new_w, int new_h) // Set graphic window title -void GUI::set_title(char *str) +void GUI::set_title(const char *str) { g_window->label(str); } @@ -1601,7 +1601,7 @@ void GUI::check_anim_buttons() // Set the status messages -void GUI::set_status(char *msg, int num) +void GUI::set_status(const char *msg, int num) { if(num == 0 || num == 1){ g_status_label[num]->label(msg); @@ -1623,7 +1623,7 @@ void GUI::set_status(char *msg, int num) } } -void GUI::add_multiline_in_browser(Fl_Browser * o, char *prefix, char *str) +void GUI::add_multiline_in_browser(Fl_Browser * o, const char *prefix, const char *str) { int start = 0, len; char *buff; @@ -4016,7 +4016,7 @@ void GUI::add_message(char *msg) msg_browser->bottomline(msg_browser->size()); } -void GUI::save_message(char *filename) +void GUI::save_message(const char *filename) { FILE *fp; @@ -4037,7 +4037,7 @@ void GUI::save_message(char *filename) fclose(fp); } -void GUI::fatal_error(char *filename) +void GUI::fatal_error(const char *filename) { fl_alert("A fatal error has occurred which will force Gmsh to abort.\n" "The error messages have been saved in the following file:\n\n%s", diff --git a/Fltk/GUI.h b/Fltk/GUI.h index 10b8a39e8edffbbbb75dd656e9ceb0ee694e1130..062519932a683265d21867d0d540c2c71ce0ae89 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -126,7 +126,7 @@ class GUI{ int MH, fontsize; Fl_Scroll *m_scroll; - void add_multiline_in_browser(Fl_Browser *o, char* prefix, char *str); + void add_multiline_in_browser(Fl_Browser *o, const char *prefix, const char *str); public: @@ -307,13 +307,13 @@ public: void update_views(); void set_anim_buttons(int mode); void check_anim_buttons(); - void set_status(char *msg, int num); + void set_status(const char *msg, int num); void add_message(char *msg); - void save_message(char *filename); - void fatal_error(char *filename); + void save_message(const char *filename); + void fatal_error(const char *filename); void set_statistics(bool compute_quality); void update_view_window(int numview); - void set_title(char *str); + void set_title(const char *str); void add_handler(); int global_shortcuts(int event); int arrow_shortcuts(); @@ -329,10 +329,10 @@ public: }; // some utility font functions -int GetFontIndex(char *fontname); +int GetFontIndex(const char *fontname); int GetFontEnum(int index); char *GetFontName(int index); -int GetFontAlign(char *alignstr); +int GetFontAlign(const char *alignstr); int GetFontSize(); #endif diff --git a/Fltk/GUI_Extras.cpp b/Fltk/GUI_Extras.cpp index 3304e2a870879b55c81597960293741f8a8b85dd..92f1aa545115109bfb7639c7b2a142976fe38768 100644 --- a/Fltk/GUI_Extras.cpp +++ b/Fltk/GUI_Extras.cpp @@ -1,4 +1,4 @@ -// $Id: GUI_Extras.cpp,v 1.40 2008-01-08 10:47:27 geuzaine Exp $ +// $Id: GUI_Extras.cpp,v 1.41 2008-01-08 12:05:45 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -46,7 +46,7 @@ extern Context_T CTX; // File chooser int file_chooser(int multi, int create, const char *message, - const char *filter, char *fname) + const char *filter, const char *fname) { static char thefilter[1024] = ""; static int thefilterindex = 0; @@ -108,13 +108,13 @@ int file_chooser(int multi, int create, const char *message, #endif } -char *file_chooser_get_name(int num) +std::string file_chooser_get_name(int num) { if(!fc) return ""; #if defined(HAVE_NATIVE_FILE_CHOOSER) - return (char *)fc->filename(num - 1); + return std::string(fc->filename(num - 1)); #else - return (char *)fc->value(num); + return std::string(fc->value(num)); #endif } @@ -135,7 +135,7 @@ void file_chooser_get_position(int *x, int *y) // Arrow editor -int arrow_editor(char *title, double &a, double &b, double &c) +int arrow_editor(const char *title, double &a, double &b, double &c) { struct _editor{ Fl_Window *window; @@ -243,7 +243,7 @@ int perspective_editor() // Generic save bitmap dialog -int generic_bitmap_dialog(char *name, char *title, int format) +int generic_bitmap_dialog(const char *name, const char *title, int format) { struct _generic_bitmap_dialog{ Fl_Window *window; @@ -297,7 +297,7 @@ int generic_bitmap_dialog(char *name, char *title, int format) // TeX dialog -int latex_dialog(char *name) +int latex_dialog(const char *name) { struct _latex_dialog{ Fl_Window *window; @@ -350,7 +350,7 @@ int latex_dialog(char *name) // Save jpeg dialog -int jpeg_dialog(char *name) +int jpeg_dialog(const char *name) { struct _jpeg_dialog{ Fl_Window *window; @@ -420,7 +420,7 @@ int jpeg_dialog(char *name) // Save gif dialog -int gif_dialog(char *name) +int gif_dialog(const char *name) { struct _gif_dialog{ Fl_Window *window; @@ -523,7 +523,7 @@ static void activate_gl2ps_choices(int format, int quality, Fl_Check_Button *b[5 } } -int gl2ps_dialog(char *name, char *title, int format) +int gl2ps_dialog(const char *name, const char *title, int format) { struct _gl2ps_dialog{ Fl_Window *window; @@ -615,7 +615,7 @@ int gl2ps_dialog(char *name, char *title, int format) // Save options dialog -int options_dialog(char *name) +int options_dialog(const char *name) { struct _options_dialog{ Fl_Window *window; @@ -670,7 +670,7 @@ int options_dialog(char *name) // geo dialog -int geo_dialog(char *name) +int geo_dialog(const char *name) { struct _geo_dialog{ Fl_Window *window; @@ -721,7 +721,7 @@ int geo_dialog(char *name) return 0; } -int pos_dialog(char *name) +int pos_dialog(const char *name) { struct _pos_dialog{ Fl_Window *window; @@ -790,7 +790,7 @@ int pos_dialog(char *name) // Generic save mesh dialog -int generic_mesh_dialog(char *name, char *title, int format) +int generic_mesh_dialog(const char *name, const char *title, int format) { struct _generic_mesh_dialog{ Fl_Window *window; @@ -844,7 +844,7 @@ int generic_mesh_dialog(char *name, char *title, int format) // Save msh dialog -int msh_dialog(char *name) +int msh_dialog(const char *name) { struct _msh_dialog{ Fl_Window *window; @@ -914,7 +914,7 @@ int msh_dialog(char *name) // unv mesh dialog -int unv_dialog(char *name) +int unv_dialog(const char *name) { struct _unv_dialog{ Fl_Window *window; @@ -971,7 +971,7 @@ int unv_dialog(char *name) // Save bdf dialog -int bdf_dialog(char *name) +int bdf_dialog(const char *name) { struct _bdf_dialog{ Fl_Window *window; @@ -1037,7 +1037,7 @@ int bdf_dialog(char *name) // Save stl dialog -int stl_dialog(char *name) +int stl_dialog(const char *name) { struct _stl_dialog{ Fl_Window *window; diff --git a/Fltk/GUI_Extras.h b/Fltk/GUI_Extras.h index 9e7619f14a14550c281e2dce4bf199aa3a755c5e..54b0610c5249fb7f68e2f7dd506b65df6a128902 100644 --- a/Fltk/GUI_Extras.h +++ b/Fltk/GUI_Extras.h @@ -20,28 +20,30 @@ // // Please report all bugs and problems to <gmsh@geuz.org>. +#include <string> + int file_chooser(int multi, int create, const char *message, - const char *pat, char *fname=NULL); -char *file_chooser_get_name(int num); + const char *pat, const char *fname=NULL); +std::string file_chooser_get_name(int num); int file_chooser_get_filter(); void file_chooser_get_position(int *x, int *y); -int arrow_editor(char *title, double &a, double &b, double &c); +int arrow_editor(const char *title, double &a, double &b, double &c); int perspective_editor(); -int jpeg_dialog(char *filename); -int gif_dialog(char *filename); -int geo_dialog(char *filename); -int generic_bitmap_dialog(char *filename, char *title, int format); -int generic_mesh_dialog(char *filename, char *title, int format); -int gl2ps_dialog(char *filename, char *title, int format); -int options_dialog(char *filename); -int pos_dialog(char *filename); -int msh_dialog(char *filename); -int unv_dialog(char *filename); -int bdf_dialog(char *filename); -int stl_dialog(char *filename); -int latex_dialog(char *filename); +int jpeg_dialog(const char *filename); +int gif_dialog(const char *filename); +int geo_dialog(const char *filename); +int generic_bitmap_dialog(const char *filename, const char *title, int format); +int generic_mesh_dialog(const char *filename, const char *title, int format); +int gl2ps_dialog(const char *filename, const char *title, int format); +int options_dialog(const char *filename); +int pos_dialog(const char *filename); +int msh_dialog(const char *filename); +int unv_dialog(const char *filename); +int bdf_dialog(const char *filename); +int stl_dialog(const char *filename); +int latex_dialog(const char *filename); #endif diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp index 32b85317e5b976e38111f3c16573bc5d3331fbef..436748f86851542c53aa24b2d06677ba7d866a25 100644 --- a/Fltk/GUI_Projection.cpp +++ b/Fltk/GUI_Projection.cpp @@ -790,9 +790,9 @@ void save_selection_cb(Fl_Widget *w, void *data) { projectionEditor *e = (projectionEditor*)data; if(file_chooser(0, 1, "Save Selection", "*.{geo,msh}")){ - FILE *fp = fopen(file_chooser_get_name(1), "w"); + FILE *fp = fopen(file_chooser_get_name(1).c_str(), "w"); if(!fp){ - Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1)); + Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1).c_str()); return; } std::vector<GEntity*> &ent(e->getEntities()); @@ -830,9 +830,9 @@ void load_projection_cb(Fl_Widget *w, void *data) { projectionEditor *e = (projectionEditor*)data; if(file_chooser(0, 0, "Load Projection", "*.pro")){ - FILE *fp = fopen(file_chooser_get_name(1), "r"); + FILE *fp = fopen(file_chooser_get_name(1).c_str(), "r"); if(!fp){ - Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1)); + Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1).c_str()); return; } int num; @@ -874,14 +874,14 @@ void save_projection_cb(Fl_Widget *w, void *data) if(p){ FM::ProjectionSurface *ps = p->face->GetProjectionSurface(); if(file_chooser(0, 1, "Save Projection", "*.pro")){ - char *name = file_chooser_get_name(1); - FILE *fp = fopen(name, "w"); + std::string name = file_chooser_get_name(1); + FILE *fp = fopen(name.c_str(), "w"); if(!fp){ - Msg(GERROR, "Unable to open file `%s'", name); + Msg(GERROR, "Unable to open file `%s'", name.c_str()); return; } char no_ext[256], ext[256], base[256]; - SplitFileName(name, no_ext, ext, base); + SplitFileName(name.c_str(), no_ext, ext, base); fprintf(fp, "1\n%s\n%s\n", base, ps->GetName().c_str()); for(unsigned int i = 0; i < p->parameters.size(); i++) fprintf(fp, "%.16g\n", p->parameters[i]->value()); @@ -1021,9 +1021,9 @@ void action_cb(Fl_Widget *w, void *data) } else{ if(file_chooser(0, 1, "Save Fourier Model", "*.fm")){ - FILE *fp = fopen(file_chooser_get_name(1), "w"); + FILE *fp = fopen(file_chooser_get_name(1).c_str(), "w"); if(!fp){ - Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1)); + Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1).c_str()); return; } fprintf(fp, "%d\n", (int)faces.size()); diff --git a/Fltk/GmshServer.h b/Fltk/GmshServer.h index 229a4ffcef9279b9eb05e3eaa1607f4f6a619420..f76c60e1fa835a59c0f1dd6f2d73bc05fd2c4c6d 100644 --- a/Fltk/GmshServer.h +++ b/Fltk/GmshServer.h @@ -30,7 +30,7 @@ // Contributor(s): // Christopher Stott -void SystemCall(char *str); +void SystemCall(const char *str); int WaitForData(int socket, int num, double waitint); #include <stdio.h> diff --git a/Graphics/ReadImg.cpp b/Graphics/ReadImg.cpp index 8bce1dee6fb9a76bbb7c15caab57b1ed6943c190..00bb038f0b29be7de92f7d3964a0de765fb40110 100644 --- a/Graphics/ReadImg.cpp +++ b/Graphics/ReadImg.cpp @@ -1,4 +1,4 @@ -// $Id: ReadImg.cpp,v 1.19 2007-09-10 04:47:03 geuzaine Exp $ +// $Id: ReadImg.cpp,v 1.20 2008-01-08 12:05:45 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -98,7 +98,7 @@ static PViewDataList *Img2Data(Fl_RGB_Image &img_init, int quads=1, return d; } -static int EndPos(char *name, PViewData *d) +static int EndPos(const char *name, PViewData *d) { if(!d) return 0; char name_pos[256], title[256]; @@ -125,25 +125,25 @@ static int EndPos(char *name, PViewData *d) } } -int read_pnm(char *name) +int read_pnm(const char *name) { Fl_PNM_Image img(name); return EndPos(name, Img2Data(img)); } -int read_jpeg(char *name) +int read_jpeg(const char *name) { Fl_JPEG_Image img(name); return EndPos(name, Img2Data(img)); } -int read_png(char *name) +int read_png(const char *name) { Fl_PNG_Image img(name); return EndPos(name, Img2Data(img)); } -int read_bmp(char *name) +int read_bmp(const char *name) { Fl_BMP_Image img(name); return EndPos(name, Img2Data(img)); diff --git a/Graphics/ReadImg.h b/Graphics/ReadImg.h index a643576ba8d7bc9e6f2fcb8e80e550b00260dc8c..ebf885d460f59345c8a9df6e978ae3303b9ca817 100644 --- a/Graphics/ReadImg.h +++ b/Graphics/ReadImg.h @@ -20,9 +20,9 @@ // // Please report all bugs and problems to <gmsh@geuz.org>. -int read_pnm(char *name); -int read_jpeg(char *name); -int read_png(char *name); -int read_bmp(char *name); +int read_pnm(const char *name); +int read_jpeg(const char *name); +int read_png(const char *name); +int read_bmp(const char *name); #endif diff --git a/Parser/CreateFile.cpp b/Parser/CreateFile.cpp index 4bde77d4d7049b69fe27050b0f1e08b03a238a50..6518c14d3d80d3ac2e134c08dd306d1fe929e38d 100644 --- a/Parser/CreateFile.cpp +++ b/Parser/CreateFile.cpp @@ -1,4 +1,4 @@ -// $Id: CreateFile.cpp,v 1.21 2007-10-03 19:40:41 geuzaine Exp $ +// $Id: CreateFile.cpp,v 1.22 2008-01-08 12:05:45 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -37,7 +37,7 @@ extern Context_T CTX; -int GuessFileFormatFromFileName(char *name) +int GuessFileFormatFromFileName(const char *name) { int len; char ext[256]; @@ -111,7 +111,7 @@ void GetDefaultFileName(int format, char *name) strcat(name, ext); } -void CreateOutputFile(char *filename, int format) +void CreateOutputFile(const char *filename, int format) { char name[256], no_ext[256], ext[256], base[256]; diff --git a/Parser/CreateFile.h b/Parser/CreateFile.h index ed6e71c067fb90f1336e2520128b1ef6be700968..e89597b88758249cdff0abf80cd5794259f12041 100644 --- a/Parser/CreateFile.h +++ b/Parser/CreateFile.h @@ -20,8 +20,8 @@ // // Please report all bugs and problems to <gmsh@geuz.org>. -int GuessFileFormatFromFileName(char *name); +int GuessFileFormatFromFileName(const char *name); void GetDefaultFileName(int format, char *name); -void CreateOutputFile(char *name, int format); +void CreateOutputFile(const char *name, int format); #endif diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index 65d85e2f562386ce6269e4adb6b65e40f35221c6..b45f37a026c2f47ebb46827f0ecc83e6713d6a58 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,4 +1,4 @@ -// $Id: OpenFile.cpp,v 1.164 2007-09-26 20:52:01 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.165 2008-01-08 12:05:45 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -46,7 +46,7 @@ extern GUI *WID; extern Context_T CTX; -void FixRelativePath(char *in, char *out){ +void FixRelativePath(const char *in, char *out){ if(in[0] == '/' || in[0] == '\\' || (strlen(in)>2 && in[1] == ':')){ // do nothing: 'in' is an absolute path strcpy(out, in); @@ -61,7 +61,7 @@ void FixRelativePath(char *in, char *out){ } } -void FixWindowsPath(char *in, char *out){ +void FixWindowsPath(const char *in, char *out){ #if defined(__CYGWIN__) cygwin_conv_to_win32_path(in, out); #else @@ -69,7 +69,7 @@ void FixWindowsPath(char *in, char *out){ #endif } -void SplitFileName(char *name, char *no_ext, char *ext, char *base) +void SplitFileName(const char *name, char *no_ext, char *ext, char *base) { strcpy(no_ext, name); strcpy(ext, ""); @@ -186,7 +186,7 @@ void AddToTemporaryBoundingBox(double x, double y, double z) FinishUpBoundingBox(); } -int ParseFile(char *f, int close, int warn_if_missing) +int ParseFile(const char *f, int close, int warn_if_missing) { char yyname_old[256], tmp[256]; FILE *yyin_old, *fp; @@ -243,7 +243,7 @@ int ParseFile(char *f, int close, int warn_if_missing) return 1; } -void ParseString(char *str) +void ParseString(const char *str) { if(!str) return; FILE *fp; @@ -256,7 +256,7 @@ void ParseString(char *str) } } -void SetProjectName(char *name) +void SetProjectName(const char *name) { char no_ext[256], ext[256], base[256]; SplitFileName(name, no_ext, ext, base); @@ -270,7 +270,7 @@ void SetProjectName(char *name) #endif } -int MergeFile(char *name, int warn_if_missing) +int MergeFile(const char *name, int warn_if_missing) { // added 'b' for pure Windows programs, since some of these files // contain binary data @@ -405,7 +405,7 @@ int MergeFile(char *name, int warn_if_missing) return status; } -void OpenProject(char *name) +void OpenProject(const char *name) { if(CTX.threads_lock) { Msg(INFO, "I'm busy! Ask me that later..."); diff --git a/Parser/OpenFile.h b/Parser/OpenFile.h index 7ccd8368c1266dccd0f2b005bdd4288bea92c927..0b8ce8d334f9c5ed41ba98277d9629071fcbf015 100644 --- a/Parser/OpenFile.h +++ b/Parser/OpenFile.h @@ -20,14 +20,14 @@ // // Please report all bugs and problems to <gmsh@geuz.org>. -int ParseFile(char *filename, int close, int warn_if_missing=0); -void ParseString(char *str); -void OpenProject(char *filename); +int ParseFile(const char *filename, int close, int warn_if_missing=0); +void ParseString(const char *str); +void OpenProject(const char *filename); void OpenProjectMacFinder(const char *filename); -int MergeFile(char *filename, int warn_if_missing=0); -void FixRelativePath(char *in, char *out); -void FixWindowsPath(char *in, char *out); -void SplitFileName(char *name, char *no_ext, char *ext, char *base); +int MergeFile(const char *filename, int warn_if_missing=0); +void FixRelativePath(const char *in, char *out); +void FixWindowsPath(const char *in, char *out); +void SplitFileName(const char *name, char *no_ext, char *ext, char *base); void SetBoundingBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);