mp3: Add support for id3 version 2 tags.
[paraslash.git] / server.h
1 /*
2 * Copyright (C) 1997-2008 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file server.h Common server data structures. */
8
9
10 /** Size of the selector_info and audio_file info strings of struct misc_meta_data. */
11 #define MMD_INFO_SIZE 16384
12
13 /**
14 * Defines one command of para_server.
15 */
16 struct server_command {
17 /** The name of the command. */
18 const char *name;
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. */
22 unsigned int perms;
23 /** One-line description of the command. */
24 const char *description;
25 /** Summary of the command line options. */
26 const char *usage;
27 /** The long help text. */
28 const char *help;
29 };
30
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. */
34 int cmd_num;
35 /** The number of the sender in question. */
36 int sender_num;
37 /** Used for the allow/deny/add/remove subcommands. */
38 struct in_addr addr;
39 /** Used for allow/deny. */
40 int netmask;
41 /** The port number for add/remove. */
42 int port;
43 };
44
45 /**
46 * Used for parent-child communication.
47 *
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:
52 *
53 * - At least one command (i.e. child of the server) must be able to
54 * change its value.
55 *
56 * or
57 *
58 * - The contents are listed in the stat command and have to be up to
59 * date.
60 */
61 struct misc_meta_data {
62 /** The size of the current audio file in bytes. */
63 size_t size;
64 /** The last modification time of the current audio file. */
65 time_t mtime;
66 /** The "old" status flags -- commands may only read them. */
67 unsigned int vss_status_flags;
68 /** The new status flags -- commands may set them. */
69 unsigned int new_vss_status_flags;
70 /** The number of data chunks sent for the current audio file. */
71 long unsigned chunks_sent;
72 /** Set by the jmp/ff commands to the new position in chunks. */
73 long unsigned repos_request;
74 /** The number of the chunk currently sent out. */
75 long unsigned current_chunk;
76 /** The milliseconds that have been skipped of the current audio file. */
77 long offset;
78 /** The time para_server started to stream. */
79 struct timeval stream_start;
80 /**
81 * The event counter.
82 *
83 * Commands may increase this to force a status update to be sent to all
84 * connected clients.
85 */
86 unsigned int events;
87 /** The number of audio files already sent. */
88 unsigned int num_played;
89 /** The number of executed commands. */
90 unsigned int num_commands;
91 /** The number of connections para_server received so far. */
92 unsigned int num_connects;
93 /** The number of connections currently active. */
94 unsigned int active_connections;
95 /** The process id of the audio file selector. */
96 pid_t afs_pid;
97 /** This gets updated by afs and contains its current mode. */
98 char afs_mode_string[MAXLINE];
99 /** Used by the sender command. */
100 struct sender_command_data sender_cmd_data;
101 /** Describes the current audio file. */
102 struct audio_file_data afd;
103 };
104
105 /** Command line options for para_server. */
106 extern struct server_args_info conf;
107
108 __noreturn void handle_connect(int fd, const char *peername);