main.c 973 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include <ip.h>
  5. #include <plumb.h>
  6. #include <thread.h>
  7. #include <fcall.h>
  8. #include <9p.h>
  9. #include "dat.h"
  10. #include "fns.h"
  11. char *cookiefile;
  12. char *mtpt = "/mnt/web";
  13. char *service;
  14. Ctl globalctl =
  15. {
  16. 1, /* accept cookies */
  17. 1, /* send cookies */
  18. 10, /* redirect limit */
  19. "webfs/2.0 (plan 9)" /* user agent */
  20. };
  21. void
  22. usage(void)
  23. {
  24. fprint(2, "usage: webfs [-c cookies] [-m mtpt] [-s service]\n");
  25. threadexitsall("usage");
  26. }
  27. void
  28. threadmain(int argc, char **argv)
  29. {
  30. rfork(RFNOTEG);
  31. ARGBEGIN{
  32. case 'D':
  33. chatty9p++;
  34. break;
  35. case 'c':
  36. cookiefile = EARGF(usage());
  37. break;
  38. case 'm':
  39. mtpt = EARGF(usage());
  40. break;
  41. case 's':
  42. service = EARGF(usage());
  43. break;
  44. }ARGEND
  45. quotefmtinstall();
  46. if(argc != 0)
  47. usage();
  48. plumbinit();
  49. globalctl.useragent = estrdup(globalctl.useragent);
  50. initcookies(cookiefile);
  51. initurl();
  52. initfs();
  53. threadpostmountsrv(&fs, service, mtpt, MREPL);
  54. threadexits(nil);
  55. }