void Interactor::Config(World* w) { if (parent != nil) { parent->Remove(this); parent = nil; } world = w; Resource::unref(output); output = nil; DoConfig(false); }
void Interactor::Config(Scene* s) { if (parent != s) { if (parent != nil) { parent->Remove(this); } parent = s; /* cast to workaround DEC C++ compiler bug */ world = ((Interactor*)s)->world; DoConfig(false); } }
static void HandleHUP(int sig) { char fn[] = "HandleHUP"; NETDEBUG(MEXECD, NETLOG_DEBUG2, ("%s: Signal SIGHUP caught - Reconfiguring\n", fn)); NetLogClose(); DoConfig(ConfigureExecD); // exit(0); return; }
BOOL CSaverApp::InitInstance() { // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. Enable3dControls(); SetRegistryKey(_T("Complex\\ProbableWorlds")); if (__argc == 1 || MatchOption(__argv[1], _T("c"))) DoConfig(); else if (MatchOption(__argv[1], _T("p"))) { /* // sorry no preview!!! CWnd* pParent = CWnd::FromHandle((HWND)atol(__argv[2])); ASSERT(pParent != NULL); CDrawWnd* pWnd = new CDrawWnd(); CRect rect; pParent->GetClientRect(&rect); pWnd->Create(NULL, WS_VISIBLE|WS_CHILD, rect, pParent, NULL); m_pMainWnd = pWnd; return TRUE; */ return FALSE; } else if (MatchOption(__argv[1], _T("s"))) { CSaverWnd* pWnd = new CSaverWnd; pWnd->Create(); m_pMainWnd = pWnd; return TRUE; } /* CSaverWnd* pWnd = new CSaverWnd; pWnd->Create(); m_pMainWnd = pWnd; return TRUE; */ return FALSE; }
void ConfigSet( void ) { DoConfig( GetCmdName( CMD_SET ), SetNameTab, SetConfJmpTab, SetNotAllTab ); }
static void config(HWND hwndParent) { if (DoConfig(mod_.hDllInstance, hwndParent)) WriteConfig(); }
int Tk_ConfigureWidget( Tcl_Interp *interp, /* Interpreter for error reporting. */ Tk_Window tkwin, /* Window containing widget (needed to set up * X resources). */ Tk_ConfigSpec *specs, /* Describes legal options. */ int argc, /* Number of elements in argv. */ CONST char **argv, /* Command-line options. */ char *widgRec, /* Record whose fields are to be modified. * Values must be properly initialized. */ int flags) /* Used to specify additional flags that must * be present in config specs for them to be * considered. Also, may have * TK_CONFIG_ARGV_ONLY set. */ { register Tk_ConfigSpec *specPtr; Tk_Uid value; /* Value of option from database. */ int needFlags; /* Specs must contain this set of flags or * else they are not considered. */ int hateFlags; /* If a spec contains any bits here, it's not * considered. */ if (tkwin == NULL) { /* * Either we're not really in Tk, or the main window was destroyed and * we're on our way out of the application */ Tcl_AppendResult(interp, "NULL main window", NULL); return TCL_ERROR; } needFlags = flags & ~(TK_CONFIG_USER_BIT - 1); if (Tk_Depth(tkwin) <= 1) { hateFlags = TK_CONFIG_COLOR_ONLY; } else { hateFlags = TK_CONFIG_MONO_ONLY; } /* * Get the build of the config for this interpreter. */ specs = GetCachedSpecs(interp, specs); /* * Pass one: scan through all of the arguments, processing those that * match entries in the specs. */ for ( ; argc > 0; argc -= 2, argv += 2) { CONST char *arg; if (flags & TK_CONFIG_OBJS) { arg = Tcl_GetStringFromObj((Tcl_Obj *) *argv, NULL); } else { arg = *argv; } specPtr = FindConfigSpec(interp, specs, arg, needFlags, hateFlags); if (specPtr == NULL) { return TCL_ERROR; } /* * Process the entry. */ if (argc < 2) { Tcl_AppendResult(interp, "value for \"", arg, "\" missing", NULL); return TCL_ERROR; } if (flags & TK_CONFIG_OBJS) { arg = Tcl_GetString((Tcl_Obj *) argv[1]); } else { arg = argv[1]; } if (DoConfig(interp, tkwin, specPtr, arg, 0, widgRec) != TCL_OK) { char msg[100]; sprintf(msg, "\n (processing \"%.40s\" option)", specPtr->argvName); Tcl_AddErrorInfo(interp, msg); return TCL_ERROR; } if (!(flags & TK_CONFIG_ARGV_ONLY)) { specPtr->specFlags |= TK_CONFIG_OPTION_SPECIFIED; } } /* * Pass two: scan through all of the specs again; if no command-line * argument matched a spec, then check for info in the option database. * If there was nothing in the database, then use the default. */ if (!(flags & TK_CONFIG_ARGV_ONLY)) { for (specPtr=specs; specPtr->type!=TK_CONFIG_END; specPtr++) { if ((specPtr->specFlags & TK_CONFIG_OPTION_SPECIFIED) || (specPtr->argvName == NULL) || (specPtr->type == TK_CONFIG_SYNONYM)) { specPtr->specFlags &= ~TK_CONFIG_OPTION_SPECIFIED; continue; } if (((specPtr->specFlags & needFlags) != needFlags) || (specPtr->specFlags & hateFlags)) { continue; } value = NULL; if (specPtr->dbName != NULL) { value = Tk_GetOption(tkwin, specPtr->dbName, specPtr->dbClass); } if (value != NULL) { if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) != TCL_OK) { char msg[200]; sprintf(msg, "\n (%s \"%.50s\" in widget \"%.50s\")", "database entry for", specPtr->dbName, Tk_PathName(tkwin)); Tcl_AddErrorInfo(interp, msg); return TCL_ERROR; } } else { if (specPtr->defValue != NULL) { value = Tk_GetUid(specPtr->defValue); } else { value = NULL; } if ((value != NULL) && !(specPtr->specFlags & TK_CONFIG_DONT_SET_DEFAULT)) { if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) != TCL_OK) { char msg[200]; sprintf(msg, "\n (%s \"%.50s\" in widget \"%.50s\")", "default value for", specPtr->dbName, Tk_PathName(tkwin)); Tcl_AddErrorInfo(interp, msg); return TCL_ERROR; } } } } } return TCL_OK; }
int main(int argc, char *argv[], char *envp[]) { int i, poolid, classid; ssize_t len; key_t key; char *msg; // Parse the options and configure appropriate values. parse_opt(argc, argv); // Read the configuration setConfigFile(); myConfigServerType = CONFIG_SERPLEX_EXECD; DoConfig(ConfigureExecD); // Daemonize if (execd_daemonize) { daemonize(); (void) freopen( "/dev/null", "r", stdin ); (void) freopen( "/var/log/iserverout.log", "a", stdout ); (void) freopen( "/var/log/iservererr.log", "a", stderr ); for (i = 3; i < MAXFD; i++) { close(i); } } // Start the signal handler thread. SignalInit(); NetSyslogOpen(pname, NETLOG_ASYNC); sprintf(pidf, "%s/%s", PIDS_DIRECTORY, EXECD_PID_FILE); execdpid = ReadPid(pidf); if ( execdpid > 0 ) { if ((kill(execdpid, 0) == 0) || (errno != ESRCH)) { NETERROR(MRSD, ("%s seems to be running already - exiting\n", basename(argv[0]))); exit(0); } else /* Get rid of the leftover file */ UnlinkPid(pidf); } StorePid(pidf); NETINFOMSG(MEXECD, ("*** NexTone Cmd Execution Server started ***\n")); // Start the thread which sends message to pm Initpoll(EXECD_ID, SERPLEX_GID); Sendpoll(0); ThreadLaunch((PFVP)SendPMPoll, NULL, 1); // Get the msg_q id. If it does not exist then create it if ((key = ftok(ISERVER_FTOK_PATH, ISERVER_EXECD_Q)) < 0) { NETERROR(MEXECD, ("ftok: %s\n", strerror(errno))); exit(0); } if (q_vget(key, 0, MAX_NUM_MSG, MAX_MSGLEN, &msgqid) < 0) { NETERROR(MEXECD, ("q_vget: %s\n", strerror(errno))); exit(0); } #ifdef USE_SYS_POPEN sys_utils_init(); #endif // Start a threadpool of worker threads poolid = ThreadPoolInit("execcmd", nthreads, PTHREAD_SCOPE_PROCESS, -1, 0); classid = ThreadAddPoolClass("execcmd", poolid, 0, 0); ThreadPoolStart(poolid); // msgqid has to be valid if we reached here for( ; ; ) { if (!(msg = malloc(MAX_MSGLEN))) { NETERROR(MEXECD, ("malloc: %s\n", strerror(errno))); sleep(5); // sleep and try again continue; } if (q_vreceive(msgqid, msg, MAX_MSGLEN, SRVR_MSG_TYP, 0, &len) < 0) { NETERROR(MEXECD, ("q_vreceive: %s\n", strerror(errno))); // Check error types if (errno == EIDRM) { printf("execd: stop messing with my message queue\n"); // somebody deleted the queue if (q_vget(key, 0, MAX_NUM_MSG, MAX_MSGLEN, &msgqid) < 0) { NETERROR(MEXECD, ("q_vget: %s\n", strerror(errno))); exit(0); } } free(msg); continue; } if (ThreadDispatch(poolid, classid, (PFVP)CmdWorker, msg, 1, PTHREAD_SCOPE_PROCESS, SCHED_FIFO, 59) < 0) { NETERROR(MRSD, ("ThreadDispatch: No free thread\n")); // Send response in a new thread ThreadLaunch((PFVP)SendFailMsg, msg, 1); } } }