]> git.sesse.net Git - vlc/blobdiff - libs/loader/resource.c
Removes trailing spaces. Removes tabs.
[vlc] / libs / loader / resource.c
index 3560dd07309919256f4b6e24a74ef27822cb0b61..dd05a3b407bbd3bf3db0c50d83334227c6d26fcc 100644 (file)
@@ -46,7 +46,7 @@
 #include "wine/winerror.h"
 #include "loader.h"
 
-#define CP_ACP                                 0
+#define CP_ACP                    0
 
 WORD WINE_LanguageId=0x409;//english
 
@@ -66,32 +66,32 @@ typedef struct _HRSRC_MAP
 } HRSRC_MAP;
 
 static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type,
-                               LPCSTR name, WORD lang, int unicode)
+                LPCSTR name, WORD lang, int unicode)
 {
     HRSRC hRsrc = 0;
-    LPWSTR typeStr, nameStr;    
+    LPWSTR typeStr, nameStr;
     WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
 
     if(!wm)
-       return 0;    
+    return 0;
     /* 32-bit PE module */
 
-    
     if ( HIWORD( type ) && (!unicode))
-       typeStr = HEAP_strdupAtoW( GetProcessHeap(), 0, type );
+    typeStr = HEAP_strdupAtoW( GetProcessHeap(), 0, type );
     else
-       typeStr = (LPWSTR)type;
+    typeStr = (LPWSTR)type;
     if ( HIWORD( name ) && (!unicode))
-       nameStr = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
+    nameStr = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
     else
-       nameStr = (LPWSTR)name;
-    
+    nameStr = (LPWSTR)name;
     hRsrc = PE_FindResourceExW( wm, nameStr, typeStr, lang );
-    
-    if ( HIWORD( type ) && (!unicode)) 
-       HeapFree( GetProcessHeap(), 0, typeStr );
-    if ( HIWORD( name ) && (!unicode)) 
-       HeapFree( GetProcessHeap(), 0, nameStr );
+    if ( HIWORD( type ) && (!unicode))
+    HeapFree( GetProcessHeap(), 0, typeStr );
+    if ( HIWORD( name ) && (!unicode))
+    HeapFree( GetProcessHeap(), 0, nameStr );
 
     return hRsrc;
 }
@@ -106,13 +106,13 @@ static HRSRC RES_FindResource( HMODULE hModule, LPCSTR type,
     HRSRC hRsrc;
 //    __TRY
 //    {
-       hRsrc = RES_FindResource2(hModule, type, name, lang, unicode);
+    hRsrc = RES_FindResource2(hModule, type, name, lang, unicode);
 //    }
 //    __EXCEPT(page_fault)
 //    {
-//     WARN("page fault\n");
-//     SetLastError(ERROR_INVALID_PARAMETER);
-//     return 0;
+//    WARN("page fault\n");
+//    SetLastError(ERROR_INVALID_PARAMETER);
+//    return 0;
 //    }
 //    __ENDTRY
     return hRsrc;
@@ -128,7 +128,7 @@ static DWORD RES_SizeofResource( HMODULE hModule, HRSRC hRsrc)
 
 //    HMODULE16 hMod16   = MapHModuleLS( hModule );
 //    NE_MODULE *pModule = NE_GetPtr( hMod16 );
-//    WINE_MODREF *wm    = pModule && pModule->module32? 
+//    WINE_MODREF *wm    = pModule && pModule->module32?
 //                         MODULE32_LookupHMODULE( pModule->module32 ) : NULL;
     WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
 
@@ -139,9 +139,9 @@ static DWORD RES_SizeofResource( HMODULE hModule, HRSRC hRsrc)
 //    hRsrc32  = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc );
     if(!HIWORD(hRsrc))
     {
-       printf("16-bit hRsrcs not supported\n");
-       return 0;
-    }  
+    printf("16-bit hRsrcs not supported\n");
+    return 0;
+    }    
     size = PE_SizeofResource( hModule, hRsrc );
     return size;
 }
@@ -182,8 +182,8 @@ static HGLOBAL RES_LoadResource( HMODULE hModule, HRSRC hRsrc)
 //    hRsrc32 = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc );
     if(!HIWORD(hRsrc))
     {
-       printf("16-bit hRsrcs not supported\n");
-       return 0;
+    printf("16-bit hRsrcs not supported\n");
+    return 0;
     }
     hMem = PE_LoadResource( wm, hRsrc );
 
