]> git.cworth.org Git - loudgame/blob - loudgame.h
Update documentation of move command for new syntax
[loudgame] / loudgame.h
1 /*
2  * Copyright (C) 2008 Carl Worth
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see http://www.gnu.org/licenses/ .
16  *
17  * Author: Carl Worth <cworth@cworth.org>
18  */
19
20 #ifndef __LOUDGAME_H__
21 #define __LOUDGAME_H__
22
23 #include <stdarg.h>
24 #include <loudmouth/loudmouth.h>
25
26 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
27 #define LOUDGAME_PRINTF_FORMAT(fmt_index, va_index) \
28         __attribute__((__format__(__printf__, fmt_index, va_index)))
29 #else
30 #define LOUDGAME_PRINTF_FORMAT(fmt_index, va_index)
31 #endif
32
33 typedef struct _loudgame loudgame_t;
34
35 typedef void (*handle_message_cb) (loudgame_t   *lg,
36                                    const char   *peer,
37                                    const char   *message);
38
39 struct _loudgame {
40     gchar               *server;
41     gchar               *name;
42     gchar               *passwd;
43     LmConnection        *connection;
44
45     GMainLoop           *main_loop;
46     GHashTable          *players;
47
48     int                  return_value;
49
50     /* Callbacks */
51     handle_message_cb    handle_message;
52 };
53
54 #define LOUDGAME_HELP                                                           \
55 "\tsay message         \t\tSay 'message' to everyone in the current game\n"     \
56 "\twhisper user message\tSay 'message' to 'user' only\n"
57
58 int
59 loudgame_init (loudgame_t *lg, int argc, char **argv);
60
61 int
62 loudgame_run (loudgame_t *lg);
63
64 void
65 loudgame_send (loudgame_t       *lg,
66                const char       *peer,
67                const char       *message);
68
69 void
70 loudgame_sendf (loudgame_t      *lg,
71                 const char      *peer,
72                 const char      *format,
73                 ...) LOUDGAME_PRINTF_FORMAT (3, 4);
74
75 void
76 loudgame_vsendf (loudgame_t     *lg,
77                  const char     *peer,
78                  const char     *format,
79                  va_list         va) LOUDGAME_PRINTF_FORMAT (3, 0);
80
81 void
82 loudgame_broadcast (loudgame_t *lg,
83                     const char *message);
84
85 void
86 loudgame_vbroadcastf (loudgame_t *lg,
87                       const char *format,
88                       va_list     va) LOUDGAME_PRINTF_FORMAT (2, 0);
89
90 void
91 loudgame_broadcastf (loudgame_t *lg,
92                      const char *format,
93                      ...) LOUDGAME_PRINTF_FORMAT (2, 3);
94
95 void
96 loudgame_quit (loudgame_t *lg, int return_value);
97
98 #endif /* __LOUDGAME_H__ */