void XMLPrintVisitor::processObject(T obj) { for (int i=0; i<level; i++) m_out << "\t"; std::string classname = obj->getClassName(); std::string templatename = obj->getTemplateName(); m_out << "<" << xmlencode(classname); if (!templatename.empty()) m_out << " template=\"" << xmlencode(templatename) << "\""; obj->writeDatas( m_out, " " ); m_out << "/>" << std::endl; }
/* make a partially valid xml for the system */ void makeitvalidxml(char **post) { int actsize = 512, actpoint = 0; char temp[256], *temppass; if ((*post = malloc(sizeof(char)*actsize)) == NULL) { fprintf(stderr, "Malloc error...\n"); exit(1); } memset(*post, '\0', actsize); sprintf(*post, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<crack>\n<sessionid>%s</sessionid>\n<format>%s</format>\n", xmlxml.sessionid, xmlxml.format); if (crackedhash != NULL) { while(strstr(crackedhash+actpoint, "\n")) { memset(temp, '\0', 256); strncpy(temp, crackedhash+actpoint, strstr(crackedhash+actpoint, "\n")-crackedhash-actpoint); actpoint = strstr(crackedhash+actpoint, "\n")-crackedhash+1; if (strlen(*post)+strlen(temp)+23>=actsize) { actsize += 512; if ((*post = realloc(*post, sizeof(char) * actsize)) == NULL) { fprintf(stderr, "Malloc error...\n"); exit(1); } memset(*post+actsize-512, '\0', 512); } strncpy(*post+strlen(*post), "<plain hash=\"", strlen("<plain hash=\"")); strncpy(*post+strlen(*post), strstr(temp, "\1")+1, strlen(temp)-(strstr(temp, "\1")-temp)-1); strncpy(*post+strlen(*post), "\">", 2); if ((temppass = malloc(sizeof(char)*(strstr(temp, "\1")-temp)*4+1)) == NULL) { fprintf(stderr, "Malloc error...\n"); exit(1); } memset(temppass, '\0', sizeof(char)*(strstr(temp, "\1")-temp)*4+1); xmlencode(temp, temppass); strncpy(*post+strlen(*post), temppass, strlen(temppass)); free(temppass); strncpy(*post+strlen(*post), "</plain>\n", strlen("</plain>\n")); } } if (strlen(*post)+strlen("</crack>\n")+1>=actsize) { actsize += strlen("</crack>\n")+1; if ((*post = realloc(*post, sizeof(char) * actsize)) == NULL) { fprintf(stderr, "Malloc error...\n"); exit(1); } memset(*post+actsize-strlen("</crack>\n")-1, '\0', strlen("</crack>\n")+1); } strncpy(*post+strlen(*post), "</crack>\n", strlen("</crack>\n")); }