Esempio n. 1
0
int64 c_SQLite3::t_lastinsertrowid() {
  INSTANCE_METHOD_INJECTION_BUILTIN(SQLite3, SQLite3::lastinsertrowid);
  validate();
  return sqlite3_last_insert_rowid(m_raw_db);
}
Esempio n. 2
0
/* Tests for generic message validation routines */
static void test_message (void)
{
  static const uint8_t extra_garbage[] =
      {0x15, 0x55, 0x00, 0x00,
       0x21, 0x12, 0xA4, 0x42, // cookie
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x76, 0x54, 0x32, 0x10,
       0xaa, 0xbb, 0xcc, 0xdd}; //extra garbage
  static const uint8_t simple_resp[] =
      {0x15, 0x55, 0x00, 0x00,
       0x21, 0x12, 0xA4, 0x42, // cookie
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x76, 0x54, 0x32, 0x10};
  static const uint8_t old_ind[] =
      {0x14, 0x55, 0x00, 0x00,
       0xfe, 0xdc, 0xba, 0x98, // NO cookie
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x76, 0x54, 0x32, 0x10};
  static const uint8_t fpr_resp[] =
      {0x15, 0x55, 0x00, 0x10,
       0x21, 0x12, 0xA4, 0x42, // cookie
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x76, 0x54, 0x32, 0x10,
       0x00, 0x06, 0x00, 0x04, // dummy USERNAME header
       0x41, 0x42, 0x43, 0x44,
       0x80, 0x28, 0x00, 0x04, // FINGERPRINT header
       0xdc, 0x8d, 0xa7, 0x74}; // CRC32;
  static const uint8_t bad1[32] =
      {0x15, 0x55, 0x00, 0x08,
       0x21, 0x12, 0xA4, 0x42, // cookie
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x76, 0x54, 0x32, 0x10,
       0x00, 0x06, 0x00, 0x05, // too big attribute for message
       0x11, 0x22, 0x33, 0x44,
       0x55, 0x66, 0x77, 0x88};
  static const uint8_t bad2[24] =
      {0x15, 0x55, 0x00, 0x05, // invalid message length
       0x21, 0x12, 0xA4, 0x42,
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x76, 0x54, 0x32, 0x10,
       0x00, 0x06, 0x00, 0x01};
  static const uint8_t bad3[27] =
      {0x15, 0x55, 0x00, 0x08,
       0x21, 0x12, 0xA4, 0x42,
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x76, 0x54, 0x32, 0x10,
       0x00, 0x06, 0x00, 0x03,
       0x11, 0x22, 0x33}; // missing padding
  static const uint8_t bad_crc[] =
      {0x15, 0x55, 0x00, 0x08,
       0x21, 0x12, 0xA4, 0x42,
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x76, 0x54, 0x32, 0x10,
       0x80, 0x28, 0x00, 0x04, // FINGERPRINT header
       0x04, 0x91, 0xcd, 0x78}; // CRC32
  static uint8_t bad_crc_offset[] =
      {0x15, 0x55, 0x00, 0x10,
       0x21, 0x12, 0xA4, 0x42,
       0x76, 0x54, 0x32, 0x10,
       0xfe, 0xdc, 0xba, 0x98,
       0x20, 0x67, 0xc4, 0x09,
       0x80, 0x28, 0x00, 0x04, // FINGERPRINT header
       0x00, 0x00, 0x00, 0x00,
       0x00, 0x06, 0x00, 0x04,
       0x41, 0x42, 0x43, 0x44};

  static unsigned char req[] =
      {0x00, 0x01, 0x00, 0x00,
       0x8b, 0x45, 0x9b, 0xc3,
       0xe7, 0x7a, 0x05, 0xb3,
       0xe4, 0xfe, 0x01, 0xf0,
       0xaf, 0x83, 0xe1, 0x9e};

  static uint8_t binding_error_resp[] =
      {0x01, 0x11, 0x00, 0x84,
       0x8b, 0x45, 0x9b, 0xc3,
       0xe7, 0x7a, 0x05, 0xb3,
       0xe4, 0xfe, 0x01, 0xf0,
       0xaf, 0x83, 0xe1, 0x9e,

       0x00, 0x06, 0x00, 0x48, // USERNAME
       0x92, 0x6b, 0x2b, 0x3e,
       0x6a, 0xa5, 0x43, 0x58,
       0xa8, 0x51, 0x25, 0xa6,
       0xf7, 0x9c, 0x0a, 0xe7,
       0xd8, 0x86, 0xf7, 0x76,
       0xf9, 0xcd, 0x8a, 0x2e,
       0x45, 0xd7, 0xcb, 0xbb,
       0xae, 0xe5, 0x03, 0xc3,
       0x3a, 0x32, 0x3a, 0xa9,
       0x9e, 0xb7, 0x7b, 0x32,
       0xe3, 0xf3, 0xa6, 0xc0,
       0xe8, 0x54, 0x4b, 0xef,
       0x52, 0xd2, 0xe2, 0xc0,
       0x43, 0xc2, 0x4c, 0xbc,
       0xaf, 0xd9, 0xf2, 0xfa,
       0x48, 0x8b, 0x8c, 0xe6,
       0x62, 0x14, 0x64, 0x3a,
       0x32, 0x00, 0x00, 0x00,

       0x00, 0x09, 0x00, 0x1c, // ERROR-CODE
       0x00, 0x00, 0x04, 0x1f,
       0x49, 0x6e, 0x74, 0x65,
       0x67, 0x72, 0x69, 0x74,
       0x79, 0x20, 0x43, 0x68,
       0x65, 0x63, 0x6b, 0x20,
       0x46, 0x61, 0x69, 0x6c,
       0x75, 0x72, 0x65, 0x2e,

       0x00, 0x08, 0x00, 0x14, // MESSAGE-INTEGRITY
       0xf7, 0x46, 0x81, 0xc4,
       0x6f, 0x4c, 0x21, 0x5c,
       0xf6, 0x8e, 0xc0, 0x81,
       0x0e, 0x20, 0x3f, 0xb1,
       0xb1, 0xad, 0xa4, 0x8a};

  StunAgent agent;
  StunAgent agent2;
  StunMessage msg;
  uint16_t known_attributes[] = {STUN_ATTRIBUTE_USERNAME,
                                 STUN_ATTRIBUTE_ERROR_CODE,
                                 STUN_ATTRIBUTE_MESSAGE_INTEGRITY};

  uint8_t username_v[] = {0x92, 0x6b, 0x2b, 0x3e, 0x6a, 0xa5, 0x43, 0x58,
                          0xa8, 0x51, 0x25, 0xa6, 0xf7, 0x9c, 0x0a, 0xe7,
                          0xd8, 0x86, 0xf7, 0x76, 0xf9, 0xcd, 0x8a, 0x2e,
                          0x45, 0xd7, 0xcb, 0xbb, 0xae, 0xe5, 0x03, 0xc3,
                          0x3a, 0x32, 0x3a, 0xa9, 0x9e, 0xb7, 0x7b, 0x32,
                          0xe3, 0xf3, 0xa6, 0xc0, 0xe8, 0x54, 0x4b, 0xef,
                          0x52, 0xd2, 0xe2, 0xc0, 0x43, 0xc2, 0x4c, 0xbc,
                          0xaf, 0xd9, 0xf2, 0xfa, 0x48, 0x8b, 0x8c, 0xe6,
                          0x62, 0x14, 0x64, 0x3a, 0x32, 0x00, 0x00, 0x00};
  uint8_t password_v[]  = {0x77, 0xd9, 0x7a, 0xe9, 0xcf, 0xe0, 0x3e, 0xa2,
                           0x28, 0xa0, 0x5d, 0xec, 0xcf, 0x36, 0xe8, 0x49};

  StunDefaultValidaterData v = {username_v, 72, password_v, 16};

  stun_agent_init (&agent, known_attributes,
      STUN_COMPATIBILITY_RFC5389, STUN_AGENT_USAGE_USE_FINGERPRINT);
  stun_agent_init (&agent2, known_attributes,
      STUN_COMPATIBILITY_RFC3489, STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS);


  stun_agent_validate (&agent2, &msg, req, sizeof(req),  NULL, NULL);
  stun_agent_finish_message (&agent2, &msg, NULL, 0);

  if (stun_agent_validate (&agent2, &msg, binding_error_resp,
          sizeof(binding_error_resp),
          stun_agent_default_validater, &v) != STUN_VALIDATION_SUCCESS)
    fatal ("Binding Error Response failed");


  if (stun_message_validate_buffer_length (NULL, 0, TRUE) !=
      STUN_MESSAGE_BUFFER_INVALID)
    fatal ("0 bytes test failed");
  if (stun_message_validate_buffer_length ((uint8_t *)"\xf0", 1, TRUE) >= 0)
    fatal ("1 byte test failed");
  if (stun_message_validate_buffer_length (bad1, sizeof (bad1), TRUE) >= 0)
    fatal ("Badness 1 test failed");
  if (stun_message_validate_buffer_length (bad2, sizeof (bad2), TRUE) >= 0)
    fatal ("Badness 2 test failed");
  if (stun_message_validate_buffer_length (bad3, sizeof (bad3), TRUE) != 0)
    fatal ("Badness 3 test failed");
  validate (simple_resp, 20);
  validate (old_ind, 20);
  validate (fpr_resp, 36);

  if (stun_agent_validate (&agent, &msg, extra_garbage, sizeof(extra_garbage),
          NULL, NULL) != STUN_VALIDATION_NOT_STUN)
    fatal ("Extra garbage test failed");
  if (stun_agent_validate (&agent, &msg, simple_resp, sizeof(simple_resp),
          NULL, NULL) != STUN_VALIDATION_BAD_REQUEST)
    fatal ("Missing CRC test failed");
  if (stun_agent_validate (&agent, &msg, old_ind, sizeof(old_ind),
          NULL, NULL) != STUN_VALIDATION_BAD_REQUEST)
    fatal ("Missing cookie test failed");
  if (stun_agent_validate (&agent, &msg, bad_crc, sizeof(bad_crc),
          NULL, NULL) != STUN_VALIDATION_BAD_REQUEST)
    fatal ("Bad CRC test failed");
  if (stun_agent_validate (&agent, &msg, bad_crc_offset, sizeof(bad_crc_offset),
          NULL, NULL) != STUN_VALIDATION_BAD_REQUEST)
    fatal ("Bad CRC offset test failed");
  if (stun_agent_validate (&agent, &msg, fpr_resp, sizeof(fpr_resp),
          NULL, NULL) != STUN_VALIDATION_UNMATCHED_RESPONSE)
    fatal ("Good CRC test failed");

  if (stun_message_get_class (&msg) != 3)
    fatal ("Class test failed");
  if (stun_message_get_method (&msg) != 0x525)
    fatal ("Method test failed");
}
Esempio n. 3
0
Plan::CompilationPath Plan::compileInThreadImpl(LongLivedState& longLivedState)
{
    Graph dfg(vm, *this, longLivedState);
    
    if (!parse(dfg)) {
        finalizer = adoptPtr(new FailedFinalizer(*this));
        return FailPath;
    }
    
    // By this point the DFG bytecode parser will have potentially mutated various tables
    // in the CodeBlock. This is a good time to perform an early shrink, which is more
    // powerful than a late one. It's safe to do so because we haven't generated any code
    // that references any of the tables directly, yet.
    codeBlock->shrinkToFit(CodeBlock::EarlyShrink);

    if (validationEnabled())
        validate(dfg);
    
    performCPSRethreading(dfg);
    performUnification(dfg);
    performPredictionInjection(dfg);
    
    if (validationEnabled())
        validate(dfg);
    
    performBackwardsPropagation(dfg);
    performPredictionPropagation(dfg);
    performFixup(dfg);
    performTypeCheckHoisting(dfg);
    
    unsigned count = 1;
    dfg.m_fixpointState = FixpointNotConverged;
    for (;; ++count) {
        if (logCompilationChanges())
            dataLogF("DFG beginning optimization fixpoint iteration #%u.\n", count);
        bool changed = false;
        
        if (validationEnabled())
            validate(dfg);
        
        performCFA(dfg);
        changed |= performConstantFolding(dfg);
        changed |= performArgumentsSimplification(dfg);
        changed |= performCFGSimplification(dfg);
        changed |= performCSE(dfg);
        
        if (!changed)
            break;
        
        performCPSRethreading(dfg);
    }
    
    if (logCompilationChanges())
        dataLogF("DFG optimization fixpoint converged in %u iterations.\n", count);

    dfg.m_fixpointState = FixpointConverged;

    performStoreElimination(dfg);
    
    // If we're doing validation, then run some analyses, to give them an opportunity
    // to self-validate. Now is as good a time as any to do this.
    if (validationEnabled()) {
        dfg.m_dominators.computeIfNecessary(dfg);
        dfg.m_naturalLoops.computeIfNecessary(dfg);
    }

#if ENABLE(FTL_JIT)
    if (Options::useExperimentalFTL()
        && compileMode == CompileFunction
        && FTL::canCompile(dfg)) {
        
        performCriticalEdgeBreaking(dfg);
        performLoopPreHeaderCreation(dfg);
        performCPSRethreading(dfg);
        performSSAConversion(dfg);
        performLivenessAnalysis(dfg);
        performCFA(dfg);
        performLICM(dfg);
        performLivenessAnalysis(dfg);
        performCFA(dfg);
        performDCE(dfg); // We rely on this to convert dead SetLocals into the appropriate hint, and to kill dead code that won't be recognized as dead by LLVM.
        performLivenessAnalysis(dfg);
        performFlushLivenessAnalysis(dfg);
        performOSRAvailabilityAnalysis(dfg);
        
        dumpAndVerifyGraph(dfg, "Graph just before FTL lowering:");
        
        // FIXME: Support OSR entry.
        // https://bugs.webkit.org/show_bug.cgi?id=113625
        
        FTL::State state(dfg);
        FTL::lowerDFGToLLVM(state);
        
        if (Options::reportCompileTimes())
            beforeFTL = currentTimeMS();
        
        if (Options::llvmAlwaysFails()) {
            FTL::fail(state);
            return FTLPath;
        }
        
        FTL::compile(state);
        FTL::link(state);
        return FTLPath;
    }
#endif // ENABLE(FTL_JIT)
    
    performCPSRethreading(dfg);
    performDCE(dfg);
    performVirtualRegisterAllocation(dfg);
    dumpAndVerifyGraph(dfg, "Graph after optimization:");

    JITCompiler dataFlowJIT(dfg);
    if (compileMode == CompileFunction) {
        dataFlowJIT.compileFunction();
        dataFlowJIT.linkFunction();
    } else {
        ASSERT(compileMode == CompileOther);
        
        dataFlowJIT.compile();
        dataFlowJIT.link();
    }
    
    return DFGPath;
}
Esempio n. 4
0
void VisibleSelection::setBase(const Position& position)
{
    m_base = position;
    validate();
}
Esempio n. 5
0
/**
Getter for all dimensions parsed.
@return collection of all dimensions parsed.
*/
Mantid::Geometry::VecIMDDimension_sptr
MDGeometryXMLParser::getAllDimensions() const {
  validate();
  return m_vecAllDims;
}
Esempio n. 6
0
void VisibleSelection::setBase(const VisiblePosition& visiblePosition)
{
    m_base = visiblePosition.deepEquivalent();
    validate();
}
Esempio n. 7
0
void VisibleSelection::setExtent(const VisiblePosition& visiblePosition)
{
    m_extent = visiblePosition.deepEquivalent();
    validate();
}
Esempio n. 8
0
inline bool compile(CompileMode compileMode, ExecState* exec, CodeBlock* codeBlock, JITCode& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck, unsigned osrEntryBytecodeIndex)
{
    SamplingRegion samplingRegion("DFG Compilation (Driver)");
    
    numCompilations++;
    
    ASSERT(codeBlock);
    ASSERT(codeBlock->alternative());
    ASSERT(codeBlock->alternative()->getJITType() == JITCode::BaselineJIT);
    
    ASSERT(osrEntryBytecodeIndex != UINT_MAX);

    if (!Options::useDFGJIT())
        return false;
    
#if DFG_ENABLE(DEBUG_VERBOSE)
    dataLog("DFG compiling ", *codeBlock, ", number of instructions = ", codeBlock->instructionCount(), "\n");
#endif
    
    // Derive our set of must-handle values. The compilation must be at least conservative
    // enough to allow for OSR entry with these values.
    unsigned numVarsWithValues;
    if (osrEntryBytecodeIndex)
        numVarsWithValues = codeBlock->m_numVars;
    else
        numVarsWithValues = 0;
    Operands<JSValue> mustHandleValues(codeBlock->numParameters(), numVarsWithValues);
    for (size_t i = 0; i < mustHandleValues.size(); ++i) {
        int operand = mustHandleValues.operandForIndex(i);
        if (operandIsArgument(operand)
            && !operandToArgument(operand)
            && compileMode == CompileFunction
            && codeBlock->specializationKind() == CodeForConstruct) {
            // Ugh. If we're in a constructor, the 'this' argument may hold garbage. It will
            // also never be used. It doesn't matter what we put into the value for this,
            // but it has to be an actual value that can be grokked by subsequent DFG passes,
            // so we sanitize it here by turning it into Undefined.
            mustHandleValues[i] = jsUndefined();
        } else
            mustHandleValues[i] = exec->uncheckedR(operand).jsValue();
    }
    
    Graph dfg(exec->globalData(), codeBlock, osrEntryBytecodeIndex, mustHandleValues);
    if (!parse(exec, dfg))
        return false;
    
    if (compileMode == CompileFunction)
        dfg.predictArgumentTypes();
    
    // By this point the DFG bytecode parser will have potentially mutated various tables
    // in the CodeBlock. This is a good time to perform an early shrink, which is more
    // powerful than a late one. It's safe to do so because we haven't generated any code
    // that references any of the tables directly, yet.
    codeBlock->shrinkToFit(CodeBlock::EarlyShrink);

    validate(dfg);
    performPredictionPropagation(dfg);
    performFixup(dfg);
    performStructureCheckHoisting(dfg);
    unsigned cnt = 1;
    dfg.m_fixpointState = FixpointNotConverged;
    for (;; ++cnt) {
#if DFG_ENABLE(DEBUG_VERBOSE)
        dataLogF("DFG beginning optimization fixpoint iteration #%u.\n", cnt);
#endif
        bool changed = false;
        performCFA(dfg);
        changed |= performConstantFolding(dfg);
        changed |= performArgumentsSimplification(dfg);
        changed |= performCFGSimplification(dfg);
        changed |= performCSE(dfg);
        if (!changed)
            break;
        dfg.resetExitStates();
        performFixup(dfg);
    }
    dfg.m_fixpointState = FixpointConverged;
    performCSE(dfg);
#if DFG_ENABLE(DEBUG_VERBOSE)
    dataLogF("DFG optimization fixpoint converged in %u iterations.\n", cnt);
#endif
    performVirtualRegisterAllocation(dfg);

    GraphDumpMode modeForFinalValidate = DumpGraph;
#if DFG_ENABLE(DEBUG_VERBOSE)
    dataLogF("Graph after optimization:\n");
    dfg.dump();
    modeForFinalValidate = DontDumpGraph;
#endif
    validate(dfg, modeForFinalValidate);
    
    JITCompiler dataFlowJIT(dfg);
    bool result;
    if (compileMode == CompileFunction) {
        ASSERT(jitCodeWithArityCheck);
        
        result = dataFlowJIT.compileFunction(jitCode, *jitCodeWithArityCheck);
    } else {
        ASSERT(compileMode == CompileOther);
        ASSERT(!jitCodeWithArityCheck);
        
        result = dataFlowJIT.compile(jitCode);
    }
    
    return result;
}
Esempio n. 9
0
File: bfi.c Progetto: ilardm/bfi
BOOL execute(UCHAR* _buffer)
{
	if ( !validate(_buffer) )
	{
		#if defined _DEBUG
		printf("\n--- execute: '%s' is invalid\n", _buffer);
		#endif
		return false;
	}

	#if defined _DEBUG
	printf("\n+++ execute: (@ 0x%X) '%s'\n", _buffer, _buffer);
	#endif

	int sz=strlen(_buffer);

	int repeat=0;
	UCHAR* repeat_start=0;
	UCHAR* repeat_stop=0;
	// TODO: crashes here
	/* with this sc
@
+3 [> +10 <-]> -3 .@
< +6 [> +10 <-]> +4 .@
< +6 (crashes here) [> -- -- -- - <-]> .@
< +6 [> +10 <-]> ..@
< +9 [> -9 <-]> - .@
< +6 [> +10 <-]> +4 .@
< +6 [> -7 <-]> - .@
+ < +6 [> +10 <-]> ..@
	*/
	UCHAR* repeat_buffer;
	repeat_buffer=(UCHAR*)calloc(BUFFER_SIZE, sizeof(char));
	if ( !repeat_buffer )
	{
		#if defined _DEBUG
		printf("--- execute: repeat_buffer=NULL\n");
		#else
		printf("error: can't allocate memory\n");
		#endif
		return false;
	}
	BOOL repeat_done=false;
	
	UCHAR* tmp_buffer;		// copy here body of loop cycle if any
	UCHAR* bf_sp=_buffer;

// 	if ( bfo & BFO_QUICK )
// 	{
// 		free(repeat_buffer);
// 		printf("not implemented qbf yet\n");
// 		return false;
// 	}
	
	while ( bf_sp<_buffer+sz )
	{
		repeat_done=false;
// 		#if defined _DEBUG
// 		printf("+++ execute: parse '%c'@ 0x%X\n", *bf_sp, bf_sp);
// 		#endif

		if ( *bf_sp=='@' )
		{
			#if defined _DEBUG
			printf("\n+++ executeq: breakpoint reached\n");
			memDump();
			printSource(_buffer, bf_sp);
			getchar();
			#else
			if ( bfo & BFO_DEBUG )
			{
				printf("\nstop on breakpoint\n");
				memDump();
				printSource(_buffer, bf_sp);
				getchar();
			}
			#endif
		}

		if ( *bf_sp=='+' )
		{
			#if defined _DEBUG
			printf("+++ execute: +\n");
			#endif

			if ( (bfo & BFO_QUICK) && bf_sp<_buffer+sz+1 )
			{
				if ( *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
				{
					repeat_start= ++bf_sp;
					while ( bf_sp<_buffer+sz+1 && *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
					{
						bf_sp++;
					}
					repeat_stop=bf_sp+1;

					memcpy(repeat_buffer, repeat_start, abs(repeat_start-repeat_stop));
					#if defined _DEBUG
					printf("+++ executeq: repeat %s(%d) times\n", repeat_buffer, atoi(repeat_buffer));
					#endif

					(*bf_mp)+=atoi(repeat_buffer);
					repeat_done=true;

					memset(repeat_buffer, 0, BUFFER_SIZE);
				}
				else
				{
					#if defined _DEBUG
					printf("--- executeq: '%c' NAN\n", *(bf_sp+1));
					#endif
				}
			}

			if ( !repeat_done )
			{
				#if defined _DEBUG
				printf("%d (0x%0X) @ 0x%X -> ", *bf_mp, *bf_mp, bf_mp);
				(*bf_mp)++;
				printf("%d (0x%0X) @ 0x%X\n", *bf_mp, *bf_mp, bf_mp);
				#else
				(*bf_mp)++;
				#endif
			}

			if ( used_memory<bf_mp )
			{
				used_memory=bf_mp;
			}
		}

		if ( *bf_sp=='-' )
		{
			#if defined _DEBUG
			printf("+++ execute: -\n");
			#endif

			if ( (bfo & BFO_QUICK) && bf_sp<_buffer+sz+1 )
			{
				if ( *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
				{
					repeat_start= ++bf_sp;
					while ( bf_sp<_buffer+sz+1 && *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
					{
						bf_sp++;
					}
					repeat_stop=bf_sp+1;

					memcpy(repeat_buffer, repeat_start, abs(repeat_start-repeat_stop));
					#if defined _DEBUG
					printf("+++ executeq: repeat %s(%d) times\n", repeat_buffer, atoi(repeat_buffer));
					#endif

					(*bf_mp)-=atoi(repeat_buffer);
					repeat_done=true;

					memset(repeat_buffer, 0, BUFFER_SIZE);
				}
				else
				{
					#if defined _DEBUG
					printf("--- executeq: '%c' NAN\n", *(bf_sp+1));
					#endif
				}
			}

			if ( !repeat_done )
			{
				#if defined _DEBUG
				printf("%d (0x%0X) @ 0x%X -> ", *bf_mp, *bf_mp, bf_mp);
				(*bf_mp)--;
				printf("%d (0x%0X) @ 0x%X\n", *bf_mp, *bf_mp, bf_mp);
				#else
				(*bf_mp)--;
				#endif
			}

			if ( used_memory<bf_mp )
			{
				used_memory=bf_mp;
			}
		}

		if ( *bf_sp=='>' )
		{
			#if defined _DEBUG
			printf("+++ execute: >\n");
			#endif

			repeat=1;

			if ( (bfo & BFO_QUICK) && bf_sp<_buffer+sz+1 )
			{
				if ( *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
				{
					repeat_start= ++bf_sp;
					while ( bf_sp<_buffer+sz+1 && *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
					{
						bf_sp++;
					}
					repeat_stop=bf_sp+1;

					memcpy(repeat_buffer, repeat_start, abs(repeat_start-repeat_stop));
					#if defined _DEBUG
					printf("+++ executeq: repeat %s(%d) times\n", repeat_buffer, atoi(repeat_buffer));
					#endif

					repeat=atoi(repeat_buffer);

					memset(repeat_buffer, 0, BUFFER_SIZE);
				}
				else
				{
					#if defined _DEBUG
					printf("--- executeq: '%c' NAN\n", *(bf_sp+1));
					#endif
				}
			}

			if ( bf_mp+repeat<=bf_mem+BF_MEMORY_SIZE)
			{
				#if defined _DEBUG
				printf("0x%X -> ", bf_mp);
				bf_mp+=repeat;
				printf("0x%X\n", bf_mp);
				#else
				bf_mp+=repeat;
				#endif
			}
			else
			{
				#if defined _DEBUG
				printf("--- execute>: out of memory bounds\n");
				#else
				printf("warning: out of memory bounds\n");
				#endif
				if ( bfo & BFO_QUICK )
				{
					bf_mp=bf_mem+BF_MEMORY_SIZE;
				}
			}

			if ( used_memory<bf_mp )
			{
				used_memory=bf_mp;
			}
		}

		if ( *bf_sp=='<' )
		{
			#if defined _DEBUG
			printf("+++ execute: <\n");
			#endif

			repeat=1;

			if ( (bfo & BFO_QUICK) && bf_sp<_buffer+sz+1 )
			{
				if ( *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
				{
					repeat_start= ++bf_sp;
					while ( bf_sp<_buffer+sz+1 && *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
					{
						bf_sp++;
					}
					repeat_stop=bf_sp+1;

					memcpy(repeat_buffer, repeat_start, abs(repeat_start-repeat_stop));
					#if defined _DEBUG
					printf("+++ executeq: repeat %s(%d) times\n", repeat_buffer, atoi(repeat_buffer));
					#endif

					repeat=atoi(repeat_buffer);

					memset(repeat_buffer, 0, BUFFER_SIZE);
				}
				else
				{
					#if defined _DEBUG
					printf("--- executeq: '%c' NAN\n", *(bf_sp+1));
					#endif
				}
			}

			if ( bf_mp-repeat>=bf_mem  )
			{
				#if defined _DEBUG
				printf("0x%X -> ", bf_mp);
				bf_mp-=repeat;
				printf("0x%X\n", bf_mp);
				#else
				bf_mp-=repeat;
				#endif
			}
			else
			{
				#if defined _DEBUG
				printf("--- execute<: out of memory bounds\n");
				#else
				printf("warning: out of memory bounds\n");
				#endif
				if ( bfo & BFO_QUICK )
				{
					bf_mp=bf_mem;
				}
			}
		}

		if ( *bf_sp=='.' )
		{
			#if defined _DEBUG
			printf("+++ execute: .\n");
			#endif

			#if defined _DEBUG
			memDump();
			#else
			putchar(*bf_mp);
			#endif

			if ( used_memory<bf_mp )
			{
				used_memory=bf_mp;
			}
		}

		if ( *bf_sp==',' )
		{
			#if defined _DEBUG
			printf("+++ execute: ,\n");
			#endif

			if ( (bfo & BFO_QUICK) && bf_sp<_buffer+sz+1 )
			{
				if ( *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
				{
					repeat_start= ++bf_sp;
					while ( bf_sp<_buffer+sz+1 && *(bf_sp+1)>=48 && *(bf_sp+1)<=57 )
					{
						bf_sp++;
					}
					repeat_stop=bf_sp+1;

					memcpy(repeat_buffer, repeat_start, abs(repeat_start-repeat_stop));
					#if defined _DEBUG
					printf("+++ executeq: repeat %s(%d) times\n", repeat_buffer, atoi(repeat_buffer));
					#endif

					repeat=atoi(repeat_buffer);

					memset(repeat_buffer, 0, BUFFER_SIZE);
				}
				else
				{
					#if defined _DEBUG
					printf("--- executeq: '%c' NAN\n", *(bf_sp+1));
					#endif
					repeat=1;
				}
			}

			while ( repeat )
			{
				*bf_mp=(UCHAR)getchar();
				#if defined _DEBUG
				printf("+++ execute,: 0x%x\n", *bf_mp);
				#endif

				if ( bf_mp<bf_mem+BF_MEMORY_SIZE)
				{
					bf_mp++;
				}
				else
				{
					#if defined _DEBUG
					printf("--- executeq: out of memory bounds. input into last cell (%d left)\n", repeat);
					#else
					printf("warning: out of memory bounds. input into last cell\n");
					#endif
				}
				repeat--;
			}

			if ( used_memory<bf_mp )
			{
				used_memory=bf_mp;
			}
		}

		if ( *bf_sp=='[' )
		{
			#if defined _DEBUG
			printf("+++ execute[: '[' found @ 0x%X\n", bf_sp);
			#endif

			UCHAR* tmp_bf_sp=index(bf_sp, ']')+1;
			int tmp_sz=abs(bf_sp-tmp_bf_sp);
			tmp_buffer=(UCHAR*)calloc(tmp_sz, sizeof(char));
			if ( tmp_buffer )
			{
				memcpy(tmp_buffer, bf_sp, tmp_sz);
				tmp_buffer[tmp_sz]=0;
			}
			else
			{
				#if defined _DEBUG
				printf("--- execute[: tmp_buffer=NULL\n");
				#else
				printf("error: can't allocate memory\n");
				#endif
				return false;
			}
			
			while ( tmp_buffer && !validate(tmp_buffer) )
			{
				#if defined _DEBUG
				printf("+++ execute[::searchEndOfCycle: '%s'(%d) is invalid : ++\n", tmp_buffer, tmp_sz);
				#endif
				tmp_bf_sp=index(tmp_bf_sp, ']')+1;
				tmp_sz=abs(bf_sp-tmp_bf_sp);
				tmp_buffer=(UCHAR*)realloc(tmp_buffer, tmp_sz);
				memset(tmp_buffer, 0, tmp_sz);

				if ( tmp_buffer )
				{
					memcpy(tmp_buffer, bf_sp, tmp_sz);
					tmp_buffer[tmp_sz]=0;
				}
				else
				{
					#if defined _DEBUG
					printf("--- execute[: tmp_buffer=NULL\n");
					#else
					printf("error: can't allocate memory\n");
					#endif
					return false;
				}
			}

			if ( tmp_buffer )
			{
				int sz=strlen(tmp_buffer);
				tmp_buffer[sz-1]=0;

				while ( *bf_mp )
				{
					#if defined _DEBUG
					printf("\n+++ execute: recursive calls left: %d\n", *bf_mp);
					#endif
					if ( !execute(tmp_buffer+1) )
					{
						#if defined _DEBUG
						printf("--- execute: error execute while recursive calls\n");
						memDump();
						#endif
						return false;
					}
				}
				#if defined _DEBUG
				printf("+++ execute: exit from recursive call\n\n");
				#endif
				free(tmp_buffer);
				bf_sp=tmp_bf_sp-1;
			}
		}

		bf_sp++;
	}

	free(repeat_buffer);

	return true;
}
Esempio n. 10
0
AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent)
	: QDialog(parent, Qt::Window), mFeedReader(feedReader), mNotify(notify), ui(new Ui::AddFeedDialog)
{
	ui->setupUi(this);

	connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(createFeed()));
	connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));

	connect(ui->useAuthenticationCheckBox, SIGNAL(toggled(bool)), this, SLOT(authenticationToggled()));
	connect(ui->useStandardStorageTimeCheckBox, SIGNAL(toggled(bool)), this, SLOT(useStandardStorageTimeToggled()));
	connect(ui->useStandardUpdateInterval, SIGNAL(toggled(bool)), this, SLOT(useStandardUpdateIntervalToggled()));
	connect(ui->useStandardProxyCheckBox, SIGNAL(toggled(bool)), this, SLOT(useStandardProxyToggled()));
	connect(ui->typeForumRadio, SIGNAL(toggled(bool)), this, SLOT(typeForumToggled()));
	connect(ui->previewButton, SIGNAL(clicked()), this, SLOT(preview()));

	/* currently only for loacl feeds */
	connect(ui->saveCompletePageCheckBox, SIGNAL(toggled(bool)), this, SLOT(denyForumToggled()));
	connect(ui->embedImagesCheckBox, SIGNAL(toggled(bool)), this, SLOT(denyForumToggled()));

	connect(ui->urlLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validate()));
	connect(ui->nameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validate()));
	connect(ui->useInfoFromFeedCheckBox, SIGNAL(toggled(bool)), this, SLOT(validate()));
	connect(ui->typeLocalRadio, SIGNAL(toggled(bool)), this, SLOT(validate()));
	connect(ui->typeForumRadio, SIGNAL(toggled(bool)), this, SLOT(validate()));

	ui->activatedCheckBox->setChecked(true);
	ui->forumComboBox->setEnabled(false);
	ui->useInfoFromFeedCheckBox->setChecked(true);
	ui->updateForumInfoCheckBox->setEnabled(false);
	ui->updateForumInfoCheckBox->setChecked(true);
	ui->forumNameLabel->hide();
	ui->useAuthenticationCheckBox->setChecked(false);
	ui->useStandardStorageTimeCheckBox->setChecked(true);
	ui->useStandardUpdateInterval->setChecked(true);
	ui->useStandardProxyCheckBox->setChecked(true);

	/* not yet supported */
	ui->authenticationGroupBox->setEnabled(false);

	/* fill own forums */
	std::list<ForumInfo> forumList;
	if (rsForums->getForumList(forumList)) {
		forumList.sort(sortForumInfo);
		for (std::list<ForumInfo>::iterator it = forumList.begin(); it != forumList.end(); ++it) {
			ForumInfo &forumInfo = *it;
			/* show only own anonymous forums */
			if ((forumInfo.subscribeFlags & RS_DISTRIB_ADMIN) && (forumInfo.forumFlags & RS_DISTRIB_AUTHEN_ANON)) {
				ui->forumComboBox->addItem(QString::fromStdWString(forumInfo.forumName), QString::fromStdString(forumInfo.forumId));
			}
		}
	}
	/* insert item to create a new forum */
	ui->forumComboBox->insertItem(0, tr("Create a new anonymous public forum"), "");
	ui->forumComboBox->setCurrentIndex(0);

	validate();

	ui->urlLineEdit->setFocus();

	/* load settings */
	processSettings(true);
}
Esempio n. 11
0
static int
backsql_get_attr_vals( void *v_at, void *v_bsi )
{
	backsql_at_map_rec	*at = v_at;
	backsql_srch_info	*bsi = v_bsi;
	backsql_info		*bi;
	RETCODE			rc;
	SQLHSTMT		sth = SQL_NULL_HSTMT;
	BACKSQL_ROW_NTS		row;
	unsigned long		i,
				k = 0,
				oldcount = 0,
				res = 0;
#ifdef BACKSQL_COUNTQUERY
	unsigned 		count,
				j,
				append = 0;
	SQLLEN			countsize = sizeof( count );
	Attribute		*attr = NULL;

	slap_mr_normalize_func		*normfunc = NULL;
#endif /* BACKSQL_COUNTQUERY */
#ifdef BACKSQL_PRETTY_VALIDATE
	slap_syntax_validate_func	*validate = NULL;
	slap_syntax_transform_func	*pretty = NULL;
#endif /* BACKSQL_PRETTY_VALIDATE */

	assert( at != NULL );
	assert( bsi != NULL );
	Debug( LDAP_DEBUG_TRACE, "==>backsql_get_attr_vals(): "
		"oc=\"%s\" attr=\"%s\" keyval=" BACKSQL_IDFMT "\n",
		BACKSQL_OC_NAME( bsi->bsi_oc ), at->bam_ad->ad_cname.bv_val, 
		BACKSQL_IDARG(bsi->bsi_c_eid->eid_keyval) );

	bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;

#ifdef BACKSQL_PRETTY_VALIDATE
	validate = at->bam_true_ad->ad_type->sat_syntax->ssyn_validate;
	pretty =  at->bam_true_ad->ad_type->sat_syntax->ssyn_pretty;

	if ( validate == NULL && pretty == NULL ) {
		return 1;
	}
#endif /* BACKSQL_PRETTY_VALIDATE */

#ifdef BACKSQL_COUNTQUERY
	if ( at->bam_true_ad->ad_type->sat_equality ) {
		normfunc = at->bam_true_ad->ad_type->sat_equality->smr_normalize;
	}

	/* Count how many rows will be returned. This avoids memory 
	 * fragmentation that can result from loading the values in 
	 * one by one and using realloc() 
	 */
	rc = backsql_Prepare( bsi->bsi_dbh, &sth, at->bam_countquery, 0 );
	if ( rc != SQL_SUCCESS ) {
		Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
			"error preparing count query: %s\n",
			at->bam_countquery );
		backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
		return 1;
	}

	rc = backsql_BindParamID( sth, 1, SQL_PARAM_INPUT,
			&bsi->bsi_c_eid->eid_keyval );
	if ( rc != SQL_SUCCESS ) {
		Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
			"error binding key value parameter\n" );
		SQLFreeStmt( sth, SQL_DROP );
		return 1;
	}

	rc = SQLExecute( sth );
	if ( ! BACKSQL_SUCCESS( rc ) ) {
		Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
			"error executing attribute count query '%s'\n",
			at->bam_countquery );
		backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
		SQLFreeStmt( sth, SQL_DROP );
		return 1;
	}

	SQLBindCol( sth, (SQLUSMALLINT)1, SQL_C_LONG,
			(SQLPOINTER)&count,
			(SQLINTEGER)sizeof( count ),
			&countsize );

	rc = SQLFetch( sth );
	if ( rc != SQL_SUCCESS ) {
		Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
			"error fetch results of count query: %s\n",
			at->bam_countquery );
		backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
		SQLFreeStmt( sth, SQL_DROP );
		return 1;
	}

	Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
		"number of values in query: %u\n", count );
	SQLFreeStmt( sth, SQL_DROP );
	if ( count == 0 ) {
		return 1;
	}

	attr = attr_find( bsi->bsi_e->e_attrs, at->bam_true_ad );
	if ( attr != NULL ) {
		BerVarray	tmp;

		if ( attr->a_vals != NULL ) {
			oldcount = attr->a_numvals;
		}

		tmp = ch_realloc( attr->a_vals, ( oldcount + count + 1 ) * sizeof( struct berval ) );
		if ( tmp == NULL ) {
			return 1;
		}
		attr->a_vals = tmp;
		memset( &attr->a_vals[ oldcount ], 0, ( count + 1 ) * sizeof( struct berval ) );

		if ( normfunc ) {
			tmp = ch_realloc( attr->a_nvals, ( oldcount + count + 1 ) * sizeof( struct berval ) );
			if ( tmp == NULL ) {
				return 1;
			}
			attr->a_nvals = tmp;
			memset( &attr->a_nvals[ oldcount ], 0, ( count + 1 ) * sizeof( struct berval ) );

		} else {
			attr->a_nvals = attr->a_vals;
		}
		attr->a_numvals += count;

	} else {
		append = 1;

		/* Make space for the array of values */
		attr = attr_alloc( at->bam_true_ad );
		attr->a_numvals = count;
		attr->a_vals = ch_calloc( count + 1, sizeof( struct berval ) );
		if ( attr->a_vals == NULL ) {
			Debug( LDAP_DEBUG_TRACE, "Out of memory!\n" );
			ch_free( attr );
			return 1;
		}
		if ( normfunc ) {
			attr->a_nvals = ch_calloc( count + 1, sizeof( struct berval ) );
			if ( attr->a_nvals == NULL ) {
				ch_free( attr->a_vals );
				ch_free( attr );
				return 1;

			}

		} else {
			attr->a_nvals = attr->a_vals;
		}
	}
