vss.c: Kill check for get_file_info == NULL
[paraslash.git] / server.h
1 /*
2 * Copyright (C) 1997-2007 Andre Noll <maan@systemlinux.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
17 */
18
19 /** \file server.h common server data structures */
20
21 #include "para.h"
22 #include <openssl/pem.h>
23
24 /** size of the selector_info and audio_file info strings of struct misc_meta_data */
25 #define MMD_INFO_SIZE 16384
26
27 /**
28 * defines one command of para_server
29 */
30 struct server_command {
31 /** the name of the command */
32 const char *name;
33 /** pointer to the function that handles the command */
34 int (*handler)(int, int, char **);
35 /** the privileges a user must have to execute this command */
36 unsigned int perms;
37 /** one-line description of the command */
38 const char *description;
39 /** summary of the command line options */
40 const char *usage;
41 /** the long help text */
42 const char *help;
43 };
44
45 /** holds the arguments for the para_server's sender command */
46 struct sender_command_data{
47 /** greater than 0 indicates that a sender cmd is already queued */
48 int cmd_num;
49 /** the number of the sender in question */
50 int sender_num;
51 /** used for the allow/deny/add/remove subcommands */
52 struct in_addr addr;
53 /** used for allow/deny */
54 int netmask;
55 /** the portnumber for add/remove */
56 int port;
57 };
58
59 /**
60 * used for parent-child communication
61 *
62 * There's only one struct of this type which lives in shared memory
63 * for communication between the server instances. Access to this
64 * area is serialized via mmd_lock() and mmd_unlock(). There are two
65 * reasons for a variable to be included here:
66 *
67 * - At least one command (i.e. child of the server) must be able to
68 * change its value.
69 *
70 * or
71 *
72 * - The contents are listed in the stat command and have to be up to
73 * date.
74 */
75 struct misc_meta_data{
76 /** the size of the current audio file in bytes */
77 long unsigned int size;
78 /** the full path of the current audio file */
79 char filename[_POSIX_PATH_MAX];
80 /** the last modification file of the current audio file */
81 time_t mtime;
82 /** the number of the current audio format */
83 int audio_format;
84 /** the "old" status flags -- commands may only read them */
85 unsigned int vss_status_flags;
86 /** the new status flags -- commands may set them **/
87 unsigned int new_vss_status_flags;
88 /** the number of data chunks sent for the current audio file */
89 long unsigned chunks_sent;
90 /** the number of chunks this audio file contains */
91 long unsigned chunks_total;
92 /** set by the jmp/ff commands to the new position in chunks */
93 long unsigned repos_request;
94 /** the number of the chunk currently sent out*/
95 long unsigned current_chunk;
96 /** the milliseconds that have been skipped of the current audio file */
97 long offset;
98 /** the length of the audio file in seconds */
99 int seconds_total;
100 /** the time para_server started to stream */
101 struct timeval stream_start;
102 /** a string that gets filled in by the audio format handler */
103 char audio_file_info[MMD_INFO_SIZE];
104 /** the event counter
105 *
106 * commands may increase this to force a status update to be sent to all
107 * connected clients
108 */
109 unsigned int events;
110 /** the number of audio files already sent */
111 unsigned int num_played;
112 /** the number of executed commands */
113 unsigned int num_commands;
114 /** the number of connections para_server received so far */
115 unsigned int num_connects;
116 /** the number of connections currently active */
117 unsigned int active_connections;
118 /** the process id of para_server */
119 pid_t server_pid;
120 /** a string that gets filled in by the current audio file selector */
121 char selector_info[MMD_INFO_SIZE];
122 /** the number if the current audio file selector */
123 int selector_num;
124 /** commands set this to non-zero to change the current selector */
125 int selector_change;
126 /** used by the sender command */
127 struct sender_command_data sender_cmd_data;
128 };
129
130 extern struct server_args_info conf;
131
132 int handle_connect(int fd, struct sockaddr_in *addr);
133 void mmd_unlock(void);
134 void mmd_lock(void);