//--------------------------------------------------------------------------- void Policy::export_schema(const char* filename) { xmlDocPtr new_doc = create_doc(); xmlSaveFormatFile(filename, new_doc, 2); xmlFreeDoc(new_doc); saved = true; }
void create_generic_doc(long size) { char filename[64]; int prefix_len; if ((size % 1048576) == 0) { prefix_len = sprintf(filename, "%ldM", size / 1048576); } else if ((size % 1024) == 0) { prefix_len = sprintf(filename, "%ldK", size / 1024); } else { prefix_len = sprintf(filename, "%ldB", size); } strcpy(filename + prefix_len, ".txt"); create_doc(filename, size, NULL, -1, 0); strcpy(filename + prefix_len, "-w-header.txt"); create_doc(filename, size, NULL, -1, 1); }
//--------------------------------------------------------------------------- int Policy::dump_schema(std::string& data) { xmlDocPtr new_doc = create_doc(); if (!new_doc) return -1; xmlChar *mem = NULL; int size = 0; xmlDocDumpFormatMemory(new_doc, &mem, &size, 2); if (size > 0) { data = std::string((const char*)mem, size); xmlFree(mem); } xmlFreeDoc(new_doc); return 0; }
//--------------------------------------------------------------------------- int Policy::export_schema(const char* filename, std::string& err) { Schema s(no_https); xmlSetGenericErrorFunc(&s, &s.manage_generic_error); xmlDocPtr new_doc = create_doc(); if (!new_doc) { err = error; xmlSetGenericErrorFunc(NULL, NULL); return -1; } int ret = xmlSaveFormatFile(filename, new_doc, 2); xmlFreeDoc(new_doc); xmlSetGenericErrorFunc(NULL, NULL); if (ret < 0) { err = "cannot save the schema"; return -1; } return 0; }
/* * Main entry to availdisks. * * @return 0 on successful exit, non-zero otherwise */ int main(int argc, char **argv) { int error = 0; int get_pools = 0; int get_devices = 0; /* Examine first arg */ int c = getopt(argc, argv, CLI_OPTSTRING); switch (c) { case CLI_ARG_ALL: get_devices = 1; get_pools = 1; break; case CLI_ARG_DEVICES: get_devices = 1; break; case CLI_ARG_POOLS: get_pools = 1; break; default: return (1); break; } argc -= optind; argv += optind; if (get_pools || get_devices) { xmlDocPtr doc = create_doc(); xmlNodePtr root = xmlDocGetRootElement(doc); if (get_devices) { /* Create the available node */ xmlNodePtr available = xmlNewChild(root, NULL, (xmlChar *)ELEMENT_AVAILABLE, NULL); /* libzfs_jni_diskmgt.o error handler */ dmgt_set_error_handler(handle_error); error = dmgt_avail_disk_iter( add_disk_to_xml, &available); } if (get_pools && !error) { /* Create the importable node */ xmlNodePtr importable = xmlNewChild(root, NULL, (xmlChar *)ELEMENT_IMPORTABLE, NULL); error = zjni_ipool_iter( argc, argv, add_pool_to_xml, &importable); } if (!error) { /* Print out XML */ (void) xmlDocFormatDump(stdout, doc, 1); } xmlFreeDoc(doc); } return (error != 0); }
int main(int argc, char *argv[]) { char *docdir = "docs"; while (argc > 1) { if (strncmp(argv[1], "-d", 2) == 0) { if (argv[1][2] != '\0') { docdir = argv[1] + 2; argv++; argc--; } else if (argc > 2) { docdir = argv[2]; argv += 2; argc -= 2; } else { fprintf(stderr, "The -d option requires an argument!\n"); return 1; } } else { break; } } mkdir(docdir, 0777); if (chdir(docdir) < 0) { return -1; } create_generic_doc(0); create_generic_doc(1); create_generic_doc(2); create_generic_doc(10); create_generic_doc(960); create_generic_doc(1024); create_generic_doc(1024 * 2); create_generic_doc(1024 * 3); create_generic_doc(1024 * 4); create_generic_doc(1024 * 5); create_generic_doc(1024 * 10); create_generic_doc(14900); /* Mean spec file size */ create_generic_doc(1024 * 100); create_generic_doc(1024 * 1024); // create_generic_doc(1024*1024*1024); #ifdef AFFINITY create_generic_doc(1024 * 20); create_generic_doc(1024 * 25); create_generic_doc(3 * 1024 * 1024); create_generic_doc(4 * 1024 * 1024); create_generic_doc(5 * 1024 * 1024); #endif /* AFFINITY */ create_doc("one_pkt", -1, " 1024 file_set/dir00000/class1_0\n" "f<!WEB99CAD><IMG SRC=\"/file_set/dirNNNNN/classX_Y\"><!/WEB99CAD>\n" "o[|2l}Dos85m4s@`1aCHF0Pi7%p9p]Wa:Sq(R5wEM,4^|S@05bWZo'C(+3?ypsZ\n" ",HM2w`)?/2Pl1$/@8ntq`{5e&G&!9v[C@(T8gZVsk&by)n;>^00>+D&0j+/&\"iF\n" "A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