#endif /* BACKSQL_COUNTQUERY */

	rc = backsql_Prepare( bsi->bsi_dbh, &sth, at->bam_query, 0 );
	if ( rc != SQL_SUCCESS ) {
		Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
			"error preparing query: %s\n", at->bam_query );
		backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
#ifdef BACKSQL_COUNTQUERY
		if ( append ) {
			attr_free( attr );
		}
#endif /* BACKSQL_COUNTQUERY */
		return 1;
	}

	rc = backsql_BindParamID( sth, 1, SQL_PARAM_INPUT,
			&bsi->bsi_c_eid->eid_keyval );
	if ( rc != SQL_SUCCESS ) {
		Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
			"error binding key value parameter\n" );
#ifdef BACKSQL_COUNTQUERY
		if ( append ) {
			attr_free( attr );
		}
#endif /* BACKSQL_COUNTQUERY */
		return 1;
	}

#ifdef BACKSQL_TRACE
	Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
		"query=\"%s\" keyval=" BACKSQL_IDFMT "\n", at->bam_query,
		BACKSQL_IDARG(bsi->bsi_c_eid->eid_keyval) );
#endif /* BACKSQL_TRACE */

	rc = SQLExecute( sth );
	if ( ! BACKSQL_SUCCESS( rc ) ) {
		Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
			"error executing attribute query \"%s\"\n",
			at->bam_query );
		backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
		SQLFreeStmt( sth, SQL_DROP );
