File: client.h

package info (click to toggle)
lcdproc 0.5.9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,064 kB
  • sloc: ansic: 59,645; sh: 1,740; perl: 681; makefile: 417
file content (88 lines) | stat: -rw-r--r-- 2,048 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/** \file server/client.h
 * Defines all the client data and actions.
 *
 * \note If you only need 'struct Client' to work with, you should use the
 *       following code (which does not create an indirect dependency on
 *       'struct Screen'):
 *
 * \code
 * #define INC_TYPES_ONLY 1
 * #include "client.h"
 * #undef INC_TYPES_ONLY
 * \endcode
 */

/* This file is part of LCDd, the lcdproc server.
 *
 * This file is released under the GNU General Public License.
 * Refer to the COPYING file distributed with this package.
 *
 * Copyright (c) 1999, William Ferrell, Selene Scriven
 *		 2002, Joris Robijn
 */

#ifndef CLIENT_H_TYPES
#define CLIENT_H_TYPES

#include "shared/LL.h"

#define CLIENT_NAME_SIZE 256

/** Possible states of a client. */
typedef enum _clientstate {
	NEW,			/**< Client did not yet send \c hello. */
	ACTIVE,			/**< Client sent \c hello, but not yet \c bye. */
	GONE			/**< Client sent \c bye. */
} ClientState;


/** The structure representing a client in the server. */
typedef struct Client {
	char *name;
	ClientState state;
	int sock;
	int backlight;
	int heartbeat;

	LinkedList *messages;		/**< Messages that the client sent. */
	LinkedList *screenlist;		/**< List of client's screens. */

	void* menu;			/**< Menu hierarchy, if any */
} Client;

#endif

#ifndef INC_TYPES_ONLY
#ifndef CLIENT_H_FNCS
#define CLIENT_H_FNCS

#define INC_TYPES_ONLY 1
#include "screen.h"
#undef INC_TYPES_ONLY

/* When a new client connects, set up a new client data struct */
Client *client_create(int sock);

/* Destroys the client data */
int client_destroy(Client *c);

/* Close the socket */
void client_close_sock(Client *c);

/* Add message to the client's queue...*/
int client_add_message(Client *c, char *message);

/* Get message from queue */
char *client_get_message(Client *c);

/* Find a named screen for the client */
Screen *client_find_screen(Client *c, char *id);

int client_add_screen(Client *c, Screen *s);

int client_remove_screen(Client *c, Screen *s);

int client_screen_count(Client *c);

#endif
#endif