Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / libcaptive / cc / bcbowner.c
1 /* $Id$
2  * reactos Cache Manager (Cc*) owner handling of libcaptive
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "privatebcbpin.h"
23 #include "privatebcb.h"
24
25
26 /**
27  * CcSetBcbOwnerPointer:
28  * @Bcb: Initialized #PUBLIC_BCB structure.
29  * %NULL value is forbidden.
30  * @Owner: Thread-specific pointer (FIXME: Is it KeGetCurrentThread()?).
31  * %NULL value is forbidden (FIXME: Is it W32 compliant?).
32  *
33  * Set thread-specific pointer for a pinned @Bcb. Use CcUnpinDataForThread()
34  * when @Bcb is no longer needed. CcUnpinDataForThread() is NOT a reverse
35  * operation for this single call CcSetBcbOwnerPointer(), see CcUnpinDataForThread().
36  *
37  * libcaptive implements this function as no-operation as it does not yet
38  * support any threading.
39  */
40 VOID CcSetBcbOwnerPointer(IN PVOID Bcb,IN PVOID Owner)
41 {
42 CaptivePrivateBcbPinObject *captive_private_bcb_pin_object;
43
44         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"enter: CcSetBcbOwnerPointer: Bcb=0x%lX,OwnerPointer=0x%lX",
45                         (long)Bcb,(long)Owner);
46
47         g_return_if_fail(Bcb!=NULL);
48         g_return_if_fail(Owner!=NULL);
49
50         captive_private_bcb_pin_object=CAPTIVE_PRIVATE_BCB_PIN_OBJECT(captive_PublicBcb_to_PrivateBcbObject(Bcb));
51
52         captive_private_bcb_pin_object_detach_pin(captive_private_bcb_pin_object);
53
54         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"leave: CcSetBcbOwnerPointer");
55 }
56
57
58 /**
59  * CcUnpinDataForThread:
60  * @Bcb: Initialized #PUBLIC_BCB structure.
61  * %NULL value is forbidden.
62  * @ResourceThreadId: Thread-specific pointer (FIXME: Is it KeGetCurrentThread()?).
63  * This pointer had to be passed to CcSetBcbOwnerPointer() #Owner parameter previously.
64  * %NULL value is forbidden (FIXME: is it W32 compliant?).
65  *
66  * CcUnpinData() for a thread specified by @ResourceThreadId.
67  * Reverse operation for a pair of CcMapData() and CcSetBcbOwnerPointer().
68  *
69  * libcaptive implements this function as a simple pass to CcUnpinData() as it does not yet
70  * support any threading.
71  */
72 VOID CcUnpinDataForThread(IN PVOID Bcb,IN ERESOURCE_THREAD ResourceThreadId)
73 {
74 CaptivePrivateBcbObject *captive_private_bcb_object;
75
76         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"enter: CcUnpinDataForThread: Bcb=0x%lX,ResourceThreadId=0x%lX",
77                         (long)Bcb,(long)ResourceThreadId);
78
79         g_return_if_fail(Bcb!=NULL);
80         g_return_if_fail(ResourceThreadId!=0);
81
82         captive_private_bcb_object=captive_PublicBcb_to_PrivateBcbObject(Bcb);
83
84         g_object_unref(captive_private_bcb_object);
85
86         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"leave: CcUnpinDataForThread");
87 }