2 * Copyright (C) 1997-2007 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file server.h common server data structures */
12 /** size of the selector_info and audio_file info strings of struct misc_meta_data */
13 #define MMD_INFO_SIZE 16384
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 **);
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 */
41 /** used for allow/deny */
43 /** the portnumber for add/remove */
48 * used for parent-child communication
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:
55 * - At least one command (i.e. child of the server) must be able to
60 * - The contents are listed in the stat command and have to be up to
63 struct misc_meta_data
{
64 /** information on the current audio file */
65 struct audio_format_info afi
;
66 /** the size of the current audio file in bytes */
68 /** the full path of the current audio file */
69 char filename
[_POSIX_PATH_MAX
];
70 /** the last modification file of the current audio file */
72 /** the number of the current audio format */
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
;
90 * commands may increase this to force a status update to be sent to all
94 /** the number of audio files already sent */
95 unsigned int num_played
;
96 /** the number of executed commands */
97 unsigned int num_commands
;
98 /** the number of connections para_server received so far */
99 unsigned int num_connects
;
100 /** the number of connections currently active */
101 unsigned int active_connections
;
102 /** the process id of para_server */
104 /** a string that gets filled in by the current audio file selector */
105 char selector_info
[MMD_INFO_SIZE
];
106 /** the number if the current audio file selector */
108 /** commands set this to non-zero to change the current selector */
110 /** used by the sender command */
111 struct sender_command_data sender_cmd_data
;
114 extern struct server_args_info conf
;
116 int handle_connect(int fd
, struct sockaddr_in
*addr
);
117 void mmd_unlock(void);