Esempio n. 1
0
bool FastXMLVisitor::VisitEnter (const XMLElement & element, const XMLAttribute* /* attr */)
{
  const char* element_name = element.Name();

  if (strcmp(element_name, "templates") == 0 ) {
    instruction_context context;
    context.ns_ = get_optional_attr(element, "templateNs", "");
    context.dictionary_ = get_optional_attr(element, "dictionary", "");

    context_stack_.push_back(context);
    return VisitEnterTemplates(element);
  }

  std::string name_attr = get_optional_attr(element, "name", "");

  if (strcmp(element_name, "templateRef") == 0) {
    return VisitTemplateRef(element, name_attr, num_fields_.back());
  }

  bool result = true;

  if (strcmp(element_name, "template") == 0 ) {
    save_context(element);
    result = VisitEnterTemplate(element, name_attr, num_fields_.back());
  }
  else if (strcmp(element_name, "group") == 0 ) {
    save_context(element);
    result = VisitEnterGroup(element, name_attr, num_fields_.back());
  }
  else if (strcmp(element_name, "sequence") == 0 ) {
    save_context(element);
    result = VisitEnterSequence(element, name_attr, num_fields_.back());
  }
  else if (strcmp(element_name, "define") == 0) {
    return VisitEnterDefine(element, name_attr);
  }
  else {
    int bits;
    bool is_vector;
    if ((strncmp(element_name, "int", 3) == 0 &&  parse_bits(element_name+3, bits, is_vector) ) ||
        (strncmp(element_name, "uInt", 4) == 0 &&  parse_bits(element_name+4, bits, is_vector) )  ) {
      // int8, int16 and uint8, uint16 are not standards, convert them to int32 and uint32 respectively
      if (is_vector)
        return VisitIntVector(element,bits, name_attr, num_fields_.back());
      return VisitInteger(element,bits, name_attr, num_fields_.back());
    }
    else if (strcmp(element_name, "decimal") == 0 ) {
      return VisitDecimal(element, name_attr, num_fields_.back());
    }
    else if (strcmp(element_name, "string") == 0 ) {
      return VisitString(element, name_attr, num_fields_.back());
    }
    else if (strcmp(element_name, "byteVector") == 0 ) {
      return VisitByteVector(element, name_attr, num_fields_.back());
    }
    return true;
  }
  num_fields_.push_back(0);
  return result;
}
Esempio n. 2
0
static CMPIStatus TCPCOMM_IndicationMI_deActivateFilter(provider_address * addr,
        RemoteCMPIIndicationMI * cThis,
        CMPIContext * context,
        CMPIResult * result,
        CMPIObjectPath * cop,
        CMPISelectExp * filter,
        const char *indType,
        CMPIBoolean lastActivation)
#endif
{
    int socket;
    unsigned long int ctxid = save_context(context);
    TRACE_NORMAL(("Executing remote MI call."));
    CMAddContextEntry(context, RCMPI_CTX_ID, &ctxid, CMPI_uint32);
    socket = __provider_connect(addr, cThis->provider, &cThis->ticket,
                                __FUNCTION__, context, cop);
    if (socket < 0)
        CMReturnWithString(CMPI_RC_ERR_FAILED,connect_error(addr));
    (__sft)->serialize_CMPISelectExp(socket, filter);
    (__sft)->serialize_string(socket, indType);
    (__sft)->serialize_UINT8(socket, lastActivation);
    {
        CMPIStatus rc;
        CMPIArray *r;
        rc = (__sft)->deserialize_CMPIStatus(socket, cThis->broker);
        r = (__sft)->deserialize_CMPIArray(socket, cThis->broker);
        close(socket);
        remove_context(ctxid);
#ifndef CMPI_VER_100
        socketcomm_array2result(r, result);
#endif
        return rc;
    };
};
Esempio n. 3
0
static CMPIStatus TCPCOMM_InstanceMI_deleteInstance(provider_address * addr,
        RemoteCMPIInstanceMI * cThis,
        CONST CMPIContext * context,
        CONST CMPIResult * result,
        CONST CMPIObjectPath * cop)
{
    int socket;
    unsigned long int ctxid = save_context(context);
    TRACE_NORMAL(("Executing remote MI call."));
    CMAddContextEntry(context, RCMPI_CTX_ID, &ctxid, CMPI_uint32);
    socket = __provider_connect(addr, cThis->provider, &cThis->ticket,
                                __FUNCTION__, context, cop);
    if (socket < 0)
        CMReturnWithString(CMPI_RC_ERR_FAILED,connect_error(addr));
    {
        CMPIStatus rc;
        CMPIArray *r;
        rc = (__sft)->deserialize_CMPIStatus(socket, cThis->broker);
        r = (__sft)->deserialize_CMPIArray(socket, cThis->broker);
        close(socket);
        remove_context(ctxid);
        socketcomm_array2result(r, result);
        return rc;
    };
}
 bool end_transaction () {
     if (!in_transaction_)
         return false;
     in_transaction_ = false;
     save_context();
     return true;
 }
Esempio n. 5
0
/**********************************************************************
 *		ill_handler
 *
 * Handler for SIGILL.
 */
static void ill_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
{
    EXCEPTION_RECORD rec;
    CONTEXT context;

    switch ( info->si_code )
    {
    default:
    case ILL_ILLOPC:
    case ILL_ILLOPN:
    case ILL_ILLADR:
    case ILL_ILLTRP:
        rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
        break;

    case ILL_PRVOPC:
    case ILL_PRVREG:
        rec.ExceptionCode = EXCEPTION_PRIV_INSTRUCTION;
        break;

    case ILL_BADSTK:
        rec.ExceptionCode = EXCEPTION_STACK_OVERFLOW;
        break;
    }

    save_context( &context, ucontext );
    rec.ExceptionRecord  = NULL;
    rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
    rec.ExceptionAddress = (LPVOID)context.pc;
    rec.NumberParameters = 0;
    __regs_RtlRaiseException( &rec, &context );
    restore_context( &context, ucontext );
}
Esempio n. 6
0
static CMPIStatus TCPCOMM_AssociationMI_references(provider_address * addr,
        RemoteCMPIAssociationMI * cThis,
        CONST CMPIContext * context,
        CONST CMPIResult * result,
        CONST CMPIObjectPath * cop,
        const char *assocclass,
        const char *role,
        CONST char **props)
{
    int socket;
    unsigned long int ctxid = save_context(context);
    TRACE_NORMAL(("Executing remote MI call."));
    CMAddContextEntry(context, RCMPI_CTX_ID, &ctxid, CMPI_uint32);
    socket = __provider_connect(addr, cThis->provider, &cThis->ticket,
                                __FUNCTION__, context, cop);
    if (socket < 0)
        CMReturnWithString(CMPI_RC_ERR_FAILED,connect_error(addr));
    (__sft)->serialize_string(socket, assocclass);
    (__sft)->serialize_string(socket, role);
    socketcomm_serialize_props(socket, (__sft), (char **)props);
    {
        CMPIStatus rc;
        CMPIArray *r;
        rc = (__sft)->deserialize_CMPIStatus(socket, cThis->broker);
        r = (__sft)->deserialize_CMPIArray(socket, cThis->broker);
        close(socket);
        remove_context(ctxid);
        socketcomm_array2result(r, result);
        return rc;
    };
}
Esempio n. 7
0
  void PendSV_Handler( void )
  {
    static unsigned stackPointer = 0;

    stackPointer = save_context();
    stackPointer = cHwRTOS_MCU::schedule( stackPointer, false );
    load_context( stackPointer );
  }
