From: Braden M. <br...@us...> - 2006-01-24 15:01:35
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13582/mozilla-plugin/src Modified Files: openvrml.cpp Log Message: Parse OPENVRML_PLAYER environment variable with g_shell_parse_argv such that arguments can be passed along with the executable name. Index: openvrml.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** openvrml.cpp 23 Jan 2006 04:45:08 -0000 1.25 --- openvrml.cpp 24 Jan 2006 15:01:27 -0000 1.26 *************** *** 1,3 **** ! // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in --- 1,3 ---- ! // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- // // OpenVRML Mozilla plug-in *************** *** 1099,1108 **** } ! const char * exec_path = getenv("OPENVRML_PLAYER"); ! if (!exec_path) { ! exec_path = OPENVRML_LIBEXECDIR_ "/openvrml-player"; } - vector<char> exec_path_vec(exec_path, - exec_path + strlen(exec_path) + 1); string socket_id_arg = --- 1099,1135 ---- } ! // ! // The OPENVRML_PLAYER environment variable overrides the ! // default path to the child process executable. To allow ! // OPENVRML_PLAYER to include arguments (rather than just be a ! // path to an executable), it is parsed wit ! // g_shell_parse_argv. This is particularly useful in case we ! // want to run the child process in a harness like valgrind. ! // ! gint openvrml_player_cmd_argc = 0; ! gchar ** openvrml_player_cmd_argv = 0; ! const gchar * const openvrml_player_cmd = ! g_getenv("OPENVRML_PLAYER"); ! if (!openvrml_player_cmd) { ! openvrml_player_cmd_argc = 1; ! openvrml_player_cmd_argv = ! static_cast<gchar **>(g_malloc(sizeof (gchar *))); ! if (!openvrml_player_cmd_argv) { throw std::bad_alloc(); } ! openvrml_player_cmd_argv[0] = ! OPENVRML_LIBEXECDIR_ "/openvrml-player"; ! } else { ! GError * error = 0; ! gboolean succeeded = ! g_shell_parse_argv(openvrml_player_cmd, ! &openvrml_player_cmd_argc, ! &openvrml_player_cmd_argv, ! &error); ! if (!succeeded) { ! if (error) { ! g_critical(error->message); ! g_error_free(error); ! } ! } } string socket_id_arg = *************** *** 1127,1137 **** write_fd_arg_c_str + write_fd_arg.length() + 1); ! char * argv[] = { ! &exec_path_vec.front(), ! &socket_id_arg_vec.front(), ! &read_fd_arg_vec.front(), ! &write_fd_arg_vec.front(), ! 0 ! }; result = execv(argv[0], argv); --- 1154,1170 ---- write_fd_arg_c_str + write_fd_arg.length() + 1); ! gchar ** const argv = ! static_cast<gchar **>( ! g_malloc( ! sizeof (gchar *) * openvrml_player_cmd_argc + 4)); ! if (!argv) { throw std::bad_alloc(); } ! gint i; ! for (i = 0; i < openvrml_player_cmd_argc; ++i) { ! argv[i] = openvrml_player_cmd_argv[i]; ! } ! argv[i++] = &socket_id_arg_vec.front(); ! argv[i++] = &read_fd_arg_vec.front(); ! argv[i++] = &write_fd_arg_vec.front(); ! argv[i] = 0; result = execv(argv[0], argv); *************** *** 1139,1142 **** --- 1172,1178 ---- g_error("Failed to start openvrml-player"); } + + g_free(argv); + g_strfreev(openvrml_player_cmd_argv); } else if (this->player_pid > 0) { int result = close(this->out_pipe[0]); |