]> git.sesse.net Git - mlt/blob - src/miracle/miracle_connection.h
ce19115f79962d66e81bedbad1f59057416655ad
[mlt] / src / miracle / miracle_connection.h
1 /*
2  * miracle_connection.h -- DV Connection Handler
3  * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
4  * Author: Charles Yates <charles.yates@pandora.be>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef _DV_CONNECTION_H_
22 #define _DV_CONNECTION_H_
23
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #include <netinet/in.h>
27
28 #include <valerie/valerie_parser.h>
29 #include <valerie/valerie_tokeniser.h>
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /** Connection structure
37 */
38
39 typedef struct 
40 {
41         int fd;
42         struct sockaddr_in sin;
43         valerie_parser parser;
44
45 connection_t;
46
47 /** Enumeration for responses.
48 */
49
50 typedef enum 
51 {
52         RESPONSE_SUCCESS = 200,
53         RESPONSE_SUCCESS_N = 201,
54         RESPONSE_SUCCESS_1 = 202,
55         RESPONSE_UNKNOWN_COMMAND = 400,
56         RESPONSE_TIMEOUT = 401,
57         RESPONSE_MISSING_ARG = 402,
58         RESPONSE_INVALID_UNIT = 403,
59         RESPONSE_BAD_FILE = 404,
60         RESPONSE_OUT_OF_RANGE = 405,
61         RESPONSE_TOO_MANY_FILES = 406,
62         RESPONSE_ERROR = 500
63
64 response_codes;
65
66 /* the following struct is passed as the single argument 
67    to all command callback functions */
68
69 typedef struct 
70 {
71         valerie_parser    parser;
72         valerie_response  response;
73         valerie_tokeniser tokeniser;
74         char         *command;
75         int           unit;
76         void         *argument;
77         char         *root_dir;
78
79 command_argument_t, *command_argument;
80
81 /* A handler is defined as follows. */
82 typedef int (*command_handler_t) ( command_argument );
83
84
85 extern void *parser_thread( void *arg );
86
87 #ifdef __cplusplus
88 }
89 #endif
90
91 #endif