// // Decode 41 sequence // int decode41(char *data, int len, char *text){ struct self_s self; int ret; u8 *pkt_my; u32 pkt_my_len; pkt_my=data; pkt_my_len=len; ret=unpack41_structure(pkt_my,pkt_my_len,(char *)&self); if (ret==-1) { printf("possible not all bytes decoded! (not found last 2 bytes of crc16)\n"); }; if (ret==-2){ return 0; }; print_structure(text,(char *)&self,1); free_structure((char *)&self); return 0; };
/* Print the structure of node NODE of an binary tree, which is LEVEL levels from the top of the tree. Uses different delimiters to visually distinguish levels. */ void print_structure(struct pbin_node *node, int level) { assert(level <= 100); if (node == NULL) { printf(" nil"); return; } printf(" %c%d", "([{`/"[level % 5], node->data); if (node->left || node->right) { print_structure(node->left, level + 1); if (node->right) print_structure(node->right, level + 1); } printf("%c", ")]}'\\"[level % 5]); }
/* Print the structure of node NODE of a red-black tree, which is LEVEL levels from the top of the tree. Uses different delimiters to visually distinguish levels. */ void print_structure(struct rb_node *node, int level) { assert(level <= 100); if (node == NULL) { printf(" nil"); return; } printf(" %c%d%c", "([{`/"[level % 5], node->data, node->color == RB_BLACK ? 'r' : 'b'); if (node->link[0] || node->link[1]) { print_structure(node->link[0], level + 1); if (node->link[1]) print_structure(node->link[1], level + 1); } printf("%c", ")]}'\\"[level % 5]); }
/* Print the structure of node NODE of an avl tree, which is LEVEL levels from the top of the tree. Uses different delimiters to visually distinguish levels. */ void print_structure (avl_node *node, int level) { char lc[] = "([{`/"; char rc[] = ")]}'\\"; assert (level <= 10); if (node == NULL) { printf (" nil"); return; } printf (" %c%d", lc[level % 5], (int) node->data); if (node->link[0] || node->link[1]) print_structure (node->link[0], level + 1); if (node->link[1]) print_structure (node->link[1], level + 1); printf ("%c", rc[level % 5]); }
int main(int argc, char **argv) { u64 total_size = sizeof(struct header_s); char *basename = pparm_common_name("index"); char *iname = NULL; int fd = 0; u64 offs = sizeof(struct header_s); uint i; struct header_s header; dub_init(); PPARM_INT_D(iblock, IBLOCK); PPARM_INT_D(segment_size, SEGMENT_SIZE); asprintf(&iname, "%s.%u", basename, iblock); fill_parameters(&header); for (i = 0; i < DEX_NOF_SECT; i++){ header.toc_offs[i] = total_size; total_size += append_sect(0, 0, i, 1); } for (i = 0; i < DEX_NOF_SECT; i++){ header.data_offs[i] = total_size; total_size += append_sect(0, 0, i, 0); } if ((fd = open(iname, O_CREAT | O_TRUNC | O_RDWR | O_LARGEFILE, S_IREAD | S_IWRITE)) == -1) dub_sysdie("Couldn't open file %s", iname); if (fio_truncate(fd, total_size)) dub_sysdie("Couldn't truncate index to %llu bytes", total_size); write(fd, &header, sizeof(struct header_s)); for (i = 0; i < DEX_NOF_SECT; i++) offs += append_sect(fd, offs, i, 1); for (i = 0; i < DEX_NOF_SECT; i++) offs += append_sect(fd, offs, i, 0); close(fd); print_structure(&header); printf(" In total %llu bytes.\n\n", total_size); return 0; }
/* Print the structure of node NODE of an avl tree, which is LEVEL levels from the top of the tree. Uses different delimiters to visually distinguish levels. */ void print_structure (avltr_tree *tree, avltr_node *node, int level) { char lc[] = "([{<`"; char rc[] = ")]}>'"; if (node == NULL) { printf (" :nil"); return; } else if (level >= 10) { printf ("Too deep, giving up.\n"); done = 1; return; } else if (node == &tree->root) { printf (" root"); return; } printf (" %c%d", lc[level % 5], (int) node->data); fflush (stdout); print_structure (tree, node->link[0], level + 1); fflush (stdout); if (node->rtag == PLUS) print_structure (tree, node->link[1], level + 1); else if (node->link[1] != &tree->root) printf (" :%d", (int) node->link[1]->data); else printf (" :r"); fflush (stdout); printf ("%c", rc[level % 5]); fflush (stdout); }
static int *pair_table_to_loop_index (short *pt) { /* number each position by which loop it belongs to (positions start at 1) */ int i,hx,l,nl; int length; int *stack = NULL; int *loop = NULL; length = pt[0]; stack = (int *) space(sizeof(int)*(length+1)); loop = (int *) space(sizeof(int)*(length+2)); hx=l=nl=0; for (i=1; i<=length; i++) { if ((pt[i] != 0) && (i < pt[i])) { /* ( */ nl++; l=nl; stack[hx++]=i; } loop[i]=l; if ((pt[i] != 0) && (i > pt[i])) { /* ) */ --hx; if (hx>0) l = loop[stack[hx-1]]; /* index of enclosing loop */ else l=0; /* external loop has index 0 */ if (hx<0) { nrerror("unbalanced brackets in make_pair_table"); } } } loop[0] = nl; free(stack); #ifdef _DEBUG_LOOPIDX fprintf(stderr,"begin loop index\n"); fprintf(stderr, "....,....1....,....2....,....3....,....4" "....,....5....,....6....,....7....,....8\n"); print_structure(pt, loop[0]); for (i=1; i<=length; i++) fprintf(stderr,"%2d ", loop[i]); fprintf(stderr,"\n"); fprintf(stderr, "end loop index\n"); fflush(stderr); #endif return (loop); }
static bool drstrace_print_info_class_struct(buf_info_t *buf, drsys_arg_t *arg) { char buf_tmp[TYPE_OUTPUT_SIZE]; drsym_type_t *type; drsym_type_t *expand_type; drsym_error_t r; r = drsym_get_type_by_name(options.sympath, arg->enum_name, buf_tmp, BUFFER_SIZE_BYTES(buf_tmp), &type); if (r != DRSYM_SUCCESS) { NOTIFY("Value to symbol %s lookup failed", arg->enum_name); return false; } r = drsym_expand_type(options.sympath, type->id, UINT_MAX, buf_tmp, BUFFER_SIZE_BYTES(buf_tmp), &expand_type); if (r != DRSYM_SUCCESS) { NOTIFY("%s structure expanding failed", arg->enum_name); return false; } if (!type_has_unknown_components(expand_type)) { NOTIFY("%s structure has unknown types", arg->enum_name); return false; } if (arg->valid && !arg->pre) { if (arg->value64 == 0) { OUTPUT(buf, "NULL"); /* We return true since we already printed for this value */ return true; } /* We're expecting an address here. So we truncate int64 to void*. */ print_structure(buf, expand_type, arg, (void *)arg->value64); } else { return false; } return true; }
int main(int argc, const char **argv) { char c, rna [MAX]; int i, j=0, score; rna_t *molecule = (rna_t *)malloc(sizeof(rna_t)); /* Get RNA strand from stdin. Finish input on EOF */ for (i = 0; (c=getchar()) != EOF && i < MAX; i++) { switch (c) { case ' ': case '\t': case '\n': break; case 'A': case 'G': case 'C': case 'U': default: rna[j++] = c; } } rna[j] = '\0'; printf("%s\n", rna); /* Compute OPT */ score = predict( rna, molecule ); //printf("score: %d\n ", score); //print_opt (molecule); print_structure (molecule); printf(" score: %d\n", score); print_pairs (molecule, 0, strlen(rna)-1); free (molecule); return 0; }
int main(int argc, char **argv) { int argn; char optc; char *optarg; char *mimesection=0; int doinfo=0, dodecode=0, dorewrite=0, dodsn=0, domimedigest=0; struct rfc2045 *p; int rwmode=0; void (*do_extract)(struct rfc2045 *, const char *, int, char **)=0; const char *extract_filename=0; for (argn=1; argn<argc; ) { if (argv[argn][0] != '-') break; optarg=0; optc=argv[argn][1]; if (optc && argv[argn][2]) optarg=argv[argn]+2; ++argn; switch (optc) { case 'c': if (!optarg && argn < argc) optarg=argv[argn++]; if (optarg && *optarg) rfc2045_setdefaultcharset(optarg); break; case 's': if (!optarg && argn < argc) optarg=argv[argn++]; if (optarg && *optarg) mimesection=optarg; break; case 'i': doinfo=1; break; case 'e': dodecode=1; break; case 'r': dorewrite=1; if (optarg && *optarg == '7') rwmode=RFC2045_RW_7BIT; if (optarg && *optarg == '8') rwmode=RFC2045_RW_8BIT; break; case 'm': domimedigest=1; break; case 'd': dodsn=1; break; case 'D': dodsn=2; break; case 'x': do_extract=extract_file; if (optarg) extract_filename=optarg; break; case 'X': do_extract=extract_pipe; break; case 'v': printf("%s\n", rcsid); exit(0); default: usage(); } } if (domimedigest) { mimedigest(argc-argn, argv+argn); return (0); } p=read_message(); if (doinfo) print_info(p, mimesection); else if (dodecode) print_decode(p, mimesection); else if (dorewrite) rewrite(p, rwmode); else if (dodsn) dsn(p, dodsn == 2); else if (do_extract) extract_section(p, mimesection, extract_filename, argc-argn, argv+argn, do_extract); else print_structure(p); rfc2045_free(p); exit(0); return (0); }
void sparselu_fini (float **BENCH, char *pass) { print_structure(pass, BENCH); }
void process_rep (int **perms, int *a, int *b, char *c, char *d, int ***auts, int rep, int orbit_length, FILE * tmp_file, FILE * descendant_file, FILE * covers_file, struct pga_vars *pga, struct pcp_vars *pcp) { int index; int *subset; int ***central; int ***stabiliser; int **S; int *seq; FILE * file; FILE * GAP_library; int lused, rank_of_cover; /* construct the presentation for the descendant and assemble the necessary automorphism information */ S = label_to_subgroup (&index, &subset, rep, pga); if (pga->print_subgroup) { printf ("The standard matrix for the allowable subgroup is:\n"); print_matrix (S, pga->s, pga->q); } factorise_subgroup (S, index, subset, pga, pcp); free_matrix (S, pga->s, 0); free_vector (subset, 0); if ((pga->print_group && pga->final_stage) || pga->print_reduced_cover) { print_presentation (FALSE, pcp); print_structure (1, pcp->lastg, pcp); print_pcp_relations (pcp); printf ("\n"); } if (pga->final_stage) { central = immediate_descendant (descendant_file, pga, pcp); /* should we write a compact description to file? */ if ((pga->capable || pga->terminal) && (Compact_Description == TRUE && (Compact_Order <= pcp->lastg || Compact_Order == 0))) { seq = compact_description (TRUE, pcp); free_vector (seq, 1); } /* should we write a description of group to GAP file? */ if (pga->capable || pga->terminal) { if (Group_library == GAP_LIBRARY) { if (Group_library_file != NULL) GAP_library = OpenFile (Group_library_file, "a+"); else GAP_library = OpenFile ("GAP_library", "a+"); write_GAP_library (GAP_library, pcp); CloseFile (GAP_library); } } /* if the group is not capable and we do not want to process terminal groups, we are finished */ if (!pga->capable && !pga->terminal) { /* first restore the original p-covering group */ RESET(tmp_file); restore_pcp (tmp_file, pcp); return; } } else { save_pcp (covers_file, pcp); /* if characteristic subgroup in nucleus, revise the nuclear rank */ if (pga->s < pcp->newgen) pcp->newgen = pga->nuclear_rank + pga->s - pga->q; set_values (pga, pcp); pga->nmr_centrals = 0; } #ifdef HAVE_GMP update_autgp_order (orbit_length, pga, pcp); #endif /* restore the original p-covering group before computing stabiliser */ RESET(tmp_file); restore_pcp (tmp_file, pcp); /* note following information before computing stabiliser */ rank_of_cover = pcp->lastg; lused = pcp->lused; stabiliser = stabiliser_of_rep (perms, rep, orbit_length, a, b, c, d, auts, pga, pcp); #ifdef HAVE_GMP if (pga->final_stage) report_autgp_order (pga, pcp); #endif if (pga->final_stage && (pga->capable || pga->terminal)) { if (Group_library == GAP_LIBRARY) { GAP_library = OpenFile ("GAP_library", "a+"); GAP_auts (GAP_library, central, stabiliser, pga, pcp); CloseFile (GAP_library); } } if (pga->final_stage) { if (StandardPresentation) pga->fixed = 0; else initialise_pga (pga, pcp); pga->step_size = 0; } /* save structure + automorphism information */ file = (pga->final_stage ? descendant_file : covers_file); save_pga (file, central, stabiliser, pga, pcp); #if defined (GROUP) #if defined (STANDARD_PCP) if (StandardPresentation) print_aut_description (central, stabiliser, pga, pcp); #endif #endif if (pga->nmr_centrals != 0) free_array (central, pga->nmr_centrals, pga->ndgen, 1); if (pga->nmr_stabilisers != 0) { free_array (stabiliser, pga->nmr_stabilisers, pga->ndgen, 1); } pcp->lastg = rank_of_cover; pcp->lused = lused; }
void print_presentation(Logical full, struct pcp_vars *pcp) { register int *y = y_address; register int i; register int k; register int l; register int length; register int relp = pcp->relp; register int ndrel = pcp->ndrel; register int gen, pointer; Logical commutator_relation; char *s; #if defined(GROUP) printf("\nGroup: %s to lower exponent-%d central class %d has order %d^%d\n", pcp->ident, pcp->p, pcp->cc, pcp->p, pcp->lastg); #endif if (!full) return; if (pcp->diagn) { /* print out the defining relations of the group */ #if defined(GROUP) s = "Group"; #endif if (pcp->ndrel != 0) printf("\n%s defining relations:\n", s); for (k = 1; k <= ndrel; ++k) { for (l = 1; l <= 2; ++l) { i = (k - 1) * 2 + l; pointer = y[relp + i]; commutator_relation = (y[pointer] < 0); length = abs(y[pointer]); if (length == 0) printf("0"); else printf("%d", y[pointer + 1]); if (commutator_relation) printf(" ["); for (i = 2; i <= length; ++i) { gen = y[pointer + i]; printf(" %d", gen); } if (commutator_relation) printf(" ]"); printf("\n"); } printf("\n"); } /* print map from defining generators to pcp generators */ print_map(pcp); #if defined(GROUP) printf("\nValues of power-commutator presentation generators\n"); #endif print_structure(1, pcp->lastg, pcp); } if (pcp->cc != 1) print_pcp_relations(pcp); }
void interactive_pga(Logical group_present, FILE *StartFile, int group_nmr, int ***auts, struct pga_vars *pga, struct pcp_vars *pcp) { struct pga_vars flag; int option; Logical soluble_group = TRUE; FILE *OutputFile = 0; FILE *LINK_input = 0; char *StartName = 0; int t; int **perms = 0; int index; int **S = 0; int k; int K; int label; int *a = 0, *b = 0; char *c = 0; int *orbit_length = 0; int nmr_of_exponents; int *subset = 0; int alpha; int upper_step; int rep; int i; list_interactive_pga_menu(); do { option = read_option(MAX_INTERACTIVE_OPTION); switch (option) { case -1: list_interactive_pga_menu(); break; case SUPPLY_AUTS: auts = read_auts(PGA, &pga->m, &nmr_of_exponents, pcp); #ifdef HAVE_GMP autgp_order(pga, pcp); #endif pga->soluble = TRUE; start_group(&StartFile, auts, pga, pcp); break; case EXTEND_AUTS: extend_automorphisms(auts, pga->m, pcp); print_auts(pga->m, pcp->lastg, auts, pcp); break; case RESTORE_GP: StartName = GetString("Enter input file name: "); StartFile = OpenFileInput(StartName); if (StartFile != NULL) { read_value(TRUE, "Which group? ", &group_nmr, 0); auts = restore_group(TRUE, StartFile, group_nmr, pga, pcp); RESET(StartFile); } break; case DISPLAY_GP: print_presentation(FALSE, pcp); print_structure(1, pcp->lastg, pcp); print_pcp_relations(pcp); break; case SINGLE_STAGE: t = runTime(); if (group_present && pga->m == 0) start_group(&StartFile, auts, pga, pcp); assert(OutputFile); construct(1, &flag, SINGLE_STAGE, OutputFile, StartFile, 0, ALL, group_nmr, pga, pcp); t = runTime() - t; printf("Time for intermediate stage is %.2f seconds\n", t * CLK_SCALE); break; case DEGREE: read_step_size(pga, pcp); read_subgroup_rank(&k); query_exponent_law(pga); enforce_laws(pga, pga, pcp); extend_automorphisms(auts, pga->m, pcp); step_range(k, &pga->s, &upper_step, auts, pga, pcp); if (pga->s > upper_step) printf("Desired step size is invalid for current group\n"); else { if (pga->s < upper_step) { printf("The permitted relative step sizes range from %d to %d\n", pga->s, upper_step); read_value( TRUE, "Input the chosen relative step size: ", &pga->s, 0); } store_definition_sets(pga->r, pga->s, pga->s, pga); get_definition_sets(pga); pga->print_degree = TRUE; compute_degree(pga); pga->print_degree = FALSE; } break; case PERMUTATIONS: if (pga->Degree != 0) { t = runTime(); query_solubility(pga); pga->trace = FALSE; if (pga->soluble) query_space_efficiency(pga); else pga->space_efficient = FALSE; query_perm_information(pga); strip_identities(auts, pga, pcp); soluble_group = (pga->soluble || pga->Degree == 1 || pga->nmr_of_perms == 0); if (!soluble_group) { #if defined(GAP_LINK) StartGapFile(pga); #else #if defined(GAP_LINK_VIA_FILE) start_GAP_file(&LINK_input, auts, pga, pcp); #endif #endif } perms = permute_subgroups(LINK_input, &a, &b, &c, auts, pga, pcp); #if defined(GAP_LINK_VIA_FILE) if (!soluble_group) CloseFile(LINK_input); #endif t = runTime() - t; printf("Time to compute permutations is %.2f seconds\n", t * CLK_SCALE); } else printf("You must first select option %d\n", DEGREE); break; case ORBITS: orbit_option(option, perms, &a, &b, &c, &orbit_length, pga); break; case STABILISERS: case STABILISER: assert(perms); stabiliser_option( option, auts, perms, a, b, c, orbit_length, pga, pcp); /* free_space (pga->soluble, perms, orbit_length, a, b, c, pga); */ break; case MATRIX_TO_LABEL: S = allocate_matrix(pga->s, pga->q, 0, FALSE); subset = allocate_vector(pga->s, 0, FALSE); printf("Input the %d x %d subgroup matrix:\n", pga->s, pga->q); read_matrix(S, pga->s, pga->q); K = echelonise_matrix(S, pga->s, pga->q, pga->p, subset, pga); printf("The standard matrix is:\n"); print_matrix(S, pga->s, pga->q); printf("The label is %d\n", subgroup_to_label(S, K, subset, pga)); free_vector(subset, 0); break; case LABEL_TO_MATRIX: read_value(TRUE, "Input allowable subgroup label: ", &label, 1); S = label_to_subgroup(&index, &subset, label, pga); printf("The corresponding standard matrix is\n"); print_matrix(S, pga->s, pga->q); break; case IMAGE: t = runTime(); /* invert_automorphisms (auts, pga, pcp); print_auts (pga->m, pcp->lastg, auts, pcp); */ printf("Input the subgroup label and automorphism number: "); read_value(TRUE, "", &label, 1); read_value(FALSE, "", &alpha, 1); printf("Image is %d\n", find_image(label, auts[alpha], pga, pcp)); t = runTime() - t; printf("Computation time in seconds is %.2f\n", t * CLK_SCALE); break; case SUBGROUP_RANK: read_subgroup_rank(&k); printf("Closure of initial segment subgroup has rank %d\n", close_subgroup(k, auts, pga, pcp)); break; case ORBIT_REP: printf("Input label for subgroup: "); read_value(TRUE, "", &label, 1); rep = abs(a[label]); for (i = 1; i <= pga->nmr_orbits && pga->rep[i] != rep; ++i) ; printf("Subgroup with label %d has representative %d and is in orbit " "%d\n", label, rep, i); break; case COMPACT_DESCRIPTION: Compact_Description = TRUE; read_value(TRUE, "Lower bound for order (0 for all groups generated)? ", &Compact_Order, 0); break; case AUT_CLASSES: t = runTime(); permute_elements(); t = runTime() - t; printf("Time to compute orbits is %.2f seconds\n", t * CLK_SCALE); break; /* printf ("Input label: "); scanf ("%d", &l); process_complete_orbit (a, l, pga, pcp); break; case TEMP: printf ("Input label: "); scanf ("%d", &l); printf ("Input label: "); scanf ("%d", &u); for (i = l; i <= u; ++i) { x = IsValidAllowableSubgroup (i, pga); printf ("%d is %d\n", i, x); } StartName = GetString ("Enter output file name: "); OutputFile = OpenFileOutput (StartName); part_setup_reps (pga->rep, pga->nmr_orbits, orbit_length, perms, a, b, c, auts, OutputFile, OutputFile, pga, pcp); list_word (pga, pcp); read_value (TRUE, "Input the rank of the subgroup: ", &pga->q, 1); strip_identities (auts, pga, pcp); break; */ case EXIT: case MAX_INTERACTIVE_OPTION: printf("Exiting from interactive p-group generation menu\n"); break; } /* switch */ } while (option != 0 && option != MAX_INTERACTIVE_OPTION); #if defined(GAP_LINK) if (!soluble_group) QuitGap(); #endif }
void sparselu_init (float ***pBENCH, char *pass) { *pBENCH = (float **) malloc(bots_arg_size*bots_arg_size*sizeof(float *)); genmat(*pBENCH); print_structure(pass, *pBENCH); }
int main(int argc, char *argv[]){ struct student ayaaz = {"Ayaaz", 20, 75}, *ptr = &ayaaz; print_structure(ptr); return 0; }
static void print_structure(buf_info_t *buf, drsym_type_t *type, drsys_arg_t *arg, void *addr) { int i; bool type_union = false; if (type->kind == DRSYM_TYPE_COMPOUND) { drsym_compound_type_t *compound_type = (drsym_compound_type_t *)type; OUTPUT(buf, "%s {", compound_type->name); if (identify_known_compound_type(buf, compound_type->name, addr)) { OUTPUT(buf, "}"); return; } /* i#1607: We need to print properly parent structures when they are * actually unions (e.g. LARGE_INTEGER). */ if (get_total_size_of_fields(compound_type) > compound_type->type.size) type_union = true; for (i = 0; i < compound_type->num_fields; i++) { print_structure(buf, compound_type->field_types[i], arg, addr); if (!type_union) addr = (char *)addr + compound_type->field_types[i]->size; /* we don't want comma after last field */ if (i+1 != compound_type->num_fields) OUTPUT(buf, ", "); } OUTPUT(buf, "}"); } else { /* Print type fields */ if (type->kind == DRSYM_TYPE_VOID) { OUTPUT(buf, "void="); safe_read_field(buf, addr, type->size, true); return; } else if (type->kind == DRSYM_TYPE_PTR) { drsym_ptr_type_t *ptr_type = (drsym_ptr_type_t *)type; /* We're expecting an address here. So we truncate int64 to void* */ void *mem_value = (void *)safe_read_field(buf, addr, ptr_type->type.size, false); print_structure(buf, ptr_type->elt_type, arg, mem_value); OUTPUT(buf, "*"); return; } else if (type->kind == DRSYM_TYPE_ARRAY) { OUTPUT(buf, "array(%d)={", type->size); /* only print up to the first 4 bytes of the array */ safe_read_field(buf, addr, 0x1, true); for (i = 1; i < type->size && i < 4; i++) { OUTPUT(buf, ", "); safe_read_field(buf, (byte *)addr + i, 0x1, true); } if (i < type->size) OUTPUT(buf, ", ..."); OUTPUT(buf, "}"); return; } else { /* Print integer base types */ switch (type->size) { case 1: OUTPUT(buf, "byte|bool="); break; case 2: OUTPUT(buf,"short="); break; case 4: OUTPUT(buf, "int="); break; case 8: OUTPUT(buf, "long long="); break; default: OUTPUT(buf, "unknown type="); break; } safe_read_field(buf, addr, type->size, true); return; } } return; }