print.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /*
  10. * usb/print - usb printer
  11. */
  12. #include <u.h>
  13. #include <libc.h>
  14. #include <thread.h>
  15. #include <usb/usb.h>
  16. enum
  17. {
  18. Arglen = 80,
  19. };
  20. static void
  21. usage(void)
  22. {
  23. fprint(2, "usage: %s [-d] [-N nb] [dev...]\n", argv0);
  24. threadexitsall("usage");
  25. }
  26. static int csps[] = { 0x020107, 0 };
  27. extern int printmain(Dev*, int, char**);
  28. void
  29. threadmain(int argc, char **argv)
  30. {
  31. char args[Arglen];
  32. char *as;
  33. char *ae;
  34. quotefmtinstall();
  35. ae = args+sizeof(args);
  36. as = seprint(args, ae, "print");
  37. ARGBEGIN{
  38. case 'd':
  39. usbdebug++;
  40. break;
  41. case 'N':
  42. as = seprint(as, ae, " -N %s", EARGF(usage()));
  43. break;
  44. default:
  45. usage();
  46. }ARGEND
  47. rfork(RFNOTEG);
  48. threadsetgrp(threadid());
  49. fmtinstall('U', Ufmt);
  50. startdevs(args, argv, argc, matchdevcsp, csps, printmain);
  51. threadexits(nil);
  52. }