ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

epmp.c
Go to the documentation of this file.
00001 /*
00002  * Endpoint Mapper
00003  *
00004  * Copyright (C) 2007 Robert Shearman for CodeWeavers
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include "epm_s.h"
00022 
00023 #include "wine/debug.h"
00024 #include "wine/list.h"
00025 
00026 WINE_DEFAULT_DEBUG_CHANNEL(ole);
00027 
00028 struct registered_ept_entry
00029 {
00030     struct list entry;
00031     GUID object;
00032     RPC_SYNTAX_IDENTIFIER iface;
00033     RPC_SYNTAX_IDENTIFIER syntax;
00034     char *protseq;
00035     char *endpoint;
00036     char *address;
00037     char annotation[ept_max_annotation_size];
00038 };
00039 
00040 static struct list registered_ept_entry_list = LIST_INIT(registered_ept_entry_list);
00041 
00042 static CRITICAL_SECTION csEpm;
00043 static CRITICAL_SECTION_DEBUG critsect_debug =
00044 {
00045     0, 0, &csEpm,
00046     { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
00047     0, 0, { (DWORD_PTR)(__FILE__ ": csEpm") }
00048 };
00049 static CRITICAL_SECTION csEpm = { &critsect_debug, -1, 0, 0, 0, 0 };
00050 
00051 static const UUID nil_object;
00052 
00053 /* must be called inside csEpm */
00054 static void delete_registered_ept_entry(struct registered_ept_entry *entry)
00055 {
00056     I_RpcFree(entry->protseq);
00057     I_RpcFree(entry->endpoint);
00058     I_RpcFree(entry->address);
00059     list_remove(&entry->entry);
00060     HeapFree(GetProcessHeap(), 0, entry);
00061 }
00062 
00063 static struct registered_ept_entry *find_ept_entry(
00064     const RPC_SYNTAX_IDENTIFIER *iface, const RPC_SYNTAX_IDENTIFIER *syntax,
00065     const char *protseq, const char *endpoint, const char *address,
00066     const UUID *object)
00067 {
00068     struct registered_ept_entry *entry;
00069     LIST_FOR_EACH_ENTRY(entry, &registered_ept_entry_list, struct registered_ept_entry, entry)
00070     {
00071         if (memcmp(&entry->iface, iface, sizeof(RPC_SYNTAX_IDENTIFIER))) continue;
00072         if (memcmp(&entry->syntax, syntax, sizeof(RPC_SYNTAX_IDENTIFIER))) continue;
00073         if (strcmp(entry->protseq, protseq)) continue;
00074         if (memcmp(&entry->object, object, sizeof(UUID))) continue;
00075     WINE_TRACE("found entry with iface %d.%d %s, syntax %d.%d %s, protseq %s, object %s\n",
00076                    entry->iface.SyntaxVersion.MajorVersion, entry->iface.SyntaxVersion.MinorVersion,
00077                    wine_dbgstr_guid(&entry->iface.SyntaxGUID),
00078                    entry->syntax.SyntaxVersion.MajorVersion, entry->syntax.SyntaxVersion.MinorVersion,
00079                    wine_dbgstr_guid(&entry->syntax.SyntaxGUID), protseq,
00080                    wine_dbgstr_guid(&entry->object));
00081         return entry;
00082     }
00083     WINE_TRACE("not found\n");
00084     return NULL;
00085 }
00086 
00087 void __RPC_USER ept_lookup_handle_t_rundown(ept_lookup_handle_t entry_handle)
00088 {
00089     WINE_FIXME("%p\n", entry_handle);
00090 }
00091 
00092 void ept_insert(handle_t h,
00093                 unsigned32 num_ents,
00094                 ept_entry_t entries[],
00095                 boolean32 replace,
00096                 error_status_t *status)
00097 {
00098     unsigned32 i;
00099     RPC_STATUS rpc_status;
00100 
00101     WINE_TRACE("(%p, %lu, %p, %lu, %p)\n", h, num_ents, entries, replace, status);
00102 
00103     *status = RPC_S_OK;
00104 
00105     EnterCriticalSection(&csEpm);
00106 
00107     for (i = 0; i < num_ents; i++)
00108     {
00109         struct registered_ept_entry *entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
00110         if (!entry)
00111         {
00112             /* FIXME: cleanup code to delete added entries */
00113             *status = EPT_S_CANT_PERFORM_OP;
00114             break;
00115         }
00116         list_init(&entry->entry);
00117         memcpy(entry->annotation, entries[i].annotation, sizeof(entries[i].annotation));
00118         rpc_status = TowerExplode(entries[i].tower, &entry->iface, &entry->syntax,
00119                                   &entry->protseq, &entry->endpoint,
00120                                   &entry->address);
00121         if (rpc_status != RPC_S_OK)
00122         {
00123             WINE_WARN("TowerExplode failed %lu\n", rpc_status);
00124             *status = rpc_status;
00125             break; /* FIXME: more cleanup? */
00126         }
00127 
00128         entry->object = entries[i].object;
00129 
00130         if (replace)
00131         {
00132             /* FIXME: correct find algorithm */
00133             struct registered_ept_entry *old_entry = find_ept_entry(&entry->iface, &entry->syntax, entry->protseq, entry->endpoint, entry->address, &entry->object);
00134             if (old_entry) delete_registered_ept_entry(old_entry);
00135         }
00136         list_add_tail(&registered_ept_entry_list, &entry->entry);
00137     }
00138 
00139     LeaveCriticalSection(&csEpm);
00140 }
00141 
00142 void ept_delete(handle_t h,
00143                 unsigned32 num_ents,
00144                 ept_entry_t entries[],
00145                 error_status_t *status)
00146 {
00147     unsigned32 i;
00148     RPC_STATUS rpc_status;
00149 
00150     *status = RPC_S_OK;
00151 
00152     WINE_TRACE("(%p, %lu, %p, %p)\n", h, num_ents, entries, status);
00153 
00154     EnterCriticalSection(&csEpm);
00155 
00156     for (i = 0; i < num_ents; i++)
00157     {
00158         struct registered_ept_entry *entry;
00159         RPC_SYNTAX_IDENTIFIER iface, syntax;
00160         char *protseq;
00161         char *endpoint;
00162         char *address;
00163         rpc_status = TowerExplode(entries[i].tower, &iface, &syntax, &protseq,
00164                                   &endpoint, &address);
00165         if (rpc_status != RPC_S_OK)
00166             break;
00167         entry = find_ept_entry(&iface, &syntax, protseq, endpoint, address, &entries[i].object);
00168         if (entry)
00169             delete_registered_ept_entry(entry);
00170         else
00171         {
00172             *status = EPT_S_NOT_REGISTERED;
00173             break;
00174         }
00175         I_RpcFree(protseq);
00176         I_RpcFree(endpoint);
00177         I_RpcFree(address);
00178     }
00179 
00180     LeaveCriticalSection(&csEpm);
00181 }
00182 
00183 void ept_lookup(handle_t h,
00184                 unsigned32 inquiry_type,
00185                 uuid_p_t object,
00186                 rpc_if_id_p_t interface_id,
00187                 unsigned32 vers_option,
00188                 ept_lookup_handle_t *entry_handle,
00189                 unsigned32 max_ents,
00190                 unsigned32 *num_ents,
00191                 ept_entry_t entries[],
00192                 error_status_t *status)
00193 {
00194     WINE_FIXME("(%p, %p, %p): stub\n", h, entry_handle, status);
00195 
00196     *status = EPT_S_CANT_PERFORM_OP;
00197 }
00198 
00199 void ept_map(handle_t h,
00200              uuid_p_t object,
00201              twr_p_t map_tower,
00202              ept_lookup_handle_t *entry_handle,
00203              unsigned32 max_towers,
00204              unsigned32 *num_towers,
00205              twr_p_t *towers,
00206              error_status_t *status)
00207 {
00208     RPC_STATUS rpc_status;
00209     RPC_SYNTAX_IDENTIFIER iface, syntax;
00210     char *protseq;
00211     struct registered_ept_entry *entry;
00212 
00213     *status = RPC_S_OK;
00214     *num_towers = 0;
00215 
00216     WINE_TRACE("(%p, %p, %p, %p, %lu, %p, %p, %p)\n", h, object, map_tower,
00217           entry_handle, max_towers, num_towers, towers, status);
00218 
00219     rpc_status = TowerExplode(map_tower, &iface, &syntax, &protseq,
00220                               NULL, NULL);
00221     if (rpc_status != RPC_S_OK)
00222     {
00223         *status = rpc_status;
00224         return;
00225     }
00226 
00227     EnterCriticalSection(&csEpm);
00228 
00229     LIST_FOR_EACH_ENTRY(entry, &registered_ept_entry_list, struct registered_ept_entry, entry)
00230     {
00231         if (IsEqualGUID(&entry->iface.SyntaxGUID, &iface.SyntaxGUID) &&
00232             (entry->iface.SyntaxVersion.MajorVersion == iface.SyntaxVersion.MajorVersion) &&
00233             (entry->iface.SyntaxVersion.MinorVersion >= iface.SyntaxVersion.MinorVersion) &&
00234             !memcmp(&entry->syntax, &syntax, sizeof(syntax)) &&
00235             !strcmp(entry->protseq, protseq) &&
00236             ((!object && IsEqualGUID(&entry->object, &nil_object)) || IsEqualGUID(object, &entry->object)))
00237         {
00238             if (*num_towers < max_towers)
00239             {
00240                 rpc_status = TowerConstruct(&entry->iface, &entry->syntax,
00241                                             entry->protseq, entry->endpoint,
00242                                             entry->address,
00243                                             &towers[*num_towers]);
00244                 if (rpc_status != RPC_S_OK)
00245                 {
00246                     *status = rpc_status;
00247                     break; /* FIXME: more cleanup? */
00248                 }
00249             }
00250             (*num_towers)++;
00251         }
00252     }
00253 
00254     LeaveCriticalSection(&csEpm);
00255 }
00256 
00257 void ept_lookup_handle_free(handle_t h,
00258                             ept_lookup_handle_t *entry_handle,
00259                             error_status_t *status)
00260 {
00261     WINE_FIXME("(%p, %p, %p): stub\n", h, entry_handle, status);
00262 
00263     *status = EPT_S_CANT_PERFORM_OP;
00264 }
00265 
00266 void ept_inq_object(handle_t h,
00267                     GUID *ept_object,
00268                     error_status_t *status)
00269 {
00270     WINE_FIXME("(%p, %p, %p): stub\n", h, ept_object, status);
00271 
00272     *status = EPT_S_CANT_PERFORM_OP;
00273 }
00274 
00275 void ept_mgmt_delete(handle_t h,
00276                      boolean32 object_speced,
00277                      uuid_p_t object,
00278                      twr_p_t tower,
00279                      error_status_t *status)
00280 {
00281     WINE_FIXME("(%p, %ld, %p, %p, %p): stub\n", h, object_speced, object, tower, status);
00282 
00283     *status = EPT_S_CANT_PERFORM_OP;
00284 }

Generated on Sat May 26 2012 04:16:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.