libassa  3.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
UNIXAddress.cpp
Go to the documentation of this file.
1 // -*- c++ -*-
2 //------------------------------------------------------------------------------
3 // UNIXAddress.C
4 //------------------------------------------------------------------------------
5 // Copyright (C) 1997-2002 Vladislav Grinchenko
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //------------------------------------------------------------------------------
12 // Created: 03/22/99
13 //------------------------------------------------------------------------------
14 
15 #include "assa/UNIXAddress.h"
16 
17 #if !defined (WIN32)
18 
19 using namespace ASSA;
20 
22 UNIXAddress (const char* socket_name_)
23 {
24  trace("UNIXAddress::UNIXAddress(char* name_)");
25 
26  size_t len;
27  m_address.sun_family = AF_UNIX;
28 
29  if ( (len = strlen(socket_name_)) > sizeof(m_address.sun_path) ) {
30  EL((ASSAERR,"Socket path name is too long (%d bytes)\n", len));
32  }
33  strcpy (m_address.sun_path, socket_name_);
34 }
35 
37 UNIXAddress (SA* saddr_)
38 {
39  trace("UNIXAddress::UNIXAddress(SA_UN*)");
40 
41  SA_UN* sa_un = (SA_UN*) saddr_;
42  m_address.sun_family = AF_UNIX;
43 
44  size_t len = strlen(sa_un->sun_path);
45 
46  if ( len > sizeof (m_address.sun_path) - 1 ) {
47  EL((ASSAERR,"Socket path name is too long (%d bytes)\n", len));
49  }
50  strcpy(m_address.sun_path, sa_un->sun_path);
51 }
52 
53 #endif /* !def WIN32 */