Remove gengetopt and help2man checks from configure.ac.
[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 extern struct lls_parse_result *server_lpr;
93
94 /**
95  * Get a reference to the supercommand of para_server.
96  *
97  * This is needed for parsing the command line and for the ENUM_STRING_VAL()
98  * macro below. The latter macro is used in command.c, so CMD_PTR() can not
99  * be made local to server.c.
100  */
101 #define CMD_PTR (lls_cmd(0, server_suite))
102
103 /** Get the parse result of an option to para_server. */
104 #define OPT_RESULT(_name) (lls_opt_result( \
105                 LSG_SERVER_PARA_SERVER_OPT_ ## _name, server_lpr))
106
107 /** How many times a server option was given. */
108 #define OPT_GIVEN(_name) (lls_opt_given(OPT_RESULT(_name)))
109
110 /** The (first) argument to a server option of type string. */
111 #define OPT_STRING_VAL(_name) (lls_string_val(0, OPT_RESULT(_name)))
112
113 /** The (first) argument to a server option of type uint32. */
114 #define OPT_UINT32_VAL(_name) (lls_uint32_val(0, OPT_RESULT(_name)))
115
116 /** The (first) argument to a server option of type int32. */
117 #define OPT_INT32_VAL(_name) (lls_int32_val(0, OPT_RESULT(_name)))
118
119 /** Get the string which corresponds to an enum constant. */
120 #define ENUM_STRING_VAL(_name) (lls_enum_string_val(OPT_UINT32_VAL(_name), \
121         lls_opt(LSG_SERVER_PARA_SERVER_OPT_ ## _name, CMD_PTR)))
122
123 __noreturn void handle_connect(int fd, const char *peername);
124 void parse_config_or_die(bool reload);
125 char *server_get_tasks(void);