Esempio n. 8
0
__attribute__((naked))void PendSV_Handler(void)
{
    save_context();
    /* call scheduler update fk_thread variable with pdc of next thread  */
    asm("bl sched_run");
    /* the thread that has higest priority and is in PENDING state */
    restore_context();
}
Esempio n. 9
0
File: atom.c Progetto: A-L-E-X/RIOT
void SVC_Handler(void)
{
    save_context();
    asm("bl sched_run");
    /* call scheduler update sched_active_thread variable with pdc of next thread
     * the thread that has higest priority and is in PENDING state */
    restore_context();
}
Esempio n. 10
0
/**********************************************************************
 *		usr1_handler
 *
 * Handler for SIGUSR1, used to signal a thread that it got suspended.
 */
static HANDLER_DEF(usr1_handler)
{
    CONTEXT context;

    save_context( &context, HANDLER_CONTEXT );
    wait_suspend( &context );
    restore_context( &context, HANDLER_CONTEXT );
}
Esempio n. 11
0
  void SysTick_Handler( void )
  {
    static unsigned stackPointer = 0;

    stackPointer = save_context();
    cHwRTOS_MCU::sysTic++;
    stackPointer = cHwRTOS_MCU::schedule( stackPointer, true );
    load_context( stackPointer );
  }
Esempio n. 12
0
void c_prepare_catch(error_context_t *  econ) {
    if (!save_context(econ))
	error("Can't catch too deep recursion error.\n");
    push_control_stack(FRAME_CATCH);
#if defined(DEBUG) || defined(TRACE_CODE)
    csp->num_local_variables = (csp - 1)->num_local_variables;	/* marion */
#endif
    assign_svalue(&catch_value, &const1);
}
Esempio n. 13
0
/* New version used when not in -o mode. The epilog() in master.c is
 * supposed to return an array of files (castles in 2.4.5) to load. The array
 * returned by apply() will be freed at next call of apply(), which means that
 * the ref count has to be incremented to protect against deallocation.
 *
 * The master object is asked to do the actual loading.
 */
void preload_objects (int eflag)
{
    VOLATILE array_t *prefiles;
    svalue_t *ret;
    VOLATILE int ix;
    error_context_t econ;

    save_context(&econ);
    if (SETJMP(econ.context)) {
        restore_context(&econ);
        pop_context(&econ);
        return;
    }
    push_number(eflag);
    ret = apply_master_ob(APPLY_EPILOG, 1);
    pop_context(&econ);
    if ((ret == 0) || (ret == (svalue_t *)-1) || (ret->type != T_ARRAY))
        return;
    else
        prefiles = ret->u.arr;
    if ((prefiles == 0) || (prefiles->size < 1))
        return;

    debug_message("\nLoading preloaded files ...\n");
    prefiles->ref++;
    ix = 0;
    /* in case of an error, effectively do a 'continue' */
    save_context(&econ);
    if (SETJMP(econ.context)) {
        restore_context(&econ);
        ix++;
    }
    for ( ; ix < prefiles->size; ix++) {
        if (prefiles->item[ix].type != T_STRING)
            continue;

        set_eval(max_cost);

        push_svalue(((array_t *)prefiles)->item + ix);
        (void) apply_master_ob(APPLY_PRELOAD, 1);
    }
    free_array((array_t *)prefiles);
    pop_context(&econ);
}       /* preload_objects() */
Esempio n. 14
0
bool persist_file_context::set_var(const std::string &global,const config &val, bool immediate)
{
//	if (cfg_.empty()) {
//		load_persist_data(namespace_,cfg_);
//	}
	config bak;
	config bactive;
	if (immediate) {
		bak = cfg_;
		bactive = active_->cfg_.child_or_add("variables");
		load();
		root_node_.init();
	}

	config &cfg = active_->cfg_.child_or_add("variables");
	if (val.has_attribute(global)) {
		if (val[global].empty()) {
			clear_var(global,immediate);
		} else {
			cfg[global] = val[global];
			if (immediate) bactive[global] = val[global];
		}
	} else {
		cfg.clear_children(global);
		cfg.append(val);
		if (immediate) {
			bactive.clear_children(global);
			bactive.append(val);
		}
	}
//	dirty_ = true;
	if (!in_transaction_)
		return save_context();
	else if (immediate) {
		bool ret = save_context();
		cfg_ = bak;
		root_node_.init();
		active_->cfg_.clear_children("variables");
		active_->cfg_.remove_attribute("variables");
		active_->cfg_.add_child("variables",bactive);
		return ret;
	} else
		return true;
}
Esempio n. 15
0
static void TCPCOMM_prepareAttachThread(int socket, CONST CMPIBroker * broker,
                                        CONST CMPIContext * context)
{
    CMPIContext *ctx;
    unsigned long int ctx_id;
    ctx = CBPrepareAttachThread(broker, context);
    ctx_id = save_context(ctx);
    CMAddContextEntry(ctx, RCMPI_CTX_ID, &ctx_id, CMPI_uint32);
    socketcomm_serialize_context(socket, (__sft), ctx);
}
Esempio n. 16
0
/* we need to expose the update to be able to complete the reset at SoC level */
int lakemont_update_after_probemode_entry(struct target *t)
{
	if (save_context(t) != ERROR_OK)
		return ERROR_FAIL;
	if (halt_prep(t) != ERROR_OK)
		return ERROR_FAIL;
	t->state = TARGET_HALTED;

	return target_call_event_callbacks(t, TARGET_EVENT_HALTED);
}
Esempio n. 17
0
	static int find_column_number(
		const Data& data,
		const shared<meta_parameter>& param,
		const polymorph_factory_context& context
	)
	{
		return data.find_column(
			save_context(context),
			param->position()
		);
	}
Esempio n. 18
0
/**********************************************************************
 *		abrt_handler
 *
 * Handler for SIGABRT.
 */
static HANDLER_DEF(abrt_handler)
{
    EXCEPTION_RECORD rec;
    CONTEXT context;

    save_context( &context, HANDLER_CONTEXT );
    rec.ExceptionCode    = EXCEPTION_WINE_ASSERTION;
    rec.ExceptionFlags   = EH_NONCONTINUABLE;
    rec.ExceptionRecord  = NULL;
    rec.ExceptionAddress = (LPVOID)context.pc;
    rec.NumberParameters = 0;
    __regs_RtlRaiseException( &rec, &context ); /* Should never return.. */
    restore_context( &context, HANDLER_CONTEXT );
}
Esempio n. 19
0
/**********************************************************************
 *		int_handler
 *
 * Handler for SIGINT.
 */
