2 * (C) Copyright 2009 ZeXx86 (zexx86@gmail.com)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Based on GLugin http://exa.czweb.org/repos/glugin.tar.bz2
19 * Big thanks for "exa"
29 void guest_read_host_requests (pluginData
*pd
)
34 if (fread (&cmd
, sizeof (int), 1, pd
->pr
) <= 0)
39 fread (&s
, sizeof (s
), 1, pd
->pr
);
41 pd
->handle_newstream (pd
,s
);
43 case gln_destroy_stream
:
44 fread (&s
, sizeof (s
), 1, pd
->pr
);
46 pd
->handle_destroystream (pd
, s
);
53 fread (&s
, sizeof (s
), 1, pd
->pr
);
54 fread (&off
, sizeof (off
), 1, pd
->pr
);
55 fread (&len
, sizeof (len
), 1, pd
->pr
);
60 fread (data
,len
,1,pd
->pr
);
62 pd
->handle_write (pd
, s
, off
, len
, data
);
70 Log ("Unhandled request to guest: %d", cmd
);
74 void guest_newstream (pluginData
*pd
, NPStream
*s
)
76 Log ("guest has NEWSTREAM: %p",s
);
79 void guest_destroystream (pluginData
*pd
, NPStream
*s
)
81 Log ("guest has DESTROYSTREAM: %p",s
);
84 void guest_write (pluginData
*pd
, NPStream
*s
, int32 off
, int32 len
, void *data
)
86 Log ("guest has WRITE: %p %d %d, data followz:", s
, off
, len
);
89 for (i
= 0; i
< len
; ++ i
)
90 Log ("%8X: %c",i
, ((char *) data
)[i
]);
93 void glugin_proc (pluginData
*pd
)
95 while (!(pd
->exit_request
)) {
96 guest_read_host_requests (pd
);