Overrides EMPIREHOST and EMPIREPORT.
+.BI \-s " host:port"
+]
+[
.B \-k
If someone else is connected to your country, kill their connection.
.TP
.B \-k
If someone else is connected to your country, kill their connection.
.TP
+.BI \-s " host:port"
+Specify host and port to which to connect.
+.IP
+Connect to \fIhost\fR using port \fIport\fR. You can specify only
+one; just leave the other empty (include the colon).
+.TP
.B \-u
Use UTF-8 rather than ASCII character set.
.IP
.B \-u
Use UTF-8 rather than ASCII character set.
.IP
.TP
.I EMPIREHOST
Specifies the host to connect to, i.e. where the server runs.
.TP
.I EMPIREHOST
Specifies the host to connect to, i.e. where the server runs.
+Only effective if no host specified via \-s.
.TP
.I EMPIREPORT
Specifies the port number or service name to connect to.
.TP
.I EMPIREPORT
Specifies the port number or service name to connect to.
+Only effective if no port specified via \-s.
.TP
.I COUNTRY
The name of your country in the game.
.TP
.I COUNTRY
The name of your country in the game.
#include <config.h>
#include <stdlib.h>
#include <config.h>
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#include "sys/socket.h"
#ifdef _WIN32
#include <windows.h>
#include "sys/socket.h"
printf("Usage: %s [OPTION]...[COUNTRY [PASSWORD]]\n"
" -2 FILE Append log of session to FILE\n"
" -k Kill connection\n"
printf("Usage: %s [OPTION]...[COUNTRY [PASSWORD]]\n"
" -2 FILE Append log of session to FILE\n"
" -k Kill connection\n"
+ " -s HOST:PORT Set host and port to connect\n"
" -u Use UTF-8\n"
" -h display this help and exit\n"
" -v display version information and exit\n",
" -u Use UTF-8\n"
" -h display this help and exit\n"
" -v display version information and exit\n",
int opt;
char *auxfname = NULL;
int send_kill = 0;
int opt;
char *auxfname = NULL;
int send_kill = 0;
+ char *host = NULL;
+ char *port = NULL;
int utf8 = 0;
char **ap;
char *country;
char *passwd;
char *uname;
int utf8 = 0;
char **ap;
char *country;
char *passwd;
char *uname;
- char *host;
- char *port;
- while ((opt = getopt(argc, argv, "2:kuhv")) != EOF) {
+ while ((opt = getopt(argc, argv, "2:ks:uhv")) != EOF) {
switch (opt) {
case '2':
auxfname = optarg;
switch (opt) {
case '2':
auxfname = optarg;
case 'k':
send_kill = 1;
break;
case 'k':
send_kill = 1;
break;
+ case 's':
+ host = strdup(optarg);
+ port = strchr(host, ':');
+ if (port == host) { /* if no host specified, then set to null */
+ host = NULL;
+ }
+ if (port) { /* make port the bit after the colon */
+ port[0] = 0;
+ port++;
+ if (port[0] == 0) { /* handle colon-at-end-of-string */
+ port = NULL;
+ }
+ }
+ break;
case 'u':
utf8 = eight_bit_clean = 1;
break;
case 'u':
utf8 = eight_bit_clean = 1;
break;
passwd = *ap++;
else
passwd = getenv("PLAYER");
passwd = *ap++;
else
passwd = getenv("PLAYER");
- port = getenv("EMPIREPORT");
+ if (!port)
+ port = getenv("EMPIREPORT");
if (!port)
port = empireport;
if (!port)
port = empireport;
- host = getenv("EMPIREHOST");
+ if (!host)
+ host = getenv("EMPIREHOST");
if (!host)
host = empirehost;
uname = getenv("LOGNAME");
if (!host)
host = empirehost;
uname = getenv("LOGNAME");