Re-revert "Auto-adjust fecdec output buffer size."
[paraslash.git] / server.h
1 /*
2 * Copyright (C) 1997-2009 Andre Noll <maan@systemlinux.org>
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 * Defines one command of para_server.
17 */
18 struct server_command {
19 /** The name of the command. */
20 const char *name;
21 /** Pointer to the function that handles the command. */
22 int (*handler)(int, int, char * const * const);
23 /** The privileges a user must have to execute this command. */
24 unsigned int perms;
25 /** One-line description of the command. */
26 const char *description;
27 /** Summary of the command line options. */
28 const char *usage;
29 /** The long help text. */
30 const char *help;
31 };
32
33 /** Holds the arguments for the para_server's sender command. */
34 struct sender_command_data{
35 /** Greater than 0 indicates that a sender cmd is already queued. */
36 int cmd_num;
37 /** The number of the sender in question. */
38 int sender_num;
39 /** Used for the allow/deny/add/remove subcommands. */
40 char host[MAX_HOSTLEN];
41 /** Used for allow/deny. */
42 int netmask;
43 /** The port number for add/remove. */
44 int port;
45 /** Maximal slice size. */
46 uint16_t max_slice_bytes;
47 /** Number of data slices plus redundant slices. */
48 uint8_t slices_per_group;
49 /** Number of slices minus number of redundant slices. */
50 uint8_t data_slices_per_group;
51 };
52
53 /**
54 * Used for parent-child communication.
55 *
56 * There's only one struct of this type which lives in shared memory
57 * for communication between the server instances. Access to this
58 * area is serialized via mmd_lock() and mmd_unlock(). There are two
59 * reasons for a variable to be included here:
60 *
61 * - At least one command (i.e. child of the server) must be able to
62 * change its value.
63 *
64 * or
65 *
66 * - The contents are listed in the stat command and have to be up to
67 * date.
68 */
69 struct misc_meta_data {
70 /** The size of the current audio file in bytes. */
71 size_t size;
72 /** The last modification time of the current audio file. */
73 time_t mtime;
74 /** The "old" status flags -- commands may only read them. */
75 unsigned int vss_status_flags;
76 /** The new status flags -- commands may set them. */
77 unsigned int new_vss_status_flags;
78 /** The number of data chunks sent for the current audio file. */
79 long unsigned chunks_sent;
80 /** Set by the jmp/ff commands to the new position in chunks. */
81 long unsigned repos_request;
82 /** The number of the chunk currently sent out. */
83 long unsigned current_chunk;
84 /** The milliseconds that have been skipped of the current audio file. */
85 long offset;
86 /** The time para_server started to stream. */
87 struct timeval stream_start;
88 /**
89 * The event counter.
90 *
91 * Commands may increase this to force a status update to be sent to all
92 * connected clients.
93 */
94 unsigned int events;
95 /** The number of audio files already sent. */
96 unsigned int num_played;
97 /** The number of executed commands. */
98 unsigned int num_commands;
99 /** The number of connections para_server received so far. */
100 unsigned int num_connects;
101 /** The number of connections currently active. */
102 unsigned int active_connections;
103 /** The process id of the audio file selector. */
104 pid_t afs_pid;
105 /** This gets updated by afs and contains its current mode. */
106 char afs_mode_string[MAXLINE];
107 /** Used by the sender command. */
108 struct sender_command_data sender_cmd_data;
109 /** Describes the current audio file. */
110 struct audio_file_data afd;
111 };
112
113 /** Command line options for para_server. */
114 extern struct server_args_info conf;
115
116 __noreturn void handle_connect(int fd, const char *peername);
117 void parse_config_or_die(int override);