Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/servers.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
servers.h
Go to the documentation of this file.
1/**********************************************************************
2 Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifndef FC__SERVERS_H
15#define FC__SERVERS_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21/* utility */
22#include "fcthread.h"
23
24#define SERVER_LAN_PORT 4555
25#define SERVER_LAN_TTL 1
26#define SERVER_LAN_VERSION 2
27
28 struct server
29{
30 char *host;
31 int port;
32 char *capability;
33 char *patches;
34 char *version;
35 char *state;
36 char *topic;
37 char *message;
38
39 struct players
40 {
41 char *name;
42 char *type;
43 char *host;
44 char *nation;
45 } *players;
46
47 int nplayers;
48 int humans;
49};
50
51#define SPECLIST_TAG server
52#define SPECLIST_TYPE struct server
53#include "speclist.h"
54
55#define server_list_iterate(serverlist, pserver) \
56 TYPED_LIST_ITERATE(struct server, serverlist, pserver)
57#define server_list_iterate_end LIST_ITERATE_END
58
59struct server_scan;
60
61 struct srv_list
62{
63 struct server_list *servers;
64 fc_mutex mutex;
65};
66
67 enum server_scan_type {
68 SERVER_SCAN_LOCAL, /* Local servers, detected through a LAN scan */
69 SERVER_SCAN_GLOBAL, /* Global servers, read from the metaserver */
70 SERVER_SCAN_LAST
71};
72
73 typedef void (*ServerScanErrorFunc)(struct server_scan *scan,
74 const char *message);
75
76struct server_scan *server_scan_begin(enum server_scan_type type,
77 ServerScanErrorFunc error_func);
78enum server_scan_type server_scan_get_type(const struct server_scan *scan);
79 enum server_scan_status {
80 SCAN_STATUS_ERROR = 0,
81 SCAN_STATUS_WAITING,
82 SCAN_STATUS_PARTIAL,
83 SCAN_STATUS_DONE,
84 SCAN_STATUS_ABORT
85};
86enum server_scan_status server_scan_poll(struct server_scan *scan);
87struct srv_list *
88 server_scan_get_list(struct server_scan *scan);
89void server_scan_finish(struct server_scan *scan);
90
91#ifdef __cplusplus
92}
93#endif /* __cplusplus */
94
95#endif /* FC__SERVERS_H */
fcthread.h
type
GType type
Definition repodlgs.c:1312
server_list
static struct server_list * server_list
Definition connectdlg.c:61
server_scan_get_list
struct srv_list * server_scan_get_list(struct server_scan *scan)
Definition servers.c:855
server_scan_finish
void server_scan_finish(struct server_scan *scan)
Definition servers.c:868
server_scan_begin
struct server_scan * server_scan_begin(enum server_scan_type type, ServerScanErrorFunc error_func)
Definition servers.c:744
server_scan_status
server_scan_status
Definition servers.h:79
SCAN_STATUS_WAITING
@ SCAN_STATUS_WAITING
Definition servers.h:81
SCAN_STATUS_ABORT
@ SCAN_STATUS_ABORT
Definition servers.h:84
SCAN_STATUS_PARTIAL
@ SCAN_STATUS_PARTIAL
Definition servers.h:82
SCAN_STATUS_ERROR
@ SCAN_STATUS_ERROR
Definition servers.h:80
SCAN_STATUS_DONE
@ SCAN_STATUS_DONE
Definition servers.h:83
server_scan_type
server_scan_type
Definition servers.h:67
SERVER_SCAN_LOCAL
@ SERVER_SCAN_LOCAL
Definition servers.h:68
SERVER_SCAN_LAST
@ SERVER_SCAN_LAST
Definition servers.h:70
SERVER_SCAN_GLOBAL
@ SERVER_SCAN_GLOBAL
Definition servers.h:69
server_scan_get_type
enum server_scan_type server_scan_get_type(const struct server_scan *scan)
Definition servers.c:798
ServerScanErrorFunc
void(* ServerScanErrorFunc)(struct server_scan *scan, const char *message)
Definition servers.h:73
server_scan_poll
enum server_scan_status server_scan_poll(struct server_scan *scan)
Definition servers.c:821
speclist.h
message
Definition messagewin_common.h:29
server::players
Definition servers.h:40
server::players::host
char * host
Definition servers.h:43
server::players::name
char * name
Definition servers.h:41
server::players::nation
char * nation
Definition servers.h:44
server::players::type
char * type
Definition servers.h:42
server_scan
Definition servers.c:83
server_scan::error_func
ServerScanErrorFunc error_func
Definition servers.c:85
server
Definition servers.h:29
server::capability
char * capability
Definition servers.h:32
server::patches
char * patches
Definition servers.h:33
server::humans
int humans
Definition servers.h:48
server::host
char * host
Definition servers.h:30
server::version
char * version
Definition servers.h:34
server::message
char * message
Definition servers.h:37
server::state
char * state
Definition servers.h:35
server::port
int port
Definition servers.h:31
server::topic
char * topic
Definition servers.h:36
server::nplayers
int nplayers
Definition servers.h:47
srv_list
Definition servers.h:62
srv_list::mutex
fc_mutex mutex
Definition servers.h:64
srv_list::servers
struct server_list * servers
Definition servers.h:63