示例#1
0
/* render all windows */
static void
render_screens (void)
{
  int row, col, chg = 0;

  getmaxyx (stdscr, row, col);
  term_size (main_win);

  generate_time ();
  chg = logger->process - logger->offset;

  draw_header (stdscr, "", "%s", row - 1, 0, col, 0, 0);
  wattron (stdscr, COLOR_PAIR (COL_WHITE));
  mvaddstr (row - 1, 1, "[F1]Help [O]pen detail view");
  mvprintw (row - 1, 30, "%d - %s", chg, asctime (now_tm));
  mvaddstr (row - 1, col - 21, "[Q]uit GoAccess");
  mvprintw (row - 1, col - 5, "%s", GO_VERSION);
  wattroff (stdscr, COLOR_PAIR (COL_WHITE));
  refresh ();

  /* call general stats header */
  display_general (header_win, conf.ifile, logger);
  wrefresh (header_win);

  /* display active label based on current module */
  update_active_module (header_win, gscroll.current);

  display_content (main_win, logger, dash, &gscroll);
}
示例#2
0
int Counter::generate_counter()
{
    Rule* rule = get_app().get_rule(m_data.rule_name) ;
    if(rule == NULL || rule->config.offset != m_data.node_offset ) return -1 ;

    RuleConfig& config = rule->config ;

    m_data.counter += config.step ;
    int now = generate_time() ;

    if( (!framework::is_same_cycle(m_data.update_time,now,config.reset_seconds)) ||
             (m_data.counter > config.max_counter)  )
    {
        m_data.counter = config.min_counter + config.offset ;
        m_data.saved_counter = m_data.counter ;
    }

    m_data.update_time = now ;

    if(m_data.counter >= m_data.saved_counter)
    {
        
        m_data.saved_counter = m_data.counter + config.step * config.batch_save ;
        async_save() ;
    }

    return m_data.counter ;

}
示例#3
0
文件: goaccess.c 项目: 0-T-0/goaccess
/* render all windows */
static void
render_screens (void)
{
  GColors *color = get_color (COLOR_DEFAULT);
  int row, col, chg = 0;

  getmaxyx (stdscr, row, col);
  term_size (main_win);

  generate_time ();
  chg = logger->processed - logger->offset;

  draw_header (stdscr, "", "%s", row - 1, 0, col, color_default);

  wattron (stdscr, color->attr | COLOR_PAIR (color->pair->idx));
  mvaddstr (row - 1, 1, "[F1]Help [Enter] Exp. Panel");
  mvprintw (row - 1, 30, "%d - %s", chg, asctime (now_tm));
  mvaddstr (row - 1, col - 21, "[Q]uit GoAccess");
  mvprintw (row - 1, col - 5, "%s", GO_VERSION);
  wattroff (stdscr, color->attr | COLOR_PAIR (color->pair->idx));

  refresh ();

  /* call general stats header */
  display_general (header_win, conf.ifile, logger);
  wrefresh (header_win);

  /* display active label based on current module */
  update_active_module (header_win, gscroll.current);

  display_content (main_win, logger, dash, &gscroll);
}
示例#4
0
文件: output.c 项目: phiexz/goaccess
/* entry point to generate a report writing it to the fp */
void
output_html (GLog * logger, GHolder * holder)
{
  FILE *fp = stdout;
  char now[DATE_TIME];

  generate_time ();
  strftime (now, DATE_TIME, "%Y-%m-%d %H:%M:%S", now_tm);

  print_html_header (fp, now);
  print_pure_menu (fp, now);

  print_html_summary (fp, logger);
  print_html_visitors_report (fp, holder + VISITORS);
  print_html_request_report (fp, holder + REQUESTS, logger->process);
  print_html_request_report (fp, holder + REQUESTS_STATIC, logger->process);
  print_html_request_report (fp, holder + NOT_FOUND, logger->process);
  print_html_hosts (fp, holder + HOSTS, logger->process);
  print_html_browser_os (fp, holder + OS);
  print_html_browser_os (fp, holder + BROWSERS);
  print_html_generic (fp, holder + REFERRERS, logger->process);
  print_html_generic (fp, holder + REFERRING_SITES, logger->process);
  print_html_generic (fp, holder + KEYPHRASES, logger->process);
#ifdef HAVE_LIBGEOIP
  print_html_geolocation (fp, holder + GEO_LOCATION, logger->process);
#endif
  print_html_status (fp, holder + STATUS_CODES, logger->process);

  print_html_footer (fp);
}
示例#5
0
文件: json.c 项目: aishikoyo/goaccess
/* Write to a buffer the date and time for the overall object. */
static void
poverall_datetime (GJSON * json, int sp)
{
  char now[DATE_TIME];

  generate_time ();
  strftime (now, DATE_TIME, "%Y-%m-%d %H:%M:%S %z", now_tm);

  pskeysval (json, OVERALL_DATETIME, now, sp, 0);
}
示例#6
0
文件: json.c 项目: 0-T-0/goaccess
/* Output date and time for the overall object.
 *
 * On success, data is outputted. */
