Merge from dev-FireflyShell branch

This commit is contained in:
Ron Pedde
2006-05-29 09:14:04 +00:00
parent 0a14704fd9
commit 7f08580a24
37 changed files with 3698 additions and 0 deletions

View File

@@ -11,6 +11,9 @@ void plugin_handler(int, int, void *, int);
#define PIPE_BUFFER_SIZE 4096
#define USE_UDP 0
#define USE_MAILSLOT 1
/* Globals */
PLUGIN_EVENT_FN _pefn = { plugin_handler };
PLUGIN_INPUT_FN *_ppi;
@@ -40,6 +43,7 @@ PLUGIN_INFO *plugin_info(PLUGIN_INPUT_FN *ppi) {
return &_pi;
}
#if USE_UDP
/** NO LOG IN HERE! We'll go into an endless loop. :) */
void plugin_handler(int event_id, int intval, void *vp, int len) {
int total_len = 3 * sizeof(int) + len + 1;
@@ -76,3 +80,44 @@ void plugin_handler(int event_id, int intval, void *vp, int len) {
free(pmsg);
return;
}
#endif /* USE_UDP */
#if USE_MAILSLOT
#define MAILSLOT_NAME "\\\\.\\mailslot\\FireflyMediaServer--67A72768-4154-417e-BFA0-FA9B50C342DE"
/** NO LOG IN HERE! We'll go into an endless loop. :) */
void plugin_handler(int event_id, int intval, void *vp, int len) {
HANDLE h = CreateFile(MAILSLOT_NAME, GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (h != INVALID_HANDLE_VALUE)
{
DWORD bytes_written;
const int packet_size = 12 + len;
unsigned char *buffer = (unsigned char *)malloc(packet_size);
if(!buffer)
return;
memset(buffer, 0, packet_size);
buffer[0] = packet_size & 0xff;
buffer[1] = (packet_size >> 8) & 0xff;
buffer[2] = (packet_size >> 16) & 0xff;
buffer[3] = (packet_size >> 24) & 0xff;
buffer[4] = event_id & 0xff;
buffer[5] = (event_id >> 8) & 0xff;
buffer[6] = (event_id >> 16) & 0xff;
buffer[7] = (event_id >> 24) & 0xff;
buffer[8] = intval & 0xff;
buffer[9] = (intval >> 8) & 0xff;
buffer[10] = (intval >> 16) & 0xff;
buffer[11] = (intval >> 24) & 0xff;
memcpy(buffer + 12, vp, len);
/* If this fails then there's nothing we can do about it anyway. */
WriteFile(h, buffer, packet_size, &bytes_written, NULL);
CloseHandle(h);
}
}
#endif /* USE_MAILSLOT */