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
26 #include <sys/types.h>
27 #include <sys/socket.h>
31 int plugin_action_0 (pluginData
*pd
)
35 return creat ("/tmp/.arenalivep", 0777);
39 int plugin_action_1 (pluginData
*pd
)
42 struct sockaddr_un local
, remote
;
44 if ((s
= socket (AF_UNIX
, SOCK_STREAM
, 0)) == -1) {
49 local
.sun_family
= AF_UNIX
;
50 strcpy (local
.sun_path
, "/tmp/.arenalive");
51 unlink (local
.sun_path
);
53 l
= strlen (local
.sun_path
) + sizeof (local
.sun_family
);
55 if (bind (s
, (struct sockaddr
*) &local
, l
) == -1) {
60 if (listen (s
, 5) == -1)
65 pid_t child
= fork ();
71 char *user
= getenv ("USER");
77 sprintf (cmd
, "/home/%s/.arenalive/%s %s &> /home/%s/.arenalive/log",
78 user
, "arenalive-linux", pd
->conparam
, user
);
84 /*system ("/home/tomas/Programming/arenalive/ioquake3_1.34-rc3/build/release-linux-x86_64/ioquake3.x86_64 +set fs_basepath \"/usr/share/games/quake3/\" +set r_fullscreen 0 +set r_mode 4 &> /home/tomas/glugin/log");*/
89 if ((s2
= accept (s
, (struct sockaddr
*) &remote
, (unsigned *) &t
)) == -1) {
94 char str
[sizeof (Window
)+1];
96 memcpy (str
, &pd
->win
, sizeof (Window
));
98 if (send (s2
, str
, sizeof (Window
), 0) < 0)
109 int plugin_action (pluginData
*pd
)
111 switch (pd
->action
) {
113 return plugin_action_0 (pd
);
115 return plugin_action_1 (pd
);