static void
poverall_datetime (FILE * fp, int isp)
{
  char now[DATE_TIME];

  generate_time ();
  strftime (now, DATE_TIME, "%Y-%m-%d %H:%M:%S", now_tm);

  pjson (fp, "%.*s\"%s\": \"%s\",%.*s", isp, TAB, OVERALL_DATETIME, now, nlines,
         NL);
}
示例#7
0
CALifeMonsterBrain::CALifeMonsterBrain		(object_type *object)
{
	VERIFY							(object);
	m_object						= object;
	m_last_search_time				= 0;
	m_smart_terrain					= 0;

#ifdef XRGAME_EXPORTS
	m_movement_manager				= xr_new<CALifeMonsterMovementManager>(object);
#endif
	
#ifdef XRGAME_EXPORTS
	u32								hours,minutes,seconds;
	sscanf							(pSettings->r_string(this->object().name(),"smart_terrain_choose_interval"),"%d:%d:%d",&hours,&minutes,&seconds);
	m_time_interval					= (u32)generate_time(1,1,1,hours,minutes,seconds);
#endif
}
示例#8
0
文件: csv.c 项目: chuzig/goaccess
/* generate overview stats */
static void
print_csv_summary (FILE * fp, GLog * logger)
{
  int i = 0;
  off_t log_size = 0;
  char now[DATE_TIME];

  generate_time ();
  strftime (now, DATE_TIME, "%Y-%m-%d %H:%M:%S", now_tm);

  /* general statistics info */
  fprintf (fp, "\"%d\",,\"%s\",\"date_time\",\"%s\"\r\n", i++, GENER_ID, now);
  fprintf (fp, "\"%d\",,\"%s\",\"total_requests\",\"%d\"\r\n", i++, GENER_ID,
           logger->process);
  fprintf (fp, "\"%d\",,\"%s\",\"unique_visitors\",\"%d\"\r\n", i++, GENER_ID,
           get_ht_size (ht_unique_visitors));
  fprintf (fp, "\"%d\",,\"%s\",\"referrers\",\"%d\"\r\n", i++, GENER_ID,
           get_ht_size (ht_referrers));

  if (!logger->piping)
    log_size = file_size (conf.ifile);

  fprintf (fp, "\"%d\",,\"%s\",\"log_size\",\"%jd\"\r\n", i++, GENER_ID,
           (intmax_t) log_size);
  fprintf (fp, "\"%d\",,\"%s\",\"failed_requests\",\"%d\"\r\n", i++, GENER_ID,
           logger->invalid);
  fprintf (fp, "\"%d\",,\"%s\",\"unique_files\",\"%d\"\r\n", i++, GENER_ID,
           get_ht_size (ht_requests));
  fprintf (fp, "\"%d\",,\"%s\",\"unique_404\",\"%d\"\r\n", i++, GENER_ID,
           get_ht_size (ht_not_found_requests));

  fprintf (fp, "\"%d\",,\"%s\",\"bandwidth\",\"%lld\"\r\n", i++, GENER_ID,
           logger->resp_size);
  fprintf (fp, "\"%d\",,\"%s\",\"generation_time\",\"%llu\"\r\n", i++,
           GENER_ID, (long long) end_proc - start_proc);
  fprintf (fp, "\"%d\",,\"%s\",\"static_files\",\"%d\"\r\n", i++, GENER_ID,
           get_ht_size (ht_requests_static));

  if (conf.ifile == NULL)
    conf.ifile = (char *) "STDIN";

  fprintf (fp, "\"%d\",,\"%s\",\"log_file\",\"%s\"\r\n", i, GENER_ID,
           conf.ifile);
}
示例#9
0
	virtual void	Execute	(LPCSTR args)
	{
		u32 year = 1, month = 1, day = 1, hours = 0, mins = 0, secs = 0, milisecs = 0;
		sscanf				(args,"%d.%d.%d %d:%d:%d.%d",&year,&month,&day,&hours,&mins,&secs,&milisecs);
		year				= _max(year,1);
		month				= _max(month,1);
		day					= _max(day,1);
		g_qwStartGameTime	= generate_time	(year,month,day,hours,mins,secs,milisecs);

		if (!g_pGameLevel)
			return;

		if (!Level().Server)
			return;

		if (!Level().Server->game)
			return;

		Level().Server->game->SetGameTimeFactor(g_qwStartGameTime,g_fTimeFactor);
	}
