1 /******************************************************************************* 2 3 Copyright: 4 Copyright (c) 2009-2016 dunnhumby Germany GmbH. 5 All rights reserved. 6 7 License: 8 Boost Software License Version 1.0. See LICENSE_BOOST.txt for details. 9 Alternatively, this file may be distributed under the terms of the Tango 10 3-Clause BSD License (see LICENSE_BSD.txt for details). 11 12 *******************************************************************************/ 13 14 15 module ocean.stdc.posix.sys.un; 16 17 import ocean.meta.types.Qualifiers; 18 19 public import core.sys.posix.sys.un; 20 import core.sys.posix.sys.socket; 21 22 extern (C): 23 24 static immutable UNIX_PATH_MAX = 108; 25 26 align(1) 27 struct sockaddr_un 28 { 29 align(1): 30 ushort sun_family; 31 char[UNIX_PATH_MAX] sun_path; 32 33 /*********************************************************************** 34 35 Creates the instance of sockaddr_un with the sun_path set 36 and with the `sin_family` set to `AF_UNIX`. 37 38 Params: 39 path = path of the socket (can't be longer than 107 bytes) 40 41 ***********************************************************************/ 42 43 public static sockaddr_un create (cstring path) 44 in 45 { 46 assert(typeof(this).sun_path.length > path.length, 47 "Can't set path longer than UNIX_PATH_MAX."); 48 } 49 do 50 { 51 sockaddr_un addr; 52 addr.sun_path[0..path.length] = path; 53 addr.sun_path[path.length] = '\0'; 54 addr.sun_family = AF_UNIX; 55 return addr; 56 } 57 }