static int show_widget (CmdConfig *cmd_config, CameraWidget *widget) { CameraWidget *parent; CameraWidgetType type; CHECK (gp_widget_get_type (widget, &type)); switch (type) { case GP_WIDGET_WINDOW: case GP_WIDGET_SECTION: CHECK (show_section (cmd_config, widget)); break; case GP_WIDGET_DATE: CHECK (show_date (cmd_config, widget)); CHECK (show_time (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; case GP_WIDGET_MENU: case GP_WIDGET_RADIO: CHECK (show_radio (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; case GP_WIDGET_RANGE: CHECK (show_range (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; case GP_WIDGET_TEXT: CHECK (show_text (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; case GP_WIDGET_TOGGLE: CHECK (show_toggle (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; default: return (GP_ERROR_NOT_SUPPORTED); } return (GP_OK); }
void * commit_updt (void * tid) { while (1) { if (pfsd->update == 2) { pfsd_updt_log (pfsd); pfsd_write_back_log (pfsd); //pfsd_print_log (pfsd); show_time (); if (pfsd->update == 2) pfsd->update = 0; } if (pfsd->update == 1) { pfsd->update = 2; } sleep (COMMIT_UPDT_SLEEP); } }
void handle_init(void) { window = window_create(); window_stack_push(window, true); w_layer = window_get_root_layer(window); background = bitmap_layer_create(layer_get_frame(w_layer)); background_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); bitmap_layer_set_bitmap(background, background_bmp); layer_add_child(w_layer, bitmap_layer_get_layer(background)); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); accel_tap_service_subscribe(handle_tap); time_t now = time(NULL); struct tm* t = localtime(&now); show_time(t); }
/* show_info() * displays contents of the utmp struct inhuman readable form * *note* these sizes shoul not be hardwired */ void show_info(struct utmpx *utbufp) { void show_time(); // if (utbufp->ut_type != USER_PROCESS) // return; printf("%-8.8s", utbufp->ut_user); /* the logname*/ printf(" "); printf("%-8.8s", utbufp->ut_line); /* the tty */ printf(" "); show_time(); # ifdef SHOWHOST if (utbufp->ut_host[0] != '\0') printf("(%s)", utbufp->ut_host); /* the host */ # endif printf("\n"); }
int main() { struct timeval tv, tv1, res; time_t now; struct tm *now_s; char tbuf[100]; char buf[100]; if (gettimeofday(&tv, NULL) != 0) { perror("failed executing gettimeofday()"); return -1; } sleep(1); if (gettimeofday(&tv1, NULL) != 0) { perror("failed executing gettimeofday()"); return -1; } timersub(&tv1, &tv, &res); printf("time sub, sec: %lx, usec: %lx\n", res.tv_sec, res.tv_usec); printf("long sz: %lu\n", sizeof(long)); printf("tv sz: %lu, sec sz: %lu, usec sz: %lu\n", sizeof(tv), sizeof(tv.tv_sec), sizeof(tv.tv_usec)); printf("sec: %x, usec: %x\n", htonl((uint32_t) tv.tv_sec), htonl((uint32_t) tv.tv_usec)); now = tv.tv_sec; now_s = localtime(&now); strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", now_s); snprintf(buf, sizeof(buf), "%s.%06ld", tbuf, tv.tv_usec); printf("hex: %lx, %lx\n", tv.tv_sec, tv.tv_usec); printf("time: %s\n", buf); show_time(&tv); return 0; }
void show_info( struct utmp *utbufp ) { if( utbufp->ut_type != USER_PROCESS ) { return; } printf( "%-8.8s", utbufp->ut_name ); printf( " " ); printf( "%-8.8s", utbufp->ut_line ); printf( " " ); show_time( utbufp->ut_time ); printf( " " ); #ifdef SHOWHOST if( utbufp->ut_host[0] != '\0' ) { printf( "( %s )", utbufp->ut_host ); } #endif printf( "\n" ); }
/** Processing related to players' last connections. * Here we check to see if a player gets a paycheck, tell them their * last connection site, and update all their LAST* attributes. * \param player dbref of player. * \param host hostname of player's current connection. * \param ip ip address of player's current connection. */ void check_last(dbref player, const char *host, const char *ip) { char *s; ATTR *a; ATTR *h; char last_time[MAX_COMMAND_LEN / 8]; char last_place[MAX_COMMAND_LEN]; /* compare to last connect see if player gets salary */ s = show_time(mudtime, 0); a = atr_get_noparent(player, "LAST"); if (a && (strncmp(atr_value(a), s, 10) != 0)) giveto(player, Paycheck(player)); /* tell the player where he last connected from */ if (!Guest(player)) { h = atr_get_noparent(player, "LASTSITE"); if (h && a) { strcpy(last_place, atr_value(h)); strcpy(last_time, atr_value(a)); notify_format(player, T("Last connect was from %s on %s."), last_place, last_time); } /* How about last failed connection */ h = atr_get_noparent(player, "LASTFAILED"); if (h && a) { strcpy(last_place, atr_value(h)); if (strlen(last_place) > 2) notify_format(player, T("Last FAILED connect was from %s."), last_place); } } /* if there is no Lastsite, then the player is newly created. * the extra variables are a kludge to work around some weird * behavior involving uncompress. */ /* set the new attributes */ (void) atr_add(player, "LAST", s, GOD, 0); (void) atr_add(player, "LASTSITE", host, GOD, 0); (void) atr_add(player, "LASTIP", ip, GOD, 0); (void) atr_add(player, "LASTFAILED", " ", GOD, 0); }
void read_rtc(bool show_extra_info) { static uint16_t counter = 0; if(g_show_temp && rtc_is_ds3231() && counter > 125) { int8_t t; uint8_t f; ds3231_get_temp_int(&t, &f); show_temp(t, f); } else { t = rtc_get_time(); if (t == NULL) return; show_time(t, g_24h_clock, show_extra_info); } counter++; if (counter == 250) counter = 0; }
/** The version command. * \param player the enactor. */ void do_version(dbref player) { #ifdef SVNREVISION int svnrev = 0; int scan; #ifdef SVNDATE char svndate[75]; #endif /* SVNDATE */ #endif /* SVNREVISION */ notify_format(player, T("You are connected to %s"), MUDNAME); if (MUDURL && *MUDURL) notify_format(player, T("Address: %s"), MUDURL); notify_format(player, T("Last restarted: %s"), show_time(globals.start_time, 0)); notify_format(player, T("PennMUSH version %s patchlevel %s %s"), VERSION, PATCHLEVEL, PATCHDATE); #ifdef SVNREVISION scan = sscanf(SVNREVISION, "$" "Rev: %d $", &svnrev); if (scan == 1) { #ifdef SVNDATE scan = sscanf(SVNDATE, "$" "Date: %s $", svndate); if (scan == 1) notify_format(player, T("SVN revision: %d [%s]"), svnrev, svndate); else notify_format(player, T("SVN revision: %d"), svnrev); #else notify_format(player, T("SVN revision: %d"), svnrev); #endif /* SVNDATE */ } #endif /* SVNREVISION */ #ifdef WIN32 notify_format(player, T("Build date: %s"), __DATE__); #else notify_format(player, T("Build date: %s"), BUILDDATE); notify_format(player, T("Compiler: %s"), COMPILER); notify_format(player, T("Compilation flags: %s"), CCFLAGS); #endif }
static QState uiRun(struct UI *me) { switch (Q_SIG(me)) { case Q_ENTRY_SIG: lcd_buttons(LCD_BUTTONS_ENTER_UP_DOWN); show_temperature(me->ti); show_time(gettimep()); return Q_HANDLED(); case BUTTON_ENTER_PRESS_SIGNAL: return Q_TRAN(uiMenuMaybeSettime); case BUTTON_UP_PRESS_SIGNAL: return Q_TRAN(uiShowMax); case BUTTON_DOWN_PRESS_SIGNAL: return Q_TRAN(uiShowMin); case CURRENT_TEMPERATURE_SIGNAL: me->ti = (int16_t) Q_PAR(me); show_temperature(me->ti); } return Q_SUPER(uiTop); }
int lclif_parse_pre(int *fdPtr) { const int fd = *fdPtr; int packet_len = (int)RFIFOREST(fd); if (packet_len < 2) return 0; char buf[100]; sprintf(buf, "log/login_%d.log", fd); FILE *file = fopen(buf, "a"); if (file == NULL) { ShowError("Cant open log file %s\n", buf); return 1; } show_time(file); dump_client_packet(file, fd, packet_len); fclose(file); return 0; }
static void skip(ClickRecognizerRef recognizer, void *context) { vibes_short_pulse(); if (timer) { app_timer_cancel(timer); } current_exercise++; if (current_exercise >= exercises) { current_exercise = 0; lap++; } seconds = default_work; working = 0; resting = 0; paused = 0; set_colors(rest); text_layer_set_text(exercise_layer, empty); update_next_text(current_exercise); show_time(); update_lap_text(); APP_LOG(APP_LOG_LEVEL_DEBUG, "Skip to lap %d, exercise %d/%d", lap, current_exercise, exercises); }
//------------------------------------------------------------------------ int notmain ( void ) { unsigned int ra; unsigned int rf; uart_init(); hexstring(0x12345678); for(ra=0;ra<10;ra++) { hexstring(ra); } spi_init(); PUT32(GPSET0,1<<7); //reset high for(ra=0;ra<0x10000;ra++) dummy(ra); PUT32(GPCLR0,1<<7); //reset low for(ra=0;ra<0x10000;ra++) dummy(ra); PUT32(GPSET0,1<<7); //reset high spi_command(0x21); //extended commands // spi_command(0xB0); //vop less contrast spi_command(0xBF); //vop more contrast spi_command(0x04); //temp coef spi_command(0x14); //bias mode 1:48 spi_command(0x20); //extended off spi_command(0x0C); //display on spi_command(0x80); //column spi_command(0x40|5); //row for(rf=0;rf<84;rf++) spi_data(0x00); tim[0]=0; tim[1]=0; tim[2]=0; tim[3]=0; show_time(); do_nmea(); hexstring(0x12345678); return(0); }
static void timer_callback(void *data) { // APP_LOG(APP_LOG_LEVEL_DEBUG, "Timer: %02d", seconds); seconds--; if (seconds <= 0) { if (working) { set_colors(rest); working = 0; resting = 1; seconds = default_rest; text_layer_set_text(exercise_layer, "Rest"); int next_exercise = current_exercise + 1; if (next_exercise >= exercises) { next_exercise = 0; } update_next_text(next_exercise); APP_LOG(APP_LOG_LEVEL_DEBUG, "Changed mode to Rest, next %s", exercise[next_exercise]); } else { set_colors(work); working = 1; resting = 0; seconds = default_work; current_exercise++; if (current_exercise >= exercises) { lap++; current_exercise = 0; } update_lap_text(); text_layer_set_text(exercise_layer, exercise[current_exercise]); text_layer_set_text(next_layer, empty); APP_LOG(APP_LOG_LEVEL_DEBUG, "Started %s", exercise[current_exercise]); } } timer = app_timer_register(timer_interval_ms, timer_callback, NULL); show_time(); }
int cli_time(int argc, char* argv[]) { if (attempt_parameter("--time", "-t", argv[1], 7, argc)) { if ((attempt_parameter("--time", "-t", argv[1], 7, argc)) == -1) { puts("Not enough arguments! Type --help (-h) for usage."); return 1; } double velocity[NUMBER_OF_PIECES]; double time[NUMBER_OF_PIECES]; int i; for(i = 0; i < 3; i++) { time[i] = atoi(argv[2+2*i]); // 2, 4, 6 args velocity[i] = atoi(argv[3+2*i]); // 3, 5, 7 args } double total_time = calculating_time(velocity, time); show_time(total_time); return 1; } return 0; }
void ASControl::test_func() { char inBuffer[4096]; // Incoming message buffer SeMessage inMsg; inMsg.SetDataMsg((void*)inBuffer, sizeof(inBuffer)); ServiceAddress sourceAddr; S_TEST_MSG* baseMsg = (S_TEST_MSG*)inBuffer; printf("ptest_thread start to recv\n"); for(;;) { int err = inMsg.Receive(sourceAddr); if(err != SE_AOK) { printf("ptest_thread message is error\n"); sleep(10); continue; } switch(baseMsg->msgId) { case ignore_dnar: ignore_func(baseMsg); break; case show_start_time: show_time(); break; default: printf("error msgId! msgId=%d\n", baseMsg->msgId); break; } } }
int main(int argn ,char *argv[]) { char in[100]; while(1) { int n = strlen(para[0]); printf("%s->", para[0]); memset(in, 0, sizeof(in)); gets(in); int choice = explain(in); //根据命令解释器的返回结果执行相对应的命令 switch(choice) { case -1: printf("' %s '不是内部或外部命令,也不是可运行的程序\n或批处理文件。\n", in);break; case 0 : show_time();break; case 1 : show_version();break; case 2 : show_date();break; case 3 : clrscr(0, 0);break; case 4 : show_directory();break; case 5 : help();break; case 6 : show_current_tree(para[0], 0);break; case 7 : return 0; case 8 : print_text(para[0]);break; case 9 : if(del_dir(para[0]) == 0) del_files(para[0]);break;//如果para[0]是文件夹,则执行删除文件夹函数,否则执行文件删除函数 case 10 : creat_dir(para[0]);break; case 11 : rename_file(para[0], para[1]);break; case 12 : change_path(in);break; }//{"time", "version", "date", "cls", "dir", "help", "tree", "print", "del", "mkdir", "ren"}; if(choice != 12)//如果没有改变路径,则每次都把当前工作目录下的以外的其它字符清除 { memset(para[0] + n, 0, (100 - n) * sizeof(char)); memset(para[1] + n, 0, (100 - n) * sizeof(char)); } } return 0; }
int main() { struct PerfCase { void (*func) (); const char *desc; }; std::vector<PerfCase> cases = { { &use_printf, "Time using printf" }, { &use_puts, "Time using puts" }, { &use_cout, "Time using cout (synced)"}, { &use_cout_unsync, "Time using cout (un-synced)"}, //{ &use_stringstream, "Time using stringstream"}, { &use_endl, "Time using endl"}, //{ &use_fill_n, "Time using fill_n"}, { &use_prettyprint, "Time using pretty print statement"}, { &use_putc, "Time using putc"}, { &use_fputs_unlocked, "Time using fputs_unlocked"}, { &use_fputs, "Time using fputs"}, { &use_fwrite_unlocked, "Time using fwrite_unlocked"}, { &use_memcpy, "Time using memcpy"} }; srand(time(0)); //random_shuffle( cases.begin(), cases.end() ); // show_time(use_memcpy, "x"); // return 0; for ( auto const& thing : cases ) { show_time(thing.func, thing.desc); } return 0; }
static void skip_back(ClickRecognizerRef recognizer, void *context) { vibes_short_pulse(); if (timer) { app_timer_cancel(timer); timer = NULL; } if ((seconds == default_work) && ((lap > 1) || (current_exercise > 1))) { current_exercise--; if (current_exercise < 0) { current_exercise = exercises - 1; lap--; } } seconds = default_work; working = 0; resting = 0; paused = 0; set_colors(rest); text_layer_set_text(exercise_layer, empty); update_next_text(current_exercise); show_time(); update_lap_text(); APP_LOG(APP_LOG_LEVEL_DEBUG, "Skip back to lap %d, exercise %d/%d", lap, current_exercise, exercises); }
static int chessclock_set_int(char* string, int* variable, int step, int min, int max, int flags) { bool done = false; int button; rb->lcd_clear_display(); rb->lcd_puts_scroll(0, FIRST_LINE, (unsigned char *)string); while (!done) { char str[32]; if (flags & FLAGS_SET_INT_SECONDS) rb->snprintf(str, sizeof str,"%s (m:s)", show_time(*variable)); else rb->snprintf(str, sizeof str,"%d", *variable); rb->lcd_puts(0, FIRST_LINE+1, (unsigned char *)str); rb->lcd_update(); button = rb->button_get(true); switch(button) { case CHC_SETTINGS_INC: case CHC_SETTINGS_INC | BUTTON_REPEAT: *variable += step; break; case CHC_SETTINGS_DEC: case CHC_SETTINGS_DEC | BUTTON_REPEAT: *variable -= step; break; case CHC_SETTINGS_OK: #ifdef CHC_SETTINGS_OK2 case CHC_SETTINGS_OK2: #endif done = true; break; case CHC_SETTINGS_CANCEL: #ifdef CHC_SETTINGS_CANCEL2 case CHC_SETTINGS_CANCEL2: #endif return CHCL_CANCEL; break; default: if (rb->default_event_handler(button) == SYS_USB_CONNECTED) return CHCL_USB; break; } if(*variable > max ) *variable = max; if(*variable < min ) *variable = min; } rb->lcd_scroll_stop(); return CHCL_OK; }
void show_stat_info_oneline(char *fname, struct stat *buf) { static char mode[255]; mode_to_letters(buf->st_mode, mode); printf("%s %d %s %s %s\t%s %s\n", mode, buf->st_nlink, uid_to_name(buf->st_uid), gid_to_name(buf->st_gid), bytes_to_human(buf->st_size), show_time((int) buf->st_mtime), fname); }
/* ---------------------------------------------------------------------- * read one set of motion parameters (extras?) and store in structure * * return 1 : finished * 0 : have data: continue * -1 : error * ---------------------------------------------------------------------- */ int read_socket(optiondata * opt, port_list * plist, motparm * mp) { static char * outstring = NULL; static int oslen = 0; int rv, len; if ( (rv = test_socket(plist->tdata_sd)) < 0 ) return -1; else if ( rv == 1 ) { if ( opt->debug > 0 ) fprintf(stderr,"++ found close request, mpcount = %d\n", mp->nread); return 1; } /* get motion params */ len = mp->nvals * sizeof(float); if ( (rv = recv(plist->tdata_sd, (void *)mp->data, len, 0)) < len ) { fprintf(stderr,"** read only %d of %d bytes on socket\n", rv, len); perror("recv mot parm"); return -1; } if ( opt->show_times && opt->debug > 2 ) show_time("received mp data"); if ( opt->swap ) swap_4(mp->data, mp->nvals); /* get extra floats */ if( mp->nex > 0 ) { len = mp->nex * sizeof(float); if ( (rv = recv(plist->tdata_sd, (void *)mp->extras, len, 0)) < len ) { fprintf(stderr,"** read only %d of %d Ebytes on socket\n", rv, len); perror("recv extra floats"); return -1; } if ( opt->swap ) swap_4(mp->extras, mp->nex); } mp->nread++; if ( opt->show_times ) { char mesg[32]; sprintf(mesg, "received mp data #%03d", mp->nread); show_time(mesg); } if ( opt->debug > 2 || opt->disp_all ) { rv = format_output(opt, mp, &outstring, &oslen); if( rv ) { fprintf(stderr,"** failed to format output string\n"); if( outstring ) { free(outstring); outstring = NULL; } return 1; } /* will probably want to send elsewhere, later */ fputs(outstring,stderr); fflush(stderr); /* may get buffered */ } return 0; }
static int run_timer(int nr) { char buf[40]; char player_info[13]; long last_tick; bool done=false; int retval=CHCL_OK; long max_ticks=timer_holder[nr].total_time*HZ-timer_holder[nr].used_time; long ticks=0; bool round_time=false; show_pause_mode(chesspause); if (settings.round_time*HZ<max_ticks) { max_ticks=settings.round_time*HZ; round_time=true; } rb->snprintf(player_info, sizeof(player_info), "Player %d", nr+1); rb->lcd_puts(0, FIRST_LINE, (unsigned char *)player_info); last_tick=*rb->current_tick; while (!done) { int button; long now; if (ticks>=max_ticks) { if (round_time) rb->lcd_puts(0, FIRST_LINE+1, (unsigned char *)"ROUND UP!"); else rb->lcd_puts(0, FIRST_LINE+1, (unsigned char *)"TIME OUT!"); rb->backlight_on(); ticks = max_ticks; } else { now=*rb->current_tick; if (!chesspause) { ticks+=now-last_tick; if ((max_ticks-ticks)/HZ == 10) { /* Backlight on if 10 seconds remain */ rb->backlight_on(); } } last_tick=now; if (round_time) { rb->snprintf(buf, sizeof(buf), "%s/", show_time((max_ticks-ticks+HZ-1)/HZ)); /* Append total time */ rb->strcpy(&buf[rb->strlen(buf)], show_time((timer_holder[nr].total_time*HZ- timer_holder[nr].used_time- ticks+HZ-1)/HZ)); rb->lcd_puts(0, FIRST_LINE+1, (unsigned char *)buf); } else { rb->lcd_puts(0, FIRST_LINE+1, (unsigned char *)show_time((max_ticks-ticks+HZ-1)/HZ)); } } rb->lcd_update(); button = rb->button_get(false); switch (button) { /* OFF/ON key to exit */ case CHC_QUIT: return CHCL_CANCEL; /* Indicate exit */ /* PLAY = Stop/Start toggle */ case CHC_STARTSTOP: chesspause=!chesspause; show_pause_mode(chesspause); break; /* LEFT = Reset timer */ case CHC_RESET: ticks=0; break; /* MENU */ case CHC_MENU: { MENUITEM_STRINGLIST(menu, "Menu", NULL, "Delete player", "Restart round", "Set round time", "Set total time", "Playback Control"); int val, res; switch(rb->do_menu(&menu, NULL, NULL, false)) { case 0: /* delete player */ timer_holder[nr].hidden=true; retval = CHCL_NEXT; done=true; break; case 1: /* restart */ ticks=0; last_tick=*rb->current_tick; break; case 2: /* set round time */ val=(max_ticks-ticks)/HZ; res=chessclock_set_int("Round time", &val, 10, 0, MAX_TIME, FLAGS_SET_INT_SECONDS); if (res==CHCL_USB) { retval = CHCL_USB; done=true; } else if (res==CHCL_OK) { ticks=max_ticks-val*HZ; last_tick=*rb->current_tick; } break; case 3: /* set total time */ val=timer_holder[nr].total_time; res=chessclock_set_int("Total time", &val, 10, 0, MAX_TIME, FLAGS_SET_INT_SECONDS); if (res==CHCL_USB) { retval = CHCL_USB; done=true; } else if (res==CHCL_OK) { timer_holder[nr].total_time=val; } break; case 4: playback_control(NULL); break; case MENU_ATTACHED_USB: retval = CHCL_USB; done=true; break; } rb->lcd_clear_display(); show_pause_mode(chesspause); rb->lcd_puts(0, FIRST_LINE, (unsigned char *)player_info); } break; /* UP (RIGHT/+) = Scroll Lap timer up */ case CHC_SETTINGS_INC: retval = CHCL_NEXT; done = true; break; /* DOWN (LEFT/-) = Scroll Lap timer down */ case CHC_SETTINGS_DEC: retval = CHCL_PREV; done = true; break; default: if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { retval = CHCL_USB; done = true; } break; } rb->sleep(HZ/4); /* Sleep 1/4 of a second */ } timer_holder[nr].used_time+=ticks; return retval; }
static void update_clock() { show_time(); alarm(1); }
/** * @brief Timer Thread - used to aid time specific tasks. * * Continuously updates the time information on the 7 Seg display * and checks for the closest Wifi beacon (every 10 seconds). * * @param Void. * @return Void. */ void * timer(void){ struct timespec timeToWait; struct timeval now; int err, init = FALSE; int paused_blink = FALSE; //extern char closest_mac[]; gettimeofday(&now,NULL); timeToWait.tv_sec = now.tv_sec+1; timeToWait.tv_nsec = 0; while(alive && logged_in) { long long int time = 0, prev_time = 0; pthread_mutex_lock(&timer_Mutex); err = pthread_cond_timedwait(&timer_Signal, &timer_Mutex, &timeToWait); /* if (err == ETIMEDOUT) { printd("timer timed out\n"); } else { printd("timer called\n"); } */ pthread_mutex_unlock(&timer_Mutex); gettimeofday(&now,NULL); if (time = getTimeGst()) //nanoseconds into current stream { if (init == FALSE) { long long int nano_offset = (1000000000UL - time); timeToWait.tv_sec = now.tv_sec + (nano_offset / 1000000000UL); timeToWait.tv_nsec = nano_offset % 1000000000UL; init = TRUE; } else { timeToWait.tv_sec = now.tv_sec + TIMEOUT; timeToWait.tv_nsec = 0; } count = time / (1000000000UL); show_time(); paused_blink = FALSE; if (time == prev_time) { killGst(); init = FALSE; clear_time(); } } else { if (!paused && init == TRUE) { killGst(); init = FALSE; clear_time(); } timeToWait.tv_sec = now.tv_sec;//+1; timeToWait.tv_nsec = 500000000UL;//0; //display_time(" "); paused_blink = TRUE; init = FALSE; } /* if (strlen(closest_mac) != 0) { printd("timer seeing mac: %s\n",closest_mac); } */ } pthread_exit(0); }
static void handle_clock_tick(struct tm *tick_time, TimeUnits units_changed) { show_time(tick_time); do_buzz(tick_time); }
void Sub3::show_contents(HumanReadable & hr) const { hr << "Signature Expiration Time (Days): " + (dt?show_time(dt):"Never"); }
void handle_minute_tick(struct tm* t, TimeUnits delta_t) { show_time(t); }
//------------------------------------------------------------------- void notmain ( void ) { unsigned short ra; unsigned short rb; unsigned short rc; unsigned short state,off,ncom; WDTCTL = 0x5A80; // use calibrated clock DCOCTL = 0x00; BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; uart_init(); //P1.0 LCD Power Control //P1.3 LCD Enable //P1.4 SPI CS //P1.5 SPI CLK //P1.6 led2 //p1.7 SPI MOSI //76543210 //11111001 //0x00xxxx //x1xx1xx1 P1DIR|=0xF9; P1OUT&=~(0xB0); P1OUT|=0x49; TACTL = 0x02E0; P1OUT^=0x40; clear_screen(); lasttime=0; //toggle_seconds=0; valid=0; state=0; off=0; ncom=0; //$GPRMC,001412.799,V,,,,,0.00,0.00,060180,,,N*43 //$GPRMC,054033.00,V, while(1) { ra=uart_getc(); //uart_putc(ra); switch(state) { case 0: { if(ra==0x0A) state++; break; } case 1: { if(ra=='$') state++; else state=0; break; } case 2: { if(ra=='G') state++; else state=0; break; } case 3: { if(ra=='P') state++; else state=0; break; } case 4: { if(ra=='R') state++; else state=0; break; } case 5: { if(ra=='M') state++; else state=0; break; } case 6: { if(ra=='C') state++; else state=0; break; } case 7: { off=0; ncom=0; if(ra==',') state++; else state=0; break; } case 8: { if((ncom)&&(ra==',')) { valid=0; for(rb=0;rb<off;rb++) { if(xstring[rb]==',') { if(xstring[rb+1]=='A') valid=1; break; } } //012345678901 //002329.799,V if(off>7) { #ifdef DEBUG_UART for(rb=0;rb<off;rb++) { uart_putc(xstring[rb]); } uart_putc(0x20); uart_putc(0x30+valid); uart_putc(0x20); #endif //if((valid)&&(locked)) if(1) { //002329.799,V //need to manipulate the hours to adjust for //time zone rb=xstring[0]&0xF; rc=xstring[1]&0xF; //first digit times 10 plus second is hours gmt //1010 rb=/*rb*10*/(rb<<3)+(rb<<1); //times 10 rb+=rc; //adjust for 24 hour clock if(rb>12) rb-=12; //====================================== ra=5; //time zone adjustment if(rb<=ra) rb+=12; rb-=ra; //====================================== //divide by 10 first digit is either 1 or not if(rb>9) { xstring[0]='1'; rb-=10; } else { xstring[0]='0'; } rb&=0xF; xstring[1]=0x30+rb; xstring[4]=0; } else { xstring[0]=0x31; xstring[1]=0x39; xstring[2]=0x37; xstring[3]=0x30|(valid); xstring[4]=0; } } else { xstring[0]=0x31; xstring[1]=0x39; xstring[2]=0x39; xstring[3]=0x39; xstring[4]=0; } #ifdef DEBUG_UART for(ra=0;ra<4;ra++) { uart_putc(xstring[ra]); } uart_putc(0x0D); uart_putc(0x0A); #endif show_time(); off=0; state++; } else { if(ra==',') ncom++; if(off<16) { xstring[off++]=ra; } } break; } case 9: { state=0; //if(zstring[off]==0) //{ //state=0; //} //else //{ //uart_putc(zstring[off++]); //} break; } } } }
static void read_scoreboard(void) { /* NOTE: this buffer should probably be limited to the maximum window * width, as it is used for display purposes. */ static char buf[PR_TUNABLE_BUFFER_SIZE] = {'\0'}; pr_scoreboard_entry_t *score = NULL; if ((ftp_sessions = calloc(chunklen, sizeof(char *))) == NULL) exit(1); if (scoreboard_open() < 0) return; /* Iterate through the scoreboard. */ while ((score = util_scoreboard_read_entry()) != NULL) { /* Default status: "A" for "authenticating" */ char *status = "A"; /* If a ServerName was given, skip unless the scoreboard entry matches. */ if (server_name && strcmp(server_name, score->sce_server_label) != 0) continue; /* Clear the buffer for this run. */ memset(buf, '\0', sizeof(buf)); /* Determine the status symbol to display. */ if (strcmp(score->sce_cmd, "idle") == 0) { status = "I"; ftp_nidles++; if (display_mode != FTPTOP_SHOW_RATES && !(display_mode & FTPTOP_SHOW_IDLE)) continue; } else if (strcmp(score->sce_cmd, "RETR") == 0) { status = "D"; ftp_ndownloads++; if (display_mode != FTPTOP_SHOW_RATES && !(display_mode & FTPTOP_SHOW_DOWNLOAD)) continue; } else if (strcmp(score->sce_cmd, "STOR") == 0 || strcmp(score->sce_cmd, "APPE") == 0 || strcmp(score->sce_cmd, "STOU") == 0) { status = "U"; ftp_nuploads++; if (display_mode != FTPTOP_SHOW_RATES && !(display_mode & FTPTOP_SHOW_UPLOAD)) continue; } else if (strcmp(score->sce_cmd, "LIST") == 0 || strcmp(score->sce_cmd, "NLST") == 0) status = "L"; if (display_mode != FTPTOP_SHOW_RATES) { snprintf(buf, sizeof(buf), FTPTOP_REG_DISPLAY_FMT, (unsigned int) score->sce_pid, status, score->sce_user, score->sce_client_name, score->sce_server_addr, show_time(&score->sce_begin_session), score->sce_cmd, FTPTOP_REG_ARG_SIZE, FTPTOP_REG_ARG_SIZE, score->sce_cmd_arg); buf[sizeof(buf)-1] = '\0'; } else { /* Skip sessions unless they are actually transferring data */ if (*status != 'U' && *status != 'D') continue; snprintf(buf, sizeof(buf), FTPTOP_XFER_DISPLAY_FMT, (unsigned int) score->sce_pid, status, score->sce_user, score->sce_client_name, (score->sce_xfer_len / 1024.0) / (score->sce_xfer_elapsed / 1000), FTPTOP_XFER_DONE_SIZE, *status == 'D' ? calc_percent_done(score->sce_xfer_size, score->sce_xfer_done) : "(n/a)"); buf[sizeof(buf)-1] = '\0'; } /* Make sure there is enough memory allocated in the session list. * Allocate more if needed. */ if (ftp_nsessions && ftp_nsessions % chunklen == 0) { if ((ftp_sessions = realloc(ftp_sessions, (ftp_nsessions + chunklen) * sizeof(char *))) == NULL) exit(1); } if ((ftp_sessions[ftp_nsessions] = calloc(1, strlen(buf) + 1)) == NULL) exit(1); strncpy(ftp_sessions[ftp_nsessions++], buf, strlen(buf) + 1); } scoreboard_close(); }