Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_tlsv12/sys/src/cmd/postscript/p9bitpost/p9bitpost.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <draw.h>
4
#include <memdraw.h>
5
#include "pslib.h"
6
 
7
#define HDLEN	60
8
 
9
int dpi = -1;
10
int debug = 0;
11
int landscape = 0;
12
char *file = "<stdin>";
13
 
14
int paperlength = 11*72;
15
int paperwidth = 612;	/* 8.5*72 */
16
 
17
void
18
error(char *s)
19
{
20
	fprint(2, "p9bitpost: can't %s file %s: %r\n", s, file);
21
	exits("error");
22
}
23
 
24
void
25
main(int argc, char *argv[]) {
26
	int i, fd = 0;
27
	double xmag = 1.0, ymag = 1.0;
28
	char *optstr, *Patch;
29
	Memimage *memimage;
30
 
31
	Patch = nil;
32
	for (i=1; i<argc; i++) {
33
		if (*argv[i] != '-') break;
34
		switch(argv[i][1]) {
35
		case 'b':
36
			if (argv[i][2] == '\0')
37
				dpi = atoi(argv[++i]);
38
			else
39
				dpi = atoi(&(argv[i][2]));
40
			break;
41
		case 'd':
42
			debug = 1;
43
			break;
44
		case 'm':
45
			if (argv[i][2] == '\0')
46
				optstr = argv[++i];
47
			else
48
				optstr = &(argv[i][2]);
49
			if ((optstr=strtok(optstr, " ,")) != 0)
50
				xmag = ymag = atof(optstr);
51
			if ((optstr=strtok(0, " ,")) != 0)
52
				ymag = atof(optstr);
53
			break;
54
		case 'L':
55
			landscape = 1;
56
			break;
57
		case 'P':
58
			if (argv[i][2] == '\0')
59
				Patch = argv[++i];
60
			else
61
				Patch = &(argv[i][2]);
62
			break;
63
		case 'p':
64
			optstr = argv[++i];
65
			if(optstr == nil)
66
				goto Usage;
67
			paperlength = 72*atof(optstr);
68
			optstr = argv[++i];
69
			if(optstr == nil)
70
				goto Usage;
71
			paperwidth = 72*atof(optstr);
72
			if(paperlength < 72 || paperwidth < 72)
73
				goto Usage;
74
			break;
75
		default:
76
		Usage:
77
			fprint(2, "usage: %s [-b dpi] [-m magnification] [-L] [-P postscript_patch_string] [-p paperlength paperwidth (in inches)] inputfile\n", argv[0]);
78
			exits("usage");
79
		}
80
	}
81
 
82
	if (i < argc) {
83
		file = argv[i];
84
		fd = open(file, OREAD);
85
		if (fd < 0)
86
			error("open");
87
	}
88
 
89
	memimageinit();
90
	memimage = readmemimage(fd);
91
	if(memimage == nil)
92
		error("alloc memory for");
93
 
94
	psinit(0, 0);
95
	if(xmag != 1.0)
96
		psopt("xmagnification", &xmag);
97
	if(ymag != 1.0)
98
		psopt("ymagnification", &ymag);
99
	if(landscape)
100
		psopt("landscape", &landscape);
101
	if(Patch)
102
		psopt("Patch", &Patch);
103
	image2psfile(1, memimage, dpi);
104
	exits("");
105
}