예제 #1
0
static void initializeRefData()
{
	RsslConnectOptions copts;
	time(&endTime);
	endTime += exampleConfig.runTime;

	refDataSessionClear(&refDataSession);

	// connect to ref data server
	printf("Connecting to ref data server %s:%s\n", exampleConfig.refDataServerAddr,
			exampleConfig.refDataServerPort);
	rsslClearConnectOpts(&copts);
	copts.connectionType = RSSL_CONN_TYPE_SOCKET;
	copts.connectionInfo.segmented.recvServiceName = exampleConfig.refDataServerPort;
	copts.connectionInfo.segmented.recvAddress = exampleConfig.refDataServerAddr;
	if (refDataSessionConnect(&refDataSession, &copts) != RSSL_RET_SUCCESS)
		exit(-1);

	if (exampleConfig.xmlRefDataTrace)
	{
		setupXMLTracing(refDataSession.pRsslChannel, exampleConfig.refDataTraceOutputFile);
	}


	// load dictionary
	loadDictionary();
}
예제 #2
0
void MainWindow::loadLevelPlist(QString level)
{
    QDomDocument doc("Level Plist");
    QFile file(level);
    if (!file.open(QIODevice::ReadOnly))
        return;
    if (!doc.setContent(&file)) {
        file.close();
        return;
    }
    file.close();

    // Clear selected objects from previous level (if any)
    selectedObjects.clear();

    levelPlist.clear();
    levelObjects.clear();

    // Load top level.
    QDomElement docElem = doc.documentElement();

    // This is the uppermost dictionary
    QDomNode n = docElem.firstChild();

    // Load level
    levelPlist = loadDictionary(n);

    // Extract game objects from levelPlist
    QList<QVariant> tempList = levelPlist.value("game_objects").toList();
    for(int i = 0; i < tempList.size(); i++)
    {
        levelObjects.append(tempList.at(i).toMap());
    }
    levelPlist.remove("game_objects");
}
예제 #3
0
GamArchive::GamArchive(const char *filename)
	: _fd(0), _groupCount(0), _groups(0) {
	_fd = new Common::File();
	if (!_fd->open(filename))
		error("GamArchive::GamArchive() Could not open %s", filename);
	loadDictionary();
}
예제 #4
0
파일: BasicHDT.cpp 프로젝트: akjoshi/hdt-it
void BasicHDT::loadFromRDF(const char *fileName, string baseUri, RDFNotation notation, ProgressListener *listener)
{
	try {
		// Make sure that URI starts and ends with <>
		if(baseUri.at(0)!='<')
			baseUri = '<'+baseUri;
		if(baseUri.at(baseUri.length()-1)!='>')
			baseUri.append(">");

		IntermediateListener iListener(listener);

		iListener.setRange(0,50);
		loadDictionary(fileName, baseUri.c_str(), notation, &iListener);

		iListener.setRange(50,99);
		loadTriples(fileName, baseUri.c_str(), notation, &iListener);
		fillHeader(baseUri);

	}catch (const char *e) {
		cout << "Catch exception load: " << e << endl;
		deleteComponents();
		createComponents();
		throw e;
	} catch (char *e) {
		cout << "Catch exception load: " << e << endl;
		deleteComponents();
		createComponents();
		throw e;
	}
}
예제 #5
0
/*!
 * Load ispell dictionary hash file for given language.
 *
 * \param szLang -  The language tag ("en-US") we want to use
 * \return The name of the dictionary file
 */
bool
ISpellChecker::loadDictionaryForLanguage ( const char * szLang )
{
	char *hashname = NULL;
	
	const char * encoding = NULL;
	const char * szFile = NULL;
	
	for (size_t i = 0; i < size_ispell_map; i++)
		{
			const IspellMap * mapping = (const IspellMap *)(&(ispell_map[i]));
			if (!strcmp (szLang, mapping->lang))
				{
					szFile = mapping->dict;
					encoding = mapping->enc;
					break;
				}
		}
	
	if (!szFile || !strlen(szFile))
		return false;

	alloc_ispell_struct();
	
	if (!(hashname = loadDictionary(szFile)))
		return false;
	
	// one of the two above calls succeeded
	setDictionaryEncoding (hashname, encoding);
	g_free (hashname);

	return true;
}
예제 #6
0
/**
 * Prints the concordance of the given file and performance information. Uses
 * the file input1.txt by default or a file name specified as a command line
 * argument.
 * @param argc
 * @param argv
 * @return
 */
