- got rid of include/async.h
[wine] / server / token.c
1 /*
2  * Tokens
3  *
4  * Copyright (C) 1998 Alexandre Julliard
5  * Copyright (C) 2003 Mike McCormack
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "config.h"
23
24 #include <assert.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27
28 #include "windef.h"
29
30 #include "handle.h"
31 #include "thread.h"
32 #include "process.h"
33 #include "request.h"
34
35 struct token
36 {
37     struct object  obj;             /* object header */
38 };
39
40 static void token_dump( struct object *obj, int verbose );
41
42 static const struct object_ops token_ops =
43 {
44     sizeof(struct token),      /* size */
45     token_dump,                /* dump */
46     no_add_queue,              /* add_queue */
47     NULL,                      /* remove_queue */
48     NULL,                      /* signaled */
49     NULL,                      /* satified */
50     no_get_fd,                 /* get_fd */
51     no_destroy                 /* destroy */
52 };
53
54
55 static void token_dump( struct object *obj, int verbose )
56 {
57     fprintf( stderr, "Security token\n" );
58 }
59
60 struct token *create_token( void )
61 {
62     struct token *token = alloc_object( &token_ops );
63     return token;
64 }
65
66 /* open a security token */
67 DECL_HANDLER(open_token)
68 {
69     if( req->flags & OPEN_TOKEN_THREAD )
70     {
71         struct thread *thread = get_thread_from_handle( req->handle, 0 );
72         if (thread)
73         {
74             if (thread->token)
75                 reply->token = alloc_handle( current->process, thread->token, TOKEN_ALL_ACCESS, 0);
76             release_object( thread );
77         }
78     }
79     else
80     {
81         struct process *process = get_process_from_handle( req->handle, 0 );
82         if (process)
83         {
84             if (process->token)
85                 reply->token = alloc_handle( current->process, process->token, TOKEN_ALL_ACCESS, 0);
86             release_object( process );
87         }
88     }
89 }