コード例 #1
0
int main(int argc, char **argv)
{
	GOC_IStream *is = NULL;
	GOC_OStream *os = NULL;
	int c;
//	unsigned char *pBuff;
//	unsigned int nBuff;
	char *line;

	if ( argc < 2 )
	{
		GOC_ERROR("No input file name");
		return -1;
	}

	os = goc_memOStreamOpen();

	GOC_INFO("--- GOC_FileIStream test");
	is = goc_fileIStreamOpen(argv[1]);
//	nBuff = goc_isAvailable(is);
//	pBuff = malloc(nBuff);
	GOC_BINFO("Available: %d\n", goc_isAvailable(is));
//	nBuff = 0;
	while ( (c = goc_isReadChar(is)) > 0 )
	{
		goc_osWriteByte(os, (unsigned char)c);
//		pBuff[nBuff++] = c;
		putchar(c);
	}
	goc_isClose(is);

	GOC_INFO("--- GOC_MemIStream test\n");
	is = goc_memIStreamAttach(goc_memOStreamGet(os), goc_memOStreamSize(os));
//	nBuff = goc_isAvailable(is);
	GOC_BINFO("Available: %d\n", goc_isAvailable(is));
	while ( (c = goc_isReadChar(is)) > 0 )
		putchar(c);
	goc_isClose(is);

	GOC_INFO("--- GOC_FileIStream readLine test");
	is = goc_fileIStreamOpen(argv[1]);
	while ( (line = goc_isReadLine(is)) )
	{
		printf("%s\n", line);
	}
	goc_isClose(is);
	
	return 0;
}
コード例 #2
0
int main(int argc, char **argv)
{
	GOC_IStream* is = NULL;
	GOC_Iterator* it = NULL;
	GOC_Properties* props = NULL;
	if ( argc != 2 )
	{
		GOC_INFO("Podaj jako argument plik typu properties");
		return -1;
	}
	is = goc_fileIStreamOpen(argv[1]);
	props = goc_propertiesAlloc();
	props = goc_propertiesLoad(props, is);

	it = goc_propertiesListCategories(props);
	while ( goc_iteratorHasNext(it) )
	{
		GOC_Category* cat = (GOC_Category*)goc_iteratorNext(it);
		printf("GOC_Category: %s\n", cat->name);
		GOC_Iterator* pit = goc_propertiesListCategory(props, cat->name);
		while ( goc_iteratorHasNext(pit) )
		{
			GOC_Property* p = (GOC_Property*)goc_iteratorNext(pit);
			printf("\t%s = %s\n", p->name, p->value);
		}
		free(pit);
		printf("\n");
	}
	free(it);


	props = goc_propertiesFree(props);
	goc_isClose(is);
	return 0;
}
コード例 #3
0
ファイル: common.c プロジェクト: rojekabc/okienkoc
static void loadConfiguration(GOC_HANDLER terrain, GOC_HANDLER build, GOC_HANDLER front)
{
	GOC_IStream* is = NULL;
	GOC_Properties* props = NULL;

	is = goc_fileIStreamOpen( "aaow.properties" );
	if ( is )
	{
		props = goc_propertiesLoad( props, is );
		goc_isClose( is );
	}

	// definiuj wartosci
	goc_maparawSetBPV(terrain, 2); // 2 bity na warto¶æ
	goc_maparawAddChar(terrain, getChar(props, "terrain.tree.char", 't'), getColor(props, "terrain.tree.color", GOC_GREEN), 0);
	goc_maparawAddChar(terrain, getChar(props, "terrain.dirt.char", '.'), getColor(props, "terrain.dirt.color", GOC_WHITE), 1);
	goc_maparawAddChar(terrain, getChar(props, "terrain.river.char", '='), getColor(props, "terrain.river.color", GOC_CYAN), 2);
	goc_maparawAddChar(terrain, getChar(props, "terrain.mountain.char", '^'), getColor(props, "terrain.mountain.color", GOC_RED), 3);

	/* Now commented - all comes from listener calculation
	// definiuj wartosci
	goc_mapaposAddChar(build,  0 , GOC_WHITE, 0x00); // nic - don't add!
	goc_mapaposAddChar(build, getChar(props, "build.supply.char", 'S'), GOC_WHITE, 0x01); // supply
	goc_mapaposAddChar(build, getChar(props, "build.factory.char", 'f'), GOC_WHITE, 0x02); // factory
	goc_mapaposAddChar(build, getChar(props, "build.city.char", 'O'), GOC_WHITE, 0x03); // city
	goc_mapaposAddChar(build, getChar(props, "build.airport.char", 'L'), GOC_WHITE, 0x04); // airport
	goc_mapaposAddChar(build, getChar(props, "build.village.char", 'o'), GOC_WHITE, 0x05); // village
	goc_mapaposAddChar(build, getChar(props, "build.fort.char", '#'), GOC_WHITE, 0x06); // fort
	goc_mapaposAddChar(build, getChar(props, "build.capital.char", '0'), GOC_WHITE, 0x07); // capital
	goc_mapaposAddChar(build, getChar(props, "build.bridge.vertical.char", '-'), GOC_WHITE, 0x08); // bridge
	goc_mapaposAddChar(build, getChar(props, "build.bridge.horizontal.char", '|'), GOC_WHITE, 0x09); // bridge
	*/

	goc_maparawSetBPV(front, 2); // 2 bity na warto¶æ
	goc_maparawAddChar(front, 0, GOC_WHITE, 0);
	goc_maparawAddChar(front, getChar(props, "front.char", 'x'), GOC_RED | GOC_FBOLD, 1);
	goc_maparawAddChar(front, getChar(props, "front.char", 'x'), GOC_GREEN | GOC_FBOLD, 2);
	goc_maparawAddChar(front, getChar(props, "front.char", 'x'), GOC_CYAN | GOC_FBOLD, 3);
	props = goc_propertiesFree( props );
}
コード例 #4
0
int controlInit(int (*fun)(unsigned int, void*))
{
	if ( fun == NULL )
	{
		fprintf(stderr, "Nie podano funkcji kontrolnej.\n%s:%d\n",
				__FILE__, __LINE__);
		exit(1);
	}
	doAction = fun;
	// zainicjowanie systemu okienkoc
	goc_systemSetListenerFunc( &nasluch );
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'n', GOC_EFLAGA_ENABLE, hotKeyNext);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'N', GOC_EFLAGA_ENABLE, hotKeyNext);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'b', GOC_EFLAGA_ENABLE, hotKeyPrev);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'B', GOC_EFLAGA_ENABLE, hotKeyPrev);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'i', GOC_EFLAGA_ENABLE, hotKeyInfo);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'I', GOC_EFLAGA_ENABLE, hotKeyInfo);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'p', GOC_EFLAGA_ENABLE, hotKeyPause);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'P', GOC_EFLAGA_ENABLE, hotKeyPause);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'h', GOC_EFLAGA_ENABLE, hotKeyHelp);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'H', GOC_EFLAGA_ENABLE, hotKeyHelp);
	goc_hkAdd(GOC_HANDLER_SYSTEM, '?', GOC_EFLAGA_ENABLE, hotKeyHelp);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'q', GOC_EFLAGA_ENABLE, hotKeyQuit);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'Q', GOC_EFLAGA_ENABLE, hotKeyQuit);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 's', GOC_EFLAGA_ENABLE, hotKeyStop);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'S', GOC_EFLAGA_ENABLE, hotKeyStop);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 0x114, GOC_EFLAGA_ENABLE, hotKeyHome);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 0x120, GOC_EFLAGA_ENABLE, hotKeyAumixPlus);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 0x11f, GOC_EFLAGA_ENABLE, hotKeyAumixMinus);
	goc_hkAdd(GOC_HANDLER_SYSTEM, '+', GOC_EFLAGA_ENABLE, hotKeyAumixPlus);
	goc_hkAdd(GOC_HANDLER_SYSTEM, '-', GOC_EFLAGA_ENABLE, hotKeyAumixMinus);
	goc_hkAdd(GOC_HANDLER_SYSTEM, '*', GOC_EFLAGA_ENABLE, hotKeyAumixNext);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'r', GOC_EFLAGA_ENABLE, hotKeyShuffleOn);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'R', GOC_EFLAGA_ENABLE, hotKeyShuffleOff);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'l', GOC_EFLAGA_ENABLE, hotKeyShowList);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'L', GOC_EFLAGA_ENABLE, hotKeyShowList);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'a', GOC_EFLAGA_ENABLE, hotKeyAddFolder);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'A', GOC_EFLAGA_ENABLE, hotKeyAddFolder);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'x', GOC_EFLAGA_ENABLE, hotKeyQueue);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'X', GOC_EFLAGA_ENABLE, hotKeyQueue);
	
	nTytul = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 1, 0, 1,
		GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_WHITE, GOC_HANDLER_SYSTEM);
	goc_labelSetText(nTytul, "Rojkowy kontroler muzyki. Wersja 0.2 :+)",GOC_FALSE);
	nMixer = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 8, 8, 1,
		GOC_EFLAGA_PAINTED | GOC_EFLAGA_LEFT, GOC_WHITE, GOC_HANDLER_SYSTEM);
	pMixer = goc_elementCreate(GOC_ELEMENT_PRECENT, 9, 8, 0, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	goc_precentSetMin(pMixer, 0);
	goc_precentSetMax(pMixer, 100);
	nPlik = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 3, 0, 2,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nTitle = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 5, 0, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nArtist = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 6, goc_screenGetWidth()>>1, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nAlbum = goc_elementCreate(GOC_ELEMENT_LABEL, (goc_screenGetWidth()>>1) + 1, 6, 0, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nComment = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 7, goc_screenGetWidth()>>1, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nStatus = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 0, 0, 1,
		GOC_EFLAGA_PAINTED, GOC_GREEN, GOC_HANDLER_SYSTEM);
	nYear = goc_elementCreate(GOC_ELEMENT_LABEL, (goc_screenGetWidth()>>1) + 1, 7, 20, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	lLista = goc_elementCreate(GOC_ELEMENT_SELLIST, 1, 10, 0, -1,
		0, GOC_WHITE, GOC_HANDLER_SYSTEM);
	pLista = goc_elementCreate(GOC_ELEMENT_FILELIST, 1, 10, 0, -1,
		0, GOC_WHITE, GOC_HANDLER_SYSTEM);
	if ( goc_isFileExists(LOGO_FILE) )
	{
		char *line = NULL;
		nLogo = goc_elementCreate(GOC_ELEMENT_LABEL, -20, -10, 20, 8,
			GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_CYAN, GOC_HANDLER_SYSTEM);
		GOC_IStream* streamLogo = goc_fileIStreamOpen(LOGO_FILE);
		while ( (line = goc_isReadLine( streamLogo )) )
		{
			goc_labelAddLine(nLogo, line);
			line = goc_stringFree( line );
		}
		goc_isClose( streamLogo );
	}
	goc_filelistSetFolder(pLista, ".");
	goc_hkAdd(pLista, ' ', GOC_EFLAGA_ENABLE, hotKeySelectFolder);
	goc_elementSetFunc(lLista, GOC_FUNID_LISTENER, nasluch);

	printMixer();
	return 0;
}
コード例 #5
0
int main(int argc, char **argv)
{
	GOC_IStream *wordStream = NULL;
	GOC_IStream *fileStream = NULL;
	GOC_Properties *props = NULL;
	GOC_Iterator *propIt = NULL;
	char *line;
	char *pos = NULL;

	if ( argc < 3 )
	{
		GOC_BINFO("Usage: %s wordconvert.properties filetochange", argv[0]);
		GOC_INFO("\tApplication changes word in file to another");
		return 0;
	}
	wordStream = goc_fileIStreamOpen(argv[1]);
	if ( wordStream == NULL )
	{
		GOC_BERROR("Cannot open file %s", argv[1]);
		return -1;
	}
	fileStream = goc_fileIStreamOpen(argv[2]);
	if ( fileStream == NULL )
	{
		GOC_BERROR("Cannot open file %s", argv[2]);
		return -1;
	}
	props = goc_propertiesAlloc();
	props = goc_propertiesLoad(props, wordStream);
	while ( line = goc_isReadLine(fileStream) )
	{
		char *bline = NULL;
		char *last = line;
		pos = NULL;
		while ( pos = findNextWordBegin(line, pos) )
		{
			char *word = getWord( pos );
			char *v = goc_propertiesGetValue( props, word );

			*pos = 0;
			bline = goc_stringAdd(bline, last);

			if ( v != NULL )
			{
				bline = goc_stringAdd(bline, v);
			}
			else
			{
				bline = goc_stringAdd(bline, word);
			}
			pos += strlen(word);
			word = goc_stringFree(word);
			last = pos;
		}
		bline = goc_stringAdd(bline, last);
		puts(bline);
		line = goc_stringFree(line);
		bline = goc_stringFree(bline);
	}
	free(propIt);
	goc_isClose(wordStream);
	goc_isClose(fileStream);

	return 0;
}