/*--------------------------------------------------------------------------*/ PegMenuButton::PegMenuButton(PegMenuDescription *pDesc) : PegThing(pDesc->wId, pDesc->wStyle), PegTextThing(pDesc->wStyle, PEG_MENU_FONT) { mReal.Set(0, 0, 100, 18); mClient.Set(0, 0, 100, 18); Type(TYPE_MENU_BUTTON); muColors[PCI_NORMAL] = PCLR_BUTTON_FACE; DataSet(pDesc->pText); mpOwner = NULL; if (pDesc->pSubMenu) { mpSubMenu = new PegMenu(pDesc->pSubMenu); } else { mpSubMenu = NULL; if (pDesc->wStyle & BF_DOTABLE) { SetSignals(SIGMASK(PSF_DOT_ON)); } else { if (pDesc->wStyle & BF_CHECKABLE) { SetSignals(SIGMASK(PSF_CHECK_ON)|SIGMASK(PSF_CHECK_OFF)); } else { if (pDesc->wStyle & AF_ENABLED) { SetSignals(SIGMASK(PSF_CLICKED)); } else { RemoveStatus(PSF_SELECTABLE); } } } } AddStatus(PSF_SIZEABLE | PSF_NONCLIENT); RemoveStatus(PSF_ACCEPTS_FOCUS); muColors[PCI_NORMAL] = PCLR_BUTTON_FACE; muColors[PCI_SELECTED] = PCLR_ACTIVE_TITLE; muColors[PCI_NTEXT] = PCLR_NORMAL_TEXT; muColors[PCI_STEXT] = PCLR_HIGH_TEXT; mbPointerOver = FALSE; mbSubVisible = FALSE; }
/*--------------------------------------------------------------------------*/ PegCheckBox::PegCheckBox(PegRect &Rect, const PEGCHAR *Text, WORD wId, WORD wStyle) : PegButton(Rect, wId, wStyle), PegTextThing(Text, wStyle & TT_COPY, PEG_CHECKBOX_FONT) { Type(TYPE_CHECKBOX); SetSignals(SIGMASK(PSF_CHECK_ON)|SIGMASK(PSF_CHECK_OFF)); }
/*--------------------------------------------------------------------------*/ PegRadioButton::PegRadioButton(SIGNED iLeft, SIGNED iTop, const PEGCHAR *Text, WORD wId, WORD wStyle) : PegButton(wId, wStyle), PegTextThing(Text, wStyle & TT_COPY, PEG_RBUTTON_FONT) { Type(TYPE_RADIOBUTTON); SetSignals(SIGMASK(PSF_DOT_ON)); mReal.wLeft = iLeft; mReal.wTop = iTop; SIGNED iHeight = TextHeight(lsTEST, mpFont); if (gbRadioOnBitmap.wHeight > iHeight) { iHeight = gbRadioOnBitmap.wHeight; } iHeight += 4; if (Text) { mReal.wRight = mReal.wLeft + TextWidth(Text, mpFont) + 2; mReal.wRight += gbRadioOnBitmap.wWidth + RBUTTON_SPACING; mReal.wBottom = mReal.wTop + iHeight; } else { mReal.wRight = mReal.wLeft + 3; mReal.wBottom = mReal.wTop + iHeight; } mClient = mReal; }
/*--------------------------------------------------------------------------*/ PegRadioButton::PegRadioButton(PegRect &Rect, const PEGCHAR *Text, WORD wId, WORD wStyle) : PegButton(Rect, wId, wStyle), PegTextThing(Text, wStyle & TT_COPY, PEG_RBUTTON_FONT) { Type(TYPE_RADIOBUTTON); SetSignals(SIGMASK(PSF_DOT_ON)); }
//----------------------------------------------------------------------------- // The 'main' function // argc - number of parameters // argv - the parameters // Returns: Error code int main(int argc, char** argv) { CrashThread* thread; int ret; SetSignals(true); // Process all of the signals we need, including the crash signals // Start the test thread thread = new CrashThread(); thread->Setup(); ret = thread->Start(); if(ret) { printf("Can't start CrashThread, error %d\n", ret); goto Exit; } // Wait for the exit time while(!_exitMain) { // The exit indicator will be triggered by one of the signals Sleep(100); } Exit: // End all processing thread->Stop(); delete thread; return 0; }
/*--------------------------------------------------------------------------*/ PegButton::PegButton(WORD wId, WORD wStyle) : PegThing(wId, wStyle) { muColors[PCI_NORMAL] = PCLR_BUTTON_FACE; muColors[PCI_NTEXT] = PCLR_NORMAL_TEXT; muColors[PCI_SELECTED] = PCLR_BUTTON_FACE; muColors[PCI_STEXT] = PCLR_NORMAL_TEXT; Type(TYPE_BUTTON); AddStatus(PSF_MOVEABLE|PSF_SIZEABLE); SetSignals(SIGMASK(PSF_CLICKED)); if (wStyle & AF_ENABLED) { AddStatus(PSF_SELECTABLE|PSF_TAB_STOP); } else { RemoveStatus(PSF_SELECTABLE|PSF_TAB_STOP); } }
/*--------------------------------------------------------------------------*/ PegPrompt::PegPrompt(const PegRect &Rect, const PEGCHAR *Text, WORD wId, WORD wStyle) : PegThing(Rect, wId, wStyle), PegTextThing(Text, wStyle & TT_COPY, PEG_PROMPT_FONT) { Type(TYPE_PROMPT); InitClient(); if (!(wStyle & AF_ENABLED)) { RemoveStatus(PSF_SELECTABLE|PSF_ACCEPTS_FOCUS); } else { AddStatus(PSF_TAB_STOP); SetSignals(SIGMASK(PSF_FOCUS_RECEIVED)); } muColors[PCI_NTEXT] = PCLR_NORMAL_TEXT; muColors[PCI_STEXT] = PCLR_HIGH_TEXT; muColors[PCI_SELECTED] = PCLR_HIGH_TEXT_BACK; muColors[PCI_NORMAL] = PCLR_CLIENT; }
//----------------------------------------------------------------------------- // Tests sound device void TestSound() { SoundThread* thread; int ret; SetSignals(); // Process all of the signals we need thread = new SoundThread(); thread->Setup(); ret = thread->Start(); if(ret) { printf("Can't start SoundThread: %s\n", thread->_errorDescr); goto Exit; } // Wait for the exit while(!_exitMain) { // The exit indicator will be triggered by one of the signals Sleep(100); } Exit: // End all processing thread->Stop(); delete thread; }
/*--------------------------------------------------------------------------*/ PegCheckBox::PegCheckBox(SIGNED iLeft, SIGNED iTop, const PEGCHAR *Text, WORD wId, WORD wStyle) : PegButton(wId, wStyle), PegTextThing(Text, wStyle & TT_COPY, PEG_CHECKBOX_FONT) { Type(TYPE_CHECKBOX); SetSignals(SIGMASK(PSF_CHECK_ON)|SIGMASK(PSF_CHECK_OFF)); mReal.wLeft = iLeft; mReal.wTop = iTop; if (Text) { mReal.wRight = mReal.wLeft + TextWidth(Text, mpFont); mReal.wRight += gbCheckBoxOnBitmap.wWidth + CBOX_SPACING + 2; mReal.wBottom = mReal.wTop + gbCheckBoxOnBitmap.wHeight + 4; } else { mReal.wRight = mReal.wLeft + 3; mReal.wBottom = mReal.wTop + 3; } mClient = mReal; }
TInt DChannelComm::DoControl(TInt aFunction, TAny* a1, TAny* a2) { TCommConfigV01 c; TInt r = KErrNone; switch (aFunction) { case RBusDevComm::EControlConfig: { //get the current configuration TPtrC8 cfg((const TUint8*)&iConfig, sizeof(iConfig)); r = Kern::ThreadDesWrite(iClient, a1, cfg, 0, KTruncateToMaxLength, iClient); break; } case RBusDevComm::EControlSetConfig: { if (AreAnyPending()) Kern::PanicCurrentThread(_L("D32COMM"), ESetConfigWhileRequestPending); else { memclr(&c, sizeof(c)); TPtr8 cfg((TUint8*)&c, 0, sizeof(c)); r = Kern::ThreadDesRead(iClient, a1, cfg, 0, 0); if (r == KErrNone) r = SetConfig(c); //set the new configuration } break; } case RBusDevComm::EControlCaps: { //get capabilities TCommCaps2 caps; PddCaps(caps); //call ipdd->Caps r = Kern::ThreadDesWrite(iClient, a1, caps, 0, KTruncateToMaxLength, iClient); break; } case RBusDevComm::EControlSignals: { r = Signals(); break; } case RBusDevComm::EControlSetSignals: { // if (((TUint)a1)&((TUint)a2)) //can't set and clear at same time // { // Kern::PanicCurrentThread(_L("D32COMM"), ESetSignalsSetAndClear); // } // else { SetSignals((TUint)a1, (TUint)a2); } break; } case RBusDevComm::EControlQueryReceiveBuffer: r = RxCount(); break; case RBusDevComm::EControlResetBuffers: if (AreAnyPending()) Kern::PanicCurrentThread(_L("D32COMM"), EResetBuffers); else ResetBuffers(ETrue); break; case RBusDevComm::EControlReceiveBufferLength: r = RxBufferSize(); break; case RBusDevComm::EControlSetReceiveBufferLength: if (AreAnyPending()) Kern::PanicCurrentThread(_L("D32COMM"), ESetReceiveBufferLength); else r = SetRxBufferSize((TInt)a1); break; case RBusDevComm::EControlMinTurnaroundTime: r = iTurnaroundMicroSeconds; // used saved value break; case RBusDevComm::EControlSetMinTurnaroundTime: { if ((TInt)a1<0) a1=(TAny*)0; iTurnaroundMicroSeconds = (TUint)a1; // save this TUint newTurnaroundMilliSeconds = (TUint)a1/1000; // convert to ms if(newTurnaroundMilliSeconds != iTurnaroundMinMilliSeconds) { // POLICY: if a new turnaround time is set before the previous running timer has expired and a // write request has been queued, the transmission goes ahead immediately TurnaroundClear(); if(newTurnaroundMilliSeconds > 0) { r = TurnaroundSet(newTurnaroundMilliSeconds); } } } break; default: r = KErrNotSupported; } return(r); }
void GenericInitialize(int argc,char **argv,char *agents) { enum cfagenttype ag = Agent2Type(agents); char vbuff[CF_BUFSIZE]; int ok = false; #ifdef HAVE_NOVA CF_DEFAULT_DIGEST = cf_sha256; CF_DEFAULT_DIGEST_LEN = CF_SHA256_LEN; #else CF_DEFAULT_DIGEST = cf_md5; CF_DEFAULT_DIGEST_LEN = CF_MD5_LEN; #endif InitializeGA(argc,argv); SetReferenceTime(true); SetStartTime(false); SetSignals(); SanitizeEnvironment(); strcpy(THIS_AGENT,CF_AGENTTYPES[ag]); NewClass(THIS_AGENT); THIS_AGENT_TYPE = ag; // need scope sys to set vars in expiry function SetNewScope("sys"); if (EnterpriseExpiry()) { CfOut(cf_error,"","Cfengine - autonomous configuration engine. This enterprise license is invalid.\n"); exit(1); } if (AM_NOVA) { CfOut(cf_verbose,""," -> This is CFE Nova\n"); } if (AM_CONSTELLATION) { CfOut(cf_verbose,""," -> This is CFE Constellation\n"); } NewScope("const"); NewScope("match"); NewScope("mon"); GetNameInfo3(); CfGetInterfaceInfo(ag); if (ag != cf_know) { Get3Environment(); BuiltinClasses(); OSClasses(); } LoadPersistentContext(); LoadSystemConstants(); snprintf(vbuff,CF_BUFSIZE,"control_%s",THIS_AGENT); SetNewScope(vbuff); NewScope("this"); NewScope("match"); if (BOOTSTRAP) { CheckAutoBootstrap(); } else { if (strlen(POLICY_SERVER) > 0) { CfOut(cf_verbose,""," -> Found a policy server (hub) on %s",POLICY_SERVER); } else { CfOut(cf_verbose,""," -> No policy server (hub) watch yet registered"); } } SetPolicyServer(POLICY_SERVER); if (ag != cf_keygen) { if (!MissingInputFile()) { bool check_promises = false; if (SHOWREPORTS) { check_promises = true; CfOut(cf_verbose, "", " -> Reports mode is enabled, force-validating policy"); } if (IsFileOutsideDefaultRepository(VINPUTFILE)) { check_promises = true; CfOut(cf_verbose, "", " -> Input file is outside default repository, validating it"); } if (NewPromiseProposals()) { check_promises = true; CfOut(cf_verbose, "", " -> Input file is changed since last validation, validating it"); } if (check_promises) { ok = CheckPromises(ag); if (BOOTSTRAP && !ok) { CfOut(cf_verbose, "", " -> Policy is not valid, but proceeding with bootstrap"); ok = true; } } else { CfOut(cf_verbose, "", " -> Policy is already validated"); ok = true; } } if (ok) { ReadPromises(ag,agents); } else { CfOut(cf_error,"","cf-agent was not able to get confirmation of promises from cf-promises, so going to failsafe\n"); snprintf(VINPUTFILE,CF_BUFSIZE-1,"failsafe.cf"); ReadPromises(ag,agents); } if (SHOWREPORTS) { CompilationReport(VINPUTFILE); } CheckLicenses(); } XML = 0; }
void CheckOpts(int argc,char **argv) { extern char *optarg; int optindex = 0; int c; umask(077); sprintf(VPREFIX,"cfenvd"); openlog(VPREFIX,LOG_PID|LOG_NOWAIT|LOG_ODELAY,LOG_DAEMON); strcpy(CFLOCK,"cfenvd"); SetContext("cfenvd"); IGNORELOCK = false; OUTPUT[0] = '\0'; while ((c=getopt_long(argc,argv,"d:vhHFVT",CFDENVOPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'd': switch ((optarg==NULL)?3:*optarg) { case '1': D1 = true; break; case '2': D2 = true; break; default: DEBUG = true; break; } NO_FORK = true; printf("cfenvd: Debug mode: running in foreground\n"); break; case 'v': VERBOSE = true; break; case 'V': printf("GNU %s-%s daemon\n%s\n",PACKAGE,VERSION,COPYRIGHT); printf("This program is covered by the GNU Public License and may be\n"); printf("copied free of charge. No warrenty is implied.\n\n"); exit(0); break; case 'F': NO_FORK = true; break; case 'H': HISTO = true; break; case 'T': TCPDUMP = true; break; default: Syntax(); exit(1); } } LOGGING = true; /* Do output to syslog */ SetReferenceTime(false); SetStartTime(false); SetSignals(); signal (SIGTERM,HandleSignal); /* Signal Handler */ signal (SIGHUP,HandleSignal); signal (SIGINT,HandleSignal); signal (SIGPIPE,HandleSignal); signal (SIGSEGV,HandleSignal); signal (SIGUSR1,HandleSignal); signal (SIGUSR2,HandleSignal); }
/*--------------------------------------------------------------------------*/ PegPrompt::PegPrompt(SIGNED iLeft, SIGNED iTop, SIGNED iWidth, const PEGCHAR *Text, WORD wId, WORD wStyle, PegFont *pFont) : PegThing(wId, wStyle), PegTextThing(Text, wStyle & TT_COPY, PEG_PROMPT_FONT) { Type(TYPE_PROMPT); if (pFont) { mpFont = pFont; } mReal.wLeft = iLeft; mReal.wTop = iTop; mReal.wRight = mReal.wLeft + iWidth; mReal.wBottom = mReal.wTop + TextHeight(lsTEST, mpFont) + 2; switch(wStyle & FF_MASK) { case FF_THICK: mReal.wBottom += PEG_FRAME_WIDTH * 2; break; case FF_THIN: mReal.wBottom += 2; break; #ifdef PEG_RUNTIME_COLOR_CHECK case FF_RAISED: case FF_RECESSED: if (NumColors() >= 4) { mReal.wBottom += 4; } else { mReal.wBottom += 2; } break; #else #if (PEG_NUM_COLORS != 2) case FF_RAISED: case FF_RECESSED: mReal.wBottom += 4; break; #endif #endif default: break; } InitClient(); if (!(wStyle & AF_ENABLED)) { RemoveStatus(PSF_SELECTABLE|PSF_ACCEPTS_FOCUS); } else { AddStatus(PSF_TAB_STOP); SetSignals(SIGMASK(PSF_FOCUS_RECEIVED)); } muColors[PCI_NTEXT] = PCLR_NORMAL_TEXT; muColors[PCI_SELECTED] = PCLR_HIGH_TEXT_BACK; muColors[PCI_STEXT] = PCLR_HIGH_TEXT; muColors[PCI_NORMAL] = PCLR_CLIENT; }