ANSI C fixes.
[wine] / server / device.c
1 /*
2  * Server-side device management
3  *
4  * Copyright (C) 1999 Alexandre Julliard
5  */
6
7 /*
8  * FIXME:
9  * all this stuff is a simple hack to avoid breaking
10  * client-side device support.
11  */
12
13 #include <assert.h>
14 #include <fcntl.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18
19 #include "winerror.h"
20 #include "winbase.h"
21
22 #include "handle.h"
23 #include "thread.h"
24 #include "request.h"
25
26 struct device
27 {
28     struct object  obj;             /* object header */
29     int            id;              /* client identifier */
30 };
31
32 static void device_dump( struct object *obj, int verbose );
33 static int device_get_info( struct object *obj, struct get_file_info_request *req );
34
35 static const struct object_ops device_ops =
36 {
37     sizeof(struct device),
38     device_dump,
39     no_add_queue,
40     NULL,  /* should never get called */
41     NULL,  /* should never get called */
42     NULL,  /* should never get called */
43     no_read_fd,
44     no_write_fd,
45     no_flush,
46     device_get_info,
47     no_destroy
48 };
49
50 static struct device *create_device( int id )
51 {
52     struct device *dev;
53     if ((dev = alloc_object( &device_ops )))
54     {
55         dev->id = id;
56     }
57     return dev;
58 }
59
60 static void device_dump( struct object *obj, int verbose )
61 {
62     struct device *dev = (struct device *)obj;
63     assert( obj->ops == &device_ops );
64     fprintf( stderr, "Device id=%08x\n", dev->id );
65 }
66
67 static int device_get_info( struct object *obj, struct get_file_info_request *req )
68 {
69     struct device *dev = (struct device *)obj;
70     assert( obj->ops == &device_ops );
71     req->type        = FILE_TYPE_UNKNOWN;
72     req->attr        = dev->id;  /* hack! */
73     req->access_time = 0;
74     req->write_time  = 0;
75     req->size_high   = 0;
76     req->size_low    = 0;
77     req->links       = 0;
78     req->index_high  = 0;
79     req->index_low   = 0;
80     req->serial      = 0;
81     return 1;
82 }
83
84 /* create a device */
85 DECL_HANDLER(create_device)
86 {
87     struct device *dev;
88
89     req->handle = -1;
90     if ((dev = create_device( req->id )))
91     {
92         req->handle = alloc_handle( current->process, dev, req->access, req->inherit );
93         release_object( dev );
94     }
95 }