int main(int argc, const char** argv)
{
    // FIXME: implement
    HashMap* map = hashMapNew(1000);
    
    FILE* file = fopen("dictionary.txt", "r");
    clock_t timer = clock();
    loadDictionary(file, map);
    timer = clock() - timer;
    printf("Dictionary loaded in %f seconds\n", (float)timer / (float)CLOCKS_PER_SEC);
    fclose(file);
    
    char inputBuffer[256];
    int quit = 0;
    while (!quit)
    {
        printf("Enter a word or \"quit\" to quit: ");
        scanf("%s", inputBuffer);
        
        // Implement the spell checker code here..
        
        if (strcmp(inputBuffer, "quit") == 0)
        {
            quit = 1;
        }
    }
    
    hashMapDelete(map);
    return 0;
}
예제 #7
0
int main (int argc, const char * argv[]) {
  clock_t timer;
  struct hashMap* hashTable;
  int tableSize = 1000;
  timer = clock();
  initMap(hashTable,tableSize);

  FILE* dictionary;

  loadDictionary(dictionary,hashTable);
  timer = clock() - timer;
	printf("Dictionary loaded in %f seconds\n", (float)timer / (float)CLOCKS_PER_SEC);

  char* word = (char*)malloc(256*sizeof(char));
  int quit=0;
  while(!quit){
    printf("Enter a word: ");
    scanf("%s",word);
    /*
      ... spell checker code goes here ...
      ... You write this               ...
    */

    /* Don't remove this. It is used for grading*/
    if(strcmp(word,"quit")==0)
      quit=!quit;
  }
  free(word);

  return 0;
}
예제 #8
0
파일: TestsChiriac.c 프로젝트: AddictedA/HW
int main(void)
{
	struct TernaryTreeNode* root = 0;
	root = loadDictionary("C:\\Dictionary.txt");

	puts("");
	puts("");
	puts("");

	if (lookup(root, "ape"))
		printf("\"ape\" word is found, test passed\n");
	else
		printf("\"ape\" word is not found, test failed\n");

	if (lookup(root, "carrot"))
		printf("\"carrot\" word is found, test passed\n");
	else
		printf("\"carrot\" word is not found, test failed\n");

	if (!lookup(root, "carrrrrrrot"))
		printf("\"carrrrrrrot\" word is not found, test passed\n");
	else
		printf("\"carrrrrrrot\" word is found, test failed\n");

	free_tree(root);

	return 0;
}
예제 #9
0
/*!
    Добавляет словарь
*/
void DictionaryManager::addDictionary(const QString &filename, const QString &key)
{
    QSharedMemory *shared = loadDictionary(filename, key);
    data[key] = shared;
    filenameToKey[filename] = key;
    watcher.addPath(filename);
    qDebug() << tr("Словарь %1 успешно загружен с ключём %2").arg(filename).arg(key);
}
예제 #10
0
파일: Lab2main.c 프로젝트: vyder/CS_15-123
int main( int argc, char *argv[] )
{
	char dictionary[MAX_WORDS][MAX_WORDLEN];
	int count=0;
	
	loadDictionary( argv[1], dictionary, &count);
	
	menu( dictionary, &count, argv[2] );
	
	return EXIT_SUCCESS;
}
예제 #11
0
QMap<QString, QVariant> MainWindow::loadDictionary(QDomNode n)
{
    QString itemName = "", itemTag = "", itemContents = "";
    QMap<QString, QVariant> returnMap;

    // Get first element of dictionary
    n = n.firstChild();

    while(!n.isNull()) {
        // Try to convert the node to an element.
        QDomElement e = n.toElement();

        // The node really is an element.
        if(!e.isNull()) {

            itemName = qPrintable(e.text());
            itemTag = qPrintable(e.tagName());

            Q_ASSERT_X(itemTag == "key", "MainWindow::loadLevelPlist", "Tag should be a key, but isn't!");

            n = n.nextSibling();
            e = n.toElement();
            itemContents = qPrintable(e.text());
            itemTag = qPrintable(e.tagName());

            // Simple case (either string or number)
            if(itemTag != "array" && itemTag != "dict")
            {
                returnMap.insert(itemName, itemContents);
            }

            // Do we have an array?
            else if(itemTag == "array")
            {
                returnMap.insert(itemName, loadArray(n));
            }

            // Else, we have a dictionary.  Let the recursion begin.
            else
            {
                returnMap.insert(itemName, loadDictionary(n));
            }

            n = n.nextSibling();
        }
    }

    return returnMap;
}
예제 #12
0
int main(int argc, char* argv[])
{
	int op;
	char buff[512], errBuff[512];
	Dictionary dict = NULL;

	loadDictionary(&dict, "Dictionary.dat");

	printf("AiRSQL mode >> 1\nAiRDB  mode >> 2\n");
	printf("Choose mode >> ");
	scanf("%d", &op);

	if (op == 2)
	{
		printf("\nFilepath : ");
		scanf("%s",buff);
		processAiRDB(buff);
	}
	else if (op == 1)
	{
		printf("Enter the string : ");

		while (1)
		{
			printf("\n[AiRSQL]> ");
			ac_gets(dict, buff);
			if (buff[0] == '0') return 0;
			int a = processAiRSQL(buff, errBuff);
			switch (a)
			{
			case DATATYPE_MISMATCH:
				printf("%s\n", errBuff);
				goto breakloop;
			default:
				break;
			}
			printf("%s\n", errBuff);
		}
	}
breakloop:

	printf("Press any key to continue...");
	_getch();
	return 0;
}
예제 #13
0
int main (int argc, const char * argv[]) {
    const char *filename;
    clock_t timer;
    int tableSize = 1000;
    struct hashMap* hashTable = createMap(tableSize);
    timer = clock();

    if(argc >= 2)
        filename = argv[1];
    else
        filename = "dictionary.txt"; /*specify your input text file here*/

    FILE* dictionary = fopen(filename, "r");
    if(dictionary == NULL) {
        char err[255];
        sprintf(err, "Failure opening file %s; exiting.\n", filename);
        perror(err);
        exit(EXIT_FAILURE);
    }

    loadDictionary(dictionary,hashTable);
    timer = clock() - timer;
    printf("Dictionary loaded in %f seconds\n", (float)timer / (float)CLOCKS_PER_SEC);

    char* word = (char*)malloc(256*sizeof(char));
    int quit=0;
    while(!quit) {
        printf("Enter a word: ");
        scanf("%s",word);
        if(containsKey(hashTable, lowercase(word)))
            printf("'%s' is spelled correctly.\n", word);
        else
            printf("'%s' is spelled incorrectly; please try again.\n", word);
        /* Don't remove this. It is used for grading*/
        if(strcmp(word,"quit")==0)
          quit=!quit;
    }
    free(word);

    fclose(dictionary);

    return 0;
}
예제 #14
0
int main(int argc, char **argv) {
	int fileLength;
	int i,j;
	char **dictionary;

	srandomdev();

	if (argc == 2) {
		fileLength = loadDictionary(argv[1], &dictionary);
		// printf("%p\n",*dictionary);
		// printf("%ld\n", sizeof(*dictionary));
		// for (i = 0; i < fileLength; i++) {
		// 	printf("%s\n", dictionary[i]);
		// }
		// printf("Random word of the day is %s\n", dictionary[random() % fileLength]);
		startGame(dictionary[random() % fileLength]);
	} else {
		printf("Usage:  %s <dictionary file>\n", argv[0]);
		printf("(try /usr/share/dict/words)\n");
	}
}
예제 #15
0
std::shared_ptr<AbstractTable> TableDumpLoader::load(std::shared_ptr<AbstractTable> intable, 
                                      const compound_metadata_list *meta, 
                                      const Loader::params &args)
{

  // First extract the dictionaries
  for(size_t i=0; i < intable->columnCount(); ++i) {
    std::string name = intable->nameOfColumn(i);
    loadDictionary(name, i, intable);
  }

  // Resize according to meta information
  size_t tableSize = getSize();
  intable->resize(tableSize);
  
  for(size_t i=0; i < intable->columnCount(); ++i) {
    std::string name = intable->nameOfColumn(i);
    loadAttribute(name, i, tableSize, intable);
  }

  return intable;
}
예제 #16
0
QList<QVariant> MainWindow::loadArray(QDomNode n)
{
    QString itemName = "", itemTag = "";
    QList< QVariant > returnArray;

    // Get first item of array
    QDomNode m = n.firstChild();

    while(!m.isNull())
    {
        // Try to convert the node to an element.
        QDomElement e = m.toElement();

        // The node really is an element.
        if(!e.isNull()) {

            itemName = qPrintable(e.text());
            itemTag = qPrintable(e.tagName());

            if(itemTag == "array")
            {
                returnArray.append(loadArray(m));
            }
            else if(itemTag == "dict")
            {
                returnArray.append(loadDictionary(m));
            }
            else
            {
                returnArray.append(itemName);
            }
        }

        m = m.nextSibling();
    }

    return returnArray;
}
예제 #17
0
int main(int argc, const char * argv[]) {
	clock_t timer;
	int tableSize = 1000;
	struct hashMap* hashTable = createMap(tableSize);
	timer = clock();
	//initMap(hashTable, tableSize); no longer in header

	FILE* dictionary = fopen("dictionary.txt", "r"); //open the dicitionary file for reading

	loadDictionary(dictionary, hashTable);
	timer = clock() - timer;
	printf("Dictionary loaded in %f seconds\n", (float)timer / (float)CLOCKS_PER_SEC);

	char* word = (char*)malloc(256 * sizeof(char));
	int quit = 0;
	while (!quit) {
		printf("Enter a word: "); //prompt to enter a word
		scanf("%s", word); //read the given input

						   //if the input value can be found in the hash table, then it was spelled correctly
		if (!containsKey(hashTable, word))
		{
			printf("%s is spelled wrong.\n", word);
		}
		else
		{
			printf("%s is spelled correctly.\n", word);
		}

		/* Don't remove this. It is used for grading*/
		if (strcmp(word, "quit") == 0)
			quit = !quit;
	}
	free(word);

	return 0;
}
예제 #18
0
int main( int argc, char *argv[] )
{
	time_t startTime, stopTime;
	clock_t startCPU, stopCPU;
	double elapsedCPUsecs;
	int capacity = INITIAL_CAPACITY;
	int count =0;
	char **dictionary = malloc( capacity * sizeof(char *) );
	if (dictionary == NULL )
	{
		printf("Initial malloc of dictionary failed. Program exiting\n");
		return EXIT_FAILURE; /* EXIT_FAILURE defined as non zero in stdlib.h */
	}

	if (argc < 3 )
	{
		printf("usage: ./%s <infileName> <outFilename>\n",argv[0]); /* you gotta put in & out file names on cmd line! */
		return EXIT_FAILURE;
	}

	startTime = time( NULL );
	printf("\nStarting load of %s at %s", argv[1], ctime( &startTime) );
	printf("each '*' represents 10,000 words loaded into dictionary\n");
	startCPU = clock();
	loadDictionary( argv[1], &dictionary, &count, & capacity );
	stopCPU = clock();
	stopTime = time( NULL );
	printf("\nFinished load of %s at %s", argv[1], ctime( &stopTime) );
	printf("%d words loaded in %lu seconds\n", count, stopTime-startTime );
	elapsedCPUsecs = ((double)(stopCPU-startCPU)) / CLOCKS_PER_SEC;
	printf("Elapsed CPU seconds: %f\n",  elapsedCPUsecs );
	doMenu( argv[2], &dictionary, &count, &capacity );
	freeAllMemory( dictionary, count );

	return EXIT_SUCCESS; /* EXIT_SUCCESS defined as 0 in stdlib.h */
}
예제 #19
0
int main(int argc, char **argv)
{
	int i, j;
	struct timeval time_interval;
	fd_set useRead;
	fd_set useExcept;
	int selRet;
	char errTxt[256];
	RsslBuffer errorText = {255, (char*)errTxt};
	RsslInProgInfo inProg = RSSL_INIT_IN_PROG_INFO;
	RsslRet	retval = 0;
	int iargs;
	RsslErrorInfo rsslErrorInfo;
	RsslBool cacheOption = RSSL_FALSE;

	RsslReactorOMMProviderRole providerRole;

	RsslBindOptions sopts = RSSL_INIT_BIND_OPTS;

	RsslCreateReactorOptions reactorOpts;

	RsslReactorDispatchOptions dispatchOpts;

	time_t nextSendTime;

	/* Initialize RSSL. The locking mode RSSL_LOCK_GLOBAL_AND_CHANNEL is required to use the RsslReactor. */
	if (rsslInitialize(RSSL_LOCK_GLOBAL_AND_CHANNEL, &rsslErrorInfo.rsslError) != RSSL_RET_SUCCESS)
	{
		printf("rsslInitialize(): failed <%s>\n",rsslErrorInfo.rsslError.text);
		/* WINDOWS: wait for user to enter something before exiting  */
#ifdef _WIN32
		printf("\nPress Enter or Return key to exit application:");
		getchar();
#endif
		exit(RSSL_RET_FAILURE);
	}

	rsslClearOMMProviderRole(&providerRole);

	providerRole.base.channelEventCallback = channelEventCallback;
	providerRole.base.defaultMsgCallback = defaultMsgCallback;
	providerRole.loginMsgCallback = loginMsgCallback;
	providerRole.directoryMsgCallback = directoryMsgCallback;
	providerRole.dictionaryMsgCallback = dictionaryMsgCallback;
	providerRole.tunnelStreamListenerCallback = tunnelStreamListenerCallback;

	rsslClearCreateReactorOptions(&reactorOpts);

	if (!(pReactor = rsslCreateReactor(&reactorOpts, &rsslErrorInfo)))
	{
		printf("Reactor creation failed: %s\n", rsslErrorInfo.rsslError.text);
		cleanUpAndExit();
	}

	snprintf(portNo, 128, "%s", defaultPortNo);
	snprintf(serviceName, 128, "%s", defaultServiceName);
	setServiceId(1);
	for(iargs = 1; iargs < argc; ++iargs)
	{
		if (0 == strcmp("-p", argv[iargs]))
		{
			++iargs; if (iargs == argc) exitWithUsage();
			snprintf(portNo, 128, "%s", argv[iargs]);
		}
		else if (0 == strcmp("-s", argv[iargs]))
		{
			++iargs; if (iargs == argc) exitWithUsage();
			snprintf(serviceName, 128, "%s", argv[iargs]);
		}
		else if (0 == strcmp("-id", argv[iargs]))
		{
			long tmpId = 0;
			++iargs; if (iargs == argc) exitWithUsage();
			tmpId = atol(argv[iargs]);
			if (tmpId < 0)
			{
				printf("ServiceId must be positive.\n");
				exitWithUsage();
			}
			setServiceId(tmpId);
		}
		else if (0 == strcmp("-x", argv[iargs]))
		{
			xmlTrace = RSSL_TRUE;
			snprintf(traceOutputFile, 128, "RsslVAProvider\0");
		}
		else if (0 == strcmp("-runtime", argv[iargs]))
		{
			++iargs; if (iargs == argc) exitWithUsage();
			timeToRun = atoi(argv[iargs]);
		}
		else if (0 == strcmp("-cache", argv[iargs]))
		{
			cacheOption = RSSL_TRUE;
		}
		else
		{
			printf("Error: Unrecognized option: %s\n\n", argv[iargs]);
			exitWithUsage();
		}
	}
	printf("portNo: %s\n", portNo);
	printf("serviceName: %s\n", serviceName);
	printf("serviceId: %llu\n", getServiceId());

	/* Initialiize client session information */
	for (i = 0; i < MAX_CLIENT_SESSIONS; i++)
	{
		clearClientSessionInfo(&clientSessions[i]);
	}

	initializeCache(cacheOption);

	/* Initialize login handler */
	initLoginHandler();

	/* Initialize source directory handler */
	initDirectoryHandler();

	/* Initialize dictionary provider */
	initDictionaryProvider();

	/* Initialize market price handler */
	initItemHandler();

	/* Initialize symbol list item list */
	initSymbolListItemList();

	/* Initialize market by order items */
	initMarketByOrderItems();


	/* set service name in directory handler */
	setServiceName(serviceName);

	/* load dictionary */
	if (loadDictionary() != RSSL_RET_SUCCESS)
	{
		/* exit if dictionary cannot be loaded */
		/* WINDOWS: wait for user to enter something before exiting  */
#ifdef _WIN32
		printf("\nPress Enter or Return key to exit application:");
		getchar();
#endif
		exit(RSSL_RET_FAILURE);
	}

	initializeCacheDictionary();

	/* Initialize run-time */
	initRuntime();

	FD_ZERO(&readFds);
	FD_ZERO(&exceptFds);
	
	sopts.guaranteedOutputBuffers = 500;
	sopts.serviceName = portNo;
	sopts.majorVersion = RSSL_RWF_MAJOR_VERSION;
	sopts.minorVersion = RSSL_RWF_MINOR_VERSION;
	sopts.protocolType = RSSL_RWF_PROTOCOL_TYPE;

	/* Create the server. */
	if (!(rsslSrvr = rsslBind(&sopts, &rsslErrorInfo.rsslError)))
	{
		printf("Unable to bind RSSL server: <%s>\n",rsslErrorInfo.rsslError.text);
		/* WINDOWS: wait for user to enter something before exiting  */
#ifdef _WIN32
		printf("\nPress Enter or Return key to exit application:");
		getchar();
#endif
		exit(RSSL_RET_FAILURE);
	}

	FD_SET(rsslSrvr->socketId, &readFds);
	FD_SET(pReactor->eventFd, &readFds);
	
	rsslClearReactorDispatchOptions(&dispatchOpts);
	dispatchOpts.maxMessages = MAX_CLIENT_SESSIONS;

	// initialize next send time
	nextSendTime = time(NULL) + UPDATE_INTERVAL;

	/* this is the main loop */
	while(RSSL_TRUE)
	{
		useRead = readFds;
		useExcept = exceptFds;
		time_interval.tv_sec = UPDATE_INTERVAL;
		time_interval.tv_usec = 0;

		/* Call select() to check for any messages */
		selRet = select(FD_SETSIZE,&useRead,
		    NULL,&useExcept,&time_interval);

		if (selRet > 0)
		{
			RsslRet ret;

			/* Accept connection, if one is waiting */
			if (FD_ISSET(rsslSrvr->socketId, &useRead))
			{
				RsslClientSessionInfo *pClientSessionInfo = NULL;
				RsslReactorAcceptOptions aopts;

				rsslClearReactorAcceptOptions(&aopts);

				/* find an available client session */
				for (i = 0; i < MAX_CLIENT_SESSIONS; i++)
				{
					if (!clientSessions[i].isInUse)
					{
						pClientSessionInfo = &clientSessions[i];
						pClientSessionInfo->isInUse = RSSL_TRUE;
						break;
					}
				}

				/* Reject the channel if we are out of client sessions */
				if (!pClientSessionInfo)
					aopts.rsslAcceptOptions.nakMount = RSSL_TRUE;
				else
					aopts.rsslAcceptOptions.userSpecPtr = pClientSessionInfo;


				printf("Accepting new connection...\n");
				if (rsslReactorAccept(pReactor, rsslSrvr, &aopts, (RsslReactorChannelRole*)&providerRole, &rsslErrorInfo) != RSSL_RET_SUCCESS)
				{
					printf("rsslReactorAccept() failed: %s(%s)\n", rsslErrorInfo.rsslError.text, rsslErrorInfo.errorLocation);
					cleanUpAndExit();
				}
			}

			/* Call rsslReactorDispatch().  This will handle any events that have occurred on its channels.
			 * If there are events or messages for the application to process, they will be delivered
			 * through the callback functions given by the providerRole object. 
			 * A return value greater than RSSL_RET_SUCCESS indicates there may be more to process. */
			while ((ret = rsslReactorDispatch(pReactor, &dispatchOpts, &rsslErrorInfo)) > RSSL_RET_SUCCESS)
				;

			if (ret < RSSL_RET_SUCCESS)
			{
				printf("rsslReactorDispatch() failed: %s\n", rsslErrorInfo.rsslError.text);
				cleanUpAndExit();
			}
		}
		else if (selRet < 0)
		{
#ifdef _WIN32
			if (WSAGetLastError() == WSAEINTR)
				continue;
			printf("Error: select: %d\n", WSAGetLastError());
#else
			if (errno == EINTR)
				continue;
			perror("select");
#endif
			cleanUpAndExit();
		}

		// send any updates at next send time
		if (time(NULL) >= nextSendTime)
		{
			/* Send market price updates for each connected channel */
			updateItemInfo();
			for (i = 0; i < MAX_CLIENT_SESSIONS; i++)
			{
				if (clientSessions[i].clientChannel != NULL)
				{
					if (sendItemUpdates(pReactor, clientSessions[i].clientChannel) != RSSL_RET_SUCCESS)
					{
						removeClientSessionForChannel(pReactor, clientSessions[i].clientChannel);
					}

					// send any tunnel stream messages
					for (j = 0; j < MAX_TUNNEL_STREAMS; j++)
					{
						if (clientSessions[i].simpleTunnelMsgHandler[j].tunnelStreamHandler.pTunnelStream != NULL)
						{
							handleSimpleTunnelMsgHandler(pReactor, clientSessions[i].clientChannel, &clientSessions[i].simpleTunnelMsgHandler[j]);
						}
					}
				}
			}

			nextSendTime += UPDATE_INTERVAL;
		}

		/* Handle run-time */
		handleRuntime();
	}
}
FourierDescriptor::FourierDescriptor(const string &fileName)
{
    FDdict= NULL;
    loadDictionary(fileName);
}
예제 #21
0
/** メインスレッド */
void ImeServer::service()
{
    uintptr_t targetID = MonAPI::Message::lookupMainThread("MONITOR.BIN");
    if (targetID == THREAD_UNKNOWN) {
        printf("IME: Monitor server not found\n");
        exit(1);
    }

    if (MonAPI::Message::send(targetID, MSG_STARTED, 0, 0, 0, NULL)) {
        printf("IME: Server start failed\n");
        exit(1);
    }

    // 辞書が読めなかったときはかな漢字変換はすべて失敗を返す
    bool dicLoaded = loadDictionary();

    MessageInfo info;
    while (1) {
        if (!MonAPI::Message::receive(&info)) {
            switch(info.header) {
            case MSG_IMESERVER_GETKANJI:
                {
                    HList<MonAPI::CString> result;
                    int hit = getKanji(info.str, &result);

                    // MSG_IMESERVER_GETKANJI
                    // arg2: ヒット数
                    if (dicLoaded == true) {
                        MonAPI::Message::reply(&info, hit, 0, NULL);
                    } else {
                        MonAPI::Message::reply(&info, 0, 0, NULL);
                    }

                    if (dicLoaded == true && hit > 0) {
                        // MSG_IMESERVER_STARTKANJI
                        // arg1: ヒット数
                        MonAPI::Message::sendReceive(&info, info.from, MSG_IMESERVER_STARTKANJI, hit, 0, 0, NULL);

                        for (int i = 0; i < hit; i++) {
                            // MSG_IMESERVER_KANJI
                            // arg1: ヒット数
                            // arg2: カウンタ
                            // str : よみ→漢字
                            MonAPI::Message::sendReceive(&info, info.from, MSG_IMESERVER_KANJI, hit, i, 0, (const char*)result.get(i));
                            //printf("%d: %s\n", i, (const char*)result.get(i));
                        }

                        // MSG_IMESERVER_ENDKANJI
                        // arg1: ヒット数
                        MonAPI::Message::sendReceive(&info, info.from, MSG_IMESERVER_ENDKANJI, hit, 0, 0, NULL);
                    }
                }
                break;
            case MSG_IMESERVER_GETYOMI:
                {
                    // MSG_IMESERVER_GETYOMI
                    // arg2: 0-失敗 1-成功
                    // str : 漢字→よみ
                    char result[MAX_TEXT_LEN];
                    if (dicLoaded == true && getYomi(info.str, result) == true) {
                        strncpy(info.str, result, MAX_TEXT_LEN);
                        MonAPI::Message::reply(&info, 1, 0, result);
                    } else {
                        strncpy(info.str, "", MAX_TEXT_LEN);
                        MonAPI::Message::reply(&info, 0, 0, "");
                    }
                }
                break;
            case MSG_IMESERVER_GETKANA:
                {
                    // MSG_IMESERVER_GETKANA
                    // arg2: 0-失敗 1-成功
                    // str : 入力文字→かな
                    char result[MAX_TEXT_LEN];
                    if (getKana(info.str, result) == true) {
                        strncpy(info.str, result, MAX_TEXT_LEN);
                        MonAPI::Message::reply(&info, 1, 0, result);
                    } else {
                        strncpy(info.str, "", MAX_TEXT_LEN);
                        MonAPI::Message::reply(&info, 0, 0, "");
                    }
                }
                break;
            case MSG_IMESERVER_GETROMAN:
                {
                    // MSG_IMESERVER_GETROMAN
                    // arg2: 0-失敗 1-成功
                    // str : かな→入力文字
                    char result[MAX_TEXT_LEN];
                    if (getRoman(info.str, result) == true) {
                        strncpy(info.str, result, MAX_TEXT_LEN);
                        MonAPI::Message::reply(&info, 1, 0, result);
                    } else {
                        strncpy(info.str, "", MAX_TEXT_LEN);
                        MonAPI::Message::reply(&info, 0, 0, "");
                    }
                }
                break;
            }
        }
    }
}
예제 #22
0
파일: checker.cpp 프로젝트: kanei/MoTag
Checker::Checker()
{
  dictionary = dictionary->getInstance();
  loadDictionary();
  //ctor
}
예제 #23
0
//END APIQA
int main(int argc, char **argv)
{
	struct timeval time_interval;
	RsslError error;
	fd_set useRead;
	fd_set useExcept;
	fd_set useWrt;
	int selRet;
	char errTxt[256];
	RsslBuffer errorText = {255, (char*)errTxt};
	RsslRet	retval = 0;
	RsslInProgInfo inProg = RSSL_INIT_IN_PROG_INFO;
	int i;
	RsslInitializeExOpts initOpts = RSSL_INIT_INITIALIZE_EX_OPTS;
	time_t currentTime;
#ifdef _WIN32
	int rcvBfrSize = 65535;
	int sendBfrSize = 65535;
#endif
	snprintf(srvrHostname, 128, "%s", defaultSrvrHostname);
	snprintf(srvrPortNo, 128, "%s", defaultSrvrPortNo);
	snprintf(serviceName, 128, "%s", defaultServiceName);
	snprintf(interfaceName, 128, "%s", defaultInterface);
	setUsername((char *)"");
	setAuthenticationToken((char *)"");
	setAuthenticationExtended((char *)"");
	setApplicationId((char *)"");
	snprintf(proxyHostname, 128, "%s", defaultProxyHost);
	snprintf(proxyPort, 128, "%s", defaultProxyPort);

    /* Check usage and retrieve operating parameters */
	if (argc == 1) /* use default operating parameters */
	{
		snprintf(itemName, 128, "%s", defaultItemName);
		/* add item name in market price handler */
		addMarketPriceItemName(itemName, RSSL_FALSE);
		mpItemReq = RSSL_TRUE;

		printf("\nUsing default operating parameters...\n\n");
		printf("srvrHostname: %s\n", srvrHostname);
		printf("srvrPortNo: %s\n", srvrPortNo);
		printf("serviceName: %s\n", serviceName);
		printf("itemName: %s\n", itemName);
		printf("connType: %d\n", connType);
	}
	else if (argc > 1) /* all operating parameters entered by user */
	{
		i = 1;

		while(i < argc)
		{
			if(strcmp("-libsslName", argv[i]) == 0)
			{
				i += 2;
				snprintf(libsslName, 128, "%s", argv[i-1]);
				initOpts.jitOpts.libsslName = libsslName;
			}
			//APIQA
			else if (strcmp("-reissueDir", argv[i]) == 0)
			{
				printf("Found -reissueDir ");

				_initialDirFilter = atoi(argv[++i]);

				printf("%d ", _initialDirFilter);

				_reissueDirFilter = atoi(argv[++i]);

				printf("%d\n", _reissueDirFilter);

				setDirectoryFilter(_initialDirFilter, _reissueDirFilter);

				break;
			}
			else if (strcmp("-reissueDict", argv[i]) == 0)
			{
				printf("Found -reissueDict ");

				_initialDictFilter = atoi(argv[++i]);

				printf("%d ", _initialDictFilter);

				_reissueDictFilter = atoi(argv[++i]);

				printf("%d\n", _reissueDictFilter);

				setDictionaryFilter(_initialDictFilter, _reissueDictFilter);

				break;
			}
			else if (strcmp("-xmlTrace", argv[i]) == 0)
			{
				xmlTrace = RSSL_TRUE;
				++i;
			}
			else if (strcmp("-loadDictFromFile", argv[i]) == 0)
			{
				_loadDictFromFile = RSSL_TRUE;
				++i;
			}
			else if (strcmp("-reissueQos", argv[i]) == 0)
			{
				_reissueQos = RSSL_TRUE;

				_qosRate = atoi(argv[++i]);

				_qosTimeliness = atoi(argv[++i]);

				printf("\nReissueQoS for rate = %d and timeline = %d\n", _qosRate, _qosTimeliness);

				setReissueQos(_qosRate, _qosTimeliness);

				break;
			}
			else if (strcmp("-reissueQosAndWorstQos", argv[i]) == 0)
			{
				_reissueQosAndWorstQos = RSSL_TRUE;

				_qosRate = atoi(argv[++i]);

				_qosTimeliness = atoi(argv[++i]);

				_worstQosRate = atoi(argv[++i]);

				_worstQosTimeliness = atoi(argv[++i]);

				printf("\nReissueQoS for rate = %d and timeline = %d\n", _qosRate, _qosTimeliness);
				printf("ReissueWorstQos QoS for worstRate = %d and worstTimeliness = %d\n", _worstQosRate, _worstQosTimeliness);

				setReissueQosAndWorstQos(_qosRate, _qosTimeliness, _worstQosRate, _worstQosTimeliness);

				break;
			}
			else if (strcmp("-sendGenericMsgOnLogin", argv[i]) == 0)
			{
				_sendGenMsgOnLogin = RSSL_TRUE;
				break;
			}
			else if (strcmp("-sendGenericMsgOnDirectory", argv[i]) == 0)
			{
				_sendGenMsgOnDirectory = RSSL_TRUE;
				break;
			}
			else if (strcmp("-requestDict", argv[i]) == 0)
			{
				_initialDictFilter = atoi(argv[++i]);
				break;
			}
			else if (strcmp("-requestDir", argv[i]) == 0)
			{
				_initialDirFilter = atoi(argv[++i]);
				break;
			}
			else if (strcmp("-reissueServiceId", argv[i]) == 0)
			{
				_changeServiceId = atoi(argv[++i]);

				printf("\nReissueServiceId to service ID = %d\n", _changeServiceId);

				setReissueChangeServiceName(_changeServiceId);
				break;
			}
			else if (strcmp("-privateStreamForItemReq", argv[i]) == 0)
			{
				setPriviateStream();
				++i;
			}
			else if (strcmp("-requestSameKeyWithDiffStreamId", argv[i]) == 0)
			{
				setReqSameKeyWithDiffStreamId();
				snprintf(itemName, 128, "%s", defaultItemName);
				addMarketPriceItemName(itemName, RSSL_FALSE);
				break;
			}
			else if (strcmp("-specificServiceId", argv[i]) == 0)
			{
				setSpecificServiceId(atoi(argv[++i]));
				++i;
			}
			else if (strcmp("-sendDirReqWithoutLogin", argv[i]) == 0)
			{
				_sendDirReqWithoutLogin = RSSL_TRUE;
				++i;
			}
			else if (strcmp("-sendDictReqWithoutLogin", argv[i]) == 0)
			{
				_sendDictReqWithoutLogin = RSSL_TRUE;
				++i;
			}
			else if (strcmp("-sendItemReqWithoutLogin", argv[i]) == 0)
			{
				_sendItemReqWithoutLogin = RSSL_TRUE;
				++i;
			}
			//END APIQA
			else if(strcmp("-libcryptoName", argv[i]) == 0)
			{
				i += 2;
				snprintf(libcryptoName, 128, "%s", argv[i-1]);
				initOpts.jitOpts.libcryptoName = libcryptoName;
			}
			else if(strcmp("-uname", argv[i]) == 0)
			{
				i += 2;
				setUsername(argv[i-1]);
			}
			else if(strcmp("-at", argv[i]) == 0)
			{
				i += 2;
				setAuthenticationToken(argv[i-1]);
			}
			else if(strcmp("-ax", argv[i]) == 0)
			{
				i += 2;
				setAuthenticationExtended(argv[i-1]);
			}
			else if(strcmp("-aid", argv[i]) == 0)
			{
				i += 2;
				setApplicationId(argv[i-1]);
			}
			else if(strcmp("-h", argv[i]) == 0)
			{
				i += 2;
				snprintf(srvrHostname, 128, "%s", argv[i-1]);
			}
			else if(strcmp("-p", argv[i]) == 0)
			{
				i += 2;
				snprintf(srvrPortNo, 128, "%s", argv[i-1]);
			}
			else if(strcmp("-ph", argv[i]) == 0)
			{
				i += 2;
				snprintf(proxyHostname, 128, "%s", argv[i-1]);
			}
			else if(strcmp("-pp", argv[i]) == 0)
			{
				i += 2;
				snprintf(proxyPort, 128, "%s", argv[i-1]);
			}
			else if(strcmp("-s", argv[i]) == 0)
			{
				i += 2;
				snprintf(serviceName, 128, "%s", argv[i-1]);
			}
			else if (strcmp("-c", argv[i]) == 0)
			{
				i += 1;				
				if (0 == strcmp(argv[i], "socket") || 0 == strcmp(argv[i], "0"))
					connType = RSSL_CONN_TYPE_SOCKET;
				else if (0 == strcmp(argv[i], "http") || 0 == strcmp(argv[i], "2"))
					connType = RSSL_CONN_TYPE_HTTP;
				else if (0 == strcmp(argv[i], "encrypted") || 0 == strcmp(argv[i], "1"))
					connType = RSSL_CONN_TYPE_ENCRYPTED;
				else if (0 == strcmp(argv[i], "reliableMCast") || 0 == strcmp(argv[i], "4"))
					connType = RSSL_CONN_TYPE_RELIABLE_MCAST;
				else 
				{
					connType = (RsslConnectionTypes)atoi(argv[i]);	
				}
				i += 1;
			}
			else if (strcmp("-yc", argv[i]) == 0)
			{
				i += 2;
				/* add item name in yield curve handler */
				addYieldCurveItemName(argv[i-1], RSSL_FALSE);
				ycItemReq = RSSL_TRUE;
			}
			else if(strcmp("-mp", argv[i]) == 0)
			{
				i += 2;
				/* add item name in market price handler */
				addMarketPriceItemName(argv[i-1], RSSL_FALSE);	
				mpItemReq = RSSL_TRUE;
				
			}
			else if(strcmp("-mbo", argv[i]) == 0)
			{
				i += 2;
				/* add item name in market by order handler */
				addMarketByOrderItemName(argv[i-1], RSSL_FALSE);
				mboItemReq = RSSL_TRUE;
			}
			else if(strcmp("-mbp", argv[i]) == 0)
			{
				i += 2;
				/* add item name in market by price handler */
				addMarketByPriceItemName(argv[i-1], RSSL_FALSE);	
				mbpItemReq = RSSL_TRUE;
			}
			else if(strcmp("-sl", argv[i]) == 0)
			{
				i++;
				slReq = RSSL_TRUE;
				/* check the rest of the command line arguments */
				if(i != argc)
				{
					/* check to see if next strings is the symbol list name */
					if(!(strncmp("-", argv[i], 1)))
					{
						/* user didn't specifiy name */
						setSymbolListInfo(RSSL_FALSE, slReq);
					}
					else
					{
						i++;
						setSymbolListName(argv[i-1]);
						setSymbolListInfo(RSSL_TRUE, slReq);
					}
				}
				else
				{
					/* no more command line arguments, so user didn't specifiy SL name */
					setSymbolListInfo(RSSL_FALSE, slReq);
				}
			}
			else if(strcmp("-view", argv[i]) == 0)
			{
				i++;
				setViewRequest();
			}
			else if (strcmp("-post", argv[i]) == 0)
			{
				i++;
				onPostEnabled = RSSL_TRUE;
				enableOnstreamPost();
			}
			else if (strcmp("-x", argv[i]) == 0)
			{
				i++;
				xmlTrace = RSSL_TRUE;
				snprintf(traceOutputFile, 128, "RsslConsumer\0");
			}
			else if (strcmp("-td", argv[i]) == 0)
			{
				i++;
				showTransportDetails = RSSL_TRUE;
			}
			else if (strcmp("-offpost", argv[i]) == 0)
			{
				i++;
				offPostEnabled = RSSL_TRUE;
			}
			else if(strcmp("-snapshot", argv[i]) == 0)
			{
				i++;
				setMPSnapshotRequest();
				setMBOSnapshotRequest();
				setMBPSnapshotRequest();
				setSLSnapshotRequest();
				setYCSnapshotRequest();
			}
			else if(strcmp("-mpps", argv[i]) == 0)
			{
				i += 2;
				/* add item name in market price handler */
				addMarketPriceItemName(argv[i-1], RSSL_TRUE);	
				mpItemReq = RSSL_TRUE;
				
			}
			else if(strcmp("-mbops", argv[i]) == 0)
			{
				i += 2;
				/* add item name in market by order handler */
				addMarketByOrderItemName(argv[i-1], RSSL_TRUE);
				mboItemReq = RSSL_TRUE;
			}
			else if(strcmp("-mbpps", argv[i]) == 0)
			{
				i += 2;
				/* add item name in market by price handler */
				addMarketByPriceItemName(argv[i-1], RSSL_TRUE);	
				mbpItemReq = RSSL_TRUE;
			}
			else if (strcmp("-ycps", argv[i]) == 0)
			{
				i += 2;
				/* add item name in yield curve handler */
				addYieldCurveItemName(argv[i-1], RSSL_TRUE);
				ycItemReq = RSSL_TRUE;
			}
			else if(strcmp("-runtime", argv[i]) == 0)
			{
				i += 2;
				timeToRun = atoi(argv[i-1]);
			}
			else
			{
				printf("Error: Unrecognized option: %s\n\n", argv[i]);
				printf("Usage: %s or\n%s [-uname <LoginUsername>] [-h <SrvrHostname>] [-p <SrvrPortNo>] [-c <ConnType>] [-s <ServiceName>] [-view] [-post] [-offpost] [-snapshot] [-sl [<SymbolList Name>]] [-mp|-mpps <MarketPrice ItemName>] [-mbo|-mbops <MarketByOrder ItemName>] [-mbp|-mbpps <MarketByPrice ItemName>] [-runtime <seconds>] [-td]\n", argv[0], argv[0]);
				printf("\n -mp or -mpps For each occurance, requests item using Market Price domain. (-mpps for private stream)\n");
				printf("\n -mbo or -mbops For each occurance, requests item using Market By Order domain. (-mbops for private stream)\n");
				printf("\n -mbp or -mbpps For each occurance, requests item using Market By Price domain. (-mbpps for private stream)\n");
				printf("\n -yc or -ycps For each occurance, requests item using Yield Curve domain. (-ycps for private stream)\n");
				printf("\n -view specifies each request using a basic dynamic view.\n");
				printf("\n -post specifies that the application should attempt to send post messages on the first requested Market Price item (i.e., on-stream)\n");
				printf("\n -offpost specifies that the application should attempt to send post messages on the login stream (i.e., off-stream)\n");
				printf("\n -snapshot specifies each request using non-streaming.\n");
				printf("\n -sl requests symbol list using Symbol List domain. (symbol list name optional)\n");
				printf("\n -td prints out additional transport details from rsslReadEx() and rsslWriteEx() function calls \n");
				printf("\n -x provides an XML trace of messages.\n");
				printf("\n -at Specifies the Authentication Token. If this is present, the login user name type will be RDM_LOGIN_USER_AUTHN_TOKEN.\n");
				printf("\n -ax Specifies the Authentication Extended information.\n");
				printf("\n -aid Specifies the Application ID.\n");
				printf("\n -runtime adjusts the time the application runs.\n");
				//APIQA
				printf("-sendGenericMsgOnLogin\n");
				printf("-sendGenericMsgOnDirectory\n");
				printf("-requestDict <verbosity>\n");
				printf("-requestDir <filters>\n");
				printf("-reissueServiceId <service ID>\n");
				printf("-reissueDir <initial filter> <reissue filter>\n");
				printf("-reissueDict <initial filter> <reissue filter>\n");
				printf("-reissueQos <rate> <timeliness>\n");
				printf("-reissueQosAndWorstQos <rate> <timeliness> <worstRate> <worstTimeliness>\n");

				printf("\nRate value definition\n\t- rate == 0 then RSSL_QOS_RATE_TICK_BY_TICK\n\t- rate == -1 then RSSL_QOS_RATE_JIT_CONFLATED\n\t- if 0 < rate <= 65535, RSSL_QOS_RATE_TIME_CONFLATED using the rate for rateInfo\n");
				printf("\nTimeliness value definition\n\t- timeliness == 0 then RSSL_QOS_TIME_REALTIME\n\t- timeliness == -1 then RSSL_QOS_TIME_DELAYED_UNKNOWN\n\t- if 0 < timeliness <= 65535, RSSL_QOS_TIME_DELAYED using the timelines for timeInfo");
				//END APIQA
#ifdef _WIN32
				/* WINDOWS: wait for user to enter something before exiting  */
				printf("\nPress Enter or Return key to exit application:");
				getchar();
#endif
				exit(RSSL_RET_FAILURE);

			}


		}
		//APIQA
		setDirectoryFilter(_initialDirFilter, _reissueDirFilter);
		setDictionaryFilter(_initialDictFilter, _reissueDictFilter);
		//END APIQA
		printf("Proxy host: %s\n", proxyHostname);
		printf("Proxy port: %s\n", proxyPort);
		
		printf("\nInput arguments...\n\n");
		printf("Using Connection Type = %d\n", connType);
		printf("srvrHostname: %s\n", srvrHostname);
		printf("srvrPortNo: %s\n", srvrPortNo);
			

		printf("serviceName: %s\n", serviceName);

		/* if no items were requested but a command line was specified, use the default item */
		if (!mpItemReq && !mboItemReq && !mbpItemReq && !slReq && !ycItemReq)
		{
			snprintf(itemName, 128, "%s", defaultItemName);
			/* add item name in market price handler */
			addMarketPriceItemName(itemName, RSSL_FALSE);
			mpItemReq = RSSL_TRUE;
		}

		/* this application requires at least one market price item to be requested
		   for on-stream posting to be performed */
		if (onPostEnabled && !mpItemReq)
		{
			printf("\nPosting will not be performed as no Market Price items were requested\n");
			onPostEnabled = RSSL_FALSE;
		}
	}

	/* set service name in directory handler */
	setServiceName(serviceName);

	/* load dictionary */
	//APIQA
	//loadDictionary();
	if (_loadDictFromFile)
	{
		loadDictionary();
	}
	//APIQA
	/* Initialize RSSL */
	/* RSSL_LOCK_NONE is used since this is a single threaded application. */
	if (rsslInitializeEx(&initOpts, &error) != RSSL_RET_SUCCESS)
	{
		printf("rsslInitialize(): failed <%s>\n", error.text);
		/* WINDOWS: wait for user to enter something before exiting  */
#ifdef _WIN32
		printf("\nPress Enter or Return key to exit application:");
		getchar();
#endif
		exit(RSSL_RET_FAILURE);
	}

	FD_ZERO(&readfds);
	FD_ZERO(&exceptfds);
	FD_ZERO(&wrtfds);

	/* Initialize run-time */
	initRuntime();

	/* this is the main loop */
	while(1)
	{
		/* this is the connection recovery loop */
		while(shouldRecoverConnection)
		{
			/* Connect to RSSL server */
			printf("\nAttempting to connect to server %s:%s...\n", srvrHostname, srvrPortNo);
			if ((rsslConsumerChannel = connectToRsslServer(connType, &error)) == NULL)
			{
				printf("Unable to connect to RSSL server: <%s>\n",error.text);
			}
			else
			{
				FD_SET(rsslConsumerChannel->socketId, &readfds);
				FD_SET(rsslConsumerChannel->socketId, &wrtfds);
				FD_SET(rsslConsumerChannel->socketId, &exceptfds);
			}

			if (rsslConsumerChannel != NULL && rsslConsumerChannel->state == RSSL_CH_STATE_ACTIVE)
				shouldRecoverConnection = RSSL_FALSE;

			/* Wait for channel to become active.  This finalizes the three-way handshake. */
			while (rsslConsumerChannel != NULL && rsslConsumerChannel->state != RSSL_CH_STATE_ACTIVE)
			{
				useRead = readfds;
				useWrt = wrtfds;
				useExcept = exceptfds;

				/* Set a timeout value if the provider accepts the connection, but does not initialize it */
				time_interval.tv_sec = 60;
				time_interval.tv_usec = 0;

				selRet = select(FD_SETSIZE, &useRead, &useWrt, &useExcept, &time_interval);

				/* select has timed out, close the channel and attempt to reconnect */
				if(selRet == 0)
				{
					printf("\nChannel initialization has timed out, attempting to reconnect...\n");

					FD_CLR(rsslConsumerChannel->socketId, &readfds);
					FD_CLR(rsslConsumerChannel->socketId, &exceptfds);
					if (FD_ISSET(rsslConsumerChannel->socketId, &wrtfds))
						FD_CLR(rsslConsumerChannel->socketId, &wrtfds);
					
					recoverConnection();
				}
				else
				/* Received a response from the provider. */
				if(selRet > 0 && (FD_ISSET(rsslConsumerChannel->socketId, &useRead) || FD_ISSET(rsslConsumerChannel->socketId, &useWrt) || FD_ISSET(rsslConsumerChannel->socketId, &useExcept)))
				{
					if (rsslConsumerChannel->state == RSSL_CH_STATE_INITIALIZING)
					{
						FD_CLR(rsslConsumerChannel->socketId,&wrtfds);
						if ((retval = rsslInitChannel(rsslConsumerChannel, &inProg, &error)) < RSSL_RET_SUCCESS)
						{
							printf("\nchannelInactive fd="SOCKET_PRINT_TYPE" <%s>\n",	
								rsslConsumerChannel->socketId,error.text);
							recoverConnection();
							break; 
						}
						else 
						{
			  				switch (retval)
							{
							case RSSL_RET_CHAN_INIT_IN_PROGRESS:
								if (inProg.flags & RSSL_IP_FD_CHANGE)
								{
									printf("\nChannel In Progress - New FD: "SOCKET_PRINT_TYPE"  Old FD: "SOCKET_PRINT_TYPE"\n",rsslConsumerChannel->socketId, inProg.oldSocket );	

									FD_CLR(inProg.oldSocket,&readfds);
									FD_CLR(inProg.oldSocket,&exceptfds);
									FD_SET(rsslConsumerChannel->socketId,&readfds);
									FD_SET(rsslConsumerChannel->socketId,&exceptfds);
									FD_SET(rsslConsumerChannel->socketId,&wrtfds);
								}
								else
								{
									printf("\nChannel "SOCKET_PRINT_TYPE" In Progress...\n", rsslConsumerChannel->socketId);	
									//Sleep(1000);
								}
								break;
							case RSSL_RET_SUCCESS:
								{
									RsslChannelInfo chanInfo;
									
									printf("\nChannel "SOCKET_PRINT_TYPE" Is Active\n" ,rsslConsumerChannel->socketId);	
									/* reset should recover connection flag */
									shouldRecoverConnection = RSSL_FALSE;
									/* if device we connect to supports connected component versioning, 
									 * also display the product version of what this connection is to */
									if ((retval = rsslGetChannelInfo(rsslConsumerChannel, &chanInfo, &error)) >= RSSL_RET_SUCCESS)
									{
										RsslUInt32 i;
										for (i = 0; i < chanInfo.componentInfoCount; i++)
										{
											printf("Connected to %s device.\n", chanInfo.componentInfo[i]->componentVersion.data);
										}
									}
										
								}
								break;
							default:
									printf("\nBad return value fd="SOCKET_PRINT_TYPE" <%s>\n",	
									   rsslConsumerChannel->socketId,error.text);
								cleanUpAndExit();
								break;
							}
						}
					}
				}
				else
				if(selRet < 0)
				{
					printf("\nSelect error.\n");
					cleanUpAndExit();
				}

				handleRuntime();
			}

			/* sleep before trying again */
			if (shouldRecoverConnection)
			{
				for(i = 0; i < CONSUMER_CONNECTION_RETRY_TIME; ++i)
				{
#ifdef _WIN32
					Sleep(1000);
#else
					sleep(1);
#endif
					handleRuntime();

				}
			}

		}

		/* WINDOWS: change size of send/receive buffer since it's small by default */
#ifdef _WIN32
		if (rsslIoctl(rsslConsumerChannel, RSSL_SYSTEM_WRITE_BUFFERS, &sendBfrSize, &error) != RSSL_RET_SUCCESS)
		{
			printf("rsslIoctl(): failed <%s>\n", error.text);
		}
		if (rsslIoctl(rsslConsumerChannel, RSSL_SYSTEM_READ_BUFFERS, &rcvBfrSize, &error) != RSSL_RET_SUCCESS)
		{
			printf("rsslIoctl(): failed <%s>\n", error.text);
		}
#endif

		/* Initialize ping handler */
		initPingHandler(rsslConsumerChannel);

		/* Send login request message */
		isLoginReissue = RSSL_FALSE;
		//APIQA
		/*if (sendLoginRequest(rsslConsumerChannel, "rsslConsumer", RSSL_CONSUMER, &loginSuccessCallBack) != RSSL_RET_SUCCESS)
		{
			cleanUpAndExit();
		}*/
		if (!_sendDirReqWithoutLogin && !_sendDictReqWithoutLogin && !_sendItemReqWithoutLogin)
		{
			if (sendLoginRequest(rsslConsumerChannel, "rsslConsumer", RSSL_CONSUMER, &loginSuccessCallBack) != RSSL_RET_SUCCESS)
			{
				cleanUpAndExit();
			}
                }
		else
		{
                               
				        printf("FALSE\n");
				if (_sendDirReqWithoutLogin)
				{
					sendSourceDirectoryRequest(rsslConsumerChannel, _sendGenMsgOnDirectory);
				}
				else if (_sendDictReqWithoutLogin)
				{
					sendDictionaryRequest(rsslConsumerChannel, "RWFFld", FIELD_DICTIONARY_STREAM_ID, _initialDictFilter);

					sendDictionaryRequest(rsslConsumerChannel, "RWFEnum", ENUM_TYPE_DICTIONARY_STREAM_ID, _initialDictFilter);
				}
				else if (_sendItemReqWithoutLogin)
				{
				        printf("Sending MP REQUEST\n");
					sendMarketPriceItemRequests(rsslConsumerChannel);
				}
		}
		//END APIQA
	
		/* this is the message processing loop */
		while(1)
		{
			useRead = readfds;
			useExcept = exceptfds;
			useWrt = wrtfds;
			time_interval.tv_sec = 1;
			time_interval.tv_usec = 0;

			/* Call select() to check for any messages */
			selRet = select(FD_SETSIZE,&useRead,
				&useWrt,&useExcept,&time_interval);

			if (selRet < 0) /* no messages received, continue */
			{
#ifdef _WIN32
				if (WSAGetLastError() == WSAEINTR)
					continue;
#else
				if (errno == EINTR)
				{
					continue;
				}
#endif
			}
			else if (selRet > 0) /* messages received, read from channel */
			{
				if ((rsslConsumerChannel != NULL) && (rsslConsumerChannel->socketId != -1))
				{
					if ((FD_ISSET(rsslConsumerChannel->socketId, &useRead)) ||
						(FD_ISSET(rsslConsumerChannel->socketId, &useExcept)))
					{
						if (readFromChannel(rsslConsumerChannel) != RSSL_RET_SUCCESS)
							recoverConnection();
					}

					/* flush for write file descriptor and active state */
					if (rsslConsumerChannel != NULL &&
						FD_ISSET(rsslConsumerChannel->socketId, &useWrt) &&
						rsslConsumerChannel->state == RSSL_CH_STATE_ACTIVE)
					{
						if ((retval = rsslFlush(rsslConsumerChannel, &error)) < RSSL_RET_SUCCESS)
						{
							printf("rsslFlush() failed with return code %d - <%s>\n", retval, error.text);
						}
						else if (retval == RSSL_RET_SUCCESS)
						{
							/* clear write fd */
							FD_CLR(rsslConsumerChannel->socketId, &wrtfds);
						}
					}
				}
			}

			/* break out of message processing loop if should recover connection */
			if (shouldRecoverConnection == RSSL_TRUE)
			{
				printf("Recovering connection in 5 seconds\n");
				connectionRecovery = RSSL_TRUE;
				#ifdef _WIN32
					Sleep(5000);
#else
					sleep(5);
#endif
				break;
			}

			/* Handle pings */
			handlePings(rsslConsumerChannel);

			/* Handle run-time */
			handleRuntime();

			if (onPostEnabled || offPostEnabled)
			{
				/* if configured to post, send post messages if its time */
				/* Handle Post */
				if (handlePosts(rsslConsumerChannel, connectionRecovery) != RSSL_RET_SUCCESS)
					recoverConnection();
				connectionRecovery = RSSL_FALSE;
			}

			if ((currentTime = time(NULL)) < 0)
			{
				printf("time() failed.\n");
			}

			// send login reissue if login reissue time has passed
			if (canSendLoginReissue == RSSL_TRUE &&
				currentTime >= (RsslInt)loginReissueTime)
			{
				isLoginReissue = RSSL_TRUE;
				if (sendLoginRequest(rsslConsumerChannel, "rsslConsumer", RSSL_CONSUMER, &loginSuccessCallBack) != RSSL_RET_SUCCESS)
				{
					printf("Login reissue failed\n");
				}
				else
				{
					printf("Login reissue sent\n");
				}
				canSendLoginReissue = RSSL_FALSE;
			}
		}
	}
}