send.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include <u.h>
  10. #include <libc.h>
  11. #include <bio.h>
  12. #include "modem.h"
  13. static Modem modems[1];
  14. static void
  15. usage(void)
  16. {
  17. fprint(2, "%s: usage: %s [-v] number pages\n", argv0, argv0);
  18. exits("usage");
  19. }
  20. void
  21. main(int argc, char *argv[])
  22. {
  23. int fd, cfd, r;
  24. Modem *m;
  25. char *addr;
  26. m = &modems[0];
  27. ARGBEGIN{
  28. case 'v':
  29. vflag = 1;
  30. break;
  31. default:
  32. usage();
  33. break;
  34. }ARGEND
  35. if(argc <= 1)
  36. usage();
  37. verbose("send: %s %s...", argv[0], argv[1]);
  38. addr = netmkaddr(*argv, "telco", "fax!9600");
  39. fd = dial(addr, 0, 0, &cfd);
  40. if(fd < 0){
  41. fprint(2, "faxsend: can't dial %s: %r\n", addr);
  42. exits("Retry, can't dial");
  43. }
  44. initmodem(m, fd, cfd, 0, 0);
  45. argc--; argv++;
  46. r = faxsend(m, argc, argv);
  47. if(r != Eok){
  48. fprint(2, "faxsend: %s\n", m->error);
  49. syslog(0, "fax", "failed %s %s: %s", argv[0], argv[1], m->error);
  50. exits(m->error);
  51. }
  52. syslog(0, "fax", "success %s %s", argv[0], argv[1]);
  53. exits(0);
  54. }