Beispiel #1
0
void document_header(void) {
	char date_time[MAX_DATETIME_LENGTH];
	time_t expire_time;
	time_t current_time;

	time(&current_time);

	printf("Cache-Control: no-store\r\n");
	printf("Pragma: no-cache\r\n");

	get_time_string(&current_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
	printf("Last-Modified: %s\r\n", date_time);

	expire_time = (time_t)0L;
	get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
	printf("Expires: %s\r\n", date_time);

	printf("Content-type: text/vnd.wap.wml\r\n\r\n");

	printf("<?xml version=\"1.0\"?>\n");
	printf("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");

	printf("<wml>\n");

	printf("<head>\n");
	printf("<meta forua=\"true\" http-equiv=\"Cache-Control\" content=\"max-age=0\"/>\n");
	printf("</head>\n");

	return;
	}
Beispiel #2
0
/*
 * Print statistics in global/process pane. Called by print_sysglobal
 * print_process.
 *
 * Parameters:
 *		window - the global or process statistics window.
 *		begin_line - where to start printing.
 *		count - how many lines should be printed.
 *		list - a stat_list.
 */
static void
print_statistics(WINDOW * window, int begin_line, int nlines, void *list)
{
	uint64_t total;
	int i = 0;

	if (!display_initialized) {
		return;
	}

	total = lt_stat_list_get_gtotal(list);

	if (total == 0) {
		return;
	}

	while (i < nlines && lt_stat_list_has_item(list, i)) {

		char tmp[WIDTH_REASON_STRING];
		const char *reason = lt_stat_list_get_reason(list, i);
		uint64_t count = lt_stat_list_get_count(list, i);

		if (count == 0) {
			continue;
		}

		(void) snprintf(tmp, sizeof (tmp), "%s", reason);
		(void) mvwprintw(window, i + begin_line, 0, "%s", tmp);

		(void) snprintf(tmp, sizeof (tmp), "%llu", count);
		fill_space_left(tmp, WIDTH_COUNT, sizeof (tmp));
		(void) mvwprintw(window, i + begin_line, BEGIN_COUNT,
		    "%s", tmp);

		(void) mvwprintw(window, i + begin_line, BEGIN_AVG,
		    "%s", get_time_string(
		    (double)lt_stat_list_get_sum(list, i) / count,
		    tmp, sizeof (tmp), WIDTH_AVG));

		(void) mvwprintw(window, i + begin_line, BEGIN_MAX,
		    "%s", get_time_string(
		    (double)lt_stat_list_get_max(list, i),
		    tmp, sizeof (tmp), WIDTH_MAX));

		if (LT_LIST_SPECIALS != current_list_type) {
			(void) snprintf(tmp, sizeof (tmp), "%.1f %%",
			    (double)lt_stat_list_get_sum(list, i)
			    / total * 100.0);
		} else {
			(void) snprintf(tmp, sizeof (tmp), "--- ");
		}

		fill_space_left(tmp, WIDTH_PCT, sizeof (tmp));

		(void) mvwprintw(window, i + begin_line, BEGIN_PCT,
		    "%s", tmp);
		i++;
	}
}
Beispiel #3
0
static void show_total_dive_stats(void)
{
	double value;
	int decimals, seconds;
	const char *unit;
	char buffer[60];
	stats_t *stats_ptr;

	if (!stats_w.framelabel)
		return;
	stats_ptr = &stats_selection;

	get_selected_dives_text(buffer, sizeof(buffer));
	set_label(stats_w.framelabel, _("Statistics %s"), buffer);
	set_label(stats_w.selection_size, "%d", stats_ptr->selection_size);
	if (stats_ptr->selection_size == 0) {
		clear_stats_widgets();
		return;
	}
	if (stats_ptr->min_temp) {
		value = get_temp_units(stats_ptr->min_temp, &unit);
		set_label(stats_w.min_temp, "%.1f %s", value, unit);
	}
	if (stats_ptr->combined_temp && stats_ptr->combined_count)
		set_label(stats_w.avg_temp, "%.1f %s", stats_ptr->combined_temp / stats_ptr->combined_count, unit);
	if (stats_ptr->max_temp) {
		value = get_temp_units(stats_ptr->max_temp, &unit);
		set_label(stats_w.max_temp, "%.1f %s", value, unit);
	}
	set_label(stats_w.total_time, get_time_string(stats_ptr->total_time.seconds, 0));
	seconds = stats_ptr->total_time.seconds;
	if (stats_ptr->selection_size)
		seconds /= stats_ptr->selection_size;
	set_label(stats_w.avg_time, get_time_string(seconds, 0));
	set_label(stats_w.longest_time, get_time_string(stats_ptr->longest_time.seconds, 0));
	set_label(stats_w.shortest_time, get_time_string(stats_ptr->shortest_time.seconds, 0));
	value = get_depth_units(stats_ptr->max_depth.mm, &decimals, &unit);
	set_label(stats_w.max_overall_depth, "%.*f %s", decimals, value, unit);
	value = get_depth_units(stats_ptr->min_depth.mm, &decimals, &unit);
	set_label(stats_w.min_overall_depth, "%.*f %s", decimals, value, unit);
	value = get_depth_units(stats_ptr->avg_depth.mm, &decimals, &unit);
	set_label(stats_w.avg_overall_depth, "%.*f %s", decimals, value, unit);
	value = get_volume_units(stats_ptr->max_sac.mliter, &decimals, &unit);
	set_label(stats_w.max_sac, _("%.*f %s/min"), decimals, value, unit);
	value = get_volume_units(stats_ptr->min_sac.mliter, &decimals, &unit);
	set_label(stats_w.min_sac, _("%.*f %s/min"), decimals, value, unit);
	value = get_volume_units(stats_ptr->avg_sac.mliter, &decimals, &unit);
	set_label(stats_w.avg_sac, _("%.*f %s/min"), decimals, value, unit);
}
Beispiel #4
0
/*
 * Print per-thread statistics in process pane.
 * This is called when mode of operation is thread.
 */
static void
print_thread(pid_t pid, id_t tid)
{
	void *list;
	char header[256];
	char tmp[30];

	if (!display_initialized) {
		return;
	}

	list = lt_stat_list_create(current_list_type, LT_LEVEL_THREAD,
	    pid, tid, 8, sort_type);

	(void) werase(process_window);
	(void) wattron(process_window, A_REVERSE);
	(void) snprintf(header, sizeof (header),
	    "Process %s (%i), LWP %d",
	    lt_stat_proc_get_name(pid), pid, tid);
	fill_space_right(header, screen_width, sizeof (header));
	(void) mvwprintw(process_window, 0, 0, "%s", header);

	if (current_list_type != LT_LIST_SPECIALS) {
		(void) mvwprintw(process_window, 0, 48, "Total: %s",
		    get_time_string(
		    (double)lt_stat_list_get_gtotal(list),
		    tmp, sizeof (tmp), 12));
	}

	print_current_mode();
	(void) wattroff(process_window, A_REVERSE);
	print_statistics(process_window, 1, 8, list);
	lt_stat_list_free(list);
	(void) wrefresh(process_window);
}
void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
{
	QFile file(filename);
	file.open(QIODevice::WriteOnly | QIODevice::Text);
	QTextStream out(&file);
	int i = 0;
	out << "divestat=[";
	while (stats_yearly != NULL && stats_yearly[i].period) {
		out << "{";
		out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
		out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
		out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
		out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
		out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
		out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
		out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
		out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
		out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
		out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
		out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
		out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
		out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
		out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
		out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
		out << "},";
		i++;
	}
	out << "]";
	file.close();
}
Beispiel #6
0
void get_now_string(char buffer[], unsigned buffer_size, char* pattern)
{
    time_t rawtime;
    time(&rawtime);
    get_time_string(buffer, buffer_size, rawtime, pattern);
    return;
}
Beispiel #7
0
static void resp_status_page(void)
{
    char uptime_str[32];
    char time_str[32];

    get_time_string(time_str, sizeof(time_str));
    get_uptime_string(uptime_str, sizeof(uptime_str));

    puts("Content-type: text/html\n");

    puts("<!DOCTYPE html>");
    puts("<head>");
    puts("  <meta charset=\"utf-8\">");
    puts("  <meta http-equiv=\"Refresh\" content=\"10\">");
    puts("<title>");
    printf("%s Status Page", hostname);
    puts("</title>");
    puts("</head>");
    puts("<body>");
    puts("<p>Server: OK</p>");
    printf("<p>%s</p>\n", time_str);
    printf("<p>Uptime: %s</p>", uptime_str);
    puts("</body>");
    puts("</html>");
}
Beispiel #8
0
static void resp_time(void)
{
    char time_str[32];
    get_time_string(time_str, sizeof(time_str));
    puts("Content-type: text/html\n");
    printf("%s", time_str);
}
Beispiel #9
0
void place_id(const PalletMovement *movement)
{
   printf("place_id: Adding tag to place [%s], with rfid tag [%s]\n", movement->id, movement->placement);
    char *time = get_time_string();
    
    const char *keys[4] = {
        "reader", "place", "p", "time"
    };
   printf("Values place_id: reader: [%s] id: [%s] tag: [%s] time: [%s]\n", movement->reader, movement->id, movement->placement, time);
    const char *values[4] = {
        movement->reader,
        movement->id, 
        movement->placement,
        time
    };
    printf("URL snart");
    char *parameters = to_parameters(4, keys, values);
    char *URL = concat3(BASE_URL, SERVER_MOVE_START, parameters);
   printf("URL: %s", URL);
    
	movements_add(URL);
	
	free(time);
	free(parameters);
	free(URL);
}
Beispiel #10
0
// move
void pallet_id(const PalletMovement *movement)
{
    printf("pallet_id: Adding id [%s] to pallet with rfid [%s] and [%s]\n", movement->id, movement->pallet, movement->pallet2);
    char *time = get_time_string();
    
    const char *keys[5] = {
        "reader", "palletId", "tag1", "tag2", "time"
    };
    const char *values[5] = {
        movement->reader,
        movement->id, 
        movement->pallet,
        movement->pallet2,
        time
    };
    
    char *parameters = to_parameters(5, keys, values);
    char *URL = concat3(BASE_URL, SERVER_MOVE_START, parameters);
    
	movements_add(URL);
	
	free(time);
	free(parameters);
	free(URL);
}
Beispiel #11
0
void status_bar_ui::current_metadata_changed(metadata_optional_t const &new_metadata, bool const reset_playback_position)
{
	if (new_metadata)
	{
		std::string title = get_metadata_value < std::string > (*new_metadata, "title", "");
		if (title.empty())
			current_song_title->setText("");
		else
			current_song_title->setText(QString::fromUtf8(title.c_str()));

		unsigned int num_ticks = get_metadata_value < unsigned int > (*new_metadata, "num_ticks", 0);
		current_num_ticks_per_second = get_metadata_value < unsigned int > (*new_metadata, "num_ticks_per_second", 0);

		if (num_ticks > 0)
		{
			if (current_num_ticks_per_second > 0)
			{
				unsigned int length_in_seconds = num_ticks / current_num_ticks_per_second;
				unsigned int minutes = length_in_seconds / 60;
				unsigned int seconds = length_in_seconds % 60;

				current_song_length->setText(get_time_string(minutes, seconds));
				if (reset_playback_position)
					current_playback_time->setText(get_time_string(0, 0));
			}
			else
			{
				current_song_length->setText("");
				if (reset_playback_position)
					current_playback_time->setText("");
			}
		}
		else
		{	
			current_song_length->setText("");
			if (reset_playback_position)
				current_playback_time->setText(get_time_string(0, 0));
		}
	}
	else
	{
		current_song_title->setText("");
		current_song_length->setText("");
		if (reset_playback_position)
			current_playback_time->setText("");
	}
}
Beispiel #12
0
static void process_interval_stats(stats_t stats_interval, GtkTreeIter *parent, GtkTreeIter *row)
{
    double value;
    const char *unit;
    char value_str[40];
    GtkTreeStore *store;

    store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(yearly_tree)));

    /* Year or month */
    snprintf(value_str, sizeof(value_str), "%d", stats_interval.period);
    add_row_to_tree(store, value_str, 0, row, parent);
    /* Dives */
    snprintf(value_str, sizeof(value_str), "%d", stats_interval.selection_size);
    add_cell_to_tree(store, value_str, 1,  row);
    /* Total duration */
    add_cell_to_tree(store, get_time_string(stats_interval.total_time.seconds, 0), 2, row);
    /* Average dive duration */
    add_cell_to_tree(store, get_minutes(stats_interval.total_time.seconds / stats_interval.selection_size), 3, row);
    /* Shortest duration */
    add_cell_to_tree(store, get_minutes(stats_interval.shortest_time.seconds), 4, row);
    /* Longest duration */
    add_cell_to_tree(store, get_minutes(stats_interval.longest_time.seconds), 5, row);
    /* Average depth */
    add_cell(store, row, stats_interval.avg_depth.mm, 6, TRUE);
    /* Smallest maximum depth */
    add_cell(store, row, stats_interval.min_depth.mm, 7, TRUE);
    /* Deepest maximum depth */
    add_cell(store, row, stats_interval.max_depth.mm, 8, TRUE);
    /* Average air consumption */
    add_cell(store, row, stats_interval.avg_sac.mliter, 9, FALSE);
    /* Smallest average air consumption */
    add_cell(store, row, stats_interval.min_sac.mliter, 10, FALSE);
    /* Biggest air consumption */
    add_cell(store, row, stats_interval.max_sac.mliter, 11, FALSE);
    /* Average water temperature */
    value = get_temp_units(stats_interval.min_temp, &unit);
    if (stats_interval.combined_temp && stats_interval.combined_count) {
        snprintf(value_str, sizeof(value_str), "%.1f %s", stats_interval.combined_temp / (stats_interval.combined_count * 1.0), unit);
        add_cell_to_tree(store, value_str, 12, row);
    } else {
        add_cell_to_tree(store, "", 12, row);
    }
    /* Coldest water temperature */
    if (value > -100.0) {
        snprintf(value_str, sizeof(value_str), "%.1f %s\t", value, unit);
        add_cell_to_tree(store, value_str, 13, row);
    } else {
        add_cell_to_tree(store, "", 13, row);
    }
    /* Warmest water temperature */
    value = get_temp_units(stats_interval.max_temp, &unit);
    if (value > -100.0) {
        snprintf(value_str, sizeof(value_str), "%.1f %s", value, unit);
        add_cell_to_tree(store, value_str, 14, row);
    } else {
        add_cell_to_tree(store, "", 14, row);
    }
}
Beispiel #13
0
int 
process_server( int sockfd_new )
{
	while(1)
	{
		fd_set readfd;
		FD_ZERO(&readfd);
		FD_SET(sockfd_new ,&readfd);

		struct timeval tv;
		tv.tv_sec = TIME_OUT_DEFAULT;
		tv.tv_usec = 0;

		if( select(sockfd_new+1, &readfd, NULL, NULL, &tv) < 0 )
		{
			if( EINTR == errno )
			{
				continue;
			}
			SERVER_DEBUG( "select error:%s\n", strerror(errno) );
			return -1;			
		} else if( FD_ISSET(sockfd_new, &readfd) ) {
			char buffer[SO_BUF_LEN_MAX];
			memset( buffer, 0, sizeof(buffer) );

			SERVER_DEBUG( "receive message:\n" );
			
			ssize_t length = 0;
			if( ( length = read_wrapper(sockfd_new, buffer, sizeof(buffer)) ) < 0 )
			{
				SERVER_DEBUG( "read error:%s\n", strerror(errno) );
				return -1;			
			}
		
			SERVER_DEBUG( "read size = %d\n", length );
		
			if( 0 < length )
			{
				SERVER_DEBUG( "send message:\n" );
				const char* message = get_time_string();
				if( ( length = write_wrapper( sockfd_new, message, strlen(message) ) ) < 0 )
				{
					SERVER_DEBUG( "write error:%s\n", strerror(errno) );
					return -1;			
				}
				SERVER_DEBUG( "write size = %d\n", length );
			} else {
				SERVER_DEBUG( "read error, close socket\n" );	
				return -1;
			}
		} else {
			continue;
		}
	}

	kill( parent, SIGCHLD );
	return 0;
}
Beispiel #14
0
void document_header(int use_stylesheet) {
	char date_time[MAX_DATETIME_LENGTH];
	time_t current_time;
	time_t expire_time;

	printf("Cache-Control: no-store\r\n");
	printf("Pragma: no-cache\r\n");
	printf("Refresh: %d\r\n", refresh_rate);

	time(&current_time);
	get_time_string(&current_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
	printf("Last-Modified: %s\r\n", date_time);

	expire_time = (time_t)0L;
	get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
	printf("Expires: %s\r\n", date_time);

	printf("Content-type: text/html\r\n\r\n");

	if(embedded == TRUE)
		return;

	printf("<html>\n");
	printf("<head>\n");
	printf("<link rel=\"shortcut icon\" href=\"%sfavicon.ico\" type=\"image/ico\">\n", url_images_path);
	printf("<title>\n");
	printf("Network Outages\n");
	printf("</title>\n");

	if(use_stylesheet == TRUE) {
		printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>", url_stylesheets_path, COMMON_CSS);
		printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>", url_stylesheets_path, OUTAGES_CSS);
		}

	printf("</head>\n");

	printf("<body CLASS='outages'>\n");

	/* include user SSI header */
	include_ssi_files(OUTAGES_CGI, SSI_HEADER);

	return;
	}
Beispiel #15
0
void document_header(int use_stylesheet) {
	char date_time[MAX_DATETIME_LENGTH];
	time_t current_time;
	time_t expire_time;

	printf("Cache-Control: no-store\r\n");
	printf("Pragma: no-cache\r\n");

	time(&current_time);
	get_time_string(&current_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
	printf("Last-Modified: %s\r\n", date_time);

	expire_time = (time_t)0L;
	get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
	printf("Expires: %s\r\n", date_time);

	printf("Content-type: text/html\r\n\r\n");

	if(embedded == TRUE)
		return;

	printf("<HTML>\n");
	printf("<HEAD>\n");
	printf("<link rel=\"shortcut icon\" href=\"%sfavicon.ico\" type=\"image/ico\">\n",url_images_path);
	printf("<meta http-equiv='content-type' content='text/html;charset=UTF-8'>\n");
	printf("<meta http-equiv='Pragma' content='no-cache'>\n");
	printf("<TITLE>\n");
	printf("%s\n",_("Nagios Log File"));
	printf("</TITLE>\n");

	if(use_stylesheet == TRUE) {
		printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>\n", url_stylesheets_path, COMMON_CSS);
		printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>\n", url_stylesheets_path, SHOWLOG_CSS);
		}

	printf("</HEAD>\n");
	printf("<BODY CLASS='showlog'>\n");

	/* include user SSI header */
	include_ssi_files(SHOWLOG_CGI, SSI_HEADER);

	return;
	}
Beispiel #16
0
/* This function will check the last reboot status. If the reboot is HARD reboot or due to 
   power failure, it will send the last stored logs to the upload queue*/
void check_last_reboot(void)
{
	FILE *fp;
	char status[50], file_path[FILE_PATH_LENGTH], time_buf[50], cmd[250];
	memset(status, 0, sizeof(status));
	memset(file_path, 0, sizeof(file_path));
	memset(time_buf, 0, sizeof(time_buf));

	DEBUG("%s : checking last reboot status...\n", __func__);
	fp = fopen(SYSTEM_REBOOT_STATUS_FILE, "r");
	if(fp == NULL)
	{
		ERROR("%s : Unable to open file \"%s\". Returning...\n", __func__, SYSTEM_REBOOT_STATUS_FILE);
		return;
	}
	fscanf(fp, "%s", status);
	fclose(fp);

	if(file_is_present(SYSTEM_SERVER_LOG_FILE) == FAIL)
	{
		ERROR("%s : returning...\n", __func__);
		return;
	}

	get_time_string(time_buf);
	if(!strcmp(status, "system_server_test"))
	{
		DEBUG("%s : Last reboot was not normal... Sending the last system_server_test logs to upload queue...\n", __func__);
		sprintf(file_path, "%stest_%s.log", SYSTEM_LOG_PATH, time_buf);
		sprintf(cmd, "cp %s %s", SYSTEM_SERVER_LOG_FILE, file_path);
		system(cmd);

		sprintf(cmd, "echo 0>%s",SYSTEM_SERVER_LOG_FILE);
		system(cmd);

		enqueue_upload_file_list(LOG_FILE, file_path);
	}
	else if(!strcmp(status, "system_server"))
	{
		DEBUG("%s : Last reboot was not normal... Sending the last system_server logs to upload queue...\n", __func__);
		sprintf(file_path, "%ssystem_%s.log", SYSTEM_LOG_PATH, time_buf);
		sprintf(cmd, "cp %s %s", SYSTEM_SERVER_LOG_FILE, file_path);
		system(cmd);

		sprintf(cmd, "echo 0>%s",SYSTEM_SERVER_LOG_FILE);
		system(cmd);

		enqueue_upload_file_list(LOG_FILE, file_path);
	}
	else
	{
		DEBUG("%s : Last reboot was normal...\n", __func__);
	}
	return;
}
Beispiel #17
0
void menu_tape_control::populate()
{
	if (current_device())
	{
		// name of tape
		item_append(current_display_name().c_str(), current_device()->exists() ? current_device()->filename() : "No Tape Image loaded", current_display_flags(), TAPECMD_SELECT);

		if (current_device()->exists())
		{
			std::string timepos;
			cassette_state state;
			double t0 = current_device()->get_position();
			double t1 = current_device()->get_length();
			UINT32 tapeflags = 0;

			// state
			if (t1 > 0)
			{
				if (t0 > 0)
					tapeflags |= FLAG_LEFT_ARROW;
				if (t0 < t1)
					tapeflags |= FLAG_RIGHT_ARROW;
			}

			get_time_string(timepos, current_device(), nullptr, nullptr);
			state = current_device()->get_state();
			item_append(
						(state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED
						?   _("stopped")
						:   ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY
								? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? _("playing") : _("(playing)"))
								: ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? _("recording") : _("(recording)"))
								),
								timepos.c_str(),
						tapeflags,
						TAPECMD_SLIDER);

			// pause or stop
			item_append(_("Pause/Stop"), nullptr, 0, TAPECMD_STOP);

			// play
			item_append(_("Play"), nullptr, 0, TAPECMD_PLAY);

			// record
			item_append(_("Record"), nullptr, 0, TAPECMD_RECORD);

			// rewind
			item_append(_("Rewind"), nullptr, 0, TAPECMD_REWIND);

			// fast forward
			item_append(_("Fast Forward"), nullptr, 0, TAPECMD_FAST_FORWARD);
		}
	}
}
Beispiel #18
0
void document_header(void) {
	char date_time[MAX_DATETIME_LENGTH];
	time_t current_time;
	time_t expire_time;


	printf("Cache-Control: no-store\r\n");
	printf("Pragma: no-cache\r\n");

	time(&current_time);
	get_time_string(&current_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
	printf("Last-Modified: %s\r\n", date_time);

	expire_time = 0L;
	get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
	printf("Expires: %s\r\n", date_time);

	printf("Content-Type: x-world/x-vrml\r\n\r\n");

	return;
	}
Beispiel #19
0
local void Ctime(const char *cmd, const char *params, Player *p, const Target *target)
{
	Arena *arena = p->arena;
	int tout;
	timerdata *td = P_ARENA_DATA(arena, tdkey);
	char time_string[40];

	if (td->enabled)
	{
		tout = TICK_DIFF(td->timeout, current_ticks());
		get_time_string(tout, time_string);
		chat->SendMessage(p, "Time left: %s.", time_string);
	}
	else if (td->timeout)
	{
		 get_time_string(td->timeout, time_string);
		 chat->SendMessage(p, "Timer paused at: %s.", time_string);
	}
	else
		chat->SendMessage(p, "Time left: 0 seconds.");
}
Beispiel #20
0
void
logd::log_access( map<string,string> &map_request )
{
  //static int i_access_lines = wrap::CONF->get_elem("httpd.logging.access_lines");

  string s_time = get_time_string();
  string s_logstr = map_request["REMOTE_ADDR"] + " - - "+s_time+" \"" + map_request["QUERY_STRING"]+"\" 200 0 \""+map_request["request"]+"\" \""+map_request["User-Agent"]+"\"\n";

  s_queue.push(s_logstr);

  if ( s_queue.size() > i_lines )
    flush();

}
Beispiel #21
0
local void Cpausetimer(const char *cmd, const char *params, Player *p, const Target *target)
{
	Arena *arena = p->arena;
	timerdata *td = P_ARENA_DATA(arena, tdkey);
	char time_string[40];

	if (td->gamelen) return;

	if (td->enabled)
	{
		td->enabled = 0;
		td->timeout -= current_ticks();
		get_time_string(td->timeout, time_string);
		chat->SendMessage(p,"Timer paused at: %s.", time_string);
	}
	else if (td->timeout)
	{
		get_time_string(td->timeout, time_string);
		chat->SendMessage(p,"Timer resumed at: %s", time_string);
		td->enabled = 1;
		td->timeout += current_ticks();
	}
}
Beispiel #22
0
QVariant YearStatisticsItem::data(int column, int role) const
{
	double value;
	QVariant ret;

	if (role == Qt::FontRole) {
		QFont font = defaultModelFont();
		font.setBold(stats_interval.is_year);
		return font;
	} else if (role != Qt::DisplayRole) {
		return ret;
	}
	switch(column) {
	case YEAR:
		if (stats_interval.is_trip) {
			ret = stats_interval.location;
		} else {
			ret =  stats_interval.period;
		}
		break;
	case DIVES:		ret =  stats_interval.selection_size; break;
	case TOTAL_TIME:	ret = get_time_string(stats_interval.total_time.seconds, 0); break;
	case AVERAGE_TIME:	ret = get_minutes(stats_interval.total_time.seconds / stats_interval.selection_size); break;
	case SHORTEST_TIME:	ret = get_minutes(stats_interval.shortest_time.seconds); break;
	case LONGEST_TIME:	ret = get_minutes(stats_interval.longest_time.seconds); break;
	case AVG_DEPTH:		ret = get_depth_string(stats_interval.avg_depth); break;
	case MIN_DEPTH:		ret = get_depth_string(stats_interval.min_depth); break;
	case MAX_DEPTH:		ret = get_depth_string(stats_interval.max_depth); break;
	case AVG_SAC:		ret = get_volume_string(stats_interval.avg_sac); break;
	case MIN_SAC:		ret = get_volume_string(stats_interval.min_sac); break;
	case MAX_SAC:		ret = get_volume_string(stats_interval.max_sac); break;
	case AVG_TEMP:
		if (stats_interval.combined_temp && stats_interval.combined_count) {
			ret = QString::number(stats_interval.combined_temp / stats_interval.combined_count, 'f', 1);
		}
		break;
	case MIN_TEMP:
		value = get_temp_units(stats_interval.min_temp, NULL);
		if (value > -100.0)
			ret =  QString::number(value, 'f', 1);
		break;
	case MAX_TEMP:
		value = get_temp_units(stats_interval.max_temp, NULL);
		if (value > -100.0)
			ret =  QString::number(value, 'f', 1);
		break;
	}
	return ret;
}
Beispiel #23
0
static bool_t log_to_file(const char *file_name, const char* txt) {
	if (!file_name)
		return False;

	time_t _t = time(NULL);
	struct tm* t = localtime(&_t);
	std::string date(get_data_string(*t));
	std::string fullPath = PUB_cat_path(log_dir, date + file_name);
	std::ofstream of(fullPath.c_str(), std::ios::app);
	if (!of.is_open())
		return False;

	of << get_time_string(*t) << txt << std::endl;
	return True;
}
Beispiel #24
0
void status_bar_ui::set_current_time_label(unsigned int const current_position)
{
	unsigned int time_in_seconds = 0;
	if (current_num_ticks_per_second > 0)
	{
		time_in_seconds = current_position / current_num_ticks_per_second;

		unsigned int minutes = time_in_seconds / 60;
		unsigned int seconds = time_in_seconds % 60;

		current_playback_time->setText(get_time_string(minutes, seconds));
	}
	else
		current_playback_time->setText("");
}
int Indexer::save_index(const string& indexedDir)
{
	string tmpIndexDir = indexedDir;
	if(*(tmpIndexDir.end() - 1) != '/')
	{
		tmpIndexDir.append("/");
	}
	
	string timeStr;
	get_time_string(timeStr);
	string postingIndexFileAbsolutePath;
	postingIndexFileAbsolutePath.append(tmpIndexDir).append(timeStr).append("_indexed").append(".idx");

	string docSetFileAbsolutePath;
	docSetFileAbsolutePath.append(tmpIndexDir).append(timeStr).append("_indexed").append(".dst");

	fstream fsPostingIndex;
	fstream fsDocSet;

	fsPostingIndex.open(postingIndexFileAbsolutePath.c_str(), ios_base::out);
	if(fsPostingIndex.fail())
	{
		fsPostingIndex.close();
		cout<<postingIndexFileAbsolutePath<<" Open Failed"<<endl;

		return -1;
	}

	fsDocSet.open(docSetFileAbsolutePath.c_str(), ios_base::out);
	if(fsDocSet.fail())
	{
		fsDocSet.close();
		cout<<docSetFileAbsolutePath<<" Open Failed"<<endl;

		return -1;
	}

	boost::archive::text_oarchive oaPostingIndex(fsPostingIndex);
	boost::archive::text_oarchive oaDocSet(fsDocSet);

	oaPostingIndex<<m_postingIndex;
	oaDocSet<<m_docSet;

	fsPostingIndex.close();
	fsDocSet.close();

	return 0;
}
Beispiel #26
0
void
logd::log_simple_line( string s_line )
{
  // Dont log empty lines!
  if (s_line.empty())
    return;

  string s_time = get_time_string();
  string s_logstr = s_time + " " + s_line;

  s_queue.push(s_logstr);

  if ( s_queue.size() > i_lines )
    flush();

}
Beispiel #27
0
int execute_and_create_process(struct subprocess* process, struct inotify_event* event, char *command) { //Execute command using wrapper function.
	process->start_time=(char*)malloc(sizeof(char)*9);
	strcpy(process->start_time,get_time_string());
	int pid=exec_pipe(command,0);
	if (pid==-1) {
		return -1;
	}
	process->pid=pid;
	process->retries=0;
	process->command=(char *)malloc(sizeof(char)*strlen(command));
	process->event=event;
	process->prev=NULL;
	process->next=NULL;
	strcpy(process->command,command);
	process->path=(char *)malloc(sizeof(char)*(strlen(global_wd_list[event->wd]->path)+strlen(event->name)+2));
	sprintf(process->path,"%s/%s",global_wd_list[event->wd]->path,event->name);
	add_list_element(process);
	return pid;
}
Beispiel #28
0
static void
set_header(pConnInfo conn_info) {
    char *time_string = get_time_string(NULL);
    conn_info->response_header->http_ver = "HTTP/1.1";
    conn_info->response_header->status_code = 200;
    conn_info->response_header->status = "OK";
    add_header_param("Cache-Control", "private", conn_info->response_header);
    add_header_param("Connection", "Keep-Alive", conn_info->response_header);
    add_header_param("Vary", "Accept-Encoding", conn_info->response_header);
    add_header_param("Server", UWS_SERVER, conn_info->response_header);
    add_header_param("Date", time_string, conn_info->response_header);

    char *len = itoa(header_body.content_len);
    add_header_param("Content-Length", len, conn_info->response_header);
    uws_free(len);

    add_header_param("Content-Type", mime, conn_info->response_header);
    header_body.header = conn_info->response_header;
    uws_free(time_string);
}
Beispiel #29
0
void		get_id(t_tree *tree, t_tree *ref, t_data *data)
{
	struct passwd	*uid;
	struct group	*gid;
	char			*s_len;

	s_len = ft_itoa(tree->stat.st_size);
	uid = getpwuid(tree->stat.st_uid);
	gid = getgrgid(tree->stat.st_gid);
	tree->uid = ft_strdup(uid->pw_name);
	tree->gid = ft_strdup(gid->gr_name);
	if (ft_strlen(tree->uid) > (size_t)ref->owner_len)
		ref->owner_len = ft_strlen(tree->uid);
	if (ft_strlen(tree->gid) > (size_t)ref->group_len)
		ref->group_len = ft_strlen(tree->gid);
	if (ft_strlen(s_len) > (size_t)ref->size_len)
		ref->size_len = ft_strlen(s_len);
	free(s_len);
	get_time_string(tree, data);
}
Beispiel #30
0
/*
 * @brief 处理当前目录下所有标记为N的文件
 * @param DIR *dir:目录指针; char *folder:目录名; char *file:当前文件名
 * @return	0表示处理成功且有新文件,可继续处理; -1表示处理失败,或处理成功但没有新文件,可休眠。
 */
int processdir(DIR *dir)
{
	struct dirent 	*ptr;
	int retv;
	char fullpath[FULL_PATH_LEN];

	while ((ptr = readdir(dir)) != NULL) {
		if (ptr->d_name[0]=='N') {
			snprintf(fullpath, FULL_PATH_LEN, "%s/%s", data_store_path, ptr->d_name);
			get_time_string();
			retv = send_2_server(fullpath);
			if (retv >= 0) {
				//ret =0 ok! 1 bad files
				remove(fullpath);
			} else {
				//ret -1, can't send file, then return and have a rest
				return -1;
			}
		}//if
	}//while
	return 0;
}