Commit eef00ae2 authored by David Woodhouse's avatar David Woodhouse

Make user-visible strings translatable

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 7d75b932
......@@ -121,7 +121,7 @@ static int parse_auth_choice(struct openconnect_info *vpninfo, struct oc_auth_fo
opt->form.label = (char *)xmlGetProp(xml_node, (unsigned char *)"label");
if (!opt->form.name) {
vpn_progress(vpninfo, PRG_ERR, "Form choice has no name\n");
vpn_progress(vpninfo, PRG_ERR, _("Form choice has no name\n"));
free(opt);
return -EINVAL;
}
......@@ -184,13 +184,15 @@ static int parse_form(struct openconnect_info *vpninfo, struct oc_auth_form *for
continue;
}
if (strcmp((char *)xml_node->name, "input")) {
vpn_progress(vpninfo, PRG_TRACE, "name %s not input\n", xml_node->name);
vpn_progress(vpninfo, PRG_TRACE,
_("name %s not input\n"), xml_node->name);
continue;
}
input_type = (char *)xmlGetProp(xml_node, (unsigned char *)"type");
if (!input_type) {
vpn_progress(vpninfo, PRG_INFO, "No input type in form\n");
vpn_progress(vpninfo, PRG_INFO,
_("No input type in form\n"));
continue;
}
......@@ -201,7 +203,8 @@ static int parse_form(struct openconnect_info *vpninfo, struct oc_auth_form *for
input_name = (char *)xmlGetProp(xml_node, (unsigned char *)"name");
if (!input_name) {
vpn_progress(vpninfo, PRG_INFO, "No input name in form\n");
vpn_progress(vpninfo, PRG_INFO,
_("No input name in form\n"));
free(input_type);
continue;
}
......@@ -224,8 +227,8 @@ static int parse_form(struct openconnect_info *vpninfo, struct oc_auth_form *for
opt->type = OC_FORM_OPT_PASSWORD;
else {
vpn_progress(vpninfo, PRG_INFO,
"Unknown input type %s in form\n",
input_type);
_("Unknown input type %s in form\n"),
input_type);
free(input_type);
free(input_name);
free(input_label);
......@@ -244,7 +247,7 @@ static int parse_form(struct openconnect_info *vpninfo, struct oc_auth_form *for
*p = opt;
}
vpn_progress(vpninfo, PRG_TRACE, "Fixed options give %s\n", body);
vpn_progress(vpninfo, PRG_TRACE, _("Fixed options give %s\n"), body);
return 0;
}
......@@ -331,15 +334,18 @@ int parse_xml_response(struct openconnect_info *vpninfo, char *response,
xml_doc = xmlReadMemory(response, strlen(response), "noname.xml", NULL, 0);
if (!xml_doc) {
vpn_progress(vpninfo, PRG_ERR, "Failed to parse server response\n");
vpn_progress(vpninfo, PRG_TRACE, "Response was:%s\n", response);
vpn_progress(vpninfo, PRG_ERR,
_("Failed to parse server response\n"));
vpn_progress(vpninfo, PRG_TRACE,
_("Response was:%s\n"), response);
free(form);
return -EINVAL;
}
xml_node = xmlDocGetRootElement(xml_doc);
if (xml_node->type != XML_ELEMENT_NODE || strcmp((char *)xml_node->name, "auth")) {
vpn_progress(vpninfo, PRG_ERR, "XML response has no \"auth\" root node\n");
vpn_progress(vpninfo, PRG_ERR,
_("XML response has no \"auth\" root node\n"));
ret = -EINVAL;
goto out;
}
......@@ -351,7 +357,8 @@ int parse_xml_response(struct openconnect_info *vpninfo, char *response,
}
if (vpninfo->nopasswd) {
vpn_progress(vpninfo, PRG_ERR, "Asked for password but '--no-passwd' set\n");
vpn_progress(vpninfo, PRG_ERR,
_("Asked for password but '--no-passwd' set\n"));
ret = -EPERM;
goto out;
}
......@@ -376,8 +383,8 @@ int parse_xml_response(struct openconnect_info *vpninfo, char *response,
if (!form->method || !form->action ||
strcasecmp(form->method, "POST") || !form->action[0]) {
vpn_progress(vpninfo, PRG_ERR,
"Cannot handle form method='%s', action='%s'\n",
form->method, form->action);
_("Cannot handle form method='%s', action='%s'\n"),
form->method, form->action);
ret = -EINVAL;
goto out;
}
......@@ -496,7 +503,7 @@ static int process_auth_form(struct openconnect_info *vpninfo,
choice_resp[0] = 0;
if (!ui) {
vpn_progress(vpninfo, PRG_ERR, "Failed to create UI\n");
vpn_progress(vpninfo, PRG_ERR, _("Failed to create UI\n"));
return -EINVAL;
}
if (form->banner) {
......@@ -539,8 +546,8 @@ static int process_auth_form(struct openconnect_info *vpninfo,
}
if (!opt->value)
vpn_progress(vpninfo, PRG_ERR,
"Auth choice \"%s\" not available\n",
vpninfo->authgroup);
_("Auth choice \"%s\" not available\n"),
vpninfo->authgroup);
}
if (!opt->value && select_opt->nr_choices == 1) {
choice = &select_opt->choices[0];
......@@ -619,7 +626,7 @@ static int process_auth_form(struct openconnect_info *vpninfo,
goto out_ui;
case -1:
/* error */
vpn_progress(vpninfo, PRG_ERR, "Invalid inputs\n");
vpn_progress(vpninfo, PRG_ERR, _("Invalid inputs\n"));
ret = -EINVAL;
out_ui:
UI_free(ui);
......@@ -642,8 +649,8 @@ static int process_auth_form(struct openconnect_info *vpninfo,
}
if (!select_opt->form.value) {
vpn_progress(vpninfo, PRG_ERR,
"Auth choice \"%s\" not valid\n",
choice_resp);
_("Auth choice \"%s\" not valid\n"),
choice_resp);
return -EINVAL;
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -570,17 +570,17 @@ int main(int argc, char **argv)
fprintf(stderr, "Set up DTLS failed; using SSL instead\n");
vpn_progress(vpninfo, PRG_INFO,
"Connected %s as %s%s%s, using %s\n", vpninfo->ifname,
vpninfo->vpn_addr?:"",
(vpninfo->vpn_addr6 && vpninfo->vpn_addr)?" + ":"",
vpninfo->vpn_addr6?:"",
(vpninfo->dtls_fd == -1) ?
(vpninfo->deflate ? "SSL + deflate" : "SSL")
: "DTLS");
_("Connected %s as %s%s%s, using %s\n"), vpninfo->ifname,
vpninfo->vpn_addr?:"",
(vpninfo->vpn_addr6 && vpninfo->vpn_addr)?" + ":"",
vpninfo->vpn_addr6?:"",
(vpninfo->dtls_fd == -1) ?
(vpninfo->deflate ? "SSL + deflate" : "SSL")
: "DTLS");
if (!vpninfo->vpnc_script)
vpn_progress(vpninfo, PRG_INFO,
"No --script argument provided; DNS and routing are not configured\n");
_("No --script argument provided; DNS and routing are not configured\n"));
if (background) {
int pid;
......@@ -591,7 +591,7 @@ int main(int argc, char **argv)
if (pidfile != NULL) {
fp = fopen(pidfile, "w");
if (!fp) {
fprintf(stderr, "Failed to open '%s' for write: %s\n",
fprintf(stderr, _("Failed to open '%s' for write: %s\n"),
pidfile, strerror(errno));
exit(1);
}
......@@ -602,7 +602,7 @@ int main(int argc, char **argv)
fclose(fp);
}
vpn_progress(vpninfo, PRG_INFO,
"Continuing in background; pid %d\n",
_("Continuing in background; pid %d\n"),
pid);
exit(0);
}
......@@ -624,7 +624,7 @@ static int write_new_config(void *_vpninfo, char *buf, int buflen)
config_fd = open(vpninfo->xmlconfig, O_WRONLY|O_TRUNC|O_CREAT, 0644);
if (config_fd < 0) {
err = errno;
fprintf(stderr, "Failed to open %s for write: %s\n",
fprintf(stderr, _("Failed to open %s for write: %s\n"),
vpninfo->xmlconfig, strerror(err));
return -err;
}
......@@ -632,7 +632,7 @@ static int write_new_config(void *_vpninfo, char *buf, int buflen)
/* FIXME: We should actually write to a new tempfile, then rename */
if(write(config_fd, buf, buflen) != buflen) {
err = errno;
fprintf(stderr, "Failed to write config to %s: %s\n",
fprintf(stderr, _("Failed to write config to %s: %s\n"),
vpninfo->xmlconfig, strerror(err));
return -err;
......@@ -721,15 +721,16 @@ static int validate_peer_cert(void *_vpninfo, X509 *peer_cert,
char buf[6];
int ret;
fprintf(stderr, "\nCertificate from VPN server \"%s\" failed verification.\n"
"Reason: %s\n", vpninfo->hostname, reason);
fprintf(stderr,
_("\nCertificate from VPN server \"%s\" failed verification.\n"
"Reason: %s\n"), vpninfo->hostname, reason);
if (non_inter)
return -EINVAL;
fflush(stderr);
ui = UI_new();
UI_add_input_string(ui, "Enter 'yes' to accept, 'no' to abort; anything else to view: ",
UI_add_input_string(ui, _("Enter 'yes' to accept, 'no' to abort; anything else to view: "),
UI_INPUT_FLAG_ECHO, buf, 2, 5);
ret = UI_process(ui);
UI_free(ui);
......@@ -738,7 +739,7 @@ static int validate_peer_cert(void *_vpninfo, X509 *peer_cert,
if (ret == -1)
buf[0] = 0;
if (!strcasecmp(buf, "yes")) {
if (!strcasecmp(buf, _("yes"))) {
struct accepted_cert *newcert = malloc(sizeof(*newcert) +
strlen(vpninfo->hostname) + 1);
if (newcert) {
......@@ -749,11 +750,11 @@ static int validate_peer_cert(void *_vpninfo, X509 *peer_cert,
}
return 0;
}
if (!strcasecmp(buf, "no"))
if (!strcasecmp(buf, _("no")))
return -EINVAL;
X509_print_fp(stderr, peer_cert);
fprintf(stderr, "SHA1 fingerprint: %s\n", fingerprint);
fprintf(stderr, _("SHA1 fingerprint: %s\n"), fingerprint);
}
}
......@@ -86,7 +86,7 @@ int vpn_mainloop(struct openconnect_info *vpninfo)
if (vpninfo->dtls_attempt_period && !vpninfo->dtls_ssl && !vpninfo->new_dtls_ssl &&
vpninfo->new_dtls_started + vpninfo->dtls_attempt_period < time(NULL)) {
vpn_progress(vpninfo, PRG_TRACE, "Attempt new DTLS connection\n");
vpn_progress(vpninfo, PRG_TRACE, _("Attempt new DTLS connection\n"));
connect_dtls_socket(vpninfo);
}
if (vpninfo->dtls_ssl)
......@@ -119,7 +119,7 @@ int vpn_mainloop(struct openconnect_info *vpninfo)
continue;
vpn_progress(vpninfo, PRG_TRACE,
"No work to do; sleeping for %d ms...\n", timeout);
_("No work to do; sleeping for %d ms...\n"), timeout);
memcpy(&rfds, &vpninfo->select_rfds, sizeof(rfds));
memcpy(&wfds, &vpninfo->select_wfds, sizeof(wfds));
memcpy(&efds, &vpninfo->select_efds, sizeof(efds));
......
......@@ -45,6 +45,7 @@
#else
#define _(s) s
#endif
#define N_(s) s
/****************************************************************************/
......
This diff is collapsed.
......@@ -80,7 +80,7 @@ static int local_config_tun(struct openconnect_info *vpninfo, int mtu_only)
{
if (!mtu_only)
vpn_progress(vpninfo, PRG_ERR,
"No vpnc-script configured. Need Solaris IP-setting code\n");
_("No vpnc-script configured. Need Solaris IP-setting code\n"));
return 0;
}
#else
......@@ -91,7 +91,7 @@ static int local_config_tun(struct openconnect_info *vpninfo, int mtu_only)
net_fd = socket(PF_INET, SOCK_DGRAM, 0);
if (net_fd < 0) {
perror("open net");
perror(_("open net"));
return -EINVAL;
}
memset(&ifr, 0, sizeof(ifr));
......@@ -101,22 +101,22 @@ static int local_config_tun(struct openconnect_info *vpninfo, int mtu_only)
struct sockaddr_in addr;
if (ioctl(net_fd, SIOCGIFFLAGS, &ifr) < 0)
perror("SIOCGIFFLAGS");
perror(_("SIOCGIFFLAGS"));
ifr.ifr_flags |= IFF_UP | IFF_POINTOPOINT;
if (ioctl(net_fd, SIOCSIFFLAGS, &ifr) < 0)
perror("SIOCSIFFLAGS");
perror(_("SIOCSIFFLAGS"));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr(vpninfo->vpn_addr);
memcpy(&ifr.ifr_addr, &addr, sizeof(addr));
if (ioctl(net_fd, SIOCSIFADDR, &ifr) < 0)
perror("SIOCSIFADDR");
perror(_("SIOCSIFADDR"));
}
ifr.ifr_mtu = vpninfo->mtu;
if (ioctl(net_fd, SIOCSIFMTU, &ifr) < 0)
perror("SIOCSIFMTU");
perror(_("SIOCSIFMTU"));
close(net_fd);
......@@ -154,8 +154,8 @@ static int process_split_xxclude(struct openconnect_info *vpninfo,
if (!slash) {
badinc:
vpn_progress(vpninfo, PRG_ERR,
"Discard bad split %sclude: \"%s\"\n",
in_ex, route);
_("Discard bad split %sclude: \"%s\"\n"),
in_ex, route);
return -EINVAL;
}
......@@ -366,8 +366,8 @@ static int script_config_tun(struct openconnect_info *vpninfo)
if (system(vpninfo->vpnc_script)) {
int e = errno;
vpn_progress(vpninfo, PRG_ERR,
"Failed to spawn script '%s': %s\n",
vpninfo->vpnc_script, strerror(e));
_("Failed to spawn script '%s': %s\n"),
vpninfo->vpnc_script, strerror(e));
return -e;
}
return 0;
......@@ -391,24 +391,24 @@ int setup_tun(struct openconnect_info *vpninfo)
int fds[2];
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds)) {
perror("socketpair");
perror(_("socketpair"));
exit(1);
}
tun_fd = fds[0];
child = fork();
if (child < 0) {
perror("fork");
perror(_("fork"));
exit(1);
} else if (!child) {
close(tun_fd);
setenv_int("VPNFD", fds[1]);
execl("/bin/sh", "/bin/sh", "-c", vpninfo->vpnc_script, NULL);
perror("execl");
perror(_("execl"));
exit(1);
}
close(fds[1]);
vpninfo->script_tun = child;
vpninfo->ifname = strdup("(script)");
vpninfo->ifname = strdup(_("(script)"));
} else {
#ifdef IFF_TUN /* Linux */
struct ifreq ifr;
......@@ -429,8 +429,8 @@ int setup_tun(struct openconnect_info *vpninfo)
tunerr = errno;
vpn_progress(vpninfo, PRG_ERR,
"Failed to open tun device: %s\n",
strerror(tunerr));
_("Failed to open tun device: %s\n"),
strerror(tunerr));
exit(1);
}
memset(&ifr, 0, sizeof(ifr));
......@@ -440,8 +440,8 @@ int setup_tun(struct openconnect_info *vpninfo)
sizeof(ifr.ifr_name) - 1);
if (ioctl(tun_fd, TUNSETIFF, (void *) &ifr) < 0) {
vpn_progress(vpninfo, PRG_ERR,
"TUNSETIFF failed: %s\n",
strerror(errno));
_("TUNSETIFF failed: %s\n"),
strerror(errno));
exit(1);
}
if (!vpninfo->ifname)
......@@ -453,20 +453,20 @@ int setup_tun(struct openconnect_info *vpninfo)
struct ifreq ifr;
if (ip_fd < 0) {
perror("open /dev/ip");
perror(_("open /dev/ip"));
return -EIO;
}
tun_fd = open("/dev/tun", O_RDWR);
if (tun_fd < 0) {
perror("open /dev/tun");
perror(_("open /dev/tun"));
close(ip_fd);
return -EIO;
}
unit_nr = ioctl(tun_fd, TUNNEWPPA, -1);
if (unit_nr < 0) {
perror("Failed to create new tun");
perror(_("Failed to create new tun"));
close(tun_fd);
close(ip_fd);
return -EIO;
......@@ -474,20 +474,20 @@ int setup_tun(struct openconnect_info *vpninfo)
tun2_fd = open("/dev/tun", O_RDWR);
if (tun2_fd < 0) {
perror("open /dev/tun again");
perror(_("open /dev/tun again"));
close(tun_fd);
close(ip_fd);
return -EIO;
}
if (ioctl(tun2_fd, I_PUSH, "ip") < 0) {
perror("Can't push IP");
perror(_("Can't push IP"));
close(tun2_fd);
close(tun_fd);
close(ip_fd);
return -EIO;
}
if (ioctl(tun2_fd, IF_UNITSEL, &unit_nr) < 0) {
perror("Can't select unit");
perror(_("Can't select unit"));
close(tun2_fd);
close(tun_fd);
close(ip_fd);
......@@ -495,7 +495,7 @@ int setup_tun(struct openconnect_info *vpninfo)
}
mux_id = ioctl(ip_fd, I_PLINK, tun2_fd);
if (mux_id < 0) {
perror("Can't link tun to IP");
perror(_("Can't link tun to IP"));
close(tun2_fd);
close(tun_fd);
close(ip_fd);
......@@ -511,14 +511,14 @@ int setup_tun(struct openconnect_info *vpninfo)
ifr.ifr_ip_muxid = mux_id;
if (ioctl(ip_fd, SIOCSIFMUXID, &ifr) < 0) {
perror("Set mux id");
perror(_("Set mux id"));
close(tun_fd);
ioctl(ip_fd, I_PUNLINK, mux_id);
close(ip_fd);
return -EIO;
}
/* Solaris tunctl needs this in order to tear it down */
vpn_progress(vpninfo, PRG_DEBUG, "mux id is %d\n", mux_id);
vpn_progress(vpninfo, PRG_DEBUG, _("mux id is %d\n"), mux_id);
vpninfo->tun_muxid = mux_id;
vpninfo->ip_fd = ip_fd;
......@@ -532,14 +532,14 @@ int setup_tun(struct openconnect_info *vpninfo)
break;
}
if (tun_fd < 0) {
perror("open tun");
perror(_("open tun"));
exit(1);
}
vpninfo->ifname = strdup(tun_name + 5);
#ifdef TUNSIFHEAD
i = 1;
if (ioctl(tun_fd, TUNSIFHEAD, &i) < 0) {
perror("TUNSIFHEAD");
perror(_("TUNSIFHEAD"));
exit(1);
}
#endif
......@@ -619,8 +619,8 @@ int tun_mainloop(struct openconnect_info *vpninfo, int *timeout)
if (!complained) {
complained = 1;
vpn_progress(vpninfo, PRG_ERR,
"Unknown packet (len %d) received: %02x %02x %02x %02x...\n",
len, data[0], data[1], data[2], data[3]);
_("Unknown packet (len %d) received: %02x %02x %02x %02x...\n"),
len, data[0], data[1], data[2], data[3]);
}
free(this);
continue;
......@@ -652,14 +652,14 @@ void shutdown_tun(struct openconnect_info *vpninfo)
setenv("reason", "disconnect", 1);
if (system(vpninfo->vpnc_script) == -1) {
vpn_progress(vpninfo, PRG_ERR,
"Failed to spawn script '%s': %s\n",
vpninfo->vpnc_script,
strerror(errno));
_("Failed to spawn script '%s': %s\n"),
vpninfo->vpnc_script,
strerror(errno));
}
}
#ifdef __sun__
if (ioctl(vpninfo->ip_fd, I_PUNLINK, vpninfo->tun_muxid) < 0)
perror("ioctl(I_PUNLINK)");
perror(_("ioctl(I_PUNLINK)"));
close(vpninfo->ip_fd);
vpninfo->ip_fd = -1;
......
......@@ -75,7 +75,8 @@ int config_lookup_host(struct openconnect_info *vpninfo, const char *host)
for (i = 0; i < SHA_DIGEST_LENGTH; i++)
sprintf(&vpninfo->xmlsha1[i*2], "%02x", sha1[i]);
vpn_progress(vpninfo, PRG_TRACE, "XML config file SHA1: %s\n", vpninfo->xmlsha1);
vpn_progress(vpninfo, PRG_TRACE, _("XML config file SHA1: %s\n"),
vpninfo->xmlsha1);
xml_doc = xmlReadMemory(xmlfile, st.st_size, "noname.xml", NULL, 0);
munmap(xmlfile, st.st_size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment