view dmd2/man.c @ 828:03b0c817a1a3

added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
author elrood
date Thu, 04 Dec 2008 22:09:24 +0100
parents f04dde6e882c
children
line wrap: on
line source


// Compiler implementation of the D programming language
// Copyright (c) 2008-2008 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
// License for redistribution is by either the Artistic License
// in artistic.txt, or the GNU General Public License in gnu.txt.
// See the included readme.txt for details.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#if _WIN32

#include <windows.h>

#pragma comment(lib,"shell32.lib")

void browse(const char *url)
{
    ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
}

#endif

#if linux || __APPLE__

#include	<sys/types.h>
#include	<sys/wait.h>
#include	<unistd.h>

void browse(const char *url)
{
    pid_t childpid;
    const char *args[3];

    const char *browser = getenv("BROWSER");
    if (browser)
	browser = strdup(browser);
    else
	browser = "firefox";

    args[0] = browser;
    args[1] = url;
    args[2] = NULL;

    childpid = fork();
    if (childpid == 0)
    {
	execvp(args[0], (char**)args);
	perror(args[0]);		// failed to execute
	return;
    }
}

#endif