コード例 #1
0
ファイル: dialogs.c プロジェクト: ohmori7/kcn-tools
static unsigned char *
get_cache_entry_info(struct listbox_item *item, struct terminal *term)
{
	struct cache_entry *cached = item->udata;
	struct string msg;

	if (item->type == BI_FOLDER) return NULL;
	if (!init_string(&msg)) return NULL;

	add_to_string(&msg, _("URL", term));
	add_to_string(&msg, ": ");
	add_uri_to_string(&msg, cached->uri, URI_PUBLIC);

	/* No need to use compare_uri() here we only want to check whether they
	 * point to the same URI. */
	if (cached->proxy_uri != cached->uri) {
		add_format_to_string(&msg, "\n%s: ", _("Proxy URL", term));
		add_uri_to_string(&msg, cached->proxy_uri, URI_PUBLIC);
	}

	if (cached->redirect) {
		add_format_to_string(&msg, "\n%s: ", _("Redirect", term));
		add_uri_to_string(&msg, cached->redirect, URI_PUBLIC);

		if (cached->redirect_get) {
			add_to_string(&msg, " (GET)");
		}
	}

	add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT, _("Size", term),
	                     cached->length);
	add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT, _("Loaded size", term),
						cached->data_size);
	if (cached->content_type) {
		add_format_to_string(&msg, "\n%s: %s", _("Content type", term),
				     cached->content_type);
	}
	if (cached->last_modified) {
		add_format_to_string(&msg, "\n%s: %s", _("Last modified", term),
				     cached->last_modified);
	}
	if (cached->etag) {
		add_format_to_string(&msg, "\n%s: %s", "ETag",
						cached->etag);
	}
	if (cached->ssl_info) {
		add_format_to_string(&msg, "\n%s: %s", _("SSL Cipher", term),
						cached->ssl_info);
	}
	if (cached->encoding_info) {
		add_format_to_string(&msg, "\n%s: %s", _("Encoding", term),
						cached->encoding_info);
	}

	if (cached->incomplete || !cached->valid) {
		add_char_to_string(&msg, '\n');
		add_to_string(&msg, _("Flags", term));
		add_to_string(&msg, ": ");
		if (cached->incomplete) {
			add_to_string(&msg, _("incomplete", term));
			add_char_to_string(&msg, ' ');
		}
		if (!cached->valid) add_to_string(&msg, _("invalid", term));
	}

#ifdef HAVE_STRFTIME
	if (cached->expire) {
		time_t expires = timeval_to_seconds(&cached->max_age);

		add_format_to_string(&msg, "\n%s: ", _("Expires", term));
		add_date_to_string(&msg, get_opt_str("ui.date_format"), &expires);
	}
#endif
#ifdef CONFIG_DEBUG
	add_format_to_string(&msg, "\n%s: %d", "Refcount", get_object_refcount(cached));
	add_format_to_string(&msg, "\n%s: %u", _("ID", term), cached->id);

	if (cached->head && *cached->head) {
		add_format_to_string(&msg, "\n%s:\n\n%s", _("Header", term),
				     cached->head);
	}
