Esempio n. 1
0
/* Print out the information log for a program object */
static void
printProgramInfoLog (GLuint program)
{
	GLint     infologLength = 0;
	GLint     charsWritten  = 0;
	char *infoLog;

	printOpenGLError ();  // Check for OpenGL errors
	glGetProgramiv (program, GL_INFO_LOG_LENGTH, &infologLength);
	printOpenGLError ();  // Check for OpenGL errors

	if (infologLength > 0)
    {
		infoLog = new char [infologLength];
		if (infoLog == NULL)
        {
			debugOut( "ERROR: Could not allocate InfoLog buffer");
			return;
        }
		glGetProgramInfoLog (program, infologLength, &charsWritten, infoLog);
		debugOut( "Program InfoLog:\n%s\n\n", infoLog);
		delete[] infoLog;
    }
	printOpenGLError ();  // Check for OpenGL errors
}
Esempio n. 2
0
void playMovieStream (int a) {
	if (! soundOK) return;
	ALboolean ok;
	ALuint src;
	
	alGenSources(1, &src);
	if(alGetError() != AL_NO_ERROR)
	{
		debugOut( "Failed to create OpenAL source!\n");
		return;
	}
	
	alSourcef (src, AL_GAIN, (float) soundCache[a].vol / 256);
	
	ok = alurePlaySourceStream(src, soundCache[a].stream,
								   10, 0, sound_eos_callback, &intpointers[a]);
	
	if(!ok) {
		debugOut("Failed to play stream: %s\n", alureGetErrorString());
		alDeleteSources(1, &src);
		if(alGetError() != AL_NO_ERROR)
		{
			debugOut("Failed to delete OpenAL source!\n");
		}
		soundCache[a].playingOnSource = 0;
	} else {
		soundCache[a].playingOnSource = src;
		soundCache[a].playing = true;
	}
}
Esempio n. 3
0
bool initSoundStuff (HWND hwnd) {

	if(!alureInitDevice(NULL, NULL))
	{
		debugOut( "Failed to open OpenAL device: %s\n",
				alureGetErrorString());
		return 1;
	}

	int a;
	for (a = 0; a < MAX_SAMPLES; a ++) {
		soundCache[a].stream = NULL;
		soundCache[a].playing = false;
		soundCache[a].fileLoaded = -1;
		soundCache[a].looping = false;
		intpointers[a] = a;
	}

	for (a = 0; a < MAX_MODS; a ++) {
		modCache[a].stream = NULL;
		modCache[a].playing = false;
	}

	if (! alureUpdateInterval(0.01))
	{
		debugOut("Failed to set Alure update interval: %s\n",
				alureGetErrorString());
		return 1;
	}
	return soundOK = true;
}
Esempio n. 4
0
int buildShaders (const char *vertexShader, const char *fragmentShader)
{
	GLuint VS, FS, prog;
	GLint vertCompiled, fragCompiled;
	GLint linked;

	// Create Shader Objects
	VS = glCreateShader(GL_VERTEX_SHADER);
	FS = glCreateShader(GL_FRAGMENT_SHADER);

	// Load source code strings into shaders
	glShaderSource(VS, 1, &vertexShader, NULL);
	glShaderSource(FS, 1, &fragmentShader, NULL);

	debugOut("Compiling vertex shader... \n");

	// Compile vertex shader and print log
	glCompileShader(VS);
	printOpenGLError();
	glGetShaderiv(VS, GL_COMPILE_STATUS, &vertCompiled);
	printShaderInfoLog (VS);

	debugOut("\nCompiling fragment shader... \n");

	// Compile fragment shader and print log
	glCompileShader(FS);
	printOpenGLError();
	glGetShaderiv(FS, GL_COMPILE_STATUS, &fragCompiled);
	printShaderInfoLog (FS);

	if (!vertCompiled || !fragCompiled)
		return 0;

	debugOut( "\nShaders compiled. \n");


	// Create a program object and attach the two compiled shaders
	prog = glCreateProgram();
	glAttachShader(prog, VS);
	glAttachShader(prog, FS);

	// Clean up
	glDeleteShader (VS);
	glDeleteShader (FS);

	// Link the program and print log
	glLinkProgram(prog);
	printOpenGLError();
	glGetProgramiv(prog, GL_LINK_STATUS, &linked);
	printProgramInfoLog(prog);

	if (!linked)
		return 0;

	debugOut("Shader program linked. \n");

	return prog;
}
Esempio n. 5
0
void changeToUserDir () {
	if (chdir (getenv ("HOME"))) {
		debugOut("Error: Failed changing to directory %s\n", getenv ("HOME"));
	}
	mkdir (".sludge-engine", 0000777);
	if (chdir (".sludge-engine")) {
		debugOut("Error: Failed changing to directory %s\n", ".sludge-engine");
	}
}
Esempio n. 6
0
int mainLoop()
{
	MSG msg;
	HACCEL hAccel;
	bool screenSaver = isScreenSaver();
//	DWORD startTickCount = GetTickCount();

	hAccel = LoadAccelerators(CUIWindow::getLanguageModule(),
		MAKEINTRESOURCE(IDR_ACCELERATORS));
	while (1)
	{
		HWND parentWindow;
		HWND topParent;
		HWND newParent;
		DWORD tickCount = GetTickCount();

		debugOut("%d\n", tickCount);
/*
		if (tickCount > startTickCount + 3000 || tickCount < startTickCount)
		{
			OleUninitialize();
			return 0;
		}
*/
		if (!GetMessage(&msg, NULL, 0, 0))
		{
			OleUninitialize();
			return (int)msg.wParam;
		}
#ifdef _DEBUG
//			_CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "hWnd: 0x%6X msg: 0x%X\n", msg.hwnd, msg.message);
#endif // _DEBUG
		parentWindow = GetParent(msg.hwnd);
		topParent = msg.hwnd;
		while ((newParent = GetParent(topParent)) != NULL)
		{
			topParent = newParent;
		}
		if (screenSaver || !TranslateAccelerator( 
		    topParent,     // handle to receiving window 
			hAccel,        // handle to active accelerator table 
			&msg))
		{
			if (!parentWindow || !IsDialogMessage(parentWindow, &msg))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
				if (screenSaver && msg.message == WM_DESTROY)
				{
					debugOut("WM_DESTROY\n", tickCount);
					PostQuitMessage(0);
				}
			}
		}
		TCAutoreleasePool::processReleases();
	}
}
Esempio n. 7
0
void playStream (int a, bool isMOD, bool loopy) {
	if (! soundOK) return;
	ALboolean ok;
	ALuint src;
	soundThing *st;
	void (*eos_callback)(void *userdata, ALuint source);

	if (isMOD) {
		st = &modCache[a];
		eos_callback = mod_eos_callback;
	}
	else {
		st = &soundCache[a];
		eos_callback = sound_eos_callback;
	}

	alGenSources(1, &src);
	if(alGetError() != AL_NO_ERROR)
	{
		debugOut( "Failed to create OpenAL source!\n");
		return;
	}

	if (isMOD) {
		alSourcef (src, AL_GAIN, (float) modLoudness * defVol / 256);
	} else {
		alSourcef (src, AL_GAIN, (float) soundCache[a].vol / 256);
	}

	if (loopy) {
		ok = alurePlaySourceStream(src, (*st).stream,
				NUM_BUFS, -1, eos_callback, &intpointers[a]);
	} else {
		ok = alurePlaySourceStream(src, (*st).stream,
				NUM_BUFS, 0, eos_callback, &intpointers[a]);
	}

	if(!ok) {
		debugOut("Failed to play stream: %s\n", alureGetErrorString());
		alDeleteSources(1, &src);
		if(alGetError() != AL_NO_ERROR)
		{
			debugOut("Failed to delete OpenAL source!\n");
		}
		(*st).playingOnSource = 0;
	} else {
		(*st).playingOnSource = src;
		(*st).playing = true;
	}
}
Esempio n. 8
0
bool SSPassword::verifyPassword(HWND hWindow)
{
	debugOut("SSPassword::verifyPassword\n");
	if (runningOnNT)
	{
		return true;
	}
	else if (verifyPasswordProc)
	{
		if (!checkingPassword)
		{
			DWORD curTime = GetTickCount();

			debugOut("SSPassword::verifyPassword %d %d %d\n", lastCheckTime,
				curTime, curTime - lastCheckTime);
			if (curTime - lastCheckTime < 200 && curTime >= lastCheckTime)
			{
//				lastCheckTime = curTime;
				return false;
			}
			debugOut("SSPassword::verifyPassword checking...\n");
			lastCheckTime = curTime;
			checkingPassword = true;
			ShowCursor(TRUE);
			if (verifyPasswordProc(hWindow))
			{
				ShowCursor(FALSE);
				checkingPassword = false;
				return true;
			}
			else
			{
				ShowCursor(FALSE);
				checkingPassword = false;
				lastCheckTime = GetTickCount();
				debugOut("SSPassword::verifyPassword failed\n");
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	else
	{
		return true;
	}
}
Esempio n. 9
0
void playSoundList(soundList *s) {
	if (soundOK) {

		cacheLoopySound = true;
		int a = cacheSound (s->sound);
		if (a == -1) {
			debugOut("Failed to cache sound!\n");
			return;
		}
		soundCache[a].looping = false;
		if (s->vol < 0)
			soundCache[a].vol = defSoundVol;
		else
			soundCache[a].vol = s->vol;
		s-> cacheIndex = a;

		ALboolean ok;
		ALuint src;
		soundThing *st;

		st = &soundCache[a];

		alGenSources(1, &src);
		if(alGetError() != AL_NO_ERROR)
		{
			debugOut("Failed to create OpenAL source!\n");
			return;
		}

		alSourcef (src, AL_GAIN, (float) soundCache[a].vol / 256);

		ok = alurePlaySourceStream(src, (*st).stream,
									   NUM_BUFS, 0, list_eos_callback, s);

		if(!ok) {
			debugOut("Failed to play stream: %s\n", alureGetErrorString());
			alDeleteSources(1, &src);
			if(alGetError() != AL_NO_ERROR)
			{
				debugOut("Failed to delete OpenAL source!\n");
			}
			(*st).playingOnSource = 0;
		} else {
			(*st).playingOnSource = src;
			(*st).playing = true;
		}
	}
}
Esempio n. 10
0
bool playMOD (int f, int a, int fromTrack) {
	if (soundOK) {

		stopMOD (a);

		setResourceForFatal (f);
		uint32_t length = openFileFromNum (f);
		if (length == 0) return NULL;

		char * memImage;
		memImage = loadEntireFileToMemory (bigDataFile, length);
		if (! memImage) return fatal (ERROR_MUSIC_MEMORY_LOW);

		mod[a] = BASS_MusicLoad (true, memImage, 0, length, BASS_MUSIC_LOOP|BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/, 0);
		delete memImage;

		if (! mod[a]) {

		}
		else
		{
			setMusicVolume (a, defVol);

			if (! BASS_ChannelPlay (mod[a], true) )
				debugOut("playMOD: Error %d!\n", BASS_ErrorGetCode());

			BASS_ChannelSetPosition (mod[a], MAKELONG(fromTrack, 0), BASS_POS_MUSIC_ORDER);
			BASS_ChannelFlags(mod[a], BASS_SAMPLE_LOOP|BASS_MUSIC_RAMP, BASS_SAMPLE_LOOP|BASS_MUSIC_RAMP);
		}
		setResourceForFatal (-1);
	}
    return true;
}
Esempio n. 11
0
int doPreview(HINSTANCE hInstance, LPSTR lpCmdLine)
{
	char *spot = strchr(lpCmdLine, ' ');

	debugOut("Command line: %s\n", lpCmdLine);
	if (spot)
	{
		HWND hParentWindow;

		spot++;
		if (sscanf(spot, "%d", &hParentWindow) == 1)
		{
			SSPreview* ssPreview = new SSPreview(hParentWindow, hInstance);

			if (ssPreview->run())
			{
				return 0;
			}
			else
			{
				return 1;
			}
		}
	}
	return 1;
}
Esempio n. 12
0
static void mod_eos_callback(void *cacheIndex, ALuint source)
{
	int *a = (int*)cacheIndex;
	alDeleteSources(1, &source);
	if(alGetError() != AL_NO_ERROR)
	{
		debugOut("Failed to delete OpenAL source!\n");
	}
	modCache[*a].playingOnSource = 0;
	if (! alureDestroyStream(modCache[*a].stream, 0, NULL)) {
		debugOut("Failed to destroy stream: %s\n",
				alureGetErrorString());
	}
	modCache[*a].stream = NULL;
	modCache[*a].playing = false;
}
Esempio n. 13
0
void showLastBytes( LPSTR info, uint32_t prevVal, uint32_t crrVal, uint16_t i, uint8_t * pData, uint32_t dwLen)
{
    int j=i-20;
    int k,len;
    char bufftmp[3], buff[3*20+1];

    if ( j<0 ) j=0;
    if ( (uint32_t)j+20 >= dwLen )
    {
        len = dwLen-j-1;
    }
    else
    {
        len = 20;
    }
    buff[0]=0;
    for ( k=0; k<len; k++ )
    {
        sprintf(bufftmp, "%.2X ", pData[j+k]);
        strcat(buff, bufftmp);
    }

    debugOut(dbError, "%s: crr(%.8d) != prev(%.8d)+1: %s",
        info,
        crrVal,
        prevVal,
        buff
        );
}
Esempio n. 14
0
// Put a message into the queue---called from another thread
void 
NodeQueueNoFlip::push(Message * m)
{
    Poco::ScopedLock<Poco::Mutex> l(_queueLock);
    debugOut("Push: %s, queue %lu\n", _name.c_str(), _queue.size());
    _queue.push_back(m);
}    
Esempio n. 15
0
static void list_eos_callback(void *list, ALuint source)
{
	soundList *s = (soundList *) list;

	int a = s->cacheIndex;
	alDeleteSources(1, &source);
	if(alGetError() != AL_NO_ERROR)
	{
		debugOut( "Failed to delete OpenAL source!\n");
	}
	soundCache[a].playingOnSource = 0;
	soundCache[a].playing = false;
	soundCache[a].looping = false;
	s-> cacheIndex = false;
	if (SilenceIKillYou) {
		while (s = deleteSoundFromList(s));
	} else {
		if (s->next) {
			if (s->next == s) {
				int v = defSoundVol;
				defSoundVol = soundCache[a].vol;
				startSound (s->sound, true);
				defSoundVol = v;
				while (s = deleteSoundFromList(s));
				return;
			}
			s->next->vol = soundCache[a].vol;
			playSoundList(s->next);
		} else {
			while (s = deleteSoundFromList(s));
		}
	}
}
Esempio n. 16
0
int initMovieSound(int f, ALenum format, int audioChannels, ALuint samplerate, 
				   ALuint (*callback)(void *userdata, ALubyte *data, ALuint bytes)) {
	if (! soundOK) return 0;

	int retval;
	int a = findEmptySoundSlot ();
	freeSound (a);
	
	soundCache[a].looping = false;
	// audioChannel * sampleRate gives us a buffer of half a second. Not much, but it should be enough.
	soundCache[a].stream = alureCreateStreamFromCallback(
					 callback,
					 &intpointers[a], format, samplerate,
					 audioChannels*samplerate, 0, NULL);
	
	if (soundCache[a].stream != NULL) {
		soundCache[a].fileLoaded = f;
		soundCache[a].vol = defSoundVol;
		retval = a;
	} else {
		debugOut("Failed to create stream from sound: %s\n",
				 alureGetErrorString());
		warning (ERROR_SOUND_ODDNESS);
		soundCache[a].stream = NULL;
		soundCache[a].playing = false;
		soundCache[a].playingOnSource = 0;
		soundCache[a].fileLoaded = -1;
		retval = -1;
	}
	//fprintf (stderr, "Stream %d created. Sample rate: %d Channels: %d\n", retval, samplerate, audioChannels);
	
	return retval;
}
Esempio n. 17
0
void checkDownStream( LPbtLink pLink, uint8_t * pData, uint32_t dwLen)
{
    uint16_t i;
    BOOL  b=FALSE;

    for ( i=0; i<dwLen; i++ )
    {
        if ( pData[i] == 0x0D )
        {
            continue;
        }

        else if ( pData[i] == 0x0A )
        {
            if ( pLink->DDcrrVal != (pLink->DDprevVal+1) )
            {
                showLastBytes( "DD", pLink->DDprevVal, pLink->DDcrrVal, i, pData, dwLen);
                b = TRUE;
            }
            pLink->DDprevVal = pLink->DDcrrVal;
            pLink->DDcrrVal  = 0;
            continue;
        }
        else
        {
            pLink->DDcrrVal *= 10;
            pLink->DDcrrVal += (pData[i] - 0x30);
        }
    }

    if ( b ) {
        debugOut( dbError, "!DD: %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X",
            pData[0],
            pData[1],
            pData[2],
            pData[3],
            pData[4],
            pData[5],
            pData[6],
            pData[7],
            pData[8],
            pData[9],
            pData[10]
            );
        debugOut( dbError, "!-----------------------");
    }
}
Esempio n. 18
0
// Pop node from the queue
PoolNode *
SimpleWorkQueue::pop()
{
    _event.wait();
    Poco::ScopedLock<Poco::Mutex> l(_queueLock);
    debugOut("%ld: Pop SimpleWorkQueue %lu\n", syscall(186), _queue.size());
    while (_queue.size() == 0) {
	_queueNonEmpty.wait(_queueLock);
    }
    debugOut("%ld: Pop SimpleWorkQueue before assert %lu\n", syscall(186), _queue.size());
    PoolNode * n = _queue.top();
    n->setIdle(false);
    debugOut("%ld: Popped from SimpleWorkQueue %p %lu\n", syscall(186), n, n->getQueueSize());
    assert(n->getQueueSize() > 0);
    _queue.pop();
    _inQueue.erase(n);
    return n;
}    
Esempio n. 19
0
static int pgeTextureLoadPngFile(const char* filename, pgeTexture* texture)
{
	png_structp png_ptr;

	int fd;
		
	fd = sceIoOpen(filename, PSP_O_RDONLY, 0777);
	
	if(fd < 0)
	{
		debugOut("7\n");
		return 0;
	}
		
	unsigned char sig[4];
	
	sceIoRead(fd, &sig, 4);
	
	sceIoLseek(fd, 0, PSP_SEEK_SET);
	
	if(png_sig_cmp(sig, 0, 4))
	{
		debugOut("8\n");
		return 0;
	}

	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

	if(png_ptr == NULL)
	{
		debugOut("9\n");
		sceIoClose(fd);
		
		return 0;
	}

	png_set_read_fn(png_ptr, &fd, (png_rw_ptr)pgeTextureReadPngFile);

	int result = pgeTextureLoadPngInternal(png_ptr, texture);

	sceIoClose(fd);

	return result;
}
Esempio n. 20
0
void stopMOD (int i) {
	if (! soundOK) return;
	alGetError();
	if (modCache[i].playing) {
		if (! alureStopSource(modCache[i].playingOnSource, AL_TRUE)) {
			debugOut("Failed to stop source: %s\n",
						alureGetErrorString());
		}
	}
}
Esempio n. 21
0
void setMusicVolume (int a, int v) {
	int ret;
	if (soundOK && mod[a])
	{
		ret = BASS_ChannelSetAttribute (mod[a], BASS_ATTRIB_VOL, (float) v / 255);
		if (! ret) {
			debugOut("setMusicVolume: Error %d\n", BASS_ErrorGetCode());
		}
	}
}
GVariant* AbstractDBusInterface::getProperty(GDBusConnection* connection, const gchar* sender, const gchar* objectPath, const gchar* interfaceName, const gchar* propertyName, GError** error, gpointer userData)
{
	*error = NULL;
	if(interfaceMap.count(interfaceName))
	{
		GVariant* value = interfaceMap[interfaceName]->getProperty(propertyName);
		return value;
	}
	debugOut("No interface for" + string(interfaceName));
	return nullptr;
}
Esempio n. 23
0
static void sound_eos_callback(void *cacheIndex, ALuint source)
{
	int *a = (int*)cacheIndex;
	alDeleteSources(1, &source);
	if(alGetError() != AL_NO_ERROR)
	{
		debugOut("Failed to delete OpenAL source!\n");
	}
	soundCache[*a].playingOnSource = 0;
	soundCache[*a].playing = false;
	soundCache[*a].looping = false;
}
Esempio n. 24
0
int popTokFile(void) {
    assert(currTokF >= 0);
    wicFclose(TOK_FILE);
    if (currTokF == 0) {
        g_currFileName = NULL;
        return 0;
    } else {
        debugOut("Pop  file: %s\n", TOK_FILE_NAME);
        restoreTokFile();
        return 1;
    }
}
Esempio n. 25
0
bool playMOD (int f, int a, int fromTrack) {
	if (! soundOK) return true;
	stopMOD (a);

	setResourceForFatal (f);
	uint32_t length = openFileFromNum (f);
	if (length == 0) {
		finishAccess();
		setResourceForFatal (-1);
		return false;
	}

	unsigned char * memImage;
	memImage = (unsigned char *) loadEntireFileToMemory (bigDataFile, length);
	if (! memImage) return fatal (ERROR_MUSIC_MEMORY_LOW);

	modCache[a].stream = alureCreateStreamFromMemory(memImage, length, 19200, 0, NULL);
	delete memImage;

	if (modCache[a].stream != NULL) {
		setMusicVolume (a, defVol);
		if (! alureSetStreamOrder (modCache[a].stream, fromTrack)) {
			debugOut( "Failed to set stream order: %s\n",
						alureGetErrorString());
		}

		playStream (a, true, true);

	} else {
		debugOut("Failed to create stream from MOD: %s\n",
						alureGetErrorString());
		warning (ERROR_MUSIC_ODDNESS);
		soundCache[a].stream = NULL;
		soundCache[a].playing = false;
		soundCache[a].playingOnSource = 0;
	}
	setResourceForFatal (-1);

	return true;
}
Esempio n. 26
0
void killSoundStuff () {
	if (! soundOK) return;

	SilenceIKillYou = true;
	for (int i = 0; i < MAX_SAMPLES; i ++) {
		if (soundCache[i].playing) {
			if (! alureStopSource(soundCache[i].playingOnSource, AL_TRUE)) {
				debugOut( "Failed to stop source: %s\n",
							alureGetErrorString());
			}
		}

		if (soundCache[i].stream != NULL) {
			if (! alureDestroyStream(soundCache[i].stream, 0, NULL)) {
				debugOut("Failed to destroy stream: %s\n",
							alureGetErrorString());
			}
		}
	}

	for (int i = 0; i < MAX_MODS; i ++) {
		if (modCache[i].playing) {
			if (! alureStopSource(modCache[i].playingOnSource, AL_TRUE)) {
				debugOut( "Failed to stop source: %s\n",
							alureGetErrorString());
			}
		}

		if (modCache[i].stream != NULL) {
			if (! alureDestroyStream(modCache[i].stream, 0, NULL)) {
				debugOut("Failed to destroy stream: %s\n",
							alureGetErrorString());
			}
		}
	}

	SilenceIKillYou = false;

	alureShutdownDevice();
}
Esempio n. 27
0
void freeSound (int a) {
	if (! soundOK) return;
	// Clear OpenAL errors to make sure they don't block anything:
	alGetError();

	SilenceIKillYou = true;

	if (soundCache[a].playing) {
		if (! alureStopSource(soundCache[a].playingOnSource, AL_TRUE)) {
			debugOut( "Failed to stop source: %s\n",
						alureGetErrorString());
		}
	}
	if (! alureDestroyStream(soundCache[a].stream, 0, NULL)) {
		debugOut("Failed to destroy stream: %s\n",
					alureGetErrorString());
	}
	soundCache[a].stream = NULL;
	soundCache[a].fileLoaded = -1;

	SilenceIKillYou = false;
}
Esempio n. 28
0
char * loadEntireFileToMemory (FILE * inputFile, uint32_t size) {
	char * allData = new char[size];
	if (! allData) return NULL;

	size_t bytes_read = fread (allData, size, 1, inputFile);
	if (bytes_read != size && ferror (inputFile)) {
		debugOut("Reading error in loadEntireFileToMemory.\n");
	}

	finishAccess ();

	return allData;
}
Esempio n. 29
0
uint32_t launch(char * filename) {
	debugOut("Trying to launch: %s\n", filename);

	if (!fileExists("/usr/bin/xdg-open")) {
		debugOut("Launching failed due to missing /usr/bin/xdg-open.\n");
		return 0;
	}

	if (  !(filename[0] == 'h' &&
		filename[1] == 't' &&
		filename[2] == 't' &&
		filename[3] == 'p' &&
		(filename[4] == ':' || (filename[4] == 's' && filename[5] == ':'))) &&
		!fileExists(filename)) {
		return 0;
	}

	int status;

	pid_t pid = fork();
	if (pid < 0) {
		return 0;
	}
	else if (pid == 0) {
		execl("/usr/bin/xdg-open", "xdg-open", filename, (char *)0);
		exit(EXIT_FAILURE);
	}
	else {
		waitpid(pid, &status, 0);
	}

	if (status == EXIT_SUCCESS) {
		return 69;
	}
	else {
		return 0;
	}
}
Esempio n. 30
0
Message *
NodeQueueNoFlip::pop()
{
    // get the message
    Poco::ScopedLock<Poco::Mutex> l(_queueLock);
    if (_queue.empty()) {
	return NULL;
    }
    debugOut("Pop: queue %lu\n", _queue.size());
    //fprintf(stderr, "Pop: queue %p %lu %d\n", this, _queue.size(), _queue.empty());
    Message * m = _queue.front();
    _queue.pop_front();
    return m;
}