bool CrpcBase::rpcInt(CXmlNodePtr param, const char *name, int& value) { cvs::string fnd; CXmlNodePtr val; val = param->Clone(); if(!strcmp(val->GetName(),"param")) val->GetChild(); if(!strcmp(val->GetName(),"struct")) { if(name) { cvs::sprintf(fnd,64,"member[@name='%s']",name); if(!val->Lookup(fnd.c_str())) return false; if(!val->XPathResultNext()) return false; } else val->GetChild(); val->GetChild("value"); } if(strcmp(val->GetName(),"value")) return false; if(!val->GetChild()) return false; if(strcmp(val->GetName(),"i4")) return false; value = atoi(val->GetValue()); return true; }
bool CrpcBase::rpcObj(CXmlNodePtr param, const char *name, rpcObject *rpcObj) { cvs::string fnd; CXmlNodePtr val; val = param->Clone(); if(!strcmp(val->GetName(),"param")) val->GetChild(); if(!strcmp(val->GetName(),"struct")) { if(name) { cvs::sprintf(fnd,64,"member[@name='%s']",name); if(!val->Lookup(fnd.c_str())) return false; if(!val->XPathResultNext()) return false; } else val->GetChild(); val->GetChild("value"); } if(strcmp(val->GetName(),"value")) return false; if(!val->GetChild()) return false; if(strcmp(val->GetName(),"struct")) return false; return rpcObj->Marshall(val); }
int chacl_fileproc(void *callerdat, struct file_info *finfo) { CXmlNodePtr acl; /* If someone has specified 'chacl foo' and foo is a directory, you'll get a dirent plus every file in the directory. We only want to set the directory in this case */ if(acl_directory_set && !strcmp(finfo->repository, acl_directory_set)) return 0; Vers_TS *vers = Version_TS (finfo, NULL, NULL, NULL, 0, 0, 0); if(!vers->vn_user && !vers->vn_rcs) { if (!really_quiet) error (0, 0, "nothing known about %s", fn_root(finfo->fullname)); freevers_ts(&vers); return 0; } freevers_ts(&vers); if(!quiet) printf("%sing ACL for file %s\n",parms.del?"delet":"sett",finfo->file); acl = fileattr_getroot(); acl->xpathVariable("name",finfo->file); if(!acl->Lookup("file[cvs:filename(@name,$name)]") || !acl->XPathResultNext()) { acl = fileattr_getroot(); acl->NewNode("file"); acl->NewAttribute("name",finfo->file); } set_acl(acl); return 0; }
int lsacl_fileproc(void *callerdat, struct file_info *finfo) { CXmlNodePtr acl; acl = fileattr_getroot(); acl->xpathVariable("name",finfo->file); if(acl->Lookup("file[cvs:filename(@name,$name)]/acl") && acl->XPathResultNext()) { printf("File: %s\n",finfo->file); show_acl(acl); } return 0; }
bool CXmlTree::CreateCache(unsigned cacheId, const char *path, const char *attribute /*= NULL*/, CacheFlags flags /*= cacheDefault*/) { CXmlNodePtr node = GetRoot(); if(!node->Lookup(path)) { CServerIo::trace(3,"CreateCache node lookup failed"); return false; } cache_t& cache = m_Cache[cacheId]; cache.flags = flags; if(flags&cacheFilename) { if(cache.filenameMap) delete cache.filenameMap; cache.filenameMap = new std::map<cvs::filename, xmlNodePtr>; } else if(flags&cacheUsername) { if(cache.usernameMap) delete cache.usernameMap; cache.usernameMap = new std::map<cvs::username, xmlNodePtr>; } else { if(cache.standardMap) delete cache.standardMap; cache.standardMap = new std::map<cvs::string, xmlNodePtr>; } while(node->XPathResultNext()) { const char *value; if(attribute) { if(attribute[0]=='@') value = node->GetAttrValue(attribute+1); else value = node->GetNodeValue(attribute); } else value = node->GetValue(); if(value) { if(flags&cacheFilename) (*cache.filenameMap)[value]=node->Object(); else if(flags&cacheUsername) (*cache.usernameMap)[value]=node->Object(); else (*cache.standardMap)[value]=node->Object(); } } return true; }