static int context_hud_handler(window_info *win, int widget_id, int mx, int my, int option) { unsigned char protocol_name; switch (option) { case CMH_MINIMAP: view_window(&minimap_win, 0); break; case CMH_RANGSTATS: view_window(&range_win, 0); break; #ifdef NEW_SOUND case CMH_SOUND: toggle_sounds(&sound_on); set_var_unsaved("enable_sound", INI_FILE_VAR); break; case CMH_MUSIC: toggle_music(&music_on); set_var_unsaved("enable_music", INI_FILE_VAR); break; #endif // NEW_SOUND case CMH_LOCATION: copy_next_LOCATE_ME = 1; protocol_name= LOCATE_ME; my_tcp_send(my_socket,&protocol_name,1); break; default: init_misc_display(); } return 1; }
void open_web_link(const char * url) { #ifdef OSX CFURLRef newurl = CFURLCreateWithString(kCFAllocatorDefault,CFStringCreateWithCStringNoCopy(NULL,url,kCFStringEncodingMacRoman, NULL),NULL); LSOpenCFURLRef(newurl,NULL); CFRelease(newurl); #else // browser name can override the windows default, and if not defined in Linux, don't error if(*browser_name){ #ifndef WINDOWS static int have_set_signal = 0; #ifdef SOUND_FORK_BUGFIX int sound_on_copy = sound_on; int music_on_copy = music_on; #endif /* we're not interested in the exit status of the child so set SA_NOCLDWAIT to stop it becoming a zombie if we don't wait() */ if (!have_set_signal) { struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = SIG_DFL; act.sa_flags = SA_NOCLDWAIT; sigaction(SIGCHLD, &act, NULL); have_set_signal = 1; } #ifdef SOUND_FORK_BUGFIX if (sound_on_copy) toggle_sounds(&sound_on); if (music_on_copy) toggle_music(&music_on); #endif if (fork() == 0){ execlp(browser_name, browser_name, url, NULL); // in case the exec errors _exit(1); } #ifdef SOUND_FORK_BUGFIX if (sound_on_copy) toggle_sounds(&sound_on); if (music_on_copy) toggle_music(&music_on); #endif #else // make a copy of the url string as it may be freed by the caller // will be freed as the only_call_from_open_web_link__go_to_url() exits char *cp_url = malloc(strlen(url)+1); safe_strncpy(cp_url, url, strlen(url)+1); // windows needs to spawn it in its own thread SDL_CreateThread(only_call_from_open_web_link__go_to_url, cp_url); } else { ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNOACTIVATE); //this returns an int we could check for errors, but that's mainly when you use shellexecute for local files #endif //_WIN32 } #endif // OSX }