Exemplo n.º 1
0
ELK_PRECONSTRUCTOR()
{
  command_insert(NULL, sectionCommand);
  command_insert("date", dateCommand);
  command_insert("time", timeCommand);
  command_insert("sleep", sleepCommand);
}
Exemplo n.º 2
0
void unix_client (int fd)
{
	GList *q = NULL;
	char temp[2048];

	memset (temp, 0, sizeof (temp));
	if (read (fd, temp, sizeof (temp)) < 0) return;

	switch (atoi (temp)) {
	case COMMAND_LIST:
		command_list (fd, g_list_first (queue), playing_mpeg);
		break;

	case COMMAND_INSERT:
	{
		int pos;
		char filename[1024];

		memset (filename, 0, sizeof (filename));
		sscanf (temp + 2, "%[^];];%d\n", filename, &pos);

		q = command_insert (fd, queue, filename,
				    pos, &playing_mpeg, unix_list_count ());
		if (q != NULL) queue = g_list_first (q);
	}
		break;

	case COMMAND_REMOVE:
	{
		int pos = 0;

		sscanf (temp + 2, "%d\n", &pos);
		q = command_remove (fd, queue, pos, &playing_mpeg);
		if (q != NULL) {
			unix_command = COMMAND_REMOVE;
			queue = g_list_first (q);
		}
	}
		break;

	case COMMAND_PLAY:
		unix_command = COMMAND_PLAY;
		break;
	
	case COMMAND_PAUSE:
		unix_command = COMMAND_PAUSE;
		break;
	
	case COMMAND_STOP:
		unix_command = COMMAND_STOP;
		break;

	case COMMAND_NEXT:
		unix_command = COMMAND_NEXT;
		break;
	
	case COMMAND_PREV:
	{
		int temp;

		if ((temp = playing_mpeg - 2) < 0) temp = unix_list_count ();
		playing_mpeg = temp;

		unix_command = COMMAND_NEXT;
	}
		break;

	case COMMAND_MUTE:
		unix_command = COMMAND_MUTE;
		break;

	default:
		dprintf (fd, "%c: Unknown command.\n%c\n",
			 COMMAND_ERROR, COMMAND_DELIM);
	}

	return;
}