Implemented the IPersistStream interface on the OLE font object.
[wine/multimedia.git] / loader / libres.c
blobd2ed8a1799149439f5bb69721f54e498ebdd0463
1 /*
2 * WINElib-Resources
4 * Copied and modified heavily from loader/resource.c
5 */
7 #include <stdlib.h>
8 #include "wine/winestring.h"
9 #include "libres.h"
10 #include "resource.h"
11 #include "debug.h"
12 #include "heap.h"
13 #include "xmalloc.h"
15 typedef struct RLE
17 const wrc_resource32_t * const * Resources; /* NULL-terminated array of pointers */
18 struct RLE* next;
19 } ResListE;
21 static ResListE* ResourceList=NULL;
23 void LIBRES_RegisterResources(const wrc_resource32_t * const * Res)
25 ResListE** Curr;
26 ResListE* n;
27 for(Curr=&ResourceList; *Curr; Curr=&((*Curr)->next)) { }
28 n=xmalloc(sizeof(ResListE));
29 n->Resources=Res;
30 n->next=NULL;
31 *Curr=n;
34 /**********************************************************************
35 * LIBRES_FindResource
37 HRSRC LIBRES_FindResource( HINSTANCE hModule, LPCWSTR name, LPCWSTR type )
39 int nameid=0,typeid;
40 ResListE* ResBlock;
41 const wrc_resource32_t* const * Res;
43 if(HIWORD(name))
45 if(*name=='#')
47 LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
48 nameid = atoi(nameA+1);
49 HeapFree( GetProcessHeap(), 0, nameA );
50 name=NULL;
53 else
55 nameid=LOWORD(name);
56 name=NULL;
58 if(HIWORD(type))
60 if(*type=='#')
62 LPSTR typeA = HEAP_strdupWtoA( GetProcessHeap(), 0, type );
63 typeid=atoi(typeA+1);
64 HeapFree( GetProcessHeap(), 0, typeA );
66 else
68 TRACE(resource, "(*,*,type=string): Returning 0\n");
69 return 0;
72 else
73 typeid=LOWORD(type);
75 /* FIXME: types can be strings */
76 for(ResBlock=ResourceList; ResBlock; ResBlock=ResBlock->next)
77 for(Res=ResBlock->Resources; *Res; Res++)
78 if(name)
80 if((*Res)->restype==typeid && !lstrncmpiW((LPCWSTR)((*Res)->resname+1), name, *((*Res)->resname)))
81 return (HRSRC)*Res;
83 else
84 if((*Res)->restype==typeid && (*Res)->resid==nameid)
85 return (HRSRC)*Res;
86 return 0;
90 /**********************************************************************
91 * LIBRES_LoadResource
93 HGLOBAL LIBRES_LoadResource( HINSTANCE hModule, HRSRC hRsrc )
95 return (HGLOBAL)(((wrc_resource32_t*)hRsrc)->data);
99 /**********************************************************************
100 * LIBRES_SizeofResource
102 DWORD LIBRES_SizeofResource( HINSTANCE hModule, HRSRC hRsrc )
104 return (DWORD)(((wrc_resource32_t*)hRsrc)->datasize);