static int codel_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats) { struct tc_codel_xstats _st = {}, *st; SPRINT_BUF(b1); if (xstats == NULL) return 0; st = RTA_DATA(xstats); if (RTA_PAYLOAD(xstats) < sizeof(*st)) { memcpy(&_st, st, RTA_PAYLOAD(xstats)); st = &_st; } fprintf(f, " count %u lastcount %u ldelay %s", st->count, st->lastcount, sprint_time(st->ldelay, b1)); if (st->dropping) fprintf(f, " dropping"); if (st->drop_next < 0) fprintf(f, " drop_next -%s", sprint_time(-st->drop_next, b1)); else fprintf(f, " drop_next %s", sprint_time(st->drop_next, b1)); fprintf(f, "\n maxpacket %u ecn_mark %u drop_overlimit %u", st->maxpacket, st->ecn_mark, st->drop_overlimit); if (st->ce_mark) fprintf(f, " ce_mark %u", st->ce_mark); return 0; }
static int pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) { struct rtattr *tb[TCA_PIE_MAX + 1]; unsigned int limit; unsigned int tupdate; unsigned int target; unsigned int alpha; unsigned int beta; unsigned ecn; unsigned bytemode; SPRINT_BUF(b1); if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_PIE_MAX, opt); if (tb[TCA_PIE_LIMIT] && RTA_PAYLOAD(tb[TCA_PIE_LIMIT]) >= sizeof(__u32)) { limit = rta_getattr_u32(tb[TCA_PIE_LIMIT]); fprintf(f, "limit %up ", limit); } if (tb[TCA_PIE_TARGET] && RTA_PAYLOAD(tb[TCA_PIE_TARGET]) >= sizeof(__u32)) { target = rta_getattr_u32(tb[TCA_PIE_TARGET]); fprintf(f, "target %s ", sprint_time(target, b1)); } if (tb[TCA_PIE_TUPDATE] && RTA_PAYLOAD(tb[TCA_PIE_TUPDATE]) >= sizeof(__u32)) { tupdate = rta_getattr_u32(tb[TCA_PIE_TUPDATE]); fprintf(f, "tupdate %s ", sprint_time(tupdate, b1)); } if (tb[TCA_PIE_ALPHA] && RTA_PAYLOAD(tb[TCA_PIE_ALPHA]) >= sizeof(__u32)) { alpha = rta_getattr_u32(tb[TCA_PIE_ALPHA]); fprintf(f, "alpha %u ", alpha); } if (tb[TCA_PIE_BETA] && RTA_PAYLOAD(tb[TCA_PIE_BETA]) >= sizeof(__u32)) { beta = rta_getattr_u32(tb[TCA_PIE_BETA]); fprintf(f, "beta %u ", beta); } if (tb[TCA_PIE_ECN] && RTA_PAYLOAD(tb[TCA_PIE_ECN]) >= sizeof(__u32)) { ecn = rta_getattr_u32(tb[TCA_PIE_ECN]); if (ecn) fprintf(f, "ecn "); } if (tb[TCA_PIE_BYTEMODE] && RTA_PAYLOAD(tb[TCA_PIE_BYTEMODE]) >= sizeof(__u32)) { bytemode = rta_getattr_u32(tb[TCA_PIE_BYTEMODE]); if (bytemode) fprintf(f, "bytemode "); } return 0; }
static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) { struct rtattr *tb[TCA_TBF_PTAB+1]; struct tc_tbf_qopt *qopt; double buffer, mtu; double latency; SPRINT_BUF(b1); SPRINT_BUF(b2); if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_TBF_PTAB, opt); if (tb[TCA_TBF_PARMS] == NULL) return -1; qopt = RTA_DATA(tb[TCA_TBF_PARMS]); if (RTA_PAYLOAD(tb[TCA_TBF_PARMS]) < sizeof(*qopt)) return -1; fprintf(f, "rate %s ", sprint_rate(qopt->rate.rate, b1)); buffer = tc_calc_xmitsize(qopt->rate.rate, qopt->buffer); if (show_details) { fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1), 1<<qopt->rate.cell_log, sprint_size(qopt->rate.mpu, b2)); } else { fprintf(f, "burst %s ", sprint_size(buffer, b1)); } if (show_raw) fprintf(f, "[%08x] ", qopt->buffer); if (qopt->peakrate.rate) { fprintf(f, "peakrate %s ", sprint_rate(qopt->peakrate.rate, b1)); if (qopt->mtu || qopt->peakrate.mpu) { mtu = tc_calc_xmitsize(qopt->peakrate.rate, qopt->mtu); if (show_details) { fprintf(f, "mtu %s/%u mpu %s ", sprint_size(mtu, b1), 1<<qopt->peakrate.cell_log, sprint_size(qopt->peakrate.mpu, b2)); } else { fprintf(f, "minburst %s ", sprint_size(mtu, b1)); } if (show_raw) fprintf(f, "[%08x] ", qopt->mtu); } } if (show_raw) fprintf(f, "limit %s ", sprint_size(qopt->limit, b1)); latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2time(qopt->buffer); if (qopt->peakrate.rate) { double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2time(qopt->mtu); if (lat2 > latency) latency = lat2; } fprintf(f, "lat %s ", sprint_time(latency, b1)); return 0; }
static int codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) { struct rtattr *tb[TCA_CODEL_MAX + 1]; unsigned int limit; unsigned int interval; unsigned int target; unsigned int ecn; unsigned int ce_threshold; SPRINT_BUF(b1); if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_CODEL_MAX, opt); if (tb[TCA_CODEL_LIMIT] && RTA_PAYLOAD(tb[TCA_CODEL_LIMIT]) >= sizeof(__u32)) { limit = rta_getattr_u32(tb[TCA_CODEL_LIMIT]); fprintf(f, "limit %up ", limit); } if (tb[TCA_CODEL_TARGET] && RTA_PAYLOAD(tb[TCA_CODEL_TARGET]) >= sizeof(__u32)) { target = rta_getattr_u32(tb[TCA_CODEL_TARGET]); fprintf(f, "target %s ", sprint_time(target, b1)); } if (tb[TCA_CODEL_CE_THRESHOLD] && RTA_PAYLOAD(tb[TCA_CODEL_CE_THRESHOLD]) >= sizeof(__u32)) { ce_threshold = rta_getattr_u32(tb[TCA_CODEL_CE_THRESHOLD]); fprintf(f, "ce_threshold %s ", sprint_time(ce_threshold, b1)); } if (tb[TCA_CODEL_INTERVAL] && RTA_PAYLOAD(tb[TCA_CODEL_INTERVAL]) >= sizeof(__u32)) { interval = rta_getattr_u32(tb[TCA_CODEL_INTERVAL]); fprintf(f, "interval %s ", sprint_time(interval, b1)); } if (tb[TCA_CODEL_ECN] && RTA_PAYLOAD(tb[TCA_CODEL_ECN]) >= sizeof(__u32)) { ecn = rta_getattr_u32(tb[TCA_CODEL_ECN]); if (ecn) fprintf(f, "ecn "); } return 0; }
extern "C" int MAMain() { printf("Local time:\n"); time_t myTime = maLocalTime(); for(int i = 0; i < 366*8 ; i++){ printf("%s\n", sprint_time(myTime)); myTime -= (60 * 60 * 24); } FREEZE; }
static void hfsc_print_sc(FILE *f, char *name, struct tc_service_curve *sc) { SPRINT_BUF(b1); fprintf(f, "%s ", name); fprintf(f, "m1 %s ", sprint_rate(sc->m1, b1)); fprintf(f, "d %s ", sprint_time(tc_core_ktime2time(sc->d), b1)); fprintf(f, "m2 %s ", sprint_rate(sc->m2, b1)); }
/** * Get date of a file. * @return File date on the form "Mon Dec 19 2011 12:46:43 GMT+0100 (CET)". * Returns empty string on error. */ static String FileGetDate(const String& path) { MAHandle file = maFileOpen(path.c_str(), MA_ACCESS_READ_WRITE); if (file < 0) { return ""; } int date = maFileDate(file); if (date < 0) { // Error. return ""; } maFileClose(file); // Return time in format "Mon Dec 19 2011 12:46:43 GMT+0100 (CET)". return sprint_time(date); }
/*---------------------------------------------------------------------------*/ static uint16_t print_prefixes(char *msg) { sprint_time(msg, uptime_min); int i; for (i=0; i<UIP_DS6_PREFIX_NB; i++) { uip_ds6_prefix_t *prefix = &uip_ds6_prefix_list[i]; if (prefix->isused) { sprintf(msg+strlen(msg), "Addr: "); sprint_addr6(msg, &prefix->ipaddr); #if UIP_MULTI_IFACES uint8_t if_type = prefix->iface == NULL ? 0 : prefix->iface->ll_type; sprintf(msg+strlen(msg), " Len: %u, IF: %u\n", prefix->length, if_type); #else sprintf(msg+strlen(msg), "\n"); #endif } } return strlen(msg); }
int localTime() { printf("Local time:\n"); printf("%s\n", sprint_time(maLocalTime())); return 0; }
static int fq_pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) { struct rtattr *tb[TCA_FQ_PIE_MAX + 1]; unsigned int target; unsigned int tupdate; unsigned int alpha; unsigned int beta; unsigned ecn; unsigned bytemode; unsigned int plimit, flow_plimit; unsigned int buckets_log; int pacing; unsigned int rate, quantum; SPRINT_BUF(b1); if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_FQ_PIE_MAX, opt); if (tb[TCA_FQ_PIE_TARGET] && RTA_PAYLOAD(tb[TCA_FQ_PIE_TARGET]) >= sizeof(__u32)) { target = rta_getattr_u32(tb[TCA_FQ_PIE_TARGET]); fprintf(f, "target %s ", sprint_time(target, b1)); } if (tb[TCA_FQ_PIE_TUPDATE] && RTA_PAYLOAD(tb[TCA_FQ_PIE_TUPDATE]) >= sizeof(__u32)) { tupdate = rta_getattr_u32(tb[TCA_FQ_PIE_TUPDATE]); fprintf(f, "tupdate %s ", sprint_time(tupdate, b1)); } if (tb[TCA_FQ_PIE_ALPHA] && RTA_PAYLOAD(tb[TCA_FQ_PIE_ALPHA]) >= sizeof(__u32)) { alpha = rta_getattr_u32(tb[TCA_FQ_PIE_ALPHA]); fprintf(f, "alpha %u ", alpha); } if (tb[TCA_FQ_PIE_BETA] && RTA_PAYLOAD(tb[TCA_FQ_PIE_BETA]) >= sizeof(__u32)) { beta = rta_getattr_u32(tb[TCA_FQ_PIE_BETA]); fprintf(f, "beta %u ", beta); } if (tb[TCA_FQ_PIE_ECN] && RTA_PAYLOAD(tb[TCA_FQ_PIE_ECN]) >= sizeof(__u32)) { ecn = rta_getattr_u32(tb[TCA_FQ_PIE_ECN]); if (ecn) fprintf(f, "ecn "); } if (tb[TCA_FQ_PIE_BYTEMODE] && RTA_PAYLOAD(tb[TCA_FQ_PIE_BYTEMODE]) >= sizeof(__u32)) { bytemode = rta_getattr_u32(tb[TCA_FQ_PIE_BYTEMODE]); if (bytemode) fprintf(f, "bytemode "); } if (tb[TCA_FQ_PIE_PLIMIT] && RTA_PAYLOAD(tb[TCA_FQ_PIE_PLIMIT]) >= sizeof(__u32)) { plimit = rta_getattr_u32(tb[TCA_FQ_PIE_PLIMIT]); fprintf(f, "limit %up ", plimit); } if (tb[TCA_FQ_PIE_FLOW_PLIMIT] && RTA_PAYLOAD(tb[TCA_FQ_PIE_FLOW_PLIMIT]) >= sizeof(__u32)) { flow_plimit = rta_getattr_u32(tb[TCA_FQ_PIE_FLOW_PLIMIT]); fprintf(f, "flow_limit %up ", flow_plimit); } if (tb[TCA_FQ_PIE_BUCKETS_LOG] && RTA_PAYLOAD(tb[TCA_FQ_PIE_BUCKETS_LOG]) >= sizeof(__u32)) { buckets_log = rta_getattr_u32(tb[TCA_FQ_PIE_BUCKETS_LOG]); fprintf(f, "buckets %u ", 1U << buckets_log); } if (tb[TCA_FQ_PIE_RATE_ENABLE] && RTA_PAYLOAD(tb[TCA_FQ_PIE_RATE_ENABLE]) >= sizeof(int)) { pacing = rta_getattr_u32(tb[TCA_FQ_PIE_RATE_ENABLE]); if (pacing == 0) fprintf(f, "nopacing "); } if (tb[TCA_FQ_PIE_QUANTUM] && RTA_PAYLOAD(tb[TCA_FQ_PIE_QUANTUM]) >= sizeof(__u32)) { quantum = rta_getattr_u32(tb[TCA_FQ_PIE_QUANTUM]); fprintf(f, "quantum %u ", quantum); } if (tb[TCA_FQ_PIE_INITIAL_QUANTUM] && RTA_PAYLOAD(tb[TCA_FQ_PIE_INITIAL_QUANTUM]) >= sizeof(__u32)) { quantum = rta_getattr_u32(tb[TCA_FQ_PIE_INITIAL_QUANTUM]); fprintf(f, "initial_quantum %u ", quantum); } if (tb[TCA_FQ_PIE_FLOW_MAX_RATE] && RTA_PAYLOAD(tb[TCA_FQ_PIE_FLOW_MAX_RATE]) >= sizeof(__u32)) { rate = rta_getattr_u32(tb[TCA_FQ_PIE_FLOW_MAX_RATE]); if (rate != ~0U) fprintf(f, "maxrate %s ", sprint_rate(rate, b1)); } if (tb[TCA_FQ_PIE_FLOW_DEFAULT_RATE] && RTA_PAYLOAD(tb[TCA_FQ_PIE_FLOW_DEFAULT_RATE]) >= sizeof(__u32)) { rate = rta_getattr_u32(tb[TCA_FQ_PIE_FLOW_DEFAULT_RATE]); if (rate != 0) fprintf(f, "defrate %s ", sprint_rate(rate, b1)); } return 0; }
static int cake_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats) { /* fq_codel stats format borrowed */ struct tc_fq_codel_xstats *st; struct tc_cake_old_xstats *stc; SPRINT_BUF(b1); if (xstats == NULL) return 0; if (RTA_PAYLOAD(xstats) < sizeof(st->type)) return -1; st = RTA_DATA(xstats); stc = RTA_DATA(xstats); if (st->type == TCA_FQ_CODEL_XSTATS_QDISC && RTA_PAYLOAD(xstats) >= sizeof(*st)) { fprintf(f, " maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u", st->qdisc_stats.maxpacket, st->qdisc_stats.drop_overlimit, st->qdisc_stats.new_flow_count, st->qdisc_stats.ecn_mark); fprintf(f, "\n new_flows_len %u old_flows_len %u", st->qdisc_stats.new_flows_len, st->qdisc_stats.old_flows_len); } else if (st->type == TCA_FQ_CODEL_XSTATS_CLASS && RTA_PAYLOAD(xstats) >= sizeof(*st)) { fprintf(f, " deficit %d count %u lastcount %u ldelay %s", st->class_stats.deficit, st->class_stats.count, st->class_stats.lastcount, sprint_time(st->class_stats.ldelay, b1)); if (st->class_stats.dropping) { fprintf(f, " dropping"); if (st->class_stats.drop_next < 0) fprintf(f, " drop_next -%s", sprint_time(-st->class_stats.drop_next, b1)); else fprintf(f, " drop_next %s", sprint_time(st->class_stats.drop_next, b1)); } } else if (stc->type == 0xCAFE && RTA_PAYLOAD(xstats) >= sizeof(*stc)) { int i; fprintf(f, " "); for(i=0; i < stc->class_cnt; i++) fprintf(f, " Class %u ", i); fprintf(f, "\n"); fprintf(f, " rate "); for(i=0; i < stc->class_cnt; i++) fprintf(f, "%10s", sprint_rate(stc->cls[i].rate, b1)); fprintf(f, "\n"); fprintf(f, " target"); for(i=0; i < stc->class_cnt; i++) fprintf(f, "%10s", sprint_time(stc->cls[i].target_us, b1)); fprintf(f, "\n"); fprintf(f, "interval"); for(i=0; i < stc->class_cnt; i++) fprintf(f, "%10s", sprint_time(stc->cls[i].interval_us, b1)); fprintf(f, "\n"); fprintf(f, " pkts "); for(i=0; i < stc->class_cnt; i++) fprintf(f, "%10u", stc->cls[i].packets); fprintf(f, "\n"); fprintf(f, " bytes "); for(i=0; i < stc->class_cnt; i++) fprintf(f, "%10llu", stc->cls[i].bytes); fprintf(f, "\n"); fprintf(f, " drops "); for(i=0; i < stc->class_cnt; i++) fprintf(f, "%10u", stc->cls[i].dropped); fprintf(f, "\n"); fprintf(f, " marks "); for(i=0; i < stc->class_cnt; i++) fprintf(f, "%10u", stc->cls[i].ecn_marked); } else { return -1; } return 0; }
void update_members_list(void) { int data=(int)schedule_data[tswitch]; char line[140]; int number_users,number; char *outfile; int loop; struct user_data user_ptr; FILE *fileptr,*fileptr2; char temptime[60]; switch (data) { case 0 : outfile=user_member_list; aput_into_buffer(server,"--> Updating USER's Member List",0,5,tswitch,9,0); break; case 1 : outfile=sysop_member_list; aput_into_buffer(server,"--> Updating SYSOP's Member List",0,5,tswitch,9,0); break; default : end_task(); break; } lock_dos(74); if (!(fileptr=g_fopen(userfile,"rb","USER#3"))) { log_error("*user file wouldn't open in update member list"); log_error(userfile); unlock_dos(); end_task(); } if (!(fileptr2=g_fopen(outfile,"wb","USER#4"))) { log_error("*could not open user member list"); log_error(user_member_list); g_fclose(fileptr); unlock_dos(); end_task(); } fseek(fileptr,0,SEEK_SET); fseek(fileptr2,0,SEEK_SET); fscanf(fileptr,"%d\n",&number_users); unlock_dos(); for (number=0;number<number_users;number++) { lock_dos(75); fseek(fileptr, (long int)sizeof(struct user_data)*(number+NUMDEFAULT),SEEK_SET); if (!fread(&user_ptr, sizeof(struct user_data), 1, fileptr)) { log_error("* fread() failed on file in member update"); log_error(userfile); g_fclose(fileptr); g_fclose(fileptr2); unlock_dos(); end_task(); } if (user_ptr.number>=0) { int point; if (data) { sprint_time(temptime,&(user_ptr.expiration)); sprintf(line,"#%03d : %c%s|*r1%c",user_ptr.number,user_ptr.staple[2],user_ptr.handle,user_ptr.staple[3]); point=ansi_strlen(line); // for(loop=0;loop<(40-point);loop++) for(loop=0;loop<(35-point);loop++) strcat(line," "); // fprintf(fileptr2,"%s%-20s %s%c%c",line,user_ptr.real_info.name,user_ptr.real_info.phone,13,10); fprintf(fileptr2,"%s%.17s%c%c",line,temptime,13,10); } else fprintf(fileptr2,"#%03d : %c%s|*r1%c%c%c",user_ptr.number,user_ptr.staple[2],user_ptr.handle,user_ptr.staple[3],13,10); } unlock_dos(); next_task(); } lock_dos(76); if (g_fclose(fileptr)) { log_error("g_fclose failed"); log_error(userfile); g_fclose(fileptr2); unlock_dos(); end_task(); } if (g_fclose(fileptr2)) { log_error("*fclose failed"); log_error(user_member_list); unlock_dos(); end_task(); } unlock_dos(); switch (data) { case 0 : aput_into_buffer(server,"--> Update of USER's Member List DONE",0,5,tswitch,9,0); break; case 1 : aput_into_buffer(server,"--> Update of SYSOP's Member List DONE",0,5,tswitch,9,0); break; default : aput_into_buffer(server,"--> (DEFAULT) Member List Update Done",0,5,tswitch,9,0); break; } end_task(); }
/******************************************************************* Program Main ******************************************************************/ main() { int i; // define an integer j to serve as a loop counter //display variables char *strPtr, *scrollStrPtr; int dpos; short scroll; //program variables int lastSwitchVal; long timeStamp,st; char line1[17]; char *rssServer,*rssPage; //display init scroll=1; dprint_init_ports(); dprint_init(); printf("LCD display initialized.\n"); //print a welcome message dprint_clear(); dprint_move_to(0,0); dprint("iDisplay"); dprint_move_to(0,12); dprint("v0.1"); dprint_move_to(1,0); dprint("initializing..."); //network init strPtr=""; if(init_DHCP()) { dprint_info(); strPtr = "success!"; } else { strPtr = "** nework initialization error!"; } //program init timeStamp = SEC_TIMER; //set up the timing for refreshing the data... lastSwitchVal = 1234; //random, so first time it grabs RSS memset(headlines,0,sizeof(headlines)); //just to be safe... //example message scrollStrPtr = strPtr; dpos = 15; while(1){ costate{ //grab the headlines after 5 mins, or on a switch change if((lastSwitchVal != BitRdPortI(PBDR,2)) || (SEC_TIMER > timeStamp+RSS_REFRESH_DELAY) ){ scroll=0; dprint_clear(); dprint_move_to(1,0); dprint("Loading data..."); if (lastSwitchVal){ rssServer=RSS_BBC_SERVER; rssPage=RSS_BBC_PAGE; strcpy(line1,"BBC News"); } else { rssServer=RSS_CNN_SERVER; rssPage=RSS_CNN_PAGE; strcpy(line1,"CNN"); } if(get_headlines(rssServer,rssPage)) strPtr = headlines; else { strPtr = "** unable to connect to Internet!"; strcpy(line1,"Error"); } scrollStrPtr = strPtr; //be friendly and leave strPtr untouched lastSwitchVal = BitRdPortI(PBDR,2); timeStamp = SEC_TIMER; dprint_move_to(0,0); //print the data source dprint(line1); sprint_time(line1); //now print the time dprint_move_to(0,11); dprint(line1); scroll=1; } } costate{ //scroll a message across the screen if(scroll==1){ dprint_move_to(1,0); for(i=0;i<dpos;i++) dprint_char(' '); if(dpos > 0) dpos--; if(dpos == 0) scrollStrPtr++; dprint(scrollStrPtr); if(*scrollStrPtr==0) { //end of str scrollStrPtr = strPtr; dpos = 15; } waitfor(DelayMs(150)); } } costate{ //debugging if (BitRdPortI(PBDR, 3)==0){ while(BitRdPortI(PBDR, 3)==0); //debounce scroll=0; dprint_info(); } } } //while true } // end program
static int fq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) { struct rtattr *tb[TCA_FQ_MAX + 1]; unsigned int plimit, flow_plimit; unsigned int buckets_log; int pacing; unsigned int rate, quantum; unsigned int refill_delay; unsigned int orphan_mask; unsigned int ce_threshold; SPRINT_BUF(b1); if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_FQ_MAX, opt); if (tb[TCA_FQ_PLIMIT] && RTA_PAYLOAD(tb[TCA_FQ_PLIMIT]) >= sizeof(__u32)) { plimit = rta_getattr_u32(tb[TCA_FQ_PLIMIT]); fprintf(f, "limit %up ", plimit); } if (tb[TCA_FQ_FLOW_PLIMIT] && RTA_PAYLOAD(tb[TCA_FQ_FLOW_PLIMIT]) >= sizeof(__u32)) { flow_plimit = rta_getattr_u32(tb[TCA_FQ_FLOW_PLIMIT]); fprintf(f, "flow_limit %up ", flow_plimit); } if (tb[TCA_FQ_BUCKETS_LOG] && RTA_PAYLOAD(tb[TCA_FQ_BUCKETS_LOG]) >= sizeof(__u32)) { buckets_log = rta_getattr_u32(tb[TCA_FQ_BUCKETS_LOG]); fprintf(f, "buckets %u ", 1U << buckets_log); } if (tb[TCA_FQ_ORPHAN_MASK] && RTA_PAYLOAD(tb[TCA_FQ_ORPHAN_MASK]) >= sizeof(__u32)) { orphan_mask = rta_getattr_u32(tb[TCA_FQ_ORPHAN_MASK]); fprintf(f, "orphan_mask %u ", orphan_mask); } if (tb[TCA_FQ_RATE_ENABLE] && RTA_PAYLOAD(tb[TCA_FQ_RATE_ENABLE]) >= sizeof(int)) { pacing = rta_getattr_u32(tb[TCA_FQ_RATE_ENABLE]); if (pacing == 0) fprintf(f, "nopacing "); } if (tb[TCA_FQ_QUANTUM] && RTA_PAYLOAD(tb[TCA_FQ_QUANTUM]) >= sizeof(__u32)) { quantum = rta_getattr_u32(tb[TCA_FQ_QUANTUM]); fprintf(f, "quantum %u ", quantum); } if (tb[TCA_FQ_INITIAL_QUANTUM] && RTA_PAYLOAD(tb[TCA_FQ_INITIAL_QUANTUM]) >= sizeof(__u32)) { quantum = rta_getattr_u32(tb[TCA_FQ_INITIAL_QUANTUM]); fprintf(f, "initial_quantum %u ", quantum); } if (tb[TCA_FQ_FLOW_MAX_RATE] && RTA_PAYLOAD(tb[TCA_FQ_FLOW_MAX_RATE]) >= sizeof(__u32)) { rate = rta_getattr_u32(tb[TCA_FQ_FLOW_MAX_RATE]); if (rate != ~0U) fprintf(f, "maxrate %s ", sprint_rate(rate, b1)); } if (tb[TCA_FQ_FLOW_DEFAULT_RATE] && RTA_PAYLOAD(tb[TCA_FQ_FLOW_DEFAULT_RATE]) >= sizeof(__u32)) { rate = rta_getattr_u32(tb[TCA_FQ_FLOW_DEFAULT_RATE]); if (rate != 0) fprintf(f, "defrate %s ", sprint_rate(rate, b1)); } if (tb[TCA_FQ_LOW_RATE_THRESHOLD] && RTA_PAYLOAD(tb[TCA_FQ_LOW_RATE_THRESHOLD]) >= sizeof(__u32)) { rate = rta_getattr_u32(tb[TCA_FQ_LOW_RATE_THRESHOLD]); if (rate != 0) fprintf(f, "low_rate_threshold %s ", sprint_rate(rate, b1)); } if (tb[TCA_FQ_FLOW_REFILL_DELAY] && RTA_PAYLOAD(tb[TCA_FQ_FLOW_REFILL_DELAY]) >= sizeof(__u32)) { refill_delay = rta_getattr_u32(tb[TCA_FQ_FLOW_REFILL_DELAY]); fprintf(f, "refill_delay %s ", sprint_time(refill_delay, b1)); } if (tb[TCA_FQ_CE_THRESHOLD] && RTA_PAYLOAD(tb[TCA_FQ_CE_THRESHOLD]) >= sizeof(__u32)) { ce_threshold = rta_getattr_u32(tb[TCA_FQ_CE_THRESHOLD]); if (ce_threshold != ~0U) fprintf(f, "ce_threshold %s ", sprint_time(ce_threshold, b1)); } return 0; }
// main program body int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT board_init(); // init dco and leds lcm_init(); // lcd rtc_timer_init(); // init 32kHz timer uart_init(); // init uart (communication) //buttons_init(); // buttons dcf77_init(); // dcf77 receiver #if DCF77_DEBUG lcm_goto(0,0); lcm_prints("DCF"); #endif while(1) { __bis_SR_register(CPUOFF + GIE); // enter sleep mode (leave on rtc second event) tstruct tnow; rtc_get_time(&tnow); char tstr[16]; sprint_time(&tnow,tstr); lcm_goto(1,0); lcm_prints(tstr); str_add_lineend(tstr,16); uart_puts(tstr); uint8_t b=get_button(); if (b) { /*lcm_goto(0,3); tstr[0]='0'+b; tstr[1]='\0'; lcm_prints(tstr);*/ if (b==3) // test rtc set function { tnow.second = 0; tnow.minute = 33; tnow.hour = 22; tnow.dayow = 2; rtc_set_time(&tnow); } } #if DCF77_DEBUG // dcf if (symbol_ready) { int ci=0; lcm_goto(0,3); tstr[ci++]=h2c(tunestatus); tstr[ci++]=' '; tstr[ci++]=h2c(last_symbol); tstr[ci++]=' '; tstr[ci++]=h2c((int)last_Q/100%10); tstr[ci++]=h2c((int)last_Q/10%10); tstr[ci++]=h2c((int)last_Q%10); tstr[ci++]=' '; tstr[ci++]=h2c((int)(finetune>>12)); tstr[ci++]=h2c((int)(finetune>>8)&0x0F); tstr[ci++]=h2c((int)(finetune>>4)&0x0F); tstr[ci++]=h2c((int)(finetune&0x0F)); tstr[ci++]='\0'; lcm_prints(tstr); symbol_ready = false; } #endif } return -1; }
static int fq_codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) { struct rtattr *tb[TCA_FQ_CODEL_MAX + 1]; unsigned int limit; unsigned int flows; unsigned int interval; unsigned int target; unsigned int ecn; unsigned int quantum; unsigned int ce_threshold; unsigned int memory_limit; SPRINT_BUF(b1); if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_FQ_CODEL_MAX, opt); if (tb[TCA_FQ_CODEL_LIMIT] && RTA_PAYLOAD(tb[TCA_FQ_CODEL_LIMIT]) >= sizeof(__u32)) { limit = rta_getattr_u32(tb[TCA_FQ_CODEL_LIMIT]); print_uint(PRINT_ANY, "limit", "limit %up ", limit); } if (tb[TCA_FQ_CODEL_FLOWS] && RTA_PAYLOAD(tb[TCA_FQ_CODEL_FLOWS]) >= sizeof(__u32)) { flows = rta_getattr_u32(tb[TCA_FQ_CODEL_FLOWS]); print_uint(PRINT_ANY, "flows", "flows %u ", flows); } if (tb[TCA_FQ_CODEL_QUANTUM] && RTA_PAYLOAD(tb[TCA_FQ_CODEL_QUANTUM]) >= sizeof(__u32)) { quantum = rta_getattr_u32(tb[TCA_FQ_CODEL_QUANTUM]); print_uint(PRINT_ANY, "quantum", "quantum %u ", quantum); } if (tb[TCA_FQ_CODEL_TARGET] && RTA_PAYLOAD(tb[TCA_FQ_CODEL_TARGET]) >= sizeof(__u32)) { target = rta_getattr_u32(tb[TCA_FQ_CODEL_TARGET]); print_uint(PRINT_JSON, "target", NULL, target); print_string(PRINT_FP, NULL, "target %s ", sprint_time(target, b1)); } if (tb[TCA_FQ_CODEL_CE_THRESHOLD] && RTA_PAYLOAD(tb[TCA_FQ_CODEL_CE_THRESHOLD]) >= sizeof(__u32)) { ce_threshold = rta_getattr_u32(tb[TCA_FQ_CODEL_CE_THRESHOLD]); print_uint(PRINT_JSON, "ce_threshold", NULL, ce_threshold); print_string(PRINT_FP, NULL, "ce_threshold %s ", sprint_time(ce_threshold, b1)); } if (tb[TCA_FQ_CODEL_INTERVAL] && RTA_PAYLOAD(tb[TCA_FQ_CODEL_INTERVAL]) >= sizeof(__u32)) { interval = rta_getattr_u32(tb[TCA_FQ_CODEL_INTERVAL]); print_uint(PRINT_JSON, "interval", NULL, interval); print_string(PRINT_FP, NULL, "interval %s ", sprint_time(interval, b1)); } if (tb[TCA_FQ_CODEL_MEMORY_LIMIT] && RTA_PAYLOAD(tb[TCA_FQ_CODEL_MEMORY_LIMIT]) >= sizeof(__u32)) { memory_limit = rta_getattr_u32(tb[TCA_FQ_CODEL_MEMORY_LIMIT]); print_uint(PRINT_JSON, "memory_limit", NULL, memory_limit); print_string(PRINT_FP, NULL, "memory_limit %s ", sprint_size(memory_limit, b1)); } if (tb[TCA_FQ_CODEL_ECN] && RTA_PAYLOAD(tb[TCA_FQ_CODEL_ECN]) >= sizeof(__u32)) { ecn = rta_getattr_u32(tb[TCA_FQ_CODEL_ECN]); if (ecn) print_bool(PRINT_ANY, "ecn", "ecn ", true); } return 0; }
int utcTime() { printf("UTC time:\n"); printf("%s\n", sprint_time(maTime())); return 0; }
static void lprresp (struct newt *notep) { struct tm *tm = localtime (¬ep->created); int i; if (left < 7) /* We need seven to print a header and some text. */ { if (use_cat) putchar ('\n'); else putchar ('\f'); page++; left = length; } if (notep->director_message) { int hashes = 70 - strlen (notep->director_message); int first = hashes / 2; int i; putchar ('\n'); for (i=0; i < first; i++) putchar ('-'); putchar (' '); printf ("%s", notep->director_message); putchar (' '); for (i=0; i < hashes - first; i++) putchar ('-'); putchar ('\n'); } else printf ("\n------------------------------------------------------------------------\n"); printf (_("Response %d"), notep->nr.respnum); putchar ('\n'); { unsigned authsize = SYSSZ + NAMESZ + 2; char *authbuf = newts_nmalloc (authsize, sizeof (char)); char *timebuf = newts_nmalloc (25, sizeof (char)); if (strcasecmp (notep->auth.name, "anonymous") && strcmp (notep->auth.system, fqdn)) snprintf (authbuf, authsize, "%s@%s", notep->auth.name, notep->auth.system); else if (strcasecmp (notep->auth.name, "anonymous")) snprintf (authbuf, authsize, "%s", notep->auth.name); else snprintf (authbuf, authsize, "anonymous"); printf ("%s", authbuf); sprint_time (timebuf, tm); for (i=0; i < 72 - strlen (authbuf) - strlen (timebuf); i++) putchar (' '); printf ("%s", timebuf); putchar ('\n'); putchar ('\n'); newts_free (authbuf); newts_free (timebuf); } left -= 5; /* Used up by the header. */ { int c; char *cursor = notep->text; while ((c = *cursor++) && c != EOF) { if (c == '\n') left--; putchar (c); } } while (left < length) { page++; left += length; } return; }
static void lprnote (FILE *tocf, struct notesfile *nf, struct newt *notep) { struct tm *tm = localtime (¬ep->created); struct newt resp; int i; if (left < 7) /* We need seven to print a header and some text. */ { if (use_cat) putchar ('\n'); else putchar ('\f'); page++; left = length; } if ((tm->tm_year + 1900 > last_year || (tm->tm_mon + 1) > last_month || tm->tm_mday > last_day) && !(notep->options & NOTE_CORRUPTED)) { char *buffer = newts_nmalloc (9, sizeof (char)); int len; if (tm->tm_year + 1900 != last_year) snprintf (buffer, 8, "%d/%d/%02d", last_month = (tm->tm_mon + 1), last_day = tm->tm_mday, (last_year = tm->tm_year + 1900) % 100); else snprintf (buffer, 8, "%d/%d", last_month = (tm->tm_mon + 1), last_day = tm->tm_mday); fprintf (tocf, "%s", buffer); len = strlen (buffer); for (; len <= 8; len++) putc (' ', tocf); newts_free (buffer); } else fprintf (tocf, " "); fprintf (tocf, "%4d", notep->nr.notenum); if (notep->options & NOTE_DIRECTORS_ONLY) putc ('=', tocf); else if (notep->options & NOTE_ANNOUNCEMENT) putc ('+', tocf); else if (notep->options & NOTE_UNAPPROVED) putc (':', tocf); else if (notep->options & NOTE_DELETED) putc ('-', tocf); else if (notep->director_message) putc ('*', tocf); else putc (' ', tocf); { char *buffer = newts_nmalloc (TITLEN + 1, sizeof (char)); int len; snprintf (buffer, TITLEN, "%s", notep->title); fprintf (tocf, "%s", buffer); len = strlen (buffer); for (; len <= TITLEN; len++) putc (' ', tocf); newts_free (buffer); } if (notep->total_resps > 0) fprintf (tocf, "%5d ", notep->total_resps); else fprintf (tocf, " "); if (strcasecmp (notep->auth.name, "anonymous") && strcmp (notep->auth.system, fqdn)) fprintf (tocf, "%s@%s", notep->auth.name, notep->auth.system); else if (strcasecmp (notep->auth.name, "anonymous")) fprintf (tocf, "%s", notep->auth.name); else fprintf (tocf, "anonymous"); putc ('\n', tocf); if (index_only) /* If we only want a table of contents, we're done. */ return; { int hashes = 70 - strlen (notep->title); int first = hashes / 2; int i; putchar ('\n'); for (i=0; i < first; i++) putchar ('='); putchar (' '); printf ("%s", notep->title); putchar (' '); for (i=0; i < hashes - first; i++) putchar ('='); putchar ('\n'); } if (notep->director_message) { int hashes = 70 - strlen (notep->director_message); int first = hashes / 2; int i; for (i=0; i < first; i++) putchar ('-'); putchar (' '); printf ("%s", notep->director_message); putchar (' '); for (i=0; i < hashes - first; i++) putchar ('-'); putchar ('\n'); } { int i; char *titlebuf, *respbuf; titlebuf = newts_nmalloc (80, sizeof (char)); respbuf = newts_nmalloc (40, sizeof (char)); sprintf (titlebuf, _("Note %d"), notep->nr.notenum); printf ("%s", titlebuf); if (notep->total_resps) { sprintf (respbuf, ngettext ("%d response", "%d responses", notep->total_resps), notep->total_resps); for (i=0; i < 72 - strlen (titlebuf) - strlen (respbuf); i++) putchar (' '); printf ("%s", respbuf); } putchar ('\n'); newts_free (titlebuf); newts_free (respbuf); } { unsigned authsize = SYSSZ + NAMESZ + 2; char *authbuf = newts_nmalloc (authsize, sizeof (char)); char *timebuf = newts_nmalloc (25, sizeof (char)); if (strcasecmp (notep->auth.name, "anonymous") && strcmp (notep->auth.system, fqdn)) snprintf (authbuf, authsize, "%s@%s", notep->auth.name, notep->auth.system); else if (strcasecmp (notep->auth.name, "anonymous")) snprintf (authbuf, authsize, "%s", notep->auth.name); else snprintf (authbuf, authsize, "anonymous"); printf ("%s", authbuf); sprint_time (timebuf, tm); for (i=0; i < 72 - strlen (authbuf) - strlen (timebuf); i++) putchar (' '); printf ("%s", timebuf); putchar ('\n'); putchar ('\n'); newts_free (authbuf); newts_free (timebuf); } left -= 5; /* Used up by the header. */ { int c; char *cursor = notep->text; while ((c = *cursor++) && c != EOF) { if (c == '\n') left--; putchar (c); } } while (left < length) { page++; left += length; } memset (&resp, 0, sizeof (struct newt)); nfref_copy (&resp.nr.nfr, ¬ep->nr.nfr); resp.nr.notenum = notep->nr.notenum; for (i=1; i <= notep->total_resps; i++) { resp.nr.respnum = i; get_note (&resp, FALSE); lprresp (&resp); } return; }
static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats) { struct tc_fq_codel_xstats _st = {}, *st; SPRINT_BUF(b1); if (xstats == NULL) return 0; st = RTA_DATA(xstats); if (RTA_PAYLOAD(xstats) < sizeof(*st)) { memcpy(&_st, st, RTA_PAYLOAD(xstats)); st = &_st; } if (st->type == TCA_FQ_CODEL_XSTATS_QDISC) { print_uint(PRINT_ANY, "maxpacket", " maxpacket %u", st->qdisc_stats.maxpacket); print_uint(PRINT_ANY, "drop_overlimit", " drop_overlimit %u", st->qdisc_stats.drop_overlimit); print_uint(PRINT_ANY, "new_flow_count", " new_flow_count %u", st->qdisc_stats.new_flow_count); print_uint(PRINT_ANY, "ecn_mark", " ecn_mark %u", st->qdisc_stats.ecn_mark); if (st->qdisc_stats.ce_mark) print_uint(PRINT_ANY, "ce_mark", " ce_mark %u", st->qdisc_stats.ce_mark); if (st->qdisc_stats.memory_usage) print_uint(PRINT_ANY, "memory_used", " memory_used %u", st->qdisc_stats.memory_usage); if (st->qdisc_stats.drop_overmemory) print_uint(PRINT_ANY, "drop_overmemory", " drop_overmemory %u", st->qdisc_stats.drop_overmemory); print_uint(PRINT_ANY, "new_flows_len", "\n new_flows_len %u", st->qdisc_stats.new_flows_len); print_uint(PRINT_ANY, "old_flows_len", " old_flows_len %u", st->qdisc_stats.old_flows_len); } if (st->type == TCA_FQ_CODEL_XSTATS_CLASS) { print_uint(PRINT_ANY, "deficit", " deficit %u", st->class_stats.deficit); print_uint(PRINT_ANY, "count", " count %u", st->class_stats.count); print_uint(PRINT_ANY, "lastcount", " lastcount %u", st->class_stats.lastcount); print_uint(PRINT_JSON, "ldelay", NULL, st->class_stats.ldelay); print_string(PRINT_FP, NULL, " ldelay %s", sprint_time(st->class_stats.ldelay, b1)); if (st->class_stats.dropping) { print_bool(PRINT_ANY, "dropping", " dropping", true); if (st->class_stats.drop_next < 0) print_string(PRINT_FP, NULL, " drop_next -%s", sprint_time(-st->class_stats.drop_next, b1)); else { print_uint(PRINT_JSON, "drop_next", NULL, st->class_stats.drop_next); print_string(PRINT_FP, NULL, " drop_next %s", sprint_time(st->class_stats.drop_next, b1)); } } } return 0; }