Paste #ep0 -- näytä pelkkänä tekstinä -- uusi tämän pohjalta
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <stdio.h> #ifdef WIN32 #include <windows.h> void os_launch_browser(const char *url) { fprintf(stderr, "INFO: Launching browser to open \"%s\"\n", url); ShellExecute(0, "open", url, 0, 0, SW_SHOWDEFAULT); } #else #include <unistd.h> void os_launch_browser(const char *url) { fprintf(stderr, "INFO: Launching browser to open \"%s\"\n", url); char prog[] = "/usr/bin/xdg-open"; char url2[1000]; snprintf(url2, 1000, "%s", url); char *argv[3]; argv[0] = prog; argv[1] = url2; argv[2] = NULL; pid_t pid = fork(); if(pid == 0){ execvp(prog, argv); _exit(1); } } #endif |