gui.c: Remove condition which is always true.
[paraslash.git] / server.h
1 /*
2 * Copyright (C) 1997 Andre Noll <maan@tuebingen.mpg.de>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file server.h Common server data structures. */
8
9 /** Size of the selector_info and audio_file info strings of struct misc_meta_data. */
10 #define MMD_INFO_SIZE 16384
11
12 /** The maximum length of the host component in an URL */
13 #define MAX_HOSTLEN 256
14
15
16 /** Arguments for the sender command. */
17 struct sender_command_data {
18 /** Greater than zero indicates that a sender cmd is already queued. */
19 int cmd_num;
20 /** The number of the sender in question. */
21 int sender_num;
22 /** Used for the allow/deny/add/remove subcommands. */
23 char host[MAX_HOSTLEN];
24 /** Used for allow/deny. */
25 int netmask;
26 /** The port number for add/remove. */
27 int port;
28 /** Maximal slice size. */
29 uint16_t max_slice_bytes;
30 /** Number of data slices plus redundant slices. */
31 uint8_t slices_per_group;
32 /** Number of slices minus number of redundant slices. */
33 uint8_t data_slices_per_group;
34 };
35
36 /**
37 * Miscellaneous data for communication between server and command handlers.
38 *
39 * There's only one instance of this structure which lives in a shared memory
40 * area. Command handlers communicate with the server process through this
41 * area. Changes made by the command handlers stay after the command handler
42 * exits. Conversely, changes made by the server process propagate to the
43 * command handlers. Access to this area is serialized via mmd_lock() and
44 * mmd_unlock().
45 *
46 * There are two reasons for a variable to be included here: (a) at least one
47 * command handler changes its value, or (b) updates by the server must
48 * propagate to the stat command handlers.
49 */
50 struct misc_meta_data {
51 /** The size of the current audio file in bytes. */
52 size_t size;
53 /** The "old" status flags -- commands may only read them. */
54 unsigned int vss_status_flags;
55 /** The new status flags -- commands may set them. */
56 unsigned int new_vss_status_flags;
57 /** The number of data chunks sent so far. */
58 long unsigned chunks_sent;
59 /** Set by the jmp/ff commands to the new position in chunks. */
60 long unsigned repos_request;
61 /** The number of the chunk currently being sent. */
62 long unsigned current_chunk;
63 /** The milliseconds that have been skipped of the current audio file. */
64 long offset;
65 /** The time para_server started to stream. */
66 struct timeval stream_start;
67 /**
68 * The event counter.
69 *
70 * Commands may increase this to force a status update to be sent to
71 * all connected stat clients.
72 */
73 unsigned int events;
74 /** The number of audio files already sent. */
75 unsigned int num_played;
76 /** The number of executed commands. */
77 unsigned int num_commands;
78 /** The number of connections para_server received so far. */
79 unsigned int num_connects;
80 /** The number of connections currently active. */
81 unsigned int active_connections;
82 /** The process id of the audio file selector. */
83 pid_t afs_pid;
84 /** This gets updated by afs and contains its current mode. */
85 char afs_mode_string[MAXLINE];
86 /** Used by the sender command. */
87 struct sender_command_data sender_cmd_data;
88 /** Describes the current audio file. */
89 struct audio_file_data afd;
90 };
91
92 /** Command line options for para_server. */
93 extern struct server_args_info conf;
94
95 __noreturn void handle_connect(int fd, const char *peername);
96 void parse_config_or_die(int override);
97 char *server_get_tasks(void);