Crossfire Client, Trunk
metaserver.c File Reference
#include "client.h"
#include "metaserver.h"
+ Include dependency graph for metaserver.c:

Go to the source code of this file.

Data Structures

struct  mbuf
 

Functions

static size_t mbuf_write (void *contents, size_t size, size_t nmemb, void *userp)
 
static bool ms_check_version (Meta_Info *server)
 
void ms_fetch (ms_callback callback)
 
static bool ms_fetch_server (const char *metaserver2, ms_callback callback)
 
void ms_init ()
 
static void parse_meta (char inbuf[static 1], ms_callback callback)
 

Variables

static const char * metaservers []
 

Detailed Description

Deals with contacting the metaserver, getting a list of hosts, displaying and returning them to calling function, and then connecting to the server when requested.

Definition in file metaserver.c.

Function Documentation

◆ mbuf_write()

static size_t mbuf_write ( void *  contents,
size_t  size,
size_t  nmemb,
void *  userp 
)
static

Curl write callback function for downloading data into memory instead of a file. Copied from Curl's 'getinmemory.c' example under the MIT License.

Definition at line 55 of file metaserver.c.

References mbuf::memory, and mbuf::size.

Referenced by ms_fetch_server().

+ Here is the caller graph for this function:

◆ ms_check_version()

static bool ms_check_version ( Meta_Info server)
static

This checks the servers sc_version and cs_version to see if they are compatible.

Parameters
entryentry number in the metaservers array to check.
Returns
1 if this entry is compatible, 0 if it is not. Note that this can only meaningfully check metaserver2 data - metaserver1 doesn't include protocol version number, so treats all of those as OK.

Definition at line 85 of file metaserver.c.

References Meta_Info::cs_version, Meta_Info::sc_version, VERSION_CS, and VERSION_SC.

Referenced by parse_meta().

+ Here is the caller graph for this function:

◆ ms_fetch()

void ms_fetch ( ms_callback  callback)

Fetch a list of servers from the built-in official metaservers.

Because this function can query multiple metaservers, the same servers may be listed multiple times in the results.

Definition at line 269 of file metaserver.c.

References metaservers, and ms_fetch_server().

Referenced by main(), and server_fetch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ms_fetch_server()

static bool ms_fetch_server ( const char *  metaserver2,
ms_callback  callback 
)
static

Fetch a list of servers from the given URL.

Parameters
metaserver2
Returns

Definition at line 223 of file metaserver.c.

References mbuf_write(), mbuf::memory, parse_meta(), and mbuf::size.

Referenced by ms_fetch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ms_init()

void ms_init ( )

Initialize metaserver client. This function should be called before any other metaserver functions.

Definition at line 257 of file metaserver.c.

Referenced by client_init(), and main().

+ Here is the caller graph for this function:

◆ parse_meta()

Variable Documentation

◆ metaservers

const char* metaservers[]
static
Initial value:
= {
"http://crossfire.real-time.com/metaserver2/meta_client.php",
"http://metaserver.eu.cross-fire.org/meta_client.php",
"http://metaserver.us.cross-fire.org/meta_client.php",
}

Definition at line 37 of file metaserver.c.

Referenced by ms_fetch().