~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/crypt32/proplist.c

Version: ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Copyright 2004-2006 Juan Lang
  3  *
  4  * This library is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2.1 of the License, or (at your option) any later version.
  8  *
  9  * This library 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 GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with this library; if not, write to the Free Software
 16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 17  */
 18 #include <assert.h>
 19 #include <stdarg.h>
 20 #include "windef.h"
 21 #include "winbase.h"
 22 #include "wincrypt.h"
 23 #include "wine/debug.h"
 24 #include "wine/list.h"
 25 #include "crypt32_private.h"
 26 
 27 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
 28 
 29 typedef struct _CONTEXT_PROPERTY_LIST
 30 {
 31     CRITICAL_SECTION cs;
 32     struct list      properties;
 33 } CONTEXT_PROPERTY_LIST;
 34 
 35 typedef struct _CONTEXT_PROPERTY
 36 {
 37     DWORD       propID;
 38     DWORD       cbData;
 39     LPBYTE      pbData;
 40     struct list entry;
 41 } CONTEXT_PROPERTY, *PCONTEXT_PROPERTY;
 42 
 43 PCONTEXT_PROPERTY_LIST ContextPropertyList_Create(void)
 44 {
 45     PCONTEXT_PROPERTY_LIST list = CryptMemAlloc(sizeof(CONTEXT_PROPERTY_LIST));
 46 
 47     if (list)
 48     {
 49         InitializeCriticalSection(&list->cs);
 50         list->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PCONTEXT_PROPERTY_LIST->cs");
 51         list_init(&list->properties);
 52     }
 53     return list;
 54 }
 55 
 56 void ContextPropertyList_Free(PCONTEXT_PROPERTY_LIST list)
 57 {
 58     PCONTEXT_PROPERTY prop, next;
 59 
 60     LIST_FOR_EACH_ENTRY_SAFE(prop, next, &list->properties, CONTEXT_PROPERTY,
 61      entry)
 62     {
 63         list_remove(&prop->entry);
 64         CryptMemFree(prop->pbData);
 65         CryptMemFree(prop);
 66     }
 67     list->cs.DebugInfo->Spare[0] = 0;
 68     DeleteCriticalSection(&list->cs);
 69     CryptMemFree(list);
 70 }
 71 
 72 BOOL ContextPropertyList_FindProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
 73  PCRYPT_DATA_BLOB blob)
 74 {
 75     PCONTEXT_PROPERTY prop;
 76     BOOL ret = FALSE;
 77 
 78     TRACE("(%p, %d, %p)\n", list, id, blob);
 79 
 80     EnterCriticalSection(&list->cs);
 81     LIST_FOR_EACH_ENTRY(prop, &list->properties, CONTEXT_PROPERTY, entry)
 82     {
 83         if (prop->propID == id)
 84         {
 85             blob->cbData = prop->cbData;
 86             blob->pbData = prop->pbData;
 87             ret = TRUE;
 88             break;
 89         }
 90     }
 91     LeaveCriticalSection(&list->cs);
 92     return ret;
 93 }
 94 
 95 BOOL ContextPropertyList_SetProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
 96  const BYTE *pbData, size_t cbData)
 97 {
 98     LPBYTE data;
 99     BOOL ret = FALSE;
100 
101     if (cbData)
102     {
103         data = CryptMemAlloc(cbData);
104         if (data)
105             memcpy(data, pbData, cbData);
106     }
107     else
108         data = NULL;
109     if (!cbData || data)
110     {
111         PCONTEXT_PROPERTY prop;
112         BOOL found = FALSE;
113 
114         EnterCriticalSection(&list->cs);
115         LIST_FOR_EACH_ENTRY(prop, &list->properties, CONTEXT_PROPERTY, entry)
116         {
117             if (prop->propID == id)
118             {
119                 found = TRUE;
120                 break;
121             }
122         }
123         if (found)
124         {
125             CryptMemFree(prop->pbData);
126             prop->cbData = cbData;
127             prop->pbData = data;
128             ret = TRUE;
129         }
130         else
131         {
132             prop = CryptMemAlloc(sizeof(CONTEXT_PROPERTY));
133             if (prop)
134             {
135                 prop->propID = id;
136                 prop->cbData = cbData;
137                 prop->pbData = data;
138                 list_add_tail(&list->properties, &prop->entry);
139                 ret = TRUE;
140             }
141             else
142                 CryptMemFree(data);
143         }
144         LeaveCriticalSection(&list->cs);
145     }
146     return ret;
147 }
148 
149 void ContextPropertyList_RemoveProperty(PCONTEXT_PROPERTY_LIST list, DWORD id)
150 {
151     PCONTEXT_PROPERTY prop, next;
152 
153     EnterCriticalSection(&list->cs);
154     LIST_FOR_EACH_ENTRY_SAFE(prop, next, &list->properties, CONTEXT_PROPERTY,
155      entry)
156     {
157         if (prop->propID == id)
158         {
159             list_remove(&prop->entry);
160             CryptMemFree(prop->pbData);
161             CryptMemFree(prop);
162             break;
163         }
164     }
165     LeaveCriticalSection(&list->cs);
166 }
167 
168 /* Since the properties are stored in a list, this is a tad inefficient
169  * (O(n^2)) since I have to find the previous position every time.
170  */
171 DWORD ContextPropertyList_EnumPropIDs(PCONTEXT_PROPERTY_LIST list, DWORD id)
172 {
173     DWORD ret;
174 
175     EnterCriticalSection(&list->cs);
176     if (id)
177     {
178         PCONTEXT_PROPERTY cursor = NULL;
179 
180         LIST_FOR_EACH_ENTRY(cursor, &list->properties, CONTEXT_PROPERTY, entry)
181         {
182             if (cursor->propID == id)
183                 break;
184         }
185         if (cursor)
186         {
187             if (cursor->entry.next != &list->properties)
188                 ret = LIST_ENTRY(cursor->entry.next, CONTEXT_PROPERTY,
189                  entry)->propID;
190             else
191                 ret = 0;
192         }
193         else
194             ret = 0;
195     }
196     else if (!list_empty(&list->properties))
197         ret = LIST_ENTRY(list->properties.next, CONTEXT_PROPERTY,
198          entry)->propID;
199     else
200         ret = 0;
201     LeaveCriticalSection(&list->cs);
202     return ret;
203 }
204 
205 void ContextPropertyList_Copy(PCONTEXT_PROPERTY_LIST to,
206  PCONTEXT_PROPERTY_LIST from)
207 {
208     PCONTEXT_PROPERTY prop;
209 
210     EnterCriticalSection(&from->cs);
211     LIST_FOR_EACH_ENTRY(prop, &from->properties, CONTEXT_PROPERTY, entry)
212     {
213         ContextPropertyList_SetProperty(to, prop->propID, prop->pbData,
214          prop->cbData);
215     }
216     LeaveCriticalSection(&from->cs);
217 }
218 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.