Added TEB in init_thread request.
[wine/multimedia.git] / server / device.c
blob5822293cb5dbdfcb1e0f07351967d3e792b5a9e3
1 /*
2 * Server-side device management
4 * Copyright (C) 1999 Alexandre Julliard
5 */
7 /*
8 * FIXME:
9 * all this stuff is a simple hack to avoid breaking
10 * client-side device support.
13 #include <assert.h>
14 #include <fcntl.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
19 #include "winerror.h"
20 #include "winbase.h"
22 #include "handle.h"
23 #include "thread.h"
25 struct device
27 struct object obj; /* object header */
28 int id; /* client identifier */
31 static void device_dump( struct object *obj, int verbose );
32 static int device_get_info( struct object *obj, struct get_file_info_reply *reply );
33 static void device_destroy( struct object *obj );
35 static const struct object_ops device_ops =
37 device_dump,
38 no_add_queue,
39 NULL, /* should never get called */
40 NULL, /* should never get called */
41 NULL, /* should never get called */
42 no_read_fd,
43 no_write_fd,
44 no_flush,
45 device_get_info,
46 device_destroy
49 static struct object *create_device( int id )
51 struct device *dev;
53 if (!(dev = mem_alloc(sizeof(*dev)))) return NULL;
54 init_object( &dev->obj, &device_ops, NULL );
55 dev->id = id;
56 return &dev->obj;
59 static void device_dump( struct object *obj, int verbose )
61 struct device *dev = (struct device *)obj;
62 assert( obj->ops == &device_ops );
63 fprintf( stderr, "Device id=%08x\n", dev->id );
66 static int device_get_info( struct object *obj, struct get_file_info_reply *reply )
68 struct device *dev = (struct device *)obj;
69 assert( obj->ops == &device_ops );
70 memset( reply, 0, sizeof(*reply) );
71 reply->type = FILE_TYPE_UNKNOWN;
72 reply->attr = dev->id; /* hack! */
73 return 1;
76 static void device_destroy( struct object *obj )
78 struct device *dev = (struct device *)obj;
79 assert( obj->ops == &device_ops );
80 free( dev );
83 /* create a device */
84 DECL_HANDLER(create_device)
86 struct object *obj;
87 struct create_device_reply reply = { -1 };
89 if ((obj = create_device( req->id )))
91 reply.handle = alloc_handle( current->process, obj,
92 req->access, req->inherit );
93 release_object( obj );
95 send_reply( current, -1, 1, &reply, sizeof(reply) );