Ported 10-menu.pl to PERL v5.10
[mirrors/libpurple-core-answerscripts.git] / answerscripts.c
index c2e4dd0acbc26aeebc3809383711b8c7022c26d8..ca1a412b9dc3c81f577871f09468185e620d95cf 100755 (executable)
@@ -17,6 +17,8 @@
 
 #ifndef __WIN32__
        #include <fcntl.h>
+#else
+       #include <windows.h>
 #endif
 
 /* Purple plugin */
@@ -30,8 +32,6 @@
 
 char *message = NULL;
 char *hook_script = NULL;
-char response[ANSWERSCRIPTS_LINE_LENGTH+1];
-int i;
 
 typedef struct {
   FILE *pipe;
@@ -39,12 +39,14 @@ typedef struct {
 } answerscripts_job;
 
 int answerscripts_process_message_cb(answerscripts_job *job) {
+       int i;
+       char response[ANSWERSCRIPTS_LINE_LENGTH+1];
        FILE *pipe = job->pipe;
        PurpleConversation *conv = job->conv;
 
        if (pipe && !feof(pipe)) {
                if(!fgets(response, ANSWERSCRIPTS_LINE_LENGTH, pipe)
-                       && (errno == EWOULDBLOCK || errno == EAGAIN)
+                       && (errno == EWOULDBLOCK || errno == EAGAIN) //WARNING! Not compatible with windows :-(
                ) return 1;
 
                for(i=0;response[i];i++) if(response[i]=='\n') response[i]=0;
@@ -100,6 +102,8 @@ static void received_im_msg_cb(PurpleAccount *account, char *who, char *buffer,
        #ifndef __WIN32__
                int fflags = fcntl(fileno(job->pipe), F_GETFL, 0);
                fcntl(fileno(job->pipe), F_SETFL, fflags | O_NONBLOCK);
+       #else
+               //WARNING! Somehow implement FILE_FLAG_OVERLAPPED & FILE_FLAG_NO_BUFFERING support on windows
        #endif
 
        purple_timeout_add(ANSWERSCRIPTS_TIMEOUT_INTERVAL, (GSourceFunc) answerscripts_process_message_cb, (gpointer) job);
This page took 0.123495 seconds and 4 git commands to generate.