-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+ X fprintf (options, "# gamename\n"); X fprintf (options, "# You not must put a blank line after gamename\n V"); X fprintf (options, "# `5Brepeat above for as many games as you like` V5D\n"); X fprintf (options, "# A '#' indicates the end of the data\n"); X fclose (options); X `7D X`0C X else X `7B X gamename`5B0`5D = 0; X if (argc == 2) while (ustrcmp(argv`5B1`5D,gamename) != 0) X `7B X fgets (hm,256,options); X hm`5Bstrlen(hm)-1`5D = 0; X if (hm`5B0`5D == '#') X `7B X printf ("\nNo games found"); X printf ("\nPrompting for all info"); X strcpy (hm,"*"); X strcpy (portname,"*"); X strcpy (countryname,"*"); X strcpy (password,"*"); X strcpy (gamename,argv`5B1`5D); X `7D X else X `7B X fgets (portname,6,options); X portname`5Bstrlen(portname)-1`5D = 0; X fgets (countryname,20,options); X countryname`5Bstrlen(countryname)-1`5D = 0; X fgets (password,20,options); X password`5Bstrlen(password)-1`5D = 0; X trash = fgets (gamename,80,options); X if (trash == NULL) X `7B X printf ("\nWarning: No game name found"); X printf ("\nYou are probably using the old CLIENT.OPTS fi Vle format"); X printf ("\nYou will get much better results if you use t Vhe new format."); X printf ("\nThe best way to convert is to temporarily rem Vove your CLIENT.OPTS"); X printf ("\nfile and rerun the empire client."); X printf ("\nDon't forget to save your current ip and port V number!"); X printf ("\n"); X printf ("\nPress return to continue"); X gets (gamename); X strcpy (gamename,argv`5B1`5D); X `7D X else gamename`5Bstrlen(gamename)-1`5D = 0; X `7D X `7D X`0C X else X `7B X printf("\nNo game name given. Trying first game listed."); X fgets (hm,256,options); X hm`5Bstrlen(hm)-1`5D = 0; X if (hm`5B0`5D == '#') X `7B X printf ("\nNo games found"); X printf ("\nPrompting for all info"); X strcpy (hm,"*"); X strcpy (portname,"*"); X strcpy (countryname,"*"); X strcpy (password,"*"); X `7D X else X `7B X fgets (portname,6,options); X portname`5Bstrlen(portname)-1`5D = 0; X fgets (countryname,20,options); X countryname`5Bstrlen(countryname)-1`5D = 0; X fgets (password,20,options); X password`5Bstrlen(password)-1`5D = 0; X trash = fgets (gamename,80,options); X if (trash == (char *) NULL) X `7B X printf ("\nWarning: No game name found"); X printf ("\nYou are probably using the old CLIENT.OPTS fi Vle format"); X printf ("\nYou will get much better results if you use t Vhe new format."); X printf ("\nThe best way to convert is to temporarily rem Vove your CLIENT.OPTS"); X printf ("\nfile and rerun the empire client."); X printf ("\nDon't forget to save your current ip and port V number!"); X printf ("\n"); X printf ("\nPress return to continue"); X gets (gamename); X `7D X else gamename`5Bstrlen(gamename)-1`5D = 0; X `7D X `7D X `7D X fclose(options); X`0C X if (strcmp(hm,"*") == 0) X `7B X printf ("\nHostname: "); X gets(hm); X `7D X if (strcmp(portname,"*") == 0) X `7B X printf ("\nPort: "); X gets(portname); X `7D X if (strcmp(countryname,"*") == 0) X `7B X printf ("\nCountry: "); X gets(countryname); X `7D X if (strcmp(password,"*") == 0) X `7B X printf ("\npassword: "); X gets(password); X `7D X X cuserid(userid); X printf ("\n"); X`0C X#ifdef WOLLENGONG X hostname = (char **) malloc(sizeof hm); X *hostname = hm; X if ((sin.sin_addr.s_addr = rhost (hostname)) == -1) X `7B X printf ("%s: unknown host\n", hm); X exit (1); X `7D X strcpy(hm,*hostname); X#else X if ((hostentry = gethostbyname(hm)) == NULL) X `7B X printf ("%s: unknown host\n", hm); X exit (1); X `7D X memcpy((void *) &sin.sin_addr, (void *) hostentry->h_addr, X (size_t) hostentry->h_length); X#endif X sin.sin_family = AF_INET; X sscanf (portname,"%d",&port); X sin.sin_port = htons (port); X X server_socket = socket (AF_INET, SOCK_STREAM, 0); X if (server_socket == -1) X `7B X printf ("EmpireClient: socket failed\n"); X exit (1); X `7D X X status = connect (server_socket, &sin, sizeof (sin)); X if (status == -1) closedown ("EmpireClient: connect refused", server_so Vcket); X X inbuffer = readit(server_socket); X if (*inbuffer != '2') exit(1); X `20 X strcpy (output, "user "); X strcat (output, userid); X strcat (output,linefeed); X l = strlen(output); X status = send(server_socket, output, l, 0); X if (status != l) closedown ("EmpireClient: send failed", server_socket) V; X if (status < 0) X `7B X printf ("\nSEND Status = %d\n", status); X printf ("\nVMSERROR = %d, UNIXERROR = %d\n",vmserrno, uerrno); X `7D X X inbuffer = readit(server_socket); X if (inbuffer`5B0`5D != C_CMDOK) X `7B X printf ("\nUser not accepted"); X exit(1); X `7D X X strcpy (output, "coun "); X strcat (output, countryname); X strcat (output,linefeed); X l = strlen(output); X status = send(server_socket, output, l, 0); X if (status != l) closedown ("EmpireClient: send failed", server_socket) V;`20 X if (status < 0) X `7B X printf ("\nSEND Status = %d\n", status); X printf ("\nVMSERROR = %d, UNIXERROR = %d\n",vmserrno, uerrno); X `7D X X inbuffer = readit(server_socket); X if (inbuffer`5B0`5D != C_CMDOK) X `7B X printf ("\nCountry not accepted"); X exit(1); X `7D X X strcpy (output, "pass "); X strcat (output, password); X strcat (output,linefeed); X l = strlen(output); X status = send(server_socket, output, l, 0); X if (status != l) closedown ("EmpireClient: send failed", server_socket) V; X if (status < 0) X `7B X printf ("\nSEND Status = %d\n", status); X printf ("\nVMSERROR = %d, UNIXERROR = %d\n",vmserrno, uerrno); X `7D X X inbuffer = readit(server_socket); X if (inbuffer`5B0`5D != C_CMDOK) X `7B X printf ("\nPassword not accepted"); X exit(1); X `7D X X strcpy (output, "play"); X strcat (output,linefeed); X l = strlen(output); X status = send(server_socket, output, l, 0); X if (status != l) closedown ("EmpireClient: send failed", server_socket) V; X if (status < 0) X `7B X printf ("\nSEND Status = %d\n", status); X printf ("\nVMSERROR = %d, UNIXERROR = %d\n",vmserrno, uerrno); X `7D X X done = TRUE; X reading = TRUE; X while (done == TRUE) X `7B X while (reading == TRUE) X `7B X inbuffer = readit(server_socket); X switch (*inbuffer) X `7B X case C_CMDOK: X fprintf (redir, " - %s", &inbuffer`5B2`5D); X break; X case C_DATA: X fprintf (redir, "%s", &inbuffer`5B2`5D); X break; X case C_INIT: X if (inbuffer`5B2`5D != '2') X `7B X fprintf(redir,`20 X "Warning! Empire version is %s\n", &inbuffer`5 VB2`5D); X fprintf(redir, "while client version is 2. "); X fprintf(redir, "Use at your own risk.\n"); X `7D X break; X case C_EXIT: X fprintf (redir, "Exit: %s", &inbuffer`5B2`5D); X exit(1); X break; X case C_FLUSH: X if (redir != stdout) X`09`09 `7B X`09`09`09fclose(redir); X`09`09`09redir = stdout; X`09`09 `7D X inbuffer`5Bstrlen(inbuffer) - 1`5D = 0; X fprintf (redir, "%s", &inbuffer`5B2`5D); X reading = FALSE; X break; X case C_NOECHO: X printf ("%s", inbuffer); X break; X case C_PROMPT: X if (redir != stdout) X`09`09 `7B X`09`09`09fclose(redir); X`09`09`09redir = stdout; X`09`09 `7D X sscanf (inbuffer, "%d %d %d", &trash, &btus, &mins); X fprintf (redir, "\n`5B%d:%d`5D Command : ", btus, mins); X reading = FALSE; X break; X case C_ABORT: X printf ("%s", inbuffer); X break; X case C_REDIR: X sscanf (&inbuffer`5B2`5D," >%s", outfile); X`09`09 if(redir != stdout ) X`09`09`09fclose(redir); X redir = fopen (outfile,"w"); X if (redir == (FILE *) 0) X `7B X fprintf (stderr, "\nUnable to open '%s' for output. V"); X redir = stdout; X `7D X break; X case C_PIPE: X printf ("%s", inbuffer); X break; X case C_CMDERR: X fprintf (redir, " - %s", &inbuffer`5B2`5D V); X exit (1); X break; X case C_BADCMD: X printf ("%s", inbuffer); X break; X case C_EXECUTE: X count = sscanf (&inbuffer`5B2`5D,"%s %s", infile, temp); X if (count == 2) X `7B X sscanf (temp,">%s", outfile); X redir = fopen (outfile,"w"); X if (redir == (FILE *) 0) X `7B X fprintf (stderr, "\nUnable to open '%s' for out Vput."); X redir = stdout; X `7D X `7D X fprintf (redir, "Sending %s...\n", infile); X input = fopen (infile,"r"); X if (input == (FILE *) 0) X `7B X fprintf (stderr, "Unable to open '%s' for input\n", X infile); X `7D X else X `7B X tempptr = fgets (buffer, sizeof(buffer)-1, input); X while (tempptr != (char *) NULL) X `7B X buflen = strlen(buffer); X status = send(server_socket, buffer, buflen, 0); X if (status != buflen) X closedown ("EmpireClient: send failed", serv Ver_socket); X if (status < 0) X `7B X printf ("\nSEND Status = %d\n", status); X printf ("\nVMSERROR = %d, UNIXERROR = %d\n", Vvmserrno, uerrno); X `7D X tempptr = fgets (buffer, sizeof(buffer)-1, input V); X `7D X `7D X buffer`5B0`5D = 10; X buffer`5B1`5D = 0; X buflen = strlen(buffer); X status = send(server_socket, buffer, buflen, 0); X if (status != buflen) X closedown ("EmpireClient: send failed", server_socke Vt); X if (status < 0) X `7B X printf ("\nSEND Status = %d\n", status); X printf ("\nVMSERROR = %d, UNIXERROR = %d\n",vmserrno V, uerrno); X `7D X`09`09 fclose(input); X input = stdin; X break; X default: X fprintf (redir, X "\n\n *****OH OH. Unknown empire directive #%d, '%c', `5B%s`5D \n\n") V; X fprintf (redir, X "\n Contact FXMLK%alaska.bitnet@cunyvm.cuny.edu" V); X fprintf (redir, X "\n and tell him what the directive was.\nThanks V!"); X fprintf (redir, "\n"); X break; X `7D X `7D `20 X X tempptr = fgets (buffer, sizeof(buffer)-1, input); X if (tempptr == (char *) NULL) X `7B X input = stdin; X strcpy (buffer,linefeed); X `7D X `20 X if (buffer`5B0`5D == commandchar) X `7B X dosend = FALSE; X switch (buffer`5B1`5D) X `7B X case 'h' : X case '?' : X printf ("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); X printf ("\n%sH - This help screen",commstr); X printf ("\n%sC - Close the connection.",commstr); X printf ("\n%s- - Change command character to ", X commstr); X printf ("\n%sS - Define as .",commstr); X printf ("\n%sM - Send .",commstr); X printf ("\n%sL - List defined macros.",commstr); X printf ("\n%s$ - Spawn a sub-process.",commstr); X printf ("\n%s$ - Spawn a command.",commstr); +-+-+-+-+-+-+-+- END OF PART 2 +-+-+-+-+-+-+-+-