void SymbianIDeviceConfigurationWidget::getRomInfoResult(const Coda::CodaCommandResult &result)
{
    codaIncreaseProgress();
    if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
        startTable(m_deviceInfo);
        QTextStream str(&m_deviceInfo);

        QVariantHash obj = result.values[0].toVariant().toHash();
        QString romVersion = obj.value(QLatin1String("romVersion"), tr("unknown")).toString();
        romVersion.replace(QLatin1Char('\n'), QLatin1Char(' ')); // The ROM string is split across multiple lines, for some reason.
        addToTable(str, tr("ROM version:"), romVersion);

        QString pr = obj.value(QLatin1String("prInfo")).toString();
        if (pr.length())
            addToTable(str, tr("Release:"), pr);
        finishTable(m_deviceInfo);
    }

    QList<quint32> packagesOfInterest;
    packagesOfInterest.append(CODA_UID);
    packagesOfInterest.append(QTMOBILITY_UID);
    packagesOfInterest.append(QTCOMPONENTS_UID);
    packagesOfInterest.append(QMLVIEWER_UID);
    if (m_codaInfoDevice)
        m_codaInfoDevice->sendSymbianInstallGetPackageInfoCommand(Coda::CodaCallback(this, &SymbianIDeviceConfigurationWidget::getInstalledPackagesResult), packagesOfInterest);
}
Exemple #2
0
void DCServer::parse(QString tableName, QJsonDocument data)
{
    Var v(data);
    QList    <Var> list = v.getList();
    if(tableName == "net_address_type")
    {
        NetAddressTypeModel *model = new NetAddressTypeModel();
        addToTable(list, model);
    }
    else
    {
        if(tableName == "net_address")
        {
            NetAddressModel *model = new NetAddressModel();
            addToTable(list, model);
        }
        else
        {
            if(tableName == "device")
            {
                DeviceModel * model = new DeviceModel();
                addToTable(list, model);
            }
        }
    }
}
void SymbianIDeviceConfigurationWidget::getInstalledPackagesResult(const Coda::CodaCommandResult &result)
{
    codaIncreaseProgress();
    if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
        startTable(m_deviceInfo);
        QTextStream str(&m_deviceInfo);

        QVariantList resultsList = result.values[0].toVariant().toList();
        const QString uidKey = QLatin1String("uid");
        const QString errorKey = QLatin1String("error");
        const QString versionKey = QLatin1String("version");
        foreach (const QVariant& var, resultsList) {
            QVariantHash obj = var.toHash();
            bool ok = false;
            uint uid = obj.value(uidKey).toString().toUInt(&ok, 16);
            if (ok) {
                const bool error = !obj.value(errorKey).isNull();
                QString versionString;
                if (!error) {
                    QVariantList version = obj.value(versionKey).toList();
                    versionString = QString::fromLatin1("%1.%2.%3").arg(version[0].toInt())
                            .arg(version[1].toInt())
                            .arg(version[2].toInt());
                }
                switch (uid) {
                case CODA_UID: {
                    if (error) {
                        // How can coda not be installed? Presumably some UID wrongness...
                        addErrorToTable(str, tr("CODA version: "), tr("Error reading CODA version"));
                    } else
                        addToTable(str, tr("CODA version: "), versionString);
                }
                break;
                case QTMOBILITY_UID: {
                    if (error)
                        addErrorToTable(str, tr("Qt Mobility version: "), tr("Error reading Qt Mobility version"));
                    else
                        addToTable(str, tr("Qt Mobility version: "), versionString);
                }
                break;
                case QTCOMPONENTS_UID: {
                    addToTable(str, tr("Qt Quick components version: "), error ? tr("Not installed") : versionString);
                }
                break;
                case QMLVIEWER_UID: {
                    addToTable(str, tr("QML Viewer version: "), error ? tr("Not installed") : versionString);
                }
                break;
                default: break;
                }
            }
        }
// 2
void setLabel(FILE* file, DynamicTable* symbols, Token token) {
	int i;

	printf("semantic: label\n");fflush(stdout);
	// if instruction already has a label, jump to the last assigned label
	if(strcmp(label,"")) {
		i = lookUpForCell(*symbols, identifier, "label");
		if(i == -1) {
			i = addToTable(symbols, identifier, identifier, "label");
			defineRow(symbols, i);
			fprintf(file, "%s\tJP\t%s\n", identifier, label);
			fflush(file);
			strcpy(identifier, "");
		}
		else {
			printf("ERROR: duplicate label %s.\n", identifier);
			fprintf(file, "ERROR: duplicate label %s.\n", identifier);
			fflush(stdout);
			fflush(file);
			system("PAUSE");
			exit(5);
		}
	}
	// otherwise, add it to symbol table and activate it as current label
	else {
		i = lookUpForCell(*symbols, identifier, "label");
		if(i == -1) {
			strcpy(label, identifier);
			strcpy(identifier, "");
			i = addToTable(symbols, label, label, "label");
			defineRow(symbols, i);
		}
		else {
			if(!getRow(*symbols, i)->defined) {
				strcpy(label, identifier);
				strcpy(identifier, "");
				defineRow(symbols, i);
			}
			else {
				printf("ERROR: duplicate label %s.\n", identifier);
				fprintf(file, "ERROR: duplicate label %s.\n", identifier);
				fflush(stdout);
				fflush(file);
				system("PAUSE");
				exit(5);
			}
		}
	}
}
Exemple #5
0
void parser(char * argv[], Node * head, Hash ** hashTable, int size)
{
	char line[MAXLINELENGTH];
    FILE * infile;
    char * returnValue;
    char * firstName;
    char * lastName;
    Node * tail;
    Node * node;
    char * phoneNumber;
    infile = fopen(argv[1], "r");
    if (infile == NULL)
    {
        printf("error opening file \n");
        exit(0);
    }
    returnValue = fgets(line, MAXLINELENGTH, infile);
    while (returnValue != NULL)
    {
        firstName = strtok(line, ",");
        lastName = strtok(NULL, ",");
        phoneNumber = strtok(NULL, "\n");
        node = addFront(head, phoneNumber, firstName, lastName);
        addToTable(node, hashTable, size);
        returnValue = fgets(line, MAXLINELENGTH, infile);
    }
    tail = getTail(head);
    //quickSort(head -> next, tail);
    fclose(infile);
}
Exemple #6
0
// At this point we have submitted the job, but we need to check if it is still running
// the job should be submitted, we check that this is indeed the
// case and add the Process to our monitor.
void ProcessMonitor::jobSubmitted()
{
   if (!m_pendingProcess) {
      qDebug() << "ProcessMonitor::submitJob3() called with no pending process";
      return;
   }

   ServerTask::Base* task = qobject_cast<ServerTask::Base*>(sender());
   if (!task) {
      delete m_pendingProcess;
      m_pendingProcess = 0;
      return;
   }

   QString errorMessage(task->errorMessage());
   qDebug() << "ProcessMonitor::jobSubmitted() error message" << errorMessage;
   task->deleteLater();
// if message = Process not found then we try a clean up

   if (!errorMessage.isEmpty()) {
      QString msg("Problem submitting Job:\n");
      msg += errorMessage;
      QMsgBox::warning(this, "IQmol", msg);
      delete m_pendingProcess;
      m_pendingProcess = 0;
      return;
   }

   jobAccepted(); // tells the QUI window to close
   Server* server = ServerRegistry::instance().get(m_pendingProcess->serverName());
   if (server) server->startTimer();
   addToTable(m_pendingProcess);
   saveProcessList();
   m_pendingProcess = 0;
}
// 21
void setParam(FILE* file, DynamicTable* symbols, Token token) {
	int i;
	char nick[128];

	printf("semantic: param\n");fflush(stdout);
	i = lookUpForCell(*symbols, identifier, "variable");

	if(i == -1) {
		strcpy(nick, "_param");
		strcat(nick, integerToString(auxiliar, params++, 10));
		strcat(nick, "_");
		strcat(nick, procedure);
		i = addToTable(symbols, identifier, nick, "variable");
		defineRow(symbols, i);
		strcpy(identifier, "");
		strcpy(auxiliar, "");
		strcpy(type, "");

		fprintf(file, "%s\t K\t/0000\n", nick);
		fflush(file);
	}
	else {
		printf("ERROR: redeclaration of \"%s\".\n", identifier);
		fprintf(file, "ERROR: redeclaration of \"%s\".\n", identifier);
		fflush(stdout);
		fflush(file);
		system("PAUSE");
		exit(5);
	}
}
Exemple #8
0
linkedList_t* addSymbol(char* text, type_t type)
{
	symbol_t symbol;
	symbol.text = (char*) calloc(strlen(text) + 1, sizeof(char));
	strcpy(symbol.text, text);
	symbol.type = type;

	switch(type)
	{
		case SYMBOL_LIT_INTEGER:
			symbol.value.intLit = atoi(text);
			break;
		case SYMBOL_LIT_TRUE:
			symbol.value.boolLit = 1;
			break;
		case SYMBOL_LIT_FALSE:
			symbol.value.boolLit = 0;
			break;
		case SYMBOL_LIT_CHAR:
			symbol.value.charLit = removeQuotes(text)[0];
			break;
		case SYMBOL_LIT_STRING:
			symbol.value.stringLit = removeQuotes(text);
			break;
		case SYMBOL_IDENTIFIER:
			symbol.value.identifier = text;
			break;
	}

	return addToTable(symbol, symbolTable, SYMBOL_TABLE_SIZE);
}
struct token checkidErrors(char *lexeme){
	//already checked for too-long id (in machine)
	//check if id is already in reserved, then symbol table
	struct token tok = isInTable(lexeme, reservedTable);
	if(tok.type != -1 && tok.attr != -1){
		return tok;
	} else{
		tok = isInTable(lexeme, symbolTable);
		if(tok.type != -1 && tok.attr != -1){
			return tok;
		} else {
			//add new symbol to symbol table
			addToTable(lexeme, ID_TYPE, NO_ATTR, &symbolTable);
			(*symbolTable).attr = (long)&(*symbolTable);
			struct token a = {.type = ID_TYPE, .attr = (*symbolTable).attr};
			return a;
		}
	}
}

int hasLeadingZeroes(char *lexeme){
	char *charpointer = lexeme;
	if(*charpointer == '0'){
		int length = 0;
		while(*charpointer != '\0'){
			length++;
			charpointer += sizeof(char);
			if(length == 1 && *charpointer == '.')
				return 0;
		}
		if(length > 1)
			return 1;
	}
	return 0;
}
Exemple #10
0
// This method checks through all the reserved list for the str
int isReserved( FILE *clean, char *str ){
	for( temp = 0; temp < 15; temp++ )
    // if the str is found add it to the lexTable and cleaninput.txt
		if( !strcmp( resword[temp], str ) ) 
      return addToTable( clean, resword[temp], restoken[temp] );
  
	return 0;
}
Exemple #11
0
void hashTree::add(const data & aData)
{
    data * ptrItem = new data;
    *ptrItem = aData;
    
    addToTable(ptrItem);
    addToTree(ptrItem);
   
}
Exemple #12
0
bool TCPObject::processArguments(S32 argc, ConsoleValueRef *argv)
{
   if(argc == 0)
      return true;
   else if(argc == 1)
   {
      addToTable(U32(dAtoi(argv[0])));
      return true;
   }
   return false;
}
Exemple #13
0
/*
 * Do the table operations on the shapes. Allow multiple type of data to be rendered.
 */
int utfgridStartShape(imageObj *img, shapeObj *shape)
{
  UTFGridRenderer *r = UTFGRID_RENDERER(img);

  if(!r->renderlayer)
    return MS_FAILURE;

  /* Table operations */
  r->utfvalue = addToTable(r, shape);

  return MS_SUCCESS;
}
// 4
void setJump(FILE* file, DynamicTable* symbols, Token token) {
	printf("semantic: jump\n");fflush(stdout);
	if(lookUpForCell(*symbols, identifier, "label") == -1) {
		addToTable(symbols, identifier, identifier, "label");
	}

	fprintf(file, "%s\tJP\t%s\n", label, identifier);
	fflush(file);

	strcpy(label, "");
	strcpy(identifier, "");
}
void DocumentZALController::setPreviousZAL(Document documentZAL)
{
    SimpleDocumentInfo simple;
    simple.setSymbol(documentZAL.getSymbol());
    simple.setDocumentDate(documentZAL.getDocumentDate());
    simple.setTotal(documentZAL.getTotal());
    if(isOtherZal(simple))
        manager->getDocumentZALPolicy()->appendToPrevious(simple);
    manager->getDocumentZALPolicy()->setPreviousZAL(manager->getDocumentZALPolicy()->getPreviousZALVector());
    manager->countGoodsValue(view->getDiscountOrWaybillNo()->text().toDouble());
    setGoodsValue();
    addToTable();
}
Exemple #16
0
void testing(int ** numberArray, int size)
{
	int i;
	Hash ** hashTable;
	Node * newNode;
	hashTable = createHashTable(size);
	for (i = 0; i < 300; i++)
	{
		newNode = initNode(i, *numberArray[i]);
		addToTable(newNode, hashTable, size);
	}
	printTable(hashTable, size);
	destroy(hashTable, size);
}
Exemple #17
0
void CustomEncoder::Create(const CodePage* target, bool extended) {
    YASSERT(target);

    DefaultChar = (const char*)target->DefaultChar;

    DefaultPlane = new char[256];

    memset(DefaultPlane, 0, 256*sizeof(char));
    for (size_t i = 0; i != 256; ++i)
        Table[i] = DefaultPlane;

    for (size_t i = 0; i != 256; ++i) {
        wchar32 ucode = target->unicode[i];
        if (ucode != BROKEN_RUNE) // always UNASSIGNED
            addToTable(ucode, (unsigned char) i, target);
    }

    if (!extended)
        return;

    for (wchar32 w = 1; w < 65535; w++){
        if (Code(w) == 0){
            wchar32 dw = w;
            while (IsComposed(dw) && Code(dw) == 0){
                const wchar32* decomp_p = NUnicode::Decomposition<true>(dw);
                YASSERT(decomp_p != NULL);

                dw = decomp_p[0];
                if (TCharTraits<wchar32>::GetLength(decomp_p) > 1 && (dw == (wchar32)' ' || dw == (wchar32)'('))
                    dw = decomp_p[1];
            }
            if (Code(dw) != 0 && isGoodDecomp(w, dw))
                addToTable(w, Code(dw), target);
        }
    }
}
Exemple #18
0
void ProcessMonitor::loadProcessList()
{
   QLOG_DEBUG() << "Loading processes from file";
   QVariantList list(Preferences::CurrentProcessList());
   if (list.isEmpty()) return;

   bool remoteProcessesActive(false);
   QVariantList::iterator iter;
   for (iter = list.begin(); iter != list.end(); ++iter) {
       Process* process(Process::deserialize(*iter));
       if (process) {
          addToTable(process);
          if (process->status() == Process::Queued  ||
              process->status() == Process::Running ||
              process->status() == Process::Suspended ||
              process->status() == Process::Unknown) {

              qDebug() << "  Watching process" << process->name();
              Server* server = ServerRegistry::instance().get(process->serverName());
              if (server) {
                 server->addToWatchList(process);
                 if (server->host() == Server::Local) {
                    server->connectServer();
                    server->updateProcesses();
                 }else {
                    remoteProcessesActive = true;
                 }
              }
          }

          if (process->status() == Process::Running ||
              process->status() == Process::Suspended) {
              qDebug() << "  Setting status to unknown";
              process->setStatus(Process::Unknown);
          }
       }
   }
   updateTable();

   if (remoteProcessesActive) {
      QString msg("IQmol found processes on remote servers that were still active "
        "in the last session. \nWould you like to reconnect to the server(s)?");
      if (QMsgBox::question(this, "IQmol", msg) == QMessageBox::Ok) reconnectServers();
   }
}
Exemple #19
0
void SyntaxAnalyzer::ids(const string& type, bool fromRead) {
	if (currentToken.type() == "identifier") {
		cout << "<IDs> -> <Identifier> <IDs>'" << endl;
		if (type != "") {
			addToTable(currentToken.lexeme(), type);
		}
		if (fromRead) {
			checkIdExistence(currentToken.lexeme());
			instTable.genInstr("STDIN", NIL);
			int addr = table.getAddress(currentToken.lexeme());
			instTable.genInstr("POPM", addr);
		}
		newToken();
	}
	else { errorMessage("<Identifier>"); }

	idsPrime(type);
}
Exemple #20
0
void readAll( Table_T fpTable )
{
        Set_T nameSet = Set_new( initSetSize, NULL, NULL ); 


        fpPair pair;

        while( !feof(stdin) )
        {      

                pair = readLine();
                addToTable( nameSet, fpTable, pair );

        }

        Set_free(&nameSet);

}
Exemple #21
0
void DixitGame::play(DixitGame::UniqueId uid, int card)
{
    Player *pp = findPlayer(uid);
    if (pp == nullptr)
        return;
    if (pp->getPlayed())
        return;
    pp->setPlayed();
    pp->getHandCards().removeAll(card);
    addToTable(card);
    if (notYetPlayed() > 0)
        setMessage(QString("还有%1位玩家未出牌。").arg(notYetPlayed()));
    else
    {
        setMessage();
        emit allPlayed();
    }
}
void startSemantics(FILE* file, DynamicTable* symbols) {
	strcpy(identifier, "");
	strcpy(label, "");
	strcpy(procedure, "");
	strcpy(type, "");
	strcpy(destination, "");
	strcpy(operator, "");
	strcpy(auxiliar, "");

	constant = -1;
	ifCount = -1;
	whileCount = -1;
	params = 0;

	newFreeList();
	newStack(&ifs);
	newStack(&whiles);

	fprintf(file, "_start\tSC\tmain\n\tHM\t_start\n\n");
	addToTable(symbols, "main", "main", "procedure");
}
// 7
void setVar(FILE* file, DynamicTable* symbols, Token token) {
	int i;

	printf("semantic: var\n");fflush(stdout);
	i = lookUpForCell(*symbols, identifier, "variable");

	if(i == -1) {
		i = addToTable(symbols, identifier, identifier, "variable");
		defineRow(symbols, i);
		strcpy(identifier, "");
		strcpy(type, "");
	}
	else {
		printf("ERROR: redeclaration of \"%s\".\n", identifier);
		fprintf(file, "ERROR: redeclaration of \"%s\".\n", identifier);
		fflush(stdout);
		fflush(file);
		system("PAUSE");
		exit(5);
	}
}
Exemple #24
0
int hashing(const char* buffer, int* CountOfHashing, func hashFunc)
{

	int i = 0, k = 0, j = 0;
	unsigned int hash = 0;
	char tmpStr[SIZEOFWORD] = "";
	int Firstly = 0;
	Table* table = new Table;
	List* Listy = new List[SIZEOFTABLE];
	table->f = hashFunc;
	table->list = Listy;
	//printf("----------------------\n");
	while (buffer[j] != '\0' && buffer[j] > 0)
	{
		if (!(takeWord(buffer, &j, tmpStr))) { Nerror = PTRERR; PrintError(__LINE__); }
		
		addToTable(table, tmpStr, CountOfHashing);

		//hash = f(tmpStr) % SIZEOFTABLE;
		//hash = hash % SIZEOFTABLE;
		//printf("hash = %d \n", hash);//debug
		//if (!(table->list[hash].addTail(tmpStr))) return BAD;// goto breakpoint;
		//table[hash].show();//debug
		
		memset(tmpStr, '\0', SIZEOFTABLE);

		while (buffer[j] == ' ' || buffer[j] == '\r' || buffer[j] == '\n')
			j++;
		tmpStr[0] = '\0';
	}
	
	char* ShowFind = "wei";
	if (!ShowElem(FindElem(table, ShowFind)))
		return BAD;// goto breakpoint;
	
	return OK;
//breakpoint:
}
Exemple #25
0
// prints error message and cleans the rest of the file of comments
int error( FILE *input, FILE *clean, char c, char *buffer, int i ){
  printf( "%s", lexError[i] );
  fprintf( clean, "%s", buffer );
  while( c != EOF ){
    switch(c){

    case '/': // still clean input of comments 
      c = getc( input );
      switch(c){
      case '*': // '/*' multiline comment
        do{ // waits for another '/' after a '*'
          do{ // waits for another '*'
						c = getc( input ); 
					}while( c != '*' && c != EOF );
					c = getc( input );
				}while( c != '/' && c != EOF );
        break;

      case '/': // '//' singleline comment
        do{ // waits for a newline character
          c = getc( input );
        }while( c != NEWLINE && c != EOF );
        break;

      default: // '/' as in 'divides' add this one to the table
        addToTable( clean, "/", slashsym );
        ungetc( c, input );
      }
			break;
    default: // not a comment so just print away
      fprintf( clean, "%c", c );
    }
    c = getc( input );
  }
 
  return 0;
}
// 19
void setLink(FILE* file, DynamicTable* symbols, Token token) {
	int i;

	printf("semantic: procedure\n");fflush(stdout);
	// TODO: procedures and variables still cannot have the same name
	i = lookUpForCell(*symbols, procedure, "procedure");
	if(i == -1) {
		i = addToTable(symbols, procedure, procedure, "procedure");
		defineRow(symbols, i);
		fprintf(file, "%s\t K\t/0000\n", procedure);
		fflush(file);
	}
	else if(!strcmp(procedure, "main") && !getRow(*symbols, i)->defined) {
		defineRow(symbols, i);
	}
	else {
		printf("ERROR: redeclaration of \"%s\".\n", procedure);
		fprintf(file, "ERROR: redeclaration of \"%s\".\n", procedure);
		fflush(stdout);
		fflush(file);
		system("PAUSE");
		exit(5);
	}
}
Exemple #27
0
int getWeight(GameTreeNode* node, int movesLeft) {
	int toR, move, best_weight;
	if (getWinner(node->gs) || isDraw(node->gs) || movesLeft == 0)
		return heuristicForState(node->gs, node->player, node->other_player);

	GameState** possibleMoves = (GameState**) malloc(sizeof(GameState*) * node->gs->width);
	int validMoves = 0;
	for (int possibleMove = 0; possibleMove < node->gs->width; possibleMove++) {
		if (!canMove(node->gs, possibleMove)) {
			continue;
		}
		
		possibleMoves[validMoves] = stateForMove(node->gs, possibleMove, (node->turn ? node->player : node->other_player));
		validMoves++;
	}

	// order possibleMoves by the heuristic
	g_node = node;
	if (node->turn) {
		// qsort_r is apparently non-standard, and won't work with emscripten. So we'll need to use a global.
		qsort(possibleMoves, validMoves, sizeof(GameState*), ascComp); 
	} else {
		qsort(possibleMoves, validMoves, sizeof(GameState*), desComp); 
	}

	best_weight = (node->turn ? INT_MIN : INT_MAX);

	for (move = 0; move < validMoves; move++) {
		// see if the game state is already in the hash table
		GameState* inTable = lookupInTable(node->ht, possibleMoves[move]);
		int child_weight;
		int child_last_move;
		if (inTable != NULL) {
			child_weight = inTable->weight;
			child_last_move = possibleMoves[move]->last_move;

		} else {
			GameTreeNode* child = newGameTreeNode(possibleMoves[move], node->player, node->other_player, !(node->turn),
							      node->alpha, node->beta, node->ht);
			child_weight = getWeight(child, movesLeft - 1);
			child_last_move = child->gs->last_move;
			free(child);
		}

	

		possibleMoves[move]->weight = child_weight;
		addToTable(node->ht, possibleMoves[move]);

		if (movesLeft == LOOK_AHEAD)
			printf("Move %d has weight %d\n", child_last_move, child_weight);

		// alpha-beta pruning
		if (!node->turn) {
			// min node
			if (child_weight <= node->alpha) {
				// MAX ensures we will never go here
				toR = child_weight;
				goto done;
			}
			node->beta = (node->beta < child_weight ? node->beta : child_weight);
		} else {
			// max node
			if (child_weight >= node->beta) {
				// MIN ensures we will never go here
				toR = child_weight;
				goto done;
			}
			node->alpha = (node->alpha > child_weight ? node->alpha : child_weight);
		}

		if (!(node->turn)) {
			// min node
			if (best_weight > child_weight) {
				best_weight = child_weight;
				node->best_move = child_last_move;
			}
		} else {
			// max node
			if (best_weight < child_weight) {
				best_weight = child_weight;
				node->best_move = child_last_move;
			}
		}

		
	}
	toR = best_weight;
done:
	for (int i = 0; i < validMoves; i++) {
		freeGameState(possibleMoves[i]);
	}

	free(possibleMoves);
	return toR;
}
Exemple #28
0
linkedList_t* addSymbol(char* text, type_t type)
{
	symbol_t symbol;
	symbol.text = (char*) calloc(strlen(text) + 1, sizeof(char));
	strcpy(symbol.text, text);
	symbol.type = type;
	symbol.marked = FALSE;

	switch(type)
	{
		case SYMBOL_LIT_INTEGER:
		{
			char* hexString = (char*)calloc(strlen(text),sizeof(char));
			sprintf(hexString,"%s",text);

			int i;

			for(i = 0; i < strlen(hexString); i++)
				hexString[i] = tolower(hexString[i]);

			char* junk;
			symbol.value.intLit = strtol(hexString,&junk,16);

			symbol.dataType = INTEGER;

			break;
		}
		case SYMBOL_LIT_TRUE:
		{
			symbol.value.boolLit = 1;

			symbol.dataType = BOOL;

			break;
		}
		case SYMBOL_LIT_FALSE:
		{
			symbol.value.boolLit = 0;

			symbol.dataType = BOOL;

			break;
		}
		case SYMBOL_LIT_CHAR:
		{
			symbol.value.charLit = removeQuotes(text)[0];

			symbol.dataType = INTEGER;

			break;
		}
		case SYMBOL_LIT_STRING:
		{
			symbol.value.stringLit = removeQuotes(text);

			break;
		}
		case SYMBOL_IDENTIFIER:
		{
			symbol.value.identifier = (char*) calloc(strlen(text) + 1, sizeof(char));
			strcpy(symbol.value.identifier, text);

			break;
		}
	}

	return addToTable(symbol, symbolTable, SYMBOL_TABLE_SIZE);
}
int main() {
	
	printf("\nCOMP2000 Assignment 6\n\nStudent # : 812000767\n\n\n\n********** Hash Parts ************* \n\n\n");
	int j;

	WordInfo wordTable[N + 1];
	for (j = 1; j <= N; j++)strcpy(wordTable[j].word, Empty);

	FILE*in = fopen("input.txt", "r");
	FILE*out = fopen("output.txt", "w");

	

	static char info[WordSize], number[6], name[20], description[30];
	double unitprice;
	int quantityinstock;
	static int x, y, i, count,stop;

	
	int numWords = 0;






#pragma warning(suppress: 6054)
	while (strcmp(number, "$$$$$$") != 0)  {
	
			for (i = 0; i < 6; i++){
				number[i] = '\0';
			}
			for (i = 0; i < 20; i++){
				name[i] = '\0';
			}
			for (i = 0; i < 30; i++){
				description[i] = '\0';
			}
			for (i=0; i< WordSize; i++){
				info[i] = '\0';
			}
	
		
			
			
		

		i = count = 0;
		while (count != 6){
			fscanf(in, "%c", &info[i]);

			if (info[i] == '"'){
				count++;
			}
			else if ( info[i] == '$'){
				stop++;
			}
			if (count == 2 && stop == 6){
				count = 6;
			}
				i++;
		
			
		}
		

		x = strlen(info);
		i = count = 0;
		for (i = 0; i<x; i++){

			if (info[i] == '"'){
				count++;
				y = 0;
			}


			else if (count > 0 && count < 2){
				number[y] = info[i];
				y++;
			}

			else if (count > 2 && count < 4){
				name[y] = info[i];
				y++;

			}

			else if (count > 4 && count < 6){
				description[y] = info[i];
				y++;
			}


		}

		fscanf(in, "%lf", &unitprice);
		fscanf(in, "%d", &quantityinstock);


		if (strcmp(number, "$$$$$$") != 0) {
			int loc = search(wordTable,number);
			if (loc > 0) {
				// exist already
				}
			else
			if (numWords < MaxWords){
				first = addToTable(wordTable,number,name,description,unitprice,quantityinstock, -loc, first);
				++numWords;
			}
			else fprintf(out, "'%s' not added to table \n",number);
		}
		
			
		
	}


////////////////////////////////////////////////////////////////////////////////////////////////////////////
	char c;
	fscanf(in, "%c", &c);
	c = tolower(c);
	while (c != 'e'){
	

		if (c == 'p'){
			for (i = 0; i < 6; i++){
				number[i] = '\0';
			}
			fscanf(in,"%s",&number);
			int x = find(wordTable,first,number);
			if (x !=0) {
				fprintf(out,"print: '%s' '%s' '%s' '%.2lf' '%d' \n",wordTable[x].word,wordTable[x].name,wordTable[x].description,wordTable[x].unitprice,wordTable[x].quantityinstock);
			}
			else if (x == 0)fprintf(out,"print: %s not present in Hash table\n",number);
		}

		else if (c == 'd'){
			for (i = 0; i < 6; i++){
				number[i] = '\0';
			}
			fscanf(in,"%s",&number);
			deleteEntry(out,wordTable,first,number);
			

		}

		else if (c == 'c'){
			for (i = 0; i < 6; i++){
				number[i] = '\0';
			}
			fscanf(in,"%s",&number);
			int x = find(wordTable,first,number);
			int n;
			fscanf(in,"%d",&n);
			if (wordTable[x].quantityinstock < n){
				fprintf(out,"item : %s NOT ORDERED - stock has %d, order is %d\n",wordTable[x].word,wordTable[x].quantityinstock,n);
			
			}
			else wordTable[x].quantityinstock = wordTable[x].quantityinstock - n;
		}

		fscanf(in, "%c", &c);
		c = tolower(c);
	}


	fprintf(out,"\n\n\n");
	fprintf(out,"\t\t-----> Parts Data <-----\n\n");
	printResults(out, wordTable, first);



	system("pause");
	return 0;

	fclose(in);
	fclose(out);
}
void SymbianIDeviceConfigurationWidget::getQtVersionCommandResult(const Coda::CodaCommandResult &result)
{
    m_deviceInfo.clear();
    if (result.type == Coda::CodaCommandResult::FailReply) {
        setDeviceInfoLabel(tr("No device information available"), true);
        SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaInfoDevice);
        m_deviceInfoButton->setEnabled(true);
        m_codaTimeout->stop();
        return;
    } else if (result.type == Coda::CodaCommandResult::CommandErrorReply){
        startTable(m_deviceInfo);
        QTextStream str(&m_deviceInfo);
        addErrorToTable(str, tr("Qt version: "), tr("Not installed on device"));
        finishTable(m_deviceInfo);
    } else {
        if (result.values.count()) {
            QHash<QString, QVariant> obj = result.values[0].toVariant().toHash();
            QString ver = obj.value(QLatin1String("qVersion")).toString();

            startTable(m_deviceInfo);
            QTextStream str(&m_deviceInfo);
            addToTable(str, tr("Qt version:"), ver);
            QString systemVersion;

            const int symVer = obj.value(QLatin1String("symbianVersion")).toInt();
            // Ugh why won't QSysInfo define these on non-symbian builds...
            switch (symVer) {
            case 10:
                systemVersion.append(QLatin1String("Symbian OS v9.2"));
                break;
            case 20:
                systemVersion.append(QLatin1String("Symbian OS v9.3"));
                break;
            case 30:
                systemVersion.append(QLatin1String("Symbian OS v9.4 / Symbian^1"));
                break;
            case 40:
                systemVersion.append(QLatin1String("Symbian^2"));
                break;
            case 50:
                systemVersion.append(QLatin1String("Symbian^3"));
                break;
            case 60:
                systemVersion.append(QLatin1String("Symbian^4"));
                break;
            case 70:
                systemVersion.append(QLatin1String("Symbian^3")); // TODO: might change
                break;
            default:
                systemVersion.append(tr("Unrecognised Symbian version 0x%1").arg(symVer, 0, 16));
                break;
            }
            systemVersion.append(QLatin1String(", "));
            int s60Ver = obj.value(QLatin1String("s60Version")).toInt();
            switch (s60Ver) {
            case 10:
                systemVersion.append(QLatin1String("S60 3rd Edition Feature Pack 1"));
                break;
            case 20:
                systemVersion.append(QLatin1String("S60 3rd Edition Feature Pack 2"));
                break;
            case 30:
                systemVersion.append(QLatin1String("S60 5th Edition"));
                break;
            case 40:
                systemVersion.append(QLatin1String("S60 5th Edition Feature Pack 1"));
                break;
            case 50:
                systemVersion.append(QLatin1String("S60 5th Edition Feature Pack 2"));
                break;
            case 70:
                systemVersion.append(QLatin1String("S60 5th Edition Feature Pack 3")); // TODO: might change
                break;
            default:
                systemVersion.append(tr("Unrecognised S60 version 0x%1").arg(symVer, 0, 16));
                break;
            }
            addToTable(str, tr("OS version:"), systemVersion);
            finishTable(m_deviceInfo);
        }
    }
    codaIncreaseProgress();
    if (m_codaInfoDevice)
        m_codaInfoDevice->sendSymbianOsDataGetRomInfoCommand(Coda::CodaCallback(this, &SymbianIDeviceConfigurationWidget::getRomInfoResult));
}