Hylafax Mailing List Archives
|
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
Byte-order, resolution problems in util/TypeRules.c++
There are two problems with util/TypeRules.c++ in hylafax-v4.0pl1:
1) It doesn't convert shorts and longs read from the typerules file
from network byte order into host byte order, so if the host's byte
order isn't network byte order, comparisons of the constants in the
typerules file against the data in the file being faxed will fail.
The patch below fixes this.
2) It uses "%g" instead of "%f" for resolution parameters inserted
into the commands into the typerules file. This is problematic
both because many of the problems it's calling (dvips, in
particular, is where I encountered this problem) won't accept
scientific notation for numerical arguments, and because some
precision is lost unnecessarily (e.g., for a fine-resolution fax,
204x196 turns into 2.00e2x2.00e2). The patch below changes the %V
and %R formats to use "%f" instead of "%g"; I don't know for sure
whether the others should be changed, so I didn't change them.
--- TypeRules.c++ 1997/07/18 15:12:06 1.1
+++ TypeRules.c++ 1997/07/18 15:49:24
@@ -32,6 +32,9 @@
#include <string.h>
#include <stdlib.h>
+extern "C" {
+#include <netinet/in.h>
+}
TypeRule::TypeRule() {}
TypeRule::~TypeRule() {}
@@ -106,7 +109,7 @@
if (off + 2 < size) {
u_short w;
memcpy(&w, cp+off, 2);
- v = w;
+ v = ntohs(w);
break;
}
if (verbose)
@@ -115,6 +118,7 @@
case LONG:
if (off + 4 < size) {
memcpy(&v, cp+off, 4);
+ v = ntohl(v);
break;
}
if (verbose)
@@ -184,9 +188,9 @@
switch (c = cmd[i]) {
case 'i': fmtd.append(input); continue;
case 'o': fmtd.append(output); continue;
- case 'R': fmtd.append(fxStr(hr, "%.2g")); continue;
+ case 'R': fmtd.append(fxStr(hr, "%.2f")); continue;
case 'r': fmtd.append(fxStr(hr/25.4, "%.2g")); continue;
- case 'V': fmtd.append(fxStr(vr, "%.2g")); continue;
+ case 'V': fmtd.append(fxStr(vr, "%.2f")); continue;
case 'v': fmtd.append(fxStr(vr/25.4, "%.2g")); continue;
case 'f': fmtd.append(df); continue;
case 'W': fmtd.append(fxStr(pw, "%.2g")); continue;