libassa
3.5.0
|
00001 // -*- c++ -*- 00002 //------------------------------------------------------------------------------ 00003 // UNIXAddress.C 00004 //------------------------------------------------------------------------------ 00005 // Copyright (C) 1997-2002 Vladislav Grinchenko 00006 // 00007 // This library is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU Library General Public 00009 // License as published by the Free Software Foundation; either 00010 // version 2 of the License, or (at your option) any later version. 00011 //------------------------------------------------------------------------------ 00012 // Created: 03/22/99 00013 //------------------------------------------------------------------------------ 00014 00015 #include "assa/UNIXAddress.h" 00016 00017 #if !defined (WIN32) 00018 00019 using namespace ASSA; 00020 00021 UNIXAddress:: 00022 UNIXAddress (const char* socket_name_) 00023 { 00024 trace("UNIXAddress::UNIXAddress(char* name_)"); 00025 00026 size_t len; 00027 m_address.sun_family = AF_UNIX; 00028 00029 if ( (len = strlen(socket_name_)) > sizeof(m_address.sun_path) ) { 00030 EL((ASSAERR,"Socket path name is too long (%d bytes)\n", len)); 00031 setstate (Address::badbit); 00032 } 00033 strcpy (m_address.sun_path, socket_name_); 00034 } 00035 00036 UNIXAddress:: 00037 UNIXAddress (SA* saddr_) 00038 { 00039 trace("UNIXAddress::UNIXAddress(SA_UN*)"); 00040 00041 SA_UN* sa_un = (SA_UN*) saddr_; 00042 m_address.sun_family = AF_UNIX; 00043 00044 size_t len = strlen(sa_un->sun_path); 00045 00046 if ( len > sizeof (m_address.sun_path) - 1 ) { 00047 EL((ASSAERR,"Socket path name is too long (%d bytes)\n", len)); 00048 setstate (Address::badbit); 00049 } 00050 strcpy(m_address.sun_path, sa_un->sun_path); 00051 } 00052 00053 #endif /* !def WIN32 */