New client option -s to specify server host and port
Overrides EMPIREHOST and EMPIREPORT.
This commit is contained in:
parent
7506039f1b
commit
f4fe7da1fb
2 changed files with 34 additions and 5 deletions
11
man/empire.6
11
man/empire.6
|
@ -10,6 +10,9 @@ empire \- Empire client
|
||||||
.BI \-2 " outfile"
|
.BI \-2 " outfile"
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
.BI \-s " host:port"
|
||||||
|
]
|
||||||
|
[
|
||||||
.I country
|
.I country
|
||||||
[
|
[
|
||||||
.I password
|
.I password
|
||||||
|
@ -34,6 +37,12 @@ Help. Print brief usage information and exit.
|
||||||
.B \-k
|
.B \-k
|
||||||
If someone else is connected to your country, kill their connection.
|
If someone else is connected to your country, kill their connection.
|
||||||
.TP
|
.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
|
.B \-u
|
||||||
Use UTF-8 rather than ASCII character set.
|
Use UTF-8 rather than ASCII character set.
|
||||||
.IP
|
.IP
|
||||||
|
@ -60,9 +69,11 @@ client:
|
||||||
.TP
|
.TP
|
||||||
.I EMPIREHOST
|
.I EMPIREHOST
|
||||||
Specifies the host to connect to, i.e. where the server runs.
|
Specifies the host to connect to, i.e. where the server runs.
|
||||||
|
Only effective if no host specified via \-s.
|
||||||
.TP
|
.TP
|
||||||
.I EMPIREPORT
|
.I EMPIREPORT
|
||||||
Specifies the port number or service name to connect to.
|
Specifies the port number or service name to connect to.
|
||||||
|
Only effective if no port specified via \-s.
|
||||||
.TP
|
.TP
|
||||||
.I COUNTRY
|
.I COUNTRY
|
||||||
The name of your country in the game.
|
The name of your country in the game.
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "sys/socket.h"
|
#include "sys/socket.h"
|
||||||
|
@ -68,6 +69,7 @@ print_usage(char *program_name)
|
||||||
printf("Usage: %s [OPTION]...[COUNTRY [PASSWORD]]\n"
|
printf("Usage: %s [OPTION]...[COUNTRY [PASSWORD]]\n"
|
||||||
" -2 FILE Append log of session to FILE\n"
|
" -2 FILE Append log of session to FILE\n"
|
||||||
" -k Kill connection\n"
|
" -k Kill connection\n"
|
||||||
|
" -s HOST:PORT Set host and port to connect\n"
|
||||||
" -u Use UTF-8\n"
|
" -u Use UTF-8\n"
|
||||||
" -h display this help and exit\n"
|
" -h display this help and exit\n"
|
||||||
" -v display version information and exit\n",
|
" -v display version information and exit\n",
|
||||||
|
@ -80,16 +82,16 @@ main(int argc, char **argv)
|
||||||
int opt;
|
int opt;
|
||||||
char *auxfname = NULL;
|
char *auxfname = NULL;
|
||||||
int send_kill = 0;
|
int send_kill = 0;
|
||||||
|
char *host = NULL;
|
||||||
|
char *port = NULL;
|
||||||
int utf8 = 0;
|
int utf8 = 0;
|
||||||
char **ap;
|
char **ap;
|
||||||
char *country;
|
char *country;
|
||||||
char *passwd;
|
char *passwd;
|
||||||
char *uname;
|
char *uname;
|
||||||
char *host;
|
|
||||||
char *port;
|
|
||||||
int sock;
|
int sock;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "2:kuhv")) != EOF) {
|
while ((opt = getopt(argc, argv, "2:ks:uhv")) != EOF) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case '2':
|
case '2':
|
||||||
auxfname = optarg;
|
auxfname = optarg;
|
||||||
|
@ -97,6 +99,20 @@ main(int argc, char **argv)
|
||||||
case 'k':
|
case 'k':
|
||||||
send_kill = 1;
|
send_kill = 1;
|
||||||
break;
|
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':
|
case 'u':
|
||||||
utf8 = eight_bit_clean = 1;
|
utf8 = eight_bit_clean = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -121,10 +137,12 @@ main(int argc, char **argv)
|
||||||
passwd = *ap++;
|
passwd = *ap++;
|
||||||
else
|
else
|
||||||
passwd = getenv("PLAYER");
|
passwd = getenv("PLAYER");
|
||||||
port = getenv("EMPIREPORT");
|
if (!port)
|
||||||
|
port = getenv("EMPIREPORT");
|
||||||
if (!port)
|
if (!port)
|
||||||
port = empireport;
|
port = empireport;
|
||||||
host = getenv("EMPIREHOST");
|
if (!host)
|
||||||
|
host = getenv("EMPIREHOST");
|
||||||
if (!host)
|
if (!host)
|
||||||
host = empirehost;
|
host = empirehost;
|
||||||
uname = getenv("LOGNAME");
|
uname = getenv("LOGNAME");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue