File: UNIXAddress.cpp

package info (click to toggle)
libassa 3.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,084 kB
  • ctags: 2,323
  • sloc: cpp: 15,641; sh: 8,704; makefile: 372; perl: 51
file content (53 lines) | stat: -rw-r--r-- 1,581 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// -*- c++ -*-
//------------------------------------------------------------------------------
//                           UNIXAddress.C
//------------------------------------------------------------------------------
//  Copyright (C) 1997-2002  Vladislav Grinchenko 
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Library General Public
//  License as published by the Free Software Foundation; either
//  version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
//  Created: 03/22/99
//------------------------------------------------------------------------------

#include "assa/UNIXAddress.h"

#if !defined (WIN32)

using namespace ASSA;

UNIXAddress::
UNIXAddress (const char* socket_name_)
{
	trace("UNIXAddress::UNIXAddress(char* name_)");
	
	size_t len;
	m_address.sun_family = AF_UNIX;
	
	if ( (len = strlen(socket_name_)) > sizeof(m_address.sun_path) ) {
		EL((ASSAERR,"Socket path name is too long (%d bytes)\n", len));
		setstate (Address::badbit);
	}
	strcpy (m_address.sun_path, socket_name_);
}

UNIXAddress::
UNIXAddress (SA* saddr_)
{
	trace("UNIXAddress::UNIXAddress(SA_UN*)");

	SA_UN* sa_un = (SA_UN*) saddr_;
	m_address.sun_family = AF_UNIX;
	
	size_t len = strlen(sa_un->sun_path);

	if ( len > sizeof (m_address.sun_path) - 1 ) {
		EL((ASSAERR,"Socket path name is too long (%d bytes)\n", len));
		setstate (Address::badbit);
	}
	strcpy(m_address.sun_path, sa_un->sun_path);
}

#endif /* !def WIN32 */