void dump_attr( struct xmlAttr *attr ) { if( attr == 0 ) { return; } printf( "ID:%s VALUE:%s\t", attr->name, attr->value ); dump_attr( attr->next ); }
static int dump_repodata_cb(void *vcbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv) { if (key->name == REPOSITORY_SOLVABLES) return SEARCH_NEXT_SOLVABLE; if (!dump_json) return dump_attr(data->repo, data, key, kv); else return dump_attr_json(data->repo, data, key, kv, vcbdata); }
void dump_node( struct xmlNode *node ) { if( node == 0 ) { return; } printf( "Node:%s Attr:", node->name ); dump_attr( node->attr_list ); putc( '\n', stdout ); dump_node( node->children ); dump_node( node->sibling ); }
int main(int ac, char **av) { const char *classpath = DEFAULT_CLASSPATH; char *classname; _jc_classbytes *cb; _jc_classfile *cf; jboolean deps = JNI_FALSE; int flags = 0; _jc_env *env; _jc_jvm *vm; int i; /* Initialize */ env = _jc_support_init(); vm = env->vm; /* Parse command line */ for (av++, ac--; ac > 0 && **av == '-'; av++, ac--) { if (strcmp(av[0], "-d") == 0) deps = JNI_TRUE; else if (strcmp(*av, "-e") == 0) flags |= DUMP_ENCODE_NAMES; else if (strcmp(*av, "-c") == 0) flags |= DUMP_TRANS_CLOSURE; else if (strcmp(*av, "-cp") == 0 || strcmp(*av, "-classpath") == 0) { av++, ac--; if (ac == 0) usage(); classpath = *av; } else usage(); } if (ac != 1) usage(); /* Parse classpath */ if (_jc_parse_classpath(env, classpath, &vm->boot.class_path, &vm->boot.class_path_len) != JNI_OK) errx(1, "%s: %s", _jc_vmex_names[env->ex.num], env->ex.msg); /* Get class name */ classname = av[0]; for (i = 0; classname[i] != '\0'; i++) { if (classname[i] == '.') classname[i] = '/'; } /* Read in classfile */ if ((cb = _jc_bootcl_find_classbytes(env, classname, NULL)) == NULL) { errx(1, "can't load class `%s': %s: %s", classname, _jc_vmex_names[env->ex.num], env->ex.msg); } /* Parse classfile */ if ((cf = _jc_parse_classfile(env, cb, 2)) == NULL) { errx(1, "can't parse class `%s': %s: %s", classname, _jc_vmex_names[env->ex.num], env->ex.msg); } _jc_free_classbytes(&cb); /* Just dump dependencies? */ if (deps) { do_deps(env, cf, flags); goto done; } /* Dump parsed classfile */ printf("version=\t%d.%d\n", cf->major_version, cf->minor_version); printf("num_constants=\t%d\n", cf->num_constants); for (i = 1; i < cf->num_constants; i++) { _jc_cf_constant *const cp = &cf->constants[i - 1]; if (cp->type == 0) continue; printf("[%2d]\t", i); dump_const(cp); printf("\n"); } printf("access_flags=\t0x%04x\n", cf->access_flags); printf("name=\t\t%s\n", cf->name); printf("superclass=\t%s\n", cf->superclass ? cf->superclass : "<NONE>"); printf("num_interfaces=\t%d\n", cf->num_interfaces); for (i = 0; i < cf->num_interfaces; i++) printf("[%2d]\t%s\n", i, cf->interfaces[i]); printf("num_fields=\t%d\n", cf->num_fields); for (i = 0; i < cf->num_fields; i++) { _jc_cf_field *const field = &cf->fields[i]; printf("[%2d]\tname=\t\t%s\n", i, field->name); printf("\tdescriptor=\t%s\n", field->descriptor); printf("\taccess_flags=\t0x%04x\n", field->access_flags); printf("\tnum_attributes=\t%d\n", field->num_attributes); dump_attr(env, 1, cf, field->attributes, field->num_attributes); } printf("num_methods=\t%d\n", cf->num_methods); for (i = 0; i < cf->num_methods; i++) { _jc_cf_method *const method = &cf->methods[i]; printf("[%2d]\tname=\t\t%s\n", i, method->name); printf("\tdescriptor=\t%s\n", method->descriptor); printf("\taccess_flags=\t0x%04x\n", method->access_flags); printf("\tnum_attributes=\t%d\n", method->num_attributes); dump_attr(env, 1, cf, method->attributes, method->num_attributes); } printf("num_attributes=\t%d\n", cf->num_attributes); dump_attr(env, 0, cf, cf->attributes, cf->num_attributes); done: /* Clean up and exit */ _jc_destroy_classfile(&cf); return 0; }
/** * \internal * Add a set of consecutive runs to an attribute. This will add and remove FILLER entries * as needed and update internal variables. * * @param a_fs File system run is from * @param fs_attr Attribute to add run to * @param a_data_run_new The set of runs to add. * * @returns 1 on error and 0 on succes */ uint8_t tsk_fs_attr_add_run(TSK_FS_INFO * a_fs, TSK_FS_ATTR * a_fs_attr, TSK_FS_ATTR_RUN * a_data_run_new) { TSK_FS_ATTR_RUN *data_run_cur, *data_run_prev; TSK_DADDR_T run_len; tsk_error_reset(); if (a_fs_attr == NULL) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_ARG); tsk_error_set_errstr ("tsk_fs_attr_add_run: Error, a_fs_attr is NULL"); return 1; } // we only support the case of a null run if it is the only run... if (a_data_run_new == NULL) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_ARG); tsk_error_set_errstr ("tsk_fs_attr_add_run: Error, a_data_run_new is NULL (%" PRIuINUM ")", a_fs_attr->fs_file->meta->addr); return 1; } run_len = 0; data_run_cur = a_data_run_new; while (data_run_cur) { run_len += data_run_cur->len; data_run_cur = data_run_cur->next; } /* First thing, is to check if we can just add it to the end */ if ((a_fs_attr->nrd.run_end) && (a_fs_attr->nrd.run_end->offset + a_fs_attr->nrd.run_end->len == a_data_run_new->offset)) { a_fs_attr->nrd.run_end->next = a_data_run_new; // update the pointer to the end of the list while (a_fs_attr->nrd.run_end->next) a_fs_attr->nrd.run_end = a_fs_attr->nrd.run_end->next; /* return head of a_fs_attr list */ return 0; } // cycle through existing runs and see if we can add this into a filler spot data_run_cur = a_fs_attr->nrd.run; data_run_prev = NULL; while (data_run_cur) { if (tsk_verbose) tsk_fprintf(stderr, "tsk_fs_attr_add: %" PRIuOFF "@%" PRIuOFF " (Filler: %s)\n", data_run_cur->offset, data_run_cur->len, (data_run_cur->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) ? "Yes" : "No"); /* Do we replace this filler spot? */ if (data_run_cur->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) { /* This should never happen because we always add * the filler to start from VCN 0 */ if (data_run_cur->offset > a_data_run_new->offset) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("tsk_fs_attr_add_run: could not add data_run b.c. offset (%" PRIuOFF ") is larger than FILLER (%" PRIuOFF ") (%" PRIuINUM ")", a_data_run_new->offset, data_run_cur->offset, a_fs_attr->fs_file->meta->addr); dump_attr(a_fs_attr); return 1; } /* Check if the new run starts inside of this filler. */ if (data_run_cur->offset + data_run_cur->len > a_data_run_new->offset) { TSK_FS_ATTR_RUN *endrun; /* if the new starts at the same as the filler, * replace the pointer */ if (data_run_cur->offset == a_data_run_new->offset) { if (data_run_prev) data_run_prev->next = a_data_run_new; else a_fs_attr->nrd.run = a_data_run_new; } /* The new run does not start at the begining of * the filler, so make a new start filler */ else { TSK_FS_ATTR_RUN *newfill = tsk_fs_attr_run_alloc(); if (newfill == NULL) return 1; if (data_run_prev) data_run_prev->next = newfill; else a_fs_attr->nrd.run = newfill; newfill->next = a_data_run_new; newfill->len = a_data_run_new->offset - data_run_cur->offset; newfill->offset = data_run_cur->offset; newfill->flags = TSK_FS_ATTR_RUN_FLAG_FILLER; data_run_cur->len -= newfill->len; } /* get to the end of the run that we are trying to add */ endrun = a_data_run_new; while (endrun->next) endrun = endrun->next; /* if the filler is the same size as the * new one, replace it */ if (run_len == data_run_cur->len) { endrun->next = data_run_cur->next; // update the pointer to the end of the list (if we are the end) if (endrun->next == NULL) a_fs_attr->nrd.run_end = endrun; free(data_run_cur); } /* else adjust the last filler entry */ else { endrun->next = data_run_cur; data_run_cur->len -= run_len; data_run_cur->offset = a_data_run_new->offset + a_data_run_new->len; } return 0; } } data_run_prev = data_run_cur; data_run_cur = data_run_cur->next; } /* * There is no filler holding the location of this run, so * we will add it to the end of the list * * we got here because it did not fit in the current list or * because the current list is NULL * * At this point data_run_prev is the end of the existing list or * 0 if there is no list */ /* This is an error condition. * It means that we cycled through the existing runs, * ended at a VCN that is larger than what we are adding, * and never found a filler entry to insert it into... */ if ((data_run_prev) && (data_run_prev->offset + data_run_prev->len > a_data_run_new->offset)) { /* MAYBE this is because of a duplicate entry .. */ if ((data_run_prev->addr == a_data_run_new->addr) && (data_run_prev->len == a_data_run_new->len)) { // @@@ Sould be we freeing this....? What if the caller tries to write to it? tsk_fs_attr_run_free(a_data_run_new); return 0; } tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("fs_attr_add_run: error adding additional run (%" PRIuINUM "): No filler entry for %" PRIuDADDR ". Final: %" PRIuDADDR, a_fs_attr->fs_file->meta->addr, a_data_run_new->offset, data_run_prev->offset + data_run_prev->len); dump_attr(a_fs_attr); return 1; } /* we should add it right here */ else if (((data_run_prev) && (data_run_prev->offset + data_run_prev->len == a_data_run_new->offset)) || (a_data_run_new->offset == 0)) { if (data_run_prev) data_run_prev->next = a_data_run_new; else a_fs_attr->nrd.run = a_data_run_new; } /* we need to make a filler before it */ else { TSK_FS_ATTR_RUN *tmprun = tsk_fs_attr_run_alloc(); if (tmprun == NULL) return 1; if (data_run_prev) { data_run_prev->next = tmprun; tmprun->offset = data_run_prev->offset + data_run_prev->len; } else { a_fs_attr->nrd.run = tmprun; } tmprun->len = a_data_run_new->offset - tmprun->offset; tmprun->flags = TSK_FS_ATTR_RUN_FLAG_FILLER; tmprun->next = a_data_run_new; } // update the pointer to the end of the list a_fs_attr->nrd.run_end = a_data_run_new; while (a_fs_attr->nrd.run_end->next) a_fs_attr->nrd.run_end = a_fs_attr->nrd.run_end->next; return 0; }