Example #1
0
static void findbrowser(void) {
#if __CygWin
    static char *stdbrowsers[] = { "netscape.exe", "opera.exe", "galeon.exe", "kfmclient.exe",
	"chrome.exe", "mozilla.exe", "mosaic.exe", /*"grail",*/
	"iexplore.exe",
	/*"lynx.exe",*/
#else
/* Both xdg-open and htmlview are not browsers per se, but browser dispatchers*/
/*  which try to figure out what browser the user intents. It seems no one */
/*  uses (understands?) environment variables any more, so BROWSER is a bit */
/*  old-fashioned */
    static char *stdbrowsers[] = { "xdg-open", "x-www-browser", "htmlview",
        "firefox", "mozilla", "konqueror", "opera", "google-chrome", "galeon",
        "kfmclient", "netscape", "mosaic", /*"grail",*/ "lynx",
#endif
	NULL };
    int i;
    char *path;

    if ( getenv("BROWSER")!=NULL ) {
	strcpy(browser,getenv("BROWSER"));
#if __CygWin			/* Get rid of any dos style names */
	if ( isalpha(browser[0]) && browser[1]==':' && browser[2]=='\\' )
	    cygwin_conv_to_full_posix_path(getenv("BROWSER"),browser);
	else if ( strchr(browser,'/')==NULL ) {
	    if ( strstrmatch(browser,".exe")==NULL )
		strcat(browser,".exe");
	    if ( (path=_GFile_find_program_dir(browser))!=NULL ) {
		snprintf(browser,sizeof(browser),"%s/%s", path, getenv("BROWSER"));
		free(path);
	    }
	}
#endif
	if ( strcmp(browser,"kde")==0 || strcmp(browser,"kfm")==0 ||
		strcmp(browser,"konqueror")==0 || strcmp(browser,"kfmclient")==0 )
	    strcpy(browser,"kfmclient openURL");
return;
    }
    for ( i=0; stdbrowsers[i]!=NULL; ++i ) {
	if ( (path=_GFile_find_program_dir(stdbrowsers[i]))!=NULL ) {
	    if ( strcmp(stdbrowsers[i],"kfmclient")==0 )
		strcpy(browser,"kfmclient openURL");
	    else
#if __CygWin
		snprintf(browser,sizeof(browser),"%s/%s", path, stdbrowsers[i]);
#else
		strcpy(browser,stdbrowsers[i]);
#endif
	    free(path);
return;
	}
    }
#if __Mac
    strcpy(browser,"open");	/* thanks to riggle */
#endif
}
Example #2
0
static void findbrowser(void) {
    /* Find a browser to use so that help messages can be displayed */

    /* Both xdg-open and htmlview are not browsers per se, but browser dispatchers*/
    /*  which try to figure out what browser the user intents. It seems no one */
    /*  uses (understands?) environment variables any more, so BROWSER is a bit */
    /*  old-fashioned */
    static char *stdbrowsers[] = { "xdg-open", "x-www-browser", "htmlview",
#if __Mac
                                   "safari",
#endif
                                   "firefox", "mozilla", "seamonkey", "iceweasel", "opera", "konqueror", "google-chrome",
                                   "galeon", "kfmclient", "netscape", "mosaic", /*"grail",*/ "lynx",
                                   NULL
                                 };
    int i;
    char *path;

    if ( getenv("BROWSER")!=NULL ) {
        strncpy(browser,getenv("BROWSER"),sizeof(browser));
        browser[sizeof(browser)-1] = '\0';
        if ( strcmp(browser,"kde")==0 || strcmp(browser,"kfm")==0 ||
                strcmp(browser,"konqueror")==0 || strcmp(browser,"kfmclient")==0 )
            strcpy(browser,"kfmclient openURL");
        return;
    }
    for ( i=0; stdbrowsers[i]!=NULL; ++i ) {
        if ( (path=_GFile_find_program_dir(stdbrowsers[i]))!=NULL ) {
            if ( strcmp(stdbrowsers[i],"kfmclient")==0 )
                strcpy(browser,"kfmclient openURL");
            else
                strcpy(browser,stdbrowsers[i]);
            free(path);
            return;
        }
    }
#if __Mac
    strcpy(browser,"open");	/* thanks to riggle */
#endif
}
Example #3
0
static void FindProgDir(char *prog) {
#if defined(__MINGW32__)
    char  path[MAX_PATH+4];
    char* c = path;
    char* tail = 0;
    unsigned int  len = GetModuleFileNameA(NULL, path, MAX_PATH);
    path[len] = '\0';
    for(; *c; *c++){
	if(*c == '\\'){
	    tail=c;
	    *c = '/';
	}
    }
    if(tail) *tail='\0';
    GResourceProgramDir = copy(path);
#else
    GResourceProgramDir = _GFile_find_program_dir(prog);
    if ( GResourceProgramDir==NULL ) {
	char filename[1025];
	GFileGetAbsoluteName(".",filename,sizeof(filename));
	GResourceProgramDir = copy(filename);
    }
#endif
}