Crossfire Client, Trunk  R18666
Functions | Variables
/home/leaf/crossfire/client/trunk/common/metaserver.c File Reference
#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>
Include dependency graph for metaserver.c:

Go to the source code of this file.

Functions

int meta_sort (Meta_Info *m1, Meta_Info *m2)
int check_server_version (int entry)
void metaserver_update_cache (const char *server_name, const char *server_ip)
size_t metaserver2_writer (void *ptr, size_t size, size_t nmemb, void *data)
void * metaserver2_thread (void *junk)
int metaserver2_get_info (void)
void init_metaserver (void)
void * metaserver1_thread (void *junk)
int metaserver1_get_info (void)
int metaserver_check_status (void)
int metaserver_get_info (char *metaserver, int meta_port)
void metaserver_show (int show_selection)
int metaserver_select (char *sel)

Variables

const char *const rcsid_common_metaserver_c = "$Id: metaserver.c 15072 2011-09-10 10:59:18Z ryo_saeba $"
Meta_Infometa_servers = NULL
int meta_numservers = 0
int cached_servers_num = 0
char * cached_servers_name [CACHED_SERVERS_MAX]
char * cached_servers_ip [CACHED_SERVERS_MAX]
const char * cached_server_file = NULL
pthread_mutex_t ms2_info_mutex

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

int check_server_version ( int  entry)

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 72 of file metaserver.c.

Here is the caller graph for this function:

void init_metaserver ( void  )

Does single use initalization of metaserver2 variables.

Definition at line 541 of file metaserver.c.

Here is the caller graph for this function:

int meta_sort ( Meta_Info m1,
Meta_Info m2 
)

Definition at line 59 of file metaserver.c.

Here is the caller graph for this function:

int metaserver1_get_info ( void  )

Definition at line 820 of file metaserver.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void* metaserver1_thread ( void *  junk)

Definition at line 636 of file metaserver.c.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Returns:
best I can tell, always returns 0

Definition at line 507 of file metaserver.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void* metaserver2_thread ( void *  junk)

Thread function that goes off and collects metaserver data.

Returns:
exits when job is done, no return value.

Definition at line 479 of file metaserver.c.

Here is the call graph for this function:

Here is the caller graph for this function:

size_t metaserver2_writer ( void *  ptr,
size_t  size,
size_t  nmemb,
void *  data 
)

Curl 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.

Parameters:
ptrpointer to data to process.
size
nmembthe 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.
datauser supplied data pointer - in this case, it points to a buffer which is used to store unprocessed information from one call to the next.
Returns:
Number of bytes processed. We always return the total number of bytes supplied - returning anything else is an error to CURL

Definition at line 295 of file metaserver.c.

Here is the call graph for this function:

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.

Returns:
Returns 1 if if we are getting data, 0 if nothing is going on right now.

Definition at line 865 of file metaserver.c.

Here is the caller graph for this function:

int metaserver_get_info ( char *  metaserver,
int  meta_port 
)

This contacts the metaserver and gets the list of servers. returns 0 on success, 1 on failure. Errors will get dumped to stderr, so most errors should be reasonably clear. metaserver and meta_port are the server name and port number to connect to.

Definition at line 882 of file metaserver.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int metaserver_select ( char *  sel)

String contains the selection that the player made for the metaserver. this may not be a a selection, but could be a host name or ip address. this returns 0 on sucessful selection, 1 if failure (invalid selection or the like.

Definition at line 964 of file metaserver.c.

Here is the call graph for this function:

void metaserver_show ( int  show_selection)

Show the metaservers to the player. We use draw_ext_info() to do that, and also let the player know they can enter their own host name.

Definition at line 899 of file metaserver.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void metaserver_update_cache ( const char *  server_name,
const char *  server_ip 
)

Add a server to the players server cache file.

Parameters:
server_name
server_ip

Definition at line 178 of file metaserver.c.

Here is the caller graph for this function:


Variable Documentation

const char* cached_server_file = NULL

Definition at line 110 of file metaserver.c.

Definition at line 108 of file metaserver.c.

Definition at line 107 of file metaserver.c.

Definition at line 106 of file metaserver.c.

int meta_numservers = 0

Definition at line 57 of file metaserver.c.

Definition at line 55 of file metaserver.c.

pthread_mutex_t ms2_info_mutex

Definition at line 252 of file metaserver.c.

const char* const rcsid_common_metaserver_c = "$Id: metaserver.c 15072 2011-09-10 10:59:18Z ryo_saeba $"

Definition at line 1 of file metaserver.c.