libassa 3.5.1
Loading...
Searching...
No Matches
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
19using namespace ASSA;
20
22UNIXAddress (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
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 */
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition Logger.h:429
#define EL(X)
A macro for writing error message to the Logger.
Definition Logger.h:285
UNIXAddress encapsulates UNIX domain socket address structure.
void setstate(addrstate flag_)
Set state of the Address object.
Definition Address.h:111
@ badbit
bad state
Definition Address.h:56
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
SA_UN m_address
UNIX socket address structure.
Definition UNIXAddress.h:51
UNIXAddress(const char *socket_name_)
Constructor.
@ ASSAERR
ASSA and system errors
Definition LogMask.h:34
struct sockaddr SA
Definition Address.h:33