Пример #1
0
void TypeSet::load(const VariantList& stream)
{
  StringArray names;
  names << stream;
  for( auto typeStr : names )
  {
    object::Type type = findType( typeStr );
    if( type != object::unknown )
    {
      insert( type );
    }
  }
}
Пример #2
0
int outputCheck(ASTnode* l){//receives leaf
	do{
		if(!isDeclared(l->array[0])){
			semanticError(1,l->array[0]->t);
			return 0;
		}
		typeCounter++;
		type[typeCounter]=findType(l->array[0],1);
		SymbolTableEntryNode* t=getSymbolTableNode(l->array[0]);
		t->type.id.initialized=1;
		l=l->array[1];		
		}while(l->array[1]!=NULL);
	}
Пример #3
0
Line* Tokenizer::tokenizeLine(int linenum, std::string linetext, FileStructure fstruc)
{
	Line* line = new Line;
	auto tokenMaps = findTokens(linetext);
	line->lnum = linenum;
	line->lblock = fstruc.findBlockContainingLine(linenum);
	line->lkeys = tokenMaps[0];
	line->lvars = tokenMaps[1];
	line->lops = tokenMaps[2];
	line->llits = tokenMaps[3];
	line->ltype = findType(line);
	return line;
}
Пример #4
0
static jboolean parseEnumElementValue(Env* env, void** attributes, Object* classLoader, jvalue* result) {
    jbyte tag = getByte(attributes);
    if (tag != 'e') return throwFormatError(env, "java.lang.Enum");
    char* className = getString(attributes);
    char* constName = getString(attributes);
    Class* c = findType(env, className, classLoader);
    if (c) {
        ClassField* f = rvmGetClassField(env, c, constName, className);
        if (f) {
            result->l = (jobject) rvmGetObjectClassFieldValue(env, c, f);
        }
    }
    return result->l ? TRUE : FALSE;
}
Пример #5
0
void
SchemaTypeTuple::checkRule(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				typeName,
	const StringVector &		typeArgs,
	const char *				rule) const throw(ConfigurationException)
{
	StringBuffer				msg;
	int							i;
	int							len;
	const char *				elemType;
	SchemaType *				typeDef;

	//--------
	// Check there is at least one pair of type and name arguments.
	//--------
	len = typeArgs.length();
	if ((len == 0) || (len % 2 != 0)) {
		msg << "the '" << typeName << "' type requires pairs of type and "
			<< "name arguments in rule '" << rule << "'";
		throw ConfigurationException(msg.c_str());
	}

	//--------
	// Check that all the type arguments are valid types.
	//--------
	for (i = 0; i < len; i+=2) {
		elemType = typeArgs[i+0];
		typeDef = findType(sv, elemType);
		if (typeDef == 0) {
			msg << "unknown type '" << elemType << "' in rule '" << rule << "'";
			throw ConfigurationException(msg.c_str());
		}
		switch (typeDef->cfgType()) {
		case Configuration::CFG_STRING:
			break;
		case Configuration::CFG_LIST:
			msg << "you cannot embed a list type ('" << elemType
				<< "') inside a " << "tuple in rule '" << rule << "'";
			throw ConfigurationException(msg.c_str());
		case Configuration::CFG_SCOPE:
			msg << "you cannot embed a scope type ('" << elemType
				<< "') inside a " << "tuple in rule '" << rule << "'";
			throw ConfigurationException(msg.c_str());
		default:
			assert(0); // Bug!
		}
	}
}
Пример #6
0
void QDBusMetaObjectGenerator::parseSignals()
{
    QDBusIntrospection::Signals::ConstIterator signal_it = data->signals_.constBegin();
    QDBusIntrospection::Signals::ConstIterator signal_end = data->signals_.constEnd();
    for ( ; signal_it != signal_end; ++signal_it) {
        const QDBusIntrospection::Signal &s = *signal_it;
        Method mm;

        mm.name = s.name.toLatin1();
        QByteArray prototype = mm.name;
        prototype += '(';

        bool ok = true;

        // build the output argument list
        for (int i = 0; i < s.outputArgs.count(); ++i) {
            const QDBusIntrospection::Argument &arg = s.outputArgs.at(i);

            Type type = findType(arg.type.toLatin1(), s.annotations, "Out", i);
            if (type.id == QVariant::Invalid) {
                ok = false;
                break;
            }

            mm.inputSignature += arg.type.toLatin1();
            mm.inputTypes.append(type.id);

            mm.parameters.append(arg.name.toLatin1());
            mm.parameters.append(',');
            
            prototype.append(type.name);
            prototype.append(',');
        }
        if (!ok) continue;

        // convert the last commas:
        if (!mm.parameters.isEmpty()) {
            mm.parameters.truncate(mm.parameters.length() - 1);
            prototype[prototype.length() - 1] = ')';
        } else {
            prototype.append(')');
        }

        // meta method flags
        mm.flags = AccessProtected | MethodSignal | MethodScriptable;

        // add
        methods.insert(QMetaObject::normalizedSignature(prototype), mm);
    }
}
Пример #7
0
static jboolean getAnnotationDefaultIterator(Env* env, jbyte type, void* attributes, void* data) {
    Object** result = (Object**) ((void**) data)[0];
    Method* method = (Method*) ((void**) data)[1];
    if (type == ANNOTATION_DEFAULT) {
        Class* c = findType(env, rvmGetReturnType(method->desc), method->clazz->classLoader);
        if (c) {
            jvalue value = {0};
            if (parseElementValue(env, &attributes, c, method->clazz->classLoader, &value)) {
                *result = rvmBox(env, c, &value);
            }
        }
        return FALSE; // Stop iterating
    }
    return TRUE; // Continue with next attribute
}
Пример #8
0
//TODO more efficient way ?
int MTGAllCards::countByType(const string &_type)
{
    int type_id = findType(_type);

    int result = 0;
    map<int, MTGCard *>::iterator it;
    for (it = collection.begin(); it != collection.end(); it++)
    {
        MTGCard * c = it->second;
        if (c->data->hasType(type_id))
        {
            result++;
        }
    }
    return result;
}
Пример #9
0
int Lanes::add(int type, const CGitHash& next, int pos) {

	// first check empty lanes starting from pos
	if (pos < (int)typeVec.size()) {
		pos = findType(EMPTY, pos);
		if (pos != -1) {
			typeVec[pos] = type;
			nextShaVec[pos] = next;
			return pos;
		}
	}
	// if all lanes are occupied add a new lane
	typeVec.push_back(type);
	nextShaVec.push_back(next);
	return (int)typeVec.size() - 1;
}
Пример #10
0
void var_dec(int level)
{
    int this_line = line_cnt;
    

    findType(this_line);
    
    id_num_check(ID, this_line);
    
    if(strcmp(tokenPos->textOfLine,";") == 0)
    {
        push(SEMI, this_line);
        pTreeType[this_line][0] = DEC_VAR;
        pTreeType[this_line][1] = level;
    }
    else if(strcmp(tokenPos->textOfLine,"[") == 0)
    {
        //교제에 있는 C-언어의 정의에서 전역변수로 배열을 정의할때
        //ID [NUM]이 되기 때문에 다른 하위 Terminal로 넘어가지 않고 바로 종결. NUM만 있으면 되니.
        push(LSGWAL, this_line);
        
        
        id_num_check(NUM,this_line);
        
        if(strcmp(tokenPos->textOfLine,"]") != 0)
        {
            print_err(tokenPos->lineNum,tokenPos->textOfLine,"VAR_DEC","]",tokenPos->tokenType);
            
        }
        else
        {
            push(RSGWAL, this_line);
            
        }
        pTreeType[this_line][0] = DEC_VAR;
        pTreeType[this_line][1] = level;
        semi_check(this_line);
        
        
    }
    else
    {
        print_err(tokenPos->lineNum,tokenPos->textOfLine,"VAR_DEC","; or ]",tokenPos->tokenType);
    }
}
const bool CtrlrComponentTypeManager::isStatic(CtrlrComponent *componentToIdentify)
{
	if (	findType(componentToIdentify) == Ids::uiArrow
			|| findType(componentToIdentify) == Ids::uiGroup
			|| findType(componentToIdentify) == Ids::uiTabs
			|| findType(componentToIdentify) == Ids::uiImage
			|| findType(componentToIdentify) == Ids::uiLCDLabel
			|| findType(componentToIdentify) == Ids::uiLabel
			|| findType(componentToIdentify) == Ids::uiNone
			)
	{
		return (true);
	}

	return (false);
}
Пример #12
0
SmartPointer<VMEntryType> VirtualMachine::findType(std::string const& name) {

    NamespaceEntry entry;

    //If the namespace entry is not found in the namespace
    if (!VM::NamespaceEntry::searchNamespace(namespace_, name, entry)) {

        VM_PRINTF_LOG("Type %s not found, inspecting to check if array\n", name.c_str());

        //If it starts with 'array(' try to generate it from existing types
        char const* prefix = "array(";

        if (strncmp(prefix, name.c_str(), strlen(prefix)) == 0) {

            std::string subtypeName = name.substr(strlen(prefix), name.size() - strlen(prefix) - 1);

            VM_PRINTF_LOG("Generating subtype %s\n", subtypeName.c_str());

            SmartPointer<VMEntryType> subtype = findType(subtypeName);

            if (subtype.get() == nullptr) {
                VM_PRINTF_FATAL("Cannot create array of invalid subtype %s\n", subtypeName.c_str());
                return nullptr;
            }

            SmartPointer<VMEntryType> entryType = SmartPointer<VMEntryType>(new VMEntryType(name, subtype));
            registerEntry(name, entryType);
            VM_PRINTF_LOG("Generating new type %s\n", name.c_str());
            return entryType;
        } else {
            VM_PRINTF_LOG("Prefix of %s does not match with array(\n", name.c_str());
            return nullptr;
        }
    }

    //If the entry in the namespace specified is not a type then return null
    if (entry.getType() != Type) {
        VM_PRINTF_LOG("Error searched type %s (%i)\n", name.c_str(), entry.getType());
        return nullptr;
    }

    return entry.getTypeReference();
}
Пример #13
0
IType* TypeManager::getType( const std::string& typeName )
{
	if( typeName.empty() )
		CORAL_THROW( IllegalArgumentException, "empty type name" );

	// is typeName an array?
	if( typeName[typeName.length() - 1] == ']' )
	{
		// get the elementType by removing the "[]" suffix
		IType* elementType = getType( std::string( typeName, 0, typeName.length() - 2 ) );
		return getArrayOf( elementType );
	}

	IType* type = findType( typeName );
	if( type )
		return type;

	return loadTypeOrThrow( typeName );
}
Пример #14
0
bool
SchemaTypeTypedef::isA(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				value,
	const char *				typeName,
	const StringVector &		typeArgs,
	int							indentLevel,
	StringBuffer &				errSuffix) const
{
    (void) value;
    (void) typeName;
    
	assert(typeArgs.length() == 0);
	const char* baseTypeName = m_baseTypeName.c_str();
	SchemaType* baseTypeDef = findType(sv, baseTypeName);
	assert(baseTypeDef != 0);
	bool result = callIsA(baseTypeDef, sv, cfg, value, baseTypeName, m_baseTypeArgs,
					 indentLevel + 1, errSuffix);
	return result;
}
Пример #15
0
int deckTlvGetString(TlvArea *tlv, int type, char *string, int length) {
  int pos = findType(tlv, type);
  int strlength = 0;

  if (pos >= 0) {
    strlength = tlv->data[pos+1];

    if (strlength > (length-1)) {
      strlength = length-1;
    }

    memcpy(string, &tlv->data[pos+2], strlength);
    string[strlength] = '\0';

    return strlength;
  } else {
    string[0] = '\0';

    return -1;
  }
}
Пример #16
0
void
SchemaTypeTypedef::validate(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				scope,
	const char *				name,
	const char *				typeName,
	const char *				origTypeName,
	const StringVector &		typeArgs,
	int							indentLevel) const
											throw(ConfigurationException)
{
	StringBuffer				msg;
	SchemaType *				baseTypeDef;
	const char *				baseTypeName;

	assert(typeArgs.length() == 0);
	baseTypeName = m_baseTypeName.c_str();
	baseTypeDef = findType(sv, baseTypeName);
	callValidate(baseTypeDef, sv, cfg, scope, name, baseTypeName, origTypeName,
				 m_baseTypeArgs, indentLevel + 1);
}
Пример #17
0
int findTypeF(ASTnode* F){
	if(F->label==37)//(AE)
		return findTypeAE(F);
	else{
		if(F->label==13){//ID or matrix element
			if(F->array[1]==NULL){
				/*SymbolTableEntryNode *t=getSymbolTableNode(F->array[0]);
				if(t==NULL)
					return -1;
				if(t->type.id.initialized!=1)
					return -1;*/
				return findType(F->array[0],0);
				}
			return 55;// INT, if matrix element then has to be int! Not checking array out of bounds here!
		}
		if(F->label==21){
			//matrixSize[0]=0;
			//matrixSize[1]=0;
		}
		return ASTlabelType(F->label);
		}
}
Пример #18
0
void param(int level)
{
    int this_line = line_cnt;
    pTreeType[this_line][0] = PARAM;
    pTreeType[this_line][1] = level;
	findType(this_line);
    id_num_check(ID,this_line);
    if(strcmp(tokenPos->textOfLine,"[") == 0)
    {
        //교제에 있는 C-언어의 정의에서 전역변수로 배열을 정의할때
        //ID [NUM]이 되기 때문에 다른 하위 Terminal로 넘어가지 않고 바로 종결. NUM만 있으면 되니.
        push(LSGWAL, this_line);
        
        if(strcmp(tokenPos->textOfLine,"]") != 0)
        {
            id_num_check(NUM,this_line);
            if(strcmp(tokenPos->textOfLine,"]") != 0)
            {
                print_err(tokenPos->lineNum,tokenPos->textOfLine,"PARAM","]",tokenPos->tokenType);
                
            }
            else
            {
                push(RSGWAL, this_line);
                
            }
        }
        else
        {
            
            push(RSGWAL, this_line);
            
        }
        
        
        
    }
    
}
Пример #19
0
    /**
     * @brief SignatureMaker::makeField
     * @param field
     * @return
     */
    QString SignatureMaker::makeField(const Entity::SharedField &field) const
    {
        if (!field)
            return tr("No field");

        QString result = makeTypeOrExtType(findType(field->typeId()));
        if (result.isEmpty())
            return tr("Type is not found");

        result.append(QChar::Space).append(field->fullName());

        const auto& keywords = field->keywords();
        if (!keywords.isEmpty()) {
            QStringList kw;
            kw.reserve(keywords.size());
            for (auto &&keyword : keywords)
                kw << Util::fieldKeywordToString(keyword);

            result.prepend(QChar::Space).prepend(kw.join(QChar::Space));
        }

        return result;
    }