static void int_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
{
    if (!dispatch_signal(SIGINT))
    {
        EXCEPTION_RECORD rec;
        CONTEXT context;

        save_context( &context, ucontext );
        rec.ExceptionCode    = CONTROL_C_EXIT;
        rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
        rec.ExceptionRecord  = NULL;
        rec.ExceptionAddress = (LPVOID)context.pc;
        rec.NumberParameters = 0;
        __regs_RtlRaiseException( &rec, &context );
        restore_context( &context, ucontext );
    }
}
//----------------------------------------------------------------------------------------------------//
//  @func - suspend
//! @desc 
//!   Suspend a process inside the kernel. A rescheduling followed by the corresponding context
//!   switch occurs within this routine.
//! @return
//!   - Nothing
//! @note
//!   - This routine is not expected to be invoked from within an ISR. i.e no suspension allowed in
//!     an ISR.
//----------------------------------------------------------------------------------------------------//
void suspend () 
{
#ifdef CONFIG_STATS
    current_process->active_ticks++;
    budget_ticks++;
#endif
    if (scheduler ()) {
	DBG_PRINT ("XMK: Scheduling error. Cannot suspend current process.\r\n");
	while (1)
	    ;
    }

    if (ctx_save_process != NULL) 
	if (save_context (ctx_save_process))    // Save context returns 0 during save
	    return;                             // When saved context is restored, returns a 1
    
    restore_context ();
}
Esempio n. 21
0
void asmlinkage save_context_sysenter(struct context *context)
{
    // Setup context
    context->esp = context->ecx;
    context->eip = context->edx;
    
    context->ss = GDT_SELECTOR_DATA_U;
    context->cs = GDT_SELECTOR_CODE_U;
    
    context->eflags = 0x200202;
    
    // Make sure we are in user mode
    int user_mode = *get_per_cpu(int, cur_in_user_mode);
    assert(user_mode);
    
    // Call the regular context save function
    save_context(context);
}
Esempio n. 22
0
/**********************************************************************
 *		fpe_handler
 *
 * Handler for SIGFPE.
 */
static void fpe_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
{
    EXCEPTION_RECORD rec;
    CONTEXT context;

    switch ( info->si_code )
    {
    case FPE_FLTSUB:
        rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
        break;
    case FPE_INTDIV:
        rec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO;
        break;
    case FPE_INTOVF:
        rec.ExceptionCode = EXCEPTION_INT_OVERFLOW;
        break;
    case FPE_FLTDIV:
        rec.ExceptionCode = EXCEPTION_FLT_DIVIDE_BY_ZERO;
        break;
    case FPE_FLTOVF:
        rec.ExceptionCode = EXCEPTION_FLT_OVERFLOW;
        break;
    case FPE_FLTUND:
        rec.ExceptionCode = EXCEPTION_FLT_UNDERFLOW;
        break;
    case FPE_FLTRES:
        rec.ExceptionCode = EXCEPTION_FLT_INEXACT_RESULT;
        break;
    case FPE_FLTINV:
    default:
        rec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION;
        break;
    }

    save_context( &context, ucontext );
    save_fpu( &context, ucontext );
    rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
    rec.ExceptionRecord  = NULL;
    rec.ExceptionAddress = (LPVOID)context.pc;
    rec.NumberParameters = 0;
    __regs_RtlRaiseException( &rec, &context );
    restore_context( &context, ucontext );
    restore_fpu( &context, ucontext );
}
Esempio n. 23
0
/**********************************************************************
 *		bus_handler
 *
 * Handler for SIGBUS.
 */
static void bus_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
{
    EXCEPTION_RECORD rec;
    CONTEXT context;

    save_context( &context, ucontext );
    rec.ExceptionRecord  = NULL;
    rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
    rec.ExceptionAddress = (LPVOID)context.pc;
    rec.NumberParameters = 0;

    if ( info->si_code == BUS_ADRALN )
        rec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT;
    else
        rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;

    __regs_RtlRaiseException( &rec, &context );
    restore_context( &context, ucontext );
}
Esempio n. 24
0
svalue_t *
safe_call_function_pointer (funptr_t * funp, int num_arg)
{
    error_context_t econ;
    svalue_t *ret;

    if (!save_context(&econ))
        return 0;
    if (!SETJMP(econ.context)) {
        ret = call_function_pointer(funp, num_arg);
    } else {
        restore_context(&econ);
        /* condition was restored to where it was when we came in */
        pop_n_elems(num_arg);
        ret = 0;
    }
    pop_context(&econ);
    return ret;
}
Esempio n. 25
0
/**********************************************************************
 *		segv_handler
 *
 * Handler for SIGSEGV.
 */
static void segv_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
{
    EXCEPTION_RECORD rec;
    CONTEXT context;

    /* we want the page-fault case to be fast */
    if ( info->si_code == SEGV_ACCERR )
        if (VIRTUAL_HandleFault( (LPVOID)info->si_addr )) return;

    save_context( &context, ucontext );
    rec.ExceptionCode    = EXCEPTION_ACCESS_VIOLATION;
    rec.ExceptionRecord  = NULL;
    rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
    rec.ExceptionAddress = (LPVOID)context.pc;
    rec.NumberParameters = 2;
    rec.ExceptionInformation[0] = 0;  /* FIXME: read/write access ? */
    rec.ExceptionInformation[1] = (ULONG_PTR)info->si_addr;

    __regs_RtlRaiseException( &rec, &context );
    restore_context( &context, ucontext );
}
Esempio n. 26
0
/**********************************************************************
 *		trap_handler
 *
 * Handler for SIGTRAP.
 */
