Ejemplo n.º 1
0
std::string NetworkLog::CreateLogLine(
  time_t time, NetworkSide side, int16_t node,
  unsigned int bytes_sent, unsigned int bytes_received,
  std::chrono::seconds seconds_elapsed, const std::string& network_name) {

  // Format: 01/03/15 20:26:23 To     1, S: 419k, R: 223k,           0.1 min  wwivnet
  // sprintf(s2, "S:%4ldk, R:%4ldk,", sent, recd);
  // sprintf(s, "%s To %5d, %s         %5s min  %s\r\n", s1, sn, s2, tmused, net_name);

  std::ostringstream ss;
  ss << date_time(time) << " ";
  if (side == NetworkSide::FROM) {
    ss << "Fr ";
  }
  else {
    ss << "To ";
  }
  ss << StringPrintf("%5d", node);
  ss << StringPrintf(", S:%4uk", (bytes_sent + 1023) / 1024);
  ss << StringPrintf(", R:%4uk", (bytes_received + 1023) / 1024);
  ss << "          ";  // should be ", %4.0f cps";
  ss << " ";  // last space before time.

  using float_minutes = std::chrono::duration<float, std::ratio<60>>;
  auto minutes = std::chrono::duration_cast<float_minutes>(seconds_elapsed);
  ss << StringPrintf("%4.1f min ", minutes.count());
  ss << " " << network_name;

  return ss.str();
}
Ejemplo n.º 2
0
cinit()
{
    getmpb(&pmd);
    osmlen = LENOSM;
    run = MGET(PD);

    /* set up system initial standard handles */

    run->p_uft[0] = H_Console;		/* stdin	=	con:	*/
    run->p_uft[1] = H_Console;		/* stdout	=	con:	*/
    run->p_uft[2] = H_Console;		/* stderr	=	con:	*/
    run->p_uft[3] = H_Aux;		/* stdaux	=	aux:	*/
    run->p_uft[4] = H_Print;		/* stdprn	=	prn:	*/

    add[0] = remove[0] = add[1] = remove[1] = add[2] = remove[2] = 0 ;


    date_time(GET_DATE, &date);		/* allow bios to initialise date and */
    date_time(GET_TIME, &time);		/* time from hardware, if supported */
}
Ejemplo n.º 3
0
void screenshot_file_dump(void *data, int length, char *format)
{
    char automatic_filename[1000];
    char *filename;
    char *image_data = data;
    int i = 0;
    FILE *fd;

    // Resolve screenshot output filename
    if (strlen(screenshot_filename) == 0)
    {
        // Automatically resolve screenshot filename if no filename is provided
        sprintf(automatic_filename, "screenshot_%s_%s.%s", screenshot_address, date_time(), format);
        filename = automatic_filename;
    }
    else
    {
        // Write image data to specified filename
        filename = screenshot_filename;
    }

    if (screenshot_no_gui)
    {
        if (strcmp(screenshot_filename, "-") == 0)
        {
            // Write image data to stdout in case filename is '-'
            for (i=0; i<length; i++)
                putchar(*(image_data+i));
            return;
        }
        else
        {
            // Write screenshot to file
            fd = fopen(filename, "w+");
            if (fd == NULL)
            {
                error_printf("Could not write screenshot file (%s)\n", strerror(errno));
                exit(EXIT_FAILURE);
            }
            fwrite(data, 1, length, fd);
            fclose(fd);

            printf("Saved screenshot image to %s\n", filename);
        }
    }
    else
    {
        // Write screenshot to buffer
        memcpy(screenshot_image_buffer, data, length);
        *screenshot_image_size = length;
        strcpy(screenshot_image_format, format);
        strcpy(screenshot_image_filename, filename);
    }
}
Ejemplo n.º 4
0
Message_Unit::Message_Unit(void) :
is_running_(false),
message_unit_max_limit_(INT_MAX),
monitor_(0),
block_group_pool_(10) {
	pause_ts_.tv_sec = 0;
	pause_ts_.tv_nsec = 30 * 1000 * 1000;
	Date_Time date_time(Time_Value::gettimeofday());
	date_time.minute(0);
	date_time.second(0);
	data_pro_tick_ = Time_Value(date_time.time_sec() + 3600);
}
Ejemplo n.º 5
0
void Message_Unit::server_status(void) {
	// 当做和日志服心跳
	RECORD_CLIENT->sync_pid(monitor_->type(), monitor_->monitor_idx());

	int uptime = (Time_Value::gettimeofday().sec() - monitor_->start_time().sec()) / 3600;
	LOG_TEXT("↓↓↓ server status start: uptime:%d(hour), type:%d, index:%d ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓", uptime, monitor_->type(), monitor_->monitor_idx());
	show_server_status();

	Date_Time date_time(Time_Value::gettimeofday());
	date_time.minute(0);
	date_time.second(0);
	data_pro_tick_ += Time_Value(3600);
	LOG_TEXT("↑↑↑ server status end: type:%d ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑", monitor_->type());
	LOG_TEXT_FLUSH;
}
Ejemplo n.º 6
0
String
osDate(void)
{
	static char str[24];
	$DESCRIPTOR(date_desc, str);
	int     status;

	/* LIB$DATE_TIME returns a string of the form DD-MMM-YYYY HH:MM:SS.HH */

	status = lib$date_time(&date_desc);
	if (!status)
		lib$signal(status, NULL);	/* report unexpected errors */

	str[23] = '\0';			/* C likes NULL terminated strings */

	return str;
}
Ejemplo n.º 7
0
	void screenshot(std::string _filename, int _w, int _h) {
		_filename.append(date_time());
		_filename.append(".bmp");
        
		std::vector< unsigned char > buf( _w * _h * 3 );

		glPixelStorei( GL_PACK_ALIGNMENT, 1 );
		glReadPixels( 0, 0, _w, _h, GL_RGB, GL_UNSIGNED_BYTE, &buf[0] );

		_w= glutGet(GLUT_WINDOW_WIDTH);
		_h = glutGet(GLUT_WINDOW_HEIGHT);
		int state = SOIL_save_screenshot(_filename.c_str(), SOIL_SAVE_TYPE_BMP, 0, 0, _w, _h);


		if (!state) std::cout << "Error: Cannot save the screenshot" << std::endl;
		else std::cout << "Saved in " << _filename << std::endl;
	}
