void main(void) { // /* Set up the USART2 9600-8N1 and to call USART2_callback_fn when new data arrives */ // USART2_init(state1_USART2_callback_fn); // // /* Set up the USART3 9600-8N1 and to call USART2_callback_fn when new data arrives */ // USART3_init(state1_USART3_callback_fn); /* Configure user pushbutton and call pushbutton_callback_fn when button press-released */ userbutton_init(userbutton_callback_fn); /* initialize the finite state machine */ fsm_init(); /* Enable interrupts - do this after initializing the system */ __asm (" cpsie i \n" ); //Put the wifi module into command mode // USART3_putchar('$'); // USART3_putchar('$'); // USART3_putchar('$'); // USART2_putchar('$'); // USART2_putchar('$'); // USART2_putchar('$');// USART2_putstr("$$$\n\r\0"); /* Wait here forever - everything is now interrupt driven */ while(1) { ;;; } }
/* * ccp_init - initialize CCP. */ static void ccp_init( int unit) { fsm *f = &ccp_fsm[unit]; f->unit = unit; f->protocol = PPP_CCP; f->callbacks = &ccp_callbacks; fsm_init(f); memset(&ccp_wantoptions[unit], 0, sizeof(ccp_options)); memset(&ccp_gotoptions[unit], 0, sizeof(ccp_options)); memset(&ccp_allowoptions[unit], 0, sizeof(ccp_options)); memset(&ccp_hisoptions[unit], 0, sizeof(ccp_options)); ccp_wantoptions[0].deflate = 1; ccp_wantoptions[0].deflate_size = DEFLATE_MAX_SIZE; ccp_wantoptions[0].deflate_correct = 1; ccp_wantoptions[0].deflate_draft = 1; ccp_allowoptions[0].deflate = 1; ccp_allowoptions[0].deflate_size = DEFLATE_MAX_SIZE; ccp_allowoptions[0].deflate_correct = 1; ccp_allowoptions[0].deflate_draft = 1; ccp_wantoptions[0].bsd_compress = 1; ccp_wantoptions[0].bsd_bits = BSD_MAX_BITS; ccp_allowoptions[0].bsd_compress = 1; ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS; ccp_allowoptions[0].predictor_1 = 1; }
/** initializing context for LCP. */ void lcp_init(lcp *_this, npppd_ppp *ppp) { fsm_init(&_this->fsm); _this->fsm.ppp = ppp; _this->fsm.callbacks = &lcp_callbacks; _this->fsm.protocol = PPP_PROTO_LCP; _this->fsm.flags |= OPT_SILENT; _this->timerctx.ctx = _this; _this->recv_ress = 0; _this->recv_reqs = 0; _this->magic_number = ((0xffff & random()) << 16) | (0xffff & random()); PPP_FSM_CONFIG(&_this->fsm, timeouttime, "lcp.timeout"); PPP_FSM_CONFIG(&_this->fsm, maxconfreqtransmits,"lcp.max_configure"); PPP_FSM_CONFIG(&_this->fsm, maxtermtransmits, "lcp.max_terminate"); PPP_FSM_CONFIG(&_this->fsm, maxnakloops, "lcp.max_nak_loop"); /* * PPTP and L2TP are able to detect lost carrier, so LCP ECHO is off * by default. */ _this->echo_interval = 0; _this->echo_failures = 0; _this->echo_max_retries = 0; _this->auth_order[0] = -1; }
/* * acscp_init - Initialize acscp. */ static void acscp_init(int unit) { fsm *f = &acscp_fsm[unit]; acscp_options *wo = &acscp_wantoptions[0]; acscp_options *ao = &acscp_allowoptions[0]; acsp_no_routes = 0; acsp_no_domains = 0; f->unit = unit; f->protocol = PPP_ACSCP; f->callbacks = &acscp_callbacks; fsm_init(&acscp_fsm[unit]); memset(wo, 0, sizeof(*wo)); memset(ao, 0, sizeof(*ao)); wo->routes_version = LATEST_ROUTES_VERSION; wo->domains_version = LATEST_DOMAINS_VERSION; ao->routes_version = LATEST_ROUTES_VERSION; ao->domains_version = LATEST_DOMAINS_VERSION; //plugin_list = 0; }
fsm_t* fsm_new (fsm_trans_t* tt) { fsm_t* this = (fsm_t*) malloc (sizeof (fsm_t)); fsm_init (this, tt); return this; }
void t_setup() { token_index = 0; diff = 0; count = 0; symbol_table_init(&fix.table); fsm_init(&fix.fsm, &fix.table); ebnf_init_fsm(&fix.fsm); }
int main(void) { _buttonusr_isr = (void *)&buttonisr_usr; _timerusr_isr = (void *)&timerisr_usr; _mmhusr_isr = (void *)&mmhisr; /* Drop privileges */ drop_privs(); /* Init board */ kk_board_init(); /* Program the model into OTP, if we're not in screen-test mode, and it's * not already there */ (void)flash_programModel(); /* Init for safeguard against stack overflow (-fstack-protector-all) */ __stack_chk_guard = (uintptr_t)random32(); /* Bootloader Verification */ check_bootloader(); led_func(SET_RED_LED); dbg_print("Application Version %d.%d.%d\n\r", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION); /* Init storage */ storage_init(); /* Init protcol buffer message map and usb msg callback */ fsm_init(); led_func(SET_GREEN_LED); usbInit(); u2fInit(); led_func(CLR_RED_LED); reset_idle_time(); if (is_mfg_mode()) layout_screen_test(); else if (!storage_isInitialized()) layout_standard_notification("Welcome", "keepkey.com/get-started", NOTIFICATION_LOGO); else layoutHomeForced(); while (1) { delay_ms_with_callback(ONE_SEC, &exec, 1); increment_idle_time(ONE_SEC); toggle_screensaver(); } return 0; }
/* * ccp_init - initialize CCP. */ void ccp_init(PPP_IF_VAR_T *pPppIf) { fsm *f = &pPppIf->ccp_fsm; ccp_options *wo = &pPppIf->ccp_wantoptions; ccp_options *ao = &pPppIf->ccp_allowoptions; f->pPppIf = pPppIf; f->protocol = PPP_CCP; f->callbacks = &ccp_callbacks; fsm_init(f); mppe_bitkeylen = 0; memset(&pPppIf->ccp_wantoptions, 0, sizeof(ccp_options)); memset(&pPppIf->ccp_gotoptions, 0, sizeof(ccp_options)); memset(&pPppIf->ccp_allowoptions, 0, sizeof(ccp_options)); memset(&pPppIf->ccp_hisoptions, 0, sizeof(ccp_options)); //wo->deflate = 1; wo->deflate = 0; wo->deflate_size = DEFLATE_MAX_SIZE; wo->deflate_correct = 1; //wo->deflate_draft = 1; wo->deflate_draft = 0; ao->deflate = 1; ao->deflate_size = DEFLATE_MAX_SIZE; ao->deflate_correct = 1; ao->deflate_draft = 1; //wo->bsd_compress = 1; wo->bsd_compress = 0; wo->bsd_bits = BSD_MAX_BITS; ao->bsd_compress = 1; ao->bsd_bits = BSD_MAX_BITS; ao->predictor_1 = 1; #ifdef MPPE if (pPppIf->mppe == 1) { pPppIf->ccp_wantoptions.mppe = 1; pPppIf->ccp_wantoptions.mppc = 1; pPppIf->ccp_wantoptions.mppe_stateless = 1; pPppIf->ccp_wantoptions.mppe_40 = 1; pPppIf->ccp_wantoptions.mppe_56 = 1; pPppIf->ccp_wantoptions.mppe_128 = 1; pPppIf->ccp_allowoptions.mppe_stateless = 1; pPppIf->ccp_allowoptions.mppe = 1; pPppIf->ccp_allowoptions.mppe_40 = 1; pPppIf->ccp_allowoptions.mppe_56 = 1; pPppIf->ccp_allowoptions.mppe_128 = 1; } #endif /* MPPE*/ }
int main() { event_t events[] = {EVT_A, EVT_B, EVT_B, EVT_C, EVT_C, EVT_A, EVT_C, EVT_B, EVT_A}; fsm_t fsm; fsm_init(&fsm); size_t events_max = sizeof(events) / sizeof(event_t); printf("|E| = %zu\n", events_max); for (size_t i = 0; i < events_max; i++) { fsm_transition(&fsm, events[i]); } }
/* * lcp_init - Initialize LCP. */ static void lcp_init( int unit) { fsm *f = &lcp_fsm[unit]; lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *ao = &lcp_allowoptions[unit]; f->unit = unit; f->protocol = PPP_LCP; f->callbacks = &lcp_callbacks; fsm_init(f); wo->passive = 0; wo->silent = 0; wo->restart = 0; /* Set to 1 in kernels or multi-line implementations */ wo->neg_mru = 1; wo->mru = DEFMRU; wo->neg_asyncmap = 1; wo->asyncmap = 0; wo->neg_chap = 0; /* Set to 1 on server */ wo->neg_upap = 0; /* Set to 1 on server */ wo->chap_mdtype = CHAP_DIGEST_MD5; wo->neg_magicnumber = 1; wo->neg_pcompression = 1; wo->neg_accompression = 1; wo->neg_lqr = 0; /* no LQR implementation yet */ wo->neg_cbcp = 0; ao->neg_mru = 1; ao->mru = MAXMRU; ao->neg_asyncmap = 1; ao->asyncmap = 0; ao->neg_chap = 1; ao->chap_mdtype = CHAP_DIGEST_MD5; ao->neg_upap = 1; ao->neg_magicnumber = 1; ao->neg_pcompression = 1; ao->neg_accompression = 1; ao->neg_lqr = 0; /* no LQR implementation yet */ #ifdef CBCP_SUPPORT ao->neg_cbcp = 1; #else ao->neg_cbcp = 0; #endif memset(xmit_accm[unit], 0, sizeof(xmit_accm[0])); xmit_accm[unit][3] = 0x60000000; }
void state_init( uint state, FUNC_PTR func, uchar *name ) { fsm_init(); if ( (state_obj == NULL) || ( fsm_obj == NULL)) ERROR_PRINTF; fsm_obj->state = state; fsm_obj->func = func; fsm_obj->name = name; state_obj->state = state; state_obj->func = func; state_obj->name = name; state_obj_copy = state_obj; list_init( &(state_obj->node) ); }
void main(void) { /* Set up the USART2 9600-8N1 and to call USART2_callback_fn when new data arrives */ USART2_init(USART2_callback_fn); /* Set up the USART3 9600-8N1 and to call USART2_callback_fn when new data arrives */ USART3_init(USART3_callback_fn); /* Set up and initialize the LEDs. */ LED_init(); /* Configure user pushbutton and call pushbutton_callback_fn when button press-released */ userbutton_init(userbutton_callback_fn); /* Initialize the systick timer with its callback function */ systick_init(systick_callback_fn); set_systick_disabled(); /* initialize the finite state machine */ fsm_init(); //Test ping the server Wifly_Send_Ping(); /* Enable interrupts - do this after initializing the system */ __asm (" cpsie i \n" ); //Put the wifi module into command mode // USART3_putchar('$'); // USART3_putchar('$'); // USART3_putchar('$'); // USART2_putchar('$'); // USART2_putchar('$'); // USART2_putchar('$');// USART2_putstr("$$$\n\r\0"); /* Wait here forever - everything is now interrupt driven */ while(1) { ;;; } }
void fsm( event_t *evt ) { /* Start with the init loop. */ if (fsm_state == FSM_INIT) { fsm_init( evt ); return; } else if (fsm_state == FSM_ERR) { LED0_ON(); return; } /* Handle normal events. */ switch (evt->type) { case EVENT_TYPE_TIMER: if (evt->timer.timer == 0) { LED0_TOGGLE(); timer_start( 0, 500, NULL ); } else if (evt->timer.timer == 1) { if (fsm_state == FSM_SEARCH) fsm_search(); else if (fsm_state == FSM_RUN) fsm_run(); } break; case EVENT_TYPE_ADC: fsm_adcBuf[ fsm_adc ] = ADCL; fsm_adcBuf[ fsm_adc ] += ADCH<<8; /*printf( "adc %d: %u", fsm_adc, fsm_adcBuf[ fsm_adc ] );*/ fsm_adc = 1-fsm_adc; adc_start( fsm_adc ); break; default: break; } }
/* * ipcp_init - Initialize IPCP. */ static void ipcp_init(int unit) { fsm *f = &ipcp_fsm[unit]; ipcp_options *wo = &ipcp_wantoptions[unit]; ipcp_options *ao = &ipcp_allowoptions[unit]; f->unit = unit; f->protocol = PPP_IPCP; f->callbacks = &ipcp_callbacks; fsm_init(&ipcp_fsm[unit]); memset(wo, 0, sizeof(*wo)); memset(ao, 0, sizeof(*ao)); wo->neg_addr = 1; wo->ouraddr = 0; //wo->ouraddr = inet_addr("10.0.0.5"); #if VJ_SUPPORT > 0 wo->neg_vj = 1; #else wo->neg_vj = 0; #endif wo->vj_protocol = IPCP_VJ_COMP; wo->maxslotindex = MAX_SLOTS - 1; wo->cflag = 0; wo->default_route = 1; ao->neg_addr = 1; #if VJ_SUPPORT > 0 ao->neg_vj = 1; #else ao->neg_vj = 0; #endif ao->maxslotindex = MAX_SLOTS - 1; ao->cflag = 1; ao->default_route = 1; }
/* * ipcp_init - Initialize IPCP. */ static void ipcp_init( int unit) { fsm *f = &ipcp_fsm[unit]; ipcp_options *wo = &ipcp_wantoptions[unit]; ipcp_options *ao = &ipcp_allowoptions[unit]; f->unit = unit; f->protocol = PPP_IPCP; f->callbacks = &ipcp_callbacks; fsm_init(&ipcp_fsm[unit]); memset(wo, 0, sizeof(*wo)); memset(ao, 0, sizeof(*ao)); wo->neg_addr = 1; wo->neg_vj = 1; wo->vj_protocol = IPCP_VJ_COMP; wo->maxslotindex = MAX_STATES - 1; /* really max index */ wo->cflag = 1; /* max slots and slot-id compression are currently hardwired in */ /* ppp_if.c to 16 and 1, this needs to be changed (among other */ /* things) gmc */ ao->neg_addr = 1; ao->neg_vj = 1; ao->maxslotindex = MAX_STATES - 1; ao->cflag = 1; /* * XXX These control whether the user may use the proxyarp * and defaultroute options. */ ao->proxy_arp = 1; ao->default_route = 1; }
/* * main() - Application main entry * * INPUT * none * OUTPUT * 0 when complete */ int main(void) { /* Init for safeguard against stack overflow (-fstack-protector-all) */ __stack_chk_guard = (uintptr_t)random32(); /* Init board */ board_init(); led_func(SET_RED_LED); dbg_print("Application Version %d.%d.%d\n\r", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION); /* Init storage */ storage_init(); /* Init protcol buffer message map and usb msg callback */ fsm_init(); led_func(SET_GREEN_LED); screen_test(); /* Enable interrupt for timer */ cm_enable_interrupts(); usb_init(); led_func(CLR_RED_LED); reset_idle_time(); while(1) { delay_ms_with_callback(ONE_SEC, &exec, 1); increment_idle_time(ONE_SEC); toggle_screensaver(); } return(0); }
/** Initialize the context for ccp */ void ccp_init(ccp *_this, npppd_ppp *ppp) { struct tunnconf *conf; memset(_this, 0, sizeof(ccp)); _this->ppp = ppp; _this->fsm.callbacks = &ccp_callbacks; _this->fsm.protocol = PPP_PROTO_NCP | NCP_CCP; _this->fsm.ppp = ppp; fsm_init(&_this->fsm); conf = ppp_get_tunnconf(ppp); PPP_FSM_CONFIG(&_this->fsm, timeouttime, conf->ccp_timeout); PPP_FSM_CONFIG(&_this->fsm, maxconfreqtransmits, conf->ccp_max_configure); PPP_FSM_CONFIG(&_this->fsm, maxtermtransmits, conf->ccp_max_terminate); PPP_FSM_CONFIG(&_this->fsm, maxnakloops, conf->ccp_max_nak_loop); }
void test_fsm() { // Create connection context which include the state machine ContextId cid = {1, 99}; Context *ctx = context_create(cid, MANAGER_CONTEXT); FSM *fsm = ctx->fsm; // Initialize FSM FsmTransitionRule transition_table[] = { { 0, 1, 1, &testfsm_action1 }, { 1, 2, 2, &testfsm_action2 }, { 2, 3, 0, &testfsm_action3 } }; fsm_init(fsm, 0, transition_table, sizeof(transition_table) / sizeof(struct FsmTransitionRule)); CU_ASSERT_EQUAL(fsm->transition_table_size, 3); // Process inputs fsm_process_evt(ctx, 1, NULL); CU_ASSERT_EQUAL(fsm->state, 1); fsm_process_evt(ctx, 2, NULL); CU_ASSERT_EQUAL(fsm->state, 2); fsm_process_evt(ctx, 3, NULL); CU_ASSERT_EQUAL(fsm->state, 0); fsm_set_manager_state_table(fsm); CU_ASSERT_EQUAL(fsm->state, fsm_state_disconnected); context_remove(cid); }
/*=========================================================================== FUNCTION LCP_INIT() DESCRIPTION This function will initialize the LCP configuration structure for the given interface (Rm or Um). DEPENDENCIES None RETURN VALUE None SIDE EFFECTS None ===========================================================================*/ void lcp_init ( ppp_dev_enum_type device, /* device to initalize */ ppp_dev_opts_type *opts_ptr /* options to initialize with */ ) { ppp_fsm_type *fsm_ptr; lcp_value_type *lwant_ptr; lcp_value_type *lwork_ptr; lcp_value_type *rwant_ptr; lcp_value_type *rwork_ptr; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if(device >= PPP_MAX_DEV || opts_ptr == NULL) { ASSERT(0); return; } fsm_ptr = &(ppp_cb_array[device].fsm[Lcp]); lwant_ptr = (lcp_value_type*)fsm_ptr->local.want_pdv; lwork_ptr = (lcp_value_type*)fsm_ptr->local.work_pdv; rwant_ptr = (lcp_value_type*)fsm_ptr->remote.want_pdv; rwork_ptr = (lcp_value_type*)fsm_ptr->remote.work_pdv; /*------------------------------------------------------------------------- Zeroing out the variables for this interface. -------------------------------------------------------------------------*/ memset(lwant_ptr, 0, sizeof(lcp_value_type)); memset(rwant_ptr, 0, sizeof(lcp_value_type)); memset(lwork_ptr, 0, sizeof(lcp_value_type)); memset(rwork_ptr, 0, sizeof(lcp_value_type)); fsm_ptr->state = fsmINITIAL; #ifdef FEATURE_DS_MOBILE_IP_PERF /*------------------------------------------------------------------------- Notify M.IP call performance that Um/Rm PPP negotiation is starting. -------------------------------------------------------------------------*/ if(device == PPP_UM_SN_DEV) { mip_perf_delay(&mip_perf_info[PERF_UM_PPP_DELAY], PERF_UM_PPP_DELAY, PERF_START_TS); } else if(device == PPP_RM_DEV) { mip_perf_delay(&mip_perf_info[PERF_RM_PPP_DELAY], PERF_RM_PPP_DELAY, PERF_START_TS); } #endif /* FEATURE_DS_MOBILE_IP_PERF */ /*------------------------------------------------------------------------- Use passed in options to initialize things. -----------------------------------------------------------------------*/ memcpy(lwant_ptr, &(opts_ptr->lcp_info.want_vals[FSM_LOCAL]), sizeof(lcp_value_type)); memcpy(rwant_ptr, &(opts_ptr->lcp_info.want_vals[FSM_REMOTE]), sizeof(lcp_value_type)); memcpy(lwork_ptr, &(opts_ptr->lcp_info.work_vals[FSM_LOCAL]), sizeof(lcp_value_type)); memcpy(rwork_ptr, &(opts_ptr->lcp_info.work_vals[FSM_REMOTE]), sizeof(lcp_value_type)); fsm_ptr->local.want = opts_ptr->lcp_info.want_mask[FSM_LOCAL]; fsm_ptr->remote.want = opts_ptr->lcp_info.want_mask[FSM_REMOTE]; fsm_ptr->local.will = opts_ptr->lcp_info.will_mask[FSM_LOCAL]; fsm_ptr->remote.will = opts_ptr->lcp_info.will_mask[FSM_REMOTE]; /*------------------------------------------------------------------------- Make sure that work is setup so that we negotiate for what we want. -------------------------------------------------------------------------*/ fsm_ptr->local.work = fsm_ptr->local.want; fsm_ptr->remote.work = fsm_ptr->remote.want; fsm_init(fsm_ptr); } /* lcp_init() */
void vControl ( void *pvParameters ) { portTickType xLastWakeTime; signed char valx, valy; unsigned char ls, rs, lb, rb; can_frame_t out_frame; can_frame_t in_frame; out_frame.id = 1; out_frame.dlc = 6; xLastWakeTime = xTaskGetTickCount (); /* Button init */ buttons_init (); /* FSM init */ fsm_init (); /* CAN init */ can_init (); /* ADC init */ adc_init ( ctrlNUM_ADC_VALUES ); /* Touch init */ touch_init ( 30, 30, 30, 30 ); while (1) { vTaskDelayUntil ( &xLastWakeTime, ctrlTASK_FREQUENCY ); if ( adc_conversion_complete () == pdTRUE ) { adc_disable (); adc_get_value ( &valx, 0 ); adc_get_value ( &valy, 0 ); touch_measure ( &ls, &rs, &lb, &rb ); out_frame.data[0] = valx; out_frame.data[1] = valy; out_frame.data[2] = ls; out_frame.data[3] = rs; out_frame.data[4] = lb; out_frame.data[5] = rb; if (fsm_get_state() == ST_PLAY) { can_transmit (&out_frame); } can_receive (&in_frame, 0); if (in_frame.data[0] == GAME_SENSOR_TRIGGERED) { // TODO: set triggered state fsm_event_t *event = pvPortMalloc (sizeof (fsm_event_t)); event->type = EV_STOP; event->ptr = NULL; fsm_event_put (event, portMAX_DELAY); in_frame.data[0] = 0; } else if (in_frame.data[0] == GAME_SENSOR_CLEARED) { // TODO: set cleared state in_frame.data[0] = 0; } adc_enable (); adc_conversion_start (); } fsm_update (); } }
void test_event_task2(void * pParam) { /*check whether MAX_IDLE_EVENT_TASK is valid*/ RAW_ASSERT((ARRAY_SIZE(active_idle_task)) == MAX_IDLE_EVENT_TASK); idle_event_init(); Bomb4_ctor(&l_bomb22, 0xd); /* the secret defuse code, 1101 binary */ l_bomb22.internal_priority = 1; fsm_init(&l_bomb22.a1.super, 0); idle_tick_start = 1; vc_port_printf("Time Bomb (raw os fsm case)\n" "Press 'u' for UP event\n" "Press 'd' for DOWN event\n" "Press 'a' for ARM event\n" "Press <Esc> to quit.\n"); while (1) { if (_kbhit()) { static STATE_EVENT up_evt = { UP_SIG, 0, 0 }; static STATE_EVENT down_evt = { DOWN_SIG, 0, 0 }; static STATE_EVENT arm_evt = { ARM_SIG, 0, 0 }; STATE_EVENT *e = 0; switch (_getch()) { case 'u': { /* UP event */ vc_port_printf("\nUP : "); e = &up_evt; /* generate the UP event */ break; } case 'd': { /* DOWN event */ vc_port_printf("\nDOWN: "); e = &down_evt; /* generate the DOWN event */ break; } case 'a': { /* ARM event */ vc_port_printf("\nARM : "); e = &arm_evt; /* generate the ARM event */ break; } case '\33': { /* <Esc> key */ vc_port_printf("\nESC : Bye! Bye!"); exit(0); break; } } if (e != 0) { /* keyboard event available? */ idle_event_end_post(&l_bomb22.a1, e->sig, &tick_evt); } } raw_sleep(10); } }
void InitSwallow(struct XObj *xobj) { unsigned long mask; XSetWindowAttributes Attr; static char *my_sm_env = NULL; static char *orig_sm_env = NULL; static int len = 0; static Bool sm_initialized = False; static Bool session_manager = False; char *cmd; /* Enregistrement des couleurs et de la police */ if (xobj->colorset >= 0) { xobj->TabColor[fore] = Colorset[xobj->colorset].fg; xobj->TabColor[back] = Colorset[xobj->colorset].bg; xobj->TabColor[hili] = Colorset[xobj->colorset].hilite; xobj->TabColor[shad] = Colorset[xobj->colorset].shadow; } else { xobj->TabColor[fore] = GetColor(xobj->forecolor); xobj->TabColor[back] = GetColor(xobj->backcolor); xobj->TabColor[hili] = GetColor(xobj->hilicolor); xobj->TabColor[shad] = GetColor(xobj->shadcolor); } mask=0; xobj->win=XCreateWindow(dpy,*xobj->ParentWin, -1000,-1000,xobj->width,xobj->height,0, CopyFromParent,InputOutput,CopyFromParent, mask,&Attr); /* Redimensionnement du widget */ if (xobj->height<30) xobj->height=30; if (xobj->width<30) xobj->width=30; if (xobj->swallow == NULL) { fprintf(stderr,"Error\n"); return; } if (!sm_initialized) { /* use sm only when needed */ sm_initialized = True; orig_sm_env = getenv("SESSION_MANAGER"); if (orig_sm_env && !StrEquals("", orig_sm_env)) { /* this set the new SESSION_MANAGER env */ session_manager = fsm_init(x11base->TabArg[0]); } } if (!session_manager) { SendText(fd, xobj->swallow, 0); return; } if (my_sm_env == NULL) { my_sm_env = getenv("SESSION_MANAGER"); len = 45 + strlen(my_sm_env) + strlen(orig_sm_env); } cmd = safemalloc(len + strlen(xobj->swallow)); sprintf( cmd, "FSMExecFuncWithSessionManagment \"%s\" \"%s\" \"%s\"", my_sm_env, xobj->swallow, orig_sm_env); SendText(fd, cmd, 0); free (cmd); }
static void ccp_init (void) { fsm_init(&ccp_fsm); }
void GSMTask (void *arg) { static const char fname[] = "GSMTask"; void *msg; phn_syshdr_t *syshdr; boolean release_msg = TRUE; /* * Get the GSM message queue handle * A hack until the tasks in irx are * CPRized. */ gsm_msg_queue = (cprMsgQueue_t) arg; if (!gsm_msg_queue) { GSM_ERR_MSG(GSM_F_PREFIX"invalid input, exiting\n", fname); return; } if (platThreadInit("GSMTask") != 0) { return; } /* * Adjust relative priority of GSM thread. */ (void) cprAdjustRelativeThreadPriority(GSM_THREAD_RELATIVE_PRIORITY); /* * Initialize all the GSM modules */ lsm_init(); fsm_init(); fim_init(); gsm_init(); dcsm_init(); cc_init(); fsmutil_init_shown_calls_ci_map(); /* * On Win32 platform, the random seed is stored per thread; therefore, * each thread needs to seed the random number. It is recommended by * MS to do the following to ensure randomness across application * restarts. */ cpr_srand((unsigned int)time(NULL)); /* * Cache random numbers for SRTP keys */ gsmsdp_cache_crypto_keys(); while (1) { release_msg = TRUE; msg = cprGetMessage(gsm_msg_queue, TRUE, (void **) &syshdr); if (msg) { switch (syshdr->Cmd) { case TIMER_EXPIRATION: gsm_process_timer_expiration(msg); break; case GSM_SIP: case GSM_GSM: release_msg = gsm_process_msg(syshdr->Cmd, msg); break; case DP_MSG_INIT_DIALING: case DP_MSG_DIGIT_STR: case DP_MSG_STORE_DIGIT: case DP_MSG_DIGIT: case DP_MSG_DIAL_IMMEDIATE: case DP_MSG_REDIAL: case DP_MSG_ONHOOK: case DP_MSG_OFFHOOK: case DP_MSG_UPDATE: case DP_MSG_DIGIT_TIMER: case DP_MSG_CANCEL_OFFHOOK_TIMER: dp_process_msg(syshdr->Cmd, msg); break; case SUB_MSG_B2BCNF_SUBSCRIBE_RESP: case SUB_MSG_B2BCNF_NOTIFY: case SUB_MSG_B2BCNF_TERMINATE: sub_process_b2bcnf_msg(syshdr->Cmd, msg); break; case SUB_MSG_FEATURE_SUBSCRIBE_RESP: case SUB_MSG_FEATURE_NOTIFY: case SUB_MSG_FEATURE_TERMINATE: sub_process_feature_msg(syshdr->Cmd, msg); break; case SUB_MSG_KPML_SUBSCRIBE: case SUB_MSG_KPML_TERMINATE: case SUB_MSG_KPML_NOTIFY_ACK: case SUB_MSG_KPML_SUBSCRIBE_TIMER: case SUB_MSG_KPML_DIGIT_TIMER: kpml_process_msg(syshdr->Cmd, msg); break; case REG_MGR_STATE_CHANGE: gsm_reset(); break; case THREAD_UNLOAD: destroy_gsm_thread(); break; default: GSM_ERR_MSG(GSM_F_PREFIX"Unknown message\n", fname); break; } cprReleaseSysHeader(syshdr); if (release_msg == TRUE) { cprReleaseBuffer(msg); } /* Check if there are pending messages for dcsm * if it in the right state perform its operation */ dcsm_process_jobs(); } } }