static void trap_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
{
    EXCEPTION_RECORD rec;
    CONTEXT context;

    switch ( info->si_code )
    {
    case TRAP_TRACE:
        rec.ExceptionCode = EXCEPTION_SINGLE_STEP;
        break;
    case TRAP_BRKPT:
    default:
        rec.ExceptionCode = EXCEPTION_BREAKPOINT;
        break;
    }

    save_context( &context, ucontext );
    rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
    rec.ExceptionRecord  = NULL;
    rec.ExceptionAddress = (LPVOID)context.pc;
    rec.NumberParameters = 0;
    __regs_RtlRaiseException( &rec, &context );
    restore_context( &context, ucontext );
}
Esempio n. 27
0
int main P2(int, argc, char **, argv)
{
    time_t tm;
    int i, new_mudlib = 0, got_defaults = 0;
    int no_ip_demon = 0;
    char *p;
    char version_buf[80];
#if 0
    int dtablesize;
#endif
    error_context_t econ;

#if !defined(LATTICE) && !defined(OLD_ULTRIX) && !defined(sequent) && \
    !defined(sgi)
    void tzset();
#endif
    struct lpc_predef_s predefs;

#if !defined(__SASC) && (defined(AMITCP) || defined(AS225))
    amiga_sockinit();
    atexit(amiga_sockexit);
#endif
#ifdef WRAPPEDMALLOC
    wrappedmalloc_init();
#endif				/* WRAPPEDMALLOC */
#ifdef DEBUGMALLOC
    MDinit();
#endif

#if (defined(PROFILING) && !defined(PROFILE_ON) && defined(HAS_MONCONTROL))
    moncontrol(0);
#endif
#if !defined(OLD_ULTRIX) && !defined(LATTICE) && !defined(sequent)
    tzset();
#endif
    boot_time = get_current_time();

    const0.type = T_NUMBER;
    const0.u.number = 0;
    const1.type = T_NUMBER;
    const1.u.number = 1;

    /* const0u used by undefinedp() */
    const0u.type = T_NUMBER;
    const0u.subtype = T_UNDEFINED;
    const0u.u.number = 0;

    /* const0n used by nullp() */
    const0n.type = T_NUMBER;
    const0n.subtype = T_NULLVALUE;
    const0n.u.number = 0;

    fake_prog.program_size = 0;

    /*
     * Check that the definition of EXTRACT_UCHAR() is correct.
     */
    p = (char *) &i;
    *p = -10;
    if (EXTRACT_UCHAR(p) != 0x100 - 10) {
	fprintf(stderr, "Bad definition of EXTRACT_UCHAR() in interpret.h.\n");
	exit(-1);
    }

    /*
     * An added test: can we do EXTRACT_UCHAR(x++)?
     * (read_number, etc uses it)
     */
    p = (char *) &i;
    (void) EXTRACT_UCHAR(p++);
    if ((p - (char *) &i) != 1) {
	fprintf(stderr, "EXTRACT_UCHAR() in interpret.h evaluates its argument more than once.\n");
	exit(-1);
    }

    /*
     * Check the living hash table size
     */
    if (CFG_LIVING_HASH_SIZE != 4 && CFG_LIVING_HASH_SIZE != 16 &&
	CFG_LIVING_HASH_SIZE != 64 && CFG_LIVING_HASH_SIZE != 256 &&
	CFG_LIVING_HASH_SIZE != 1024 && CFG_LIVING_HASH_SIZE != 4096) {
	fprintf(stderr, "CFG_LIVING_HASH_SIZE in options.h must be one of 4, 16, 64, 256, 1024, 4096, ...\n");
	exit(-1);
    }

#ifdef RAND
    srand(get_current_time());
#else
#  ifdef DRAND48
    srand48(get_current_time());
#  else
#    ifdef RANDOM
    srandom(get_current_time());
#    else
    fprintf(stderr, "Warning: no random number generator specified!\n");
#    endif
#  endif
#endif
    current_time = get_current_time();
    /*
     * Initialize the microsecond clock.
     */
    init_usec_clock();

    /* read in the configuration file */

    got_defaults = 0;
    for (i = 1; (i < argc) && !got_defaults; i++) {
	if (argv[i][0] != '-') {
	    set_defaults(argv[i]);
	    got_defaults = 1;
	}
    }
    if (!got_defaults) {
	fprintf(stderr, "You must specify the configuration filename as an argument.\n");
	exit(-1);
    }

    printf("Initializing internal tables....\n");
    init_strings();		/* in stralloc.c */
    init_otable();		/* in otable.c */
    init_identifiers();		/* in lex.c */
    init_locals();              /* in compiler.c */

/* disable this for now */
#if 0
    /*
     * We estimate that we will need MAX_USERS + MAX_EFUN_SOCKS + 10 file
     * descriptors if the maximum number of users were to log in and all LPC
     * sockets were in use.  This is a pretty close estimate.
     */
#ifndef LATTICE
    dtablesize = MAX_USERS + MAX_EFUN_SOCKS + 10;
#else
    /*
     * Amiga sockets separate from file descriptors
     */
    dtablesize = MAX_USERS + MAX_EFUN_SOCKS;
#endif

    /*
     * If our estimate is larger than FD_SETSIZE, then we need more file
     * descriptors than the operating system can handle.  This is a problem
     * that can be resolved by decreasing MAX_USERS, MAX_EFUN_SOCKS, or both.
     */
    if (dtablesize > FD_SETSIZE) {
	fprintf(stderr, "Warning: File descriptor requirements exceed system capacity!\n");
	fprintf(stderr, "         Configuration exceeds system capacity by %d descriptor(s).\n",
		dtablesize - FD_SETSIZE);
    }
#ifdef HAS_SETDTABLESIZE
    /*
     * If the operating system supports setdtablesize() then we can request
     * the number of file descriptors we really need.  First check to see if
     * wee already have enough.  If so dont bother the OS. If not, attempt to
     * allocate the number we estimated above.  There are system imposed
     * limits on file descriptors, so we may not get as many as we asked for.
     * Check to make sure we get enough.
     */
    if (getdtablesize() < dtablesize)
	if (setdtablesize(dtablesize) < dtablesize) {
	    fprintf(stderr, "Warning: Could not allocate enough file descriptors!\n");
	    fprintf(stderr, "         setdtablesize() could not allocate %d descriptor(s).\n",
		    getdtablesize() - dtablesize);
	}
    /*
     * Just be polite and tell the administrator how many he has.
     */
    fprintf(stderr, "%d file descriptors were allocated, (%d were requested).\n",
	    getdtablesize(), dtablesize);
#endif
#endif
    time_to_clean_up = TIME_TO_CLEAN_UP;
    time_to_swap = TIME_TO_SWAP;
    max_cost = MAX_COST;
    reserved_size = RESERVED_SIZE;
    max_array_size = MAX_ARRAY_SIZE;
    max_buffer_size = MAX_BUFFER_SIZE;
    max_string_length = MAX_STRING_LENGTH;
    master_file_name = (char *) MASTER_FILE;
    /* fix the filename */
    while (*master_file_name == '/') master_file_name++;
    p = master_file_name;
    while (*p++);
    if (p[-2]=='c' && p[-3]=='.')
	p[-3]=0;
    mud_lib = (char *) MUD_LIB;
    set_inc_list(INCLUDE_DIRS);
    if (reserved_size > 0)
	reserved_area = (char *) DMALLOC(reserved_size, TAG_RESERVED, "main.c: reserved_area");
    for (i = 0; i < sizeof consts / sizeof consts[0]; i++)
	consts[i] = exp(-i / 900.0);
    init_num_args();
    reset_machine(1);
    /*
     * The flags are parsed twice ! The first time, we only search for the -m
     * flag, which specifies another mudlib, and the D-flags, so that they
     * will be available when compiling master.c.
     */
    for (i = 1; i < argc; i++) {
	if (argv[i][0] != '-')
	    continue;
	switch (argv[i][1]) {
	case 'D':
	    if (argv[i][2]) {	/* Amylaar : allow flags to be passed down to
				 * the LPC preprocessor */
		struct lpc_predef_s *tmp;

		tmp = &predefs;
		tmp->flag = argv[i] + 2;
		tmp->next = lpc_predefs;
		lpc_predefs = tmp;
		continue;
	    }
	    fprintf(stderr, "Illegal flag syntax: %s\n", argv[i]);
	    exit(-1);
	case 'N':
	    no_ip_demon++;
	    continue;
#ifdef YYDEBUG
	case 'y':
	    yydebug = 1;
	    continue;
#endif				/* YYDEBUG */
	case 'm':
	    mud_lib = alloc_cstring(argv[i] + 2, "mudlib dir");
	    if (chdir(mud_lib) == -1) {
		fprintf(stderr, "Bad mudlib directory: %s\n", mud_lib);
		exit(-1);
	    }
	    new_mudlib = 1;
	    break;
	}
    }
    if (!new_mudlib && chdir(mud_lib) == -1) {
	fprintf(stderr, "Bad mudlib directory: %s\n", mud_lib);
	exit(-1);
    }
    get_version(version_buf);
    time(&tm);
    debug_message("----------------------------------------------------------------------------\n%s (%s) starting up on %s - %s\n\n", MUD_NAME, version_buf, ARCH, ctime(&tm));

#ifdef BINARIES
    init_binaries(argc, argv);
#endif
#ifdef LPC_TO_C
    init_lpc_to_c();
#endif
    add_predefines();

#ifndef NO_IP_DEMON
    if (!no_ip_demon && ADDR_SERVER_IP)
	init_addr_server(ADDR_SERVER_IP, ADDR_SERVER_PORT);
#endif				/* NO_IP_DEMON */

    eval_cost = max_cost;	/* needed for create() functions */

    save_context(&econ);
    if (SETJMP(econ.context)) {
	debug_message("The simul_efun (%s) and master (%s) objects must be loadable.\n", 
		      SIMUL_EFUN, MASTER_FILE);
	exit(-1);
    } else {
	init_simul_efun(SIMUL_EFUN);
	init_master(MASTER_FILE);
    }
    pop_context(&econ);

    for (i = 1; i < argc; i++) {
	if (argv[i][0] != '-') {
	    continue;
	} else {
	    /*
	     * Look at flags. -m and -o has already been tested.
	     */
	    switch (argv[i][1]) {
	    case 'D':
	    case 'N':
	    case 'm':
	    case 'y':
		continue;
	    case 'f':
		save_context(&econ);
		if (SETJMP(econ.context)) {
		    debug_message("Error while calling master::flag(\"%s\"), aborting ...", argv[i] + 2);
		    exit(-1);
		}
		push_constant_string(argv[i] + 2);
		(void) apply_master_ob(APPLY_FLAG, 1);
		if (MudOS_is_being_shut_down) {
		    debug_message("Shutdown by master object.\n");
		    exit(0);
		}
		pop_context(&econ);
		continue;
	    case 'e':
		e_flag++;
		continue;
	    case 'p':
		external_port[0].port = atoi(argv[i] + 2);
		continue;
            case 'd':
#ifdef DEBUG
                d_flag++;
#else
                debug_message("Driver must be compiled with DEBUG on to use -d.\n");
#endif
	    case 'c':
		comp_flag++;
		continue;
	    case 't':
		t_flag++;
		continue;
	    default:
		debug_message("Unknown flag: %s\n", argv[i]);
		exit(-1);
	    }
	}
    }
    if (MudOS_is_being_shut_down)
	exit(1);
    if (strlen(DEFAULT_FAIL_MESSAGE))
	default_fail_message = DEFAULT_FAIL_MESSAGE;
    else
	default_fail_message = "What?";
#ifdef PACKAGE_MUDLIB_STATS
    restore_stat_files();
#endif
#ifdef PACKAGE_SOCKETS
    init_sockets();		/* initialize efun sockets           */
#endif
    preload_objects(e_flag);
#ifdef SIGFPE
    signal(SIGFPE, sig_fpe);
#endif
#ifdef TRAP_CRASHES
#ifdef SIGUSR1
    signal(SIGUSR1, sig_usr1);
#endif
    signal(SIGTERM, sig_term);
    signal(SIGINT, sig_int);
#ifndef DEBUG
#if defined(SIGABRT) && !defined(LATTICE)
    signal(SIGABRT, sig_abrt);
#endif
#ifdef SIGIOT
    signal(SIGIOT, sig_iot);
#endif
#ifdef SIGHUP
    signal(SIGHUP, sig_hup);
#endif
#ifdef SIGBUS
    signal(SIGBUS, sig_bus);
#endif
#ifndef LATTICE
    signal(SIGSEGV, sig_segv);
    signal(SIGILL, sig_ill);
#endif
#endif				/* DEBUG */
#endif
    backend();
    return 0;
}
Esempio n. 28
0
bool persist_file_context::clear_var(const std::string &global, bool immediate)
{
//	if (cfg_.empty()) {
//		load_persist_data(namespace_.root(),cfg_);
//	}

	config bak;
	config bactive;
	if (immediate) {
		bak = cfg_;
		bactive = active_->cfg_.child_or_add("variables");
		load();
		root_node_.init();
	}
	config &cfg = active_->cfg_.child_or_add("variables");
	bool ret(cfg);
	if (ret) {
		bool exists = cfg.has_attribute(global);
		if (!exists) {
			if (cfg.child(global)) {
				exists = true;
				std::string::const_iterator index_start = std::find(global.begin(),global.end(),'[');
				if (index_start != global.end())
				{
					const std::string::const_iterator index_end = std::find(global.begin(),global.end(),']');
					const std::string index_str(index_start+1,index_end);
					size_t index = static_cast<size_t>(lexical_cast_default<int>(index_str));
					cfg.remove_child(global,index);
					if (immediate) bactive.remove_child(global,index);
				} else {
					cfg.clear_children(global);
					if (immediate) bactive.clear_children(global);
				}
			}
		}
		if (exists) {
			cfg.remove_attribute(global);
			if (immediate) bactive.remove_attribute(global);
			if (cfg.empty()) {
				active_->cfg_.clear_children("variables");
				active_->cfg_.remove_attribute("variables");
				while ((active_->cfg_.empty()) && (active_->parent_ != NULL)) {
					active_ = active_->parent_;
					active_->remove_child(namespace_.node_);
					namespace_ = namespace_.prev();
				}
			}
	//		dirty_ = true;
			if (!in_transaction_)
				ret = save_context();
			else if (immediate) {
				ret = save_context();
				cfg_ = bak;
				root_node_.init();
				active_->cfg_.clear_children("variables");
				active_->cfg_.remove_attribute("variables");
				active_->cfg_.add_child("variables",bactive);
				config &cfg = active_->cfg_.child("variables");
				if (cfg.empty()) {
					active_->cfg_.clear_children("variables");
					active_->cfg_.remove_attribute("variables");
					while ((active_->cfg_.empty()) && (active_->parent_ != NULL)) {
						active_ = active_->parent_;
						active_->remove_child(namespace_.node_);
						namespace_ = namespace_.prev();
					}
				}
			} else
				ret = true;
		} else {
			ret = exists;
		}
	}
	return ret;
}
Esempio n. 29
0
int main (int argc, char ** argv)
{
    time_t tm;
    int i, new_mudlib = 0, got_defaults = 0;
    char *p;
    char version_buf[80];
#if 0
    int dtablesize;
#endif
    error_context_t econ;

#ifdef PROTO_TZSET
    void tzset();
#endif

#ifdef INCL_LOCALE_H
    setlocale(LC_ALL, "C");
#endif

#if !defined(__SASC) && (defined(AMITCP) || defined(AS225))
    amiga_sockinit();
    atexit(amiga_sockexit);
#endif
#ifdef WRAPPEDMALLOC
    wrappedmalloc_init();
#endif        /* WRAPPEDMALLOC */
#ifdef DEBUGMALLOC
    MDinit();
#endif

#if (defined(PROFILING) && !defined(PROFILE_ON) && defined(HAS_MONCONTROL))
    moncontrol(0);
#endif
#ifdef USE_TZSET
    tzset();
#endif
    boot_time = get_current_time();

    const0.type = T_NUMBER;
    const0.u.number = 0;
    const1.type = T_NUMBER;
    const1.u.number = 1;

    /* const0u used by undefinedp() */
    const0u.type = T_NUMBER;
    const0u.subtype = T_UNDEFINED;
    const0u.u.number = 0;

    //fake_prog.program_size = 0; //0 anyway

    /*
     * Check that the definition of EXTRACT_UCHAR() is correct.
     */
    p = (char *) &i;
    *p = -10;
    if (EXTRACT_UCHAR(p) != 0x100 - 10) {
        fprintf(stderr, "Bad definition of EXTRACT_UCHAR() in interpret.h.\n");
        exit(-1);
    }

    /*
     * An added test: can we do EXTRACT_UCHAR(x++)?
     * (read_number, etc uses it)
     */
    p = (char *) &i;
    (void) EXTRACT_UCHAR(p++);
    if ((p - (char *) &i) != 1) {
        fprintf(stderr, "EXTRACT_UCHAR() in interpret.h evaluates its argument more than once.\n");
        exit(-1);
    }

    /*
     * Check the living hash table size
     */
    if (CFG_LIVING_HASH_SIZE != 4 && CFG_LIVING_HASH_SIZE != 16 &&
            CFG_LIVING_HASH_SIZE != 64 && CFG_LIVING_HASH_SIZE != 256 &&
            CFG_LIVING_HASH_SIZE != 1024 && CFG_LIVING_HASH_SIZE != 4096) {
        fprintf(stderr, "CFG_LIVING_HASH_SIZE in options.h must be one of 4, 16, 64, 256, 1024, 4096, ...\n");
        exit(-1);
    }

#ifdef RAND
    srand(get_current_time());
#else
#  ifdef DRAND48
    srand48(get_current_time());
#  else
#    ifdef RANDOM
    srandom(get_current_time());
#    else
    fprintf(stderr, "Warning: no random number generator specified!\n");
#    endif
#  endif
#endif
    current_time = get_current_time();
    /*
     * Initialize the microsecond clock.
     */
    init_usec_clock();

    /* read in the configuration file */

    got_defaults = 0;
    for (i = 1; (i < argc) && !got_defaults; i++) {
        if (argv[i][0] != '-') {
            set_defaults(argv[i]);
            got_defaults = 1;
        }
    }
    get_version(version_buf);
    if (!got_defaults) {
        fprintf(stderr, "%s for %s.\n", version_buf, ARCH);
        fprintf(stderr, "You must specify the configuration filename as an argument.\n");
        exit(-1);
    }

    printf("Initializing internal tables....\n");
    init_strings();   /* in stralloc.c */
    init_otable();    /* in otable.c */
    init_identifiers();   /* in lex.c */
    init_locals();              /* in compiler.c */

    /*
     * If our estimate is larger than FD_SETSIZE, then we need more file
     * descriptors than the operating system can handle.  This is a problem
     * that can be resolved by decreasing MAX_USERS, MAX_EFUN_SOCKS, or both.
     *
     * Unfortunately, since neither MAX_USERS or MAX_EFUN_SOCKS exist any more,
     * we have no clue how many we will need.  This code really should be
     * moved to places where ENFILE/EMFILE is returned.
     */
#if 0
    if (dtablesize > FD_SETSIZE) {
        fprintf(stderr, "Warning: File descriptor requirements exceed system capacity!\n");
        fprintf(stderr, "         Configuration exceeds system capacity by %d descriptor(s).\n",
                dtablesize - FD_SETSIZE);
    }
#ifdef HAS_SETDTABLESIZE
    /*
     * If the operating system supports setdtablesize() then we can request
     * the number of file descriptors we really need.  First check to see if
     * wee already have enough.  If so dont bother the OS. If not, attempt to
     * allocate the number we estimated above.  There are system imposed
     * limits on file descriptors, so we may not get as many as we asked for.
     * Check to make sure we get enough.
     */
    if (getdtablesize() < dtablesize)
        if (setdtablesize(dtablesize) < dtablesize) {
            fprintf(stderr, "Warning: Could not allocate enough file descriptors!\n");
            fprintf(stderr, "         setdtablesize() could not allocate %d descriptor(s).\n",
                    getdtablesize() - dtablesize);
        }
    /*
     * Just be polite and tell the administrator how many he has.
     */
    fprintf(stderr, "%d file descriptors were allocated, (%d were requested).\n",
            getdtablesize(), dtablesize);
#endif
#endif
    time_to_clean_up = TIME_TO_CLEAN_UP;
    max_cost = MAX_COST;
    reserved_size = RESERVED_SIZE;
    max_array_size = MAX_ARRAY_SIZE;
    if(max_array_size > 65535){
        fprintf(stderr, "Maximum array size can not exceed 65535");
        max_array_size = 65535;
    }
    max_buffer_size = MAX_BUFFER_SIZE;
    max_string_length = MAX_STRING_LENGTH;
    mud_lib = (char *) MUD_LIB;
    set_inc_list(INCLUDE_DIRS);
    if (reserved_size > 0)
        reserved_area = (char *) DMALLOC(reserved_size, TAG_RESERVED, "main.c: reserved_area");
    for (i = 0; i < sizeof consts / sizeof consts[0]; i++)
        consts[i] = exp(-i / 900.0);
    reset_machine(1);
    /*
     * The flags are parsed twice ! The first time, we only search for the -m
     * flag, which specifies another mudlib, and the D-flags, so that they
     * will be available when compiling master.c.
     */
    for (i = 1; i < argc; i++) {
        if (argv[i][0] != '-')
            continue;
        switch (argv[i][1]) {
            case 'D':
                if (argv[i][2]) {
                    lpc_predef_t *tmp = ALLOCATE(lpc_predef_t, TAG_PREDEFINES,
                            "predef");
                    tmp->flag = argv[i] + 2;
                    tmp->next = lpc_predefs;
                    lpc_predefs = tmp;
                    continue;
                }
                fprintf(stderr, "Illegal flag syntax: %s\n", argv[i]);
                exit(-1);
            case 'N':
                no_ip_demon++;
                continue;
#ifdef HAS_CONSOLE
            case 'C':
                has_console = 1;
                continue;
#endif
#ifdef YYDEBUG
            case 'y':
                yydebug = 1;
                continue;
#endif        /* YYDEBUG */
            case 'm':
                mud_lib = alloc_cstring(argv[i] + 2, "mudlib dir");
                if (chdir(mud_lib) == -1) {
                    fprintf(stderr, "Bad mudlib directory: %s\n", mud_lib);
                    exit(-1);
                }
                new_mudlib = 1;
                break;
        }
    }
    if (!new_mudlib && chdir(mud_lib) == -1) {
        fprintf(stderr, "Bad mudlib directory: %s\n", mud_lib);
        exit(-1);
    }
    time(&tm);
    debug_message("----------------------------------------------------------------------------\n%s (%s) starting up on %s - %s\n\n", MUD_NAME, version_buf, ARCH, ctime(&tm));

    add_predefines();
#ifdef WIN32
    _tzset();
#endif

#ifndef NO_IP_DEMON
    if (!no_ip_demon && ADDR_SERVER_IP)
        init_addr_server(ADDR_SERVER_IP, ADDR_SERVER_PORT);
#endif        /* NO_IP_DEMON */

    set_eval(max_cost);

    save_context(&econ);
    if (SETJMP(econ.context)) {
        debug_message("The simul_efun (%s) and master (%s) objects must be loadable.\n",
                SIMUL_EFUN, MASTER_FILE);
        exit(-1);
    } else {
        init_simul_efun(SIMUL_EFUN);
        init_master();
    }
    pop_context(&econ);

    for (i = 1; i < argc; i++) {
        if (argv[i][0] != '-') {
            continue;
        } else {
            /*
             * Look at flags. -m and -o has already been tested.
             */
            switch (argv[i][1]) {
                case 'D':
                case 'N':
                case 'm':
                case 'y':
                case 'C':
                    continue;
                case 'f':
                    save_context(&econ);
                    if (SETJMP(econ.context)) {
                        debug_message("Error while calling master::flag(\"%s\"), aborting ...\n", argv[i] + 2);
                        exit(-1);
                    }
                    push_constant_string(argv[i] + 2);
                    apply_master_ob(APPLY_FLAG, 1);
                    if (MudOS_is_being_shut_down) {
                        debug_message("Shutdown by master object.\n");
                        exit(0);
                    }
                    pop_context(&econ);
                    continue;
                case 'e':
                    e_flag++;
                    continue;
                case 'p':
                    external_port[0].port = atoi(argv[i] + 2);
                    continue;
                case 'd':
#ifdef DEBUG_MACRO
                    if (argv[i][2])
                        debug_level_set(&argv[i][2]);
                    else
                        debug_level |= DBG_d_flag;
#else
                    debug_message("Driver must be compiled with DEBUG_MACRO on to use -d.\n");
#endif
                    break;
                case 'c':
                    comp_flag++;
                    continue;
                case 't':
                    t_flag++;
                    continue;
                default:
                    debug_message("Unknown flag: %s\n", argv[i]);
                    exit(-1);
            }
        }
    }
    if (MudOS_is_being_shut_down)
        exit(1);
    if (*(DEFAULT_FAIL_MESSAGE)) {
        char buf[8192];

        strcpy(buf, DEFAULT_FAIL_MESSAGE);
        strcat(buf, "\n");
        default_fail_message = make_shared_string(buf);
    } else
        default_fail_message = "What?\n";
#ifdef PACKAGE_MUDLIB_STATS
    restore_stat_files();
#endif
    preload_objects(e_flag);
#ifdef SIGFPE
    signal(SIGFPE, sig_fpe);
#endif
#ifdef TRAP_CRASHES
#ifdef SIGUSR1
    signal(SIGUSR1, sig_usr1);
#endif
#ifdef SIGUSR2
    signal(SIGUSR2, sig_usr2);
#endif
    signal(SIGTERM, sig_term);
    signal(SIGINT, sig_int);
#ifndef DEBUG
#if defined(SIGABRT)
    signal(SIGABRT, sig_abrt);
#endif
#ifdef SIGIOT
    signal(SIGIOT, sig_iot);
#endif
#ifdef SIGHUP
    signal(SIGHUP, sig_hup);
#endif
#ifdef SIGBUS
    signal(SIGBUS, sig_bus);
#endif
    signal(SIGSEGV, sig_segv);
    signal(SIGILL, sig_ill);
#endif        /* DEBUG */
#endif
#ifndef WIN32
#ifdef USE_BSD_SIGNALS
    signal(SIGCHLD, sig_cld);
#else
    signal(SIGCLD, sig_cld);
#endif
#endif

#ifdef HAS_CONSOLE
    if(has_console >= 0)
        signal(SIGTTIN, sig_ttin);
    signal(SIGTTOU, SIG_IGN);
#endif

    backend();
    return 0;
}
Esempio n. 30
0
MainWindow::MainWindow()
{
    //CREATION DU MENU
    setWindowTitle("CalcUTC");
    this->size_min();
    QMenu *menuOption = menuBar()->addMenu("&Option");
    QAction *actionQuitter = new QAction("&Quitter", this); //AJOUT DE QUITTER
    menuOption->addAction(actionQuitter);
    QAction *actionProgEdit = new QAction("Nouveau programme", this); // Ajout d'une action créer nouveau programme qui ouvre un QEDITTEXT
    menuOption->addAction(actionProgEdit);

    QMenu *menuAffichage = menuBar()->addMenu("&Affichage");
    QAction *actionClavier = new QAction("&Clavier", this);   //OPTION D'AFFICHAGE DU CLAVIER ET DES FONCTIONS SCIENTIFIQUES
    menuAffichage->addAction(actionClavier);
    QAction *actionScientifique = new QAction("&Mode scientifique", this);
    menuAffichage->addAction(actionScientifique);
    QAction *actionProg = new QAction("&Gestion Programme",this);
    menuAffichage->addAction(actionProg);


    QAction *actionRedo = new QAction("&Redo", this);  // AJOUT DU "Redo"
    menuOption->addAction(actionRedo);
    actionRedo->setIcon(QIcon("\\Users\\Adrien\\Documents\\Adrien\\UTC\\GI 02\\LO21\\Projet\\version finale\\projet_1_0\\images/arrow_redo.png"));
    actionRedo->setShortcut(QKeySequence(tr("Ctrl+y")));

    QAction *actionUndo = new QAction("&Undo", this);  // AJOUT DU "Undo"
    menuOption->addAction(actionUndo);
    actionUndo->setIcon(QIcon("\\Users\\Adrien\\Documents\\Adrien\\UTC\\GI 02\\LO21\\Projet\\version finale\\projet_1_0\\images/arrow_undo.png"));
    actionUndo->setShortcut(QKeySequence(tr("Ctrl+z")));

    QMenu *menuAide = menuBar()->addMenu("&Aide");
    QAction *actionAPropos = new QAction("&A propos", this);  // AJOUT DU "A PROPOS"
    menuAide->addAction(actionAPropos);

    // GESTION DES SIGNAUX ET SLOTS DU MENU
    connect(actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
    actionQuitter->setShortcut(QKeySequence("Escape"));
    connect(actionScientifique, SIGNAL(triggered()), this, SLOT(afficher_scientique()));
    connect(actionClavier, SIGNAL(triggered()), this, SLOT(afficher_clavier()));
    actionClavier->setCheckable(true);
    actionScientifique->setCheckable(true);
    // CONNECT DU PROGEDIT

    connect(actionProg,SIGNAL(triggered(bool)), this, SLOT(openProgWindow()));
    connect(actionProgEdit,SIGNAL(triggered()), this, SLOT(openEditProg())); // OUVRE LE QEDITTEXT
    connect(actionAPropos,SIGNAL(triggered(bool)), this, SLOT(afficher_APropos()));


    //INITIALISATION DES OBJETS DU .h
    mainArea = new QWidget;
    mainSet = new QHBoxLayout;
    scientificPad = new scientific_pad;
    scientificPad->hide();


    keyboard = new Keyboard();
    keyboard->hide();
    controlScreen = new QWidget();
    controlScreen->setFixedSize(QSize(280, 300));

    pile = new Pile ;
    qDebug()<<pile;
    controleur = Controleur::getInstance(LiteraleManager::getInstance() , *pile) ;
    message = new QLineEdit() ;
    commande = new QLineEdit() ;
    vuePile = new QTableWidget (pile->getNbItemsToAffiche(),1) ;
    pile_create();
    topLayout = new QHBoxLayout();

    middleLayout = new QHBoxLayout();
    boutons_droits = new QVBoxLayout();

    bottomLayout = new QHBoxLayout();
    pile_plus = new QPushButton();
    pile_moins = new QPushButton();
    enter = new QPushButton();

    leftLayout = new QVBoxLayout();
    leftLayout->addWidget(vuePile);
    vuePile->setStyleSheet("background : rgba(35,141,214,45)");

    commande->setStyleSheet("background : rgba(35,141,214,45)");
    //MIDDLELAYOUT SETTINGS

    middleLayout->addLayout(leftLayout);
    middleLayout->addLayout(boutons_droits);

    boutons_droits->addWidget(pile_plus);
    boutons_droits->addWidget(pile_moins);

    //BOTTOM LAYOUT SETTINGS

    bottomLayout->addWidget(commande);
    bottomLayout->addWidget(enter);
    enter->setIcon(QIcon("\\Users\\Adrien\\Documents\\Adrien\\UTC\\GI 02\\LO21\\Projet\\version finale\\projet_1_0\\images/enter-arrow.png"));
    enter->setFlat(true);
    enter->setFocusPolicy(Qt::NoFocus);

    connect(enter,SIGNAL(clicked(bool)),this,SLOT(slot_getNextCommande()));

    //BOUTON PILE SETTINGS + CONNECT
    pile_plus->setIcon(QIcon("\\Users\\Adrien\\Documents\\Adrien\\UTC\\GI 02\\LO21\\Projet\\version finale\\projet_1_0\\images/add.png"));
    pile_plus->setFlat(true);
    pile_plus->setFocusPolicy(Qt::NoFocus);
    pile_moins->setIcon(QIcon("\\Users\\Adrien\\Documents\\Adrien\\UTC\\GI 02\\LO21\\Projet\\version finale\\projet_1_0\\images/minus.png"));
    pile_moins->setFlat(true);
    pile_moins->setFocusPolicy(Qt::NoFocus);

    connect(pile_plus,SIGNAL(clicked(bool)),pile,SLOT(aug_pile()));
    connect(pile_plus,SIGNAL(clicked(bool)),this,SLOT(pile_create()));
    connect(pile_moins,SIGNAL(clicked(bool)),pile,SLOT(dim_pile()));
    connect(pile_moins,SIGNAL(clicked(bool)),this,SLOT(pile_create()));

    // MESSAGE SETTINGS

    message->setReadOnly(true);    //empèche d'écrire dans la lineEdit
    message->setStyleSheet("background: blue; color: yellow");
    message->setAlignment(Qt::AlignHCenter);
    message->setFixedHeight(45);

    //VUE PLIE SETTINGS

    vuePile->horizontalHeader()->setVisible(false);   //enlève l'indice de col
    vuePile->horizontalHeader()->setStretchLastSection(true);   //ajuste la largeur à la fenetre
    vuePile->setSelectionMode(QAbstractItemView::NoSelection);
    vuePile->setEditTriggers(QAbstractItemView::NoEditTriggers) ;  //empèche d'écrire dans les cellules

    //SOUND_LOCK SETTINGS
    sound_lock = new QPushButton();
    sound_lock->setIcon(QIcon("\\Users\\Adrien\\Documents\\Adrien\\UTC\\GI 02\\LO21\\Projet\\version finale\\projet_1_0\\images/speaker.png"));
    sound_lock->setFlat(true);
    sound_lock->setFocusPolicy(Qt::NoFocus);
    connect(sound_lock,SIGNAL(clicked(bool)),this,SLOT(sound_disable()));

    //GESTION DES CONNECTS DU SCIENTIFIC_PAD

    connect(scientificPad->cos, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->sin, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->tan, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->arccos, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->arcsin, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->arctan, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->sqrt, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->puis, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->exp, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->ln, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->div, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    connect(scientificPad->mod, SIGNAL(clicked(bool)), this, SLOT(keyboardButtonPressed()));
    

    //GESTION DES CONNECTS DU CONTROLSCREEN
    connect(commande, SIGNAL (returnPressed()) , this , SLOT(slot_getNextCommande())) ;
    connect(pile , SIGNAL (modificationEtat()) , this, SLOT(refresh())) ;

    //GESTION DES CONNECTS DU KEYBOARD

    connect(keyboard->b1,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b2,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b3,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b4,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b5,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b6,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b7,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b8,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b9,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->b0,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->bplus,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->bmoins,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->bdiv,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->bmult,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->clear,SIGNAL(clicked(bool)),commande, SLOT(clear()));
    connect(keyboard->space,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->bComp,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->bPo,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));
    connect(keyboard->bPf,SIGNAL(clicked(bool)),this, SLOT(keyboardButtonPressed()));


    //CREATION DES LIENS ENTRE LES LAYOUTS


    mainSet->addWidget(scientificPad);
    scientificPad->setStyleSheet("background : rgba(35,141,214,45)");
    mainSet->addWidget(controlScreen);
    message->setStyleSheet("background : rgba(35,186,117,45)");
    vuePile->setStyleSheet("background : rgba(35,141,214,25)");;
    mainSet->addWidget(keyboard);
    keyboard->setStyleSheet("background : rgba(35,141,214,45)");


    topLayout->addWidget(message);
    topLayout->addWidget(sound_lock);

    LcontrolScreen = new QVBoxLayout;
    controlScreen->setLayout(LcontrolScreen);
    LcontrolScreen->addLayout(topLayout);
    LcontrolScreen->addLayout(middleLayout);
    LcontrolScreen->addLayout(bottomLayout);


    mainArea->setLayout(mainSet);
    setCentralWidget(mainArea);

    //GESTION SAUVEGARDE CONTEXTE

    connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(save_context()));
    open_context();
}