Ejemplo n.º 8
0
 bool parse(std::string::const_iterator& first, std::string::const_iterator last, date_time& v) {
     std::string::const_iterator f = first;
     date_time::tm_type tm;
     tiny_parser tp(f, last);
     tp.space();
     tp.push();
     tm.tm_wday = tp.array_item(wkday, ARRAY_SIZE(wkday));
     if (tm.tm_wday != -1 && tp(", ")) { // RFC 1123
         /// Sun, 06 Nov 1994 08:49:37 GMT
         if ((tm.tm_mday = tp.digits(2)) < 0 || !tp(" ") ||
             (tm.tm_mon = (int)tp.array_item(month, ARRAY_SIZE(month))) == -1 || !tp(" ") ||
             (tm.tm_year = tp.digits(4)) < 0 || !tp(" ") ||
             (tm.tm_hour = tp.digits(2)) < 0 || !tp(":") ||
             (tm.tm_min = tp.digits(2)) < 0 || !tp(":") ||
             (tm.tm_sec = tp.digits(2)) < 0 || !tp(" GMT"))
             return false;
         tm.tm_year -= 1900;
     } else if (tm.tm_wday != -1 && tp(" ")) { // asctime
         /// Sun Nov  6 08:49:37 1994
         if ((tm.tm_mon = tp.array_item(month, ARRAY_SIZE(month))) == -1 || !tp(" ") ||
             (tm.tm_mday = tp.digits(2, false)) < 0 || !tp(" ") ||
             (tm.tm_hour = tp.digits(2)) < 0 || !tp(":") ||
             (tm.tm_min = tp.digits(2)) < 0 || !tp(":") ||
             (tm.tm_sec = tp.digits(2)) < 0 || !tp(" ") ||
             (tm.tm_year = tp.digits(4)) < 0)
             return false;
         tm.tm_year -= 1900;
     } else { // RFC 850
         /// Sunday, 06-Nov-94 08:49:37 GMT
         tp.pop();
         if ((tm.tm_wday = tp.array_item(weekday, ARRAY_SIZE(weekday))) == -1 || !tp(", ") ||
             (tm.tm_mday = tp.digits(2)) < 0 || !tp("-") ||
             (tm.tm_mon = tp.array_item(month, ARRAY_SIZE(month))) == -1 || !tp("-") ||
             (tm.tm_year = tp.digits(2)) < 0 || !tp(" ") ||
             (tm.tm_hour = tp.digits(2)) < 0 || !tp(":") ||
             (tm.tm_min = tp.digits(2)) < 0 || !tp(":") ||
             (tm.tm_sec = tp.digits(2)) < 0 || !tp(" GMT"))
             return false;
         if (tm.tm_year < 70)
             tm.tm_year += 100;
     }
     v = date_time(tm, true);
     first = tp.first();
     return true;
 }
