recv.c: Make rn_event_handler() static
[paraslash.git] / server.h
1 /*
2 * Copyright (C) 1997-2006 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 "list.h"
23 #include <openssl/pem.h>
24
25 /** size of the selector_info and audio_file info strings of struct misc_meta_data */
26 #define MMD_INFO_SIZE 16384
27
28 /**
29 * defines one command of para_server
30 */
31 struct server_command {
32 /** the name of the command */
33 const char *name;
34 /** pointer to the function that handles the command */
35 int (*handler)(int, int, char **);
36 /** the privileges a user must have to execute this command */
37 unsigned int perms;
38 /** one-line description of the command */
39 const char *description;
40 /** summary of the command line options */
41 const char *synopsis;
42 /** the long help text */
43 const char *help;
44 };
45
46 /** holds the arguments for the para_server's sender command */
47 struct sender_command_data{
48 /** greater than 0 indicates that a sender cmd is already queued */
49 int cmd_num;
50 /** the number of the sender in question */
51 int sender_num;
52 /** used for the allow/deny/add/remove subcommands */
53 struct in_addr addr;
54 /** used for allow/deny */
55 int netmask;
56 /** the portnumber for add/remove */
57 int port;
58 };
59
60 /**
61 * used for parent-child communication
62 *
63 * There's only one struct of this type which lives in shared memory
64 * for communication between the server instances. Access to this
65 * area is serialized via mmd_lock() and mmd_unlock(). There are two
66 * reasons for a variable to be included here:
67 *
68 * - At least one command (i.e. child of the server) must be able to
69 * change its value.
70 *
71 * or
72 *
73 * - The contents are listed in the stat command and have to be up to
74 * date.
75 */
76 struct misc_meta_data{
77 /** the size of the current audio file in bytes */
78 long unsigned int size;
79 /** the full path of the current audio file */
80 char filename[_POSIX_PATH_MAX];
81 /** the last modification file of the current audio file */
82 time_t mtime;
83 /* the number of the current audio format */
84 int audio_format;
85 /** the "old" status flags -- commands may only read them */
86 unsigned int afs_status_flags;
87 /** the new status flags -- commands may set them **/
88 unsigned int new_afs_status_flags;
89 /** the number of data chunks sent for the current audio file */
90 long unsigned chunks_sent;
91 /** the number of chunks this audio file contains */
92 long unsigned chunks_total;
93 /** set by the jmp/ff commands to the new position in chunks */
94 long unsigned repos_request;
95 /** the number of the chunk currently sent out*/
96 long unsigned current_chunk;
97 /** the milliseconds that have been skipped of the current audio file */
98 long offset;
99 /** the length of the audio file in seconds */
100 int seconds_total;
101 /** the time para_server started to stream */
102 struct timeval stream_start;
103 /** a string that gets filled in by the audio format handler */
104 char audio_file_info[MMD_INFO_SIZE];
105 /** the event counter
106 *
107 * commands may increase this to force a status update to be sent to all
108 * connected clients
109 */
110 unsigned int events;
111 /** the number of audio files already sent */
112 unsigned int num_played;
113 /** the number of executed commands */
114 unsigned int num_commands;
115 /** the number of connections para_server received so far */
116 unsigned int num_connects;
117 /** the number of connections currently active */
118 unsigned int active_connections;
119 /** the process id of para_server */
120 pid_t server_pid;
121 /** a string that gets filled in by the current audio file selector */
122 char selector_info[MMD_INFO_SIZE];
123 /** the number if the current audio file selector */
124 int selector_num;
125 /** commands set this to non-zero to change the current selector */
126 int selector_change;
127 /** used by the sender command */
128 struct sender_command_data sender_cmd_data;
129 };
130
131 extern struct server_args_info conf;
132
133 int handle_connect(int fd, struct sockaddr_in *addr);
134 void mmd_unlock(void);
135 void mmd_lock(void);