1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <fcntl.h>
 4 #include <unistd.h>
 5 #include "config.h"
 6 #include "client.h"
 7 #include "server.h"
 8 #include "rh_string.h"
 9 #include "handler.h"
10 #include "http_request.h"
11 #include "rh_chunk.h"
12 
13 /*
14  *
15  * stat
16  *
17  * just stat() the current filename so the first (whatever)
18  * file based handler has a correct stat
19  *
20  *
21  */
22 
23 
24 DECLARE_HANDLER_FUNCTION (stat,exec)
25 {
26         http_request_t          *request;
27         
28 #ifdef RHTTPD_DUMP_HANDLER_CALL
29         printf ("%s(%p)\n", __FUNCTION__, (void*)handler);
30 #endif
31 
32         request = handler->request;
33         
34         if (0 != request->header_in.status)
35                 return HANDLER_FAILURE;
36 
37         if (0 != http_request_stat_symlink (request))
38                 return HANDLER_FAILURE;
39         
40         if (NULL == request->st)
41                 return HANDLER_FAILURE;
42 
43         if (RH_STAT_ISERROR(request->st)) {
44                 http_header_set_errno_status (
45                                 &request->header_out,
46                                 request->st->error );
47 
48                 return HANDLER_FAILURE;
49         }
50 
51         return HANDLER_SUCCESS;
52 }
53 
54 
55 DECLARE_HANDLER_BEGIN (stat, CONTENT)
56         .DECLARE_HANDLER_NULL   (stat, setup),
57         .DECLARE_HANDLER_NULL   (stat, init),
58         .DECLARE_HANDLER_NULL   (stat, init_global),
59         .DECLARE_HANDLER_NULL   (stat, free),
60         .DECLARE_HANDLER_NULL   (stat, free_global),
61         .DECLARE_HANDLER_SYMBOL (stat, exec),
62 DECLARE_HANDLER_END


syntax highlighted by Code2HTML, v. 0.9.1