static gboolean process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) { epan_dissect_t edt; union wtap_pseudo_header phdr; guint8 pd[WTAP_MAX_PACKET_SIZE]; double cur_time; /* Load the frame from the capture file */ if (!cf_read_frame_r(&cfile, frame, &phdr, pd)) return FALSE; /* failure */ /* Dissect the frame tree not visible */ epan_dissect_init(&edt, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ epan_dissect_fake_protocols(&edt, FALSE); epan_dissect_run(&edt, &phdr, pd, frame, cinfo); /* Get stats from this protocol tree */ process_tree(edt.tree, ps, frame->pkt_len); /* Update times */ cur_time = nstime_to_sec(&frame->abs_ts); if (cur_time < ps->first_time) { ps->first_time = cur_time; } if (cur_time > ps->last_time) { ps->last_time = cur_time; } /* Free our memory. */ epan_dissect_cleanup(&edt); return TRUE; /* success */ }
int main(int argc, char *argv[]) { struct rooted_tree *tree; struct hash *rename_map; struct parameters params; params = get_params(argc, argv); rename_map = read_map(params.map_filename); while (NULL != (tree = parse_tree())) { process_tree(tree, rename_map, params); destroy_tree(tree, DONT_FREE_NODE_DATA); } struct llist *keys = hash_keys(rename_map); if (NULL == keys) { perror(NULL); exit(EXIT_FAILURE); } struct list_elem *e; for (e = keys->head; NULL != e; e = e->next) { char *key = (char *) e->data; char *val = hash_get(rename_map, key); free(val); } destroy_llist(keys); destroy_hash(rename_map); return 0; }
int main(int argc, char *argv[]) { struct rooted_tree *tree; struct parameters params; static struct rooted_tree * (*process_tree)(struct rooted_tree *, set_t *); params = get_params(argc, argv); switch (params.mode) { case PRUNE_DIRECT: process_tree = process_tree_direct; break; case PRUNE_REVERSE: process_tree = process_tree_reverse; break; default: assert (0); } while (NULL != (tree = parse_tree())) { tree = process_tree(tree, params.prune_labels); dump_newick(tree->root); destroy_all_rnodes(NULL); destroy_tree(tree); } destroy_set(params.prune_labels); return 0; }
void traverse_commit_list(struct rev_info *revs, void (*show_commit)(struct commit *), void (*show_object)(struct object_array_entry *)) { int i; struct commit *commit; struct object_array objects = { 0, 0, NULL }; while ((commit = get_revision(revs)) != NULL) { process_tree(revs, commit->tree, &objects, NULL, ""); show_commit(commit); } for (i = 0; i < revs->pending.nr; i++) { struct object_array_entry *pending = revs->pending.objects + i; struct object *obj = pending->item; const char *name = pending->name; if (obj->flags & (UNINTERESTING | SEEN)) continue; if (obj->type == OBJ_TAG) { obj->flags |= SEEN; add_object_array(obj, name, &objects); continue; } if (obj->type == OBJ_TREE) { process_tree(revs, (struct tree *)obj, &objects, NULL, name); continue; } if (obj->type == OBJ_BLOB) { process_blob(revs, (struct blob *)obj, &objects, NULL, name); continue; } die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name); } for (i = 0; i < objects.nr; i++) show_object(&objects.objects[i]); free(objects.objects); if (revs->pending.nr) { free(revs->pending.objects); revs->pending.nr = 0; revs->pending.alloc = 0; revs->pending.objects = NULL; } }
static int get_delta(struct rev_info *revs, struct remote_lock *lock) { int i; struct commit *commit; struct object_list **p = &objects; int count = 0; while ((commit = get_revision(revs)) != NULL) { p = process_tree(commit->tree, p); commit->object.flags |= LOCAL; if (!(commit->object.flags & UNINTERESTING)) count += add_send_request(&commit->object, lock); } for (i = 0; i < revs->pending.nr; i++) { struct object_array_entry *entry = revs->pending.objects + i; struct object *obj = entry->item; const char *name = entry->name; if (obj->flags & (UNINTERESTING | SEEN)) continue; if (obj->type == OBJ_TAG) { obj->flags |= SEEN; p = add_one_object(obj, p); continue; } if (obj->type == OBJ_TREE) { p = process_tree((struct tree *)obj, p); continue; } if (obj->type == OBJ_BLOB) { p = process_blob((struct blob *)obj, p); continue; } die("unknown pending object %s (%s)", oid_to_hex(&obj->oid), name); } while (objects) { if (!(objects->item->flags & UNINTERESTING)) count += add_send_request(objects->item, lock); objects = objects->next; } return count; }
int main(int argc, char **argv) { const char *defos, *outtype; int srv_fds[2]; int dstdir_fd; int opt; pid_t pid; defos = NULL; outtype = "ascii"; while ((opt = getopt(argc, argv, "I:T:")) != -1) { switch (opt) { case 'I': defos = optarg; break; case 'T': outtype = optarg; break; default: usage(); } } if (argc > 0) { argc -= optind; argv += optind; } if (argc != 2) usage(); if (socketpair(AF_LOCAL, SOCK_STREAM, AF_UNSPEC, srv_fds) == -1) err(1, "socketpair"); pid = fork(); switch (pid) { case -1: err(1, "fork"); case 0: close(srv_fds[0]); run_mandocd(srv_fds[1], outtype, defos); default: break; } close(srv_fds[1]); if ((dstdir_fd = open(argv[1], O_RDONLY | O_DIRECTORY)) == -1) err(1, "open(%s)", argv[1]); if (chdir(argv[0]) == -1) err(1, "chdir(%s)", argv[0]); return process_tree(srv_fds[0], dstdir_fd) == -1 ? 1 : 0; }
void traverse_commit_list(struct rev_info *revs, show_commit_fn show_commit, show_object_fn show_object, void *data) { int i; struct commit *commit; struct strbuf base; strbuf_init(&base, PATH_MAX); while ((commit = get_revision(revs)) != NULL) { /* * an uninteresting boundary commit may not have its tree * parsed yet, but we are not going to show them anyway */ if (commit->tree) add_pending_tree(revs, commit->tree); show_commit(commit, data); } for (i = 0; i < revs->pending.nr; i++) { struct object_array_entry *pending = revs->pending.objects + i; struct object *obj = pending->item; const char *name = pending->name; if (obj->flags & (UNINTERESTING | SEEN)) continue; if (obj->type == OBJ_TAG) { obj->flags |= SEEN; show_object(obj, NULL, name); continue; } if (obj->type == OBJ_TREE) { process_tree(revs, (struct tree *)obj, show_object, NULL, &base, name); continue; } if (obj->type == OBJ_BLOB) { process_blob(revs, (struct blob *)obj, show_object, NULL, name); continue; } die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name); } if (revs->pending.nr) { free(revs->pending.objects); revs->pending.nr = 0; revs->pending.alloc = 0; revs->pending.objects = NULL; } strbuf_release(&base); }
int process_site() { int res = 0; res = prepare_site(); if (res != 0) return -1; res = process_tree(); res = generate_pages(); // res = generate_redirections(); // res = generate_sitemap(); return res; }
int main(int argc, char *argv[]) { struct rooted_tree *tree; struct parameters params; params = get_params(argc, argv); while (NULL != (tree = parse_tree())) { /* tree is free()d in process_tree(), as derooting is * compatible with ordinary free()ing (with destroy_tree()), * but rerooting is not. */ process_tree(tree, params); } destroy_llist(params.labels); return 0; }
int main(int argc, char *argv[]) { struct rooted_tree *tree; struct parameters params; params = get_params(argc, argv); while (NULL != (tree = parse_tree())) { /* tree is free()d in process_tree(), as derooting is * compatible with ordinary free()ing (with * destroy_tree()), but rerooting is not. */ // TODO: why not? Can this be obsolete now that rnodes are // free()d at the end? process_tree(tree, params); } destroy_llist(params.labels); return 0; }
static void process_tree(struct rev_info *revs, struct tree *tree, struct object_array *p, struct name_path *path, const char *name) { struct object *obj = &tree->object; struct tree_desc desc; struct name_entry entry; struct name_path me; if (!revs->tree_objects) return; if (!obj) die("bad tree object"); if (obj->flags & (UNINTERESTING | SEEN)) return; if (parse_tree(tree) < 0) die("bad tree object %s", sha1_to_hex(obj->sha1)); obj->flags |= SEEN; name = xstrdup(name); add_object(obj, p, path, name); me.up = path; me.elem = name; me.elem_len = strlen(name); init_tree_desc(&desc, tree->buffer, tree->size); while (tree_entry(&desc, &entry)) { if (S_ISDIR(entry.mode)) process_tree(revs, lookup_tree(entry.sha1), p, &me, entry.path); else if (S_ISGITLINK(entry.mode)) process_gitlink(revs, entry.sha1, p, &me, entry.path); else process_blob(revs, lookup_blob(entry.sha1), p, &me, entry.path); } free(tree->buffer); tree->buffer = NULL; }
int main(int argc, char **argv) { int64_t i; if (argc<3) { printf("Usage: %s box_size tree.dat ...\n", argv[0]); exit(1); } box_size = atof(argv[1]); init_time_table(0.27, 0.7); printf("#Scale Id Mvir_acc(Host) Rvir_acc(Host) Mnow Vnow Mlastmm Vlastmm Rlastmm Rlastmm/Rvir Vacc Mistracked? RlastMajM Rlastmillim a_acc a_lastmm a_lastmajm a_lastmillim\n"); for (i=2; i<argc; i++) { read_tree(argv[i]); process_tree(); delete_tree(); } return 0; }
static void traverse_trees_and_blobs(struct rev_info *revs, struct strbuf *base, show_object_fn show_object, void *show_data, filter_object_fn filter_fn, void *filter_data) { int i; assert(base->len == 0); for (i = 0; i < revs->pending.nr; i++) { struct object_array_entry *pending = revs->pending.objects + i; struct object *obj = pending->item; const char *name = pending->name; const char *path = pending->path; if (obj->flags & (UNINTERESTING | SEEN)) continue; if (obj->type == OBJ_TAG) { obj->flags |= SEEN; show_object(obj, name, show_data); continue; } if (!path) path = ""; if (obj->type == OBJ_TREE) { process_tree(revs, (struct tree *)obj, show_object, base, path, show_data, filter_fn, filter_data); continue; } if (obj->type == OBJ_BLOB) { process_blob(revs, (struct blob *)obj, show_object, base, path, show_data, filter_fn, filter_data); continue; } die("unknown pending object %s (%s)", oid_to_hex(&obj->oid), name); } object_array_clear(&revs->pending); }
static gboolean process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats_t* ps) { epan_dissect_t edt; struct wtap_pkthdr phdr; Buffer buf; double cur_time; wtap_phdr_init(&phdr); /* Load the record from the capture file */ ws_buffer_init(&buf, 1500); if (!cf_read_record_r(cf, frame, &phdr, &buf)) return FALSE; /* failure */ /* Dissect the record tree not visible */ epan_dissect_init(&edt, cf->epan, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ epan_dissect_fake_protocols(&edt, FALSE); epan_dissect_run(&edt, cf->cd_t, &phdr, frame_tvbuff_new_buffer(frame, &buf), frame, cinfo); /* Get stats from this protocol tree */ process_tree(edt.tree, ps, frame->pkt_len); if (frame->flags.has_ts) { /* Update times */ cur_time = nstime_to_sec(&frame->abs_ts); if (cur_time < ps->first_time) ps->first_time = cur_time; if (cur_time > ps->last_time) ps->last_time = cur_time; } /* Free our memory. */ epan_dissect_cleanup(&edt); wtap_phdr_cleanup(&phdr); ws_buffer_free(&buf); return TRUE; /* success */ }
int main(int argc, char *argv[]) { struct rooted_tree *tree; struct parameters params; params = get_params(argc, argv); while ((tree = parse_tree()) != NULL) { process_tree(tree, params); destroy_tree(tree, DONT_FREE_NODE_DATA); } if (EXACT == params.mode) destroy_llist(params.labels); else { /* This does not free 'params.regexp' itself, only memory pointed to by 'params.regexp' * members and allocated by regcomp().*/ regfree(params.regexp); /* Therefore: */ free(params.regexp); } return 0; }
static int process_object(struct walker *walker, struct object *obj) { if (obj->type == OBJ_COMMIT) { if (process_commit(walker, (struct commit *)obj)) return -1; return 0; } if (obj->type == OBJ_TREE) { if (process_tree(walker, (struct tree *)obj)) return -1; return 0; } if (obj->type == OBJ_BLOB) { return 0; } if (obj->type == OBJ_TAG) { if (process_tag(walker, (struct tag *)obj)) return -1; return 0; } return error("Unable to determine requirements " "of type %s for %s", typename(obj->type), sha1_to_hex(obj->sha1)); }
static gboolean process_record(capture_file *cf, frame_data *frame, column_info *cinfo, wtap_rec *rec, Buffer *buf, ph_stats_t* ps) { epan_dissect_t edt; double cur_time; /* Load the record from the capture file */ if (!cf_read_record(cf, frame, rec, buf)) return FALSE; /* failure */ /* Dissect the record tree not visible */ epan_dissect_init(&edt, cf->epan, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ epan_dissect_fake_protocols(&edt, FALSE); epan_dissect_run(&edt, cf->cd_t, rec, frame_tvbuff_new_buffer(&cf->provider, frame, buf), frame, cinfo); /* Get stats from this protocol tree */ process_tree(edt.tree, ps); if (frame->has_ts) { /* Update times */ cur_time = nstime_to_sec(&frame->abs_ts); if (cur_time < ps->first_time) ps->first_time = cur_time; if (cur_time > ps->last_time) ps->last_time = cur_time; } /* Free our memory. */ epan_dissect_cleanup(&edt); return TRUE; /* success */ }
static void process_tree(struct rev_info *revs, struct tree *tree, show_object_fn show, struct name_path *path, struct strbuf *base, const char *name) { struct object *obj = &tree->object; struct tree_desc desc; struct name_entry entry; struct name_path me; int all_interesting = (revs->diffopt.pathspec.nr == 0); int baselen = base->len; if (!revs->tree_objects) return; if (!obj) die("bad tree object"); if (obj->flags & (UNINTERESTING | SEEN)) return; if (parse_tree(tree) < 0) die("bad tree object %s", sha1_to_hex(obj->sha1)); obj->flags |= SEEN; show(obj, path, name); me.up = path; me.elem = name; me.elem_len = strlen(name); if (!all_interesting) { strbuf_addstr(base, name); if (base->len) strbuf_addch(base, '/'); } init_tree_desc(&desc, tree->buffer, tree->size); while (tree_entry(&desc, &entry)) { if (!all_interesting) { int showit = tree_entry_interesting(&entry, base, 0, &revs->diffopt.pathspec); if (showit < 0) break; else if (!showit) continue; else if (showit == 2) all_interesting = 1; } if (S_ISDIR(entry.mode)) process_tree(revs, lookup_tree(entry.sha1), show, &me, base, entry.path); else if (S_ISGITLINK(entry.mode)) process_gitlink(revs, entry.sha1, show, &me, entry.path); else process_blob(revs, lookup_blob(entry.sha1), show, &me, entry.path); } strbuf_setlen(base, baselen); free(tree->buffer); tree->buffer = NULL; }
static void process_tree(struct rev_info *revs, struct tree *tree, show_object_fn show, struct strbuf *base, const char *name, void *cb_data) { struct object *obj = &tree->object; struct tree_desc desc; struct name_entry entry; enum interesting match = revs->diffopt.pathspec.nr == 0 ? all_entries_interesting: entry_not_interesting; int baselen = base->len; if (!revs->tree_objects) return; if (!obj) die("bad tree object"); if (obj->flags & (UNINTERESTING | SEEN)) return; if (parse_tree_gently(tree, revs->ignore_missing_links) < 0) { if (revs->ignore_missing_links) return; die("bad tree object %s", oid_to_hex(&obj->oid)); } obj->flags |= SEEN; strbuf_addstr(base, name); show(obj, base->buf, cb_data); if (base->len) strbuf_addch(base, '/'); init_tree_desc(&desc, tree->buffer, tree->size); while (tree_entry(&desc, &entry)) { if (match != all_entries_interesting) { match = tree_entry_interesting(&entry, base, 0, &revs->diffopt.pathspec); if (match == all_entries_not_interesting) break; if (match == entry_not_interesting) continue; } if (S_ISDIR(entry.mode)) process_tree(revs, lookup_tree(entry.sha1), show, base, entry.path, cb_data); else if (S_ISGITLINK(entry.mode)) process_gitlink(revs, entry.sha1, show, base, entry.path, cb_data); else process_blob(revs, lookup_blob(entry.sha1), show, base, entry.path, cb_data); } strbuf_setlen(base, baselen); free_tree_buffer(tree); }