Ejemplo n.º 1
0
// teksty wywala, zostaja kolumny 
static int listClear(GOC_HANDLER uchwyt)
{
	GOC_StList *lista = (GOC_StList*)uchwyt;
	GOC_COLUMN *k;
	int j;
	lista->kursor = -1;
	lista->start = 0;
	
	if ( lista->flag & GOC_LISTFLAG_EXTERNAL )
	{
		for ( j=0; j<lista->nKolumna; j++ )
		{
			k = lista->pKolumna[j];
			k->pText = NULL;
			k->nText = 0;
			lista->flag &= ~GOC_LISTFLAG_EXTERNAL;
		}
	}
	else
	{
		int i;
		for ( j=0; j<lista->nKolumna; j++ )
		{
			k = lista->pKolumna[j];
			for ( i=0; i<k->nText; i++ )
				goc_stringFree(k->pText[i]);
			k->pText = goc_tableClear(k->pText, &k->nText);
		}
	}
	return GOC_ERR_OK;
}
Ejemplo n.º 2
0
// listuj katalog i dodawaj pliki w nim zawarte, ktróre s± mp3
static void listAddFolder(const char *fullname)
{
	DIR *dir = opendir( fullname );
	struct dirent *ent;
	if ( dir == NULL )
		return;
	while ( (ent = readdir( dir )) != NULL )
	{
		char *buf = NULL;
		if ( goc_stringEquals( ent->d_name, ".." ) )
			continue;
		if ( goc_stringEquals( ent->d_name, "." ) )
			continue;
		buf = goc_stringCopy( buf, fullname );
		if ( fullname[strlen(fullname)-1] != '/' )
			buf = goc_stringAdd( buf, "/" );
		buf = goc_stringAdd( buf, ent->d_name );
		if ( goc_isFolder( buf ) )
			listAddFolder( buf );
		else
			checkAddFile( buf );
		buf = goc_stringFree( buf );
	}
	closedir( dir );
}
Ejemplo n.º 3
0
int goc_labelRemLines(GOC_HANDLER u)
{
	GOC_StLabel *napis = (GOC_StLabel*)u;
	int i;
	for ( i = 0; i<napis->nText; i++ )
		goc_stringFree(napis->tekst[i].line);
	napis->tekst = goc_tableClear(napis->tekst, &napis->nText);
	return GOC_ERR_OK;
}
Ejemplo n.º 4
0
int goc_systemFreeTimers()
{
	int i;
	for ( i=0; i<nHandler; i++ )
		pId[i] = goc_stringFree(pId[i]);
	pHandler = goc_tableClear( pHandler, &nHandler );
	nHandler = i;
	pId = goc_tableClear( pId, &nHandler);
	return GOC_ERR_OK;
}
Ejemplo n.º 5
0
int goc_labelRemLine(GOC_HANDLER u, unsigned int numer)
{
	GOC_StLabel *napis = (GOC_StLabel*)u;
	
	if ( numer < napis->nText )
  	{
		goc_stringFree(napis->tekst[numer].line);
		napis->tekst = goc_tableRemove(napis->tekst, &napis->nText, sizeof(GOC_StColorLine), numer);
	}
	return GOC_ERR_OK;
}
Ejemplo n.º 6
0
static int goc_listDestroy(GOC_HANDLER uchwyt)
{
	GOC_StList *lista = (GOC_StList*)uchwyt;
	int j;
	goc_listClear(uchwyt);
	goc_stringFree(lista->pTytul);
	for ( j=0; j<lista->nKolumna; j++ )
		free(lista->pKolumna[j]);
	lista->pKolumna = goc_tableClear(
		lista->pKolumna, &lista->nKolumna);
	return goc_elementDestroy(uchwyt);
}
Ejemplo n.º 7
0
/*
 * Wygenerowanie wnêtrza metody alloc dla podanego noda
 */