#endif

	return msg.source;
}
コード例 #2
0
ファイル: server.c プロジェクト: kekyo/xpilot-ng
void Main_loop(void)
{
    struct timeval tv1, tv2;
    double t1, t2;

    gettimeofday(&tv1, NULL);

    main_loops++;

    if ((main_loops & 0x3F) == 0)
	Meta_update(false);

    /*
     * Check for possible shutdown, the server will
     * shutdown when ShutdownServer (a counter) reaches 0.
     * If the counter is < 0 then no shutdown is in progress.
     */
    if (ShutdownServer >= 0) {
	if (ShutdownServer == 0)
	    End_game();
	else
	    ShutdownServer--;
    }

    Input();

    if (NumPlayers > NumRobots + NumPseudoPlayers || options.RawMode) {

	if (NoPlayersEnteredYet) {
	    if (NumPlayers > NumRobots + NumPseudoPlayers) {
		NoPlayersEnteredYet = false;
		if (options.gameDuration > 0.0) {
		    xpprintf("%s Server will stop in %g minutes.\n",
			     showtime(), options.gameDuration);
		    gameOverTime
			= (time_t)(options.gameDuration * 60) + time(NULL);
		}
	    }
	}

	Update_objects();

	if ((main_loops % CONF_UPDATES_PR_FRAME) == 0)
	    Frame_update();
    }

    if (!options.NoQuit
	&& NumPlayers == NumRobots + NumPseudoPlayers
	&& !login_in_progress
	&& !NumQueuedPlayers) {

	if (!NoPlayersEnteredYet)
	    End_game();

	if (serverStartTime + 5*60 < time(NULL)) {
	    error("First player has yet to show his butt, I'm bored... Bye!");
	    Log_game("NOSHOW");
	    End_game();
	}
    }

    playback = record = 0;
    Queue_loop();
    playback = rplayback;
    record = rrecord;

    if (playback && (*playback_ei == main_loops)) {
	char *a, *b, *c, *d, *e;
	int i;
	unsigned j;
	a = playback_es;
	while (*playback_es++);
	b = playback_es;
	while (*playback_es++);
	c = playback_es;
	while (*playback_es++);
	d = playback_es;
	while (*playback_es++);
	e = playback_es;
	while (*playback_es++);
	playback_ei++;
	i = *playback_ei++;
	j = *playback_ei++;
	Setup_connection(a, b, c, i, d, e, j);
    }

    gettimeofday(&tv2, NULL);
    t1 = timeval_to_seconds(&tv1);
    t2 = timeval_to_seconds(&tv2);
    options.mainLoopTime = (t2 - t1) * 1e3;
}
コード例 #3
0
ファイル: conv.c プロジェクト: rkd77/elinks-tv
/** @relates string */
struct string *
add_timeval_to_string(struct string *string, timeval_T *timeval)
{
	return add_duration_to_string(string, timeval_to_seconds(timeval));
}
コード例 #4
0
ファイル: dialogs.c プロジェクト: Efreak/elinks
static unsigned char *
get_cache_entry_info(struct listbox_item *item, struct terminal *term)
{
	struct cache_entry *cached = item->udata;
	struct string msg;

	if (item->type == BI_FOLDER) return NULL;
	if (!init_string(&msg)) return NULL;

	add_to_string(&msg, _("URL", term));
	add_to_string(&msg, ": ");
	add_uri_to_string(&msg, cached->uri, URI_PUBLIC);

	/* No need to use compare_uri() here we only want to check whether they
	 * point to the same URI. */
	if (cached->proxy_uri != cached->uri) {
		add_format_to_string(&msg, "\n%s: ", _("Proxy URL", term));
		add_uri_to_string(&msg, cached->proxy_uri, URI_PUBLIC);
	}

	if (cached->redirect) {
		add_format_to_string(&msg, "\n%s: ", _("Redirect", term));
		add_uri_to_string(&msg, cached->redirect, URI_PUBLIC);

		if (cached->redirect_get) {
			add_to_string(&msg, " (GET)");
		}
	}

	add_format_to_string(&msg, "\n%s: %" OFF_PRINT_FORMAT, _("Size", term),
			     (off_print_T) cached->length);
	add_format_to_string(&msg, "\n%s: %" OFF_PRINT_FORMAT, _("Loaded size", term),
			     (off_print_T) cached->data_size);
	if (cached->content_type) {
		add_format_to_string(&msg, "\n%s: %s", _("Content type", term),
				     cached->content_type);
	}
	if (cached->last_modified) {
		add_format_to_string(&msg, "\n%s: %s", _("Last modified", term),
				     cached->last_modified);
	}
	if (cached->etag) {
		add_format_to_string(&msg, "\n%s: %s", "ETag",
						cached->etag);
	}
	if (cached->ssl_info) {
		add_format_to_string(&msg, "\n%s: %s", _("SSL Cipher", term),
						cached->ssl_info);
	}
	if (cached->encoding_info) {
		add_format_to_string(&msg, "\n%s: %s", _("Encoding", term),
						cached->encoding_info);
	}

	if (cached->incomplete || !cached->valid) {
		add_char_to_string(&msg, '\n');
		add_to_string(&msg, _("Flags", term));
		add_to_string(&msg, ": ");
		if (cached->incomplete) {
			add_to_string(&msg, _("incomplete", term));
			add_char_to_string(&msg, ' ');
		}
		if (!cached->valid) add_to_string(&msg, _("invalid", term));
	}

#ifdef HAVE_STRFTIME
	if (cached->expire) {
		time_t expires = timeval_to_seconds(&cached->max_age);

		add_format_to_string(&msg, "\n%s: ", _("Expires", term));
		add_date_to_string(&msg, get_opt_str("ui.date_format", NULL), &expires);
	}
#endif

	add_format_to_string(&msg, "\n%s: ", _("Cache mode", term));
	switch (cached->cache_mode) {
	case CACHE_MODE_NEVER:
		add_to_string(&msg, _("never use cache entry", term));
		break;
	case CACHE_MODE_ALWAYS:
		add_to_string(&msg, _("always use cache entry", term));
		break;
	case CACHE_MODE_INCREMENT:
	case CACHE_MODE_NORMAL:
	case CACHE_MODE_CHECK_IF_MODIFIED:
	case CACHE_MODE_FORCE_RELOAD:
		/* Cache entries only use two values of enum cache_mode. */
		INTERNAL("cached->cache_mode = %d", cached->cache_mode);
		break;
	}

#ifdef CONFIG_DEBUG
	add_format_to_string(&msg, "\n%s: %d", "Refcount", get_object_refcount(cached));
	add_format_to_string(&msg, "\n%s: %u", _("ID", term), cached->cache_id);

	if (cached->head && *cached->head) {
		add_format_to_string(&msg, "\n%s:\n\n%s", _("Header", term),
				     cached->head);
	}
#endif

	return msg.source;
}