sync.c 674 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "stdinc.h"
  2. #include "dat.h"
  3. #include "fns.h"
  4. char *host;
  5. void
  6. usage(void)
  7. {
  8. fprint(2, "usage: sync [-h host]\n");
  9. exits("usage");
  10. }
  11. int
  12. main(int argc, char *argv[])
  13. {
  14. VtSession *z;
  15. ARGBEGIN{
  16. case 'h':
  17. host = EARGF(usage());
  18. if(host == nil)
  19. usage();
  20. break;
  21. default:
  22. usage();
  23. break;
  24. }ARGEND
  25. if(argc != 0)
  26. usage();
  27. vtAttach();
  28. fmtinstall('V', vtScoreFmt);
  29. fmtinstall('R', vtErrFmt);
  30. z = vtDial(host, 0);
  31. if(z == nil)
  32. vtFatal("could not connect to server: %R");
  33. if(!vtConnect(z, 0))
  34. sysfatal("vtConnect: %r");
  35. if(!vtSync(z))
  36. sysfatal("vtSync: %r");
  37. vtClose(z);
  38. vtDetach();
  39. exits(0);
  40. return 0; /* shut up compiler */
  41. }