fecdec_filter.c: Kill useless UNUSED_GROUP_NUM.
[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 };
46
47 /**
48 * Used for parent-child communication.
49 *
50 * There's only one struct of this type which lives in shared memory
51 * for communication between the server instances. Access to this
52 * area is serialized via mmd_lock() and mmd_unlock(). There are two
53 * reasons for a variable to be included here:
54 *
55 * - At least one command (i.e. child of the server) must be able to
56 * change its value.
57 *
58 * or
59 *
60 * - The contents are listed in the stat command and have to be up to
61 * date.
62 */
63 struct misc_meta_data {
64 /** The size of the current audio file in bytes. */
65 size_t size;
66 /** The last modification time of the current audio file. */
67 time_t mtime;
68 /** The "old" status flags -- commands may only read them. */
69 unsigned int vss_status_flags;
70 /** The new status flags -- commands may set them. */
71 unsigned int new_vss_status_flags;
72 /** The number of data chunks sent for the current audio file. */
73 long unsigned chunks_sent;
74 /** Set by the jmp/ff commands to the new position in chunks. */
75 long unsigned repos_request;
76 /** The number of the chunk currently sent out. */
77 long unsigned current_chunk;
78 /** The milliseconds that have been skipped of the current audio file. */
79 long offset;
80 /** The time para_server started to stream. */
81 struct timeval stream_start;
82 /**
83 * The event counter.
84 *
85 * Commands may increase this to force a status update to be sent to all
86 * connected clients.
87 */
88 unsigned int events;
89 /** The number of audio files already sent. */
90 unsigned int num_played;
91 /** The number of executed commands. */
92 unsigned int num_commands;
93 /** The number of connections para_server received so far. */
94 unsigned int num_connects;
95 /** The number of connections currently active. */
96 unsigned int active_connections;
97 /** The process id of the audio file selector. */
98 pid_t afs_pid;
99 /** This gets updated by afs and contains its current mode. */
100 char afs_mode_string[MAXLINE];
101 /** Used by the sender command. */
102 struct sender_command_data sender_cmd_data;
103 /** Describes the current audio file. */
104 struct audio_file_data afd;
105 };
106
107 /** Command line options for para_server. */
108 extern struct server_args_info conf;
109
110 __noreturn void handle_connect(int fd, const char *peername);
111 void parse_config_or_die(int override);