@@ -214,40 +214,40 @@ static WIN_BOOL RES_FreeResource( HGLOBAL handle )
 }
 
 /**********************************************************************
- *         FindResourceA    (KERNEL32.128)
+ *        FindResourceA    (KERNEL32.128)
  */
 HANDLE WINAPI FindResourceA( HMODULE hModule, LPCSTR name, LPCSTR type )
 {
-    return RES_FindResource( hModule, type, name, 
+    return RES_FindResource( hModule, type, name,
                              WINE_LanguageId, 0);
 }
 HANDLE WINAPI FindResourceW( HMODULE hModule, LPCWSTR name, LPCWSTR type )
 {
-    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name, 
+    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name,
                              WINE_LanguageId, 1);
 }
 
 /**********************************************************************
- *         FindResourceExA  (KERNEL32.129)
+ *        FindResourceExA  (KERNEL32.129)
  */
-HANDLE WINAPI FindResourceExA( HMODULE hModule, 
+HANDLE WINAPI FindResourceExA( HMODULE hModule,
                                LPCSTR type, LPCSTR name, WORD lang )
 {
-    return RES_FindResource( hModule, type, name, 
+    return RES_FindResource( hModule, type, name,
                              lang, 0 );
 }
 
-HANDLE WINAPI FindResourceExW( HMODULE hModule, 
+HANDLE WINAPI FindResourceExW( HMODULE hModule,
                                LPCWSTR type, LPCWSTR name, WORD lang )
 {
-    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name, 
+    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name,
                              lang, 1 );
 }
 
 
 
 /**********************************************************************
- *         LockResource     (KERNEL32.384)
+ *        LockResource     (KERNEL32.384)
  */
 LPVOID WINAPI LockResource( HGLOBAL handle )
 {
@@ -256,7 +256,7 @@ LPVOID WINAPI LockResource( HGLOBAL handle )
 
 
 /**********************************************************************
- *         FreeResource     (KERNEL32.145)
+ *        FreeResource     (KERNEL32.145)
  */
 WIN_BOOL WINAPI FreeResource( HGLOBAL handle )
 {
@@ -265,14 +265,14 @@ WIN_BOOL WINAPI FreeResource( HGLOBAL handle )
 
 
 /**********************************************************************
- *         AccessResource   (KERNEL32.64)
+ *        AccessResource   (KERNEL32.64)
  */
 INT WINAPI AccessResource( HMODULE hModule, HRSRC hRsrc )
 {
     return RES_AccessResource( hModule, hRsrc );
 }
 /**********************************************************************
- *         SizeofResource   (KERNEL32.522)
+ *        SizeofResource   (KERNEL32.522)
  */
 DWORD WINAPI SizeofResource( HINSTANCE hModule, HRSRC hRsrc )
 {
@@ -284,7 +284,7 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
                             LPWSTR buffer, INT buflen );
 
 /**********************************************************************
- *     LoadStringA     (USER32.375)
+ *    LoadStringA    (USER32.375)
  */
 INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
                             LPSTR buffer, INT buflen )
@@ -296,11 +296,11 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
     LPSTR  abuf = NULL;
 
     if ( buffer != NULL && buflen > 0 )
-       *buffer = 0;
+    *buffer = 0;
 
     wbuflen = LoadStringW(instance,resource_id,NULL,0);
     if ( !wbuflen )
-       return 0;
+    return 0;
     wbuflen ++;
 
     retval = 0;
@@ -308,25 +308,25 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
     wbuflen = LoadStringW(instance,resource_id,wbuf,wbuflen);
     if ( wbuflen > 0 )
     {
-       abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,NULL,0,NULL,NULL);
-       if ( abuflen > 0 )
-       {
-           if ( buffer == NULL || buflen == 0 )
-               retval = abuflen;
-           else
-           {
-               abuf = (LPSTR) HeapAlloc( GetProcessHeap(), 0, abuflen * sizeof(CHAR) );
-               abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,abuf,abuflen,NULL,NULL);
-               if ( abuflen > 0 )
-               {
-                   abuflen = min(abuflen,buflen - 1);
-                   memcpy( buffer, abuf, abuflen );
-                   buffer[abuflen] = 0;
-                   retval = abuflen;
-               }
-               HeapFree( GetProcessHeap(), 0, abuf );
-           }
-       }
+    abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,NULL,0,NULL,NULL);
+    if ( abuflen > 0 )
+    {
+        if ( buffer == NULL || buflen == 0 )
+        retval = abuflen;
+        else
+        {
+        abuf = (LPSTR) HeapAlloc( GetProcessHeap(), 0, abuflen * sizeof(CHAR) );
+        abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,abuf,abuflen,NULL,NULL);
+        if ( abuflen > 0 )
+        {
+            abuflen = min(abuflen,buflen - 1);
+            memcpy( buffer, abuf, abuflen );
+            buffer[abuflen] = 0;
+            retval = abuflen;
+        }
+        HeapFree( GetProcessHeap(), 0, abuf );
+        }
+    }
     }
     HeapFree( GetProcessHeap(), 0, wbuf );
 
