apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/misc/win32 misc.c
Date Sun, 30 Dec 2001 20:46:22 GMT
wrowe       01/12/30 12:46:22

  Modified:    include/arch/win32 misc.h
               misc/win32 misc.c
  Log:
    Never had set the global apr_os_level (outch!)  Also improve the
    versioning for several significant API events.
  
  Revision  Changes    Path
  1.35      +20 -10    apr/include/arch/win32/misc.h
  
  Index: misc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/misc.h,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- misc.h	27 Nov 2001 03:08:58 -0000	1.34
  +++ misc.h	30 Dec 2001 20:46:22 -0000	1.35
  @@ -104,16 +104,26 @@
    * export new kernel or winsock functions or behavior.
    */
   typedef enum {
  -        APR_WIN_UNK = 0,
  -        APR_WIN_95 = 2,
  -        APR_WIN_98 = 4,
  -        APR_WIN_NT = 8,
  -        APR_WIN_NT_4 = 12,
  -        APR_WIN_NT_4_SP2 = 14,
  -        APR_WIN_NT_4_SP3 = 15,
  -        APR_WIN_NT_4_SP4 = 16,
  -        APR_WIN_NT_4_SP6 = 18,
  -        APR_WIN_2000 = 24
  +        APR_WIN_UNK =       0,
  +        APR_WIN_UNSUP =     1,
  +        APR_WIN_95 =       10,
  +        APR_WIN_95_B =     11,
  +        APR_WIN_95_OSR2 =  12,
  +        APR_WIN_98 =       14,
  +        APR_WIN_98_SE =    16,
  +        APR_WIN_ME =       18,
  +        APR_WIN_NT_3_5 =   35,
  +        APR_WIN_NT_3_51 =  36,
  +        APR_WIN_NT_4 =     40,
  +        APR_WIN_NT_4_SP2 = 42,
  +        APR_WIN_NT_4_SP3 = 43,
  +        APR_WIN_NT_4_SP4 = 44,
  +        APR_WIN_NT_4_SP5 = 45,
  +        APR_WIN_NT_4_SP6 = 46,
  +        APR_WIN_2000 =     50,
  +        APR_WIN_2000_SP1 = 51,
  +        APR_WIN_2000_SP2 = 52,
  +        APR_WIN_XP =       60
   } apr_oslevel_e;
   
   extern apr_oslevel_e apr_os_level;
  
  
  
  1.7       +79 -36    apr/misc/win32/misc.c
  
  Index: misc.c
  ===================================================================
  RCS file: /home/cvs/apr/misc/win32/misc.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- misc.c	28 Dec 2001 23:50:49 -0000	1.6
  +++ misc.c	30 Dec 2001 20:46:22 -0000	1.7
  @@ -62,60 +62,103 @@
       if (apr_os_level == APR_WIN_UNK) 
       {
           static OSVERSIONINFO oslev;
  -        static unsigned int servpack = 0;
  -        char *pservpack;
  -
           oslev.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
           GetVersionEx(&oslev);
  -        if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) {
  -            for (pservpack = oslev.szCSDVersion; 
  -                 *pservpack && !isdigit(*pservpack); pservpack++)
  -                ;
  -            if (*pservpack)
  -                servpack = atoi(pservpack);
  -        }
  -        if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) {
  -            if (oslev.dwMajorVersion == 5) {
  -                (*level) = APR_WIN_2000;
  +
  +        if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) 
  +        {
  +            static unsigned int servpack = 0;
  +            char *pservpack;
  +            if (pservpack = oslev.szCSDVersion) {
  +                while (*pservpack && !isdigit(*pservpack)) {
  +                    pservpack++;
  +                }
  +                if (*pservpack)
  +                    servpack = atoi(pservpack);
               }
  -            else if (oslev.dwMajorVersion == 4) {
  -                if (servpack >= 6) {
  -                    (*level) = APR_WIN_NT_4_SP6;
  +
  +            if (oslev.dwMajorVersion < 3) {
  +                apr_os_level = APR_WIN_UNSUP;
  +            }
  +            else if (oslev.dwMajorVersion == 3) {
  +                if (oslev.dwMajorVersion < 50) {
  +                    apr_os_level = APR_WIN_UNSUP;
                   }
  -                else if (servpack >= 4) {
  -                    (*level) = APR_WIN_NT_4_SP4;
  +                else if (oslev.dwMajorVersion == 50) {
  +                    apr_os_level = APR_WIN_NT_3_5;
                   }
  -                else if (servpack >= 3) {
  -                    (*level) = APR_WIN_NT_4_SP3;
  +                else {
  +                    apr_os_level = APR_WIN_NT_3_51;
                   }
  -                else if (servpack >= 2) {
  -                    (*level) = APR_WIN_NT_4_SP2;
  +            }
  +            else if (oslev.dwMajorVersion == 4) {
  +                if (servpack < 2)
  +                    apr_os_level = APR_WIN_NT_4;
  +                else if (servpack <= 2)
  +                    apr_os_level = APR_WIN_NT_4_SP2;
  +                else if (servpack <= 3)
  +                    apr_os_level = APR_WIN_NT_4_SP3;
  +                else if (servpack <= 4)
  +                    apr_os_level = APR_WIN_NT_4_SP4;
  +                else if (servpack <= 5)
  +                    apr_os_level = APR_WIN_NT_4_SP5;
  +                else 
  +                    apr_os_level = APR_WIN_NT_4_SP6;
  +            }
  +            else if (oslev.dwMajorVersion == 5) {
  +                if (oslev.dwMinorVersion == 0) {
  +                    if (servpack == 0)
  +                        apr_os_level = APR_WIN_2000;
  +                    else if (servpack == 1)
  +                        apr_os_level = APR_WIN_2000_SP1;
  +                    else
  +                        apr_os_level = APR_WIN_2000_SP2;
                   }
                   else {
  -                    (*level) = APR_WIN_NT_4;
  +                    apr_os_level = APR_WIN_XP;
                   }
               }
               else {
  -                (*level) = APR_WIN_NT;
  +                apr_os_level = APR_WIN_XP;
               }
  -            return APR_SUCCESS;
           }
           else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
  -            if (oslev.dwMinorVersion == 0) {
  -                (*level) = APR_WIN_95;
  -                return APR_SUCCESS;
  -            }
  -            else if (oslev.dwMinorVersion > 0) {
  -                (*level) = APR_WIN_98;
  -                return APR_SUCCESS;
  +            char *prevision;
  +            if (prevision = oslev.szCSDVersion) {
  +                while (*prevision && !isupper(*prevision)) {
  +                     prevision++;
  +                }
  +            }
  +            else prevision = "";
  +
  +            if (oslev.dwMinorVersion < 10) {
  +                if (*prevision < 'C')
  +                    apr_os_level = APR_WIN_95;
  +                else
  +                    apr_os_level = APR_WIN_95_OSR2;
  +            }
  +            else if (oslev.dwMinorVersion < 90) {
  +                if (*prevision < 'A')
  +                    apr_os_level = APR_WIN_98;
  +                else
  +                    apr_os_level = APR_WIN_98_SE;
  +            }
  +            else {
  +                apr_os_level = APR_WIN_ME;
               }
           }
  +        else {
  +            apr_os_level = APR_WIN_UNSUP;
  +        }
       }
  -    else {
  -        *level = apr_os_level;
  -        return APR_SUCCESS;
  +
  +    *level = apr_os_level;
  +
  +    if (apr_os_level < APR_WIN_UNSUP) {
  +        return APR_EGENERAL;
       }
  -    return APR_EGENERAL;
  +
  +    return APR_SUCCESS;
   }
   
   
  
  
  

Mime
View raw message