Release 960717
[wine/multimedia.git] / library / libres.c
blobf7b450e08c7288b23784d92c386c3d5c841891dd
1 /*
2 * WINElib-Resources
4 * Copied and modified heavily from loader/resource.c
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "libres.h"
10 #include "windows.h"
11 #include "xmalloc.h"
13 typedef struct RLE
15 const struct resource* const * Resources; /* NULL-terminated array of pointers */
16 struct RLE* next;
17 } ResListE;
19 static ResListE* ResourceList=NULL;
21 void LIBRES_RegisterResources(const struct resource* const * Res)
23 ResListE** Curr;
24 ResListE* n;
25 for(Curr=&ResourceList; *Curr; Curr=&((*Curr)->next)) { }
26 n=xmalloc(sizeof(ResListE));
27 n->Resources=Res;
28 n->next=NULL;
29 *Curr=n;
32 /**********************************************************************
33 * LIBRES_FindResource
35 HRSRC32 LIBRES_FindResource( HINSTANCE hModule, LPCSTR name, LPCSTR type )
37 int nameid=0,typeid;
38 ResListE* ResBlock;
39 const struct resource* const * Res;
41 if(HIWORD(name))
43 if(*name=='#')
45 nameid=atoi(name+1);
46 name=NULL;
49 else
51 nameid=LOWORD(name);
52 name=NULL;
54 if(HIWORD(type))
56 if(*type=='#')
57 typeid=atoi(type+1);
58 else
60 WINELIB_UNIMP("LIBRES_FindResource(*,*,type=string)");
61 return 0;
64 else
65 typeid=LOWORD(type);
67 for(ResBlock=ResourceList; ResBlock; ResBlock=ResBlock->next)
68 for(Res=ResBlock->Resources; *Res; Res++)
69 if(name)
71 if((*Res)->type==typeid && !lstrcmpi32A((*Res)->name,name))
72 return (HRSRC32)*Res;
74 else
75 if((*Res)->type==typeid && (*Res)->id==nameid)
76 return (HRSRC32)*Res;
77 return 0;
81 /**********************************************************************
82 * LIBRES_LoadResource
84 HGLOBAL32 LIBRES_LoadResource( HINSTANCE hModule, HRSRC32 hRsrc )
86 return (HGLOBAL32)(((struct resource*)hRsrc)->bytes);
90 /**********************************************************************
91 * LIBRES_LockResource
93 LPVOID LIBRES_LockResource( HGLOBAL32 handle )
95 return (LPVOID)handle;
99 /**********************************************************************
100 * LIBRES_FreeResource
102 BOOL LIBRES_FreeResource( HGLOBAL handle )
104 return 0; /* Obsolete in Win32 */
108 /**********************************************************************
109 * LIBRES_AccessResource
111 INT LIBRES_AccessResource( HINSTANCE hModule, HRSRC hRsrc )
113 WINELIB_UNIMP("LIBRES_AccessResource()");
114 return -1; /* Obsolete in Win32 */
118 /**********************************************************************
119 * LIBRES_SizeofResource
121 DWORD LIBRES_SizeofResource( HINSTANCE hModule, HRSRC32 hRsrc )
123 return (DWORD)(((struct resource*)hRsrc)->size);
127 /**********************************************************************
128 * LIBRES_AllocResource
130 HGLOBAL LIBRES_AllocResource( HINSTANCE hModule, HRSRC hRsrc, DWORD size )
132 WINELIB_UNIMP("LIBRES_AllocResource()");
133 return 0; /* Obsolete in Win32 */