Stop sharing requirement_unit_state_ereq().
[freeciv.git] / client / servers.h
blob07fbfd5063d06f5cee30e4558df2de40a0ae7c02
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.
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 ***********************************************************************/
14 #ifndef FC__SERVERS_H
15 #define FC__SERVERS_H
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
21 /* utility */
22 #include "fcthread.h"
24 #define SERVER_LAN_PORT 4555
25 #define SERVER_LAN_TTL 1
26 #define SERVER_LAN_VERSION 2
28 struct server
30 char *host;
31 int port;
32 char *capability;
33 char *patches;
34 char *version;
35 char *state;
36 char *topic;
37 char *message;
39 struct players
41 char *name;
42 char *type;
43 char *host;
44 char *nation;
45 } *players;
47 int nplayers;
48 int humans;
51 #define SPECLIST_TAG server
52 #define SPECLIST_TYPE struct server
53 #include "speclist.h"
55 #define server_list_iterate(serverlist, pserver) \
56 TYPED_LIST_ITERATE(struct server, serverlist, pserver)
57 #define server_list_iterate_end LIST_ITERATE_END
59 struct server_scan;
61 struct srv_list
63 struct server_list *servers;
64 fc_mutex mutex;
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
73 typedef void (*ServerScanErrorFunc)(struct server_scan *scan,
74 const char *message);
76 struct server_scan *server_scan_begin(enum server_scan_type type,
77 ServerScanErrorFunc error_func);
78 enum 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
86 enum server_scan_status server_scan_poll(struct server_scan *scan);
87 struct srv_list *
88 server_scan_get_list(struct server_scan *scan);
89 void server_scan_finish(struct server_scan *scan);
91 #ifdef __cplusplus
93 #endif /* __cplusplus */
95 #endif /* FC__SERVERS_H */