summaryrefslogtreecommitdiff
path: root/sys/src/cmd/usb/print/main.c
blob: 49113b6672de2cc659cc8e603cbdd5ed900a954a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * usb/print - usb printer
 */
#include <u.h>
#include <libc.h>
#include <thread.h>
#include "usb.h"

enum
{
	Arglen = 80,
};

static void
usage(void)
{
	fprint(2, "usage: %s [-d] [-N nb] [dev...]\n", argv0);
	threadexitsall("usage");
}

static int csps[] = { 0x020107, 0 };

extern int printmain(Dev*, int, char**);

void
threadmain(int argc, char **argv)
{
	char args[Arglen];
	char *as;
	char *ae;

	quotefmtinstall();
	ae = args+sizeof(args);
	as = seprint(args, ae, "print");
	ARGBEGIN{
	case 'd':
		usbdebug++;
		break;
	case 'N':
		as = seprint(as, ae, " -N %s", EARGF(usage()));
		break;
	default:
		usage();
	}ARGEND

	rfork(RFNOTEG);
	threadsetgrp(threadid());
	fmtinstall('U', Ufmt);
	startdevs(args, argv, argc, matchdevcsp, csps, printmain);
	threadexits(nil);
}