#ifdef BACKSQL_COUNTQUERY
		if ( append ) {
			attr_free( attr );
		}
#endif /* BACKSQL_COUNTQUERY */
		return 1;
	}

	backsql_BindRowAsStrings_x( sth, &row, bsi->bsi_op->o_tmpmemctx );
#ifdef BACKSQL_COUNTQUERY
	j = oldcount;
#endif /* BACKSQL_COUNTQUERY */
	for ( rc = SQLFetch( sth ), k = 0;
			BACKSQL_SUCCESS( rc );
			rc = SQLFetch( sth ), k++ )
	{
		for ( i = 0; i < (unsigned long)row.ncols; i++ ) {

			if ( row.value_len[ i ] > 0 ) {
				struct berval		bv;
				int			retval;
#ifdef BACKSQL_TRACE
				AttributeDescription	*ad = NULL;
				const char		*text;

				retval = slap_bv2ad( &row.col_names[ i ], &ad, &text );
				if ( retval != LDAP_SUCCESS ) {
					Debug( LDAP_DEBUG_ANY,
						"==>backsql_get_attr_vals(\"%s\"): "
						"unable to find AttributeDescription %s "
						"in schema (%d)\n",
						bsi->bsi_e->e_name.bv_val,
						row.col_names[ i ].bv_val, retval );
					res = 1;
					goto done;
				}

				if ( ad != at->bam_ad ) {
					Debug( LDAP_DEBUG_ANY,
						"==>backsql_get_attr_vals(\"%s\"): "
						"column name %s differs from "
						"AttributeDescription %s\n",
						bsi->bsi_e->e_name.bv_val,
						ad->ad_cname.bv_val,
						at->bam_ad->ad_cname.bv_val );
					res = 1;
					goto done;
				}
#endif /* BACKSQL_TRACE */

				/* ITS#3386, ITS#3113 - 20070308
				 * If a binary is fetched?
				 * must use the actual size read
				 * from the database.
				 */
				if ( BACKSQL_IS_BINARY( row.col_type[ i ] ) ) {
#ifdef BACKSQL_TRACE
					Debug( LDAP_DEBUG_ANY,
						"==>backsql_get_attr_vals(\"%s\"): "
						"column name %s: data is binary; "
						"using database size %ld\n",
						bsi->bsi_e->e_name.bv_val,
						ad->ad_cname.bv_val,
						row.value_len[ i ] );
#endif /* BACKSQL_TRACE */
					bv.bv_val = row.cols[ i ];
					bv.bv_len = row.value_len[ i ];

				} else {
					ber_str2bv( row.cols[ i ], 0, 0, &bv );
				}

#ifdef BACKSQL_PRETTY_VALIDATE
				if ( pretty ) {
					struct berval	pbv;

					retval = pretty( at->bam_true_ad->ad_type->sat_syntax,
						&bv, &pbv, bsi->bsi_op->o_tmpmemctx );
					bv = pbv;

				} else {
					retval = validate( at->bam_true_ad->ad_type->sat_syntax,
						&bv );
				}

				if ( retval != LDAP_SUCCESS ) {
					/* FIXME: we're ignoring invalid values,
					 * but we're accepting the attributes;
					 * should we fail at all? */
					Debug(LDAP_DEBUG_TRACE,
					      "==>backsql_get_attr_vals(\"%s\"): " "unable to %s value #%lu " "of AttributeDescription %s (%d)\n",
					      bsi->bsi_e->e_name.bv_val,
					      pretty ? "prettify" : "validate",
					      k - oldcount,
					      at->bam_ad->ad_cname.bv_val,
					      retval );
					continue;
				}
#endif /* BACKSQL_PRETTY_VALIDATE */

#ifndef BACKSQL_COUNTQUERY
				(void)backsql_entry_addattr( bsi->bsi_e, 
						at->bam_true_ad, &bv,
						bsi->bsi_op->o_tmpmemctx );

#else /* BACKSQL_COUNTQUERY */
				if ( normfunc ) {
					struct berval	nbv;

					retval = (*normfunc)( SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
						at->bam_true_ad->ad_type->sat_syntax,
						at->bam_true_ad->ad_type->sat_equality,
						&bv, &nbv,
						bsi->bsi_op->o_tmpmemctx );

					if ( retval != LDAP_SUCCESS ) {
						/* FIXME: we're ignoring invalid values,
						 * but we're accepting the attributes;
						 * should we fail at all? */
						Debug(LDAP_DEBUG_TRACE,
						      "==>backsql_get_attr_vals(\"%s\"): " "unable to normalize value #%lu " "of AttributeDescription %s (%d)\n",
						      bsi->bsi_e->e_name.bv_val,
						      k - oldcount,
						      at->bam_ad->ad_cname.bv_val,
						      retval );

#ifdef BACKSQL_PRETTY_VALIDATE
						if ( pretty ) {
							bsi->bsi_op->o_tmpfree( bv.bv_val,
									bsi->bsi_op->o_tmpmemctx );
						}
#endif /* BACKSQL_PRETTY_VALIDATE */

						continue;
					}
					ber_dupbv( &attr->a_nvals[ j ], &nbv );
					bsi->bsi_op->o_tmpfree( nbv.bv_val,
							bsi->bsi_op->o_tmpmemctx );
				}

				ber_dupbv( &attr->a_vals[ j ], &bv );

				assert( j < oldcount + count );
				j++;
#endif /* BACKSQL_COUNTQUERY */

#ifdef BACKSQL_PRETTY_VALIDATE
				if ( pretty ) {
					bsi->bsi_op->o_tmpfree( bv.bv_val,
							bsi->bsi_op->o_tmpmemctx );
				}
#endif /* BACKSQL_PRETTY_VALIDATE */

#ifdef BACKSQL_TRACE
				Debug( LDAP_DEBUG_TRACE, "prec=%d\n",
					(int)row.col_prec[ i ] );

			} else {
      				Debug( LDAP_DEBUG_TRACE, "NULL value "
					"in this row for attribute \"%s\"\n",
					row.col_names[ i ].bv_val );
#endif /* BACKSQL_TRACE */
			}
		}
	}

