Skip to content

Commit

Permalink
Make more strings translatable
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Oct 7, 2011
1 parent 4db0b9b commit f18f582
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cstp.c
Expand Up @@ -106,7 +106,7 @@ static int start_cstp_connection(struct openconnect_info *vpninfo)
if (vpninfo->dtls_times.last_rekey + vpninfo->dtls_times.rekey <
time(NULL) + 300 &&
RAND_bytes(vpninfo->dtls_secret, sizeof(vpninfo->dtls_secret)) != 1) {
fprintf(stderr, "Failed to initialise DTLS secret\n");
fprintf(stderr, _("Failed to initialise DTLS secret\n"));
exit(1);
}

Expand Down
41 changes: 21 additions & 20 deletions main.c
Expand Up @@ -202,11 +202,11 @@ static void read_stdin(char **string)
{
char *c = malloc(100);
if (!c) {
fprintf(stderr, "Allocation failure for string from stdin\n");
fprintf(stderr, _("Allocation failure for string from stdin\n"));
exit(1);
}
if (!fgets(c, 100, stdin)) {
perror("fgets (stdin)");
perror(_("fgets (stdin)"));
exit(1);
}

Expand Down Expand Up @@ -246,7 +246,7 @@ int main(int argc, char **argv)

vpninfo = malloc(sizeof(*vpninfo));
if (!vpninfo) {
fprintf(stderr, "Failed to allocate vpninfo structure\n");
fprintf(stderr, _("Failed to allocate vpninfo structure\n"));
exit(1);
}
memset(vpninfo, 0, sizeof(*vpninfo));
Expand Down Expand Up @@ -345,7 +345,7 @@ int main(int argc, char **argv)
} else if (!strcasecmp(optarg, "PEM")) {
vpninfo->cert_type = CERT_TYPE_PEM;
} else {
fprintf(stderr, "Unknown certificate type '%s'\n",
fprintf(stderr, _("Unknown certificate type '%s'\n"),
optarg);
usage();
}
Expand All @@ -370,7 +370,7 @@ int main(int argc, char **argv)
case 'm':
vpninfo->mtu = atol(optarg);
if (vpninfo->mtu < 576) {
fprintf(stderr, "MTU %d too small\n", vpninfo->mtu);
fprintf(stderr, _("MTU %d too small\n"), vpninfo->mtu);
vpninfo->mtu = 576;
}
break;
Expand All @@ -389,8 +389,9 @@ int main(int argc, char **argv)
proxy = NULL;
break;
case OPT_NO_HTTP_KEEPALIVE:
fprintf(stderr, "Disabling all HTTP connection re-use due to --no-http-keepalive option.\n"
"If this helps, please report to <openconnect-devel@lists.infradead.org>.\n");
fprintf(stderr,
_("Disabling all HTTP connection re-use due to --no-http-keepalive option.\n"
"If this helps, please report to <openconnect-devel@lists.infradead.org>.\n"));
vpninfo->no_http_keepalive = 1;
break;
case OPT_NO_CERT_CHECK:
Expand All @@ -411,7 +412,7 @@ int main(int argc, char **argv)
if (strend[0]) {
struct passwd *pw = getpwnam(optarg);
if (!pw) {
fprintf(stderr, "Invalid user \"%s\"\n",
fprintf(stderr, _("Invalid user \"%s\"\n"),
optarg);
exit(1);
}
Expand All @@ -425,7 +426,7 @@ int main(int argc, char **argv)
if (strend[0]) {
struct passwd *pw = getpwnam(optarg);
if (!pw) {
fprintf(stderr, "Invalid user \"%s\"\n",
fprintf(stderr, _("Invalid user \"%s\"\n"),
optarg);
exit(1);
}
Expand All @@ -443,7 +444,7 @@ int main(int argc, char **argv)
case 'Q':
vpninfo->max_qlen = atol(optarg);
if (!vpninfo->max_qlen) {
fprintf(stderr, "Queue length zero not permitted; using 1\n");
fprintf(stderr, _("Queue length zero not permitted; using 1\n"));
vpninfo->max_qlen = 1;
}
break;
Expand All @@ -454,7 +455,7 @@ int main(int argc, char **argv)
verbose = PRG_TRACE;
break;
case 'V':
printf("OpenConnect version %s\n", openconnect_version);
printf(_("OpenConnect version %s\n"), openconnect_version);
exit(0);
case 'x':
vpninfo->xmlconfig = optarg;
Expand All @@ -476,7 +477,7 @@ int main(int argc, char **argv)
}

if (optind != argc - 1) {
fprintf(stderr, "No server specified\n");
fprintf(stderr, _("No server specified\n"));
usage();
}

Expand All @@ -489,7 +490,7 @@ int main(int argc, char **argv)
#ifdef LIBPROXY_HDR
vpninfo->proxy_factory = px_proxy_factory_new();
#else
fprintf(stderr, "This version of openconnect was built without libproxy support\n");
fprintf(stderr, _("This version of openconnect was built without libproxy support\n"));
exit(1);
#endif
}
Expand Down Expand Up @@ -523,12 +524,12 @@ int main(int argc, char **argv)

if (internal_parse_url(url, &scheme, &vpninfo->hostname, &vpninfo->port,
&group, 443)) {
fprintf(stderr, "Failed to parse server URL '%s'\n",
fprintf(stderr, _("Failed to parse server URL '%s'\n"),
url);
exit(1);
}
if (scheme && strcmp(scheme, "https")) {
fprintf(stderr, "Only https:// permitted for server URL\n");
fprintf(stderr, _("Only https:// permitted for server URL\n"));
exit(1);
}
if (group) {
Expand All @@ -544,7 +545,7 @@ int main(int argc, char **argv)
#endif

if (!vpninfo->cookie && openconnect_obtain_cookie(vpninfo)) {
fprintf(stderr, "Failed to obtain WebVPN cookie\n");
fprintf(stderr, _("Failed to obtain WebVPN cookie\n"));
exit(1);
}

Expand All @@ -555,24 +556,24 @@ int main(int argc, char **argv)
exit(0);
}
if (make_cstp_connection(vpninfo)) {
fprintf(stderr, "Creating SSL connection failed\n");
fprintf(stderr, _("Creating SSL connection failed\n"));
exit(1);
}

if (setup_tun(vpninfo)) {
fprintf(stderr, "Set up tun device failed\n");
fprintf(stderr, _("Set up tun device failed\n"));
exit(1);
}

if (uid != getuid()) {
if (setuid(uid)) {
fprintf(stderr, "Failed to set uid %d\n", uid);
fprintf(stderr, _("Failed to set uid %d\n"), uid);
exit(1);
}
}

if (vpninfo->dtls_attempt_period && setup_dtls(vpninfo))
fprintf(stderr, "Set up DTLS failed; using SSL instead\n");
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,
Expand Down
21 changes: 12 additions & 9 deletions xml.c
Expand Up @@ -51,19 +51,20 @@ int config_lookup_host(struct openconnect_info *vpninfo, const char *host)

fd = open(vpninfo->xmlconfig, O_RDONLY);
if (fd < 0) {
perror("Open XML config file");
fprintf(stderr, "Treating host \"%s\" as a raw hostname\n", host);
perror(_("Open XML config file"));
fprintf(stderr, _("Treating host \"%s\" as a raw hostname\n"),
host);
return 0;
}

if (fstat(fd, &st)) {
perror("fstat XML config file");
perror(_("fstat XML config file"));
return -1;
}

xmlfile = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (xmlfile == MAP_FAILED) {
perror("mmap XML config file");
perror(_("mmap XML config file"));
close(fd);
return -1;
}
Expand All @@ -82,8 +83,10 @@ int config_lookup_host(struct openconnect_info *vpninfo, const char *host)
munmap(xmlfile, st.st_size);
close(fd);
if (!xml_doc) {
fprintf(stderr, "Failed to parse XML config file %s\n", vpninfo->xmlconfig);
fprintf(stderr, "Treating host \"%s\" as a raw hostname\n", host);
fprintf(stderr, _("Failed to parse XML config file %s\n"),
vpninfo->xmlconfig);
fprintf(stderr, _("Treating host \"%s\" as a raw hostname\n"),
host);
return 0;
}
xml_node = xmlDocGetRootElement(xml_doc);
Expand Down Expand Up @@ -117,7 +120,7 @@ int config_lookup_host(struct openconnect_info *vpninfo, const char *host)
char *content = (char *)xmlNodeGetContent(xml_node2);
if (content) {
vpninfo->hostname = content;
printf("Host \"%s\" has address \"%s\"\n",
printf(_("Host \"%s\" has address \"%s\"\n"),
host, content);
}
} else if (match &&
Expand All @@ -126,7 +129,7 @@ int config_lookup_host(struct openconnect_info *vpninfo, const char *host)
if (content) {
free(vpninfo->urlpath);
vpninfo->urlpath = content;
printf("Host \"%s\" has UserGroup \"%s\"\n",
printf(_("Host \"%s\" has UserGroup \"%s\"\n"),
host, content);
}
}
Expand All @@ -140,7 +143,7 @@ int config_lookup_host(struct openconnect_info *vpninfo, const char *host)
xmlFreeDoc(xml_doc);

if (!vpninfo->hostname) {
fprintf(stderr, "Host \"%s\" not listed in config; treating as raw hostname\n",
fprintf(stderr, _("Host \"%s\" not listed in config; treating as raw hostname\n"),
host);
}

Expand Down

0 comments on commit f18f582

Please sign in to comment.