void InspIRCd::ProcessColors(file_cache& input) { /* * Replace all color codes from the special[] array to actual * color code chars using C++ style escape sequences. You * can append other chars to replace if you like -- Justasic */ static struct special_chars { std::string character; std::string replace; special_chars(const std::string& c, const std::string& r) : character(c) , replace(r) { } } special[] = { special_chars("\\b", "\x02"), // Bold special_chars("\\c", "\x03"), // Color special_chars("\\i", "\x1D"), // Italic special_chars("\\m", "\x11"), // Monospace special_chars("\\r", "\x16"), // Reverse special_chars("\\s", "\x1E"), // Strikethrough special_chars("\\u", "\x1F"), // Underline special_chars("\\x", "\x0F"), // Reset special_chars("", "") }; for(file_cache::iterator it = input.begin(), it_end = input.end(); it != it_end; it++) { std::string ret = *it; for(int i = 0; special[i].character.empty() == false; ++i) { std::string::size_type pos = ret.find(special[i].character); if(pos == std::string::npos) // Couldn't find the character, skip this line continue; if((pos > 0) && (ret[pos-1] == '\\') && (ret[pos] == '\\')) continue; // Skip double slashes. // Replace all our characters in the array while(pos != std::string::npos) { ret = ret.substr(0, pos) + special[i].replace + ret.substr(pos + special[i].character.size()); pos = ret.find(special[i].character, pos + special[i].replace.size()); } } // Replace double slashes with a single slash before we return std::string::size_type pos = ret.find("\\\\"); while(pos != std::string::npos) { ret = ret.substr(0, pos) + "\\" + ret.substr(pos + 2); pos = ret.find("\\\\", pos + 1); } *it = ret; } }
* along with this program; if not, see see <http://www.gnu.org/licenses/>. */ #include "module.h" #include "modules/xmlrpc.h" #include "modules/httpd.h" static struct special_chars { Anope::string character; Anope::string replace; special_chars(const Anope::string &c, const Anope::string &r) : character(c), replace(r) { } } special[] = { special_chars("&", "&"), special_chars("\"", """), special_chars("<", "<"), special_chars(">", "&qt;"), special_chars("'", "'"), special_chars("\n", "
"), special_chars("\002", ""), // bold special_chars("\003", ""), // color special_chars("\035", ""), // italics special_chars("\037", ""), // underline special_chars("\026", ""), // reverses special_chars("", "") }; class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage {
int dlcall( void* ptr, char** argv, int argc, Prototype proto ) { int i, j, tmp; int ret; if( argc < proto.type_count ) { printf("* Too few arguments.\n"); return 1; } for(i = 0;i < /*proto.type_count*/argc;i++) { if(!strcmp(argv[i],"##")) { argv[i] = specialPointer; continue; } else if(!strcmp(argv[i],"stdin")) { argv[i] = (char*)stdin; continue; } else if(!strcmp(argv[i],"stdout")) { argv[i] = (char*)stdout; continue; } else if(!strcmp(argv[i],"NULL")) { argv[i] = (char*)NULL; continue; } if(!strncmp(argv[i],"0x",2)) { tmp = strtol( argv[i] + 2, NULL, 16 ); argv[i] = (char*)tmp; continue; } else if(!strncmp(argv[i],"*[int*]0x",9)) { tmp = strtol( argv[i] + 9, NULL, 16 ); argv[i] = *(int*)tmp; continue; } else if(!strncmp(argv[i],"*[char*]0x",10)) { tmp = strtol( argv[i] + 10, NULL, 16 ); argv[i] = *((char*)tmp); continue; } else if(!strncmp(argv[i],"*[int*]##",9)) { argv[i] = *(int*)specialPointer; continue; } else if(!strncmp(argv[i],"*[char*]##",10)) { argv[i] = *(char*)specialPointer; continue; } if(i < proto.type_count) { if(proto.types[i] == Integer) { tmp = atoi(argv[i]); argv[i] = (char*)tmp; } else if(proto.types[i] == Double) { tmp = atof(argv[i]); argv[i] = (char*)tmp; } else if(proto.types[i] == Pointer) { special_chars( argv[i] ); } } } for(i = 0,j = 0;i < argc;i++, j += 4) asm("movl %0, (%%esp,%1)" : :"r"(argv[i]), "r"(j) ); asm("call *%0" : :"r"(ptr)); asm("movl %%eax, %0" :"=r"(ret)); return ret; }