void threadmain(int argc, char *argv[]) { char *errmsg; int ac; char *ap, *av[256]; Cmd *cp; int32_t status; if (argc > 3) { print("usage: cifscmd [to [share]]\n"); exits("args"); } smbglobalsguess(1); errmsg = nil; if (Binit(&bin, 0, OREAD) == Beof || Binit(&bout, 1, OWRITE) == Beof) { fprint(2, "%s: can't init bio: %r\n", argv0); threadexits("Binit"); } if (argc > 1) { c = smbconnect(argv[1], argc == 3 ? argv[2] : nil, &errmsg); if (c == nil) fprint(2, "failed to connect: %s\n", errmsg); } while (ap = Brdline(&bin, '\n')) { ap[Blinelen(&bin) - 1] = 0; switch (ac = parse(ap, av, nelem(av))) { default: for (cp = cmd; cp->name; cp++) { if (strcmp(cp->name, av[0]) == 0) break; } if (cp->name == 0) { Bprint(&bout, "eh?\n"); break; } if (c == 0 && cp->connected) { Bprint(&bout, "not currently connected\n"); break; } if ((status = (*cp->f)(c, ac - 1, &av[1])) != -1) { if(verbose) Bprint(&bout, "ok %ld/%ld\n", status >> 16, status & 0xffff); break; } break; case -1: Bprint(&bout, "eh?\n"); break; case 0: break; } Bflush(&bout); } threadexits(0); }
void threadmain(int argc, char *argv[]) { SmbClient *c; char *errmsg; if (argc != 2 && argc != 3) { print("usage: testconnect to [share]\n"); exits("args"); } smbglobalsguess(1); errmsg = nil; c = smbconnect(argv[1], argc == 3 ? argv[2] : nil, &errmsg); if (c) { int i, rv; int entries; SmbRapServerInfo1 *si = nil; SmbFindFileBothDirectoryInfo ip[10]; char *errmsg; ushort sid, searchcount, endofsearch; errmsg = nil; rv = smbnetserverenum2(c, SV_TYPE_SERVER, "PLAN9", &entries, &si, &errmsg); if (rv < 0) print("error: %s\n", errmsg); else if (rv > 0) print("error code %d\n", rv); else for (i = 0; i < entries; i++) print("%s: %d.%d 0x%.8lux %s\n", si[i].name, si[i].vmaj, si[i].vmin, si[i].type, si[i].remark); free(si); if (rv == 0) { rv = smbnetserverenum2(c, SV_TYPE_DOMAIN_ENUM, nil, &entries, &si, &errmsg); if (rv < 0) print("error: %s\n", errmsg); else if (rv > 0) print("error code %d\n", rv); else for (i = 0; i < entries; i++) print("%s: %d.%d 0x%.8lux %s\n", si[i].name, si[i].vmaj, si[i].vmin, si[i].type, si[i].remark); free(si); } rv = smbclienttrans2findfirst2(c, nelem(ip), "\\LICENSE", &sid, &searchcount, &endofsearch, ip, &errmsg); if (rv) { print("sid 0x%.4ux\n", sid); print("searchcount 0x%.4ux\n", searchcount); print("endofsearch 0x%.4ux\n", endofsearch); } else print("search failed %s\n", errmsg); smbclientfree(c); } else print("failed to connect: %s\n", errmsg); }
void threadmain(int argc, char **argv) { NbName from, to; char *e = nil; int netbios = 0; ARGBEGIN { case 'u': smbglobals.unicode = strtol(ARGF(), 0, 0) != 0; break; case 'p': smbglobals.log.print = 1; break; case 'd': logset(ARGF()); break; case 'w': smbglobals.primarydomain = ARGF(); break; case 'n': netbios = 1; break; default: usage(); } ARGEND; smbglobalsguess(0); smblistencifs(cifsaccept); if (netbios) { nbinit(); nbmknamefromstring(from, "*"); nbmknamefromstring(to, "*smbserver\\x20"); nbsslisten(to, from, nbssaccept, nil); nbmknamefromstringandtype(to, smbglobals.serverinfo.name, 0x20); nbsslisten(to, from, nbssaccept, nil); } smblogprint(-1, "Aquarela %d.%d running\n", smbglobals.serverinfo.vmaj, smbglobals.serverinfo.vmin); for (;;) { if (netbios&& !smbbrowsesendhostannouncement(smbglobals.serverinfo.name, 60 * 1000, SV_TYPE_SERVER, smbglobals.serverinfo.remark, &e)) { smblogprint(-1, "hostannounce failed: %s\n", e); } if (sleep(60 * 1000) < 0) break; } }