/** called when replicated from NSBaseView::Instantiate() */ int gui_init_replicant(int argc, char** argv) { nserror ret; BPath options; struct netsurf_table beos_table = { &beos_misc_table, beos_window_table, beos_download_table, beos_clipboard_table, &beos_fetch_table, NULL, /* use POSIX file */ NULL, /* default utf8 */ NULL, /* default search */ NULL, /* default web search */ NULL, /* default low level cache persistant storage */ beos_bitmap_table, beos_layout_table }; ret = netsurf_register(&beos_table); if (ret != NSERROR_OK) { die("NetSurf operation table failed registration"); } if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) { options.Append("x-vnd.NetSurf"); } /* initialise logging. Not fatal if it fails but not much we * can do about it either. */ nslog_init(nslog_stream_configure, &argc, argv); // FIXME: use options as readonly for replicants /* user options setup */ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default); if (ret != NSERROR_OK) { // FIXME: must not die when in replicant! die("Options failed to initialise"); } nsoption_read(options.Path(), NULL); nsoption_commandline(&argc, argv, NULL); /* common initialisation */ BPath messages = get_messages_path(); ret = messages_add_from_file(messages.Path()); ret = netsurf_init(NULL); if (ret != NSERROR_OK) { // FIXME: must not die when in replicant! die("NetSurf failed to initialise"); } gui_init(argc, argv); return 0; }
/** * Main entry point from OS. */ int main(int argc, char** argv) { char *cache_home = NULL; nserror ret; struct netsurf_table nsgtk_table = { .misc = &nsgtk_misc_table, .window = nsgtk_window_table, .clipboard = nsgtk_clipboard_table, .download = nsgtk_download_table, .fetch = nsgtk_fetch_table, .llcache = filesystem_llcache_table, .search = nsgtk_search_table, .search_web = nsgtk_search_web_table, .bitmap = nsgtk_bitmap_table, .layout = nsgtk_layout_table, }; ret = netsurf_register(&nsgtk_table); if (ret != NSERROR_OK) { die("NetSurf operation table failed registration\n"); } /* Locate the correct user configuration directory path */ ret = get_config_home(&nsgtk_config_home); if (ret == NSERROR_NOT_FOUND) { /* no config directory exists yet so try to create one */ ret = create_config_home(&nsgtk_config_home); } if (ret != NSERROR_OK) { LOG("Unable to locate a configuration directory."); nsgtk_config_home = NULL; } /* Initialise gtk */ gtk_init(&argc, &argv); /* initialise logging. Not fatal if it fails but not much we * can do about it either. */ nslog_init(nslog_stream_configure, &argc, argv); /* build the common resource path list */ respaths = nsgtk_init_resource_path(nsgtk_config_home); if (respaths == NULL) { fprintf(stderr, "Unable to locate resources\n"); return 1; } /* initialise the gtk resource handling */ ret = nsgtk_init_resources(respaths); if (ret != NSERROR_OK) { fprintf(stderr, "GTK resources failed to initialise (%s)\n", messages_get_errorcode(ret)); return 1; } /* Initialise user options */ ret = nsgtk_option_init(&argc, argv); if (ret != NSERROR_OK) { fprintf(stderr, "Options failed to initialise (%s)\n", messages_get_errorcode(ret)); return 1; } /* Initialise translated messages */ ret = nsgtk_messages_init(respaths); if (ret != NSERROR_OK) { fprintf(stderr, "Unable to load translated messages (%s)\n", messages_get_errorcode(ret)); LOG("Unable to load translated messages"); /** \todo decide if message load faliure should be fatal */ } /* Locate the correct user cache directory path */ ret = get_cache_home(&cache_home); if (ret == NSERROR_NOT_FOUND) { /* no cache directory exists yet so try to create one */ ret = create_cache_home(&cache_home); } if (ret != NSERROR_OK) { LOG("Unable to locate a cache directory."); } /* core initialisation */ ret = netsurf_init(cache_home); free(cache_home); if (ret != NSERROR_OK) { fprintf(stderr, "NetSurf core failed to initialise (%s)\n", messages_get_errorcode(ret)); return 1; } /* run the browser */ ret = nsgtk_init(argc, argv, respaths); if (ret != NSERROR_OK) { fprintf(stderr, "NetSurf gtk initialise failed (%s)\n", messages_get_errorcode(ret)); } else { nsgtk_main(); } /* common finalisation */ netsurf_exit(); /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); return 0; }
/** Normal entry point from OS */ int main(int argc, char** argv) { nserror ret; BPath options; struct netsurf_table beos_table = { &beos_misc_table, beos_window_table, beos_download_table, beos_clipboard_table, &beos_fetch_table, NULL, /* use POSIX file */ NULL, /* default utf8 */ NULL, /* default search */ NULL, /* default web search */ NULL, /* default low level cache persistant storage */ beos_bitmap_table, beos_layout_table }; ret = netsurf_register(&beos_table); if (ret != NSERROR_OK) { die("NetSurf operation table failed registration"); } if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) { options.Append("x-vnd.NetSurf"); } if (!replicated) { // create the Application object before trying to use messages // so we can open an alert in case of error. new NSBrowserApplication; } /* initialise logging. Not fatal if it fails but not much we * can do about it either. */ nslog_init(nslog_stream_configure, &argc, argv); /* user options setup */ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default); if (ret != NSERROR_OK) { die("Options failed to initialise"); } nsoption_read(options.Path(), NULL); nsoption_commandline(&argc, argv, NULL); /* common initialisation */ BResources resources; resources.SetToImage((const void*)main); size_t size = 0; char path[12]; sprintf(path,"%.2s/Messages", getenv("LC_MESSAGES")); fprintf(stderr, "Loading messages from resource %s\n", path); const uint8_t* res = (const uint8_t*)resources.LoadResource('data', path, &size); if (size > 0 && res != NULL) { ret = messages_add_from_inline(res, size); } else { BPath messages = get_messages_path(); ret = messages_add_from_file(messages.Path()); } ret = netsurf_init(NULL); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } gui_init(argc, argv); while (!nsbeos_done) { nsbeos_gui_poll(); } netsurf_exit(); return 0; }
/** * Entry point from OS. * * /param argc The number of arguments in the string vector. * /param argv The argument string vector. * /return The return code to the OS */ int main(int argc, char** argv) { char messages[PATH_MAX]; char store[PATH_MAX]; const char *addr; char * file_url = NULL; struct stat stat_buf; nsurl *url; nserror ret; struct netsurf_table atari_table = { .misc = &atari_misc_table, .window = &atari_window_table, .clipboard = &atari_clipboard_table, .download = atari_download_table, .fetch = &atari_fetch_table, .file = atari_file_table, .utf8 = atari_utf8_table, .search = atari_search_table, .llcache = filesystem_llcache_table, .bitmap = atari_bitmap_table, .layout = atari_layout_table }; ret = netsurf_register(&atari_table); if (ret != NSERROR_OK) { die("NetSurf operation table failed registration"); } /** @todo logging file descriptor update belongs in a nslog_init callback */ setbuf(stderr, NULL); setbuf(stdout, NULL); #ifdef WITH_DBG_LOGFILE freopen("stdout.log", "a+", stdout); freopen("stderr.log", "a+", stderr); #endif graf_mouse(BUSY_BEE, NULL); init_app(NULL); init_os_info(); atari_find_resource((char*)&messages, "messages", "res/messages"); atari_find_resource((char*)&options, "Choices", "Choices"); atari_find_resource((char*)&store, "cache", "res/cache"); /* initialise logging - not fatal if it fails but not much we can * do about it */ nslog_init(NULL, &argc, argv); /* user options setup */ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default); if (ret != NSERROR_OK) { die("Options failed to initialise"); } nsoption_read(options, NULL); nsoption_commandline(&argc, argv, NULL); ret = messages_add_from_file(messages); /* common initialisation */ LOG("Initialising core..."); ret = netsurf_init(store); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } LOG("Initializing GUI..."); gui_init(argc, argv); graf_mouse( ARROW , NULL); LOG("Creating initial browser window..."); addr = option_homepage_url; if (strncmp(addr, "file://", 7) && strncmp(addr, "http://", 7)) { if (stat(addr, &stat_buf) == 0) { file_url = local_file_to_url(addr); addr = file_url; } } /* create an initial browser window */ ret = nsurl_create(addr, &url); if (ret == NSERROR_OK) { ret = browser_window_create(BW_CREATE_HISTORY, url, NULL, NULL, NULL); nsurl_unref(url); } if (ret != NSERROR_OK) { atari_warn_user(messages_get_errorcode(ret), 0); } else { LOG("Entering Atari event mainloop..."); while (!atari_quit) { atari_poll(); } } netsurf_exit(); free(file_url); #ifdef WITH_DBG_LOGFILE fclose(stdout); fclose(stderr); #endif LOG("exit_gem"); exit_gem(); return 0; }