Пример #20
0
void filter::getOptions(argStruct *arguments){
  fname=angsd::getArg("-filter",fname,arguments);
  
  if(fname!=NULL)
    doFilter = findType(fname);
  //1=bim 2=keep

  doMajorMinor = angsd::getArg("-doMajorMinor",doMajorMinor,arguments);
  if(doMajorMinor==3 && doFilter!=1){
    fprintf(stderr,"Must supply -filter with .bim file if -doMajorMinor 3\n");
    exit(0);
  }
  

  if(doFilter==1){
    fm = getMap(fname,revMap);
    fprintf(stderr,"\t-> number of sites in filter: %lu\n",fm.size());
  }else if(doFilter==2){
    fp = getFILE(fname,"r");
    //  readSites();
    fprintf(stderr,"Filtering with .keep is still beta\n");
  }
  minInd = angsd::getArg("-minInd",minInd,arguments);
}
Пример #21
0
int main(int argc, char** argv) {
    
    /*File Pointers*/
        FILE *namef;
        FILE *entrantf;
        FILE *nodef;
        FILE *trackf;
        FILE *timef;
        FILE *coursef;
        FILE *logf;
    
    /*Filenames*/
    char namefile[30];
    char nodesfile[30];
    char tracksfile[30];
    char entrantsfile[30];
    char coursesfile[30];
    char cp_timesfile1[30];
    char logfile[30];
    
    /*These are the structures that will contain all the data read in*/
    NAME title[3];
    COURSE courses[26];
    ENTRANT *entrant_head = NULL;
    NODE *node_head = NULL;
    TRACK *track_head = NULL;
    TIME *time_head = NULL;

    char my_buffer[100];
    
    /*These variables are used when reading in files and calculating queries*/
    char name[100];
    int i, j, n1, n2, n3, h, m, timesanswer, answer, qh, qm, node;
    char t;

    i = 0;
    answer = 0;
    timesanswer = 0;
    
    
    /*This is where the user is asked to enter all the files that are needed to run the program They are entered sequentially
          to ensure that all files are read in and that none conflict with each other.*/
    
    printf("Please enter the name of the log file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", logfile);
    
    logf = fopen(logfile, "a");
    
    fprintf(logf, "Log File Opened\n");

    printf("Please enter the names file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", namefile);

    namef = fopen(namefile, "r");

    while (fgets(my_buffer, 80, namef) != NULL) {
        strcpy(title[i].line, my_buffer);
        i++;
    }

    fclose(namef);

    
    printf("Please enter the nodes file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", nodesfile);

    createLinkedNodes(&node_head, nodef, nodesfile);
     




    printf("Please enter the tracks file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", tracksfile);

    createLinkedTracks(&track_head, trackf, tracksfile);




    printf("Please enter the entrants file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", entrantsfile);

    createLinkedEntrants(&entrant_head, entrantf, entrantsfile);





    printf("Please enter the courses file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", coursesfile);

    coursef = fopen(coursesfile, "r");


    while (!feof(coursef)) {
        i = 0;
        if (fscanf(coursef, "%c %d", &(courses[i].name),
                &(courses[i].amount)) == 2) {

            for (j = 0; j < courses[i].amount; j++) {
                while (fscanf(coursef, " %d", &(courses[i].nodes[j])) == 1);

            }
            fscanf(coursef, "\n");

            i++;
        } else {
            fprintf(stderr, "Error: file format wrong.\n");
            break;
        }
    }

    /*This prompts the user to choose how they will enter the first competitor's time. There is an
        option to add more later.*/

    printf(" Choose how times for competitors are entered.\n");
    printf(" 1. Enter a pre-prepared file of all competitors' times.\n");
    printf(" 2. Manually enter more times for competitors.\n");

    scanf("%d", &timesanswer);

    if (timesanswer == 1) {

        printf("Please enter the times file: \n");
        scanf(" %[a-z,A-Z,.,_,0-9]", cp_timesfile1);


        timef = fopen(cp_timesfile1, "r");

        while (fgets(my_buffer, 100, timef) != NULL) {
            sscanf(my_buffer, "%c %d %d %d:%d", &t, &n1, &n2, &h, &m);
            createLinkedTimes(&time_head, t, n1, n2, h, m);
        }

        fclose(timef);

    } else if (timesanswer == 2) {
        printf("How many times do you wish to enter? ");
        scanf(" %d", &i);
        int count = 0;
        while (count != i) {
            printf("Please enter the type of checkpoint :");
            scanf(" %[A-Z]", &t);
            printf("Please  enter the checkpoint node :");
            scanf(" %d", &n2);
            printf("Please enter the competitor number :");
            scanf(" %d", &n3);
            printf("Please enter the hours :");
            scanf(" %d", &h);
            printf("Please enter the minutes :");
            scanf(" %d", &m);

            createLinkedTimes(&time_head, t, n2, n3, h, m);

            count += 1;
        }
        printTimes(&time_head);
    }

    while (answer != 11) {

        for (i = 0; i < 3; i++) {
            printf("%s", title[i].line);
        }
        /*This prints out the last time entered into the linked list of times. This is assumed to be the current time.*/
        printf("Current Time : %02d:%02d\n", h, m);
        
        /*MENU*/
        printf("Please choose an option :\n");
        printf("1. Query the status and location of a competitor.\n");
        printf("2. Query how many competitors have not yet started.\n");
        printf("3. Query how many competitors are out on the course.\n");
        printf("4. Query how many competitors are finished.\n");
        printf("5. Add more times\n");
        printf("6. Results\n");
        printf("7. Query which competitors were excluded for going to an incorrect checkpoint\n");
        printf("8. Query which competitors were excluded for medical reasons\n");
        printf("9. Query when a competitor entered a medical checkpoint\n");
        printf("10. Query when a competitor left a medical checkpoint\n");
        printf("11. Quit\n");

        scanf("%d", &answer);
        
        /*Allows the user to query the location and status of one competitor*/
        if (answer == 1) {
            
            fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried location and status of a competitor\n", h, m, title[1].line);
            
            printf("Enter a time you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            if (compareTime(h, m, qh, qm) == 0) {
                printf("Time entered is after current time, please enter an appropriate time\n");
            } else {
                printf("Enter competitor's  number: \n");
                scanf("%d", &n1);

                findCompetitor(&entrant_head, n1, name);
                if ((strcmp(name, "Not Found")) != 0) {
                    printf("Name : %s\n", name);

                    node = 0;

                    node = findLocation(&time_head, n1, qh, qm);
                    if (node == 100) {
                        printf("Location : %d\n", node);
                        printf("Status : Finished\n");
                        printf("\n");
                    }
                    if (node == 0) {
                        printf("Status : Not Started\n");
                        printf("\n");
                    } else {
                        printf("Location : %d\n", node);
                        printf("Status : On Course\n");
                        printf("\n");
                    }

                }
                else {
                    printf("%s\n", name);
                }


            }
            
            /*Allows the user to query all the competitors that have not started*/
        } else if (answer == 2) {
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors had not started\n", h, m, title[1].line);

            printf("Enter a time for you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            queryNotStarted(&time_head, &entrant_head, qh, qm);

              /*Allows the user to query all the competitors that are out on course*/
        } else if (answer == 3) {
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors are out on course\n", h, m, title[1].line);
            
            printf("Enter a time for you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            queryOnCourse(&time_head, &entrant_head, qh, qm);
            
            
             /*Allows the user to query all the competitors that are finished*/
        }else if (answer == 4) {
            
            fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors are finished\n", h, m, title[1].line);
            
            printf("Enter a time for you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            queryFinished(&time_head, &entrant_head, qh, qm);
            
            
            /*Allows the user to enter more times*/
        } else if (answer == 5) {
            
            printf(" Choose how times for competitors are entered.\n");
            printf(" 1. Enter a pre-prepared file of all competitors' times.\n");
            printf(" 2. Manually enter more times for competitors.\n");

            scanf("%d", &timesanswer);

            if (timesanswer == 1) {
                
                 fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Added more times from a file\n", h, m, title[1].line);

                printf("Please enter the times file: \n");
                scanf(" %[a-z,A-Z,.,_,0-9]", cp_timesfile1);


                timef = fopen(cp_timesfile1, "r");

                while (fgets(my_buffer, 100, timef) != NULL) {
                    sscanf(my_buffer, "%c %d %d %d:%d", &t, &n1, &n2, &h, &m);
                    createLinkedTimes(&time_head, t, n1, n2, h, m);
                }

                fclose(timef);

                printTimes(&time_head);

            } else if (timesanswer == 2) {
                
                 fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Manually entered more times\n", h, m, title[1].line);
                
                printf("How many times do you wish to enter? ");
                scanf(" %d", &i);
                int count = 0;
                while (count != i) {
                    printf("Please enter the type of checkpoint :");
                    scanf(" %[A-Z]", &t);
                    printf("Please  enter the checkpoint node :");
                    scanf(" %d", &n2);
                    printf("Please enter the competitor number :");
                    scanf(" %d", &n3);
                    printf("Please enter the hours :");
                    scanf(" %d", &h);
                    printf("Please enter the minutes :");
                    scanf(" %d", &m);

                    createLinkedTimes(&time_head, t, n2, n3, h, m);

                    count += 1;
                }
                printTimes(&time_head);
            }
        }
        /*Allows the user to print out the results*/
        else if (answer == 6) {
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Checked results\n", h, m, title[1].line);
            
            queryResults(&time_head, &entrant_head, h, m);
        }
        
        
        
        else if(answer == 7){
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors were excluded for incorrect checkpoints \n", h, m, title[1].line);
            
              printf("Enter a time for you wish to query for : \n");
              scanf("%d:%d", &qh, &qm);

            queryWrongExclusion(&time_head, &entrant_head, qh, qm);
        }
        
        
        
        else if(answer == 8){
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors were excluded for medical reasons \n", h, m, title[1].line);
            
              printf("Enter a time for you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            queryMedicalExclusion(&time_head, &entrant_head, qh, qm);
        }

        else if (answer == 9) {
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried a competitor's entry into a medical checkpoint \n", h, m, title[1].line);
            
            int compNum = 0;
            
            
            printf("Enter a time you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            if (compareTime(h, m, qh, qm) == 0) {
                printf("Time entered is after current time, please enter an appropriate time\n");
            } else {
                printf("Enter competitor's  number: \n");
                scanf("%d", &compNum);

                findCompetitor(&entrant_head, compNum, name);
                if ((strcmp(name, "Not Found")) != 0) {
                    printf("Name : %s\n", name);

                    char type;
                    
                    type = findType(&time_head, compNum, qh, qm);
                    
                    if(type == 'A'){
                        int h = findHourTime(&time_head, compNum, qh, qm);
                        int m = findMinutesTime(&time_head, compNum, qh, qm);
                        printf("Time : %d:%d", h, m);
                    }

                }
                else {
                    printf("%s\n", name);
                }
        }
        
        }
        
        else if(answer == 10){
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried a competitor's departure from a medical checkpoint \n", h, m, title[1].line);
            
            int compNum = 0;
            
            printf("Enter a time you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            if (compareTime(h, m, qh, qm) == 0) {
                printf("Time entered is after current time, please enter an appropriate time\n");
            } else {
                printf("Enter competitor's  number: \n");
                scanf("%d", &compNum);

                findCompetitor(&entrant_head, compNum, name);
                if ((strcmp(name, "Not Found")) != 0) {
                    printf("Name : %s\n", name);

                    char type;
                    
                    type = findType(&time_head, compNum, qh, qm);
                    
                    if(type == 'D'){
                        int h = findHourTime(&time_head, compNum, qh, qm);
                        int m = findMinutesTime(&time_head, compNum, qh, qm);
                        printf("Time : %d:%d \n", h, m);
                    }

                }
                else {
                    printf("%s\n", name);
                }
            
        }
        
    }        
        
        }


    return (EXIT_SUCCESS);

}
Пример #22
0
void QDBusMetaObjectGenerator::parseMethods()
{
    //
    // TODO:
    //  Add cloned methods when the remote object has return types
    //

    QDBusIntrospection::Methods::ConstIterator method_it = data->methods.constBegin();
    QDBusIntrospection::Methods::ConstIterator method_end = data->methods.constEnd();
    for ( ; method_it != method_end; ++method_it) {
        const QDBusIntrospection::Method &m = *method_it;
        Method mm;

        mm.name = m.name.toLatin1();
        QByteArray prototype = mm.name;
        prototype += '(';

        bool ok = true;

        // build the input argument list
        for (int i = 0; i < m.inputArgs.count(); ++i) {
            const QDBusIntrospection::Argument &arg = m.inputArgs.at(i);

            Type type = findType(arg.type.toLatin1(), m.annotations, "In", i);
            if (type.id == QVariant::Invalid) {
                ok = false;
                break;
            }

            mm.inputSignature += arg.type.toLatin1();
            mm.inputTypes.append(type.id);

            mm.parameters.append(arg.name.toLatin1());
            mm.parameters.append(',');
            
            prototype.append(type.name);
            prototype.append(',');
        }
        if (!ok) continue;

        // build the output argument list:
        for (int i = 0; i < m.outputArgs.count(); ++i) {
            const QDBusIntrospection::Argument &arg = m.outputArgs.at(i);

            Type type = findType(arg.type.toLatin1(), m.annotations, "Out", i);
            if (type.id == QVariant::Invalid) {
                ok = false;
                break;
            }

            mm.outputSignature += arg.type.toLatin1();
            mm.outputTypes.append(type.id);

            if (i == 0) {
                // return value
                mm.typeName = type.name;
            } else {
                // non-const ref parameter
                mm.parameters.append(arg.name.toLatin1());
                mm.parameters.append(',');

                prototype.append(type.name);
                prototype.append("&,");
            }
        }
        if (!ok) continue;

        // convert the last commas:
        if (!mm.parameters.isEmpty()) {
            mm.parameters.truncate(mm.parameters.length() - 1);
            prototype[prototype.length() - 1] = ')';
        } else {
            prototype.append(')');
        }

        // check the async tag
        if (m.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true"))
            mm.tag = "Q_NOREPLY";

        // meta method flags
        mm.flags = AccessPublic | MethodSlot | MethodScriptable;

        // add
        methods.insert(QMetaObject::normalizedSignature(prototype), mm);
    }
}
//==============================================================================
String AudioDeviceManager::initialise (const int numInputChannelsNeeded,
                                       const int numOutputChannelsNeeded,
                                       const XmlElement* const e,
                                       const bool selectDefaultDeviceOnFailure,
                                       const String& preferredDefaultDeviceName,
                                       const AudioDeviceSetup* preferredSetupOptions)
{
    scanDevicesIfNeeded();

    numInputChansNeeded = numInputChannelsNeeded;
    numOutputChansNeeded = numOutputChannelsNeeded;

    if (e != nullptr && e->hasTagName ("DEVICESETUP"))
    {
        lastExplicitSettings = new XmlElement (*e);

        String error;
        AudioDeviceSetup setup;

        if (preferredSetupOptions != nullptr)
            setup = *preferredSetupOptions;

        if (e->getStringAttribute ("audioDeviceName").isNotEmpty())
        {
            setup.inputDeviceName = setup.outputDeviceName
                = e->getStringAttribute ("audioDeviceName");
        }
        else
        {
            setup.inputDeviceName = e->getStringAttribute ("audioInputDeviceName");
            setup.outputDeviceName = e->getStringAttribute ("audioOutputDeviceName");
        }

        currentDeviceType = e->getStringAttribute ("deviceType");

        if (findType (currentDeviceType) == nullptr)
        {
            AudioIODeviceType* const type = findType (setup.inputDeviceName, setup.outputDeviceName);

            if (type != nullptr)
                currentDeviceType = type->getTypeName();
            else if (availableDeviceTypes.size() > 0)
                currentDeviceType = availableDeviceTypes.getUnchecked(0)->getTypeName();
        }

        setup.bufferSize = e->getIntAttribute ("audioDeviceBufferSize");
        setup.sampleRate = e->getDoubleAttribute ("audioDeviceRate");

        setup.inputChannels .parseString (e->getStringAttribute ("audioDeviceInChans",  "11"), 2);
        setup.outputChannels.parseString (e->getStringAttribute ("audioDeviceOutChans", "11"), 2);

        setup.useDefaultInputChannels  = ! e->hasAttribute ("audioDeviceInChans");
        setup.useDefaultOutputChannels = ! e->hasAttribute ("audioDeviceOutChans");

        error = setAudioDeviceSetup (setup, true);

        midiInsFromXml.clear();
        forEachXmlChildElementWithTagName (*e, c, "MIDIINPUT")
            midiInsFromXml.add (c->getStringAttribute ("name"));

        const StringArray allMidiIns (MidiInput::getDevices());

        for (int i = allMidiIns.size(); --i >= 0;)
            setMidiInputEnabled (allMidiIns[i], midiInsFromXml.contains (allMidiIns[i]));

        if (error.isNotEmpty() && selectDefaultDeviceOnFailure)
            error = initialise (numInputChannelsNeeded, numOutputChannelsNeeded, 0,
                                false, preferredDefaultDeviceName);

        setDefaultMidiOutput (e->getStringAttribute ("defaultMidiOutput"));

        return error;
    }
    else
    {
        AudioDeviceSetup setup;

        if (preferredSetupOptions != nullptr)
        {
            setup = *preferredSetupOptions;
        }
        else if (preferredDefaultDeviceName.isNotEmpty())
        {
            for (int j = availableDeviceTypes.size(); --j >= 0;)
            {
                AudioIODeviceType* const type = availableDeviceTypes.getUnchecked(j);

                StringArray outs (type->getDeviceNames (false));

                int i;
                for (i = 0; i < outs.size(); ++i)
                {
                    if (outs[i].matchesWildcard (preferredDefaultDeviceName, true))
                    {
                        setup.outputDeviceName = outs[i];
                        break;
                    }
                }

                StringArray ins (type->getDeviceNames (true));

                for (i = 0; i < ins.size(); ++i)
                {
                    if (ins[i].matchesWildcard (preferredDefaultDeviceName, true))
                    {
                        setup.inputDeviceName = ins[i];
                        break;
                    }
                }
            }
        }

        insertDefaultDeviceNames (setup);
        return setAudioDeviceSetup (setup, false);
    }
}
Пример #24
0
void
SchemaTypeTuple::validate(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				scope,
	const char *				name,
	const char *				typeName,
	const char *				origTypeName,
	const StringVector &		typeArgs,
	int							indentLevel) const
											throw(ConfigurationException)
{
    (void) origTypeName;
    
	StringBuffer				msg;
	StringBuffer				errSuffix;
	StringBuffer				fullyScopedName;
	const char **				list;
	const char *				elemValue;
	const char *				elemTypeName;
	int							i;
	int							listSize;
	int							typeArgsSize;
	int							elemNameIndex;
	int							typeIndex;
	int							numElems;
	SchemaType *				elemTypeDef;
	StringVector				emptyArgs;
	bool						ok;
	const char *				sep;

	//--------
	// Check the length of the list matches the size of the tuple
	//--------
	typeArgsSize = typeArgs.length();
	assert(typeArgsSize != 0);
	assert(typeArgsSize % 2 == 0);
	numElems = typeArgsSize / 2;
	cfg->lookupList(scope, name, list, listSize);
	if (listSize != numElems) {
		cfg->mergeNames(scope, name, fullyScopedName);
		msg << cfg->fileName() << ": there should be " << numElems
			<< " entries in the '" << fullyScopedName << "' " << typeName
		    << "; entries denote";
		for (i = 0; i < numElems; i++) {
			msg << " '" << typeArgs[i*2+0] << "'";
			if (i < numElems-1) {
				msg << ",";
			}
		}
		throw ConfigurationException(msg.c_str());
	}
	//--------
	// Check each item is of the type specified in the tuple
	//--------
	for (i = 0; i < listSize; i++) {
		typeIndex     = (i * 2 + 0) % typeArgsSize;
		elemNameIndex = (i * 2 + 1) % typeArgsSize;
		elemValue = list[i];
		elemTypeName = typeArgs[typeIndex];
		elemTypeDef = findType(sv, elemTypeName);
		ok = callIsA(elemTypeDef, sv, cfg, elemValue, elemTypeName, emptyArgs,
					 indentLevel + 1, errSuffix);
		if (!ok) {
			if (errSuffix.length() == 0) {
				sep = "";
			} else {
				sep = "; ";
			}
			cfg->mergeNames(scope, name, fullyScopedName);
			msg << cfg->fileName() << ": bad " << elemTypeName << " value ('"
				<< elemValue << "') for element " << i+1 << " ('"
			    << typeArgs[elemNameIndex] << "') of the '" << fullyScopedName
				<< "' " << typeName << sep << errSuffix;
			throw ConfigurationException(msg.c_str());
		}
	}
}
Пример #25
0
static jboolean getAnnotationValue(Env* env, void** attributes, Class* expectedAnnotationClass, Object* classLoader,
        jvalue* result, jboolean ignoreClassNotFound) {

    char* annotationTypeName = getString(attributes);
    if (expectedAnnotationClass && strncmp(&annotationTypeName[1], expectedAnnotationClass->name, strlen(expectedAnnotationClass->name))) {
        return throwFormatError(env, rvmFromBinaryClassName(env, expectedAnnotationClass->name));
    }

    Class* annotationClass = expectedAnnotationClass;
    if (!annotationClass) {
        annotationClass = rvmFindClassByDescriptor(env, annotationTypeName, classLoader);
        if (!annotationClass) {
            if (ignoreClassNotFound && rvmExceptionOccurred(env)->clazz == java_lang_ClassNotFoundException) {
                rvmExceptionClear(env);
                jint length = getInt(attributes);
                for (jint i = 0; i < length; i++) {
                    getString(attributes);
                    skipElementValue(attributes);
                }
            }
            return FALSE;
        }
    }

    // Find the annotation impl class
    Class* annotationImplClass = findAnnotationImplClass(env, annotationClass, classLoader);
    if (rvmExceptionCheck(env)) return FALSE;

    jint length = getInt(attributes);
    if (length == 0) {
        // No member values specified. Use a singleton instance.
        Method* factoryMethod = rvmGetClassMethod(env, annotationImplClass, "$createSingleton", "()Ljava/lang/Object;");
        if (rvmExceptionCheck(env)) return FALSE;
        Object* annotationObject = rvmCallObjectClassMethod(env, annotationImplClass, factoryMethod);
        if (rvmExceptionCheck(env)) return FALSE;
        result->l = (jobject) annotationObject;
        return TRUE;
    }

    // Call the annotation impl $create() method
    Method* factoryMethod = rvmGetClassMethod(env, annotationImplClass, "$create", "()Ljava/lang/Object;");
    if (rvmExceptionCheck(env)) return FALSE;
    Object* annotationObject = rvmCallObjectClassMethod(env, annotationImplClass, factoryMethod);
    if (rvmExceptionCheck(env)) return FALSE;

    jint i = 0;
    for (i = 0; i < length; i++) {
        char* name = getString(attributes);
        Method* method = getAnnotationValueMethod(env, annotationClass, name);
        if (rvmExceptionCheck(env)) return FALSE;
        if (!method) {
            skipElementValue(attributes);
        } else {
            const char* memberDesc = rvmGetReturnType(method->desc);
            Class* type = findType(env, memberDesc, method->clazz->classLoader);
            Object* value = NULL;
            if (!type) {
                value = rvmExceptionClear(env);
            } else {
                jvalue v = {0};
                if (!parseElementValue(env, attributes, type, classLoader, &v)) {
                    value = rvmExceptionClear(env);
                } else {
                    value = rvmBox(env, type, &v);
                }
            }

            InstanceField* field = getAnnotationMemberField(env, annotationImplClass, method->name);
            if (!field) return FALSE;

            rvmSetObjectInstanceFieldValue(env, annotationObject, field, value);
            if (rvmExceptionCheck(env)) return FALSE;
        }
    }

    result->l = (jobject) annotationObject;
    return TRUE;
}
Пример #26
0
String AudioDeviceManager::initialiseFromXML (const XmlElement& xml,
                                              const bool selectDefaultDeviceOnFailure,
                                              const String& preferredDefaultDeviceName,
                                              const AudioDeviceSetup* preferredSetupOptions)
{
    lastExplicitSettings = new XmlElement (xml);

    String error;
    AudioDeviceSetup setup;

    if (preferredSetupOptions != nullptr)
        setup = *preferredSetupOptions;

    if (xml.getStringAttribute ("audioDeviceName").isNotEmpty())
    {
        setup.inputDeviceName = setup.outputDeviceName
            = xml.getStringAttribute ("audioDeviceName");
    }
    else
    {
        setup.inputDeviceName  = xml.getStringAttribute ("audioInputDeviceName");
        setup.outputDeviceName = xml.getStringAttribute ("audioOutputDeviceName");
    }

    currentDeviceType = xml.getStringAttribute ("deviceType");

    if (findType (currentDeviceType) == nullptr)
    {
        if (AudioIODeviceType* const type = findType (setup.inputDeviceName, setup.outputDeviceName))
            currentDeviceType = type->getTypeName();
        else if (availableDeviceTypes.size() > 0)
            currentDeviceType = availableDeviceTypes.getUnchecked(0)->getTypeName();
    }

    setup.bufferSize = xml.getIntAttribute ("audioDeviceBufferSize", setup.bufferSize);
    setup.sampleRate = xml.getDoubleAttribute ("audioDeviceRate", setup.sampleRate);

    setup.inputChannels .parseString (xml.getStringAttribute ("audioDeviceInChans",  "11"), 2);
    setup.outputChannels.parseString (xml.getStringAttribute ("audioDeviceOutChans", "11"), 2);

    setup.useDefaultInputChannels  = ! xml.hasAttribute ("audioDeviceInChans");
    setup.useDefaultOutputChannels = ! xml.hasAttribute ("audioDeviceOutChans");

    error = setAudioDeviceSetup (setup, true);

    midiInsFromXml.clear();

    forEachXmlChildElementWithTagName (xml, c, "MIDIINPUT")
        midiInsFromXml.add (c->getStringAttribute ("name"));

    const StringArray allMidiIns (MidiInput::getDevices());

    for (int i = allMidiIns.size(); --i >= 0;)
        setMidiInputEnabled (allMidiIns[i], midiInsFromXml.contains (allMidiIns[i]));

    if (error.isNotEmpty() && selectDefaultDeviceOnFailure)
        error = initialise (numInputChansNeeded, numOutputChansNeeded,
                            nullptr, false, preferredDefaultDeviceName);

    setDefaultMidiOutput (xml.getStringAttribute ("defaultMidiOutput"));

    return error;
}
Пример #27
0
ClassDef::ClassDef( char * defFile ):openErr(0)
{

  // allocate for the input line from the class defination file.
  //
  char * classDefLine = new char[256];

  // open the needed files:
  //
  ifstream classDef(defFile);
  if( ! classDef )
  {
     cerr << "Could not open class definition file: " << defFile << endl;
     openErr = true;
  }

  cppFile = defFile;
  hppFile = defFile;
  cppFile += ".cpp";
  hppFile += ".hpp";

  if( !openErr )
  {
    char * result;
    const char * Level2;
    const char * Level3;

    // expect the first line in the class def to contain the CLASS
    // keyword.
    //
    if ( classDef.getline( classDefLine, 80 ) )
    {

      cout << classDefLine << endl;

      result = strtok( classDefLine," " );

      cout << result << endl;

      if( !strcmp( result, tokClassHeader ) )
      {
	result = strtok( '\0', " " );
	cout << result << endl;
	className = result;
        className.trim();
      }
    }

    while ( classDef.getline( classDefLine, 80 ) && className.max() )
    {
      trim( classDefLine );

      if( strlen( classDefLine ) )
      {
        cout << classDefLine << endl;

        // level 2
        if( strstr( classDefLine, tokPrivate ) )
        {
		 Level2 = tokPrivate;
        }
        else if( strstr( classDefLine, tokPublic ) )
        {
		 Level2 = tokPublic;
        }
        else if( strstr( classDefLine, tokData ) )
        {
		 Level3 = tokData;
        }
        else if( strstr( classDefLine, tokMethods ) )
        {
		 Level3 = tokMethods;
        }
        else if( strstr( classDefLine, tokParents ) )
        {
		 Level3 = tokParents;
        }
        else if( strstr( classDefLine, tokInclude ) )
        {
	  hString * incLine = new hString;
	  *incLine = classDefLine;
	  includes.add(incLine);
        }
        else
        {
	  if( Level3 == tokData )
	  {
	    classMember * member = new classMember;

	    if( parseMember( *member, classDefLine ) )
	    {

	      findType( *member );
	      accessDefs( *member );
              accessImps( *member );
              initAndDestroy( *member );

	      if( Level2 == tokPublic )
	      {
	        publicMembers.add(member);
	      }
	      else if( Level2 == tokPrivate )
	      {
	        privateMembers.add(member);
	      }
              if( member->type.matchIn("*") )
              {
	        classMember * sizMember = new classMember;
                sizMember->name = "size";
                sizMember->name += member->name.upperS();
                sizMember->type = "unsigned long";
	        findType( *sizMember );
	        accessDefs( *sizMember );
                accessImps( *sizMember );
                initAndDestroy( *sizMember );
	        sizeMembers.add( sizMember );

              }

	    }
	  }
	  else if ( Level3 == tokMethods )
	  {

	    hString * method = new hString;
	    *method = classDefLine;
	    if( Level2 == tokPublic )
	    {
	      publicMethods.add(method);
	    }
	    else if( Level2 == tokPrivate )
	    {
	      privateMethods.add(method);
	    }

	  }
	  else if ( Level3 == tokParents )
	  {

	    hString * dad = new hString;
	    *dad = classDefLine;
	    if( Level2 == tokPublic )
	    {
	      publicParents.add(dad);
	    }
	    else if( Level2 == tokPrivate )
	    {
	      privateParents.add(dad);
	    }

	  }

        }

      } // end if length

    } // end while

  } // end if

  delete [] classDefLine;

}
int main(int argc ,char* argv[])
{
	if(argc<3) {
		printf("hostname and recode type required");
		exit(0);
	}
	signal(SIGALRM,ha);
	struct sockaddr_in servaddr;
	bzero(&servaddr, sizeof(servaddr));
	servaddr.sin_family= AF_INET;
	servaddr.sin_port =htons( SERV_PORT);
	servaddr.sin_addr.s_addr = inet_addr(addr);

	int sock = socket(AF_INET,SOCK_DGRAM,0);
	if(sock<0) errExit("socket");
	Msg msg;
	bzero(&msg, sizeof(msg));
	msg.header.id = htons(1);
	msg.header.noques = htons(1);

	msg.qtype=htons(findType(argv[2]));
	
	msg.qclass=htons(1);
	
	char delim[2] = ".";
   	char *label;
   	int i=0;
    label = strtok(argv[1], delim);
    while( label!= NULL ) 
    {
   	  msg.question[i].length = strlen(label);
   	  memcpy(msg.question[i].label,label,strlen(label));
   	  i++;
      label = strtok(NULL, delim);
    }
    msg.question[i].length=0;
    

    char* udp_msg = (char*)malloc(512*sizeof(char));
	char* udp_temp = udp_msg;
	bzero(udp_msg, 512);
	memcpy(udp_temp,&msg.header.id,2);
	udp_temp += 2;
	memcpy(udp_temp,(char*)&msg.header.param,2);
	udp_temp += 2;
	memcpy(udp_temp,(char*)&msg.header.noques,2);
	udp_temp += 2;
	memcpy(udp_temp,(char*)&msg.header.noans,2);
	udp_temp += 2;
	memcpy(udp_temp,(char*)&msg.header.noauth,2);
	udp_temp += 2;
	memcpy(udp_temp,(char*)&msg.header.noadd,2);
	udp_temp += 2;
	int m = 0;
	while(msg.question[m].length != 0){
		memcpy(udp_temp,(char*)&msg.question[m].length,1);
		udp_temp += 1;
		memcpy(udp_temp,msg.question[m].label,strlen(msg.question[m].label));
		udp_temp += strlen(msg.question[m].label);
		m++;
	}
	*udp_temp = 0;
	udp_temp += 1;
	memcpy(udp_temp,(char*)&msg.qtype,2);
	udp_temp += 2;
	memcpy(udp_temp,(char*)&msg.qclass,2);
	udp_temp += 2;
	*udp_temp = '\0';

	int answer_offset=udp_temp-udp_msg;
	char recvline[513];
	while(1){
		printf("MSG TO BE SENT:\n");
		printQuestionSection(udp_msg);
		printf("\nSending to server \n");
		printf("Trying %s.....\n",inet_ntoa(servaddr.sin_addr));
		alarm(5);
		if(sendto(sock,udp_msg,512,0,(struct sockaddr*) &servaddr,sizeof(servaddr)) < 0)
			errExit("sendto");
		alarm(0);
		int n;
		alarm(5);
		if((n = recvfrom(sock,recvline,512,0,NULL,NULL)) < 0)
			errExit("recvfrom");
		alarm(0);
		recvline[n] = '\0';

		printf("MSG RECIEVED:\n");
		printQuestionSection(recvline);
		char* newAddr= printAnswerSection(recvline,answer_offset);
		
		printf("\n******************************************************************************************\n");

		char* temp= recvline+2;
		if((*temp) & (uint8_t)0x04)
		{
			printf("Got authoritative answer\n");
			exit(0);
		}
		else
		{
			
			
			if(truncated(recvline))
			{
				printf("Truncated msg, exiting\n");
				exit(0);
			}
			if(error(recvline) || newAddr==NULL)
			{
				setjmp(env);
				canjmp=1;
				if(cur<0)
					exit(0);
				else 
				{
					newAddr = ipaddresses[cur];
					cur--;
					num--;
				}
			}
			servaddr.sin_addr.s_addr= *((int32_t*) newAddr);
		}
	}
return 0;
}
Пример #29
0
const ModelType *ModelData::getTypeRef(OovStringRef const typeName) const
    {
    OovString baseTypeName = getBaseType(typeName);
    return findType(baseTypeName);
    }
Пример #30
0
bool deckTlvHasElement(TlvArea *tlv, int type) {
  return findType(tlv, type) >= 0;
}