int generateAllocBody(xmlNode *child, xmlNode *method, FILE *file)
{
	char *classname = NULL;
	classname = goc_stringCopy(classname, getAttr(child, "name"));

	fprintf(file, "\tSt%s* tmp = NULL;\n", classname);
	fprintf(file, "\ttmp = malloc(sizeof(St%s));\n", classname);
	fprintf(file, "\tmemset(tmp, 0, sizeof(St%s));\n", classname);
	fprintf(file, "\treturn tmp;\n");

	classname = goc_stringFree(classname);
	return 0;
}
Ejemplo n.º 8
0
int goc_systemFreeTimer(GOC_HANDLER uchwyt)
{
	int i;
	for ( i=0; i<nHandler; i++ )
	{
		if ( pHandler[i] == uchwyt )
		{
			pHandler = goc_tableRemove(
				pHandler, &nHandler, sizeof(GOC_HANDLER), i);
			nHandler++;
			pId[i] = goc_stringFree(pId[i]);
			pId = goc_tableRemove(
				pId, &nHandler, sizeof(char *), i);
			return GOC_ERR_OK;
		}
	}
	return GOC_ERR_END;
}
Ejemplo n.º 9
0
static int hotKeySelectFolder(
	GOC_HANDLER uchwyt, GOC_MSG wiesc, void *pBuf, unsigned int nBuf)
{
	char *element = goc_stringCopy(NULL, goc_filelistGetFolder(uchwyt));
	element = goc_stringAdd(element, "/");
	element = goc_stringAdd(element, goc_listGetUnderCursor(uchwyt));
	if ( goc_isFileExists( element ) )
	{
		if ( goc_isFolder( element ) )
		{
			listAddFolder( element );
		}
		else
		{ // a wiec to plik
			checkAddFile( element );
		}
		char *tmp = goc_stringAdd(goc_stringCopy(NULL, "Dodano: "), element);
		goc_labelSetText(nStatus, tmp, 0);
		tmp = goc_stringFree(tmp);
		goc_systemSendMsg(nStatus, GOC_MSG_PAINT, 0, 0);
	}
}
Ejemplo n.º 10
0
int main(int argc, char** argv)
{
	// zak³ada siê, ¿e ramka zawiera próbkê, w której
	// jest d¼wiêk beat-u i cisza do nastêpnego beatu
	// 
	//
	// ramka
	//char *pFrame;
	// licznik
	int i;
//	goc_termInit();
	printf(GOC_STRING_WHITE);

	// Procedury inicjuj±ce
	GOC_DEBUG("Initializing libao");
	ao_initialize();

	GOC_DEBUG("Initializing libao Device");
	aodriverid = ao_default_driver_id();
	if ( aodriverid == -1 )
		return -1;
	openOutputDevice();

	params = allocParameters();

	if ( argc > 1 )
	{
		if ( interpretArgs(argc, argv, params) < 0 )
			endProgram(-1);
	}


	GOC_DEBUG("Allocating buffer");

	generateBeat(params, BEAT_BASE);
	generateBeat(params, BEAT_ACCENT);
	generateBeat(params, BEAT_INTER);
	generateBeat(params, BEAT_QUIET);

//	pFrame = malloc(nFrame);
//	memset(pFrame, 0, nFrame);
	GOC_BINFO("Tempo: %d Rate: %d Channels: %d Bits: %d",
			params->tempo, SAMPLE_RATE, SAMPLE_CHANNELS, SAMPLE_BITS);
//	GOC_BDEBUG("Allocated %d at 0x%X", nFrame, (unsigned int)pFrame);
	if ( params->flags & FLAG_PRINTCOUNT )
	{
		goc_clearscreen();
		goc_gotoxy(1,1);
	}

	printf("Playing ... \n");
	if ( params->pattern )
		printf("Use pattern: %s\n", params->pattern);
	fflush(stdout);
	{
		// to nie do koñca jest liczba ramek - to jest liczba
		// podstawowych beatów jakie maj± zostaæ zagrane - nie
		// s± liczone beat-y po¶rednie
		int nFrames;
		int imeasure = 0;
		int iinter;
		int patternPosition = 0;
		int patternLen = 0;

		char *prevString = goc_stringCopy(NULL, "");
		char playedPattern = '.';

		if ( params->pattern )
		{
			patternLen = strlen(params->pattern);
		}

		if ( params->tacts )
			// na podstawie liczby podanych taktów
			nFrames = params->tacts * params->measure;
		else
			// na podstawie podanego czasu
			nFrames = params->tempo * params->pdur / 60;

		NEXTPATTERN();

		// goc_saveXY();
		for (i=0; i<nFrames; i++)
		{
			if ( imeasure )
			{
				if ( params->flags & FLAG_PRINTCOUNT )
				{
					goc_gotoxy(1, 5);
					printf("%s%s%s%d%s", GOC_STRING_YELLOW, prevString, GOC_STRING_BWHITE, imeasure + 1, GOC_STRING_YELLOW);
					prevString = goc_stringAddInt(prevString, imeasure+1);
					prevString = goc_stringAdd(prevString, " .. ");
					fflush(stdout);
				}
				if ( playedPattern == '.' )
					ao_play(aodev, params->pBeat[BEAT_BASE].pFrame, params->pBeat[BEAT_BASE].nFrame);
				else
					ao_play(aodev, params->pBeat[BEAT_QUIET].pFrame, params->pBeat[BEAT_QUIET].nFrame);
				NEXTPATTERN();
			}
			else
			{
				if ( params->flags & FLAG_PRINTCOUNT )
				{
					goc_gotoxy(1, 5);
					printf("%s%s", GOC_STRING_YELLOW, prevString);
					goc_gotoxy(1, 5);
					printf("%s%d%s", GOC_STRING_BWHITE, imeasure + 1, GOC_STRING_YELLOW);
					prevString = goc_stringFree(prevString);
					prevString = goc_stringAddInt(prevString, imeasure+1);
					prevString = goc_stringAdd(prevString, " .. ");

					fflush(stdout);
				}
				if ( playedPattern == '.' )
					ao_play(aodev, params->pBeat[BEAT_ACCENT].pFrame, params->pBeat[BEAT_ACCENT].nFrame);
				else
					ao_play(aodev, params->pBeat[BEAT_QUIET].pFrame, params->pBeat[BEAT_QUIET].nFrame);
				NEXTPATTERN();
			}
			if ( (iinter = params->inter) )
			{
				while  ( iinter-- )
				{
					if ( params->flags & FLAG_PRINTCOUNT )
					{
						goc_gotoxy(1, 5);
						printf("%s%s%si%s", GOC_STRING_YELLOW, prevString, GOC_STRING_WHITE, GOC_STRING_YELLOW);
						prevString = goc_stringAdd(prevString, "i .. ");
						fflush(stdout);
					}
					if ( playedPattern == '.' )
						ao_play(aodev, params->pBeat[BEAT_INTER].pFrame, params->pBeat[BEAT_INTER].nFrame);
					else
						ao_play(aodev, params->pBeat[BEAT_QUIET].pFrame, params->pBeat[BEAT_QUIET].nFrame);
					NEXTPATTERN();
				}
			}
			imeasure++;
			imeasure %= params->measure;
		}
		if ( params->flags & FLAG_PRINTCOUNT )
		{
			goc_gotoxy(1, 5);
			printf("%s%s", GOC_STRING_YELLOW, prevString);
		}
		prevString = goc_stringFree(prevString);
	}
	printf("%s\nFinish\n", GOC_STRING_WHITE);

	if ( params->tacts )
	{
		GOC_BINFO("Played %d frames in %d tacts", i, params->tacts);
	}
	else
	{
		GOC_BINFO("Played %d frames in %d seconds", i, params->pdur);
	}

	endProgram(0);
	return 0;
}
Ejemplo n.º 11
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;
}
Ejemplo n.º 12
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;
}