#ifdef BACKSQL_COUNTQUERY
	if ( BER_BVISNULL( &attr->a_vals[ 0 ] ) ) {
		/* don't leave around attributes with no values */
		attr_free( attr );

	} else if ( append ) {
		Attribute	**ap;

		for ( ap = &bsi->bsi_e->e_attrs; (*ap) != NULL; ap = &(*ap)->a_next )
			/* goto last */ ;
		*ap =  attr;
	}
#endif /* BACKSQL_COUNTQUERY */

	SQLFreeStmt( sth, SQL_DROP );
	Debug( LDAP_DEBUG_TRACE, "<==backsql_get_attr_vals()\n" );

	if ( at->bam_next ) {
		res = backsql_get_attr_vals( at->bam_next, v_bsi );
	} else {
		res = 1;
	}

#ifdef BACKSQL_TRACE
done:;
#endif /* BACKSQL_TRACE */
	backsql_FreeRow_x( &row, bsi->bsi_op->o_tmpmemctx );

	return res;
}
Esempio n. 12
0
int64 c_SQLite3::t_changes() {
  INSTANCE_METHOD_INJECTION_BUILTIN(SQLite3, SQLite3::changes);
  validate();
  return sqlite3_changes(m_raw_db);
}
Esempio n. 13
0
String c_SQLite3::t_lasterrormsg() {
  INSTANCE_METHOD_INJECTION_BUILTIN(SQLite3, SQLite3::lasterrormsg);
  validate();
  return String((char*)sqlite3_errmsg(m_raw_db), CopyString);
}
Esempio n. 14
0
int64 c_SQLite3::t_lasterrorcode() {
  INSTANCE_METHOD_INJECTION_BUILTIN(SQLite3, SQLite3::lasterrorcode);
  validate();
  return sqlite3_errcode(m_raw_db);
}
Esempio n. 15
0
void checkDock::validateAll()
{
  validate( ValidateAll );
}
// This is only called from SimpleResponseHandler.deliver() but lives in this
// class because all asyncronous response must have a "response" pointer
// to go through. Only operation classes have a response pointer
void OperationResponseHandler::send(Boolean isComplete)
{
	// some handlers do not send async because their callers cannot handle
	// partial responses. If this is the case, stop here.

	if (isAsync() == false)
	{
		// preserve tradional behavior
		if (isComplete == true)
        {
            transfer();
        }

        return;
	}

	SimpleResponseHandler *simpleP = dynamic_cast<SimpleResponseHandler*>(this);

	// It is possible to instantiate this class directly (not derived)
	// The caller would do this only if the operation does not have any data to
	// be returned

	if (! simpleP)
	{
		// if there is no data to be returned, then the message should NEVER be
		// incomplete (even on an error)
		if (isComplete == false)
        {
            PEGASUS_ASSERT(false);
        }

        return;
	}

	SimpleResponseHandler &simple = *simpleP;
	PEGASUS_ASSERT(_response);
	Uint32 objectCount = simple.size();

	// have not reached threshold yet
	if ((isComplete == false) && (objectCount < _responseObjectThreshold))
    {
        return;
    }

	CIMResponseMessage *response = _response;

	// for complete responses, just use the one handed down from caller
	// otherwise, create our own that the caller never sees but is
	// utilized for async responses underneath

	if (isComplete == false)
    {
        _response = _request->buildResponse();
    }

	_response->setComplete(isComplete);
	_responseObjectTotal += objectCount;

	// since we are reusing response for every chunk,keep track of original count
	_response->setIndex(_responseMessageTotal++);

	// set the originally allocated response to one more than the current.
	// The reason for doing this is proactive in case of an exception. This
	// allows the last response to be set as it may not re-enter this code.

	if (isComplete == false)
    {
        response->setIndex(_responseMessageTotal);
    }

	validate();

	if (_response->cimException.getCode() != CIM_ERR_SUCCESS)
    {
        simple.clear();
    }

	String function = getClass() + "::" + "transfer";
	Logger::put(
        Logger::STANDARD_LOG,
        System::CIMSERVER,
        Logger::TRACE,
        function);

	transfer();
	simple.clear();

	// l10n
	_response->operationContext.set(ContentLanguageListContainer(simple.getLanguages()));

	// call thru ProviderManager to get externally declared entry point

	if (isComplete == false)
	{
		ProviderManagerService::handleCimResponse(*_request, *_response);
	}

	// put caller's allocated response back in place. Note that _response
	// is INVALID after sending because it has been deleted externally

	_response = response;
}
Esempio n. 17
0
void checkDock::validateSelected()
{
  validate( ValidateSelected );
}
Esempio n. 18
0
int main(int argc, char **argv)
{
	uint16_t fsize, isize, bsize = 512, shift = 0;
	uint16_t j;
	uint32_t s;
	int opt;

	while((opt = getopt(argc, argv, "Xb:")) != -1) {
		switch(opt) {
			case 'X':	
				swizzling = 1;
				break;
			case 'b':
				bsize = atoi(optarg);
				shift = validate(bsize);
				break;
			default:
				usage();
		}
	}
	if (argc - optind != 3)
		usage();

	if (sizeof(inode) != 512) {
		printf("inode is the wrong size -- %d\n",
		       (int) sizeof(inode));
	}

	isize = (uint16_t) atoi(argv[optind + 1]);
	fsize = (uint16_t) atoi(argv[optind + 2]);

	if (fsize < 3 || isize < 2 || isize >= fsize) {
		printf("Bad parameter values\n");
		return -1;
	}

	memset(zero512, 0, 512);

	printf("Making %d byte/block filesystem with %s byte order on device %s with fsize = %u and isize = %u.\n",
	       bsize, swizzling==0 ? "normal" : "reversed", argv[optind], fsize, isize);

	if (fd_open(argv[optind])) {
		printf("Can't open device");
		return -1;
	}

	s = fsize << shift;

	/* Zero out the blocks */
	for (j = 0; j < s; ++j)
		dwrite(j, zero512);

	/* Initialize the super-block */

	fs_super.fs.s_mounted = swizzle16(SMOUNTED);	/* Magic number */
	fs_super.fs.s_isize = swizzle16(isize);
	fs_super.fs.s_fsize = swizzle16(fsize);
	fs_super.fs.s_nfree = swizzle16(1);
	fs_super.fs.s_free[0] = 0;
	fs_super.fs.s_tfree = 0;
	fs_super.fs.s_ninode = 0;
	fs_super.fs.s_tinode = swizzle16(8 * (isize - 2) - 2);
	fs_super.fs.s_shift = shift;

	/* Free each block, building the free list. This is done in
	   terms of the block shift, while isize is in 512 byte blocks.
	   Adjust isize so that it's in block terms and references the
	   block after the last inode */
	  
	isize <<= shift;

	/* Don't free the block isize because it's got the / directory in it */
	for (j = fsize - 1; j > isize; --j) {
		int n;
		if (swizzle16(fs_super.fs.s_nfree) == 50) {
			dwrite(j, (char *) &fs_super.fs.s_nfree);
			fs_super.fs.s_nfree = 0;
		}

		fs_super.fs.s_tfree =
		    swizzle16(swizzle16(fs_super.fs.s_tfree) + 1);
		n = swizzle16(fs_super.fs.s_nfree);
		fs_super.fs.s_free[n++] = swizzle16(j);
		fs_super.fs.s_nfree = swizzle16(n);
	}

	/* The inodes are already zeroed out */
	/* create the root dir */
	inode[ROOTINODE].i_mode = swizzle16(F_DIR | (0777 & MODE_MASK));
	inode[ROOTINODE].i_nlink = swizzle16(3);
	inode[ROOTINODE].i_size = swizzle32(64);
	inode[ROOTINODE].i_addr[0] = swizzle16(isize);

	/* Reserve reserved inode */
	inode[0].i_nlink = swizzle16(1);
	inode[0].i_mode = ~0;

	dwrite(2, (char *) inode);

	dirbuf[0].d_ino = swizzle16(dirbuf[0].d_ino);
	dirbuf[1].d_ino = swizzle16(dirbuf[1].d_ino);
	dwrite(isize, (char *) dirbuf);

	/* Write out super block */
	dwrite(1, (char *) &fs_super);
	return 0;
}
Esempio n. 19
0
void VisibleSelection::setExtent(const Position& position)
{
    m_extent = position;
    validate();
}
Esempio n. 20
0
int
main (int argc, char *argv[])
{
  int c;
  int option_index = 0;
  char *charset = "aA1!";
  enum { m_benchmark, m_brute_force, m_dictionary } mode = m_brute_force;

  while ((c = getopt_long (argc, argv, "DbBc:hVvp:l:um:2:", options, &option_index)) != -1)
    switch (c)
      {
      case 'b':
        mode = m_brute_force;
        break;

      case 'D':
        mode = m_dictionary;
        break;

      case 'p':
        strcpy (pw, optarg);
        break;

      case 'l':
        pw[0] = 0;
        switch (sscanf (optarg, "%d-%d", &min_length, &max_length))
          {
          default:
            fprintf (stderr, "'%s' is an incorrect length specification\n", optarg);
            exit (1);
          case 1:
            max_length = min_length;
          case 2:
            ;
          }
        break;

      case 2:
        if (sscanf (optarg, "%d/%d", &residuent, &modul) != 2)
          fprintf (stderr, "malformed --modulo option, expected 'residuent/modul'\n"), exit (1);

        if (residuent < 0 || modul <= 0)
          fprintf (stderr, "residuent and modul must be positive\n"), exit (1);

        if (residuent >= modul)
          fprintf (stderr, "residuent must be less than modul\n"), exit (1);

        break;

      case 'B':
        mode = m_benchmark;
        benchmark ();
        exit (0);

      case 'v':
        verbosity++;
        break;

      case 'm':
        {
          for (method_number = 0; methods[method_number].desc; method_number++)
            if (!strncmp (methods[method_number].desc, optarg, strlen (optarg)))
              break;

          if (!methods[method_number].desc)
            method_number = atoi (optarg);

          crack_method = methods + method_number;
        }
        break;

      case 'V':
        validate ();
        exit (0);

      case 'c':
        charset = optarg;
        break;

      case 'u':
        use_unzip = 1;
        break;

      case 'h':
        usage (0);
      case 'R':
        printf (PACKAGE " version " VERSION "\n");
        exit (0);

      case ':':
        fprintf (stderr, "required argument missing\n");
        exit (1);

      case '?':
        fprintf (stderr, "unknown option\n");
        exit (1);

      default:
        usage (1);
      }

  if (method_number < 0)
    {
      method_number = default_method;
      crack_method = methods + default_method;
    }

  if (optind >= argc)
    {
      fprintf (stderr, "you have to specify one or more zip files (try --help)\n");
      exit (1);
    }

  for (; optind < argc; optind++)
    if (file_count < MAX_FILES)
      crack_method->load_file (argv[optind]);
    else if (verbosity)
      printf ("%d file maximum reached, ignoring '%s'\n", MAX_FILES, argv[optind]);

  if (file_count == 0)
    {
      fprintf (stderr, "no usable files found\n");
      exit (1);
    }

  crack_method->init_crack_pw ();

  switch (mode)
    {
    case m_brute_force:
      parse_charset (charset);

      if (!pw[0])
        {
          if (min_length < 0)
            {
              fprintf (stderr, "you have to specify either --init-password or --length with --brute-force\n");
              exit (1);
            }
          else
            {
              u8 *p = pw;
              while (p < pw + min_length)
                *p++ = bf_next[255];

              *p++ = 0;
            }
        }

      if (residuent)
        {
          int xmodul = modul;
          modul = residuent;
          pw_end = pw + strlen (pw);
          brute_force_gen ();
          printf ("%s\n", pw);
          modul = xmodul;
          printf ("WARNING: residuent mode NOT supported YET!\n");
        }

      crack_method->crack_pw (brute_force_gen, print_callback);
      break;

    case m_dictionary:
      if (!pw[0])
        {
          fprintf (stderr, "you have to specify a file to read passwords from using the -p switch\n");
          exit (1);
        }

      if (!(dict_file = fopen (pw, "r")))
        {
          perror (pw);
          exit (1);
        }
      else
        {
          *(pw_end = pw) = 0;
          dictionary_gen (); /* fetch first password */
          crack_method->crack_pw (dictionary_gen, print_callback);

          fclose (dict_file);
        }

      break;

    default:
      fprintf (stderr, "specified mode not supported in this version\n");
      exit (1);
    }

  return 0;
}
Esempio n. 21
0
void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
{
    if (m_base.isNull() || m_start.isNull() || m_end.isNull())
        return;

    Node* baseRoot = highestEditableRoot(m_base);
    Node* startRoot = highestEditableRoot(m_start);
    Node* endRoot = highestEditableRoot(m_end);
    
    Node* baseEditableAncestor = lowestEditableAncestor(m_base.containerNode());
    
    // The base, start and end are all in the same region.  No adjustment necessary.
    if (baseRoot == startRoot && baseRoot == endRoot)
        return;
    
    // The selection is based in editable content.
    if (baseRoot) {
        // If the start is outside the base's editable root, cap it at the start of that root.
        // If the start is in non-editable content that is inside the base's editable root, put it
        // at the first editable position after start inside the base's editable root.
        if (startRoot != baseRoot) {
            VisiblePosition first = firstEditablePositionAfterPositionInRoot(m_start, baseRoot);
            m_start = first.deepEquivalent();
            if (m_start.isNull()) {
                ASSERT_NOT_REACHED();
                m_start = m_end;
            }
        }
        // If the end is outside the base's editable root, cap it at the end of that root.
        // If the end is in non-editable content that is inside the base's root, put it
        // at the last editable position before the end inside the base's root.
        if (endRoot != baseRoot) {
            VisiblePosition last = lastEditablePositionBeforePositionInRoot(m_end, baseRoot);
            m_end = last.deepEquivalent();
            if (m_end.isNull())
                m_end = m_start;
        }
    // The selection is based in non-editable content.
    } else {
        // FIXME: Non-editable pieces inside editable content should be atomic, in the same way that editable
        // pieces in non-editable content are atomic.
    
        // The selection ends in editable content or non-editable content inside a different editable ancestor, 
        // move backward until non-editable content inside the same lowest editable ancestor is reached.
        Node* endEditableAncestor = lowestEditableAncestor(m_end.containerNode());
        if (endRoot || endEditableAncestor != baseEditableAncestor) {
            
            Position p = previousVisuallyDistinctCandidate(m_end);
            Node* shadowAncestor = endRoot ? endRoot->shadowAncestorNode() : 0;
            if (p.isNull() && endRoot && (shadowAncestor != endRoot))
                p = positionAfterNode(shadowAncestor);
            while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) {
                Node* root = editableRootForPosition(p);
                shadowAncestor = root ? root->shadowAncestorNode() : 0;
                p = isAtomicNode(p.containerNode()) ? positionInParentBeforeNode(p.containerNode()) : previousVisuallyDistinctCandidate(p);
                if (p.isNull() && (shadowAncestor != root))
                    p = positionAfterNode(shadowAncestor);
            }
            VisiblePosition previous(p);

            if (previous.isNull()) {
                // The selection crosses an Editing boundary.  This is a
                // programmer error in the editing code.  Happy debugging!
                ASSERT_NOT_REACHED();
                m_base = Position();
                m_extent = Position();
                validate();
                return;
            }
            m_end = previous.deepEquivalent();
        }

        // The selection starts in editable content or non-editable content inside a different editable ancestor, 
        // move forward until non-editable content inside the same lowest editable ancestor is reached.
        Node* startEditableAncestor = lowestEditableAncestor(m_start.containerNode());      
        if (startRoot || startEditableAncestor != baseEditableAncestor) {
            Position p = nextVisuallyDistinctCandidate(m_start);
            Node* shadowAncestor = startRoot ? startRoot->shadowAncestorNode() : 0;
            if (p.isNull() && startRoot && (shadowAncestor != startRoot))
                p = positionBeforeNode(shadowAncestor);
            while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) {
                Node* root = editableRootForPosition(p);
                shadowAncestor = root ? root->shadowAncestorNode() : 0;
                p = isAtomicNode(p.containerNode()) ? positionInParentAfterNode(p.containerNode()) : nextVisuallyDistinctCandidate(p);
                if (p.isNull() && (shadowAncestor != root))
                    p = positionBeforeNode(shadowAncestor);
            }
            VisiblePosition next(p);
            
            if (next.isNull()) {
                // The selection crosses an Editing boundary.  This is a
                // programmer error in the editing code.  Happy debugging!
                ASSERT_NOT_REACHED();
                m_base = Position();
                m_extent = Position();
                validate();
                return;
            }
            m_start = next.deepEquivalent();
        }
    }
    
    // Correct the extent if necessary.
    if (baseEditableAncestor != lowestEditableAncestor(m_extent.containerNode()))
        m_extent = m_baseIsFirst ? m_end : m_start;
}
Esempio n. 22
0
		std::string 
		_nes_rom::header_as_string(
			__in const nes_rom_header &header,
			__in_opt bool verbose
			)
		{
			size_t iter = 0;
			uint32_t mapper = 0, rom_character = 0, rom_program = 0;
			std::stringstream result;

			if(!validate(header)) {
				THROW_NES_ROM_EXCEPTION(NES_ROM_EXCEPTION_MALFORMED);
			}

			result << "header: \'";

			for(; iter < ROM_MAGIC_LEN; ++iter) {
				result << (std::isprint((char) header.magic[iter]) ? (char) header.magic[iter] : ' ');
			}

			rom_character = header.rom_character;
			rom_program = header.rom_program;
			result << "\'" << std::endl << "program rom: " << rom_program << " (x" << ROM_PROGRAM_LEN << ")" 
				<< std::endl << "character rom: " << rom_character << " (x" << ROM_CHARACTER_LEN << ")";

			if(verbose) {
				mapper = (((header.flag_7.mapper_high << BITS_PER_NIBBLE) & 0xf0)
					| (header.flag_6.mapper_low & 0xf));

				result << std::endl << "format: " << ((header.flag_7.format == ROM_INES_2) ? 2 : 1) 
					<< std::endl << "mapper: " << mapper
					<< std::endl << "[flag_6]"
					<< std::endl << "--- mirroring: " << FLAG_6_MIRRORING_STRING(header.flag_6.mirroring) 
					<< " (" << (int) header.flag_6.mirroring << ")"
 					<< std::endl << "--- sram present: " << (int) header.flag_6.sram
					<< std::endl << "--- trainer present: " << (int) header.flag_6.trainer
					<< std::endl << "--- four-scrren mode: "<< (int) header.flag_6.four_screen_mode
					<< std::endl << "[flag_7]"
					<< std::endl << "--- vs. unisystem: " << (int) header.flag_7.vs
					<< std::endl << "--- playchoice-10: " << (int) header.flag_7.pc;

				if(header.flag_7.format == ROM_INES_2) {
					mapper |= ((header.extension.ines_2.flag_8.mapper_high << BITS_PER_BYTE) 
						& 0xf00);
					rom_character |= ((header.extension.ines_2.flag_9.rom_character_high << BITS_PER_BYTE)
						& 0xf00);
					rom_program |= ((header.extension.ines_2.flag_9.rom_program_high << BITS_PER_BYTE)
						& 0xf00);

					result << std::endl << "[flag_8]" 
						<< std::endl << "--- mapper (ext): " << mapper
						<< std::endl << "--- submapper: " 
						<< (int) header.extension.ines_2.flag_8.mapper_sub
						<< std::endl << "[flag_9]"
						<< std::endl << "--- program rom (ext): " << rom_program
						<< std::endl << "--- character rom (ext): " << rom_character
						<< std::endl << "[flag_10]"
						<< std::endl << "--- program non-sram: "
						<< (int) header.extension.ines_2.flag_10.rom_program_non_sram
						<< std::endl << "--- program sram: "
						<< (int) header.extension.ines_2.flag_10.rom_program_sram
						<< std::endl << "[flag_11]"
						<< std::endl << "--- character non-sram: "
						<< (int) header.extension.ines_2.flag_11.rom_character_non_sram
						<< std::endl << "--- character sram: "
						<< (int) header.extension.ines_2.flag_11.rom_character_sram
						<< std::endl << "[flag_12]"
						<< std::endl << "--- tv mode: "
						<< FLAG_12_2_TV_MODE_STRING(header.extension.ines_2.flag_12.mode)
						<< " (" << (int) header.extension.ines_2.flag_12.mode << ")"
						<< std::endl << "[flag_13]"
						<< std::endl << "--- vs. ppu: "
						<< (int) header.extension.ines_2.flag_13.vs_ppu
						<< std::endl << "--- vs. mode: "
						<< (int) header.extension.ines_2.flag_13.vs_mode; 
				} else {
					result << std::endl << "[flag_8]" 
						<< std::endl << "--- program ram: " 
						<< (int) header.extension.ines_1.block_program_ram
						<< " (x" << RAM_PROGRAM_LEN << ")"
						<< std::endl << "[flag_9]" 
						<< std::endl << "--- tv mode: " 
						<< FLAG_9_1_TV_MODE_STRING(header.extension.ines_1.flag_9.mode)
						<< " (" << (int) header.extension.ines_1.flag_9.mode << ")"
						<< std::endl << "flag_10]" 
						<< std::endl << "--- tv mode: " 
						<< FLAG_10_1_TV_MODE_STRING(header.extension.ines_1.flag_10.mode)
						<< " (" << (int) header.extension.ines_1.flag_10.mode << ")"
						<< std::endl << "--- program ram present: " 
						<< (int) header.extension.ines_1.flag_10.ram
						<< std::endl << "--- bus conflict present: "
						<< (int) header.extension.ines_1.flag_10.bus_conflict;
				}
			}

			return result.str();
		}
