std::string help(Namespace *ns) const { if (ns == NULL) { return ""; } std::stringstream sstr; if(ns!=getGlobal()->getGlobalNamespace()){ sstr <<"\tNamespace " << ns->name() << " consists of: \n"; } printSubBlockInfo(ns->subspaces(), "Namespaces", sstr); if(not ns->subspaces().empty()){ sstr <<"\t\t\tFor more information on a nested namespace, type help(<namespacename>)\n"; } printSubBlockInfo(ns->vocabularies(), "Vocabularies", sstr); printSubBlockInfo(ns->theories(), "Theories", sstr); printSubBlockInfo(ns->structures(), "Structures", sstr); printSubBlockInfo(ns->terms(), "Terms", sstr); printSubBlockInfo(ns->queries(), "Queries", sstr); // FIXME additional blocks are not detected automatically! // Printing procedures std::map<std::string, std::string> procedures; // Get text for each internal procedure in the given namespace for (auto i = getAllInferences().cbegin(); i < getAllInferences().cend(); ++i) { if ((*i)->getNamespace() == ns->name()) { std::vector<std::string> args; for (auto j = (*i)->getArgumentTypes().cbegin(); j < (*i)->getArgumentTypes().cend(); ++j) { args.push_back(toCString(*j)); } auto text = printProcedure((*i)->getName(), args, (*i)->getDescription()); procedures.insert({text, ""}); } } // Get text for each user defined procedure in the given namespace for (auto it = ns->procedures().cbegin(); it != ns->procedures().cend(); ++it) { auto text = printProcedure(it->first, it->second->args(), it->second->description()); procedures.insert({text, ""}); } if (procedures.empty()) { if (ns->isGlobal()) { sstr << "\t\tThere are no procedures in the global namespace\n"; } else { sstr << "\t\tThere are no procedures in namespace "; ns->putName(sstr); sstr << '\n'; } } else { printSubBlockInfo(procedures, "Procedures", sstr); } return sstr.str(); }
void printScript(struct SCRIPT * script){ int i; printf("\\** Script: %s *************************************/\n",script->name); printf("[+] Global variables:\n"); if(script->nbvar){ for(i=0;i<script->nbvar;i++) printf(" | -%s\n",script->variables[i]); printf("\n"); }//if global variable printManagers(&script->managers); printf("\n"); printf("[+] Code:\n | -%d lines of code\n",script->nblines); printf("[+] Script Functions:\n"); for(i=0;i<script->nbfunc;i++){ printf("------------------------\n"); printFunction(&script->functionslist[i]); } printf("------------------------\n"); printf("\n"); printf("[+] Script Procedures:\n"); for(i=0;i<script->nbproc;i++){ printf("------------------------\n"); printProcedure(&script->procedureslist[i]); } printf("------------------------\n"); printf("\n"); if(script->strciphered){ printf("[+] String ciphered by %s\n\n", script->functionslist[script->cipherfunction].name); } printf("\\** End Script: %s *********************************/\n\n\n",script->name); }