- Use POSIX error handling (errno and strerror()) for standard C and
POSIX functions, including in Windows-only code.
- Add standard error messages with strerror() whenever possible. They
are standard and easily recognisable by end-users.
- Add missing _() when neeeded.
- Remove extra "\n" from vpn_perror() call.
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
} else {
/* Not a console; maybe reading from a piped stdin? */
if (!fgetws(wbuf, ARRAY_SIZE(wbuf), stdin)) {
- char *errstr = openconnect__win32_strerror(GetLastError());
- fprintf(stderr, _("fgetws (stdin): %s\n"), errstr);
- free(errstr);
+ perror(_("fgetws (stdin)"));
*string = NULL;
return;
}
}
buf = malloc(nr_read);
if (!buf) {
- fprintf(stderr, _("Allocation failure for string from stdin\n"));
+ perror(_("Allocation failure for string from stdin"));
exit(1);
}
}
pid = fork();
if (pid == -1) {
- vpn_perror(vpninfo, "Failed to continue in background\n");
+ vpn_perror(vpninfo, _("Failed to continue in background"));
exit(1);
} else if (pid > 0) {
if (fp) {