OLD | NEW |
1 /* ***** BEGIN LICENSE BLOCK ***** | 1 /* ***** BEGIN LICENSE BLOCK ***** |
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
3 * | 3 * |
4 * The contents of this file are subject to the Mozilla Public License Version | 4 * The contents of this file are subject to the Mozilla Public License Version |
5 * 1.1 (the "License"); you may not use this file except in compliance with | 5 * 1.1 (the "License"); you may not use this file except in compliance with |
6 * the License. You may obtain a copy of the License at | 6 * the License. You may obtain a copy of the License at |
7 * http://www.mozilla.org/MPL/ | 7 * http://www.mozilla.org/MPL/ |
8 * | 8 * |
9 * Software distributed under the License is distributed on an "AS IS" basis, | 9 * Software distributed under the License is distributed on an "AS IS" basis, |
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
(...skipping 17 matching lines...) Expand all Loading... |
28 * under the terms of either the GPL or the LGPL, and not to allow others to | 28 * under the terms of either the GPL or the LGPL, and not to allow others to |
29 * use your version of this file under the terms of the MPL, indicate your | 29 * use your version of this file under the terms of the MPL, indicate your |
30 * decision by deleting the provisions above and replace them with the notice | 30 * decision by deleting the provisions above and replace them with the notice |
31 * and other provisions required by the GPL or the LGPL. If you do not delete | 31 * and other provisions required by the GPL or the LGPL. If you do not delete |
32 * the provisions above, a recipient may use your version of this file under | 32 * the provisions above, a recipient may use your version of this file under |
33 * the terms of any one of the MPL, the GPL or the LGPL. | 33 * the terms of any one of the MPL, the GPL or the LGPL. |
34 * | 34 * |
35 * ***** END LICENSE BLOCK ***** */ | 35 * ***** END LICENSE BLOCK ***** */ |
36 | 36 |
37 #ifdef DEBUG | 37 #ifdef DEBUG |
38 static const char CVS_ID[] = "@(#) $RCSfile: devtoken.c,v $ $Revision: 1.53 $ $D
ate: 2010/01/08 02:00:58 $"; | 38 static const char CVS_ID[] = "@(#) $RCSfile: devtoken.c,v $ $Revision: 1.54 $ $D
ate: 2010/04/03 18:27:30 $"; |
39 #endif /* DEBUG */ | 39 #endif /* DEBUG */ |
40 | 40 |
41 #include "pkcs11.h" | 41 #include "pkcs11.h" |
42 | 42 |
43 #ifndef DEVM_H | 43 #ifndef DEVM_H |
44 #include "devm.h" | 44 #include "devm.h" |
45 #endif /* DEVM_H */ | 45 #endif /* DEVM_H */ |
46 | 46 |
47 #ifndef CKHELPER_H | 47 #ifndef CKHELPER_H |
48 #include "ckhelper.h" | 48 #include "ckhelper.h" |
49 #endif /* CKHELPER_H */ | 49 #endif /* CKHELPER_H */ |
50 | 50 |
51 #include "pk11func.h" | 51 #include "pk11func.h" |
52 #include "dev3hack.h" | 52 #include "dev3hack.h" |
53 #include "secerr.h" | 53 #include "secerr.h" |
54 | 54 |
55 extern const NSSError NSS_ERROR_NOT_FOUND; | 55 extern const NSSError NSS_ERROR_NOT_FOUND; |
56 extern const NSSError NSS_ERROR_INVALID_ARGUMENT; | 56 extern const NSSError NSS_ERROR_INVALID_ARGUMENT; |
57 extern const NSSError NSS_ERROR_PKCS11; | 57 extern const NSSError NSS_ERROR_PKCS11; |
58 | 58 |
59 /* The number of object handles to grab during each call to C_FindObjects */ | 59 /* The number of object handles to grab during each call to C_FindObjects */ |
60 #define OBJECT_STACK_SIZE 16 | 60 #define OBJECT_STACK_SIZE 16 |
61 | 61 |
62 NSS_IMPLEMENT PRStatus | 62 NSS_IMPLEMENT PRStatus |
63 nssToken_Destroy ( | 63 nssToken_Destroy ( |
64 NSSToken *tok | 64 NSSToken *tok |
65 ) | 65 ) |
66 { | 66 { |
67 if (tok) { | 67 if (tok) { |
68 » if (PR_AtomicDecrement(&tok->base.refCount) == 0) { | 68 » if (PR_ATOMIC_DECREMENT(&tok->base.refCount) == 0) { |
69 PZ_DestroyLock(tok->base.lock); | 69 PZ_DestroyLock(tok->base.lock); |
70 nssTokenObjectCache_Destroy(tok->cache); | 70 nssTokenObjectCache_Destroy(tok->cache); |
71 /* The token holds the first/last reference to the slot. | 71 /* The token holds the first/last reference to the slot. |
72 * When the token is actually destroyed, that ref must go too. | 72 * When the token is actually destroyed, that ref must go too. |
73 */ | 73 */ |
74 (void)nssSlot_Destroy(tok->slot); | 74 (void)nssSlot_Destroy(tok->slot); |
75 return nssArena_Destroy(tok->base.arena); | 75 return nssArena_Destroy(tok->base.arena); |
76 } | 76 } |
77 } | 77 } |
78 return PR_SUCCESS; | 78 return PR_SUCCESS; |
(...skipping 13 matching lines...) Expand all Loading... |
92 ) | 92 ) |
93 { | 93 { |
94 (void)nssToken_Destroy(tok); | 94 (void)nssToken_Destroy(tok); |
95 } | 95 } |
96 | 96 |
97 NSS_IMPLEMENT NSSToken * | 97 NSS_IMPLEMENT NSSToken * |
98 nssToken_AddRef ( | 98 nssToken_AddRef ( |
99 NSSToken *tok | 99 NSSToken *tok |
100 ) | 100 ) |
101 { | 101 { |
102 PR_AtomicIncrement(&tok->base.refCount); | 102 PR_ATOMIC_INCREMENT(&tok->base.refCount); |
103 return tok; | 103 return tok; |
104 } | 104 } |
105 | 105 |
106 NSS_IMPLEMENT NSSSlot * | 106 NSS_IMPLEMENT NSSSlot * |
107 nssToken_GetSlot ( | 107 nssToken_GetSlot ( |
108 NSSToken *tok | 108 NSSToken *tok |
109 ) | 109 ) |
110 { | 110 { |
111 return nssSlot_AddRef(tok->slot); | 111 return nssSlot_AddRef(tok->slot); |
112 } | 112 } |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 theClass = CKO_PRIVATE_KEY; | 1609 theClass = CKO_PRIVATE_KEY; |
1610 if (!nssSlot_IsLoggedIn(token->slot)) { | 1610 if (!nssSlot_IsLoggedIn(token->slot)) { |
1611 theClass = CKO_PUBLIC_KEY; | 1611 theClass = CKO_PUBLIC_KEY; |
1612 } | 1612 } |
1613 if (PK11_MatchItem(token->pk11slot, instance->handle, theClass) | 1613 if (PK11_MatchItem(token->pk11slot, instance->handle, theClass) |
1614 != CK_INVALID_HANDLE) { | 1614 != CK_INVALID_HANDLE) { |
1615 return PR_TRUE; | 1615 return PR_TRUE; |
1616 } | 1616 } |
1617 return PR_FALSE; | 1617 return PR_FALSE; |
1618 } | 1618 } |
OLD | NEW |