2 * Copyright (C) 1997-2009 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file server.h Common server data structures. */
9 /** Size of the selector_info and audio_file info strings of struct misc_meta_data. */
10 #define MMD_INFO_SIZE 16384
12 /** The maximum length of the host component in an URL */
13 #define MAX_HOSTLEN 256
16 * Defines one command of para_server.
18 struct server_command
{
19 /** The name of the command. */
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. */
25 /** One-line description of the command. */
26 const char *description
;
27 /** Summary of the command line options. */
29 /** The long help text. */
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. */
37 /** The number of the sender in question. */
39 /** Used for the allow/deny/add/remove subcommands. */
40 char host
[MAX_HOSTLEN
];
41 /** Used for allow/deny. */
43 /** The port number for add/remove. */
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
;
54 * Used for parent-child communication.
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:
61 * - At least one command (i.e. child of the server) must be able to
66 * - The contents are listed in the stat command and have to be up to
69 struct misc_meta_data
{
70 /** The size of the current audio file in bytes. */
72 /** The last modification time of the current audio file. */
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. */
86 /** The time para_server started to stream. */
87 struct timeval stream_start
;
91 * Commands may increase this to force a status update to be sent to all
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. */
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
;
113 /** Command line options for para_server. */
114 extern struct server_args_info conf
;
116 __noreturn
void handle_connect(int fd
, const char *peername
);
117 void parse_config_or_die(int override
);