1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include "rh_string.h"
 4 #include "handler.h"
 5 #include "http_request.h"
 6 #include "rh_chunk.h"
 7 
 8 /*
 9  *
10  * alias
11  *
12  *
13  * rewrites the filename based on server configuration
14  *
15  *
16  */
17 
18 
19 DECLARE_HANDLER_FUNCTION (alias,exec)
20 {
21 #ifdef RHTTPD_DUMP_HANDLER_CALL
22         printf ("%s(%p)\n", __FUNCTION__, (void*)handler);
23 #endif
24         return HANDLER_SUCCESS;
25 }
26 
27 
28 DECLARE_HANDLER_FUNCTION (alias,setup)
29 {
30 #ifdef RHTTPD_DUMP_HANDLER_CALL
31         printf ("%s(%p)\n", __FUNCTION__, (void*)handler);
32 #endif
33 
34         return HANDLER_SUCCESS;
35 }
36 
37 DECLARE_HANDLER_FUNCTION (alias,init)
38 {
39 #ifdef RHTTPD_DUMP_HANDLER_CALL
40         printf ("%s(%p)\n", __FUNCTION__, (void*)handler);
41 #endif
42         
43         handler->data_local  = malloc(123);
44         if (NULL == handler->data_local)
45                 return HANDLER_FAILURE;
46         
47         return HANDLER_SUCCESS;
48 }
49 
50 DECLARE_HANDLER_FUNCTION (alias,init_global)
51 {
52 #ifdef RHTTPD_DUMP_HANDLER_CALL
53         printf ("%s(%p)\n", __FUNCTION__, (void*)handler);
54 #endif
55         
56         handler->data_global = malloc(456);
57         if (NULL == handler->data_global)
58                 return HANDLER_FAILURE;
59         
60         return HANDLER_SUCCESS;
61 }
62 
63 DECLARE_HANDLER_FUNCTION (alias,free)
64 {
65 #ifdef RHTTPD_DUMP_HANDLER_CALL
66         printf ("%s(%p)\n", __FUNCTION__, (void*)handler);
67 #endif
68         memset (handler->data_local, 0, 123);
69         free (handler->data_local);
70         return HANDLER_SUCCESS;
71 }
72 
73 DECLARE_HANDLER_FUNCTION (alias,free_global)
74 {
75 #ifdef RHTTPD_DUMP_HANDLER_CALL
76         printf ("%s(%p)\n", __FUNCTION__, (void*)handler);
77 #endif
78         memset (handler->data_global, 0, 456);
79         free (handler->data_global);
80         return HANDLER_SUCCESS;
81 }
82 
83 DECLARE_HANDLER_BEGIN (alias, REWRITE)
84         .DECLARE_HANDLER_SYMBOL (alias, setup),
85         .DECLARE_HANDLER_SYMBOL (alias, init),
86         .DECLARE_HANDLER_SYMBOL (alias, init_global),
87         .DECLARE_HANDLER_SYMBOL (alias, free),
88         .DECLARE_HANDLER_SYMBOL (alias, free_global),
89         .DECLARE_HANDLER_SYMBOL (alias, exec),
90 DECLARE_HANDLER_END


syntax highlighted by Code2HTML, v. 0.9.1