static void do_stats(void) { long cLoops = cComponents + cLegs - cStns; putnl(); if (cStns == 1) { fputs(msg(/*Survey contains 1 survey station,*/172), stdout); } else { printf(msg(/*Survey contains %ld survey stations,*/173), cStns); } if (cLegs == 1) { fputs(msg(/* joined by 1 leg.*/174), stdout); } else { printf(msg(/* joined by %ld legs.*/175), cLegs); } putnl(); if (cLoops == 1) { fputs(msg(/*There is 1 loop.*/138), stdout); } else { printf(msg(/*There are %ld loops.*/139), cLoops); } putnl(); if (cComponents != 1) { printf(msg(/*Survey has %ld connected components.*/178), cComponents); putnl(); } printf(msg(/*Total length of survey legs = %7.2fm (%7.2fm adjusted)*/132), total, totadj); putnl(); printf(msg(/*Total plan length of survey legs = %7.2fm*/133), totplan); putnl(); printf(msg(/*Total vertical length of survey legs = %7.2fm*/134), totvert); putnl(); /* If there's no underground survey, we've no ranges */ if (pfxHi[0]) { do_range(2, /*Vertical range = %4.2fm (from %s at %4.2fm to %s at %4.2fm)*/135); do_range(1, /*North-South range = %4.2fm (from %s at %4.2fm to %s at %4.2fm)*/136); do_range(0, /*East-West range = %4.2fm (from %s at %4.2fm to %s at %4.2fm)*/137); } print_node_stats(); /* Also, could give: * # nodes stations (ie have other than two references or are fixed) * # fixed stations (list of?) */ }
static void do_type(const char *varname) { int ret; unsigned int i, numq, numa; char **answer; const char *query[4]; query[0] = "TYPE"; query[1] = upsname; query[2] = varname; numq = 3; ret = upscli_get(ups, numq, query, &numa, &answer); if ((ret < 0) || (numa < numq)) { printf("Unknown type\n"); return; } /* TYPE <upsname> <varname> <type>... */ for (i = 3; i < numa; i++) { if (!strcasecmp(answer[i], "ENUM")) { do_enum(varname); return; } if (!strcasecmp(answer[i], "RANGE")) { do_range(varname); return; } if (!strncasecmp(answer[i], "STRING:", 7)) { do_string(varname); return; } /* ignore this one */ if (!strcasecmp(answer[i], "RW")) { continue; } printf("Type: %s (unrecognized)\n", answer[i]); } }
void set_up_aplot_range() { static char *n[]={"Basename","Still(1/0)","Tag(0/1)"}; char values[3][MAX_LEN_SBOX]; int status; double *x; sprintf(values[0],"%s",aplot_range_stem); sprintf(values[1],"%d",aplot_still); sprintf(values[2],"%d",aplot_tag); status=do_string_box(3,3,1,"Array range saving",n,values,28); if(status!=0){ sprintf(aplot_range_stem,"%s",values[0]); aplot_still=atoi(values[1]); aplot_tag=atoi(values[2]); aplot_range=1; aplot_range_count=0; x=&MyData[0]; do_range(x,0); } }
string & DosTextEditer::edcommand(string prompt,ostream &out,LinkList<string> &tmpfile) // pre: string is == to the prompt you wont and ostream == to the stream you wont to output too tmpfile == the file you have opend { string tmpstr; unsigned __int8 changed=0; do { cout<<prompt; MSF::getline(cin,tmpstr); if(tmpstr[0]!='Q') { tmpstr=MSF::tolower(tmpstr); } if(do_range(tmpstr,tmpfile,changed,out)); else if(do_double(tmpstr,tmpfile,changed,out)); else if(do_single(tmpstr,tmpfile,changed,out)); else { cout<<"Bad command."<<endl; } }while(tmpstr[0]!='Q'); return filename; }
static void do_stats(void) { long cLoops = cComponents + cLegs - cStns; int length_units = get_length_units(Q_LENGTH); const char * units = get_units_string(length_units); real length_factor = 1.0 / get_units_factor(length_units); putnl(); if (cStns == 1) { fputs(msg(/*Survey contains 1 survey station,*/172), stdout); } else { printf(msg(/*Survey contains %ld survey stations,*/173), cStns); } if (cLegs == 1) { fputs(msg(/* joined by 1 leg.*/174), stdout); } else { printf(msg(/* joined by %ld legs.*/175), cLegs); } putnl(); if (cLoops == 1) { fputs(msg(/*There is 1 loop.*/138), stdout); } else { printf(msg(/*There are %ld loops.*/139), cLoops); } putnl(); if (cComponents != 1) { /* TRANSLATORS: "Connected component" in the graph theory sense - it * means there are %ld bits of survey with no connections between them. * This message is only used if there are more than 1. */ printf(msg(/*Survey has %ld connected components.*/178), cComponents); putnl(); } printf(msg(/*Total length of survey legs = %7.2f%s (%7.2f%s adjusted)*/132), total * length_factor, units, totadj * length_factor, units); putnl(); printf(msg(/*Total plan length of survey legs = %7.2f%s*/133), totplan * length_factor, units); putnl(); printf(msg(/*Total vertical length of survey legs = %7.2f%s*/134), totvert * length_factor, units); putnl(); /* If there's no underground survey, we've no ranges */ if (pfxHi[0]) { /* TRANSLATORS: numbers are altitudes of highest and lowest stations */ do_range(2, /*Vertical range = %4.2f%s (from %s at %4.2f%s to %s at %4.2f%s)*/135, length_factor, units); /* TRANSLATORS: c.f. previous message */ do_range(1, /*North-South range = %4.2f%s (from %s at %4.2f%s to %s at %4.2f%s)*/136, length_factor, units); /* TRANSLATORS: c.f. previous two messages */ do_range(0, /*East-West range = %4.2f%s (from %s at %4.2f%s to %s at %4.2f%s)*/137, length_factor, units); } print_node_stats(); /* Also, could give: * # nodes stations (ie have other than two references or are fixed) * # fixed stations (list of?) */ }
int main(int argc, char *argv[]) { int c; int action = 0; processorid_t cpu; processorid_t cpuid_max; char *errptr; int errors; psr_action_t *pac; bool disable_smt = 0; cmdname = basename(argv[0]); while ((c = getopt(argc, argv, "afFinsSv")) != EOF) { switch (c) { case 'a': /* applies to all possible CPUs */ all_flag = 1; break; case 'F': force = 1; break; case 'S': disable_smt = 1; break; case 'f': case 'i': case 'n': case 's': if (action != 0 && action != c) { (void) fprintf(stderr, "%s: options -f, -n, -i, and -s are " "mutually exclusive.\n", cmdname); usage(); return (2); } action = c; break; case 'v': verbose = 1; break; default: usage(); return (2); } } if (disable_smt) { if (!all_flag) { fprintf(stderr, "%s: -S must be used with -a.\n", cmdname); usage(); return (2); } if (force || action != 0 || argc != optind) { usage(); return (2); } if (p_online(P_ALL_SIBLINGS, P_DISABLED) == -1) { fprintf(stderr, "Failed to disable simultaneous " "multi-threading: %s\n", strerror(errno)); return (EXIT_FAILURE); } return (EXIT_SUCCESS); } switch (action) { case 'f': action = P_OFFLINE; break; case 'i': action = P_NOINTR; break; case 'n': action = P_ONLINE; break; case 's': action = P_SPARE; break; default: if (force != 0) { /* * The -F option without other transition options * puts processor(s) into faulted state. */ action = P_FAULTED; break; } (void) fprintf(stderr, "%s: option -f, -n, -s or -i must " "be specified.\n", cmdname); usage(); return (2); } pac = psr_action_lookup(action); assert(pac != NULL); errors = 0; if (all_flag) { if (argc != optind) { usage(); return (2); } cpuid_max = (processorid_t)sysconf(_SC_CPUID_MAX); for (cpu = 0; cpu <= cpuid_max; cpu++) { if (psr_set_state(cpu, action, pac, 0) < 0) errors = 1; } } else { argc -= optind; if (argc <= 0) { usage(); /* not enough arguments */ return (2); } for (argv += optind; argc > 0; argv++, argc--) { if (strchr(*argv, '-') == NULL) { /* individual processor id */ cpu = (processorid_t) strtol(*argv, &errptr, 10); if (errptr != NULL && *errptr != '\0') { (void) fprintf(stderr, "%s: invalid processor" " ID %s\n", cmdname, *argv); errors = 2; continue; } if (psr_set_state(cpu, action, pac, 1) < 0) errors = 1; } else { /* range of processors */ processorid_t first, last; first = (processorid_t) strtol(*argv, &errptr, 10); if (*errptr++ != '-') { (void) fprintf(stderr, "%s: invalid processor" " range %s\n", cmdname, *argv); errors = 2; continue; } last = (processorid_t) strtol(errptr, &errptr, 10); if ((errptr != NULL && *errptr != '\0') || last < first || first < 0) { (void) fprintf(stderr, "%s: invalid processor" " range %s\n", cmdname, *argv); errors = 2; continue; } if (do_range(first, last, action, pac)) errors = 1; } } } if (log_open) { closelog(); } return (errors); }
int main(int argc, char *argv[]) { char *displayname = NULL; const char *format = "%lu\t%s"; int i, doit; int didit = 0; xcb_connection_t *c = NULL; ProgramName = argv[0]; for (doit = 0; doit < 2; doit++) { /* pre-parse to get display */ for (i = 1; i < argc; i++) { char *arg = argv[i]; if (arg[0] == '-') { switch (arg[1]) { case 'd': /* -display dpy */ if (++i >= argc) usage (); if (!doit) displayname = argv[i]; continue; case 'f': /* -format string */ if (++i >= argc) usage (); if (doit) format = argv[i]; continue; case 'r': /* -range num-[num] */ if (++i >= argc) usage (); if (doit) { do_range (c, format, argv[i]); didit = 1; } continue; case 'n': /* -name string */ if (++i >= argc) usage (); if (doit) { do_name (c, format, argv[i]); didit = 1; } continue; } } usage (); } if (!doit) { DisplayString = displayname; if (!DisplayString) DisplayString = getenv("DISPLAY"); if (!DisplayString) DisplayString = ""; c = xcb_connect(displayname, NULL); if (!c || xcb_connection_has_error(c)) { fprintf (stderr, "%s: unable to open display \"%s\"\n", ProgramName, DisplayString); exit (1); } } else if (!didit) /* no options, default is list all */ list_atoms(c, format, 0, 0, 0); } xcb_disconnect(c); exit (0); }
int main(int argc, char *argv[]) { char *displayname = NULL; const char *format = "%lu\t%s"; int i, doit; int didit = 0; xcb_connection_t *c = NULL; ProgramName = argv[0]; for (doit = 0; doit < 2; doit++) { /* pre-parse to get display */ for (i = 1; i < argc; i++) { char *arg = argv[i]; if (arg[0] == '-') { switch (arg[1]) { case 'd': /* -display dpy */ if (++i >= argc) usage ("-display requires an argument"); if (!doit) displayname = argv[i]; continue; case 'f': /* -format string */ if (++i >= argc) usage ("-format requires an argument"); if (doit) format = argv[i]; continue; case 'r': /* -range num-[num] */ if (++i >= argc) usage ("-range requires an argument"); if (doit) { do_range (c, format, argv[i]); didit = 1; } continue; case 'n': /* -name string */ if (++i >= argc) usage ("-name requires an argument"); if (doit) { do_name (c, format, argv[i]); didit = 1; } continue; case 'v': if (strcmp(arg, "-version") == 0) { puts(PACKAGE_STRING); exit(0); } /* else FALLTHROUGH to unrecognized arg case below */ } } fprintf (stderr, "%s: unrecognized argument %s\n\n", ProgramName, arg); usage (NULL); } if (!doit) { DisplayString = displayname; if (!DisplayString) DisplayString = getenv("DISPLAY"); if (!DisplayString) DisplayString = ""; c = xcb_connect(displayname, NULL); if (!c || xcb_connection_has_error(c)) { fprintf (stderr, "%s: unable to open display \"%s\"\n", ProgramName, DisplayString); exit (1); } } else if (!didit) /* no options, default is list all */ list_atoms(c, format, 0, 0, 0); } xcb_disconnect(c); exit (0); }
static TEE_Result htree_test_rewrite(struct test_aux *aux, size_t num_blocks, size_t w_unsync_begin, size_t w_unsync_num) { TEE_Result res; struct tee_fs_htree *ht = NULL; size_t salt = 23; assert((w_unsync_begin + w_unsync_num) <= num_blocks); aux->data_len = 0; memset(aux->data, 0xce, aux->data_alloced); res = tee_fs_htree_open(true, &test_htree_ops, aux, &ht); CHECK_RES(res, goto out); /* * Intialize all blocks and verify that they read back as * expected. */ res = do_range(write_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); res = do_range(read_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); /* * Write all blocks again, but starting from the end using a new * salt, then verify that that read back as expected. */ salt++; res = do_range_backwards(write_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); res = do_range(read_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); /* * Use a new salt to write all blocks once more and verify that * they read back as expected. */ salt++; res = do_range(write_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); res = do_range(read_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); /* * Sync the changes of the nodes to memory, verify that all * blocks are read back as expected. */ res = tee_fs_htree_sync_to_storage(&ht); CHECK_RES(res, goto out); res = do_range(read_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); /* * Close and reopen the hash-tree */ tee_fs_htree_close(&ht); res = tee_fs_htree_open(false, &test_htree_ops, aux, &ht); CHECK_RES(res, goto out); /* * Verify that all blocks are read as expected. */ res = do_range(read_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); /* * Rewrite a few blocks and verify that all blocks are read as * expected. */ res = do_range_backwards(write_block, &ht, w_unsync_begin, w_unsync_num, salt + 1); CHECK_RES(res, goto out); res = do_range(read_block, &ht, 0, w_unsync_begin, salt); CHECK_RES(res, goto out); res = do_range(read_block, &ht, w_unsync_begin, w_unsync_num, salt + 1); CHECK_RES(res, goto out); res = do_range(read_block, &ht, w_unsync_begin + w_unsync_num, num_blocks - (w_unsync_begin + w_unsync_num), salt); CHECK_RES(res, goto out); /* * Rewrite the blocks from above again with another salt and * verify that they are read back as expected. */ res = do_range(write_block, &ht, w_unsync_begin, w_unsync_num, salt + 2); CHECK_RES(res, goto out); res = do_range(read_block, &ht, 0, w_unsync_begin, salt); CHECK_RES(res, goto out); res = do_range(read_block, &ht, w_unsync_begin, w_unsync_num, salt + 2); CHECK_RES(res, goto out); res = do_range(read_block, &ht, w_unsync_begin + w_unsync_num, num_blocks - (w_unsync_begin + w_unsync_num), salt); CHECK_RES(res, goto out); /* * Skip tee_fs_htree_sync_to_storage() and call * tee_fs_htree_close() directly to undo the changes since last * call to tee_fs_htree_sync_to_storage(). Reopen the hash-tree * and verify that recent changes indeed was discarded. */ tee_fs_htree_close(&ht); res = tee_fs_htree_open(false, &test_htree_ops, aux, &ht); CHECK_RES(res, goto out); res = do_range(read_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); /* * Close, reopen and verify that all blocks are read as expected * again. */ tee_fs_htree_close(&ht); res = tee_fs_htree_open(false, &test_htree_ops, aux, &ht); CHECK_RES(res, goto out); res = do_range(read_block, &ht, 0, num_blocks, salt); CHECK_RES(res, goto out); out: tee_fs_htree_close(&ht); return res; }