Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Sock_Connect.cpp File Reference

#include "ace_pch.h"
#include "ace/Sock_Connect.h"
#include "ace/OS.h"
#include "ace/INET_Addr.h"
#include "ace/Log_Msg.h"
#include "ace/Handle_Set.h"
#include "ace/Auto_Ptr.h"
#include "ace/SString.h"

Include dependency graph for Sock_Connect.cpp:

Include dependency graph

Go to the source code of this file.

Enumerations

enum  ACE_WINDOWS_VERSION {
  ACE_WINDOWS_IS_UNKNOWN, ACE_WINDOWS_IS_WIN95, ACE_WINDOWS_IS_WIN98, ACE_WINDOWS_IS_WINME,
  ACE_WINDOWS_IS_WINNT, ACE_WINDOWS_IS_WIN2K, ACE_WINDOWS_IS_WINCE
}

Functions

const char * get_rcsid_ace_Sock_Connect (const char *)
int get_reg_subkeys (const ACE_TCHAR *key, ACE_TCHAR *buffer, DWORD &buf_len)
int get_reg_value (const ACE_TCHAR *key, const ACE_TCHAR *name, ACE_TCHAR *buffer, DWORD &buf_len, int all_subkeys=0)
ACE_WINDOWS_VERSION get_windows_version ()

Variables

const char * rcsid_ace_Sock_Connect = get_rcsid_ace_Sock_Connect ( rcsid_ace_Sock_Connect )


Enumeration Type Documentation

enum ACE_WINDOWS_VERSION
 

Enumeration values:
ACE_WINDOWS_IS_UNKNOWN 
ACE_WINDOWS_IS_WIN95 
ACE_WINDOWS_IS_WIN98 
ACE_WINDOWS_IS_WINME 
ACE_WINDOWS_IS_WINNT 
ACE_WINDOWS_IS_WIN2K 
ACE_WINDOWS_IS_WINCE 

Definition at line 199 of file Sock_Connect.cpp.

Referenced by ACE_Sock_Connect::get_ip_interfaces.


Function Documentation

const char* get_rcsid_ace_Sock_Connect const char *    [inline, static]
 

Definition at line 56 of file Sock_Connect.cpp.

00056 : Sock_Connect.cpp,v 1.1.1.2.2.1 2003/03/13 19:44:22 chad Exp $")

int get_reg_subkeys const ACE_TCHAR   key,
ACE_TCHAR   buffer,
DWORD &    buf_len
[static]
 

Definition at line 63 of file Sock_Connect.cpp.

References ACE_MAX_FULLY_QUALIFIED_NAME_LEN, ACE_TCHAR, and ACE_OS_String::strcpy.

00066 {
00067   HKEY hk;
00068   LONG rc = ACE_TEXT_RegOpenKeyEx (HKEY_LOCAL_MACHINE,
00069                                    key,
00070                                    0,
00071                                    KEY_READ,
00072                                    &hk);
00073 
00074   if (rc != ERROR_SUCCESS)
00075     return -1;
00076 
00077   ACE_TCHAR subkeyname[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1];
00078   DWORD subkeyname_len = ACE_MAX_FULLY_QUALIFIED_NAME_LEN;
00079   FILETIME update_dummy;
00080 
00081   DWORD total = 0;
00082 
00083   for (int i = 0;
00084        (rc = ACE_TEXT_RegEnumKeyEx (hk, i,
00085                                     subkeyname,
00086                                     &subkeyname_len,
00087                                     0, 0, 0,
00088                                     &update_dummy)) != ERROR_NO_MORE_ITEMS;
00089         ++i)
00090     {
00091       if (subkeyname_len < buf_len - total)
00092         {
00093           ACE_OS::strcpy(buffer + total, subkeyname);
00094           total += subkeyname_len + 1;
00095           // Reset: was changed by RegEnumKeyEx call.
00096           subkeyname_len = ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1;
00097         }
00098       else
00099         return -1;
00100     }
00101 
00102   buf_len = total;
00103 
00104   ::RegCloseKey (hk);
00105   return 0;
00106 }

int get_reg_value const ACE_TCHAR   key,
const ACE_TCHAR   name,
ACE_TCHAR   buffer,
DWORD &    buf_len,
int    all_subkeys = 0
[static]
 

Definition at line 113 of file Sock_Connect.cpp.

References ACE_MAX_FULLY_QUALIFIED_NAME_LEN, and ACE_TCHAR.

Referenced by ACE_Sock_Connect::get_ip_interfaces.