main () {

   /* Find my group and member IDs for $getjpi */  
   status = sys$getjpiw(0,0,0,getjpi_items,&jpi_iosb,0,0);
   if (!(status & 1)) lib$signal(status);
   if (!(jpi_iosb.iosb_status & 1)) lib$signal(jpi_iosb.iosb_status);

   /* Build the pscan stuff */
   assert (psitems[1].code == PSCAN$_GRP);
   psitems[1].val = mygrp;
   assert (psitems[2].code == PSCAN$_MEM);
   psitems[2].val = mymem;

   /* Build the context for $getjpi */
   status = sys$process_scan(&ps_ctx, &psitems);
   if (!(status & 1)) lib$signal(status);
   status = lib$date_time(&time_desc);
   printf("\n         Checking uptime agent status at: %s\n",timestring);


   printf("\n               Image         Node       Pid       CPUsec        ppgcnt  gpgcnt\n");
   printf("----------------------------------------------------------------------------------\n");

   /* Run the context until all processes found */
   while (TRUE) {
      status = sys$getjpiw (EFN$C_ENF, &ps_ctx, 0, getjpi_items, &jpi_iosb, 0, 0);
      if (jpi_iosb.iosb_status == SS$_NOMOREPROC) {
         printf("----------------------------------------------------------------------------------\n");
         break;
      }else{
         if (!(jpi_iosb.iosb_status & 1)) lib$signal(jpi_iosb.iosb_status);
         total_mem = pages + gblpages;
         lib$trim_filespec(&img_desc,&short_desc,&sizeof(shortname));  /* Just the filename  */
         if (strstr(shortname,"UPTIME-AGENT") != NULL) { 
            status = sys$asctim(&timlen,&time_desc,&logintime,timeflag);  /* Convert binary time */
            printf ("%20s       %6s  %x     %8.1f        %6d  %6d\n",
               shortname,nodename,mypid,(float)cputime/100,pages,gblpages);   
         } 
      }
   }
}
Ejemplo n.º 10
0
Archivo: date.c Proyecto: 0CV0/libgit2
static void date_midnight(struct tm *tm, struct tm *now, int *num)
{
   GIT_UNUSED(num);
	date_time(tm, now, 0);
}
Ejemplo n.º 11
0
Logger::Logger(const string& kind) : kind_(kind), display_fn_(Logger::DefaultDisplay) { 
  stream_ << kind_ << date_time() << " "; 
}
Ejemplo n.º 12
0
Archivo: date.c Proyecto: Brian1176/git
static void date_tea(struct tm *tm, struct tm *now, int *num)
{
	date_time(tm, now, 17);
}
Ejemplo n.º 13
0
Archivo: date.c Proyecto: Brian1176/git
static void date_noon(struct tm *tm, struct tm *now, int *num)
{
	date_time(tm, now, 12);
}
Ejemplo n.º 14
0
Archivo: date.c Proyecto: Brian1176/git
static void date_midnight(struct tm *tm, struct tm *now, int *num)
{
	date_time(tm, now, 0);
}
Ejemplo n.º 15
0
void open_list_file(void)
{
	char charspace;
	uint4 status;
	unsigned char	list_name[MAX_MIDENT_LEN + STR_LIT_LEN(LISTEXT)], fname[255];
	struct FAB	fab;
	struct NAM	nam;

#ifdef __ALPHA
# pragma member_alignment save
# pragma nomember_alignment
#endif
	static readonly struct{
	unsigned char	newversion;
	unsigned char	wrap;
	unsigned char	width;
	int4		v_width;
	unsigned char	eol;
	}open_params_list = {
	(unsigned char)iop_newversion,	(unsigned char)iop_wrap,
	(unsigned char)iop_recordsize,	(int4)132,
	(unsigned char)iop_eol
	};
#ifdef __ALPHA
# pragma member_alignment restore
#endif

	mval params;
	mval file;
	struct dsc$descriptor_s print_time_d
		= { SIZEOF(print_time_buf), DSC$K_DTYPE_T, DSC$K_CLASS_S, print_time_buf };

	lst_param.list_line = 1;
	lst_param.page = 0;

	fab = cc$rms_fab;
	nam = cc$rms_nam;
	fab.fab$l_dna = &list_name[0];
	assert(module_name.len <= MAX_MIDENT_LEN);
	fab.fab$b_dns = module_name.len;
	memcpy(&list_name[0], module_name.addr, fab.fab$b_dns);
	MEMCPY_LIT(&list_name[fab.fab$b_dns], LISTEXT);
	fab.fab$b_dns += STR_LIT_LEN(LISTEXT);
	if (MV_DEFINED(&cmd_qlf.list_file))
	{
		fab.fab$b_fns = cmd_qlf.list_file.str.len;
		fab.fab$l_fna = cmd_qlf.list_file.str.addr;
	}
	nam.nam$l_esa = &fname[0];
	nam.nam$b_ess = SIZEOF(fname);
	nam.nam$b_nop = (NAM$M_SYNCHK);
	fab.fab$l_nam = &nam;
	fab.fab$l_fop = FAB$M_NAM;
	if ((status = sys$parse(&fab,0,0)) != RMS$_NORMAL)
	{	rts_error(VARLSTCNT(1) status);
	}

	file.mvtype = params.mvtype = MV_STR;
	file.str.len = nam.nam$b_esl;
	file.str.addr = &fname[0];
	params.str.len = SIZEOF(open_params_list);
	params.str.addr = &open_params_list;
	(*op_open_ptr)(&file, &params, 30, 0);
	params.str.len = 1;
	charspace = (char) iop_eol;
	params.str.addr = &charspace;
	dev_in_use = io_curr_device;
	op_use(&file,&params);
	lib$date_time(&print_time_d);
	list_head(0);
	return;
}
Ejemplo n.º 16
0
TEST_F(TimeTest, testDateTime) {
    date_time a;
    date_time b(2012, 12, 21, 13, 37, 42, 007);
    date_time before(2012, 12, 19, 13, 37, 42, 007);
    date_time c(2008, 2, 29);
    EXPECT_ANY_THROW(date_time d(2009, 2, 29));
    EXPECT_ANY_THROW(date_time d(2009, 1, 0));
    EXPECT_ANY_THROW(date_time d(2009, 4, 31));
    date_time e(c);

    date_time f(1900, 1, 1, 13, 37, 42);
    mariadb::time ta(13, 37, 42);
    date_time g(ta);

    EXPECT_EQ(b, before.add_days(2));
    EXPECT_EQ(e, c);
    EXPECT_NE(a, b);
    EXPECT_EQ(f, g);

    // test time.h constructors
    tm sometime;
    sometime.tm_year = 112;
    sometime.tm_mon = 11;
    sometime.tm_mday = 21;
    sometime.tm_hour = 13;
    sometime.tm_min = 37;
    sometime.tm_sec = 42;

    tm invtime;
    invtime.tm_year = 110;
    invtime.tm_mon = 12;
    invtime.tm_mday = 1;

    time_t someothertime = ::time(nullptr);

    date_time h(sometime);
    EXPECT_ANY_THROW(date_time d(invtime));

    date_time i(someothertime);

    EXPECT_EQ(h.add_milliseconds(007), b);
    EXPECT_NE(a, i);

    date_time aa("2012-12-21 13:37:42.007");
    date_time ba("2008-02-29 13:37:42.007");
    EXPECT_ANY_THROW(date_time ca("2007-02-29 13:37:42.007"));
    EXPECT_ANY_THROW(date_time ca("2007-02-29 a13:37:42.007"));
    EXPECT_ANY_THROW(date_time ca("2007-02-29 13:37:a42.007"));
    EXPECT_ANY_THROW(date_time ca("2007-02-29 13:37:42.007"));
    EXPECT_ANY_THROW(date_time ca("2007-02-29 113:37:42.007"));
    EXPECT_ANY_THROW(date_time ca("2007-02-29 13:37:42.a007"));
    EXPECT_ANY_THROW(date_time ca("2007-a02-29 13:37:42.007"));

    EXPECT_EQ(b, aa);

    u16 doy = aa.day_of_year();
    date_time da = date_time::reverse_day_of_year(aa.year(), doy);
    EXPECT_EQ(da, aa.date());

    readdTest(before, b);

    // leap year
    readdTest(date_time(2000, 1, 1), date_time(2000, 2, 1));

    readdTest(date_time(2000, 9, 1), date_time(2010, 2, 1));
    readdTest(date_time(2000, 2, 1), date_time(2010, 9, 1));

    // non-leap
    readdTest(date_time(2001, 1, 1), date_time(2001, 2, 1));

    readdTest(date_time(2001, 9, 1), date_time(2010, 2, 1));
    readdTest(date_time(2001, 2, 1), date_time(2010, 9, 1));

    EXPECT_EQ("2012-12-21 13:37:42.007", aa.str(true));
    EXPECT_EQ("2012-12-21 13:37:42", aa.str(false));
    EXPECT_EQ("2012-12-21", aa.str_date());

    EXPECT_EQ("2008-02-29 13:37:42.007", ba.str(true));
    EXPECT_EQ("2008-02-29 13:37:42", ba.str(false));
    EXPECT_EQ("2008-02-29", ba.str_date());
}
Ejemplo n.º 17
0
//*******************************************************************
// customEvent                                     PRIVATE inherited
//*******************************************************************
void QBtWorkspace::customEvent( QEvent* const in_event )
{
    const QBtEvent* const event = dynamic_cast< QBtEvent* >( in_event );
    const int type = static_cast<int>( event->type() );

    switch( type ) {
    case QBtEvent::SWITCH_TAB_REQUEST:
        switch_panels();
        break;
    case QBtEvent::F5_KEY:
        copy();
        break;
    case QBtEvent::F9_KEY:
        pack();
        break;
    case QBtEvent::COMPARE_FILES:
        compare_files();
        break;
    case QBtEvent::COMPARE_DIRS:
        compare_dirs();
        break;
    case QBtEvent::SYNC_DIRS:
        sync_dirs();
        break;
    case QBtEvent::JOIN_FILES:
        join_files();
        break;
    case QBtEvent::DIR_TREE:
        dir_tree();
        break;
    case QBtEvent::MD5_CREATE:
        md5_create();
        break;
    case QBtEvent::MD5_CHECK:
        md5_check();
        break;
    case QBtEvent::DATE_TIME:
        date_time();
        break;
    case QBtEvent::DROP_FILES:
        drop_files( event->data(0).toMap() );
        break;
    case QBtEvent::OPEN_OPOSITE:
        open_oposite();
        break;
    case QBtEvent::OPEN_DIR:
        open_dir( event->data(0).toString() );
        break;
    case QBtEvent::OPEN_SHELL:
        open_shell();
        break;
    case QBtEvent::OPEN_TERMINAL:
        open_terminal();
        break;
    case QBtEvent::OPEN_EDITOR:
        open_editor();
        break;
    case QBtEvent::EXECUTE:
        open( event->data(0).toString(), QStringList(), QString() );
        break;
    }
}
Ejemplo n.º 18
0
 date_time date_time::now() {return date_time(::time(0));}
Ejemplo n.º 19
0
Archivo: date.c Proyecto: 0CV0/libgit2
static void date_tea(struct tm *tm, struct tm *now, int *num)
{
   GIT_UNUSED(num);
	date_time(tm, now, 17);
}