@@ -334,7 +334,7 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
 }
 
 /**********************************************************************
- *     LoadStringW             (USER32.376)
+ *    LoadStringW        (USER32.376)
  */
 INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
                             LPWSTR buffer, INT buflen )
@@ -346,37 +346,37 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
     int i;
 
     if (HIWORD(resource_id)==0xFFFF) /* netscape 3 passes this */
-       resource_id = (UINT)(-((INT)resource_id));
+    resource_id = (UINT)(-((INT)resource_id));
     TRACE("instance = %04x, id = %04x, buffer = %08x, "
           "length = %d\n", instance, (int)resource_id, (int) buffer, buflen);
 
-    /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out 
+    /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out
      * 20 - 31. */
     hrsrc = FindResourceW( instance, (LPCWSTR)(((resource_id>>4)&0xffff)+1),
                              RT_STRINGW );
     if (!hrsrc) return 0;
     hmem = LoadResource( instance, hrsrc );
     if (!hmem) return 0;
-    
     p = (WCHAR*) LockResource(hmem);
     string_num = resource_id & 0x000f;
     for (i = 0; i < string_num; i++)
-       p += *p + 1;
-    
+    p += *p + 1;
     TRACE("strlen = %d\n", (int)*p );
-    
     if (buffer == NULL) return *p;
     i = min(buflen - 1, *p);
     if (i > 0) {
-       memcpy(buffer, p + 1, i * sizeof (WCHAR));
-       buffer[i] = (WCHAR) 0;
+    memcpy(buffer, p + 1, i * sizeof (WCHAR));
+    buffer[i] = (WCHAR) 0;
     } else {
-       if (buflen > 1) {
-           buffer[0] = (WCHAR) 0;
-           return 0;
-       }
+    if (buflen > 1) {
+        buffer[0] = (WCHAR) 0;
+        return 0;
+    }
 #if 0
-       WARN("Don't know why caller give buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1);
+    WARN("Don't know why caller give buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1);
 #endif
     }
 
@@ -385,39 +385,39 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
 }
 
 /* Messages...used by FormatMessage32* (KERNEL32.something)
- * 
+ *
  * They can be specified either directly or using a message ID and
  * loading them from the resource.
- * 
+ *
  * The resourcedata has following format:
  * start:
  * 0: DWORD nrofentries
  * nrofentries * subentry:
- *     0: DWORD firstentry
- *     4: DWORD lastentry
+ *    0: DWORD firstentry
+ *    4: DWORD lastentry
  *      8: DWORD offset from start to the stringentries
  *
  * (lastentry-firstentry) * stringentry:
  * 0: WORD len (0 marks end)
  * 2: WORD flags
  * 4: CHAR[len-4]
- *     (stringentry i of a subentry refers to the ID 'firstentry+i')
+ *     (stringentry i of a subentry refers to the ID 'firstentry+i')
  *
  * Yes, ANSI strings in win32 resources. Go figure.
  */
 
 /**********************************************************************
- *     LoadMessageA            (internal)
+ *    LoadMessageA        (internal)
  */
 INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang,
                       LPSTR buffer, INT buflen )
 {
-    HGLOBAL    hmem;
-    HRSRC      hrsrc;
-    PMESSAGE_RESOURCE_DATA     mrd;
-    PMESSAGE_RESOURCE_BLOCK    mrb;
-    PMESSAGE_RESOURCE_ENTRY    mre;
-    int                i,slen;
+    HGLOBAL    hmem;
+    HRSRC    hrsrc;
+    PMESSAGE_RESOURCE_DATA    mrd;
+    PMESSAGE_RESOURCE_BLOCK    mrb;
+    PMESSAGE_RESOURCE_ENTRY    mre;
+    int        i,slen;
 
     TRACE("instance = %08lx, id = %08lx, buffer = %p, length = %ld\n", (DWORD)instance, (DWORD)id, buffer, (DWORD)buflen);
 
@@ -426,77 +426,77 @@ INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang,
     if (!hrsrc) return 0;
     hmem = LoadResource( instance, hrsrc );
     if (!hmem) return 0;
-    
     mrd = (PMESSAGE_RESOURCE_DATA)LockResource(hmem);
     mre = NULL;
     mrb = &(mrd->Blocks[0]);
     for (i=mrd->NumberOfBlocks;i--;) {
-       if ((id>=mrb->LowId) && (id<=mrb->HighId)) {
-           mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mrd)+mrb->OffsetToEntries);
-           id  -= mrb->LowId;
-           break;
-       }
-       mrb++;
+        if ((id>=mrb->LowId) && (id<=mrb->HighId)) {
+        mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mrd)+mrb->OffsetToEntries);
+        id    -= mrb->LowId;
+        break;
+    }
+    mrb++;
     }
     if (!mre)