Esempio n. 23
0
/**
Getter for t dimension
@return t dimension.
*/
Mantid::Geometry::IMDDimension_sptr MDGeometryXMLParser::getTDimension() const {
  validate();
  return m_tDimension;
}
// ---------------------------------------------------------------------------
//  GeneralAttributeCheck: Validation methods
// ---------------------------------------------------------------------------
void
GeneralAttributeCheck::checkAttributes(const DOMElement* const elem,
                                       const unsigned short elemContext,
                                       TraverseSchema* const schema,
                                       const bool isTopLevel,
                                       ValueVectorOf<DOMNode*>* const nonXSAttList)
{
    if (nonXSAttList)
        nonXSAttList->removeAllElements();

    if (elem == 0 || !fAttMap || elemContext>=E_Count)
        return;

    const XMLCh* elemName = elem->getLocalName();
    if (!XMLString::equals(SchemaSymbols::fgURI_SCHEMAFORSCHEMA, elem->getNamespaceURI())) {
        schema->reportSchemaError
        (
            elem
            , XMLUni::fgXMLErrDomain
            , XMLErrs::ELTSchemaNS
            , elemName
        );
    }

    DOMNamedNodeMap* eltAttrs = elem->getAttributes();
    const XMLSize_t  attrCount = eltAttrs->getLength();
    XMLByte          attList[A_Count];

    memset(attList, 0, sizeof(attList));

    for (XMLSize_t i = 0; i < attrCount; i++) {

        DOMNode*     attribute = eltAttrs->item(i);
        const XMLCh* attName = attribute->getNodeName();

        // skip namespace declarations
        if (XMLString::equals(attName, XMLUni::fgXMLNSString)
            || XMLString::startsWith(attName, XMLUni::fgXMLNSColonString))
            continue;

        // Bypass attributes that start with xml
        // add this to the list of "non-schema" attributes
        if ((*attName == chLatin_X || *attName == chLatin_x)
           && (*(attName+1) == chLatin_M || *(attName+1) == chLatin_m)
           && (*(attName+2) == chLatin_L || *(attName+2) == chLatin_l)) {

           if (nonXSAttList)
                nonXSAttList->addElement(attribute);

            continue;
        }

        // for attributes with namespace prefix
        const XMLCh* attrURI = attribute->getNamespaceURI();

        if (attrURI != 0 && *attrURI) {

            // attributes with schema namespace are not allowed
            // and not allowed on "documentation" and "appInfo"
            if (XMLString::equals(attrURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) ||
                XMLString::equals(elemName, SchemaSymbols::fgELT_APPINFO) ||
                XMLString::equals(elemName, SchemaSymbols::fgELT_DOCUMENTATION)) {

                schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                                          isTopLevel?XMLErrs::AttributeDisallowedGlobal:XMLErrs::AttributeDisallowedLocal, 
                                          attName, elemName);
            }
            else if (nonXSAttList)
            {
                nonXSAttList->addElement(attribute);
            }

            continue;
        }

        int attNameId = A_Invalid;
        attName = attribute->getLocalName();

        bool bContinue=false;   // workaround for Borland bug with 'continue' in 'catch'
        try {
            attNameId= fAttMap->get(attName, fMemoryManager);
        }
        catch(const OutOfMemoryException&)
        {
            throw;
        }
        catch(...) {

            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                                      isTopLevel?XMLErrs::AttributeDisallowedGlobal:XMLErrs::AttributeDisallowedLocal, 
                                      attName, elemName);
            bContinue=true;
        }
        if(bContinue)
            continue;

        if (fgElemAttTable[elemContext][attNameId] & Att_Mask) {

            attList[attNameId] = 1;
            validate
            (
                elem
                , attName
                , attribute->getNodeValue()
                , fgElemAttTable[elemContext][attNameId] & DV_Mask
                , schema
            );
        }
        else {
            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                                      isTopLevel?XMLErrs::AttributeDisallowedGlobal:XMLErrs::AttributeDisallowedLocal, 
                                      attName, elemName);
        }
    }

    // ------------------------------------------------------------------
    // Check for required attributes
    // ------------------------------------------------------------------
    for (unsigned int j=0; j < A_Count; j++) {

        if ((fgElemAttTable[elemContext][j] & Att_Required) && attList[j] == 0) {
            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, 
                                      isTopLevel?XMLErrs::AttributeRequiredGlobal:XMLErrs::AttributeRequiredLocal, 
                                      fAttNames[j], elemName);
        }
    }
}
Esempio n. 25
0
/**
 Determine wheter t dimension is present.
 @return true if available.
*/
bool MDGeometryXMLParser::hasTDimension() const {
  validate();
  return nullptr != m_tDimension.get();
}
Esempio n. 26
0
void PST_Edge::make_facets( 
    const std::vector<double>& coordinates,
    const std::vector<int>& connections,
    double tolerance, 
    DLIList<PST_Edge*>& edge_list )
{
  DLIList<PST_Face*> face_list;
  double tol_sqr = tolerance * tolerance;
  int i, j, k, numcoords, numtriangles;
  
  numcoords = coordinates.size()/3;
  numtriangles = connections.size()/3;
  //The list of points created.
  PST_Point** ptlist = new PST_Point*[numcoords];
  
  //The list of indices into ptlist, where the index into this
  //list is the same as the index into the point list, and
  //the value in this list is the index of the corresponding 
  //point in ptlist.  This is used because some points will
  //be merged due to the tolerance.  
  int* ptindex_list = new int[numcoords];
   
  //Create the points
  k = 0;
  for( i = 0; i < numcoords; i++ )
  {
    CubitVector pos( coordinates[3*i], coordinates[3*i+1], coordinates[3*i+2] );
 
    //Check if we need to merge this point with a different point
    for( j = 0; j < k; j++ )
    {
      if( (*(ptlist[j]) - pos).length_squared() <= tol_sqr )
        break;
    }
    if( j == k )
    {
      ptlist[k] = new PST_Point( pos );
      ptlist[k++]->sequence = i;
    }
    ptindex_list[i] = j;
  } 
  
  int fail_count = 0;
  for ( i = 0; i < numtriangles; i++ )
  {
    int i1 = ptindex_list[connections[3*i  ]];
    int i2 = ptindex_list[connections[3*i+1]];
    int i3 = ptindex_list[connections[3*i+2]];
    if ( i1 == i2 || i2 == i3 || i3 == i1 )
    {
      PRINT_ERROR("Degenerate facet encountered in PST_Edge::make_facets()\n");
      fail_count++;
    }
    else
    {
      PST_Face* new_face 
        = PST_Edge::create_face( ptlist[i1], ptlist[i2], ptlist[i3] );
      if( new_face ){
        face_list.append(new_face);
        new_face->sequence = i;
      }
      else{
        fail_count++;
      }
    }
  }
   
  if( fail_count > 0 )
    PRINT_ERROR("Failed to construct %d facets in PST_Data::make_facets(..)\n",
      fail_count);
   
  delete [] ptindex_list;
  delete [] ptlist;
  
  if(fail_count == 0)
  {
    PST_Edge::edges( face_list, edge_list );
    validate( edge_list, true );
    bool debug1 = false;
    if (debug1)
      debug_draw_edges( edge_list, CUBIT_BLUE, CUBIT_RED, true );
  }
}
Esempio n. 27
0
void WSrcCards::Shuffle()
{
    std::random_shuffle(cards.begin(), cards.end());
    validate();
}
Esempio n. 28
0
void checkDock::validateExtent()
{
  validate( ValidateExtent );
}
void peanoclaw::tests::GhostLayerCompositorTest::testTimesteppingVeto2D() {
  #if defined(Dim2)

  for(int vetoIndex = 0; vetoIndex < TWO_POWER_D; vetoIndex++) {

    logDebug("testTimesteppingVeto2D", "testing vetoIndex=" << vetoIndex);

    peanoclaw::Patch patches[TWO_POWER_D];

    for(int i = 0; i < TWO_POWER_D; i++) {
      patches[i] = createPatch(
        3,       //Unknowns per subcell
        0,       //Aux fields per subcell
        0,       //Aux fields per subcell
        16,      //Subdivision factor
        2,       //Ghostlayer width
        0.0,     //Position
        1.0/3.0, //Size
        0,       //Level
        0.0,     //Current time
        1.0,     //Timestep size
        1.0      //Minimal neighbor time
      );
    }
    patches[vetoIndex] =
        createPatch(
            3,       //Unknowns per subcell
            0,       //Aux fields per subcell
            0,       //Aux fields per subcell
            16,      //Subdivision factor
            2,       //Ghostlayer width
            0.0,     //Position
            1.0/3.0, //Size
            0,       //Level
            0.5,     //Current time
            1.0,     //Timestep size
            1.0      //Minimal neighbor time
           );

    for(int i = 0; i < TWO_POWER_D; i++) {
      patches[i].getTimeIntervals().resetMinimalNeighborTimeConstraint();
      validate(patches[i].isValid());
    }

    peanoclaw::tests::NumericsTestStump numerics;
    peanoclaw::interSubgridCommunication::GhostLayerCompositor ghostLayerCompositor
      = peanoclaw::interSubgridCommunication::GhostLayerCompositor(
          patches,
          0,
          numerics,
          false
          );
    ghostLayerCompositor.fillGhostLayersAndUpdateNeighborTimes(-1);

    for(int cellIndex = 0; cellIndex < 4; cellIndex++) {
      if(cellIndex == vetoIndex) {
        validateNumericalEqualsWithParams2(patches[cellIndex].getTimeIntervals().getMinimalNeighborTimeConstraint(), 1.0, vetoIndex, cellIndex);
        validateNumericalEqualsWithParams2(!patches[cellIndex].getTimeIntervals().isBlockedByNeighbors(), false, vetoIndex, cellIndex);
      } else {
        validateNumericalEqualsWithParams2(patches[cellIndex].getTimeIntervals().getMinimalNeighborTimeConstraint(), 1.0, vetoIndex, cellIndex);
        validateNumericalEqualsWithParams2(!patches[cellIndex].getTimeIntervals().isBlockedByNeighbors(), true, vetoIndex, cellIndex);
      }
    }
  }
  #endif
}
Esempio n. 30
0
BufferElementInfo::BufferElementInfo(const BufferElementInfo& rhs)
{
	*this = rhs;
	validate();
}