#ifdef FILE
#undef FILE
#endif
#ifdef v003
#ifndef CONSOLE
#define CONSOLE
#endif
#ifndef NO_READLINE
#define NO_READLINE
#endif
#ifndef NO_SLOW
#define NO_SLOW
#endif
#endif
#ifdef d000
#ifndef b025
#define b025
#endif
#include "x032.h"
#endif 
#ifdef v035
#ifndef b025
#define b025
#endif
#endif 
#ifdef b025
#ifndef NO_READLINE
#define NO_READLINE
#endif
#ifndef CONSOLE
#define CONSOLE
#endif
#endif 
#if defined(__unix__) || defined(__linux__)
#if !defined(HAVE_UNISTD_H) && !defined(n035)
#define HAVE_UNISTD_H
#endif 
#endif 
#if defined(CONSOLE)&&defined(l049)
#undef l049
#endif
#if !defined(v003)&&(defined(WIN32)||defined(_WIN32)||defined(__WIN32)||defined (_WIN32_)||defined(__WIN32__))
#define d030 1
#define k029 0
#define s038 0
#else
#define d030 0
#define k029 1
#define s038 0
#if defined(_MACH_)
#undef s038
#define s038 1
#endif
#endif
#if (defined(__cplusplus) || defined(z000)) && !defined(__STDC__)
#define __STDC__ 1
#endif
#ifdef CONSOLE
#ifdef l049
#undef l049
#endif
#else
#define l049
#endif
#if defined(HAVE_CONFIG_H)
#include "config.h"
#if defined (HAVE_STRING_H)
#include <string.h>
#else 
#if defined(HAVE_STRINGS_H)
#include <strings.h>
#endif 
#endif 
#if defined(HAVE_STDLIB_H)
#include <stdlib.h>
#endif 
#if defined (HAVE_SYS_STAT_H)
#include <sys/stat.h>
#endif 
#if defined (HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif 
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#else 
#if d030
#define unlink _unlink
#else 
int unlink(char *); 
#endif 
#endif 
#else 
#include <string.h>
#include <stdlib.h>
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#else
#if d030
#define unlink _unlink
#else 
int unlink(char *); 
#endif 
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif 
#include <time.h>
#include "adv0.h"
#define s003
#include "adv1.h"
#define d035(X) { char *v048 = X; while (*v048) o001(*v048++); }
#ifdef l049
#if d030
#include <q056.h>
#include <z058.h>
#define v063 r047
#else 
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#define v063 close
#endif 
#endif
#if d030
#include <windows.h>
#endif 
#if !defined(NO_SLOW) && d030
#ifdef __STDC__
void y002 (int q057) 
#else
void y002 (q057) int q057; 
#endif
{ SleepEx(q057, 0); return; } 
#endif 
#if d030
#define y034 '\\'
#else
#define y034 '/'
#endif
#if !d030
#include <dirent.h>
#endif 
#include <stdio.h>
#ifdef __STDC__
int j033 (int i054, char *k040) 
#else
int j033 (i054, k040) int i054; char *k040; 
#endif
{ char s044[64]; 
#if d030
int l057 = -1; WIN32_FIND_DATA v064; HANDLE f045; 
#else 
int l057 = 0; DIR *j061; struct dirent *q058; 
#endif 
char *j062; *(s044 + 63) = '\0'; 
#if d030
if (i054 < 1 && strlen (k040) > 57) return (0); sprintf (s044, "%s\\*.adv",
"."); if ((f045 = FindFirstFile (s044, &v064)) == INVALID_HANDLE_VALUE)
#else 
if ((j061 = opendir(".")) == NULL) 
#endif 
return (0); while (1) { 
#if d030
if (l057 >= 0) { if (FindNextFile(f045, &v064) == 0) break; } else l057
= 0; strncpy(s044, v064.cFileName, 63); if (*s044 == '.' || *s044 == '_'
|| strcmp (j062 = s044 + strlen(s044) - 4, ".adv") != 0) continue; 
#else 
if ((q058 = readdir(j061)) == NULL) break; strncpy (s044, q058->d_name,
63); if ((i054 >= 0 && *s044 == '.') || strcmp (j062 = s044 + strlen(s044)
- 4, ".adv") != 0) continue; 
#endif 
*j062 = '\0'; l057++; if (i054 != 0) { if (i054 < 0) { if (i054-- != -1)
o001 ('|'); d035 (s044); } else { if (l057 > 1) d035 (i054 == l057 ? " and "
: ", ") if (a004) { o001 (i000); o001 ('b'); o001 (f000); } d035 (s044)
if (a004) { o001 (i000); o001 ('/'); o001 ('b'); o001 (f000); } } } } 
#if d030
FindClose(f045); 
#else 
closedir (j061); 
#endif 
if (l057 == 0) return (0); if (i054 > 0) d035 (".\n"); return (l057); }
#ifdef l049
int k045 = 0; int v065 = 0; int t054 = 1978; char *i055 = "20 21!22\"23#25%26&27'28(29)2A*2B+2C,2F/3A:3B;3D=3F?40@5B[5D]";
void k046 (void) { int l076 = 1; struct protoent *z059; struct sockaddr_in
q059; int z060 = 0; memset ((char *)&q059, 0, sizeof(q059)); q059.sin_family
= AF_INET; q059.sin_addr.s_addr = inet_addr("127.0.0.1"); if ((z059 = getprotobyname
("tcp")) == NULL) { fprintf (stderr, "Failed to find protocol TCP!\n");
exit (-1); } if ((k045 = socket (AF_INET, SOCK_STREAM, z059->p_proto)) <
0) { perror(""); fprintf (stderr, "Failed to create listennig socket!\n");
exit (-1); } setsockopt(k045, SOL_SOCKET, SO_REUSEADDR, (void *)&l076, sizeof(int));
while (1) { q059.sin_port = htons (t054); if (bind (k045, (struct sockaddr
*)&q059, sizeof(q059)) == 0) break; t054++; z060++; if (z060 == 100) { fprintf
(stderr,"Failed to bind listening socket!\n"); exit (-1); } } if (listen
(k045, 10) < 0) { fprintf (stderr,"Failed to set up listener!\n"); exit
(-1); } } void i003 (char *a043) { int v061; int o039 = 1024; 
#ifdef DEBUG
printf ("=== Entering %s\n", "browser_write"); 
#endif 
a043 = n003 (a043); v061 = strlen (a043); while (v061 > 0) { if (v061 <
o039) o039 = v061; send (v065, a043, o039, 0); a043 += o039; v061 -= o039;
} v063 (v065); v065 = 0; 
#ifdef DEBUG
printf ("=== Exiting %s\n", "browser_write"); 
#endif 
} int u004 (char *s057, int j063) { int o039; char k047[4096]; char *a043
= k047; char *z042; int c050 = 'N'; int q060 = ' '; int v066; struct sockaddr_in
l077; fd_set j064; struct timeval g038; int o061; 
#ifdef DEBUG
printf ("=== Entering %s\n", "browser_read"); 
#endif 
FD_ZERO(&j064); FD_SET(k045, &j064); while (1) { g038.tv_sec = j063; g038.tv_usec
= 0; o061 = select (FD_SETSIZE, &j064, (fd_set *) 0, (fd_set *) 0, &g038);
if (!o061) { fprintf (stderr, "*** No response from browser! ***\n"); exit
(1); } v066 = sizeof(l077); if (v065) { v063 (v065); v065 = 0; } if ((v065
= accept (k045, (struct sockaddr *)&l077, (socklen_t *)&v066)) < 0) { fprintf(stderr,
"Failed to accept incoming call!\n"); exit (-1); } a043 = k047; while (1)
{ o039 = recv (v065, a043, sizeof(k047) - 1, 0); *(a043 + o039) = '\0';
z042 = a043 + 1; q060 = *a043; a043 += o039; while (z042 < a043) { if (q060
== '\n' && *z042 == '\n') { o039 = 0; break; } if (*z042 != '\r') q060 =
*z042; z042++; } if (o039 == 0) break; } if (strstr (k047, "IE 5.0")) {
fprintf (stderr, "*ERROR* Sorry, this setup does not work with IE 5.0.\n");
exit (1); } if (strncmp (k047, "GET", 3) != 0) { v063 (v065); continue;
} if ((a043 = strstr (k047, "status=")) != NULL) { z042 = a043 + 7; if (*z042
== '0' && *(z042 + 1) == 'x') { z042 += 2; if (*z042 == 'R' || *z042 ==
'S') c050 = *z042; else { o003 (); continue; } } else { while (*z042 >=
'0' && *z042 <= '9') z042++; z042++; } } if (strstr (k047, "favicon") !=
NULL) { send (v065, "HTTP/1.0 404 Not found\nContent-Length: 0\n\n", 42,
0); v063 (v065); continue; } break; } if (s057) { a043 = s057; while (*z042
!= ' ' && *z042 != '\n') { if (*z042 == '%') { char *c058 = i055; while
(*c058) { if (*c058 == *(z042 + 1) && *(c058 + 1) == *(z042 + 2)) { *a043++
= *(c058 + 2); z042 += 3; break; } c058 += 3; } if (*c058) continue; } *a043++
= *z042; z042++; } *a043++ = '\n'; *a043 = '\0'; } 
#ifdef DEBUG
printf ("=== Exiting %s: '%s'\n", "browser_read", s057); 
#endif 
return (c050); } void x004 (char *x049, int g038) { char g054 [256]; int
u052 = 0; int tm = time(NULL) % 10000; 
#if d030
y056 d052; l078 o062; o063 g055; w061(0y057, &g055); 
#endif 
#ifdef DEBUG
printf ("=== Entering %s\n", "invoke_browser"); 
#endif 
k046 (); 
#if d030
sprintf (g054, "%s http://localhost:%d/%d/", x049, t054, tm); y058( &d052,
sizeof(d052) ); d052.g056 = sizeof(d052); y058( &o062, sizeof(o062) ); if
(!k048(NULL, g054, NULL, NULL, 0, 0, NULL, NULL, &d052, &o062)) { printf
("*ERROR* Failed to kick off '%s'!\n", g054); exit (-1); } 
#else 
if (isatty (1)) fputs ("Invoking browser...\n", stderr); if (fork () ==
0) { int w062; v063 (k045); k045 = 0; sprintf (g054, "http://localhost:%d/%d/",
t054, tm); fflush(stdout); close (0); close (1); w062 = dup(2); close(2);
execl (x049, x049, g054, (char *)NULL); dup(w062); dup (w062); printf ("*ERROR* Failed to exec %s!\n",
x049); exit (1); } 
#if !defined(DEBUG) && !defined(b051)
if (getppid() != 1) { int i; if (isatty (1)) fputs ("Daemonising game server...\n",
stderr); if (fork() > 0) exit (0); setsid (); close (0); close (1); close
(2); i = open ("/dev/null", O_RDWR); dup (i); dup (i); } 
#endif 
#endif 
u052 = u004 (NULL, g038); if (u052 != 'R') { if (u052 == 'N') w006(); while
((u052 = u004 (NULL, g038)) == 'N') o003(); } 
#ifdef DEBUG
printf ("=== Exiting %s\n", "invoke_browser"); 
#endif 
} 
#endif 

