int main(int argc, char **argv) { XmRegion region1 = _XmRegionCreate(); XRectangle rect; printf ("\tRegion 1 -- _XmRegionCreate()\n"); print_region(region1); rect.x = rect.y = 5; rect.width = rect.height = 100; _XmRegionUnionRectWithRegion(&rect, region1, region1); printf ("\tRegion 1 -- after _XmUnionRectWithRegion\n"); print_region(region1); _XmRegionOffset(region1, 10, 10); printf ("\tRegion 1 -- after _XmRegionOffset\n"); print_region(region1); exit(0); }
int main(int argc, char **argv) { XmRegion region1 = _XmRegionCreate(); XmRegion region2 = _XmRegionCreateSize(100); printf ("\tRegion 1 -- _XmRegionCreate()\n"); print_region(region1); printf ("\tRegion 2 -- _XmRegionCreateSize(100)\n"); print_region(region2); exit(0); }
static void print_region_list (void) { struct region_t *r; printf (" address size prot maxp\n"); for (r = region_list_head; r; r = r->next) print_region (r->address, r->size, r->protection, r->max_protection); }
static void print_regions (void) { task_t target_task = mach_task_self (); vm_address_t address = (vm_address_t) 0; vm_size_t size; struct vm_region_basic_info info; mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT; mach_port_t object_name; printf (" address size prot maxp\n"); while (vm_region (target_task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t) &info, &info_count, &object_name) == KERN_SUCCESS && info_count == VM_REGION_BASIC_INFO_COUNT) { print_region (address, size, info.protection, info.max_protection); if (object_name != MACH_PORT_NULL) mach_port_deallocate (target_task, object_name); address += size; } }
/* Build the list of regions that need to be dumped. Regions with addresses above VM_DATA_TOP are omitted. Adjacent regions with identical protection are merged. Note that non-writable regions cannot be omitted because they some regions created at run time are read-only. */ static void build_region_list (void) { task_t target_task = mach_task_self (); vm_address_t address = (vm_address_t) 0; vm_size_t size; struct vm_region_basic_info info; mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT; mach_port_t object_name; struct region_t *r; #if VERBOSE printf ("--- List of All Regions ---\n"); printf (" address size prot maxp\n"); #endif while (vm_region (target_task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t) &info, &info_count, &object_name) == KERN_SUCCESS && info_count == VM_REGION_BASIC_INFO_COUNT) { /* Done when we reach addresses of shared libraries, which are loaded in high memory. */ if (address >= VM_DATA_TOP) break; #if VERBOSE print_region (address, size, info.protection, info.max_protection); #endif /* If a region immediately follows the previous one (the one most recently added to the list) and has identical protection, merge it with the latter. Otherwise create a new list element for it. */ if (region_list_tail && info.protection == region_list_tail->protection && info.max_protection == region_list_tail->max_protection && region_list_tail->address + region_list_tail->size == address) { region_list_tail->size += size; } else { r = malloc (sizeof *r); if (!r) unexec_error ("cannot allocate region structure"); r->address = address; r->size = size; r->protection = info.protection; r->max_protection = info.max_protection; r->next = 0; if (region_list_head == 0) { region_list_head = r; region_list_tail = r; } else { region_list_tail->next = r; region_list_tail = r; } /* Deallocate (unused) object name returned by vm_region. */ if (object_name != MACH_PORT_NULL) mach_port_deallocate (target_task, object_name); } address += size; } printf ("--- List of Regions to be Dumped ---\n"); print_region_list (); }
int main(int argc, char *argv[]) { struct GModule *module; char *input_opt, *field_opt; int hist_flag, col_flag, shell_flag; struct Map_info Map; G_gisinit(argv[0]); module = G_define_module(); G_add_keyword(_("vector")); G_add_keyword(_("metadata")); G_add_keyword(_("topology")); G_add_keyword(_("extent")); G_add_keyword(_("history")); G_add_keyword(_("attribute columns")); module->description = _("Outputs basic information about a vector map."); G_debug(1, "LFS is %s", sizeof(off_t) == 8 ? "available" : "not available"); parse_args(argc, argv, &input_opt, &field_opt, &hist_flag, &col_flag, &shell_flag); /* try to open head-only on level 2 */ if (Vect_open_old_head2(&Map, input_opt, "", field_opt) < 2) { /* force level 1, open fully * NOTE: number of points, lines, boundaries, centroids, faces, kernels is still available */ Vect_close(&Map); Vect_set_open_level(1); /* no topology */ if (Vect_open_old2(&Map, input_opt, "", field_opt) < 1) G_fatal_error(_("Unable to open vector map <%s>"), Vect_get_full_name(&Map)); /* level one info not needed for history, title, columns */ if (!hist_flag && !col_flag) level_one_info(&Map); } if (hist_flag || col_flag) { if (hist_flag) { char buf[1001]; Vect_hist_rewind(&Map); while (Vect_hist_read(buf, 1000, &Map) != NULL) { fprintf(stdout, "%s\n", buf); } } else if (col_flag) { print_columns(&Map, input_opt, field_opt); } Vect_close(&Map); return (EXIT_SUCCESS); } if (shell_flag & SHELL_BASIC) { print_shell(&Map); } if (shell_flag & SHELL_REGION) { print_region(&Map); } if (shell_flag & SHELL_TOPO) { print_topo(&Map); } if (shell_flag == 0) { print_info(&Map); } Vect_close(&Map); return (EXIT_SUCCESS); }
void vm_dmp() { static struct proc proc[NR_TASKS + NR_PROCS]; static struct vm_region_info vri[LINES]; struct vm_stats_info vsi; struct vm_usage_info vui; static int prev_i = -1; static vir_bytes prev_base = 0; int r, r2, i, j, first, n = 0; if (prev_i == -1) { if ((r = vm_info_stats(&vsi)) != OK) { printf("IS: warning: couldn't talk to VM: %d\n", r); return; } printf("Total %lu kB, free %lu kB, largest free %lu kB, cached %lu kB\n", vsi.vsi_total * (vsi.vsi_pagesize / 1024), vsi.vsi_free * (vsi.vsi_pagesize / 1024), vsi.vsi_largest * (vsi.vsi_pagesize / 1024), vsi.vsi_cached * (vsi.vsi_pagesize / 1024)); n++; printf("\n"); n++; prev_i++; } if ((r = sys_getproctab(proc)) != OK) { printf("IS: warning: couldn't get copy of process table: %d\n", r); return; } for (i = prev_i; i < NR_TASKS + NR_PROCS && n < LINES; i++, prev_base = 0) { if (i < NR_TASKS || isemptyp(&proc[i])) continue; /* The first batch dump for each process contains a header line. */ first = prev_base == 0; r = vm_info_region(proc[i].p_endpoint, vri, LINES - first, &prev_base); if (r < 0) { printf("Process %d (%s): error %d\n", proc[i].p_endpoint, proc[i].p_name, r); n++; continue; } if (first) { /* The entire batch should fit on the screen. */ if (n + 1 + r > LINES) { prev_base = 0; /* restart on next page */ break; } if ((r2 = vm_info_usage(proc[i].p_endpoint, &vui)) != OK) { printf("Process %d (%s): error %d\n", proc[i].p_endpoint, proc[i].p_name, r2); n++; continue; } printf("Process %d (%s): total %lu kB, common %lu kB, " "shared %lu kB\n", proc[i].p_endpoint, proc[i].p_name, vui.vui_total / 1024L, vui.vui_common / 1024L, vui.vui_shared / 1024L); n++; } while (r > 0) { for (j = 0; j < r; j++) { print_region(&vri[j], &n); } if (LINES - n - 1 <= 0) break; r = vm_info_region(proc[i].p_endpoint, vri, LINES - n - 1, &prev_base); if (r < 0) { printf("Process %d (%s): error %d\n", proc[i].p_endpoint, proc[i].p_name, r); n++; } } print_region(NULL, &n); if (n > LINES) printf("IS: internal error\n"); if (n == LINES) break; /* This may have to wipe out the "--more--" from below. */ printf(" \n"); n++; } if (i >= NR_TASKS + NR_PROCS) { i = -1; prev_base = 0; } else printf("--more--\r"); prev_i = i; }
int main( int argc, char* argv[] ) { char mafn[MAX_FN_LEN+1]; char ma_in_fn[MAX_FN_LEN+1]; char assign_id[MAX_ID_LEN+1]; unsigned int any_arg; int id_assigned = 0; // Boolean, set to true if -I is given int cons_scheme; int out_ma = 0; int in_ma = 0; int no_dups = 0; // allow duplicate ids by default - the user knows what he's doing int out_format = 1; int reg_start = 90; int reg_end = 109; int in_color = 0; // Output f6 format colored -> bad when you want to pipe it into a file MapAlignmentP maln; PWAlnFragP pwaln; IDsListP rest_ids_list, // the IDs in the -i argument, if any, will go here used_ids_list; // the IDs seen thusfar; just for this list, // the segment character is tacked onto the end int ich, cons_scheme_def, ids_rest; double score_int, score_slo; extern char* optarg; cons_scheme_def = 1; ids_rest = 0; // Boolean set to no => no IDs restriction set (yet) /* Get input options */ any_arg = 0; cons_scheme = cons_scheme_def; score_int = -1.0; // Set the score intercept to -1 => not specified (yet) score_slo = -1.0; // Set the score intercept to -1 => not specified (yet) while( (ich=getopt( argc, argv, "I:c:i:f:R:s:m:M:Cb:s:d" )) != -1 ) { switch(ich) { case 'h' : help(); exit( 0 ); any_arg = 1; break; case 'I' : strcpy( assign_id, optarg ); id_assigned = 1; break; case 'c' : cons_scheme = atoi( optarg ); any_arg = 1; break; case 'i' : rest_ids_list = parse_ids( optarg ); ids_rest = 1; any_arg = 1; break; case 'f' : out_format = atoi( optarg ); any_arg = 1; break; case 'R' : parse_region( optarg, ®_start, ®_end ); any_arg = 1; break; case 's' : score_slo = atof( optarg ); any_arg = 1; break; case 'b' : score_int = atof( optarg ); any_arg = 1; break; case 'C' : in_color = 1; break; case 'm' : strcpy( mafn, optarg ); out_ma = 1; any_arg = 1; break; case 'M' : strcpy( ma_in_fn, optarg ); in_ma = 1; any_arg = 1; break; case 'd' : no_dups = 1; used_ids_list = init_ids_list(); any_arg = 1; break; default : help(); any_arg = 1; exit( 0 ); } } if ( !any_arg || ( (score_slo == -1) && (score_int != -1) ) || ( (score_slo != -1) && (score_int == -1) ) ) { help(); exit( 0 ); } /* Initialize maln, either from specified input file or brand new */ if ( in_ma ) { maln = read_ma( ma_in_fn ); } else { help(); exit( 0 ); } /* Set the maln->cons_code to something reasonable */ maln->cons_code = cons_scheme; /* Now input from all sources has been dealt with, we turn our attention to output...*/ sort_aln_frags( maln ); /* If an ID to be assigned to the assembly was given, then assign it now */ if ( id_assigned ) { strcpy( maln->ref->id, assign_id ); } if ( (out_format == 6) || (out_format == 61) ) { print_region( maln, reg_start, reg_end, out_format, in_color ); } else { show_consensus( maln, out_format ); } if (out_format == 7){ ace_output(maln); } /* Write MapAlignment output to a file */ if ( out_ma ) { write_ma( mafn, maln ); } exit( 0 ); }