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 */
10 /** size of the selector_info and audio_file info strings of struct misc_meta_data */
11 #define MMD_INFO_SIZE 16384
14 * defines one command of para_server
16 struct server_command {
17 /** the name of the command */
19 /** pointer to the function that handles the command */
20 int (*handler)(int, int, char * const * const);
21 /** the privileges a user must have to execute this command */
23 /** one-line description of the command */
24 const char *description;
25 /** summary of the command line options */
27 /** the long help text */
31 /** holds the arguments for the para_server's sender command */
32 struct sender_command_data{
33 /** greater than 0 indicates that a sender cmd is already queued */
35 /** the number of the sender in question */
37 /** used for the allow/deny/add/remove subcommands */
39 /** used for allow/deny */
41 /** the portnumber for add/remove */
46 * Used for parent-child communication.
48 * There's only one struct of this type which lives in shared memory
49 * for communication between the server instances. Access to this
50 * area is serialized via mmd_lock() and mmd_unlock(). There are two
51 * reasons for a variable to be included here:
53 * - At least one command (i.e. child of the server) must be able to
58 * - The contents are listed in the stat command and have to be up to
61 struct misc_meta_data {
62 /** the size of the current audio file in bytes */
64 /** the full path of the current audio file */
65 char filename[_POSIX_PATH_MAX];
66 /** the last modification time of the current audio file */
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 */
80 /** the time para_server started to stream */
81 struct timeval stream_start;
85 * Commands may increase this to force a status update to be sent to all
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 para_server */
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;
107 extern struct server_args_info conf;
108 extern int afs_socket;
110 int handle_connect(int fd, struct sockaddr_in *addr);
111 void mmd_unlock(void);