bool addFilename(StringAttrArray &names,const char *name,bool sub) { if (isWild(name)) { StringBuffer dir; const char *tail = splitDirTail(name,dir); if (isWild(dir.str())) { printf("Directory %s - cannot be wild!\n",dir.str()); return false; } Owned<IFile> dirf = createIFile(dir.str()); Owned<IDirectoryIterator> iter = dirf->directoryFiles(tail,sub,false); StringBuffer subname; ForEach(*iter) { subname.clear().append(iter->query().queryFilename()); names.append(*new StringAttrItem(subname.str())); } } else
void Do(unsigned i) { ISocket *sock = sockets.item(i); StringBuffer epstr; SocketEndpoint ep = eps.item(i); ep.getUrlStr(epstr); // PROGLOG("T.1 %s %x",epstr.str(),(unsigned)sock); StringBuffer verstr; unsigned rver=0; if (sock) { rver = getRemoteVersion(sock, verstr); switch (mode) { case AMcheck: if (rver!=0) return; case AMver: { CriticalBlock block(sect); result.append(ep); StringBuffer ln; ln.append(rver).append(",\"").append(verstr).append('"'); resultstr.append(* new StringAttrItem(ln.str())); } return; case AMstopver: case AMcheckver: case AMcheckvermajor: { // compares versions up to the '-' const char *rv = verstr.str(); const char *v = remoteServerVersionString(); if (mode!=AMcheckvermajor) { while (*v&&(*v!='-')&&(*v==*rv)) { v++; rv++; } } if ((*rv==*v)&&(rver==ver)) return; while (*rv&&(*rv!='-')) rv++; verstr.setLength(rv-verstr.str()); if ((mode==AMcheckver)||(mode==AMcheckvermajor)) break; } // fall through case AMstop: { unsigned err = stopRemoteServer(sock); if (err!=0) { ERRLOG("Could not stop server on %s, %d returned",epstr.str(),err); if (mode!=AMstopver) return; // even though failed to stop - still return code } else Sleep(1000); // let stop } break; default: return; } } CriticalBlock block(sect); result.append(ep); if ((mode!=AMver)&&(mode!=AMcheckver)&&(mode!=AMcheckvermajor)&&(mode!=AMstopver)) resultstr.append(* new StringAttrItem("")); else resultstr.append(* new StringAttrItem(verstr.str())); }