version 1.16, 2010/06/29 14:18:05 |
version 1.17, 2010/06/29 14:53:14 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <stdarg.h> |
#include <stdarg.h> |
|
#include <stdint.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
Line 373 static void ps_setfont(struct termp *, enum termfon |
|
Line 374 static void ps_setfont(struct termp *, enum termfon |
|
|
|
|
|
void * |
void * |
ps_alloc(void) |
ps_alloc(char *outopts) |
{ |
{ |
struct termp *p; |
struct termp *p; |
size_t pagex, pagey, margin; |
size_t pagex, pagey, margin; |
|
const char *toks[2]; |
|
char *v; |
|
|
if (NULL == (p = term_alloc(TERMENC_ASCII))) |
if (NULL == (p = term_alloc(TERMENC_ASCII))) |
return(NULL); |
return(NULL); |
|
|
|
/* Default is USA letter. */ |
pagex = 612; |
pagex = 612; |
pagey = 792; |
pagey = 792; |
margin = 72; |
margin = 72; |
|
|
p->advance = ps_advance; |
p->advance = ps_advance; |
p->endline = ps_endline; |
p->endline = ps_endline; |
p->width = ps_width; |
p->width = ps_width; |
|
|
|
toks[0] = "paper"; |
|
toks[1] = NULL; |
|
|
|
while (outopts && *outopts) |
|
switch (getsubopt(&outopts, UNCONST(toks), &v)) { |
|
case (0): |
|
if (0 == strcasecmp(v, "a4")) { |
|
pagex = 595; |
|
pagey = 842; |
|
} else if (0 == strcasecmp(v, "letter")) { |
|
pagex = 612; |
|
pagey = 792; |
|
} |
|
break; |
|
default: |
|
break; |
|
} |
|
|
assert(margin * 2 < pagex); |
assert(margin * 2 < pagex); |
assert(margin * 2 < pagey); |
assert(margin * 2 < pagey); |