@ENABLE_NLS@
#define LOCALEDIR "@LOCALEDIR@"
#define LOCALE_DOMAIN "@LOCALE_DOMAIN@"
-#include "NLS.h"
#endif
*/
#include "FaxClient.h"
#include "Sys.h"
+#include "NLS.h"
#include "config.h"
extern int
int
main(int argc, char** argv)
{
- setupNLS();
+ NLS::Setup("hylafax-clients");
faxAlterApp app;
return (app.run(argc, argv));
}
#include "PageSize.h"
#include "Sys.h"
+#include "NLS.h"
+
#include <stdarg.h>
#include <ctype.h>
#include <pwd.h>
int
main(int argc, char** argv)
{
- setupNLS();
+ NLS::Setup("hylafax-client");
faxCoverApp app;
app.initialize(argc, argv);
app.open();
#include "MemoryDecoder.h"
#include "tiffio.h"
#include "Sys.h"
+#include "NLS.h"
const char* appName;
bool doAll = false;
int c;
- setupNLS();
+ NLS::Setup("hylafax-server");
appName = argv[0];
while ((c = Sys::getopt(argc, argv, "t:a")) != -1)
switch (c) {
#include "Class2Params.h"
#include "Str.h"
#include "FaxTrace.h"
+#include "NLS.h"
#include "tiffio.h"
struct CQDecoder : public G3Decoder {
extern char* optarg;
int c;
- setupNLS();
+ NLS::Setup("hylafax-server");
CQDecoder cq;
appName = argv[0];
while ((c = Sys::getopt(argc, argv, "m:o:p:")) != -1)
#include "faxApp.h"
#include "Dictionary.h"
#include "FaxRequest.h"
+#include "NLS.h"
#include "config.h"
#include <sys/file.h>
int
main(int argc, char** argv)
{
- setupNLS();
+ NLS::Setup("hylafax-server");
faxApp::setupLogging("FaxQCleaner");
fxStr appName = argv[0];
* Usage: tagtest [-f fontfile] [-m format] [-o output.tif] input.tif
*/
#include "Sys.h"
-
+#include "NLS.h"
#include "PCFFont.h"
#include "StackBuffer.h"
#include "FaxFont.h"
int c;
const char* output = "t.tif";
+ NLS::Setup("hylafax-server");
+
#ifdef LC_CTYPE
setlocale(LC_CTYPE, ""); // for <ctype.h> calls
#endif
#ifdef LC_TIME
setlocale(LC_TIME, ""); // for strftime calls
#endif
- setupNLS();
+
appName = argv[0];
while ((c = Sys::getopt(argc, argv, "f:m:o:")) != -1)
switch (c) {
#include "BoolArray.h"
#include "Str.h"
#include "Sys.h"
+#include "NLS.h"
fxStr qualifyTSI;
REArray* tsiPats = NULL; // recv tsi patterns
extern int optind;
int c;
- setupNLS();
+ NLS::Setup("hylafax-server");
appName = argv[0];
while ((c = Sys::getopt(argc, argv, ":q")) != -1)
switch (c) {
#include "StrArray.h"
#include "Sys.h"
#include "SendFaxClient.h"
+#include "NLS.h"
#include "config.h"
#include <ctype.h>
#ifdef LC_CTYPE
setlocale(LC_CTYPE, ""); // for <ctype.h> calls
#endif
- setupNLS();
+ NLS::Setup("hylafax-client");
app = new faxMailApp;
*/
#include "FaxClient.h"
#include "Sys.h"
+#include "NLS.h"
#include "config.h"
class faxRmApp : public FaxClient {
int
main(int argc, char** argv)
{
- setupNLS();
+ NLS::Setup("hylafax-client");
faxRmApp app;
app.run(argc, argv);
return 0;
#include "FaxClient.h"
#include "StrArray.h"
#include "Sys.h"
+#include "NLS.h"
#include "config.h"
#include <errno.h>
int
main(int argc, char** argv)
{
- setupNLS();
+ NLS::Setup("hylafax-client");
faxStatApp app;
app.run(argc, argv);
return 0;
#include <time.h>
#include <ctype.h>
+#include "NLS.h"
+
#define TM_YEAR_BASE 1900 // tm times all start here...
#define EPOCH_YEAR 1970
#define EPOCH_WDAY 4 // January 1, 1970 was a Thursday
if (isdigit(cp[1]) && isdigit(cp[2])) {
int min = 10*(cp[1]-'0') + (cp[2]-'0');
if (min >= 60) {
- _atError(emsg, _("Illegal minutes value %u"), min);
+ _atError(emsg, NLS::TEXT("Illegal minutes value %u"), min);
return (false);
}
v += min;
cp += 3;
} else {
- _atSyntax(emsg, _("expecting HH:MM"));
+ _atSyntax(emsg, NLS::TEXT("expecting HH:MM"));
return (false);
}
}
cp = whitespace(cp);
if (streq(cp, "am", 2)) {
if (v >= HALFDAY+HOUR) {
- _atError(emsg, _("%u:%02u is not an AM value"), v/HOUR, v%HOUR);
+ _atError(emsg, NLS::TEXT("%u:%02u is not an AM value"), v/HOUR, v%HOUR);
return (false);
}
if (HALFDAY <= v && v < HALFDAY+HOUR)
cp += 2;
} else if (streq(cp, "pm", 2)) {
if (v >= HALFDAY+HOUR) {
- _atError(emsg, _("%u:%02u is not a PM value"), v/HOUR, v%HOUR);
+ _atError(emsg, NLS::TEXT("%u:%02u is not a PM value"), v/HOUR, v%HOUR);
return (false);
}
if (v < HALFDAY)
v = at.tm_hour*HOUR + at.tm_min;
cp += 4;
} else {
- _atSyntax(emsg, _("unrecognized symbolic time \"%s\""), cp);
+ _atSyntax(emsg, NLS::TEXT("unrecognized symbolic time \"%s\""), cp);
return (false);
}
}
if ((unsigned) v >= FULLDAY) {
- _atError(emsg, _("Illegal time value; out of range"));
+ _atError(emsg, NLS::TEXT("Illegal time value; out of range"));
return (false);
}
at.tm_hour = v/HOUR;
at.tm_yday++;
cp += 8;
} else if (cp[0] != '\0' && cp[0] != '+') {
- _atSyntax(emsg, _("expecting \"+\" after time"));
+ _atSyntax(emsg, NLS::TEXT("expecting \"+\" after time"));
return (false);
}
/*
return (false);
fixup(at);
if (at < ref) {
- _atError(emsg, _("Invalid date/time; time must be in the future"));
+ _atError(emsg, NLS::TEXT("Invalid date/time; time must be in the future"));
return (false);
}
at0 = at;
char* tp;
at.tm_mday = (u_int) strtoul(cp, &tp, 10);
if (tp == cp) {
- _atSyntax(emsg, _("missing or invalid day of month"));
+ _atSyntax(emsg, NLS::TEXT("missing or invalid day of month"));
return (false);
}
at.tm_mday--; // tm_mday is [0..31]
char* xp;
u_int year = (u_int) strtoul(++tp, &xp, 10);
if (tp == xp) {
- _atSyntax(emsg, _("missing year"));
+ _atSyntax(emsg, NLS::TEXT("missing year"));
return (false);
}
if (year < TM_YEAR_BASE) {
- _atError(emsg, _("Sorry, cannot handle dates before %u"),
+ _atError(emsg, NLS::TEXT("Sorry, cannot handle dates before %u"),
TM_YEAR_BASE);
return (false);
}
}
const int* days = daysInMonth[isLeapYear(at)];
if (at.tm_mday > days[at.tm_mon]) {
- _atError(emsg, _("Invalid day of month, %s has only %u days"),
+ _atError(emsg, NLS::TEXT("Invalid day of month, %s has only %u days"),
months[at.tm_mon], days[at.tm_mon]);
return (false);
}
{
cp = whitespace(cp);
if (!isdigit(cp[0])) {
- _atSyntax(emsg, _("expecting number after \"+\""));
+ _atSyntax(emsg, NLS::TEXT("expecting number after \"+\""));
return (false);
}
int v = 0;
v = v*10 + (*cp - '0');
cp = whitespace(cp);
if (*cp == '\0') {
- _atSyntax(emsg, _("\"+%u\" without unit"), v);
+ _atSyntax(emsg, NLS::TEXT("\"+%u\" without unit"), v);
return (false);
}
if (streq(cp, "minute", 6))
} else if (streq(cp, "year", 4))
at.tm_year += v;
else {
- _atError(emsg, _("Unknown increment unit \"%s\""), cp);
+ _atError(emsg, NLS::TEXT("Unknown increment unit \"%s\""), cp);
return (false);
}
return (true);
{
va_list ap;
va_start(ap, fmt);
- emsg = _("Syntax error, ") | fxStr::vformat(fmt, ap);
+ emsg = NLS::TEXT("Syntax error, ") | fxStr::vformat(fmt, ap);
va_end(ap);
}
#include <ctype.h>
+#include "NLS.h"
+
/*
* Interpolation points in replacement strings have
* the META bit or'd together with their match identifier.
ok = parseRules();
fclose(fp);
} else if (shouldExist)
- parseError(_("Cannot open file \"%s\" for reading"),
+ parseError(NLS::TEXT("Cannot open file \"%s\" for reading"),
(const char*) filename);
return (ok);
}
DialStringRules::def(const fxStr& var, const fxStr& value)
{
if (verbose)
- traceParse(_("Define %s = \"%s\""),
+ traceParse(NLS::TEXT("Define %s = \"%s\""),
(const char*) var, (const char*) value);
(*vars)[var] = value;
}
DialStringRules::undef(const fxStr& var)
{
if (verbose)
- traceParse(_("Undefine %s"), (const char*) var);
+ traceParse(NLS::TEXT("Undefine %s"), (const char*) var);
vars->remove(var);
}
while ((cp = nextLine(line, sizeof (line)))) {
// collect token
if (!isalpha(*cp)) {
- parseError(_("Syntax error, expecting identifier"));
+ parseError(NLS::TEXT("Syntax error, expecting identifier"));
return (false);
}
const char* tp = cp;
if (*cp == ':' && cp[1] == '=') { // rule set definition
for (cp += 2; *cp != '['; cp++)
if (*cp == '\0') {
- parseError(_("Missing '[' while parsing rule set"));
+ parseError(NLS::TEXT("Missing '[' while parsing rule set"));
return (false);
}
if (verbose)
return (false);
def(var, value);
} else { // an error
- parseError(_("Missing '=' or ':=' after \"%s\""), (const char*) var);
+ parseError(NLS::TEXT("Missing '=' or ':=' after \"%s\""), (const char*) var);
return (false);
}
}
if (verbose) {
RuleArray* ra = (*rules)["CanonicalNumber"];
if (ra == 0)
- traceParse(_("Warning, no \"CanonicalNumber\" rules."));
+ traceParse(NLS::TEXT("Warning, no \"CanonicalNumber\" rules."));
ra = (*rules)["DialString"];
if (ra == 0)
- traceParse(_("Warning, no \"DialString\" rules."));
+ traceParse(NLS::TEXT("Warning, no \"DialString\" rules."));
}
return (true);
}
tp = ++cp;
for (;;) {
if (*cp == '\0') {
- parseError(_("String with unmatched '\"'"));
+ parseError(NLS::TEXT("String with unmatched '\"'"));
return (NULL);
}
if (*cp == '\\' && cp[1] == '\0') {
- parseError(_("Bad '\\' escape sequence"));
+ parseError(NLS::TEXT("Bad '\\' escape sequence"));
return (NULL);
}
if (*cp == '"' && (cp == tp || cp[-1] != '\\'))
} else { // token terminated by white space
for (tp = cp; *cp != '\0'; cp++) {
if (*cp == '\\' && cp[1] == '\0') {
- parseError(_("Bad '\\' escape sequence"));
+ parseError(NLS::TEXT("Bad '\\' escape sequence"));
return (NULL);
}
if (isspace(*cp) && (cp == tp || cp[-1] != '\\'))
*/
u_int l = v.next(i, '}');
if (l >= v.length()) {
- parseError(_("Missing '}' for variable reference"));
+ parseError(NLS::TEXT("Missing '}' for variable reference"));
return (NULL);
}
fxStr var = v.cut(i+2,l-(i+2));// variable name
char line[1024];
const char* cp = nextLine(line, sizeof (line));
if (!cp) {
- parseError(_("Missing ']' while parsing rule set"));
+ parseError(NLS::TEXT("Missing ']' while parsing rule set"));
return (false);
}
if (*cp == ']')
while (isspace(*cp))
cp++;
if (*cp != '=') {
- parseError(_("Rule pattern without '='"));
+ parseError(NLS::TEXT("Rule pattern without '='"));
return (false);
}
DialRule r;
DialStringRules::applyRules(const fxStr& name, const fxStr& s)
{
if (verbose)
- traceRules(_("Apply %s rules to \"%s\""),
+ traceRules(NLS::TEXT("Apply %s rules to \"%s\""),
(const char*) name, (const char*) s);
fxStr result(s);
RuleArray* ra = (*rules)[name];
result.insert(replace, ix);
off = ix + replace.length(); // skip replace when searching
if (verbose)
- traceRules(_("--> match rule \"%s\", result now \"%s\""),
+ traceRules(NLS::TEXT("--> match rule \"%s\", result now \"%s\""),
rule.pat->pattern(), (const char*) result);
}
}
}
if (verbose)
- traceRules(_("--> return result \"%s\""), (const char*) result);
+ traceRules(NLS::TEXT("--> return result \"%s\""), (const char*) result);
return result;
}
{
va_list ap;
va_start(ap, fmt);
- fprintf(stderr, _("%s: line %u: "), (const char*) filename, lineno);
+ fprintf(stderr, NLS::TEXT("%s: line %u: "), (const char*) filename, lineno);
vfprintf(stderr, fmt, ap);
va_end(ap);
putc('\n', stderr);
{
va_list ap;
va_start(ap, fmt);
- fprintf(stdout, _("%s: line %u: "), (const char*) filename, lineno);
+ fprintf(stdout, NLS::TEXT("%s: line %u: "), (const char*) filename, lineno);
vfprintf(stdout, fmt, ap);
va_end(ap);
putc('\n', stdout);
#include <sys/mman.h>
#endif
+#include "NLS.h"
+
#define N(a) (sizeof (a) / sizeof (a[0]))
FaxClient::FaxClient()
void
FaxClient::vprintWarning(const char* fmt, va_list ap)
{
- fprintf(stderr, _("Warning, "));
+ fprintf(stderr, NLS::TEXT("Warning, "));
vfprintf(stderr, fmt, ap);
fputs("\n", stderr);
}
if (name)
userName = name;
else {
- emsg = fxStr::format(_("Can not locate your password entry "
+ emsg = fxStr::format(NLS::TEXT("Can not locate your password entry "
"(uid %lu): %s"), (u_long) getuid(), strerror(errno));
return (false);
}
} else
senderName = userName;
if (senderName.length() == 0) {
- emsg = _("Bad (null) user name; your password file entry"
+ emsg = NLS::TEXT("Bad (null) user name; your password file entry"
" probably has bogus GECOS field information.");
return (false);
} else
user = userName;
}
if (*user == '\0') {
- emsg = _("Malformed (null) username");
+ emsg = NLS::TEXT("Malformed (null) username");
return (false);
}
int n = command("USER %s", user);
}
return (true);
} else {
- emsg = _("Login failed: ") | lastResponse;
+ emsg = NLS::TEXT("Login failed: ") | lastResponse;
return (false);
}
}
FaxClient::admin(const char* pass, fxStr& emsg)
{
if (command("ADMIN %s", pass ? pass : getpass("Password:")) != COMPLETE) {
- emsg = _("Admin failed: ") | lastResponse;
+ emsg = NLS::TEXT("Admin failed: ") | lastResponse;
return (false);
} else
return (true);
return (false);
}
} else {
- printError(_("Bad %s parameter value %u."), parm.cmd, v);
+ printError(NLS::TEXT("Bad %s parameter value %u."), parm.cmd, v);
return (false);
}
this->*parm.pv = v;
if (v == TZ_GMT) state &= ~FS_TZPEND;
else state |= FS_TZPEND;
} else {
- printError(_("Bad time zone parameter value %u."), v);
+ printError(NLS::TEXT("Bad time zone parameter value %u."), v);
return (false);
}
return (true);
if (transport) {
if (!transport->initDataConn(emsg)) {
if (emsg == "") {
- emsg = _("Unable to initialize data connection to server");
+ emsg = NLS::TEXT("Unable to initialize data connection to server");
}
return (false);
}
if (transport) {
if (!transport->openDataConn(emsg)) {
if (emsg == "") {
- emsg = _("Unable to open data connection to server");
+ emsg = NLS::TEXT("Unable to open data connection to server");
}
return (false);
}
fflush(fdOut);
if (!transport->abortCmd(emsg)) {
if (emsg == "") {
- emsg = _("Unable to abort data connection to server");
+ emsg = NLS::TEXT("Unable to abort data connection to server");
}
return (false);
}
void
FaxClient::lostServer(void)
{
- printError(_("Service not available, remote server closed connection"));
+ printError(NLS::TEXT("Service not available, remote server closed connection"));
hangupServer();
}
void
FaxClient::unexpectedResponse(fxStr& emsg)
{
- emsg = _("Unexpected server response: ") | lastResponse;
+ emsg = NLS::TEXT("Unexpected server response: ") | lastResponse;
}
void
{
va_list ap;
va_start(ap, fmt);
- emsg = _("Protocol botch") | fxStr::vformat(fmt, ap);
+ emsg = NLS::TEXT("Protocol botch") | fxStr::vformat(fmt, ap);
va_end(ap);
}
} else {
line = (char *)malloc(100);
if (line == NULL)
- printError(_("Memory allocation failed"));
+ printError(NLS::TEXT("Memory allocation failed"));
else {
vsnprintf(line, 100, fmt, ap);
traceServer("-> %s", line);
}
}
if (fdOut == NULL) {
- printError(_("No control connection for command"));
+ printError(NLS::TEXT("No control connection for command"));
code = -1;
return (0);
}
l = lastResponse.find(pos, pat);
}
if (l == lastResponse.length()) {
- protocolBotch(emsg, _(": No \"%s\" in %s response: %s"),
+ protocolBotch(emsg, NLS::TEXT(": No \"%s\" in %s response: %s"),
pattern, cmd, (const char*) lastResponse);
return false;
}
l = lastResponse.skip(l+pat.length(), ' ');// skip white space
result = lastResponse.extract(l, lastResponse.next(l, ' ')-l);
if (result == "") {
- protocolBotch(emsg, _(": Null %s in %s response: %s"),
+ protocolBotch(emsg, NLS::TEXT(": Null %s in %s response: %s"),
pattern, cmd, (const char*) lastResponse);
return false;
}
ok = runScript(fd, filename, emsg);
fclose(fd);
} else
- emsg = fxStr::format(_("Unable to open script file \"%s\"."), filename);
+ emsg = fxStr::format(NLS::TEXT("Unable to open script file \"%s\"."), filename);
return (ok);
}
if (Sys::read(fileno(fp), addr, (u_int) sb.st_size) == sb.st_size)
ok = runScript(addr, sb.st_size, filename, emsg);
else
- emsg = fxStr::format(_("%s: Read error: %s"),
+ emsg = fxStr::format(NLS::TEXT("%s: Read error: %s"),
filename, strerror(errno));
delete [] addr;
#if HAS_MMAP
u_int cmdLen = ep-script;
if (cmdLen > 1) {
if (command("%.*s", cmdLen, script) != COMPLETE) {
- emsg = fxStr::format(_("%s: line %u: %s"),
+ emsg = fxStr::format(NLS::TEXT("%s: line %u: %s"),
filename, lineno, (const char*) lastResponse);
return (false);
}
for (int cnt, sent = 0; cc; sent += cnt, cc -= cnt)
if ((cnt = write(fdData, bp + sent, cc)) <= 0) {
protocolBotch(emsg, errno == EPIPE ?
- _(" (server closed connection)") : _(" (server write error: %s)."),
+ NLS::TEXT(" (server closed connection)") : _(" (server write error: %s)."),
strerror(errno));
return (false);
}
#else
if (write(fdData, buf, cc) != cc) {
protocolBotch(emsg, errno == EPIPE ?
- _(" (server closed connection)") : _(" (server write error: %s)."),
+ NLS::TEXT(" (server closed connection)") : _(" (server write error: %s)."),
strerror(errno));
return (false);
}
size_t cc;
(void) Sys::fstat(fd, sb);
if (getVerbose())
- traceServer(_("SEND data, %lu bytes"), (u_long) sb.st_size);
+ traceServer(NLS::TEXT("SEND data, %lu bytes"), (u_long) sb.st_size);
if (!initDataConn(emsg))
goto bad;
if (!setMode(MODE_S))
char buf[32*1024]; // XXX better if page-aligned
size_t n = fxmin(cc, sizeof (buf));
if (read(fd, buf, n) != (ssize_t)n) {
- protocolBotch(emsg, _(" (data read: %s)."), strerror(errno));
+ protocolBotch(emsg, NLS::TEXT(" (data read: %s)."), strerror(errno));
goto bad;
}
if (!sendRawData(buf, n, emsg))
size_t cc;
Sys::fstat(fd, sb);
if (getVerbose())
- traceServer(_("SEND compressed data, %lu bytes"), (u_long) sb.st_size);
+ traceServer(NLS::TEXT("SEND compressed data, %lu bytes"), (u_long) sb.st_size);
if (!initDataConn(emsg))
goto bad;
if (!setMode(MODE_Z))
char buf[32*1024];
int n = fxmin((size_t) cc, sizeof (buf));
if (read(fd, buf, n) != n) {
- protocolBotch(emsg, _(" (data read: %s)"), strerror(errno));
+ protocolBotch(emsg, NLS::TEXT(" (data read: %s)"), strerror(errno));
goto bad;
}
zstream.next_in = (Bytef*) buf;
zstream.avail_in = n;
do {
if (deflate(&zstream, Z_NO_FLUSH) != Z_OK) {
- emsg = fxStr::format(_("zlib compressor error: %s"),
+ emsg = fxStr::format(NLS::TEXT("zlib compressor error: %s"),
zstream.msg);
goto bad;
}
zstream.avail_in = (u_int) sb.st_size;
do {
if (deflate(&zstream, Z_NO_FLUSH) != Z_OK) {
- emsg = fxStr::format(_("zlib compressor error: %s"),
+ emsg = fxStr::format(NLS::TEXT("zlib compressor error: %s"),
zstream.msg);
goto bad;
}
}
break;
default:
- emsg = fxStr::format(_("zlib compressor error: %s"),
+ emsg = fxStr::format(NLS::TEXT("zlib compressor error: %s"),
zstream.msg);
goto bad;
}
} while (dstate != Z_STREAM_END);
if (getVerbose())
- traceServer(_("SEND %lu bytes transmitted (%.1fx compression)"),
+ traceServer(NLS::TEXT("SEND %lu bytes transmitted (%.1fx compression)"),
#define NZ(x) ((x)?(x):1)
zstream.total_out, float(sb.st_size) / NZ(zstream.total_out));
closeDataConn();
#endif
deflateEnd(&zstream);
} else
- emsg = fxStr::format(_("Can not initialize compression library: %s"),
+ emsg = fxStr::format(NLS::TEXT("Can not initialize compression library: %s"),
zstream.msg);
return (false);
}
return (getReply(false) == COMPLETE);
}
if (cc < 0) {
- emsg = fxStr::format(_("Data Connection: %s"), strerror(errno));
+ emsg = fxStr::format(NLS::TEXT("Data Connection: %s"), strerror(errno));
(void) getReply(false);
break;
}
return (getReply(false) == COMPLETE);
}
if (cc < 0) {
- emsg = fxStr::format(_("Data Connection: %s"), strerror(errno));
+ emsg = fxStr::format(NLS::TEXT("Data Connection: %s"), strerror(errno));
(void) getReply(false);
goto bad;
}
if (dstate == Z_STREAM_END)
break;
if (dstate != Z_OK) {
- emsg = fxStr::format(_("Decoding error: %s"), zstream.msg);
+ emsg = fxStr::format(NLS::TEXT("Decoding error: %s"), zstream.msg);
goto bad;
}
size_t occ = sizeof (obuf) - zstream.avail_out;
closeDataConn();
inflateEnd(&zstream);
} else
- emsg = fxStr::format(_("Can not initialize decoder: %s"), zstream.msg);
+ emsg = fxStr::format(NLS::TEXT("Can not initialize decoder: %s"), zstream.msg);
return (false);
}
if (fspec[1] == '-') // left justify
width = -width;
if (width == 0 && prec == 0)
- header.append(_(hp->title));
+ header.append(NLS::TEXT(hp->title));
else
- header.append(fxStr::format("%*.*s", width, prec, _(hp->title)));
+ header.append(fxStr::format("%*.*s", width, prec, NLS::TEXT(hp->title)));
} else {
*fp++ = c;
header.append(fxStr(fspec, fp-fspec));
#include <pwd.h>
#include "Sys.h"
+#include "NLS.h"
+
FaxConfig::FaxConfig()
{
{
FILE* fd = Sys::fopen(tildeExpand(filename), "r");
if (fd) {
- configTrace(_("Read config file %s"), (const char*) filename);
+ configTrace(NLS::TEXT("Read config file %s"), (const char*) filename);
char line[1024];
while (fgets(line, sizeof (line)-1, fd)){
line[strlen(line)-1]='\0'; // Nuke \r at end of line
if (!cp || *cp == '\0') {
struct passwd* pwd = getpwuid(getuid());
if (!pwd) {
- configError(_("No passwd file entry for uid %u,"
+ configError(NLS::TEXT("No passwd file entry for uid %u,"
" cannot expand ~ in \"%s\""),
getuid(), (const char*) filename);
cp = ""; // NB: XXX maybe this should be fatal?
cp++;
}
if (*cp != ':') {
- configError(_("Syntax error at line %u, missing ':' in \"%s\""),
+ configError(NLS::TEXT("Syntax error at line %u, missing ':' in \"%s\""),
lineno, b);
return (false);
}
char* dp = ++cp;
for (value = dp; (c = *cp) != '"'; cp++) {
if (c == '\0') { // unmatched quote mark
- configError(_("Syntax error at line %u, missing quote mark in \"%s\""),
+ configError(NLS::TEXT("Syntax error at line %u, missing quote mark in \"%s\""),
lineno, b);
return (false);
}
if (streq(tag, "include") ) {
u_int old_lineno = lineno;
- configTrace(_("%s = %s (line %u)"), tag, value, lineno);
+ configTrace(NLS::TEXT("%s = %s (line %u)"), tag, value, lineno);
lineno = 0;
readConfig(value);
lineno = old_lineno;
return (true);
}
if (!setConfigItem(tag, value)) {
- configTrace(_("Unknown configuration parameter \"%s\" ignored at line %u"),
+ configTrace(NLS::TEXT("Unknown configuration parameter \"%s\" ignored at line %u"),
tag, lineno);
return (false);
} else {
- configTrace(_("%s = %s (line %u)"), tag, value, lineno);
+ configTrace(NLS::TEXT("%s = %s (line %u)"), tag, value, lineno);
return (true);
}
}
*/
#include "FaxDB.h"
#include "RE.h"
+#include "NLS.h"
+
FaxDBRecord::FaxDBRecord()
{
while (getToken(fd, key)) {
if (key == "]") {
if (parent == 0)
- fprintf(stderr, _("%s: line %d: Unmatched \"]\".\n"),
+ fprintf(stderr, NLS::TEXT("%s: line %d: Unmatched \"]\".\n"),
(const char*) filename, lineno);
break;
}
if (!getToken(fd, value))
break;
if (value != ":") {
- fprintf(stderr, _("%s: line %d: Missing \":\" separator.\n"),
+ fprintf(stderr, NLS::TEXT("%s: line %d: Missing \":\" separator.\n"),
(const char*) filename, lineno);
continue;
}
if (c == '\\') {
c = getc(fd);
if (c == EOF) {
- fprintf(stderr, _("%s: Premature EOF.\n"), (const char*) filename);
+ fprintf(stderr, NLS::TEXT("%s: Premature EOF.\n"), (const char*) filename);
return (false);
}
// XXX handle standard escapes
#include "FaxClient.h"
#include "InetTransport.h"
#include "Sys.h"
+#include "NLS.h"
+
InetTransport::InetTransport(FaxClient& c) : Transport(c) {}
InetTransport::~InetTransport(){}
const char* cproto = proto; // XXX for busted include files
struct protoent* pp = getprotobyname(cproto);
if (!pp) {
- client.printWarning(_("%s: No protocol definition, using default."),
+ client.printWarning(NLS::TEXT("%s: No protocol definition, using default."),
cproto);
protocol = 0;
} else
struct hostent* hp = Socket::gethostbyname(client.getHost());
if (!hp) {
- emsg = client.getHost() | _(": Unknown host");
+ emsg = client.getHost() | NLS::TEXT(": Unknown host");
return (false);
}
int fd = socket(hp->h_addrtype, SOCK_STREAM, protocol);
if (fd < 0) {
- emsg = _("Can not create socket to connect to server.");
+ emsg = NLS::TEXT("Can not create socket to connect to server.");
return (false);
}
struct sockaddr_in sin;
if (!sp) {
if (!isdigit(cproto[0])) {
client.printWarning(
- _("No \"%s\" service definition, using default %u/%s."),
+ NLS::TEXT("No \"%s\" service definition, using default %u/%s."),
FAX_SERVICE, FAX_DEFPORT, cproto);
sin.sin_port = htons(FAX_DEFPORT);
} else
for (char** cpp = hp->h_addr_list; *cpp; cpp++) {
memcpy(&sin.sin_addr, *cpp, hp->h_length);
if (client.getVerbose())
- client.traceServer(_("Trying %s (%s) at port %u..."),
+ client.traceServer(NLS::TEXT("Trying %s (%s) at port %u..."),
(const char*) client.getHost(),
inet_ntoa(sin.sin_addr),
ntohs(sin.sin_port));
if (Socket::connect(fd, &sin, sizeof (sin)) >= 0) {
if (client.getVerbose())
- client.traceServer(_("Connected to %s."), hp->h_name);
+ client.traceServer(NLS::TEXT("Connected to %s."), hp->h_name);
#if defined(IP_TOS) && defined(IPTOS_LOWDELAY)
int tos = IPTOS_LOWDELAY;
if (Socket::setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof (tos)) < 0)
- client.printWarning(_("setsockopt(TOS): %s (ignored)"),
+ client.printWarning(NLS::TEXT("setsockopt(TOS): %s (ignored)"),
strerror(errno));
#endif
#ifdef SO_OOBINLINE
int on = 1;
if (Socket::setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &on, sizeof (on)) < 0)
- client.printWarning(_("setsockopt(OOBLINE): %s (ignored)"),
+ client.printWarning(NLS::TEXT("setsockopt(OOBLINE): %s (ignored)"),
strerror(errno));
#endif
/*
return (true);
}
}
- emsg = fxStr::format(_("Can not reach server at host \"%s\", port %u."),
+ emsg = fxStr::format(NLS::TEXT("Can not reach server at host \"%s\", port %u."),
(const char*) client.getHost(), ntohs(sin.sin_port));
Sys::close(fd), fd = -1;
return (false);
void
Transport::notConfigured(fxStr& emsg)
{
- emsg = _("Sorry, no TCP/IP communication support was configured.");
+ emsg = NLS::TEXT("Sorry, no TCP/IP communication support was configured.");
}
bool InetTransport::callServer(fxStr& emsg)
* OF THIS SOFTWARE.
*/
#include "NLS.h"
+#include "Types.h"
+#include "Sys.h"
-void
-setupNLS()
+#include <errno.h>
+
+void do_bind (const char* domain, const char* ldir)
+{
+ /* bindtextdomain() doesn't preserver errno */
+ int save_errno = errno;
+
+ if (!ldir)
+ ldir = getenv("HFLOCALEDIR");
+ if (!ldir)
+ ldir = LOCALEDIR;
+ bindtextdomain(domain, ldir);
+ errno = save_errno;
+}
+
+const char* NLS::TEXT (const char* msgid)
+{
+ if (! bound)
+ {
+ bound = true;
+ do_bind(domain, NULL);
+ }
+ return dgettext(domain, msgid);
+}
+
+void NLS::Setup (const char* d, const char* ldir)
{
-#ifdef ENABLE_NLS
setlocale(LC_CTYPE, "");
setlocale(LC_MESSAGES, "");
- bindtextdomain(LOCALE_DOMAIN, LOCALEDIR);
- textdomain(LOCALE_DOMAIN);
-#endif
+
+ /*
+ * We'll take the hit of setting up libhylafax NLS here
+ */
+ do_bind(domain, NULL);
+ bound = true;
+
+ do_bind(d, ldir);
+ textdomain(d);
}
+
+const char* NLS::domain = "libhylafax";
+bool NLS::bound = false;
#ifndef _NLS_
#define _NLS_
-#include "config.h"
-
-extern void setupNLS();
+#include "Types.h"
-#define _(String) gettext(String)
-#define N_(String) gettext_noop(String)
-#define gettext_noop(String) String
-
-#ifdef ENABLE_NLS
+#include "config.h"
-#include <locale.h>
-#include <libintl.h>
+class NLS
+{
+ public:
+ static const char* TEXT (const char*);
-#ifdef NEED_NGETTEXT
-#define ngettext(s1,s2,n) (n ==1 ? gettext(s1) : gettext(s2))
-#endif
+ static void Setup (const char* domain, const char* local_dir = NULL);
-#else /* ENABLE_NLS */
-#define gettext(String) (String)
-#define textdomain(Domain) do {} while()
-#define bindtextdomain(Package, Directory) do {} while()
-#define ngettext(s1, s2, n) (n==1?s1:s2)
+ static const char* domain;
-#endif /* ENABLE_NLS */
+ private:
+ static bool bound;
+};
#endif /* _NLS_ */
* OF THIS SOFTWARE.
*/
#include "Obj.h"
+#include "NLS.h"
extern "C" void abort();
void fxObj::subClassMustDefine(const char* method) const
{
- fprintf(stderr, _("%s: Sub class must define method \"%s\".\n"),
+ fprintf(stderr, NLS::TEXT("%s: Sub class must define method \"%s\".\n"),
className(), method);
abort();
}
#include <ctype.h>
#include <stdlib.h>
+#include "NLS.h"
+
fxDECLARE_StructArray(PageInfoArray, PageInfo)
fxIMPLEMENT_StructArray(PageInfoArray, PageInfo)
{
va_list ap;
va_start(ap, fmt);
- fprintf(stderr, _("%s: line %u: "), file, lineno);
+ fprintf(stderr, NLS::TEXT("%s: line %u: "), file, lineno);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
cp++;
if (*cp == '\0') {
parseError(file, lineno,
- _("Unexpected end of line after \"%s\".\n"), item);
+ NLS::TEXT("Unexpected end of line after \"%s\".\n"), item);
return (false);
} else
return (true);
pi.name = cp;
while (*cp != '\t')
cp++;
- if (!skipws(cp, file, _("page size name"), lineno))
+ if (!skipws(cp, file, NLS::TEXT("page size name"), lineno))
continue;
pi.abbr = cp;
while (*cp != '\t')
cp++;
- if (!skipws(cp, file, _("page size abbreviation"), lineno))
+ if (!skipws(cp, file, NLS::TEXT("page size abbreviation"), lineno))
continue;
pi.w = (BMU) strtoul(cp, &cp, 10);
- if (!skipws(cp, file, _("page width"), lineno))
+ if (!skipws(cp, file, NLS::TEXT("page width"), lineno))
continue;
pi.h = (BMU) strtoul(cp, &cp, 10);
- if (!skipws(cp, file, _("page height"), lineno))
+ if (!skipws(cp, file, NLS::TEXT("page height"), lineno))
continue;
pi.grw = (BMU) strtoul(cp, &cp, 10);
- if (!skipws(cp, file, _("guaranteed page width"), lineno))
+ if (!skipws(cp, file, NLS::TEXT("guaranteed page width"), lineno))
continue;
pi.grh = (BMU) strtoul(cp, &cp, 10);
- if (!skipws(cp, file, _("guaranteed page height"), lineno))
+ if (!skipws(cp, file, NLS::TEXT("guaranteed page height"), lineno))
continue;
pi.top = (BMU) strtoul(cp, &cp, 10);
- if (!skipws(cp, file, _("top margin"), lineno))
+ if (!skipws(cp, file, NLS::TEXT("top margin"), lineno))
continue;
pi.left = (BMU) strtoul(cp, &cp, 10);
pi.name = strdup(pi.name);
fclose(fp);
} else {
fprintf(stderr,
- _("Warning, no page size database file \"%s\", using builtin default.\n"),
+ NLS::TEXT("Warning, no page size database file \"%s\", using builtin default.\n"),
(const char*)file);
PageInfo pi;
pi.name = strdup("default");
#define N(a) (sizeof (a) / sizeof (a[0]))
+#include "NLS.h"
+
SNPPClient::SNPPClient()
{
init();
void
SNPPClient::vprintWarning(const char* fmt, va_list ap)
{
- fprintf(stderr, _("Warning, "));
+ fprintf(stderr, NLS::TEXT("Warning, "));
vfprintf(stderr, fmt, ap);
fputs("\n", stderr);
}
}
fxStr mbox;
if (senderName == "" || !getNonBlankMailbox(mbox)) {
- emsg = _("Malformed (null) sender name or mail address");
+ emsg = NLS::TEXT("Malformed (null) sender name or mail address");
return (false);
} else
return (true);
pwd = getpwuid(getuid());
if (!pwd) {
emsg = fxStr::format(
- _("Can not locate your password entry (uid %lu): %s."),
+ NLS::TEXT("Can not locate your password entry (uid %lu): %s."),
(u_long) getuid(), strerror(errno));
return (false);
}
} else
senderName = userName;
if (senderName.length() == 0) {
- emsg = _("Bad (null) user name; your password file entry"
+ emsg = NLS::TEXT("Bad (null) user name; your password file entry"
" probably has bogus GECOS field information.");
return (false);
} else
} else if (streq(tag, "holdtime")) {
fxStr emsg;
if (!jproto.setHoldTime(tag, emsg))
- configError(_("Invalid hold time \"%s\": %s"),
+ configError(NLS::TEXT("Invalid hold time \"%s\": %s"),
value, (const char*) emsg);
} else if (streq(tag, "retrytime")) {
jproto.setRetryTime(value);
}
struct hostent* hp = Socket::gethostbyname(getHost());
if (!hp) {
- emsg = getHost() | _(": Unknown host");
+ emsg = getHost() | NLS::TEXT(": Unknown host");
return (false);
}
int protocol;
const char* cproto = proto; // XXX for busted include files
struct protoent* pp = getprotobyname(cproto);
if (!pp) {
- printWarning(_("%s: No protocol definition, using default."), cproto);
+ printWarning(NLS::TEXT("%s: No protocol definition, using default."), cproto);
protocol = 0;
} else
protocol = pp->p_proto;
int fd = socket(hp->h_addrtype, SOCK_STREAM, protocol);
if (fd < 0) {
- emsg = _("Can not create socket to connect to server.");
+ emsg = NLS::TEXT("Can not create socket to connect to server.");
return (false);
}
struct sockaddr_in sin;
if (!sp) {
if (!isdigit(cproto[0])) {
printWarning(
- _("No \"%s\" service definition, using default %u/%s."),
+ NLS::TEXT("No \"%s\" service definition, using default %u/%s."),
SNPP_SERVICE, SNPP_DEFPORT, cproto);
sin.sin_port = htons(SNPP_DEFPORT);
} else
for (char** cpp = hp->h_addr_list; *cpp; cpp++) {
memcpy(&sin.sin_addr, *cpp, hp->h_length);
if (getVerbose())
- traceServer(_("Trying %s (%s) at port %u..."),
+ traceServer(NLS::TEXT("Trying %s (%s) at port %u..."),
(const char*) getHost(),
inet_ntoa(sin.sin_addr),
ntohs(sin.sin_port));
if (Socket::connect(fd, &sin, sizeof (sin)) >= 0) {
if (getVerbose())
- traceServer(_("Connected to %s."), hp->h_name);
+ traceServer(NLS::TEXT("Connected to %s."), hp->h_name);
#if defined(IP_TOS) && defined(IPTOS_LOWDELAY)
int tos = IPTOS_LOWDELAY;
if (Socket::setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof (tos)) < 0)
- printWarning(_("setsockopt(TOS): %s (ignored)"),
+ printWarning(NLS::TEXT("setsockopt(TOS): %s (ignored)"),
strerror(errno));
#endif
#ifdef SO_OOBINLINE
int on = 1;
if (Socket::setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &on, sizeof (on)) < 0)
- printWarning(_("setsockopt(OOBLINE): %s (ignored)"),
+ printWarning(NLS::TEXT("setsockopt(OOBLINE): %s (ignored)"),
strerror(errno));
#endif
setCtrlFds(fd, fd);
return (true);
}
}
- emsg = fxStr::format(_("Can not reach server at host \"%s\", port %u."),
+ emsg = fxStr::format(NLS::TEXT("Can not reach server at host \"%s\", port %u."),
(const char*) getHost(), ntohs(sin.sin_port));
close(fd), fd = -1;
return (false);
bool
SNPPServer::callInetServer(fxStr& emsg)
{
- emsg = _("Sorry, no TCP/IP communication support was configured.");
+ emsg = NLS::TEXT("Sorry, no TCP/IP communication support was configured.");
return (false);
}
#endif
state &= ~SS_HASSITE;
return (true);
} else {
- emsg = _("Login failed: ") | lastResponse;
+ emsg = NLS::TEXT("Login failed: ") | lastResponse;
return (false);
}
}
void
SNPPClient::lostServer(void)
{
- printError(_("Service not available, remote server closed connection"));
+ printError(NLS::TEXT("Service not available, remote server closed connection"));
hangupServer();
}
void
SNPPClient::unexpectedResponse(fxStr& emsg)
{
- emsg = _("Unexpected server response: ") | lastResponse;
+ emsg = NLS::TEXT("Unexpected server response: ") | lastResponse;
}
void
{
va_list ap;
va_start(ap, fmt);
- emsg = _("Protocol botch") | fxStr::vformat(fmt, ap);
+ emsg = NLS::TEXT("Protocol botch") | fxStr::vformat(fmt, ap);
va_end(ap);
}
}
}
if (fdOut == NULL) {
- printError(_("No control connection for command"));
+ printError(NLS::TEXT("No control connection for command"));
code = -1;
return (0);
}
SNPPClient::submitJobs(fxStr& emsg)
{
if (!isLoggedIn()) {
- emsg = _("Not logged in to server");
+ emsg = NLS::TEXT("Not logged in to server");
return (false);
}
/*
void
SNPPClient::notifyNewJob(const SNPPJob& job)
{
- printf(_("destination pin %s: request id is %s for host %s\n")
+ printf(NLS::TEXT("destination pin %s: request id is %s for host %s\n")
, (const char*) job.getPIN()
, (const char*) job.getJobID()
, (const char*) getHost()
for (int cnt, sent = 0; cc; sent += cnt, cc -= cnt)
if ((cnt = write(fileno(fdOut), bp + sent, cc)) <= 0) {
protocolBotch(emsg, errno == EPIPE ?
- _(" (server closed connection)") : _(" (server write error: %s)."),
+ NLS::TEXT(" (server closed connection)") : _(" (server write error: %s)."),
strerror(errno));
return (false);
}
#else
if (write(fileno(fdOut), buf, cc) != cc) {
protocolBotch(emsg, errno == EPIPE ?
- _(" (server closed connection)") : _(" (server write error: %s)."),
+ NLS::TEXT(" (server closed connection)") : _(" (server write error: %s)."),
strerror(errno));
return (false);
}
struct stat sb;
(void) Sys::fstat(fd, sb);
if (getVerbose())
- traceServer(_("SEND message data, %lu bytes"), (u_long) sb.st_size);
+ traceServer(NLS::TEXT("SEND message data, %lu bytes"), (u_long) sb.st_size);
if (command("DATA") == CONTINUE) {
size_t cc = (size_t) sb.st_size;
while (cc > 0) {
char buf[32*1024];
size_t n = fxmin(cc, sizeof (buf));
if (read(fd, buf, n) != (ssize_t) n) {
- protocolBotch(emsg, _(" (data read: %s)."), strerror(errno));
+ protocolBotch(emsg, NLS::TEXT(" (data read: %s)."), strerror(errno));
return (false);
}
if (!sendRawData(buf, n, emsg))
ok = sendData(fd, emsg);
Sys::close(fd);
} else
- emsg = fxStr::format(_("Unable to open message file \"%s\"."),
+ emsg = fxStr::format(NLS::TEXT("Unable to open message file \"%s\"."),
(const char*) filename);
return (ok);
}
SNPPClient::siteParm(const char* name, const fxStr& value)
{
if (!hasSiteCmd()) {
- printWarning(_("no SITE %s support; ignoring set request."), name);
+ printWarning(NLS::TEXT("no SITE %s support; ignoring set request."), name);
return (true);
} else
return (command("SITE %s %s", name, (const char*) value) == COMPLETE);
SNPPClient::siteParm(const char* name, u_int value)
{
if (!hasSiteCmd()) {
- printWarning(_("no SITE %s support; ignoring set request."), name);
+ printWarning(NLS::TEXT("no SITE %s support; ignoring set request."), name);
return (true);
} else
return (command("SITE %s %u", name, value) == COMPLETE);
#include "TypeRules.h"
#include "DialRules.h"
#include "Array.h"
+#include "NLS.h"
+
struct FileInfo : public fxObj {
fxStr name; // user-specified document file
if (typeRules == NULL) {
typeRules = TypeRules::read(typeRulesFile);
if (!typeRules) {
- emsg = _("Unable to setup file typing and conversion rules");
+ emsg = NLS::TEXT("Unable to setup file typing and conversion rules");
return (false);
}
}
if (job.getPageWidth() != 0 && job.getPageLength() != 0)
continue;
if (!job.setPageSize(job.getPageSize())) {
- emsg = _("Unknown page size ") | job.getPageSize();
+ emsg = NLS::TEXT("Unknown page size ") | job.getPageSize();
return (false);
}
}
pid_t pid = fork();
switch (pid) {
case -1: // error
- emsg = fxStr::format(_("Error creating cover sheet; "
+ emsg = fxStr::format(NLS::TEXT("Error creating cover sheet; "
"could not fork subprocess: %s"), strerror(errno));
Sys::close(pfd[1]);
break;
file = tmpFile;
return (true);
}
- emsg = fxStr::format(_("Error creating cover sheet; "
+ emsg = fxStr::format(NLS::TEXT("Error creating cover sheet; "
"command was \"%s\"; exit status %x")
, (const char*) joinargs(coverCmd, av)
, status
}
Sys::close(pfd[0]);
} else {
- emsg = fxStr::format(_("Error creating cover sheet; "
+ emsg = fxStr::format(NLS::TEXT("Error creating cover sheet; "
"unable to create pipe to subprocess: %s"), strerror(errno));
}
#undef MAXARGS
} else
- emsg = fxStr::format(_("%s: Can not create temporary file for cover page"),
+ emsg = fxStr::format(NLS::TEXT("%s: Can not create temporary file for cover page"),
(const char*) tmpFile);
Sys::unlink(tmpFile);
return (false);
SendFaxClient::submitJobs(fxStr& emsg)
{
if (!setup) {
- emsg = _("Documents not prepared");
+ emsg = NLS::TEXT("Documents not prepared");
return (false);
}
if (!isLoggedIn()) {
- emsg = _("Not logged in to server");
+ emsg = NLS::TEXT("Not logged in to server");
return (false);
}
/*
FileInfo& info = (*files)[i];
int fd = Sys::open(info.temp, O_RDONLY);
if (fd < 0) {
- emsg = fxStr::format(info.temp | _(": Can not open: %s"),
+ emsg = fxStr::format(info.temp | NLS::TEXT(": Can not open: %s"),
strerror(errno));
return (false); // XXX
}
Sys::close(fd);
if (!fileSent) {
if (emsg == "")
- emsg = _("Document transfer failed: ") | getLastResponse();
+ emsg = NLS::TEXT("Document transfer failed: ") | getLastResponse();
return (false);
}
}
}
fxStr mbox;
if (senderName == "" || !getNonBlankMailbox(mbox)) {
- emsg = _("Malformed (null) sender name or mail address");
+ emsg = NLS::TEXT("Malformed (null) sender name or mail address");
return (false);
} else
return (true);
printf("CONVERT \"%s\"\n", (const char*) sysCmd);
if (system(sysCmd) != 0) {
Sys::unlink(tmpFile);
- emsg = fxStr::format(_("Error converting document; command was \"%s\""),
+ emsg = fxStr::format(NLS::TEXT("Error converting document; command was \"%s\""),
(const char*) sysCmd);
return (false);
}
struct stat sb;
int fd = Sys::open(filename, O_RDONLY);
if (fd < 0) {
- emsg = fxStr::format(_("%s: Can not open file"), filename);
+ emsg = fxStr::format(NLS::TEXT("%s: Can not open file"), filename);
return (NULL);
}
if (Sys::fstat(fd, sb) < 0) {
- emsg = fxStr::format(_("%s: Can not stat file"), filename);
+ emsg = fxStr::format(NLS::TEXT("%s: Can not stat file"), filename);
Sys::close(fd);
return (NULL);
}
if ((sb.st_mode & S_IFMT) != S_IFREG) {
- emsg = fxStr::format(_("%s: Not a regular file"), filename);
+ emsg = fxStr::format(NLS::TEXT("%s: Not a regular file"), filename);
Sys::close(fd);
return (NULL);
}
int cc = Sys::read(fd, buf, sizeof (buf));
Sys::close(fd);
if (cc == 0) {
- emsg = fxStr::format(_("%s: Empty file"), filename);
+ emsg = fxStr::format(NLS::TEXT("%s: Empty file"), filename);
return (NULL);
}
const TypeRule* tr = typeRules->match(buf, cc);
if (!tr) {
- emsg = fxStr::format(_("%s: Can not determine file type"), filename);
+ emsg = fxStr::format(NLS::TEXT("%s: Can not determine file type"), filename);
return (NULL);
}
if (tr->getResult() == TypeRule::ERROR) {
#include "PageSize.h"
#include "FaxConfig.h"
+#include "NLS.h"
+
SendFaxJob::SendFaxJob()
{
}
if (coverFile != "") {
int fd = Sys::open(coverFile, O_RDONLY);
if (fd < 0) {
- emsg = fxStr::format(_("%s: Can not open: %s"),
+ emsg = fxStr::format(NLS::TEXT("%s: Can not open: %s"),
(const char*) coverFile, strerror(errno));
return (false); // XXX
}
Sys::close(fd);
if (!fileSent) {
if (emsg == "")
- emsg = _("Document transfer failed: ") | client.getLastResponse();
+ emsg = NLS::TEXT("Document transfer failed: ") | client.getLastResponse();
return (false);
}
CHECK(client.jobCover(coverDoc))
#include <sys/file.h>
#include <errno.h>
+#include "NLS.h"
+
const fxStr Sequence::format("%09u");
fd = -1;
}
if (fd < 0) {
- emsg = fxStr::format(_("Unable to open sequence number file %s; %s."),
+ emsg = fxStr::format(NLS::TEXT("Unable to open sequence number file %s; %s."),
name, strerror(errno));
logError("%s: open: %s", name, strerror(errno));
return ((u_long) -1);
seqnum = atol(line);
}
if (seqnum < 1 || seqnum >= MAXSEQNUM) {
- logWarning(_("%s: Invalid sequence number \"%s\", resetting to 1"),
+ logWarning(NLS::TEXT("%s: Invalid sequence number \"%s\", resetting to 1"),
name, line);
seqnum = 1;
}
if (Sys::write(fd, (const char*)line2, len) != len ||
ftruncate(fd, len)) {
emsg = fxStr::format(
- _("Unable update sequence number file %s; write failed."), name);
+ NLS::TEXT("Unable update sequence number file %s; write failed."), name);
logError("%s: Problem updating sequence number file", name);
return ((u_long) -1);
}
#include <sys/mman.h>
#endif
+#include "NLS.h"
+
#define LUNIT (72*20) // local coord system is .05 scale
#define ICVT(x) ((TextCoord)((x)*LUNIT)) // scale inches to local coordinates
#define CVTI(x) (float(x)/LUNIT) // convert coords to inches
void
TextFormat::warning(const char* fmt ...) const
{
- fputs(_("Warning, "), stderr);
+ fputs(NLS::TEXT("Warning, "), stderr);
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
if (workStarted) {
fxStr emsg;
if (!f->readMetrics(pointSize, useISO8859, emsg))
- error(_("Font %s: %s"), f->getFamily(), (const char*) emsg);
+ error(NLS::TEXT("Font %s: %s"), f->getFamily(), (const char*) emsg);
}
return (f);
}
*/
tf = Sys::tmpfile();
if (tf == NULL)
- fatal(_("Cannot open temporary file: %s"), strerror(errno));
+ fatal(NLS::TEXT("Cannot open temporary file: %s"), strerror(errno));
numcol = fxmax(1,numcol);
if (pointSize == -1)
else
pointSize = fxmax(inch("3bp"), pointSize);
if (pointSize > inch("18bp"))
- warning(_("point size is unusually large (>18pt)"));
+ warning(NLS::TEXT("point size is unusually large (>18pt)"));
// read font metrics
for (FontDictIter iter(*fonts); iter.notDone(); iter++) {
fxStr emsg;
TextFont* f = iter.value();
if (!f->readMetrics(pointSize, useISO8859, emsg))
- error(_("Font %s: %s"), f->getFamily(), (const char*) emsg);
+ error(NLS::TEXT("Font %s: %s"), f->getFamily(), (const char*) emsg);
}
outline = fxmax(0L,outline);
curFont = (*fonts)["Roman"];
pageHeight = t;
}
if (lm+rm >= pageWidth)
- fatal(_("Margin values too large for page; lm %lu rm %lu page width %lu"),
+ fatal(NLS::TEXT("Margin values too large for page; lm %lu rm %lu page width %lu"),
lm, rm, pageWidth);
if (tm+bm >= pageHeight)
- fatal(_("Margin values too large for page; tm %lu bm %lu page height %lu"),
+ fatal(NLS::TEXT("Margin values too large for page; tm %lu bm %lu page height %lu"),
tm, bm, pageHeight);
col_width = (pageWidth - (lm + rm))/numcol;
Copy_Block(0L, last-1);
}
if (fclose(tf))
- fatal(_("Close failure on temporary file: %s"), strerror(errno));
+ fatal(NLS::TEXT("Close failure on temporary file: %s"), strerror(errno));
tf = NULL;
emitTrailer();
fflush(output);
size_t cc = (size_t) fxmin(sizeof (buf), (size_t) (b2-k+1));
fseek(tf, (long) k, SEEK_SET); // position to desired block
if (fread(buf, 1, (size_t) cc, tf) != cc)
- fatal(_("Read error during reverse collation: %s"), strerror(errno));
+ fatal(NLS::TEXT("Read error during reverse collation: %s"), strerror(errno));
if (fwrite(buf, 1, (size_t) cc, output) != cc)
- fatal(_("Output write error: %s"), strerror(errno));
+ fatal(NLS::TEXT("Output write error: %s"), strerror(errno));
}
}
formatFile(fp);
fclose(fp);
} else
- error(_("%s: Cannot open file: %s"), name, strerror(errno));
+ error(NLS::TEXT("%s: Cannot open file: %s"), name, strerror(errno));
}
void
{
fflush(tf);
if (ferror(tf) && errno == ENOSPC)
- fatal(_("Output write error: %s"), strerror(errno));
+ fatal(NLS::TEXT("Output write error: %s"), strerror(errno));
}
/*
size_t len = strcspn(buf, "%\n");
if (len == strlen(buf)) {
emsg = fxStr::format(
- _("Warning: %s - line too long."), (const char*)fontMapFile);
+ NLS::TEXT("Warning: %s - line too long."), (const char*)fontMapFile);
break;
}
if (len == 0) continue;
*(buf + len) = '\0';
if (len == strlen(buf)) {
emsg = fxStr::format(
- _("Warning: %s - line too long."), (const char*) fontMapFile);
+ NLS::TEXT("Warning: %s - line too long."), (const char*) fontMapFile);
break;
}
if (len == 0) continue;
bool result = stat(filename, &junk) ? false : true;
if (!result)
emsg = fxStr::format(
- _("Warning: %s invalid Fontmap entry - no filename present"), (const char*)val);
+ NLS::TEXT("Warning: %s invalid Fontmap entry - no filename present"), (const char*)val);
return result;
}
}
FILE *fp = openAFMFile(file);
if (fp == NULL) {
emsg = fxStr::format(
- _("%s: Can not open font metrics file; using fixed widths"),
+ NLS::TEXT("%s: Can not open font metrics file; using fixed widths"),
(const char*) file);
loadFixedMetrics(625*ps/1000L); // NB: use fixed width metrics
return (false);
do {
if (!getAFMLine(fp, buf, sizeof (buf))) {
emsg = fxStr::format(
- _("%s: No glyph metric table located; using fixed widths"),
+ NLS::TEXT("%s: No glyph metric table located; using fixed widths"),
(const char*) file);
fclose(fp);
/*
int ix, w;
/* read the glyph position and width */
if (sscanf(buf, "C %d ; WX %d ;", &ix, &w) != 2) {
- emsg = fxStr::format(_("%s, line %u: format error"),
+ emsg = fxStr::format(NLS::TEXT("%s, line %u: format error"),
(const char*) file, lineno);
fclose(fp);
return (false);
}
#endif
+#include "NLS.h"
+
#ifndef TRUE
#define TRUE 1
#endif
TypeRule::match(const void* data, size_t size, bool verbose) const
{
if (verbose) {
- printf(_("rule: %soffset %#lx %s %s"),
+ printf(NLS::TEXT("rule: %soffset %#lx %s %s"),
cont ? ">" : "",
(u_long) off,
typeNames[type],
printf(" \"%s\"", value.s);
else if (type != ASCII && type != ASCIIESC) {
if (op == ANY)
- printf(_(" <any value>"));
+ printf(NLS::TEXT(" <any value>"));
else
printf(" %#llx", (long long) value.v);
}
}
if (off > (off_t)size) {
if (verbose)
- printf(_("failed (offset past data)\n"));
+ printf(NLS::TEXT("failed (offset past data)\n"));
return (false);
}
bool ok = false;
for (i = 0; i < size; i++)
if (!isprint(cp[i]) && !isspace(cp[i])) {
if (verbose)
- printf(_("failed (unprintable char %#x)\n"), cp[i]);
+ printf(NLS::TEXT("failed (unprintable char %#x)\n"), cp[i]);
return (false);
}
ok = true;
for (i = 0; i < size; i++)
if (!isprint(cp[i]) && !isspace(cp[i]) && cp[i] != '\033') {
if (verbose)
- printf(_("failed (unprintable char %#x)\n"), cp[i]);
+ printf(NLS::TEXT("failed (unprintable char %#x)\n"), cp[i]);
return (FALSE);
}
ok = TRUE;
break;
}
if (verbose)
- printf(_("failed (insufficient data)\n"));
+ printf(NLS::TEXT("failed (insufficient data)\n"));
return (false);
case LONG:
if (off + 4 < (off_t)size) {
break;
}
if (verbose)
- printf(_("failed (insufficient data)\n"));
+ printf(NLS::TEXT("failed (insufficient data)\n"));
return (false);
}
/*
done:
if (verbose) {
if (ok)
- printf(_("success (result %s, rule \"%s\")\n"),
+ printf(NLS::TEXT("success (result %s, rule \"%s\")\n"),
resultNames[result], (const char*) cmd);
else
- printf(_("failed (comparison)\n"));
+ printf(NLS::TEXT("failed (comparison)\n"));
}
return (ok);
}
{
va_list ap;
va_start(ap, fmt);
- fprintf(stderr, _("%s: line %u: "), file, lineno);
+ fprintf(stderr, NLS::TEXT("%s: line %u: "), file, lineno);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
fp = fopen(file, "r");
if (fp == NULL) {
- fprintf(stderr, _("%s: Can not open type rules file.\n"),
+ fprintf(stderr, NLS::TEXT("%s: Can not open type rules file.\n"),
(const char*) file);
return NULL;
}
const char *op = cp;
rule.off = strtoul(op, &cp, 0); // file offset
if (cp == op) {
- parseError(file, lineno, _("Missing file offset"));
+ parseError(file, lineno, NLS::TEXT("Missing file offset"));
continue;
}
while (isspace(*cp))
else if (strncasecmp(tp, "addr", cp-tp) == 0)
rule.type = TypeRule::ADDR;
else {
- parseError(file, lineno, _("Unknown datatype \"%.*s\""), cp-tp, tp);
+ parseError(file, lineno, NLS::TEXT("Unknown datatype \"%.*s\""), cp-tp, tp);
continue; // bad type
}
while (isspace(*cp))
const char* vp = cp;
rule.value.v = strtol(vp, &cp, 0);
if (vp == cp) {
- parseError(file, lineno, _("Missing match value"));
+ parseError(file, lineno, NLS::TEXT("Missing match value"));
continue;
}
}
else if (strncasecmp(rp, "error", cp-rp) == 0)
rule.result = TypeRule::ERROR;
else {
- parseError(file, lineno, _("Unknown result \"%.*s\""), cp-rp, rp);
+ parseError(file, lineno, NLS::TEXT("Unknown result \"%.*s\""), cp-rp, rp);
continue;
}
while (isspace(*cp))
TypeRules::match(const void* data, u_int size) const
{
if (verbose)
- printf(_("match against (..., %u)\n"), size);
+ printf(NLS::TEXT("match against (..., %u)\n"), size);
for (u_int i = 0, n = (*rules).length(); i < n; i++) {
TypeRule& rule = (*rules)[i];
if (!rule.isContinuation() && rule.match(data, size, verbose))
return (&(*rules)[i + match2(i, data, size, verbose)]);
}
if (verbose)
- printf(_("no match\n"));
+ printf(NLS::TEXT("no match\n"));
return (NULL);
}
#define fxSIGACTIONHANDLER
#endif
+// --------------------------------------------------------------------
+//
+// Support for NLS
+
+#define _(String) gettext(String)
+#define N_(String) gettext_noop(String)
+#define gettext_noop(String) String
+
+#ifdef ENABLE_NLS
+
+#include <locale.h>
+#include <libintl.h>
+
+#ifdef NEED_NGETTEXT
+#define ngettext(s1,s2,n) (n ==1 ? gettext(s1) : gettext(s2))
+#endif
+
+#else /* ENABLE_NLS */
+
+#define gettext(String) (String)
+#define textdomain(Domain) do {} while()
+#define bindtextdomain(Package, Directory) do {} while()
+#define ngettext(s1, s2, n) (n==1?s1:s2)
+
+#endif /* ENABLE_NLS */
+
+
#endif /* _Types_ */
#include "UnixTransport.h"
#include "Sys.h"
+#include "NLS.h"
+
UnixTransport::UnixTransport(FaxClient& c) : Transport(c) {}
UnixTransport::~UnixTransport() {}
{
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
- emsg = _("Can not create socket to connect to server.");
+ emsg = NLS::TEXT("Can not create socket to connect to server.");
return (false);
}
struct sockaddr_un Sun;
Sun.sun_family = AF_UNIX;
strncpy(Sun.sun_path, client.getHost(), sizeof (Sun.sun_path));
if (client.getVerbose())
- client.traceServer(_("connect to server at %s"),
+ client.traceServer(NLS::TEXT("connect to server at %s"),
(const char*) client.getHost());
if (Socket::connect(fd, &Sun, sizeof (Sun)) >= 0) {
client.setCtrlFds(fd, dup(fd));
return (true);
} else {
- emsg = fxStr::format(_("Can not reach server at Unix domain socket \"%s\"."),
+ emsg = fxStr::format(NLS::TEXT("Can not reach server at Unix domain socket \"%s\"."),
(const char*) client.getHost());
Sys::close(fd), fd = -1;
return (false);
void
Transport::notConfigured(fxStr& emsg)
{
- emsg = _("Sorry, no Unix domain communication support was configured.");
+ emsg = NLS::TEXT("Sorry, no Unix domain communication support was configured.");
}
bool UnixTransport::callServer(fxStr& emsg)
#include "SendFaxClient.h"
#include "FaxDB.h"
#include "Sys.h"
+#include "NLS.h"
#include "config.h"
#include <ctype.h> // isspace()
#ifdef LC_TIME
setlocale(LC_TIME, ""); // for strftime calls
#endif
- setupNLS();
+ NLS::Setup("hylafax-client");
signal(SIGHUP, fxSIGHANDLER(sigDone));
signal(SIGINT, fxSIGHANDLER(sigDone));
signal(SIGTERM, fxSIGHANDLER(sigDone));
*/
#include "SNPPClient.h"
#include "Sys.h"
+#include "NLS.h"
#include "config.h"
#if HAS_LOCALE
#ifdef LC_TIME
setlocale(LC_TIME, ""); // for strftime calls
#endif
- setupNLS();
+ NLS::Setup("hylafax-client");
signal(SIGHUP, fxSIGHANDLER(sigDone));
signal(SIGINT, fxSIGHANDLER(sigDone));
signal(SIGTERM, fxSIGHANDLER(sigDone));