int main(int argc, char *argv[]) { char *docname; xmlDocPtr doc; xmlChar *xpath = ("//*"); xmlNodeSetPtr nodeset; xmlXPathObjectPtr result; int i; xmlChar *value; if (argc <= 1) { printf("Usage: %s docname\n", argv[0]); return 0; } docname = argv[1]; doc = getdoc(docname); result = getnodeset(doc, xpath); if (result) { nodeset = result->nodesetval; for (i=0; i < nodeset->nodeNr; i++) { value = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); printf("%s: %s\n", nodeset->nodeTab[i]->name, value); xmlFree(value); } xmlXPathFreeObject(result); } xmlFreeDoc(doc); return 0; }
int main(int argc, char **argv) { int i; if (argc <= 2) { printf("Usage: %s docname xpath\n", argv[0]); return(0); } xmlChar *xpath = (xmlChar*) argv[2]; char* docname = argv[1]; xmlDocPtr doc = getdoc(docname); xmlXPathObjectPtr result = getnodeset (doc, xpath); if (result){ xmlNodeSetPtr nodeset = result->nodesetval; for (i=0; i < nodeset->nodeNr; i++) { xmlChar *text = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); printf("%s\n", text); xmlFree(text); } xmlXPathFreeObject (result); } xmlFreeDoc(doc); xmlCleanupParser(); return (1); }
int editor_type::cmd_i (command_type& ct) { getdoc (ct.param); buffer.append (line2 - 1, ct.param); return ct.command; }
int editor_type::cmd_c (command_type& ct) { getdoc (ct.param); buffer.change (line1, line2, ct.param); return ct.command; }
int main(int argc, char **argv) { char *docname; xmlDocPtr doc; xmlChar *xpath = (xmlChar*) "//storyinfo/keyword"; xmlNodeSetPtr nodeset; xmlXPathObjectPtr result; int i; xmlChar *keyword; if (argc <= 1) { printf("Usage: %s docname\n", argv[0]); return(0); } docname = argv[1]; doc = getdoc(docname); result = getnodeset (doc, xpath); if (result) { nodeset = result->nodesetval; for (i=0; i < nodeset->nodeNr; i++) { keyword = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); printf("keyword: %s\n", keyword); xmlFree(keyword); } xmlXPathFreeObject (result); } xmlFreeDoc(doc); xmlCleanupParser(); return (1); }
void theApp_show_function(const char *path, CORE_ADDR low, CORE_ADDR high) { CSrcD *doc = getdoc(); doc->func(path, low, high); doc->UpdateAllViews(0); }
ValgrindResult* valgrindXML_evaluate(char *xml_path,int testing_framework) { char *docname; xmlDocPtr doc; xmlChar *xpath = (xmlChar*) "//errorcounts/pair/count"; xmlNodeSetPtr nodeset; xmlXPathObjectPtr result; int i; docname = xml_path; doc = getdoc(docname); result = getnodeset (doc, xpath); ValgrindResult *valgrindResult=NULL; //Get all the errors first if (result) { nodeset = result->nodesetval; if(nodeset->nodeNr==0){ //NO valgrind errors for this mutant return NULL; } valgrindResult= malloc(sizeof(ValgrindResult)); //Initialization of valgrindResult valgrindResult->valgrind_error_count=0; valgrindResult->unique_valgrind_error_count=0; //Capturing results in valgrindResult valgrindResult->unique_valgrind_error_count=nodeset->nodeNr; valgrindResult->valgrindErrors = malloc(nodeset->nodeNr*sizeof(ValgrindError)); for (i=0; i < nodeset->nodeNr; i++) { //Get <count></count> xmlNodePtr countNode = nodeset->nodeTab[i]; //Get <unique></unique> xmlNodePtr uniqueNode = xmlNextElementSibling(countNode); //Values for both of the nodes xmlChar *count_value = xmlNodeListGetString(doc, countNode->xmlChildrenNode, 1); xmlChar *unique_value = xmlNodeListGetString(doc, uniqueNode->xmlChildrenNode, 1); int error_count = (int)strtoumax((char*)count_value, NULL, 10); valgrindResult->valgrind_error_count+=error_count; //For each unique value, get all its error nodes evaluate_error_nodes(&valgrindResult->valgrindErrors[i],doc,error_count,unique_value,testing_framework); xmlFree(count_value); xmlFree(unique_value); } xmlXPathFreeObject (result); } xmlFreeDoc(doc); xmlCleanupParser(); return valgrindResult; }
void theApp_show_with_symtab(CSymtab *st) { CSrcD *doc = getdoc(); doc->read_src_by_symtab(st); doc->UpdateAllViews(0); }
void theApp_show_file(const char *path) { CSrcD *doc = getdoc(); doc->read_src_by_filename(path); doc->UpdateAllViews(0); }
/*** inc - translate a mailbox into a set of documents * * We read each message from the mailbox, copying it into * a 'presentation file', which contains the message in * the DH presentation format. We need to translate the * "From " line into presentation header format, but * fortunately the rest of a standard mail message is * conformant with the DH presentation format. * * When we have copied the entire message to this file, * we rewind the stream to the start of that file, and * create a document, setting the text (header and body) * of the document to the message, by a call to puttext(); * * This operation is repeated until the end of the mailbox * is reached. */ static VOID inc(PSTR mboxname, PSTR foldername) { static CHAR lbuf[MAXLEN]; /* line buffer */ FILE *mailbox; /* mailbox file */ FILE *pf; /* presentation format file */ Dhandle dh; /* handle to document being created */ Fhandle fh; /* target folder */ PSTR tmpnam; /* pointer to name of temp. file */ PSTR p; /* open mailbox for reading */ if ( (mailbox = fopen(mboxname, "r")) == NULL ) { fprintf(stderr, "Can't open mailbox '%s'\n", mboxname); exit(1); } /* open up the inbox folder */ if ( (fh = getfolder(foldername, FLD_SPEC)) == ERROR ) { fprintf(stderr, "can't open folder '%s'\n", foldername); fclose(mailbox); exit(1); } /* skip to start of first message */ do { fgets(lbuf, MAXLEN, mailbox); } while ( feof(mailbox) == 0 && !startline(lbuf) ); /* ** at the start of this loop, the stream 'mailbox' ** is either pointing to the end of the mailbox, or ** to the beginning of a message */ while ( feof(mailbox) == 0 ) { /* open presentation format file */ tmpnam = mktmpnam(); pf = fopen(tmpnam, "w+"); #if defined (XENIX) unlink("dhtmp"); #endif fputs ("Mail-Flags: 0001\n", pf); /* copy message into presentation file */ /* if from line contains only "From ", don't output it */ p = lbuf + 4; while ( *p == ' ' ) p++; if ( *p == '\n' ) fgets(lbuf, MAXLEN, mailbox); do { if ( strncmp(lbuf, "Mail-Flags: ", 12) ) fputs(lbuf, pf); fgets(lbuf, MAXLEN, mailbox); } while ( feof(mailbox) == 0 && !startline(lbuf)); fseek(pf, 0L, 0); fflush(pf); /* ** message is now in presentation file, with stream ** positioned at the start of the message */ if ( (dh = getdoc(fh, DOC_CREATE, NULL)) == ERROR ) { fprintf(stderr, "Can't create document\n"); exit(1); } puttext(dh, _fileno(pf)); adddl(fh, getid(dh)); putdoc(dh); fclose(pf); #if defined (MSDOS) _unlink(tmpnam); #endif free(tmpnam); } putfolder(fh); putdl(); fclose(mailbox); }
int pickbackave(char dfil[]) { int ncount, k,maxback; float * ptr; float sum, avg, dlist[7]; float * dbuf = NULL; FILE * fp = NULL; char strwin[] = " Overall-window-avg #windows"; int maxregp1 = 6+1; /* Size for array pointed to by dbuf */ int maxkeys = 1001; /* Size for array pointed to by dbuf */ int openit = TRUE; /* Retrieve window averages from dfil */ if (getdoc((FILE *) NULL, dfil, datexc, maxkeys, maxregp1, &dbuf, &maxback) > 0) { /* Problem retrieving doc file, assume it does not exist */ if (dbuf) free(dbuf); dbuf = NULL; spouts("*** Unable to read doc file: "); spout(dfil); return -1; } ptr = dbuf; sum = 0.0; ncount = 0; /* Sum window averages from dfil */ for (k = 0; k < maxback; k++) { if (*ptr != 0.0) { ncount++; sum += *(ptr+1); } ptr += maxregp1; } if (dbuf) free(dbuf); dbuf = NULL; if (ncount < 1) { spouts("*** No windows for averaging in doc file: "); spout(dfil); XBell(idispl,50); return 0; } /* Find average */ avg = sum / ncount; dlist[0] = 999; dlist[1] = avg; dlist[2] = ncount; dlist[3] = 0.0; dlist[4] = 0.0; dlist[5] = 0.0; dlist[6] = 0.0; /* Save average in doc file */ if (!(fp = savdnc(dfil, datexc, &fp, dlist, 7, &openit, TRUE, FALSE, strwin))) { /* Unable to open the doc file!! */ XBell(idispl,50); XBell(idispl,50); return 0; } fclose(fp); fp = NULL; return ncount; }
static void c_help(char *args) { char *sec = strchr(args, ' '); if(sec) *(sec++) = 0; // list available commands if(!args[0]) { ui_m(NULL, 0, "\nAvailable commands:"); struct cmd *c = cmds; for(; c->f; c++) ui_mf(NULL, 0, " /%s - %s", c->name, getdoc(c)->sum); ui_m(NULL, 0, "\nFor help on key bindings, use `/help keys'.\n"); // list information on a setting } else if((strcmp(args, "set") == 0 || strcmp(args, "hset") == 0) && sec) { sec = strncmp(sec, "color_", 6) == 0 ? "color_*" : sec; struct doc_set *s = (struct doc_set *)doc_sets; for(; s->name; s++) if(strcmp(s->name, sec) == 0) break; if(!s->name) ui_mf(NULL, 0, "\nUnknown setting '%s'.", sec); else ui_mf(NULL, 0, "\nSetting: %s.%s %s\n\n%s\n", s->hub ? "#hub" : "global", s->name, s->type, s->desc); // list available key sections } else if(strcmp(args, "keys") == 0 && !sec) { ui_m(NULL, 0, "\nAvailable sections:"); const struct doc_key *k = doc_keys; for(; k->sect; k++) ui_mf(NULL, 0, " %s - %s", k->sect, k->title); ui_m(NULL, 0, "\nUse `/help keys <name>' to get help on the key bindings for the selected section.\n"); // get information on a particular key section } else if(strcmp(args, "keys") == 0 && sec) { const struct doc_key *k = doc_keys; for(; k->sect; k++) if(strcmp(k->sect, sec) == 0) break; if(!k->sect) ui_mf(NULL, 0, "\nUnknown keys section '%s'.", sec); else ui_mf(NULL, 0, "\nKey bindings for: %s - %s.\n\n%s\n", k->sect, k->title, k->desc); // get information on a particular command } else if(!sec) { if(*args == '/') args++; struct cmd *c = getcmd(args); if(!c) ui_mf(NULL, 0, "\nUnknown command '%s'.", args); else { struct doc_cmd *d = getdoc(c); ui_mf(NULL, 0, "\nUsage: /%s %s\n %s\n", c->name, d->args ? d->args : "", d->sum); if(d->desc) ui_mf(NULL, 0, "%s\n", d->desc); } } else ui_mf(NULL, 0, "\nUnknown help section `%s'.", args); }