Release 20031118.
[wine/multimedia.git] / server / device.c
blobc2422b962187d83f3bdc114577c340a33e15276c
1 /*
2 * Server-side device management
4 * Copyright (C) 1999 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * FIXME:
23 * all this stuff is a simple hack to avoid breaking
24 * client-side device support.
27 #include <assert.h>
28 #include <fcntl.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
34 #include "windef.h"
35 #include "winbase.h"
37 #include "handle.h"
38 #include "thread.h"
39 #include "request.h"
41 struct device
43 struct object obj; /* object header */
44 int id; /* client identifier */
47 static void device_dump( struct object *obj, int verbose );
49 static const struct object_ops device_ops =
51 sizeof(struct device), /* size */
52 device_dump, /* dump */
53 no_add_queue, /* add_queue */
54 NULL, /* remove_queue */
55 NULL, /* signaled */
56 NULL, /* satisfied */
57 no_get_fd, /* get_fd */
58 no_destroy /* destroy */
61 static struct device *create_device( int id )
63 struct device *dev;
64 if ((dev = alloc_object( &device_ops )))
66 dev->id = id;
68 return dev;
71 static void device_dump( struct object *obj, int verbose )
73 struct device *dev = (struct device *)obj;
74 assert( obj->ops == &device_ops );
75 fprintf( stderr, "Device id=%08x\n", dev->id );
78 /* create a device */
79 DECL_HANDLER(create_device)
81 struct device *dev;
83 reply->handle = 0;
84 if ((dev = create_device( req->id )))
86 reply->handle = alloc_handle( current->process, dev, req->access, req->inherit );
87 release_object( dev );
92 /* Retrieve the client private id for a device */
93 DECL_HANDLER(get_device_id)
95 struct device *dev;
97 if ((dev = (struct device *)get_handle_obj( current->process, req->handle, 0, &device_ops )))
99 reply->id = dev->id;
100 release_object( dev );