-       return 0;
+        return 0;
     for (i=id;i--;) {
-       if (!mre->Length)
-               return 0;
-       mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mre)+(mre->Length));
+        if (!mre->Length)
+        return 0;
+        mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mre)+(mre->Length));
     }
     slen=mre->Length;
-    TRACE("    - strlen=%d\n",slen);
+    TRACE("    - strlen=%d\n",slen);
     i = min(buflen - 1, slen);
     if (buffer == NULL)
-       return slen;
+    return slen;
     if (i>0) {
-       lstrcpynA(buffer,(char*)mre->Text,i);
-       buffer[i]=0;
+    lstrcpynA(buffer,(char*)mre->Text,i);
+    buffer[i]=0;
     } else {
-       if (buflen>1) {
-           buffer[0]=0;
-           return 0;
-       }
+    if (buflen>1) {
+        buffer[0]=0;
+        return 0;
+    }
     }
     if (buffer)
-           TRACE("'%s' copied !\n", buffer);
+        TRACE("'%s' copied !\n", buffer);
     return i;
 }
 
 
 
 /**********************************************************************
- *     EnumResourceTypesA      (KERNEL32.90)
+ *    EnumResourceTypesA    (KERNEL32.90)
  */
 WIN_BOOL WINAPI EnumResourceTypesA( HMODULE hmodule,ENUMRESTYPEPROCA lpfun,
                                     LONG lParam)
 {
-       /* FIXME: move WINE_MODREF stuff here */
+    /* FIXME: move WINE_MODREF stuff here */
     return PE_EnumResourceTypesA(hmodule,lpfun,lParam);
 }
 
 /**********************************************************************
- *     EnumResourceNamesA      (KERNEL32.88)
+ *    EnumResourceNamesA    (KERNEL32.88)
  */
 WIN_BOOL WINAPI EnumResourceNamesA( HMODULE hmodule, LPCSTR type,
                                     ENUMRESNAMEPROCA lpfun, LONG lParam )
 {
-       /* FIXME: move WINE_MODREF stuff here */
+    /* FIXME: move WINE_MODREF stuff here */
     return PE_EnumResourceNamesA(hmodule,type,lpfun,lParam);
 }
 /**********************************************************************
- *     EnumResourceLanguagesA  (KERNEL32.86)
+ *    EnumResourceLanguagesA    (KERNEL32.86)
  */
 WIN_BOOL WINAPI EnumResourceLanguagesA( HMODULE hmodule, LPCSTR type,
                                         LPCSTR name, ENUMRESLANGPROCA lpfun,
                                         LONG lParam)
 {
-       /* FIXME: move WINE_MODREF stuff here */
+    /* FIXME: move WINE_MODREF stuff here */
     return PE_EnumResourceLanguagesA(hmodule,type,name,lpfun,lParam);
 }
 /**********************************************************************
- *         LoadResource     (KERNEL32.370)
+ *        LoadResource     (KERNEL32.370)
  */
 HGLOBAL WINAPI LoadResource( HINSTANCE hModule, HRSRC hRsrc )
 {