Crossfire Client, Branch
R11627
|
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <client.h>
#include <cconfig.h>
#include <external.h>
#include <metaserver.h>
Go to the source code of this file.
Functions | |
int | check_server_version (int entry) |
static int | get_metaserver2_data (char *metaserver2) |
Connects to the URL and gets metaserver data. | |
void | init_metaserver (void) |
Does single use initalization of metaserver2 variables. | |
int | metaserver1_get_info (void) |
void * | metaserver1_thread (void *junk) |
int | metaserver2_get_info (void) |
this is basically a replacement to the metaserver_get_info - idea being that when metaserver 1 support goes away, just yank that entire function and replace it with this. | |
void * | metaserver2_thread (void *junk) |
Thread function that goes off and collects metaserver data. | |
size_t | metaserver2_writer (void *ptr, size_t size, size_t nmemb, void *data) |
Curle doesn't really have any built in way to get data from the URL into string data - instead, we get a blob of data which we need to find the newlines, etc from. | |
int | metaserver_check_status (void) |
Sees if we are gathering data or not. | |
int | metaserver_get_info (char *metaserver, int meta_port) |
static void | metaserver_load_cache (void) |
static void | metaserver_save_cache (void) |
int | metaserver_select (char *sel) |
void | metaserver_show (int show_selection) |
Variables | |
const char * | cached_server_file = NULL |
char * | cached_servers_ip [CACHED_SERVERS_MAX] |
static int | cached_servers_loaded = 0 |
char * | cached_servers_name [CACHED_SERVERS_MAX] |
int | cached_servers_num = 0 |
int | meta_numservers = 0 |
Meta_Info * | meta_servers = NULL |
static char * | metaservers [] = {"http://crossfire.real-time.com/metaserver2/meta_client.php"} |
static int | ms1_is_running = 0 |
pthread_mutex_t | ms2_info_mutex |
static int | ms2_is_running = 0 |
const char *const | rcsid_common_metaserver_c = "$Id: metaserver.c 11626 2009-04-04 12:41:46Z lalo $" |
int check_server_version | ( | int | entry | ) |
Definition at line 69 of file metaserver.c.
References VERSION_CS, and VERSION_SC.
Referenced by get_metaserver(), and metaserver_show().
static int get_metaserver2_data | ( | char * | metaserver2 | ) | [static] |
Connects to the URL and gets metaserver data.
metaserver2 | metaserver to connect to. |
Definition at line 369 of file metaserver.c.
References metaserver2_writer().
Referenced by metaserver2_thread().
void init_metaserver | ( | void | ) |
Does single use initalization of metaserver2 variables.
Definition at line 459 of file metaserver.c.
References ms2_info_mutex.
Referenced by init_client_vars().
int metaserver1_get_info | ( | void | ) |
Definition at line 729 of file metaserver.c.
References LOG(), LOG_ERROR, MAX_METASERVER, metaserver1_thread(), metaserver_load_cache(), metaserver_on, ms1_is_running, and ms2_info_mutex.
Referenced by metaserver_get_info().
void* metaserver1_thread | ( | void * | junk | ) |
Definition at line 548 of file metaserver.c.
References draw_info(), Meta_Info::hostname, Meta_Info::idle_time, Meta_Info::ip_addr, LOG(), LOG_WARNING, MAX_METASERVER, meta_numservers, meta_port, meta_server, meta_sort(), ms1_is_running, ms2_info_mutex, MS_LARGE_BUF, NDI_BLACK, Meta_Info::num_players, Meta_Info::text_comment, and Meta_Info::version.
Referenced by metaserver1_get_info().
int metaserver2_get_info | ( | void | ) |
this is basically a replacement to the metaserver_get_info - idea being that when metaserver 1 support goes away, just yank that entire function and replace it with this.
Definition at line 423 of file metaserver.c.
References LOG(), LOG_ERROR, MAX_METASERVER, metaserver2_on, metaserver2_thread(), metaserver_load_cache(), ms2_info_mutex, and ms2_is_running.
Referenced by metaserver_get_info().
void* metaserver2_thread | ( | void * | junk | ) |
Thread function that goes off and collects metaserver data.
Definition at line 397 of file metaserver.c.
References get_metaserver2_data(), meta_numservers, meta_sort(), metaservers, ms2_info_mutex, and ms2_is_running.
Referenced by metaserver2_get_info().
size_t metaserver2_writer | ( | void * | ptr, |
size_t | size, | ||
size_t | nmemb, | ||
void * | data | ||
) |
Curle doesn't really have any built in way to get data from the URL into string data - instead, we get a blob of data which we need to find the newlines, etc from.
Curl also provides the data in multiple calls if there is lots of data, and does not break the data on newline, so we need to store the extra (unprocessed) data from one call to the next.
ptr | pointer to data to process. |
size | |
nmemb | the size of each piece of data, and the number of these elements. We always presume the data is byte sized, and just multiple these together to get total amount of data. |
data | user supplied data pointer - in this case, it points to a buffer which is used to store unprocessed information from one call to the next. |
Definition at line 214 of file metaserver.c.
References Meta_Info::cs_version, Meta_Info::idle_time, Meta_Info::in_bytes, LOG(), LOG_CRITICAL, LOG_ERROR, meta_numservers, ms2_info_mutex, Meta_Info::num_players, Meta_Info::out_bytes, Meta_Info::port, Meta_Info::sc_version, and Meta_Info::uptime.
Referenced by get_metaserver2_data().
int metaserver_check_status | ( | void | ) |
Sees if we are gathering data or not.
Note that we don't have to check to see what update methods are being used - the is_running flag is initialized to zero no matter if we are using that method to get the data, and unless we are using ms1 or ms2, the is_running flag will never get changed to be non-zero.
Definition at line 774 of file metaserver.c.
References ms1_is_running, ms2_info_mutex, and ms2_is_running.
Referenced by get_metaserver(), and metaserver_show().
int metaserver_get_info | ( | char * | metaserver, |
int | meta_port | ||
) |
Definition at line 791 of file metaserver.c.
References meta_numservers, metaserver1_get_info(), metaserver2_get_info(), and metaserver_on.
Referenced by do_metaserver(), main(), and metaserver_select().
static void metaserver_load_cache | ( | void | ) | [static] |
Definition at line 110 of file metaserver.c.
References cached_server_file, cached_servers_ip, cached_servers_loaded, CACHED_SERVERS_MAX, cached_servers_name, cached_servers_num, MS_LARGE_BUF, and name.
Referenced by metaserver1_get_info(), and metaserver2_get_info().
static void metaserver_save_cache | ( | void | ) | [static] |
Definition at line 144 of file metaserver.c.
References cached_server_file, cached_servers_ip, cached_servers_name, cached_servers_num, and server.
Referenced by metaserver_select().
int metaserver_select | ( | char * | sel | ) |
Definition at line 861 of file metaserver.c.
References cached_servers_ip, CACHED_SERVERS_MAX, cached_servers_name, cached_servers_num, CONFIG_PORT, csocket, draw_info(), ClientSocket::fd, Meta_Info::hostname, init_connection(), Meta_Info::ip_addr, MAX_BUF, meta_numservers, meta_server, metaserver_get_info(), metaserver_save_cache(), metaserver_show(), MIN, ms2_info_mutex, name, NDI_BLACK, Meta_Info::port, server, TRUE, and use_config.
Referenced by main().
void metaserver_show | ( | int | show_selection | ) |
Definition at line 807 of file metaserver.c.
References cached_servers_ip, cached_servers_name, cached_servers_num, check_server_version(), draw_info(), meta_numservers, meta_sort(), metaserver_check_status(), ms2_info_mutex, NDI_BLACK, and server.
Referenced by do_metaserver(), main(), and metaserver_select().
const char* cached_server_file = NULL |
Definition at line 107 of file metaserver.c.
Referenced by main(), metaserver_load_cache(), and metaserver_save_cache().
Definition at line 105 of file metaserver.c.
Referenced by get_metaserver(), metaserver_load_cache(), metaserver_save_cache(), metaserver_select(), and metaserver_show().
int cached_servers_loaded = 0 [static] |
Definition at line 106 of file metaserver.c.
Referenced by metaserver_load_cache().
Definition at line 104 of file metaserver.c.
Referenced by get_metaserver(), metaserver_load_cache(), metaserver_save_cache(), metaserver_select(), and metaserver_show().
int cached_servers_num = 0 |
Definition at line 103 of file metaserver.c.
Referenced by get_metaserver(), metaserver_load_cache(), metaserver_save_cache(), metaserver_select(), and metaserver_show().
int meta_numservers = 0 |
Definition at line 57 of file metaserver.c.
Referenced by get_metaserver(), metaserver1_thread(), metaserver2_thread(), metaserver2_writer(), metaserver_get_info(), metaserver_select(), and metaserver_show().
Meta_Info* meta_servers = NULL |
Definition at line 55 of file metaserver.c.
Referenced by get_metaserver().
char* metaservers[] = {"http://crossfire.real-time.com/metaserver2/meta_client.php"} [static] |
Definition at line 188 of file metaserver.c.
Referenced by metaserver2_thread().
int ms1_is_running = 0 [static] |
Definition at line 478 of file metaserver.c.
Referenced by metaserver1_get_info(), metaserver1_thread(), and metaserver_check_status().
pthread_mutex_t ms2_info_mutex |
Definition at line 171 of file metaserver.c.
Referenced by get_metaserver(), init_metaserver(), metaserver1_get_info(), metaserver1_thread(), metaserver2_get_info(), metaserver2_thread(), metaserver2_writer(), metaserver_check_status(), metaserver_select(), and metaserver_show().
int ms2_is_running = 0 [static] |
Definition at line 178 of file metaserver.c.
Referenced by metaserver2_get_info(), metaserver2_thread(), and metaserver_check_status().
const char* const rcsid_common_metaserver_c = "$Id: metaserver.c 11626 2009-04-04 12:41:46Z lalo $" |
Definition at line 1 of file metaserver.c.