int verifyGroup(GroupInfo *groupInfo) { if(groupInfo == NULL) { fprintf(stderr, "empty groupInfo\n"); return -1; } int i; for(i = 0; i < groupInfo->config.procNum; i++) { ProcInfo *procInfo = getProcInfo(groupInfo, i); if(procInfo == NULL || verifyProc(procInfo) == -1) { fprintf(stderr, "groupInfo verification error\n"); return -1; } } return 0; }
static int execQuery(char const *vserver, VserverTag tag, int argc, char *argv[]) { char const * res = 0; char buf[sizeof(xid_t)*4 + 1024 + strlen(vserver)]; memset(buf, 0, sizeof buf); switch (tag) { case tgNAME : res = vc_getVserverName(vserver, vcCFG_AUTO); break; case tgVDIR : res = vc_getVserverVdir(vserver, vcCFG_AUTO, argc>0 && atoi(argv[0])); break; case tgCFGDIR : res = vc_getVserverCfgDir(vserver, vcCFG_AUTO); break; case tgAPPDIR : res = vc_getVserverAppDir(vserver, vcCFG_AUTO, argc==0 ? "" : argv[0]); break; case tgRUNNING : { signed long xid; // type is a small hack, but should be ok... struct vc_vx_info info; if (isNumber(vserver, &xid, true) && xid>=0) res = (vc_get_vx_info(xid, &info)==-1) ? 0 : "1"; else res = (vc_getVserverCtx(vserver, vcCFG_AUTO, false, 0, vcCTX_XID)==VC_NOCTX) ? 0 : "1"; break; } case tgCANONIFY : strcpy(buf, vserver); if (canonifyVserverName(buf)>0) res = buf; break; case tgCONTEXT : res = getContext(buf, vserver, argc==0 || str2bool(argv[0])); break; case tgINITPID_PID : res = getInitPidPid(buf, vserver); break; case tgAPIVER : res = getAPIVer(buf); break; case tgXID : res = getXid(buf, vserver); break; case tgPXID : res = getPXid(buf, vserver); break; case tgSYSINFO : return printSysInfo(buf); break; case tgFEATURE : return testFeature(argc,argv); break; case tgVERIFYCAP : return verifyCap() ? 0 : 1; break; case tgVERIFYPROC : return verifyProc() ? 0 : 1; break; case tgNID : res = getNid(buf, vserver); break; case tgTAG : res = getTag(buf, vserver); break; default : { xid_t xid = *vserver!='\0' ? vc_xidopt2xid(vserver,true,0) : VC_SAMECTX; switch (tag) { case tgID : res = vc_getVserverByCtx(xid,0,0); break; case tgINITPID : res = getInitPid(buf, xid); break; case tgUTS : res = getUTS(buf, xid, argc, argv); break; case tgXIDTYPE : res = getXIDType(xid, argc, argv); break; default : assert(false); abort(); // TODO } } } if (res==0) return EXIT_FAILURE; WRITE_STR(1, res); WRITE_MSG(1, "\n"); return EXIT_SUCCESS; }