Changeset 178

Show
Ignore:
Timestamp:
11/29/04 16:06:04 (4 years ago)
Author:
kris
Message:

changed the license

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mango/base/ByteSwap.d

    r15 r178  
    2424           of the source. 
    2525 
     26        4. Any and all ideas, design, and/or code embodied within remain the  
     27           property of the original author(s). Specifically, they may not be  
     28           used simply to produce a 'competitive' library, or equivalent  
     29           functionality: it is unfortunate that some feel such actions are  
     30           ethical. This clause is retroactive to all prior releases of the  
     31           Mango Tree source-code. Feel free to contact the author for full 
     32           clarification. 
     33            
    2634 
    2735                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/mango/base/System.d

    r122 r178  
    2424           of the source. 
    2525 
     26        4. Any and all ideas, design, and/or code embodied within remain the  
     27           property of the original author(s). Specifically, they may not be  
     28           used simply to produce a 'competitive' library, or equivalent  
     29           functionality: it is unfortunate that some feel such actions are  
     30           ethical. This clause is retroactive to all prior releases of the  
     31           Mango Tree source-code. Feel free to contact the author for full 
     32           clarification. 
     33            
    2634 
    2735                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    4755 
    4856version (Win32) 
    49    
    50    private import std.c.windows.windows; 
    51  
    52    static uint FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; 
    53    static uint FORMAT_MESSAGE_IGNORE_INSERTS  = 0x00000200; 
    54    static uint FORMAT_MESSAGE_FROM_STRING     = 0x00000400; 
    55    static uint FORMAT_MESSAGE_FROM_HMODULE    = 0x00000800; 
    56    static uint FORMAT_MESSAGE_FROM_SYSTEM     = 0x00001000; 
    57    static uint FORMAT_MESSAGE_ARGUMENT_ARRAY  = 0x00002000; 
    58    static uint FORMAT_MESSAGE_MAX_WIDTH_MASK  = 0x000000FF; 
    59  
    60    WORD MAKELANGID(WORD p, WORD s)  { return (((cast(WORD)s) << 10) | cast(WORD)p); } 
    61    WORD PRIMARYLANGID(WORD lgid)    { return (cast(WORD)lgid & 0x3ff); } 
    62    WORD SUBLANGID(WORD lgid)        { return (cast(WORD)lgid >> 10); } 
    63  
    64    alias HGLOBAL HLOCAL; 
    65  
    66    static uint LANG_NEUTRAL = 0x00; 
    67    static uint SUBLANG_DEFAULT = 0x01; 
    68  
    69    extern (Windows)  
    70           { 
    71           DWORD FormatMessageA (DWORD dwFlags, 
    72                     LPCVOID lpSource, 
    73                     DWORD dwMessageId, 
    74                     DWORD dwLanguageId, 
    75                     LPTSTR lpBuffer, 
    76                     DWORD nSize, 
    77                     LPCVOID args 
    78                     ); 
    79  
    80           HLOCAL LocalFree(HLOCAL hMem); 
     57       
     58        private import std.c.windows.windows; 
     59 
     60        static uint FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; 
     61        static uint FORMAT_MESSAGE_IGNORE_INSERTS  = 0x00000200; 
     62        static uint FORMAT_MESSAGE_FROM_STRING     = 0x00000400; 
     63        static uint FORMAT_MESSAGE_FROM_HMODULE    = 0x00000800; 
     64        static uint FORMAT_MESSAGE_FROM_SYSTEM     = 0x00001000; 
     65        static uint FORMAT_MESSAGE_ARGUMENT_ARRAY  = 0x00002000; 
     66        static uint FORMAT_MESSAGE_MAX_WIDTH_MASK  = 0x000000FF; 
     67 
     68        WORD MAKELANGID(WORD p, WORD s)  { return (((cast(WORD)s) << 10) | cast(WORD)p); } 
     69        WORD PRIMARYLANGID(WORD lgid)    { return (cast(WORD)lgid & 0x3ff); } 
     70        WORD SUBLANGID(WORD lgid)        { return (cast(WORD)lgid >> 10); } 
     71 
     72        alias HGLOBAL HLOCAL; 
     73 
     74        static uint LANG_NEUTRAL = 0x00; 
     75        static uint SUBLANG_DEFAULT = 0x01; 
     76 
     77        extern (Windows)  
     78               { 
     79               DWORD FormatMessageA (DWORD dwFlags, 
     80                                     LPCVOID lpSource, 
     81                                     DWORD dwMessageId, 
     82                                     DWORD dwLanguageId, 
     83                                     LPTSTR lpBuffer, 
     84                                     DWORD nSize, 
     85                                     LPCVOID args 
     86                                     ); 
     87 
     88               HLOCAL LocalFree(HLOCAL hMem); 
    8189               int QueryPerformanceCounter (ulong *count); 
    8290               int QueryPerformanceFrequency (ulong *frequency); 
    8391 
    8492               VOID Sleep (DWORD millisecs); 
    85           } 
     93               } 
    8694        } 
    8795 
     
    273281        ***********************************************************************/ 
    274282 
    275    final static char[] error () 
    276    
    277        version (Win32) 
     283        final static char[] error () 
     284       
     285                version (Win32) 
    278286                         return error (GetLastError); 
    279287                     else 
     
    285293        ***********************************************************************/ 
    286294 
    287    final static char[] error (uint errcode) 
    288    
    289        char[] text; 
    290  
    291        version (Win32) 
    292                { 
     295        final static char[] error (uint errcode) 
     296       
     297                char[] text; 
     298 
     299                version (Win32) 
     300                        { 
    293301                        DWORD  r; 
    294             LPVOID lpMsgBuf;             
    295  
    296            r = FormatMessageA (  
    297                FORMAT_MESSAGE_ALLOCATE_BUFFER |  
    298                FORMAT_MESSAGE_FROM_SYSTEM |  
    299                FORMAT_MESSAGE_IGNORE_INSERTS, 
    300                null, 
    301                errcode, 
    302                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 
    303                cast(LPTSTR)&lpMsgBuf, 
    304                0, 
    305                null); 
    306  
    307            /* Remove \r\n from error string */ 
    308            if (r >= 2) r-= 2; 
    309            text = (cast(char *)lpMsgBuf)[0..r].dup; 
    310            LocalFree(cast(HLOCAL)lpMsgBuf); 
    311                } 
    312             else 
    313                { 
     302                        LPVOID lpMsgBuf;                         
     303 
     304                        r = FormatMessageA (  
     305                                FORMAT_MESSAGE_ALLOCATE_BUFFER |  
     306                                FORMAT_MESSAGE_FROM_SYSTEM |  
     307                                FORMAT_MESSAGE_IGNORE_INSERTS, 
     308                                null, 
     309                                errcode, 
     310                                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 
     311                                cast(LPTSTR)&lpMsgBuf, 
     312                                0, 
     313                                null); 
     314 
     315                        /* Remove \r\n from error string */ 
     316                        if (r >= 2) r-= 2; 
     317                        text = (cast(char *)lpMsgBuf)[0..r].dup; 
     318                        LocalFree(cast(HLOCAL)lpMsgBuf); 
     319                        } 
     320                     else 
     321                        { 
    314322                        uint  r; 
    315            char* pemsg; 
    316  
    317            pemsg = strerror(errcode); 
    318            r = strlen(pemsg); 
    319  
    320            /* Remove \r\n from error string */ 
    321            if (pemsg[r-1] == '\n') r--; 
    322            if (pemsg[r-1] == '\r') r--; 
    323            text = pemsg[0..r].dup; 
    324                } 
    325          
    326        return text; 
    327    
     323                        char* pemsg; 
     324 
     325                        pemsg = strerror(errcode); 
     326                        r = strlen(pemsg); 
     327 
     328                        /* Remove \r\n from error string */ 
     329                        if (pemsg[r-1] == '\n') r--; 
     330                        if (pemsg[r-1] == '\r') r--; 
     331                        text = pemsg[0..r].dup; 
     332                        } 
     333                 
     334                return text; 
     335       
    328336} 
    329337