示例#10
0
/* generate overview stats */
static void
print_json_summary (FILE * fp, GLog * logger)
{
  off_t log_size = 0;
  char now[DATE_TIME];

  generate_time ();
  strftime (now, DATE_TIME, "%Y-%m-%d %H:%M:%S", now_tm);

  fprintf (fp, "\t\"%s\": {\n", GENER_ID);
  /* general statistics info */
  fprintf (fp, "\t\t\"date_time\": \"%s\",\n", now);
  fprintf (fp, "\t\t\"total_requests\": %d,\n", logger->process);
  fprintf (fp, "\t\t\"unique_ips\": %d,\n", get_ht_size (ht_unique_ips));
  fprintf (fp, "\t\t\"unique_visitors\": %d,\n",
           get_ht_size (ht_unique_visitors));
  fprintf (fp, "\t\t\"referrers\": %d,\n", get_ht_size (ht_referrers));

  if (!logger->piping)
    log_size = file_size (conf.ifile);

  fprintf (fp, "\t\t\"log_size\": %jd,\n", (intmax_t) log_size);
  fprintf (fp, "\t\t\"failed_requests\": %d,\n", logger->invalid);
  fprintf (fp, "\t\t\"unique_files\": %d,\n", get_ht_size (ht_requests));
  fprintf (fp, "\t\t\"unique_404\": %d,\n",
           get_ht_size (ht_not_found_requests));

  fprintf (fp, "\t\t\"bandwidth\": %lld,\n", logger->resp_size);
  fprintf (fp, "\t\t\"generation_time\": %llu,\n",
           ((long long) end_proc - start_proc));
  fprintf (fp, "\t\t\"excluded_ip_hits\": %u,\n", logger->exclude_ip);
  fprintf (fp, "\t\t\"static_files\": %d,\n", get_ht_size (ht_requests_static));

  if (conf.ifile == NULL)
    conf.ifile = (char *) "STDIN";

  fprintf (fp, "\t\t\"log_file\": \"%s\"\n", conf.ifile);
  fprintf (fp, "\t}");
}
示例#11
0
int Counter::generate_counter()
{
    Rule* rule = get_app().get_rule(m_data.rule_name) ;
    if(rule == NULL || rule->config.offset != m_data.node_offset ) return -1 ;

    m_data.counter += rule->config.step ;
    int now = generate_time() ;
    int reset_seconds = rule->config.reset_seconds  ;

    if( ( reset_seconds>0 && (!framework::is_same_cycle(m_data.update_time,now,reset_seconds) ) )||
             (m_data.counter > rule->config.max_counter)  )
    {
        m_data.counter = rule->config.min_counter + rule->config.offset ;
    }

    m_data.update_time = now ;

    async_save() ;


    return m_data.counter ;

}
示例#12
0
文件: csv.c 项目: 0-T-0/goaccess
/* Output general statistics information. */
static void
print_csv_summary (FILE * fp, GLog * logger)
{
  long long t = 0LL;
  int i = 0, total = 0;
  off_t log_size = 0;
  char now[DATE_TIME];
  const char *fmt;

  generate_time ();
  strftime (now, DATE_TIME, "%Y-%m-%d %H:%M:%S", now_tm);

  /* generated date time */
  fmt = "\"%d\",,\"%s\",,,,,,,,\"%s\",\"%s\"\r\n";
  fprintf (fp, fmt, i++, GENER_ID, now, OVERALL_DATETIME);

  /* total requests */
  fmt = "\"%d\",,\"%s\",,,,,,,,\"%d\",\"%s\"\r\n";
  total = logger->processed;
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_REQ);

  /* valid requests */
  fmt = "\"%d\",,\"%s\",,,,,,,,\"%d\",\"%s\"\r\n";
  total = logger->valid;
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_VALID);

  /* invalid requests */
  total = logger->invalid;
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_FAILED);

  /* generated time */
  fmt = "\"%d\",,\"%s\",,,,,,,,\"%llu\",\"%s\"\r\n";
  t = (long long) end_proc - start_proc;
  fprintf (fp, fmt, i++, GENER_ID, t, OVERALL_GENTIME);

  /* visitors */
  fmt = "\"%d\",,\"%s\",,,,,,,,\"%d\",\"%s\"\r\n";
  total = ht_get_size_uniqmap (VISITORS);
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_VISITORS);

  /* files */
  total = ht_get_size_datamap (REQUESTS);
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_FILES);

  /* excluded hits */
  total = logger->excluded_ip;
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_EXCL_HITS);

  /* referrers */
  total = ht_get_size_datamap (REFERRERS);
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_REF);

  /* not found */
  total = ht_get_size_datamap (NOT_FOUND);
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_NOTFOUND);

  /* static files */
  total = ht_get_size_datamap (REQUESTS_STATIC);
  fprintf (fp, fmt, i++, GENER_ID, total, OVERALL_STATIC);

  /* log size */
  if (!logger->piping && conf.ifile)
    log_size = file_size (conf.ifile);
  fmt = "\"%d\",,\"%s\",,,,,,,,\"%jd\",\"%s\"\r\n";
  fprintf (fp, fmt, i++, GENER_ID, (intmax_t) log_size, OVERALL_LOGSIZE);

  /* bandwidth */
  fmt = "\"%d\",,\"%s\",,,,,,,,\"%lld\",\"%s\"\r\n";
  fprintf (fp, fmt, i++, GENER_ID, logger->resp_size, OVERALL_BANDWIDTH);

  /* log path */
  if (conf.ifile == NULL)
    conf.ifile = (char *) "STDIN";

  fmt = "\"%d\",,\"%s\",,,,,,,,\"%s\",\"%s\"\r\n";
  fprintf (fp, fmt, i++, GENER_ID, conf.ifile, OVERALL_LOG);
}
int main (void)
{

	key_t message_key;
	int mid; // message ID
	int rc;	// return code from message processing
	int done = 0;
	int count = 0;
	MSGENVELOPE msg;
	char buffer[100];
	int x,temp,select,type,user;
	double dest;
	float recharge=0.0;
	double t1,t2;
	int d,cardnum;
	float charge;
	int min,sec,l;

	// ======== Initial value===============//
	msg.data.validuser=0;
	msg.data.recharge=0;
	strcpy(msg.data.name,"!!!!!!!");
	strcpy(msg.data.addrs,"@@@@@@");
	type=0;//1-prepaid 2-postpaid
	strcpy(msg.data.prooftype,"######");	
	msg.data.balance=0;
	msg.data.timer=0;
	msg.data.number=0;
	msg.data.durcha.front=0;
	msg.data.durcha.rear=0;
	msg.data.durcha.charge[10]=0,0,0,0,0,0,0,0,0,0;
	msg.data.durcha.duration[10]=0,0,0,0,0,0,0,0,0,0;
	strcpy(msg.data.gender,"!");
	msg.data.dob[12]="00/00/0000";
	strcpy(msg.data.city,"!!!!!!!!!!!");
	strcpy(msg.data.state,"!!!!!!!!!!!");
	strcpy(msg.data.nationality,"!!!!!!!!!!!");
	msg.data.pincode=000000;
	//========= Initial value==============//


	/*
	 * open the same message key/queue as server
	 */

	message_key = ftok (".", 'A');
	if (message_key == -1) { 
		printf ("cannot allocate key\n");
		return 1;
	}	/* endif */


	/*
	 * if message queue exists, use it, or
	 * allocate a new one
	 */

	mid = msgget (message_key, 0);

	//printf ("my PID is %d\n", getpid());
	//printf ("message queue ID is %d\n", mid);

	printf ("1 ... New User\n");
	printf ("2 ... Old User\n");
	
	printf ("choice: ");
	scanf("%d",&x);

	msg.type = 1;
	
		
	switch (x) {
	case 1:
		//=======Input details of new user=========//

		msg.data.message_command = 1;
		fflush(stdin);
		printf("\nEnter the name:");
		scanf("%s",msg.data.name);
		printf("\nEnter the address:");
		scanf("%s",msg.data.addrs);
		printf("\nEnter the Date of Birth:");
		scanf("%s",msg.data.dob);
		printf("\nEnter the gender");
		fflush(stdin);		
		scanf("%s",msg.data.gender);
		printf("\nEnter the city:");
		scanf("%s",msg.data.city);
		printf("\nEnter the state:");
		scanf("%s",msg.data.state);
		printf("\nEnter the Nationality:");
		scanf("%s",msg.data.nationality);
		printf("\nEnter the Pincode:");
		scanf("%ld",&msg.data.pincode);
		printf("\nSelect the connection type\n");
		printf("\t1.Prepaid\n\t2.Postpaid\n\nChoice:");
		scanf("%d",&type);
	
		if(type==1)
			msg.data.type=1;
		else if	(type==2)
			msg.data.type=2;
		else
			printf("\nWrong Choice");	


		/*send the user details*/
		rc = msgsnd (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0);
		if (rc == -1) {
			printf ("send error!\n");
			return 4;
		}	
		
		/*receive the num */
		rc = msgrcv (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0, 0);
		if (rc == -1) {
			printf ("receive error!\n");
			return 5;
		}

		printf("\n\nYour number is :%10.0f",msg.data.number);
		break;

	case 2:				
		printf("\nSelect the connection type\n");
		printf("\t1.Prepaid\n\t2.Postpaid\n\nChoice:");
		scanf("%d",&type);
		
		if(type==1)
			msg.data.type=1;
		else if	(type==2)
			msg.data.type=2;
		else
			printf("\nWrong Choice");

		
			msg.data.message_command = 2;

			printf("Enter ur number");
			scanf("%10lf",&msg.data.number);
			
			/*send message to check the number */

			rc = msgsnd (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0);
			if (rc == -1) {
			printf ("send error!\n");
			return 4;
			}	
			
			/*receive info on validity*/
			rc = msgrcv (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0, 0);
			if (rc == -1) {
				printf ("receive error!\n");
			return 5;
			}		
				
		

			if(msg.data.validuser==1)
			{
				printf("\nUr a vaild user");

				while(1)
				{
					if(type==1)
					{
						printf("\nSelect ur choice:");
						printf("\n1.Call");
						printf("\n2.Check Balance");
						printf("\n3.Recharge");					
					}
					else if(type ==2)						
					{
						printf("\nSelect ur choice:");
						printf("\n1.Call");
						printf("\n2.Generate Bill");
						printf("\n3.Pay Bill");
					}
					printf("\n4. Exit(0)");
						
					scanf("%d",&select);
						
						if(select==1)
						{
							if(type==1 && msg.data.balance<=0)
							{
								printf("Insufficient balance");
								break;
							}	

							printf("\nEnter the Destination no:\n");
							scanf("%lf",&dest);
							
							printf("\nPress 1 to make the call\n");
							scanf("%d",&temp);
							fflush(stdin);

							if(temp == 1)
							{
								t1=generate_time();
								
								printf("End call(Press any number)");
								scanf("%d",&d);
								t2=generate_time();
								
								t2=t2-t1;
								
								if(t2/60<1)
								{
									printf("\nThe call duration is%10.0lf seconds\n",t2);		

									printf("Your call charge is: Rs 0.50\n");
									charge=(0.50);
	
								}	
								else
								{
									min=(int)t2/60;
									sec=(int)t2%60;

									printf("\nThe call duration is%d minutes %d seconds \n",min,sec);
		
									charge= (0.50)*(min + 1);
									printf("Your call charge is: Rs %f\n",charge);
								}
					
								msg.data.timer=t2;
								
								if(msg.data.type==1)					
									msg.data.balance-=charge;
								else if(msg.data.type==2)
									msg.data.balance+=charge;
								msg.data.durcha.charge[msg.data.durcha.front]=charge;
								msg.data.durcha.duration[msg.data.durcha.front]=(int)t2;
								(msg.data.durcha.front)++;
								msg.data.durcha.front%=10;
								if((msg.data.durcha.front)==(msg.data.durcha.rear))
									{
										(msg.data.durcha.rear)++;
										msg.data.durcha.rear%=10;
									}

								msg.data.message_command=3;								
								/*send mgs to update the file */

								rc = msgsnd (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0);
								if (rc == -1) {
										printf ("send error!\n");
										return 4;
										}	
								
								/*receive the updated the file */
								rc = msgrcv (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0, 0);
									if (rc == -1) {
											printf ("receive error!\n");
											return 5;
									}		
								
								if(type==1)
								{	
									msg.data.message_command=4;
									
									/*send msg to read the balance*/			
									rc = msgsnd (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0);
									if (rc == -1) {
										printf ("send error!\n");
										return 4;
										}
								
									/*recieve msg to read the balance*/
									rc = msgrcv (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0, 0);
									if (rc == -1) {
											printf ("receive error!\n");
											return 5;
									}									

									printf("\n\nUr current balance is :%f",msg.data.balance);
									for(l=msg.data.durcha.rear;l!=msg.data.durcha.front;)
									{
										printf("\n%f\t%d",msg.data.durcha.charge[l],msg.data.durcha.duration[l]);
										l=(l+1)%10;
									}
								}																									
								
							}/*end if(temp)*/

						}
						else if(select==2)
						{
							if(type ==1)
								{
									msg.data.message_command=4;
									/*send msg to read the balance*/
									rc = msgsnd (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0);
									if (rc == -1) {
										printf ("send error!\n");
										return 4;
										}										
									/*Recieve message about the balance*/
									rc = msgrcv (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0, 0);
									if (rc == -1) {
											printf ("receive error!\n");
											return 5;
									}									
								printf("Ur current Balance is %f ",msg.data.balance);
								}		
							else if(type==2)
								{
									msg.data.message_command=4;
									/*send the msg to generate the bill*/
									rc = msgsnd (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0);
									if (rc == -1) {
										printf ("send error!\n");
										return 4;
										}	

									/*receive the generated the bill details*/
									rc = msgrcv (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0, 0);
									if (rc == -1) {
											printf ("receive error!\n");
											return 5;
											}
									printf("\nBill number:",generate_no());
									printf("\n\nName");	
									printf("%s",msg.data.name);
									printf("\nPhone Number:");
									printf("%10.0f",msg.data.number);
									printf("\nAddress:%s",msg.data.addrs);
									printf("\nTotal charge:%f",msg.data.balance);
									printf("\n\nTotal duration:%f",msg.data.timer);
									printf("\nLast 10 calls:\n");
									printf("\nCharge\t\tTime\n");
									for(l=msg.data.durcha.rear;l!=msg.data.durcha.front;)
									{
										printf("\n%f\t\t%d\n",msg.data.durcha.charge[l],msg.data.durcha.duration[l]);
										l=(l+1)%10;
									}
								}
							
						}						
						else if (select==3)
						{	
							if(type==1)
							{
								msg.data.message_command=3;							
								printf("\nEnter the recharge amount:");
								scanf("%f",&recharge);
								msg.data.balance+=recharge;
								msg.data.recharge=1;

								/*send the updated balance amount */
								rc = msgsnd (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0);
									if (rc == -1) {
										printf ("send error!\n");
										return 4;
										}

								/*receive the updated balance amount */
								rc = msgrcv (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0, 0);
									if (rc == -1) {
											printf ("receive error!\n");
											return 5;
											}
								printf("\nYour account has been recharged successfully.");
								printf("\nYour account balance is %f",msg.data.balance);			
							}
							else if(type==2)
							{
								msg.data.message_command=3;							
								printf("\nEnter ur credit card number:");
								scanf("%d",&cardnum);
								
								msg.data.balance=0.0;
								
								/*send the msg to pay the bill*/
								rc = msgsnd (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0);
									if (rc == -1) {
										printf ("send error!\n");
										return 4;
										}

								/*receive the msg*/
								rc = msgrcv (mid, (void *)&msg, sizeof (SAMPLEMESSAGE), 0, 0);
									if (rc == -1) {
											printf ("receive error!\n");
											return 5;
											}
								printf("\nYour bill is paid successfully");
								
							}
						}
						else
							exit(0);									
					}/*end while*/

				}/*end if (vaild user)*/
												
		default :exit(0);
		
	}/*end switch*/	

	return 0;
}	/* end main */
示例#14
0
文件: json.c 项目: fecori/goaccess
static void
print_json_summary (FILE * fp, GLog * logger)
{
  long long t = 0LL;
  int total = 0;
  off_t log_size = 0;
  char now[DATE_TIME];

  generate_time ();
  strftime (now, DATE_TIME, "%Y-%m-%d %H:%M:%S", now_tm);

  fprintf (fp, "\t\"%s\": {\n", GENER_ID);

  /* generated date time */
  fprintf (fp, "\t\t\"%s\": \"%s\",\n", OVERALL_DATETIME, now);

  /* total requests */
  total = logger->process;
  fprintf (fp, "\t\t\"%s\": %d,\n", OVERALL_REQ, total);

  /* invalid requests */
  total = logger->invalid;
  fprintf (fp, "\t\t\"%s\": %d,\n", OVERALL_FAILED, total);

  /* generated time */
  t = (long long) end_proc - start_proc;
  fprintf (fp, "\t\t\"%s\": %llu,\n", OVERALL_GENTIME, t);

  /* visitors */
  total = get_ht_size_by_metric (VISITORS, MTRC_UNIQMAP);
  fprintf (fp, "\t\t\"%s\": %d,\n", OVERALL_VISITORS, total);

  /* files */
  total = get_ht_size_by_metric (REQUESTS, MTRC_DATAMAP);
  fprintf (fp, "\t\t\"%s\": %d,\n", OVERALL_FILES, total);

  /* excluded hits */
  total = logger->exclude_ip;
  fprintf (fp, "\t\t\"%s\": %d,\n", OVERALL_EXCL_HITS, total);

  /* referrers */
  total = get_ht_size_by_metric (REFERRERS, MTRC_DATAMAP);
  fprintf (fp, "\t\t\"%s\": %d,\n", OVERALL_REF, total);

  /* not found */
  total = get_ht_size_by_metric (NOT_FOUND, MTRC_DATAMAP);
  fprintf (fp, "\t\t\"%s\": %d,\n", OVERALL_NOTFOUND, total);

  /* static files */
  total = get_ht_size_by_metric (REQUESTS_STATIC, MTRC_DATAMAP);
  fprintf (fp, "\t\t\"%s\": %d,\n", OVERALL_STATIC, total);

  /* log size */
  if (!logger->piping)
    log_size = file_size (conf.ifile);
  fprintf (fp, "\t\t\"%s\": %jd,\n", OVERALL_LOGSIZE, (intmax_t) log_size);

  /* bandwidth */
  fprintf (fp, "\t\t\"%s\": %lld,\n", OVERALL_BANDWIDTH, logger->resp_size);

  /* log path */
  if (conf.ifile == NULL)
    conf.ifile = (char *) "STDIN";
  fprintf (fp, "\t\t\"%s\": \"", OVERALL_LOG);
  escape_json_output (fp, conf.ifile);
  fprintf (fp, "\"\n");

  fprintf (fp, "\t},\n");
}
示例#15
0
文件: xr_time.cpp 项目: 2asoft/xray
void	xrTime::set				(int y, int mo, int d, int h, int mi, int s, int ms)
{ 
	m_time=0; 
	m_time+=generate_time(y,mo,d,h,mi,s,ms);
}
示例#16
0
文件: xr_time.cpp 项目: 2asoft/xray
void	xrTime::setHMSms		(int h, int m, int s, int ms)			
{ 
	m_time=0; 
	m_time+=generate_time(1,1,1,h,m,s,ms);
}