/** * Print a list of audits, with their names, numbers, and current * counters. */ void print_audit_list (const char *title, struct audit *aud) { U8 auditno = 1; audit_t *aptr; U8 format; print_string (title); print_nl (); print_bar (); while (far_read_pointer (&aud->name, TEST_PAGE) != NULL) { sprintf ("%02d", auditno); print_string (sprintf_buffer); printer_moveto (5); print_from_page (TEST_PAGE); print_string ((char *)far_read_pointer (&aud->name, TEST_PAGE)); print_from_this_page (); aptr = far_read_pointer (&aud->nvram, TEST_PAGE); if (aptr) { format = far_read8 (&aud->format, TEST_PAGE); printer_moveto (30); render_audit (*aptr, format); print_string (sprintf_buffer); } print_nl (); aud++; auditno++; } }
void client_autotune() { uint8_t channels = rf_cfg_get_channel_count(); print_hw(PSTR("autotune channels="), channels); uint8_t bw = rf_cfg_get_channel_bw(); print_hb(PSTR(", bw = "), bw); print_nl(); rf_scan_start(); uint8_t c; for(c=0; c<channels; c++) { uint16_t v = rf_scan_get_signal_level_at_channel(c); print_hb(PSTR("channel "),c); uint16_t f = rf_cfg_get_channel_f0(c, bw); print_hw(PSTR(", freq "),f); print_hw(PSTR(" - sig_level "),v); if (v > 0) { rf_scan_stop(); if (client_check_for_server(c)) { print(PSTR(" server detected")); } else { print(PSTR(" no server")); } rf_scan_start(); } print_nl(); } rf_scan_stop(); }
/* This function should be invoked from a separate task context, because it may sleep. */ void print_all_audits (void) { printer_reconfig (); printout_name = "AUDIT REPORT"; print_audit_list ("MAIN AUDITS", main_audits); print_nl (); print_audit_list ("EARNINGS AUDITS", earnings_audits); print_nl (); print_audit_list ("STANDARD AUDITS", standard_audits); print_nl (); print_audit_list ("FEATURE AUDITS", feature_audit_info); print_ff (); }
static void print_ndtstats(const struct ndt_stats *ndts) { print_string(PRINT_FP, NULL, " stats ", NULL); print_u64(PRINT_ANY, "allocs", "allocs %llu ", ndts->ndts_allocs); print_u64(PRINT_ANY, "destroys", "destroys %llu ", ndts->ndts_destroys); print_u64(PRINT_ANY, "hash_grows", "hash_grows %llu ", ndts->ndts_hash_grows); print_string(PRINT_FP, NULL, "%s ", _SL_); print_u64(PRINT_ANY, "res_failed", "res_failed %llu ", ndts->ndts_res_failed); print_u64(PRINT_ANY, "lookups", "lookups %llu ", ndts->ndts_lookups); print_u64(PRINT_ANY, "hits", "hits %llu ", ndts->ndts_hits); print_string(PRINT_FP, NULL, "%s ", _SL_); print_u64(PRINT_ANY, "rcv_probes_mcast", "rcv_probes_mcast %llu ", ndts->ndts_rcv_probes_mcast); print_u64(PRINT_ANY, "rcv_probes_ucast", "rcv_probes_ucast %llu ", ndts->ndts_rcv_probes_ucast); print_string(PRINT_FP, NULL, "%s ", _SL_); print_u64(PRINT_ANY, "periodic_gc_runs", "periodic_gc_runs %llu ", ndts->ndts_periodic_gc_runs); print_u64(PRINT_ANY, "forced_gc_runs", "forced_gc_runs %llu ", ndts->ndts_forced_gc_runs); print_nl(); }
void tex::show_page_stats(int b, int pi, int c) { begin_diagnostic(); print_nl("%"); print(" t="); print_totals(); print(" g="); print_scaled(page_goal); print(" b="); if (b == AWFUL_BAD) { print_char('*'); } else { print_int(b); } print(" p="); print_int(pi); print(" c="); if (c == AWFUL_BAD) { print("*"); } else { print_int(c); } if (c <= least_page_cost) { print("#"); } end_diagnostic(FALSE); }
/** * Move the print head to the specified column. This can be used * to implement tabs. Physical spaces are output as needed to get * to the correct location. */ void printer_moveto (U8 colno) { if (colno < printer_colno) { print_nl (); } print_repeated_char (' ', colno - printer_colno); }
void tex::flush_discretionary(ptr p) { begin_diagnostic(); print_nl("The following discretionary sublist has been deleted:"); show_box(p); end_diagnostic(TRUE); flush_node_list(p); }
/* sec 0073 */ void print_err (const char * s) { if (interaction == error_stop_mode) do_nothing(); print_nl("! "); prints(s); }
static void message_body_print(const ProtobufCMessage *message, FILE *out, int tabs) { print_tabs(out, tabs); fprintf(out, "{ [%zu]", message->descriptor->sizeof_message); tabs++; unsigned i; for (i = 0; i < message->descriptor->n_fields; i++) { const ProtobufCFieldDescriptor *field = message->descriptor->fields + i; const void *member = ((const char *) message) + field->offset; const void *qmember = ((const char *) message) + field->quantifier_offset; print_nl(out, tabs); fprintf(out, "%d: ", field->id); if (field->label == PROTOBUF_C_LABEL_REQUIRED) { fprintf(out, "required "); type_name_print(field, out); fprintf(out, " = "); required_field_print(field, member, out, tabs); } else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) { fprintf(out, "optional "); type_name_print(field, out); fprintf(out, " = "); optional_field_print(field, qmember, member, out, tabs); } else { fprintf(out, "repeated "); type_name_print(field, out); fprintf(out, " = "); repeated_field_print(field, *(const size_t *)qmember, member, out, tabs); } } for (i = 0; i < message->n_unknown_fields; i++) { fprintf(out, "unknown "); unknown_field_print(&message->unknown_fields[i], out); print_nl(out, tabs); } tabs--; print_nl(out, tabs); fprintf(out, "}"); }
void tex::box_error(int n) { error(); begin_diagnostic(); print_nl("The following box has been deleted:"); show_box(box(n)); end_diagnostic(TRUE); flush_node_list(box(n)); box(n) = null; }
void tex::show_cur_page() { ptr p, q; int t; if (page_head == page_tail) return; print_nl("### current page:"); if (output_active) print(" (held over for next output)"); show_box(link(page_head)); if (page_contents > EMPTY) { print_nl("total height "); print_totals(); print_nl(" goal height "); print_scaled(page_goal); p = link(page_ins_head); while (p != page_ins_head) { print_ln(); print_esc("insert"); t = subtype(p); print_int(t); print(" adds "); t = x_over_n(page_ins_height(p), 1000) * count(t); print_scaled(t); if (type(p) == SPLIT_UP) { q = page_head; t = 0; do { q = link(q); if (type(q) == INS_NODE && subtype(q) == subtype(p)) incr(t); } while (q != broken_ins(p)); print(", #"); print_int(t); print(" might split"); } p = link(p); } } }
void display_proposal_info(proposal_info_type *info) { print_nl(); print_nl(); print_str("*************************************************\n"); print_str("Title: "); print_str(info->title); print_nl(); print_str("Start Date: "); if (info->start_date.month !=0) { print_date(info->start_date); } print_nl(); print_str("End Date: "); if (info->end_date.month !=0) { print_date(info->end_date); } print_nl(); print_str("Fee/Profit: "); print_fp(info->fee); print_nl(); print_str("*************************************************\n"); }
void set_print_info() { uint8_t mode = eerd_b(EE_AUTO_MODE); print_hb(PSTR("auto mode (0:client, 1:server) = "),mode); print_nl(); uint8_t slot_size = eerd_b(EE_SLOT_SIZE); print_hb(PSTR("slot_size (in ms) = "),slot_size); print_nl(); uint8_t slot_count = eerd_b(EE_SLOT_COUNT); print_hb(PSTR("slot_count (clients = slots-3) = "),slot_count); print_nl(); uint8_t slot_rest_delay = eerd_b(EE_SLOT_REST_DELAY); print_hb(PSTR("slot_rest_delay (in 50us) = "),slot_rest_delay); print_nl(); uint8_t slot_rf_timeout = eerd_b(EE_SLOT_RF_TIMEOUT); print_hb(PSTR("slot_rf_timeout (in 20us) = "),slot_rf_timeout); print_nl(); uint8_t cid = eerd_b(EE_CLIENT_ID); print_hb(PSTR("client_id = "),cid); print_nl(); }
void client_select_channel(uint8_t c) { print_hb(PSTR("setting channel "), c); rf_tune_channel(c); print_nl(); print(PSTR("listening for server packet...")); uint8_t it = 10; uint8_t ok = 0; while(it--) { uint8_t rc = rf_recv_packet(50); print_char('0'+rc); print_hb(PSTR(" v0:"), rf_get_packet_v0()); print_hb(PSTR(" v1:"), rf_get_packet_v1()); print_hb(PSTR(" v2:"), rf_get_packet_v2()); print_hb(PSTR(" v3:"), rf_get_packet_v3()); print_nl(); if (rc == 1) { ok++; } } print_nl(); print_hb(PSTR("result = "),ok); print_nl(); }
void show_cur_cmd_chr() { begin_diagnostic(); print_nl("{"); if (mode != shown_mode) { print_mode(mode); print(": "); shown_mode = mode; } print_cmd_chr(cur_cmd, cur_chr); print("}"); end_diagnostic(FALSE); }
boolean e_of_ch_module P1C(file_index,i) #line 937 "../../../texk/web2c/tiedir/tie.w" {register input_description*inp_desc= input_organization[i]; if(inp_desc->limit<0){ print_nl("! At the end of change file missing @z "); print2("%s",input_organization[i]->name_of_file); term_new_line; return(true); }else if(inp_desc->limit>=2)if(inp_desc->buffer[0]==64&& (inp_desc->buffer[1]==90||inp_desc->buffer[1]==122)) return(true); return(false); }
void tex::freeze_page_specs(int s) { page_contents = s; page_goal = vsize; page_max_depth = max_depth; page_depth = 0; do_all_six(set_page_so_far_zero); least_page_cost = AWFUL_BAD; if (tracing_pages > 0) { begin_diagnostic(); print_nl("%% goal height="); print_scaled(page_goal); print(", max depth="); print_scaled(page_max_depth); end_diagnostic(FALSE); } }
void tex::show_split(int n, scal w, ptr q) { begin_diagnostic(); print_nl("% split"); print_int(n); print(" to "); print_scaled(w); print_char(','); print_scaled(best_height_plus_depth); print(" p="); if (q == null) { print_int(EJECT_PENALTY); } else if (type(q) == PENALTY_NODE) { print_int(penalty(q)); } else { print("0"); } end_diagnostic(FALSE); }
void print_header (void) { if (print_header_needed == FALSE) return; print_header_needed = FALSE; printer_pageno++; /** * Just before printing the page header, see if the PAUSE EVERY PAGE * setting is on. If so, the user must press Enter before the page * is written. This would be for printers that need paper manually fed * into them. */ if (printer_config.pause_every_page == YES) { dmd_alloc_low_clean (); font_render_string_center (&font_mono5, 64, 11, "PRESS ENTER"); font_render_string_center (&font_mono5, 64, 21, "FOR NEXT PAGE"); dmd_show_low (); while (!switch_poll (SW_ENTER)) task_sleep (TIME_66MS); while (switch_poll (SW_ENTER)) task_sleep (TIME_66MS); } /* Print the actual page header. * Note that we do not use sprintf() here, as that has been * seen to cause stack overflows. We opt for a much simpler * approach whereby the tilde character is substituted with * the real page number. This limits reports to 9 pages. * The proper solution would be to use fork a separate * task to work around the stack size limitation. */ print_string (printout_name); print_line_right ("PAGE ~"); print_nl (); }
void ldctor_build_sets (void) { static bfd_boolean called; bfd_boolean header_printed; struct set_info *p; /* The emulation code may call us directly, but we only want to do this once. */ if (called) return; called = TRUE; if (constructors_sorted) { for (p = sets; p != NULL; p = p->next) { int c, i; struct set_element *e; struct set_element **array; if (p->elements == NULL) continue; c = 0; for (e = p->elements; e != NULL; e = e->next) ++c; array = xmalloc (c * sizeof *array); i = 0; for (e = p->elements; e != NULL; e = e->next) { array[i] = e; ++i; } qsort (array, c, sizeof *array, ctor_cmp); e = array[0]; p->elements = e; for (i = 0; i < c - 1; i++) array[i]->next = array[i + 1]; array[i]->next = NULL; free (array); } } lang_list_init (&constructor_list); push_stat_ptr (&constructor_list); header_printed = FALSE; for (p = sets; p != NULL; p = p->next) { struct set_element *e; reloc_howto_type *howto; int reloc_size, size; /* If the symbol is defined, we may have been invoked from collect, and the sets may already have been built, so we do not do anything. */ if (p->h->type == bfd_link_hash_defined || p->h->type == bfd_link_hash_defweak) continue; /* For each set we build: set: .long number_of_elements .long element0 ... .long elementN .long 0 except that we use the right size instead of .long. When generating relocatable output, we generate relocs instead of addresses. */ howto = bfd_reloc_type_lookup (link_info.output_bfd, p->reloc); if (howto == NULL) { if (link_info.relocatable) { einfo (_("%P%X: %s does not support reloc %s for set %s\n"), bfd_get_target (link_info.output_bfd), bfd_get_reloc_code_name (p->reloc), p->h->root.string); continue; } /* If this is not a relocatable link, all we need is the size, which we can get from the input BFD. */ if (p->elements->section->owner != NULL) howto = bfd_reloc_type_lookup (p->elements->section->owner, p->reloc); if (howto == NULL) { einfo (_("%P%X: %s does not support reloc %s for set %s\n"), bfd_get_target (p->elements->section->owner), bfd_get_reloc_code_name (p->reloc), p->h->root.string); continue; } } reloc_size = bfd_get_reloc_size (howto); switch (reloc_size) { case 1: size = BYTE; break; case 2: size = SHORT; break; case 4: size = LONG; break; case 8: if (howto->complain_on_overflow == complain_overflow_signed) size = SQUAD; else size = QUAD; break; default: einfo (_("%P%X: Unsupported size %d for set %s\n"), bfd_get_reloc_size (howto), p->h->root.string); size = LONG; break; } lang_add_assignment (exp_assop ('=', ".", exp_unop (ALIGN_K, exp_intop (reloc_size)))); lang_add_assignment (exp_assop ('=', p->h->root.string, exp_nameop (NAME, "."))); lang_add_data (size, exp_intop (p->count)); for (e = p->elements; e != NULL; e = e->next) { if (config.map_file != NULL) { int len; if (! header_printed) { minfo (_("\nSet Symbol\n\n")); header_printed = TRUE; } minfo ("%s", p->h->root.string); len = strlen (p->h->root.string); if (len >= 19) { print_nl (); len = 0; } while (len < 20) { print_space (); ++len; } if (e->name != NULL) minfo ("%T\n", e->name); else minfo ("%G\n", e->section->owner, e->section, e->value); } /* Need SEC_KEEP for --gc-sections. */ if (! bfd_is_abs_section (e->section)) e->section->flags |= SEC_KEEP; if (link_info.relocatable) lang_add_reloc (p->reloc, howto, e->section, e->name, exp_intop (e->value)); else lang_add_data (size, exp_relop (e->section, e->value)); } lang_add_data (size, exp_intop (0)); } pop_stat_ptr (); }
static void print_ndtparams(struct rtattr *tpb[]) { if (tpb[NDTPA_IFINDEX]) { __u32 ifindex = rta_getattr_u32(tpb[NDTPA_IFINDEX]); print_string(PRINT_FP, NULL, " dev ", NULL); print_color_string(PRINT_ANY, COLOR_IFNAME, "dev", "%s ", ll_index_to_name(ifindex)); print_nl(); } print_string(PRINT_FP, NULL, " ", NULL); if (tpb[NDTPA_REFCNT]) { __u32 refcnt = rta_getattr_u32(tpb[NDTPA_REFCNT]); print_uint(PRINT_ANY, "refcnt", "refcnt %u ", refcnt); } if (tpb[NDTPA_REACHABLE_TIME]) { __u64 reachable = rta_getattr_u64(tpb[NDTPA_REACHABLE_TIME]); print_u64(PRINT_ANY, "reachable", "reachable %llu ", reachable); } if (tpb[NDTPA_BASE_REACHABLE_TIME]) { __u64 breachable = rta_getattr_u64(tpb[NDTPA_BASE_REACHABLE_TIME]); print_u64(PRINT_ANY, "base_reachable", "base_reachable %llu ", breachable); } if (tpb[NDTPA_RETRANS_TIME]) { __u64 retrans = rta_getattr_u64(tpb[NDTPA_RETRANS_TIME]); print_u64(PRINT_ANY, "retrans", "retrans %llu ", retrans); } print_string(PRINT_FP, NULL, "%s ", _SL_); if (tpb[NDTPA_GC_STALETIME]) { __u64 gc_stale = rta_getattr_u64(tpb[NDTPA_GC_STALETIME]); print_u64(PRINT_ANY, "gc_stale", "gc_stale %llu ", gc_stale); } if (tpb[NDTPA_DELAY_PROBE_TIME]) { __u64 delay_probe = rta_getattr_u64(tpb[NDTPA_DELAY_PROBE_TIME]); print_u64(PRINT_ANY, "delay_probe", "delay_probe %llu ", delay_probe); } if (tpb[NDTPA_QUEUE_LEN]) { __u32 queue = rta_getattr_u32(tpb[NDTPA_QUEUE_LEN]); print_uint(PRINT_ANY, "queue", "queue %u ", queue); } print_string(PRINT_FP, NULL, "%s ", _SL_); if (tpb[NDTPA_APP_PROBES]) { __u32 aprobe = rta_getattr_u32(tpb[NDTPA_APP_PROBES]); print_uint(PRINT_ANY, "app_probes", "app_probes %u ", aprobe); } if (tpb[NDTPA_UCAST_PROBES]) { __u32 uprobe = rta_getattr_u32(tpb[NDTPA_UCAST_PROBES]); print_uint(PRINT_ANY, "ucast_probes", "ucast_probes %u ", uprobe); } if (tpb[NDTPA_MCAST_PROBES]) { __u32 mprobe = rta_getattr_u32(tpb[NDTPA_MCAST_PROBES]); print_uint(PRINT_ANY, "mcast_probes", "mcast_probes %u ", mprobe); } print_string(PRINT_FP, NULL, "%s ", _SL_); if (tpb[NDTPA_ANYCAST_DELAY]) { __u64 anycast_delay = rta_getattr_u64(tpb[NDTPA_ANYCAST_DELAY]); print_u64(PRINT_ANY, "anycast_delay", "anycast_delay %llu ", anycast_delay); } if (tpb[NDTPA_PROXY_DELAY]) { __u64 proxy_delay = rta_getattr_u64(tpb[NDTPA_PROXY_DELAY]); print_u64(PRINT_ANY, "proxy_delay", "proxy_delay %llu ", proxy_delay); } if (tpb[NDTPA_PROXY_QLEN]) { __u32 pqueue = rta_getattr_u32(tpb[NDTPA_PROXY_QLEN]); print_uint(PRINT_ANY, "proxy_queue", "proxy_queue %u ", pqueue); } if (tpb[NDTPA_LOCKTIME]) { __u64 locktime = rta_getattr_u64(tpb[NDTPA_LOCKTIME]); print_u64(PRINT_ANY, "locktime", "locktime %llu ", locktime); } print_nl(); }
/** * Print a string right justified to the edge of the page. */ void print_line_right (const char *text) { printer_moveto (printer_config.column_width - strlen (text)); print_string (text); print_nl (); }
void print_bar (void) { print_repeated_char ('-', printer_config.column_width); print_nl (); }
static int print_ntable(struct nlmsghdr *n, void *arg) { FILE *fp = (FILE *)arg; struct ndtmsg *ndtm = NLMSG_DATA(n); int len = n->nlmsg_len; struct rtattr *tb[NDTA_MAX+1]; struct rtattr *tpb[NDTPA_MAX+1]; int ret; if (n->nlmsg_type != RTM_NEWNEIGHTBL) { fprintf(stderr, "Not NEIGHTBL: %08x %08x %08x\n", n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags); return 0; } len -= NLMSG_LENGTH(sizeof(*ndtm)); if (len < 0) { fprintf(stderr, "BUG: wrong nlmsg len %d\n", len); return -1; } if (preferred_family && preferred_family != ndtm->ndtm_family) return 0; parse_rtattr(tb, NDTA_MAX, NDTA_RTA(ndtm), n->nlmsg_len - NLMSG_LENGTH(sizeof(*ndtm))); if (tb[NDTA_NAME]) { const char *name = rta_getattr_str(tb[NDTA_NAME]); if (filter.name && strcmp(filter.name, name)) return 0; } if (tb[NDTA_PARMS]) { parse_rtattr(tpb, NDTPA_MAX, RTA_DATA(tb[NDTA_PARMS]), RTA_PAYLOAD(tb[NDTA_PARMS])); if (tpb[NDTPA_IFINDEX]) { __u32 ifindex = rta_getattr_u32(tpb[NDTPA_IFINDEX]); if (filter.index && filter.index != ifindex) return 0; } else { if (filter.index && filter.index != NONE_DEV) return 0; } } open_json_object(NULL); print_string(PRINT_ANY, "family", "%s ", family_name(ndtm->ndtm_family)); if (tb[NDTA_NAME]) { const char *name = rta_getattr_str(tb[NDTA_NAME]); print_string(PRINT_ANY, "name", "%s ", name); } print_nl(); ret = (tb[NDTA_THRESH1] || tb[NDTA_THRESH2] || tb[NDTA_THRESH3] || tb[NDTA_GC_INTERVAL]); if (ret) print_string(PRINT_FP, NULL, " ", NULL); if (tb[NDTA_THRESH1]) { __u32 thresh1 = rta_getattr_u32(tb[NDTA_THRESH1]); print_uint(PRINT_ANY, "thresh1", "thresh1 %u ", thresh1); } if (tb[NDTA_THRESH2]) { __u32 thresh2 = rta_getattr_u32(tb[NDTA_THRESH2]); print_uint(PRINT_ANY, "thresh2", "thresh2 %u ", thresh2); } if (tb[NDTA_THRESH3]) { __u32 thresh3 = rta_getattr_u32(tb[NDTA_THRESH3]); print_uint(PRINT_ANY, "thresh3", "thresh3 %u ", thresh3); } if (tb[NDTA_GC_INTERVAL]) { __u64 gc_int = rta_getattr_u64(tb[NDTA_GC_INTERVAL]); print_u64(PRINT_ANY, "gc_interval", "gc_int %llu ", gc_int); } if (ret) print_nl(); if (tb[NDTA_CONFIG] && show_stats) print_ndtconfig(RTA_DATA(tb[NDTA_CONFIG])); if (tb[NDTA_PARMS]) print_ndtparams(tpb); if (tb[NDTA_STATS] && show_stats) print_ndtstats(RTA_DATA(tb[NDTA_STATS])); print_string(PRINT_FP, NULL, "\n", ""); close_json_object(); fflush(fp); return 0; }
uint8_t client_do_prompt() { char cmd[17]; //scanf("%16s",cmd); scan_key(cmd,17); if (strcmp(cmd,"init")==0) { client_init(); print_ok_nl(); return 1; } if (strcmp(cmd,"loop")==0) { uint16_t count = scan_uint16(); if (count == 0) { print(PSTR("client loop....")); while(!uart_read_ready()) { client_loop(); } print(PSTR(" end\n\r")); } else { while(count--) { print_char('.'); client_loop(); } } return 1; } if (strcmp(cmd,"autotune")==0) { client_autotune(); return 1; } if (strcmp(cmd,"channel")==0) { uint8_t c = scan_uint8(); client_select_channel(c); return 1; } if (strcmp(cmd,"check")==0) { uint8_t c = scan_uint8(); if (client_check_for_server(c)) { print(PSTR("ok\r\n")); } else { print(PSTR("fail\r\n")); } return 1; } if (strcmp(cmd,"pad")==0) { uint8_t l = client_read_pad(); print_hb(0,l); while(!uart_read_ready()) { uint8_t d = client_read_pad(); if (d!=l) { l = d; print_hb(PSTR(" "), d); } } return 1; } if (strcmp(cmd,"reset_stats")==0) { stats_ok = 0; stats_inv_seq = 0; stats_bad_crc = 0; stats_timeout = 0; print(PSTR("stat reset ok")); return 1; } if (strcmp(cmd,"stats")==0) { print_dw(PSTR("ok: "), stats_ok); print_dw(PSTR(" inv_seq: "), stats_inv_seq); print_dw(PSTR(" bad_crc: "), stats_bad_crc); print_dw(PSTR(" timeout: "), stats_timeout); print_nl(); return 1; } return 1; }
static int ipntable_modify(int cmd, int flags, int argc, char **argv) { struct { struct nlmsghdr n; struct ndtmsg ndtm; char buf[1024]; } req = { .n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndtmsg)), .n.nlmsg_flags = NLM_F_REQUEST | flags, .n.nlmsg_type = cmd, .ndtm.ndtm_family = preferred_family, }; char *namep = NULL; char *threshsp = NULL; char *gc_intp = NULL; char parms_buf[1024] = {}; struct rtattr *parms_rta = (struct rtattr *)parms_buf; int parms_change = 0; parms_rta->rta_type = NDTA_PARMS; parms_rta->rta_len = RTA_LENGTH(0); while (argc > 0) { if (strcmp(*argv, "name") == 0) { int len; NEXT_ARG(); if (namep) duparg("NAME", *argv); namep = *argv; len = strlen(namep) + 1; addattr_l(&req.n, sizeof(req), NDTA_NAME, namep, len); } else if (strcmp(*argv, "thresh1") == 0) { __u32 thresh1; NEXT_ARG(); threshsp = *argv; if (get_u32(&thresh1, *argv, 0)) invarg("\"thresh1\" value is invalid", *argv); addattr32(&req.n, sizeof(req), NDTA_THRESH1, thresh1); } else if (strcmp(*argv, "thresh2") == 0) { __u32 thresh2; NEXT_ARG(); threshsp = *argv; if (get_u32(&thresh2, *argv, 0)) invarg("\"thresh2\" value is invalid", *argv); addattr32(&req.n, sizeof(req), NDTA_THRESH2, thresh2); } else if (strcmp(*argv, "thresh3") == 0) { __u32 thresh3; NEXT_ARG(); threshsp = *argv; if (get_u32(&thresh3, *argv, 0)) invarg("\"thresh3\" value is invalid", *argv); addattr32(&req.n, sizeof(req), NDTA_THRESH3, thresh3); } else if (strcmp(*argv, "gc_int") == 0) { __u64 gc_int; NEXT_ARG(); gc_intp = *argv; if (get_u64(&gc_int, *argv, 0)) invarg("\"gc_int\" value is invalid", *argv); addattr_l(&req.n, sizeof(req), NDTA_GC_INTERVAL, &gc_int, sizeof(gc_int)); } else if (strcmp(*argv, "dev") == 0) { __u32 ifindex; NEXT_ARG(); ifindex = ll_name_to_index(*argv); if (!ifindex) return nodev(*argv); rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_IFINDEX, ifindex); } else if (strcmp(*argv, "base_reachable") == 0) { __u64 breachable; NEXT_ARG(); if (get_u64(&breachable, *argv, 0)) invarg("\"base_reachable\" value is invalid", *argv); rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_BASE_REACHABLE_TIME, &breachable, sizeof(breachable)); parms_change = 1; } else if (strcmp(*argv, "retrans") == 0) { __u64 retrans; NEXT_ARG(); if (get_u64(&retrans, *argv, 0)) invarg("\"retrans\" value is invalid", *argv); rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_RETRANS_TIME, &retrans, sizeof(retrans)); parms_change = 1; } else if (strcmp(*argv, "gc_stale") == 0) { __u64 gc_stale; NEXT_ARG(); if (get_u64(&gc_stale, *argv, 0)) invarg("\"gc_stale\" value is invalid", *argv); rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_GC_STALETIME, &gc_stale, sizeof(gc_stale)); parms_change = 1; } else if (strcmp(*argv, "delay_probe") == 0) { __u64 delay_probe; NEXT_ARG(); if (get_u64(&delay_probe, *argv, 0)) invarg("\"delay_probe\" value is invalid", *argv); rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_DELAY_PROBE_TIME, &delay_probe, sizeof(delay_probe)); parms_change = 1; } else if (strcmp(*argv, "queue") == 0) { __u32 queue; NEXT_ARG(); if (get_u32(&queue, *argv, 0)) invarg("\"queue\" value is invalid", *argv); rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_QUEUE_LEN, queue); parms_change = 1; } else if (strcmp(*argv, "app_probes") == 0) { __u32 aprobe; NEXT_ARG(); if (get_u32(&aprobe, *argv, 0)) invarg("\"app_probes\" value is invalid", *argv); rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_APP_PROBES, aprobe); parms_change = 1; } else if (strcmp(*argv, "ucast_probes") == 0) { __u32 uprobe; NEXT_ARG(); if (get_u32(&uprobe, *argv, 0)) invarg("\"ucast_probes\" value is invalid", *argv); rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_UCAST_PROBES, uprobe); parms_change = 1; } else if (strcmp(*argv, "mcast_probes") == 0) { __u32 mprobe; NEXT_ARG(); if (get_u32(&mprobe, *argv, 0)) invarg("\"mcast_probes\" value is invalid", *argv); rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_MCAST_PROBES, mprobe); parms_change = 1; } else if (strcmp(*argv, "anycast_delay") == 0) { __u64 anycast_delay; NEXT_ARG(); if (get_u64(&anycast_delay, *argv, 0)) invarg("\"anycast_delay\" value is invalid", *argv); rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_ANYCAST_DELAY, &anycast_delay, sizeof(anycast_delay)); parms_change = 1; } else if (strcmp(*argv, "proxy_delay") == 0) { __u64 proxy_delay; NEXT_ARG(); if (get_u64(&proxy_delay, *argv, 0)) invarg("\"proxy_delay\" value is invalid", *argv); rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_PROXY_DELAY, &proxy_delay, sizeof(proxy_delay)); parms_change = 1; } else if (strcmp(*argv, "proxy_queue") == 0) { __u32 pqueue; NEXT_ARG(); if (get_u32(&pqueue, *argv, 0)) invarg("\"proxy_queue\" value is invalid", *argv); rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_PROXY_QLEN, pqueue); parms_change = 1; } else if (strcmp(*argv, "locktime") == 0) { __u64 locktime; NEXT_ARG(); if (get_u64(&locktime, *argv, 0)) invarg("\"locktime\" value is invalid", *argv); rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_LOCKTIME, &locktime, sizeof(locktime)); parms_change = 1; } else { invarg("unknown", *argv); } argc--; argv++; } if (!namep) missarg("NAME"); if (!threshsp && !gc_intp && !parms_change) { fprintf(stderr, "Not enough information: changeable attributes required.\n"); exit(-1); } if (parms_rta->rta_len > RTA_LENGTH(0)) { addattr_l(&req.n, sizeof(req), NDTA_PARMS, RTA_DATA(parms_rta), RTA_PAYLOAD(parms_rta)); } if (rtnl_talk(&rth, &req.n, NULL) < 0) exit(2); return 0; } static const char *ntable_strtime_delta(__u32 msec) { static char str[32]; struct timeval now = {}; time_t t; struct tm *tp; if (msec == 0) goto error; if (gettimeofday(&now, NULL) < 0) { perror("gettimeofday"); goto error; } t = now.tv_sec - (msec / 1000); tp = localtime(&t); if (!tp) goto error; strftime(str, sizeof(str), "%Y-%m-%d %T", tp); return str; error: strcpy(str, "(error)"); return str; } static void print_ndtconfig(const struct ndt_config *ndtc) { print_uint(PRINT_ANY, "key_length", " config key_len %u ", ndtc->ndtc_key_len); print_uint(PRINT_ANY, "entry_size", "entry_size %u ", ndtc->ndtc_entry_size); print_uint(PRINT_ANY, "entries", "entries %u ", ndtc->ndtc_entries); print_nl(); print_string(PRINT_ANY, "last_flush", " last_flush %s ", ntable_strtime_delta(ndtc->ndtc_last_flush)); print_string(PRINT_ANY, "last_rand", "last_rand %s ", ntable_strtime_delta(ndtc->ndtc_last_rand)); print_nl(); print_uint(PRINT_ANY, "hash_rnd", " hash_rnd %u ", ndtc->ndtc_hash_rnd); print_0xhex(PRINT_ANY, "hash_mask", "hash_mask %08llx ", ndtc->ndtc_hash_mask); print_uint(PRINT_ANY, "hash_chain_gc", "hash_chain_gc %u ", ndtc->ndtc_hash_chain_gc); print_uint(PRINT_ANY, "proxy_qlen", "proxy_qlen %u ", ndtc->ndtc_proxy_qlen); print_nl(); }
uint8_t pad_do_prompt() { char cmd[17]; scan_key(cmd,17); if (strcmp(cmd,"init")==0) { pad_init(); return 1; } if ((strcmp(cmd,"test")==0) || (strcmp(cmd,"ping")==0)) { if (pad_ping()) { print_ok_nl(); } else { print_err_nl(); } return 1; } if (strcmp(cmd,"state")==0) { uint8_t d = pad_state(); if (d == PAD_REMOTE_ERROR) { print_err_nl(); } else { print_hb(0,d); print_nl(); } return 1; } if (strcmp(cmd,"led")==0) { pad_led(); return 1; } if (strcmp(cmd,"rled")==0) { pad_remote_led(); return 1; } if (strcmp(cmd,"read")==0) { uint8_t d = pad_read(); print_hb(0,d); print_nl(); return 1; } if (strcmp(cmd,"write")==0) { uint8_t v0 = scan_uint8(); if (pad_write(v0)) { print_ok_nl(); } else { print_err_nl(); } return 1; } if (strcmp(cmd,"autoread")==0) { pad_autoread(); return 1; } return 1; }
int proposal_setup(proposal_info_type *info){ char *proposal_setup_menu[] = { "Proposal Setup\n\n", "A - Display Proposal Info\n", "B - Enter Proposal Name\n", "C - Enter Proposal Fee/Profit\n", "D - Enter Proposal POP\n", "E - Exit Proposal Setup\n:" }; char buf[10]; size_t rcv_cnt; int i; // loop over the proposal setup menu while (1) { print_nl(); for (i=0;i< sizeof(proposal_setup_menu)/sizeof(char *);++i) print_str(proposal_setup_menu[i]); rcv_cnt=getnstr(buf, sizeof(buf)); if (rcv_cnt==0) continue; switch (buf[0]){ case 'a': case 'A': display_proposal_info(info); break; case 'b': case 'B': set_proposal_name(info); break; case 'c': case 'C': set_proposal_fee(info); break; case 'd': case 'D': set_proposal_pop(info); break; case 'e': case 'E': if (validate_proposal_setup(info)==-1) { display_proposal_info(info); while (1) { print_str("Proposal is not completely setup. Are you sure you wish to exit setup? "); rcv_cnt=getnstr(buf, sizeof(buf)); if (rcv_cnt==0) continue; if (buf[0]=='y' || buf[0]=='Y') return 0; else break; } // while } // proposal has been setup so now other things are allowed to happen else { info->is_proposal_setup=1; return 0; } break; } } return 0; }
void pdf_ship_out (pointer p) { integer page_loc; char j, k; if (tracing_output > 0) { print_nl(""); print_ln(); prints("Completed box being shipped out"); } if (term_offset > max_print_line - 9) print_ln(); else if ((term_offset > 0) || (file_offset > 0)) print_char(' '); print_char('['); j = 9; while ((count(j) == 0) && (j > 0)) decr(j); for (k = 0; k <= j; k++) { print_int(count(k)); if (k < j) print_char('.'); } update_terminal(); if (tracing_output > 0) { print_char(']'); begin_diagnostic(); show_box(p); end_diagnostic(true); } if ((height(p) > max_dimen) || (depth(p) > max_dimen) || (height(p) + depth(p) + v_offset > max_dimen) || (width(p) + h_offset > max_dimen)) { print_err("Huge page cannot be shipped out"); help2("The page just created is more than 18 feet tall or", "more than 18 feet wide, so I suspect something went wrong."); error(); if (tracing_output <= 0) { begin_diagnostic(); print_nl("The following box has been deleted:"); show_box(p); end_diagnostic(true); } goto done; } if (height(p) + depth(p) + v_offset > max_v) max_v = height(p) + depth(p) + v_offset; if (width(p) + h_offset > max_h) max_h = width(p) + h_offset; dvi_h = 0; dvi_v = 0; cur_h = h_offset; dvi_f = null_font; ensure_pdf_open(); if (total_pages == 0) { pdf_set_version(5); pdf_set_compression(9); pdf_init_fontmaps(); read_config_file("dvipdfmx.cfg"); pdf_doc_set_producer("Y&YTeX 2.3.0"); pdf_doc_set_creator("TeX"); pdf_files_init(); pdf_init_device(0.000015202, 2, 0); // TODO: pdfTeX's page width and height. // page_width = pdf_page_width != 0 ? <- : width(p) + 2 * (pdf_h_origin + h_offset); // page_height = pdf_page_height != 0 ? <- : height(p) + depth(p) + 2 * (pdf_v_origin + v_offset); pdf_open_document(pdf_file_name, 0, 595.0, 842.0, 0, 0, (1 << 4)); spc_exec_at_begin_document(); } page_loc = dvi_offset + dvi_ptr; pdf_doc_begin_page(1.0, 72.0, 770.0); spc_exec_at_begin_page(); last_bop = page_loc; cur_v = height(p) + v_offset; temp_ptr = p; if (type(p) == vlist_node) pdf_vlist_out(); else pdf_hlist_out(); spc_exec_at_end_page(); pdf_doc_end_page(); incr(total_pages); cur_s = -1; done: if (tracing_output <= 0) print_char(']'); dead_cycles = 0; update_terminal(); #ifdef STAT if (tracing_stats > 1) { print_nl("Memory usage before: "); print_int(var_used); print_char('&'); print_int(dyn_used); print_char(';'); } #endif flush_node_list(p); #ifdef STAT if (tracing_stats > 1) { prints(" after: "); print_int(var_used); print_char('&'); print_int(dyn_used); prints("; still utouched: "); print_int(hi_mem_min - lo_mem_max - 1); print_ln(); } #endif }
void tex::show_activities () { int a; int m; list *p; *nest_ptr = cur_list; print_nl(null_str); print_ln(); for (p = nest_ptr; p >= nest; decr(p)) { m = p->mode_field; a = p->aux_field; print_nl("### "); print_mode(m); print(" entered at line "); print_int(abs(p->ml_field)); if (m == HMODE) { if (p->lhm_field != 2 || p->rhm_field != 3) { print(" (hyphenmin "); print_int(p->lhm_field); print(","); print_int(p->rhm_field); print(")"); } } if (p->ml_field < 0) { print(" (\\output routine)"); } if (p == nest) { show_cur_page(); if (link(contrib_head) != null) print_nl("### recent contributions:"); } show_box(link(p->head_field)); switch (abs(m) / (MAX_COMMAND + 1)) { case 0: print_nl("prevdepth "); if (a <= IGNORE_DEPTH) { print("ignored"); } else { print_scaled(a); } if (p->pg_field != 0) { print(", prevgraf "); print_int(p->pg_field); print(" line"); if (p->pg_field != 1) print("s"); } break; case 1: print_nl("spacefactor "); print_int(a); if (m > 0 && p->clang_field > 0) { print(", current language "); print_int(p->clang_field); } break; case 2: if (a != null) { print_nl("this will be denominator of:"); show_box(a); } break; } } }