Mixe for Privacy and Anonymity in the Internet
CASocketAddrUnix.cpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2000, The JAP-Team
3
All rights reserved.
4
Redistribution and use in source and binary forms, with or without modification,
5
are permitted provided that the following conditions are met:
6
7
- Redistributions of source code must retain the above copyright notice,
8
this list of conditions and the following disclaimer.
9
10
- Redistributions in binary form must reproduce the above copyright notice,
11
this list of conditions and the following disclaimer in the documentation and/or
12
other materials provided with the distribution.
13
14
- Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
15
may be used to endorse or promote products derived from this software without specific
16
prior written permission.
17
18
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
20
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
22
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
27
*/
28
#include "
StdAfx.h
"
29
#ifdef HAVE_UNIX_DOMAIN_PROTOCOL
30
#include "
CASocketAddrUnix.hpp
"
31
32
34
CASocketAddrUnix::CASocketAddrUnix
()
35
{
36
sun_family=
AF_LOCAL
;
37
memset(sun_path,0,
sizeof
(sun_path));
38
}
39
41
CASocketAddrUnix::CASocketAddrUnix
(
const
CASocketAddrUnix
& addr)
42
{
43
sun_family=
AF_LOCAL
;
44
memcpy(sun_path,addr.sun_path,
sizeof
(sun_path));
45
}
46
53
SINT32
CASocketAddrUnix::setPath
(
const
char
* path)
54
{
55
if
(path==NULL)
56
return
E_UNSPECIFIED
;
57
// ((sockaddr_un*)m_pAddr)->sun_len=strlen(path);
58
if
(strlen(path)>=
sizeof
(sun_path))
59
return
E_SPACE
;
60
strcpy(sun_path,path);
61
return
E_SUCCESS
;
62
}
63
69
UINT8
*
CASocketAddrUnix::getPath
()
const
70
{
71
UINT32
len
=strlen(sun_path);
72
if
(
len
==0)
73
return
NULL;
74
UINT8
* p=
new
UINT8
[
len
+1];
75
strcpy((
char
*)p,sun_path);
76
return
p;
77
}
78
79
#endif
CASocketAddrUnix.hpp
StdAfx.h
AF_LOCAL
#define AF_LOCAL
Definition:
StdAfx.h:482
SINT32
signed int SINT32
Definition:
basetypedefs.h:132
UINT8
unsigned char UINT8
Definition:
basetypedefs.h:135
UINT32
unsigned int UINT32
Definition:
basetypedefs.h:131
CASocketAddrUnix
This is a class for Unix Domain Protocol Sockat Addresses.
Definition:
CASocketAddrUnix.hpp:34
CASocketAddrUnix::getPath
UINT8 * getPath() const
Retruns the path of this address.
Definition:
CASocketAddrUnix.cpp:69
CASocketAddrUnix::CASocketAddrUnix
CASocketAddrUnix()
Constructs an address with an empty path.
Definition:
CASocketAddrUnix.cpp:34
CASocketAddrUnix::setPath
SINT32 setPath(const char *path)
Sets the path of this unix address.
Definition:
CASocketAddrUnix.cpp:53
E_SUCCESS
const SINT32 E_SUCCESS
Definition:
errorcodes.hpp:2
E_SPACE
#define E_SPACE
Definition:
errorcodes.hpp:7
E_UNSPECIFIED
#define E_UNSPECIFIED
Definition:
errorcodes.hpp:6
len
UINT16 len
Definition:
typedefs.hpp:0
Generated on Sat Jul 22 2023 00:20:12 for Mixe for Privacy and Anonymity in the Internet by
1.9.1