static void test_XtAppMainLoop_34715(void) { XtAppContext app; struct sigaction sa; XtToolkitInitialize(); app = XtCreateApplicationContext(); XtAppAddTimeOut(app, 1000, _Tick, app); /* AppTimeouts should finish and exit in 3 seconds. Give them 10 seconds just in case system is busy, then fail. */ sa.sa_handler = sigalrm; sa.sa_flags = SA_RESTART; sigemptyset (&sa.sa_mask); if (sigsetjmp(jump_env, 1) == 0) { sigaction(SIGALRM, &sa, NULL); alarm(10); XtAppMainLoop(app); } else { g_assert(XtAppGetExitFlag(app) == TRUE); g_assert(0 /* timed out */); } g_assert(XtAppGetExitFlag(app) == TRUE); XtDestroyApplicationContext(app); }
void main( int argc, char **argv ) { Display *display; int result; #ifdef USERHELP malloc_check(1); malloc_trace(0); #endif XtAppContext app; /* Initialize the toolkit and open the display */ XtToolkitInitialize(); app = XtCreateApplicationContext(); display = XtOpenDisplay(app, NULL, argv[0], "Customize", NULL, 0, &argc, argv); /* Go register the DT error handler */ XeProgName = argv[0]; result = InitializeDtcolor(display, DEFAULT_SESSION); if(result != 0) exit(0); XtAppMainLoop(app); }
void Application::initialize(std::string name, int argc, char* argv[]) { String fallbacks[fallbackResources.size() + 1]; XtToolkitInitialize(); context = XtCreateApplicationContext(); for(unsigned int resourceIndex = 0; resourceIndex < fallbackResources.size(); resourceIndex++) { fallbacks[resourceIndex] = (char*)fallbackResources.at(resourceIndex).c_str(); } fallbacks[fallbackResources.size()] = NULL; XtAppSetFallbackResources(context, fallbacks); Application::name = name; display = XtOpenDisplay(context, NULL, name.c_str(), name.c_str(), NULL, 0, &argc, argv); if(display == NULL) { throw MotifException("Failed to open display"); } initialized = true; widget = XtAppCreateShell(Application::getName().c_str(), Application::getName().c_str(), applicationShellWidgetClass, Application::getDisplay(), NULL, 0); }
int main (int argc, char *argv[]) { XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL ); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "XApplication", NULL, 0, &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } create_shell ( display, argv[0], argc, argv ); XtRealizeWidget (shell); /* Note: the following values are the result of * querying the current geometry. */ { static XtWidgetGeometry Expected[] = { CWWidth | CWHeight , 361, 266, 74, 400, 0,0,0, /* form */ CWWidth | CWHeight | CWX | CWY, 0, 0, 74, 260, 0,0,0, /* list1SW */ CWWidth | CWHeight | CWX | CWY, 0, 0, 74, 260, 0,0,0, /* list1 */ CWWidth | CWHeight | CWX | CWY, 0, 260, 74, 140, 0,0,0, /* da */ }; /* toplevel should be replaced with to correct applicationShell */ PrintDetails(shell, Expected); } LessTifTestMainLoop(shell); exit (0); }
void main (int argc, char **argv) { XtAppContext context; Display *display; /* ** Initialize toolkit and open display. */ XtToolkitInitialize (); context = XtCreateApplicationContext(); /* ** Keep the same application name, so I don't have to muck around the ** Xdefaults file */ display = XtOpenDisplay (context, NULL, "phase", "Space", NULL, 0, &argc, argv); if (!display) { XtWarning("Space: Can't open display"); exit(0); } /* ** Create an event display panel */ DisplayEventFileSp(display, exit); /* ** Process events. */ XtAppMainLoop (context); }
void motif_init(QSP_ARG_DECL const char *progname) { const char *argv[1]; int argc=1; argv[0]=progname; the_dname = check_display(SINGLE_QSP_ARG); /* * initialize the Xt toolkit and create an application context * and shell */ XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL ); XtToolkitInitialize (); globalAppContext = XtCreateApplicationContext (); display = XtOpenDisplay (globalAppContext, the_dname, argv[0],"guimenu", NULL, 0, &argc, (char **)argv); if (!display) { fprintf(stderr, "can't open display\n"); return; } add_event_func(QSP_ARG motif_dispatch); // This is not really a motif-specific thing, // but we do this here because nav_panel_itp is // static to this file... if( nav_panel_itp == NO_ITEM_TYPE ){ init_nav_panels(SINGLE_QSP_ARG); add_genwin(QSP_ARG nav_panel_itp, &navp_genwin_funcs, NULL); } }
void serve_client(int socket) { XEvent event; XtToolkitInitialize(); app_context = XtCreateApplicationContext(); LispAction.string = "Lisp"; LispAction.proc = LispActionProc; XtAppAddActions(app_context, &LispAction, 1); string_token_tag = find_type_entry(ExtRStringToken); string_tag = find_type_entry(XtRString); xm_string_tag = find_type_entry(XmRXmString); enum_tag = find_type_entry(XtREnum); int_tag = find_type_entry(XtRInt); window_tag = find_type_entry(XtRWindow); boolean_tag = find_type_entry(XtRBoolean); widget_tag = find_type_entry(XtRWidget); function_tag = find_type_entry(XtRFunction); callback_reason_tag = find_type_entry(ExtRCallbackReason); event_tag = find_type_entry(ExtREvent); resource_list_tag = find_type_entry(ExtRResourceList); translation_table_tag = find_type_entry(XtRTranslationTable); accelerator_table_tag = find_type_entry(XtRAcceleratorTable); atom_tag = find_type_entry(XtRAtom); font_list_tag = find_type_entry(XmRFontList); string_table_tag = find_type_entry(XtRStringTable); xm_string_table_tag = find_type_entry(XmRXmStringTable); int_list_tag = find_type_entry(ExtRIntList); cursor_tag = find_type_entry(XtRCursor); client_socket = socket; greet_client(socket); XtAppAddInput(app_context, socket, (XtPointer)XtInputReadMask, (XtInputCallbackProc)get_input, (XtPointer)NULL); XtAppSetErrorHandler(app_context, MyErrorHandler); XtAppSetWarningHandler(app_context, MyWarningHandler); /* Here is where we want to return on errors */ if( setjmp(env) ) { printf("Attempting to recover from error.\n"); fflush(stdout); } while( !terminate_server ) { XtAppNextEvent(app_context, &event); XtDispatchEvent(&event); } close(socket); XtDestroyApplicationContext(app_context); exit(0); }
/************************************************************** * main: **************************************************************/ int main(int argc, char **argv) { XtAppContext app_context; Display * display; Widget top_level; char * aclass = "XmdDaInput"; char name[132]; char ** temp_argv = argv; (void) strncpy(name, base(argv[0]), 132); /* handle the '-name' option */ while (*temp_argv) { if (strcmp(*temp_argv, "-name") == 0) { (void) strncpy(name, *++temp_argv, 132); break; } temp_argv++; } /* Initialize the X Intrinsics */ XtToolkitInitialize(); /* Set up language environment */ XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); /* create application context */ app_context = XtCreateApplicationContext(); /* open up one display */ display = XtOpenDisplay(app_context, NULL, name, aclass, (XrmOptionDescRec *)NULL, 0, &argc, argv); if (!display) { (void) fprintf(stderr, "Unable to open display\n"); exit(0); } /* Create the user interface */ top_level = DaCreateGui(name, aclass, argc, argv, display); if (top_level == NULL) { (void) fprintf(stderr, "Unable to create user interface\n"); exit(1); } /* Realize and start event dispatching */ XtRealizeWidget(top_level); XtAppMainLoop(app_context); return 0; /* make compiler happy */ }
void imagesc(void *data, int x, int y, const char* type, double (*transf)(double), const char **colormap, char *title) { static XtAppContext context; Widget drawing_area; Widget toplevel; Atom wm_delete; XEvent event; XpmImage *xpmImage; Boolean exitFlag = False; static Display *display = NULL; Arg al[10]; int ac; int argc = 0; xpmImage = CreateXpmImage(data, x, y, type, transf, colormap); /* create the toplevel shell */ XtToolkitInitialize(); if (display == NULL) { context = XtCreateApplicationContext(); display = XtOpenDisplay(context, NULL, NULL, "", NULL, 0, &argc, NULL); } toplevel =XtAppCreateShell(title, "", applicationShellWidgetClass, display, NULL, 0); /* set window size. */ ac=0; XtSetArg(al[ac],XmNmaxWidth, x); ac++; XtSetArg(al[ac],XmNmaxHeight, y); ac++; XtSetArg(al[ac],XmNminWidth, x); ac++; XtSetArg(al[ac],XmNminHeight, y); ac++; XtSetArg(al[ac],XmNdeleteResponse, XmDO_NOTHING); ac++; XtSetValues(toplevel,al,ac); ac=0; drawing_area=XmCreateDrawingArea(toplevel,"drawing_area",al,ac); XtManageChild(drawing_area); XtAddCallback(drawing_area,XmNexposeCallback,draw_pixmap,(XtPointer) xpmImage); XtAddEventHandler(drawing_area, KeyReleaseMask, false, KeyAction, (XtPointer) &exitFlag); XtRealizeWidget(toplevel); wm_delete = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False); XmAddWMProtocolCallback(toplevel, wm_delete, quitCB, (XtPointer) &exitFlag); XmActivateWMProtocol(toplevel, wm_delete); while (!exitFlag) { XtAppNextEvent(context, &event); XtDispatchEvent(&event); } XtDestroyWidget(drawing_area); XtDestroyWidget(toplevel); free(xpmImage); }
static void XInit(int *argc, char ***argv) { XtToolkitInitialize(); xi.context = XtCreateApplicationContext(); XtAppSetFallbackResources(xi.context, fallback_resources); xi.disp = XtOpenDisplay(xi.context, NULL, "NMovie", "NMovie", NULL, 0, argc, *argv); if (!xi.disp) ErrorExit(ERROR_BAD_PARM,"Unable to open display"); shmext = XShmQueryExtension(xi.disp); xi.screenno = DefaultScreen(xi.disp); }
int Tclxttest_Init( Tcl_Interp *interp) /* Interpreter for application. */ { if (Tcl_InitStubs(interp, "8.1", 0) == NULL) { return TCL_ERROR; } XtToolkitInitialize(); InitNotifier(); Tcl_CreateCommand(interp, "testeventloop", TesteventloopCmd, NULL, NULL); return TCL_OK; }
XtEvents::XtEvents() { XtToolkitInitialize(); context = XtCreateApplicationContext(); int argc = qApp->argc(); XtDisplayInitialize( context, QX11Info::display(), qAppName().toLatin1(), QX11Info::appClass(), NULL, 0, &argc, qApp->argv()); connect( &timer, SIGNAL(timeout()), SLOT(idleProcess())); kapp->installX11EventFilter( this ); // No way to find out when to process Xt events, so poll :( // ... but only after enable() has been called self = this; }
int main(int argc, char *argv[]) { KCmdLineArgs::init(argc, argv, appName, I18N_NOOP("KXSConfig"), description, version); KCmdLineArgs::addCmdLineOptions(options); KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if(args->count()==0) exit(1); /* We must read exactly the same resources as xscreensaver. That means we must have both the same progclass *and* progname, at least as far as the resource database is concerned. So, put "xscreensaver" in argv[0] while initializing Xt. */ const char *dummyargs[] = { "xscreensaver" }; int dummyargc = 1; progname = dummyargs[0]; // Teach Xt to use the Display that TQt has already opened. XtToolkitInitialize (); XtAppContext xtApp = XtCreateApplicationContext (); Display *dpy = qt_xdisplay(); XtAppSetFallbackResources (xtApp, const_cast<char**>(defaults)); XtDisplayInitialize (xtApp, dpy, progname, progclass, 0, 0, &dummyargc, const_cast<char**>(dummyargs)); Widget toplevel_shell = XtAppCreateShell (progname, progclass, applicationShellWidgetClass, dpy, 0, 0); dpy = XtDisplay (toplevel_shell); db = XtDatabase (dpy); XtGetApplicationNameAndClass (dpy, const_cast<char**>(&progname), const_cast<char**>(&progclass)); TQString name = TQString::fromLocal8Bit(args->arg(args->count() - 1)); KXSConfigDialog *dialog=new KXSConfigDialog(args->arg(0), name); if ( dialog->create() ) { dialog->show(); app.setMainWidget(dialog); app.exec(); } else { KMessageBox::sorry(0, i18n("No configuration available for %1").tqarg(name), name ); } delete dialog; }
int main (int argc, char **argv) { Widget app_shell; /* Add Xt support for i18n: locale */ XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "ArborSplash", NULL, 0, &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } /* * Create a dummy application shell, and then hide it again so that the * splash screen can be a top-level screen for all applications. */ app_shell = XtAppCreateShell(".splash", "ArborSplash", applicationShellWidgetClass, display, NULL, 0); create_splash_shell(app_shell); XtUnmanageChild(splash_form); /* * Unmanage the OK button -- the window will pop itself down after * 5 seconds. */ XtUnmanageChild(splash_ok_btn); show_window(splash_shell, splash_form); XtAddEventHandler(splash_shell, VisibilityChangeMask, False, popup_splash, NULL); XtAppAddTimeOut(app_context, 5000, exit_splash, NULL); XtAppMainLoop(app_context); return(0); }
/*! Constructs a QApplication and initializes the Xt toolkit. The \a appclass, \a options, \a num_options, and \a resources arguments are passed on to XtAppSetFallbackResources and XtDisplayInitialize. Use this constructor when writing a new Qt application which needs to use some existing Xt/Motif widgets. */ KXtApplication::KXtApplication(int& argc, char** argv, const QCString& rAppName, bool allowStyles, bool GUIenabled, XrmOptionDescRec *options, int num_options, char** resources) : KApplication(argc, argv, rAppName, allowStyles, GUIenabled) { my_xt = TRUE; XtToolkitInitialize(); appcon = XtCreateApplicationContext(); if (resources) XtAppSetFallbackResources(appcon, (char**)resources); XtDisplayInitialize(appcon, qt_xdisplay(), name(), rAppName, options, num_options, &argc, argv); init(); }
int main( int argc, /* Number of command-line arguments. */ char **argv) /* Values of command-line arguments. */ { #ifdef TCL_XT_TEST XtToolkitInitialize(); #endif #ifdef TCL_LOCAL_MAIN_HOOK TCL_LOCAL_MAIN_HOOK(&argc, &argv); #endif Tcl_Main(argc, argv, TCL_LOCAL_APPINIT); return 0; /* Needed only to prevent compiler warning. */ }
QXtEventLoop::QXtEventLoop( const char *applicationClass, XtAppContext context, XrmOptionDescRec *options , int numOptions) { #if defined(QT_CHECK_STATE) if ( static_d ) tqWarning( "QXtEventLoop: should only have one QXtEventLoop instance!" ); #endif d = static_d = new QXtEventLoopPrivate; XtToolkitInitialize(); if ( context ) d->appContext = context; else d->ownContext = d->appContext = XtCreateApplicationContext(); d->applicationClass = applicationClass; d->options = options; d->numOptions = numOptions; }
void OnLibraryLoad() { // Tell X Threads are OK. XInitThreads(); #ifdef XT XtToolkitInitialize(); app_context = XtCreateApplicationContext(); #endif // Open local display. disp = XOpenDisplay(XDisplayName(NULL)); #ifdef DEBUG if (disp != NULL) { fprintf(stdout, "OnLibraryLoad(): XOpenDisplay successful.\n"); } else { fprintf(stderr, "OnLibraryLoad(): XOpenDisplay failure!\n"); } #endif Bool isAutoRepeat = False; #ifdef XKB // Enable detectable autorepeat. XkbSetDetectableAutoRepeat(disp, True, &isAutoRepeat); #else XAutoRepeatOn(disp); XKeyboardState kb_state; XGetKeyboardControl(disp, &kb_state); isAutoRepeat = (kb_state.global_auto_repeat == AutoRepeatModeOn); #endif #ifdef DEBUG if (isAutoRepeat) { fprintf(stdout, "OnLibraryLoad(): Successfully enabled detectable autorepeat.\n"); } else { fprintf(stderr, "OnLibraryLoad(): Could not enable detectable auto-repeat!\n"); } #endif }
EIF_POINTER xt_init () { /* Initialize Xt toolkit and application context * add action c_callback_on_trans to the list of * application actions, it will be called by any * new translations or accelerators. * Prepare the Xt toolkit and create a global * application context. */ XtAppContext gAppContext; static XtActionsRec actionTable [] = { {c_trans_routine, handle_translation}, }; XtToolkitInitialize (); gAppContext = XtCreateApplicationContext (); XtAppAddActions (gAppContext, actionTable, XtNumber (actionTable)); return (EIF_POINTER) gAppContext; }
int main (int argc, char **argv) { XtAppContext app_context; Display *display; /* Display */ XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL ); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "XApplication", NULL, 0, &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } create_shell ( display, argv[0], argc, argv ); exit (0); }
/* Initial Xt plugin */ static void xt_client_init( XtClient * xtclient, Visual *xtvisual, Colormap xtcolormap, int xtdepth) { XtAppContext app_context; char *mArgv[1]; int mArgc = 0; /* * Initialize Xt stuff */ xtclient->top_widget = NULL; xtclient->child_widget = NULL; xtclient->xtdisplay = NULL; xtclient->xtvisual = NULL; xtclient->xtcolormap = 0; xtclient->xtdepth = 0; if (!xt_is_initialized) { #ifdef DEBUG_XTBIN printf("starting up Xt stuff\n"); #endif XtToolkitInitialize(); app_context = XtCreateApplicationContext(); if (fallback) XtAppSetFallbackResources(app_context, fallback); xtdisplay = XtOpenDisplay(app_context, gdk_get_display(), NULL, "Wrapper", NULL, 0, &mArgc, mArgv); if (xtdisplay) xt_is_initialized = TRUE; } xtclient->xtdisplay = xtdisplay; xtclient->xtvisual = xtvisual; xtclient->xtcolormap = xtcolormap; xtclient->xtdepth = xtdepth; }
int main( int argc, /* Number of command-line arguments. */ char **argv) /* Values of command-line arguments. */ { /* * The following #if block allows you to change the AppInit function by * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire * file. The #if checks for that #define and uses Tcl_AppInit if it does * not exist. */ #ifndef TCL_LOCAL_APPINIT #define TCL_LOCAL_APPINIT Tcl_AppInit #endif extern int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp)); /* * The following #if block allows you to change how Tcl finds the startup * script, prime the library or encoding paths, fiddle with the argv, * etc., without needing to rewrite Tcl_Main() */ #ifdef TCL_LOCAL_MAIN_HOOK extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); #endif #ifdef TCL_XT_TEST XtToolkitInitialize(); #endif #ifdef TCL_LOCAL_MAIN_HOOK TCL_LOCAL_MAIN_HOOK(&argc, &argv); #endif Tcl_Main(argc, argv, TCL_LOCAL_APPINIT); return 0; /* Needed only to prevent compiler warning. */ }
void * pceXtAppContext(void * ctx) { if ( ThePceXtAppContext == NULL ) { if ( ctx != NULL ) { ThePceXtAppContext = ctx; XSetErrorHandler(x_error_handler); } else { #if defined(_REENTRANT) && defined(HAVE_XINITTHREADS) if ( XPCE_mt == TRUE ) { if ( use_x_init_threads ) XInitThreads(); } else { XPCE_mt = -1; } #else XPCE_mt = -1; #endif XtToolkitInitialize(); XSetErrorHandler(x_error_handler); if ( (ThePceXtAppContext = XtCreateApplicationContext()) == NULL ) { errorPce(TheDisplayManager(), NAME_noApplicationContext); fail; } if ( !XtSetLanguageProc(ThePceXtAppContext, NULL, NULL) ) { errorPce(TheDisplayManager(), NAME_noLocaleSupport, CtoName(setlocale(LC_ALL, NULL))); fail; } } } return ThePceXtAppContext; }
/************************************************************** * main: **************************************************************/ int main(int argc, char **argv) { Display * display; char name[132]; (void) strncpy(name, base(argv[0]), 132); /* Initialize the X Intrinsics */ XtToolkitInitialize(); /* Set up language environment for X */ XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); /* Create application context */ app_context = XtCreateApplicationContext(); XtAppSetFallbackResources(app_context, fallback_reslist); /* open up one display */ display = XtOpenDisplay(app_context, NULL, name, "XmdI18nInput", (XrmOptionDescRec *)NULL, 0, &argc, argv); if (!display) { (void) fprintf(stderr, "Unable to open display\n"); exit(0); } /* Call init functions. This creates the user interface (placed in input.c) */ if (dialog_init(&argc, argv, display) != 0) exit(1); XtAppMainLoop(app_context); return 0; /* make compiler happy */ }
static void common_main() { #ifndef NO_MESSAGE_CATALOG if (uil_catd == NULL) uil_catd = catopen("Uil", NL_CAT_LOCALE); #endif /* Initialize the X toolkit. */ XtToolkitInitialize(); /* use the user supplied data base instead */ if (Uil_cmd_z_command.v_database) db_incorporate(); /* initialize the diagnostic system */ diag_initialize_diagnostics(); /* initialize the symbol table */ sym_initialize_storage(); /* initialize the source */ src_initialize_source(); /* open listing file if requested */ if (Uil_cmd_z_command.v_listing_file) lst_open_listing(); /* initialize the lexical analyzer */ lex_initialize_analyzer(); /* initialize the keyword table */ key_initialize(); /* initialize the sar data structures */ sar_initialize(); /* call YACC to parse the source file */ /* return 0 for success, 1 for failure */ /* Make sure the root entry sections pointer is filled in */ if (yyparse() != 0) diag_issue_diagnostic (d_inv_module, diag_k_no_source, diag_k_no_column); sym_az_root_entry->sections = sym_az_current_section_entry; /* call forward reference resolver */ sem_resolve_forward_refs(); /* call semantic validation */ sem_validation (); /* call the output phase if requested */ if (Uil_cmd_z_command.v_resource_file) sem_output_uid_file(); /* call symbol table dumper - if requested */ #if debug_version if (uil_v_dump_symbols == TRUE) sym_dump_symbols(); #endif /* write compilation summary */ diag_issue_summary(); /* write listing file if requested */ if (Uil_cmd_z_command.v_listing_file) lst_output_listing(); /* Storage is not cleaned up, since we will exit */ uil_exit( uil_l_compile_status ); }
int main(int argc, char **argv) { // nspluginviewer is a helper app, it shouldn't do session management at all setenv("SESSION_MANAGER", "", 1); // trap X errors kdDebug(1430) << "1 - XSetErrorHandler" << endl; XSetErrorHandler(x_errhandler); setvbuf(stderr, NULL, _IONBF, 0); kdDebug(1430) << "2 - parseCommandLine" << endl; parseCommandLine(argc, argv); #if QT_VERSION < 0x030100 // Create application kdDebug(1430) << "3 - XtToolkitInitialize" << endl; XtToolkitInitialize(); g_appcon = XtCreateApplicationContext(); Display *dpy = XtOpenDisplay(g_appcon, NULL, "nspluginviewer", "nspluginviewer", 0, 0, &argc, argv); _notifiers[0].setAutoDelete(TRUE); _notifiers[1].setAutoDelete(TRUE); _notifiers[2].setAutoDelete(TRUE); kdDebug(1430) << "4 - KXtApplication app" << endl; KLocale::setMainCatalogue("nsplugin"); KXtApplication app(dpy, argc, argv, "nspluginviewer"); #else kdDebug(1430) << "3 - create QXtEventLoop" << endl; QXtEventLoop integrator("nspluginviewer"); parseCommandLine(argc, argv); KLocale::setMainCatalogue("nsplugin"); kdDebug(1430) << "4 - create KApplication" << endl; KApplication app(argc, argv, "nspluginviewer"); GlibEvents glibevents; #endif { KConfig cfg("kcmnspluginrc", true); cfg.setGroup("Misc"); int v = KCLAMP(cfg.readNumEntry("Nice Level", 0), 0, 19); if(v > 0) { nice(v); } v = cfg.readNumEntry("Max Memory", 0); if(v > 0) { rlimit rl; memset(&rl, 0, sizeof(rl)); if(0 == getrlimit(RLIMIT_AS, &rl)) { rl.rlim_cur = kMin(v, int(rl.rlim_max)); setrlimit(RLIMIT_AS, &rl); } } } // initialize the dcop client kdDebug(1430) << "5 - app.dcopClient" << endl; DCOPClient *dcop = app.dcopClient(); if(!dcop->attach()) { KMessageBox::error(NULL, i18n("There was an error connecting to the Desktop " "communications server. Please make sure that " "the 'dcopserver' process has been started, and " "then try again."), i18n("Error Connecting to DCOP Server")); exit(1); } kdDebug(1430) << "6 - dcop->registerAs" << endl; if(g_dcopId) g_dcopId = dcop->registerAs(g_dcopId, false); else g_dcopId = dcop->registerAs("nspluginviewer"); dcop->setNotifications(true); // create dcop interface kdDebug(1430) << "7 - new NSPluginViewer" << endl; NSPluginViewer *viewer = new NSPluginViewer("viewer", 0); // start main loop #if QT_VERSION < 0x030100 kdDebug(1430) << "8 - XtAppProcessEvent" << endl; while(!g_quit) XtAppProcessEvent(g_appcon, XtIMAll); #else kdDebug(1430) << "8 - app.exec()" << endl; app.exec(); #endif // delete viewer delete viewer; }
int main(int argc, char **argv) { FEM_ObjectBrokerAllClasses theBroker; MPI_MachineBroker theMachine(&theBroker, argc, argv); theMachineBroker = &theMachine; OPS_MACHINE = &theMachine; rank = theMachine.getPID(); np = theMachine.getNP(); if (rank == 0) { OPS_theChannels = new Channel *[np-1]; theChannels = OPS_theChannels; numChannels = np-1; } else { OPS_theChannels = new Channel *[1]; theChannels = OPS_theChannels; numChannels = 1; } // // if rank 0 we send all args // int numArg = 0; int sizeArg = 0; char **args = 0; char *dataArgs = 0; if (rank == 0) { for (int i=0; i<argc; i++) if (argv[i] == NULL) { i = argc+1; } else { numArg ++; sizeArg += strlen(argv[i])+1; } static ID data(2); data(0) = numArg; data(1) = sizeArg; dataArgs = new char[sizeArg]; int loc = 0; for (int i=0; i<numArg; i++) { int lengthArg = strlen(argv[i]); strncpy(&dataArgs[loc], argv[i],lengthArg+1); loc+=lengthArg+1; } Message msgChar(dataArgs, sizeArg); for (int j=0; j<np-1; j++) { Channel *otherChannel = theMachine.getRemoteProcess(); OPS_theChannels[j] = otherChannel; otherChannel->sendID(0,0,data); otherChannel->sendMsg(0,0,msgChar); } } else { static ID data(2); Channel *myChannel = theMachine.getMyChannel(); OPS_theChannels[0] = myChannel; myChannel->recvID(0,0,data); numArg = data(0); sizeArg = data(1); dataArgs = new char[sizeArg]; Message msgChar(dataArgs, sizeArg); myChannel->recvMsg(0,0,msgChar); } args = new char *[numArg]; args[0] = dataArgs; int argCount = 1; for (int j=1; j<sizeArg-1; j++) if (dataArgs[j] == '\0') { args[argCount] = &dataArgs[j+1]; argCount++; } OpenSeesParseArgv(argc, argv); #ifndef TCL_LOCAL_APPINIT #define TCL_LOCAL_APPINIT Tcl_AppInit #endif #ifdef TCL_LOCAL_MAIN_HOOK extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); #endif #ifdef TCL_XT_TEST XtToolkitInitialize(); #endif #ifdef TCL_LOCAL_MAIN_HOOK TCL_LOCAL_MAIN_HOOK(&argc, &argv); #endif g3TclMain(numArg, args, TCL_LOCAL_APPINIT, rank, np); // some clean up to shut the remotes down if still running // theDomain.clearAll(); // shutdown the remote machines // theMachine.shutdown(); // // mpi clean up // fprintf(stderr, "Process Terminating %d\n", rank); return 0; }
int main (unsigned int argc, char **argv) { FILE *fp; /* check for existance of ARBOR_GUI_LANGUAGE, exit if absent */ if (getenv("ARBOR_GUI_LANGUAGE") == NULL) { printf("Environment variable ARBOR_GUI_LANGUAGE not set. Exiting...\n"); exit(1) ; } /* Add Xt support for i18n: locale */ XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "SysAdmin", NULL, 0, (int *) &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } if ( argc == 2) { fp = fopen(argv[1],"r"); if ( fp == (FILE *) NULL) { printf ("\007Unable to open password file \"%s\".\n", argv[1]); exit(-1); } if (fgets(gsSybase_User,80,fp) != NULL) gsSybase_User[strlen(gsSybase_User)-1] = 0; else { printf("\007\nERROR -- Unable to read password file; exiting.") ; exit(1) ; } if (fgets(gsSybase_Pass,80,fp) != NULL) gsSybase_Pass[strlen(gsSybase_Pass)-1] = 0; else { printf("\007\nERROR -- Unable to read password file; exiting.") ; exit(1) ; } fclose(fp); if ( unlink(argv[1]) ) { printf("\007WARNING -- Unable to remove password file.\n"); } gintAutoLogin = 1; } /* Register converters, just in case you are really unlucky !! */ XmRegisterConverters(); /* String to unit type doesn't get added !! */ XtAddConverter ( XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0 ); strcpy(gstrProcessname, "SysAdmin"); gLoginMethod1 = GUI_DSQUERY_ONLY; create_gCIloginwindow ( display, "SysAdmin", argc, argv ); XtRealizeWidget (gCIloginwindow); XmProcessTraversal(gCIpassword,XmTRAVERSE_CURRENT); if ( gintAutoLogin ) { XWithdrawWindow(display, XtWindow(gCIloginwindow), 0); XmTextSetString(gCIusername,gsSybase_User); CI_sybase_login_cb(okloginbtn, NULL, NULL); } XtAppMainLoop (app_context); return(0); }
int main (unsigned int argc, char **argv) { process_arguments(argc, argv); /* g_module, db_name side-effected */ #ifdef _DBG_PRINT dbrecftos("/tmp/msg"); #endif dbproc = mydblogin(); if (dbproc == NULL) { fprintf(stderr, "Unable to log into DB. Exiting.\n"); exit(1); } initialize_message_system("UTL", dbproc); /* a lie, but... */ if(em_initialize_severity_codes(dbproc) == FAILURE) { fprintf(stderr,"Severity codes initialization failed. Exiting.\n"); exit(1); } if((nmodule_names = initialize_module_names(dbproc, &module_names)) < 0) { fprintf(stderr,"Module names initialization failed. Exiting.\n"); exit(1); } if (!g_module[0]) /* No module given. Select "All". */ strcpy(g_module, ALL); else { /* module name not specified */ /* * Check if module name given is legal. * If not, issue a message and exit. */ int i; for (i = 0; i < nmodule_names; i++) if (!strcmp(g_module, module_names[i])) break; if (i == nmodule_names) { /* module not found */ fprintf(stderr, "Unknown module name '%s.' Allowed modules are:\n\t", g_module); for (i = 0; i < nmodule_names; i++) if (strcmp(module_names[i], ALL)) fprintf(stderr, " %s ", module_names[i]); fputc('\n', stderr); exit(1); } } XtToolkitInitialize (); app_context = XtCreateApplicationContext(); display = XtOpenDisplay(app_context, NULL, argv[0], "EditMessage", NULL, 0, &argc, argv); if (!display) { fprintf(stderr, "%s: can't open display, exiting...\n", argv[0]); exit (1); } XmRegisterConverters(); XtAddConverter (XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0); create_appShell ( display, argv[0], argc, argv ); /* Cache the chosen module, for callbacks. We could just use the set_module() callback, but that swaps labels etc. and we're cheap. */ initialize_default_module(g_module); XtRealizeWidget(appShell); XtAppMainLoop(app_context); exit(0); /* never get here */ }
int main(int argc, char **argv) { FEM_ObjectBrokerAllClasses theBroker; // MPI_MachineBroker theMachine(&theBroker, argc, argv); // theMachineBroker = &theMachine; theMachineBroker = new MPI_MachineBroker(&theBroker, argc, argv); OPS_rank = theMachineBroker->getPID(); OPS_np = theMachineBroker->getNP(); // // depending on rank we do something // if (OPS_rank != 0) { // // on slave processes we spin waiting to create & run actors // fprintf(stderr, "Slave Process Running %d\n", OPS_rank); theMachineBroker->runActors(); } else { // // on process 0 we create some ShadowSubdomains & then start the OpenSees interpreter // fprintf(stderr, "Master Process Running OpenSees Interpreter %d\n", OPS_rank); // // set some global parameters // OPS_OBJECT_BROKER = &theBroker; // OPS_MACHINE = &theMachine; OPS_MACHINE = theMachineBroker; OPS_PARALLEL_PROCESSING = OPS_np; /* only use p0 if even number of partitions if (OPS_np%2 == 0) { OPS_NUM_SUBDOMAINS = OPS_np; OPS_USING_MAIN_DOMAIN = true; OPS_MAIN_DOMAIN_PARTITION_ID = 1; } else OPS_NUM_SUBDOMAINS = OPS_np - 1; */ // always use p0 even if ODD number of partitions OPS_NUM_SUBDOMAINS = OPS_np; OPS_USING_MAIN_DOMAIN = true; OPS_MAIN_DOMAIN_PARTITION_ID = 1; OPS_PARTITIONED = false; // // the rest straightr out of regular tclMain to start our interpreter // /* * The following #if block allows you to change the AppInit * function by using a #define of TCL_LOCAL_APPINIT instead * of rewriting this entire file. The #if checks for that * #define and uses Tcl_AppInit if it doesn't exist. */ #ifndef TCL_LOCAL_APPINIT #define TCL_LOCAL_APPINIT Tcl_AppInit #endif /* fmk - comment out the following block to get to compile extern "C" int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp)); fmk - end commented block */ /* * The following #if block allows you to change how Tcl finds the startup * script, prime the library or encoding paths, fiddle with the argv, * etc., without needing to rewrite Tcl_Main() */ #ifdef TCL_LOCAL_MAIN_HOOK extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); #endif #ifdef TCL_XT_TEST XtToolkitInitialize(); #endif #ifdef TCL_LOCAL_MAIN_HOOK TCL_LOCAL_MAIN_HOOK(&argc, &argv); #endif g3TclMain(argc, argv, TCL_LOCAL_APPINIT, 1, 0); // some clean up to shut the remotes down if still running theDomain.clearAll(); // shutdown the remote machines theMachineBroker->shutdown(); } // // mpi clean up // fprintf(stderr, "Process Terminating %d\n", OPS_rank); if (theMachineBroker != 0) delete theMachineBroker; return 0; }