| 1 |
|
| 2 |
#include "obx.h" |
| 3 |
|
| 4 |
void FmtInt(FILE *fp, int n, int w) { |
| 5 |
fprintf(fp, "%*d", w, n); |
| 6 |
} |
| 7 |
|
| 8 |
void FmtLong(FILE *fp, longint n, int w) { |
| 9 |
#ifdef __MINGW32__ |
| 10 |
const char *fmt = "%*I64d"; |
| 11 |
#else |
| 12 |
const char *fmt = "%*lld"; |
| 13 |
#endif |
| 14 |
fprintf(fp, fmt, w, n); |
| 15 |
} |
| 16 |
|
| 17 |
void FmtReal(FILE *fp, float x) { |
| 18 |
fprintf(fp, "%#G", x); |
| 19 |
} |
| 20 |
|
| 21 |
void FmtLongReal(FILE *fp, double x) { |
| 22 |
fprintf(fp, "%#.12G", x); |
| 23 |
} |
| 24 |
|
| 25 |
void FmtFixed(FILE *fp, double x, int width, int dec) { |
| 26 |
fprintf(fp, "%*.*f", width, dec, x); |
| 27 |
} |
| 28 |
|
| 29 |
void FmtString(FILE *fp, char *s, int len) { |
| 30 |
fprintf(fp, "%.*s", len, s); |
| 31 |
} |
| 32 |
|
| 33 |
void InitFiles(value *in, value *out, value *err) { |
| 34 |
put_long(in, (ptrtype) stdin); |
| 35 |
put_long(out, (ptrtype) stdout); |
| 36 |
put_long(err, (ptrtype) stderr); |
| 37 |
} |
| 38 |
|