00118 {
00119   HKEY hk;
00120   DWORD buf_type;
00121   LONG rc = ACE_TEXT_RegOpenKeyEx (HKEY_LOCAL_MACHINE,
00122                                    key,
00123                                    0,
00124                                    KEY_READ,
00125                                    &hk);
00126 
00127   if (rc != ERROR_SUCCESS)
00128     // print_error_string(ACE_LIB_TEXT ("RegOpenKeyEx"), rc);
00129     return -1;
00130 
00131   if (all_subkeys)
00132     {
00133       ACE_TCHAR ifname[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1];
00134       DWORD ifname_len = ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1;
00135       FILETIME update_dummy;
00136 
00137       DWORD total = 0;
00138       DWORD size = buf_len;
00139 
00140       for (int i = 0;
00141            (rc = ACE_TEXT_RegEnumKeyEx (hk, i, ifname, &ifname_len,
00142                                         0, 0, 0,
00143                                         &update_dummy)) != ERROR_NO_MORE_ITEMS;
00144            ++i)
00145         {
00146           HKEY ifkey;
00147           if (rc != ERROR_SUCCESS
00148               || ACE_TEXT_RegOpenKeyEx (hk, ifname, 0,
00149                                         KEY_READ, &ifkey) != ERROR_SUCCESS)
00150             continue;
00151 
00152           if (ACE_TEXT_RegQueryValueEx (ifkey, name, 0, 0,
00153                                         (u_char*) (buffer + total),
00154                                         &size) != ERROR_SUCCESS)
00155             {
00156               RegCloseKey(ifkey);
00157               continue;
00158             }
00159           else
00160             {
00161               total += size;
00162               size = buf_len - total;
00163             }
00164           // Needs to be reset.
00165           ifname_len = ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1;
00166         }
00167 
00168       if (total == 0)
00169         {
00170           ::RegCloseKey (hk);
00171           return -2;
00172         }
00173       else
00174         {
00175           buf_len = total;
00176         }
00177     }
00178   else
00179     {
00180 
00181       rc = ACE_TEXT_RegQueryValueEx (hk,
00182                                      name,
00183                                      0,
00184                                      &buf_type,
00185                                      (u_char *) buffer,
00186                                      &buf_len);
00187       if (rc != ERROR_SUCCESS)
00188         {
00189           // print_error_string(ACE_LIB_TEXT ("RegEnumKeyEx"), rc);
00190           RegCloseKey (hk);
00191           return -2;
00192         }
00193     }
00194 
00195   ::RegCloseKey (hk);
00196   return 0;
00197 }

ACE_WINDOWS_VERSION get_windows_version   [static]
 

Definition at line 210 of file Sock_Connect.cpp.

References ACE_WINDOWS_IS_UNKNOWN, ACE_WINDOWS_IS_WIN2K, ACE_WINDOWS_IS_WIN95, ACE_WINDOWS_IS_WIN98, ACE_WINDOWS_IS_WINCE, ACE_WINDOWS_IS_WINME, and ACE_WINDOWS_IS_WINNT.

Referenced by ACE_Sock_Connect::get_ip_interfaces.

00211 {
00212   OSVERSIONINFO vinfo;
00213   vinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00214   if (::GetVersionEx(&vinfo) == 0)
00215     {
00216       return ACE_WINDOWS_IS_UNKNOWN;
00217     }
00218 
00219   switch (vinfo.dwPlatformId)
00220     {
00221     case VER_PLATFORM_WIN32_NT:
00222       if (vinfo.dwMajorVersion <= 4)
00223         return ACE_WINDOWS_IS_WINNT;
00224       else
00225         return ACE_WINDOWS_IS_WIN2K;
00226     case VER_PLATFORM_WIN32_WINDOWS:
00227       if (vinfo.dwMajorVersion == 4)
00228         {
00229           if (vinfo.dwMinorVersion == 0)
00230             return ACE_WINDOWS_IS_WIN95;
00231           else if (vinfo.dwMinorVersion == 10)
00232             return ACE_WINDOWS_IS_WIN98;
00233           else if (vinfo.dwMinorVersion == 90)
00234             return ACE_WINDOWS_IS_WINME;
00235         }
00236     case VER_PLATFORM_WIN32_CE:
00237         if (vinfo.dwMajorVersion >= 3) {
00238             return ACE_WINDOWS_IS_WINCE;
00239         }
00240         else {
00241             return ACE_WINDOWS_IS_UNKNOWN;
00242         }
00243       // If no match we fall throu.
00244     default:
00245       return ACE_WINDOWS_IS_UNKNOWN;
00246     }
00247 }


Variable Documentation

const char* rcsid_ace_Sock_Connect = get_rcsid_ace_Sock_Connect ( rcsid_ace_Sock_Connect ) [static]
 

Definition at line 56 of file Sock_Connect.cpp.


Generated on Mon Jun 16 12:26:22 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002