libdrizzle Developer Documentation
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
libdrizzle
conn_uds.c
Go to the documentation of this file.
1
/*
2
* Drizzle Client & Protocol Library
3
*
4
* Copyright (C) 2008 Eric Day (eday@oddments.org)
5
* All rights reserved.
6
*
7
* Use and distribution licensed under the BSD license. See
8
* the COPYING file in this directory for full text.
9
*/
10
16
#include "
common.h
"
17
18
const
char
*
drizzle_con_uds
(
const
drizzle_con_st
*con)
19
{
20
if
(con->
socket_type
==
DRIZZLE_CON_SOCKET_UDS
)
21
{
22
if
(con->
socket
.
uds
.
sockaddr
.sun_path[0] != 0)
23
return
con->
socket
.
uds
.
sockaddr
.sun_path;
24
25
if
(con->
options
&
DRIZZLE_CON_MYSQL
)
26
return
DRIZZLE_DEFAULT_UDS_MYSQL
;
27
28
return
DRIZZLE_DEFAULT_UDS
;
29
}
30
31
return
NULL;
32
}
33
34
void
drizzle_con_set_uds
(
drizzle_con_st
*con,
const
char
*uds)
35
{
36
drizzle_con_reset_addrinfo
(con);
37
38
con->
socket_type
=
DRIZZLE_CON_SOCKET_UDS
;
39
40
if
(uds == NULL)
41
uds=
""
;
42
43
con->
socket
.
uds
.
sockaddr
.sun_family= AF_UNIX;
44
strncpy(con->
socket
.
uds
.
sockaddr
.sun_path, uds,
45
sizeof
(con->
socket
.
uds
.
sockaddr
.sun_path));
46
con->
socket
.
uds
.
sockaddr
.sun_path[
sizeof
(con->
socket
.
uds
.
sockaddr
.sun_path) - 1]= 0;
47
48
con->
socket
.
uds
.
addrinfo
.ai_family= AF_UNIX;
49
con->
socket
.
uds
.
addrinfo
.ai_socktype= SOCK_STREAM;
50
con->
socket
.
uds
.
addrinfo
.ai_protocol= 0;
51
con->
socket
.
uds
.
addrinfo
.ai_addrlen=
sizeof
(
struct
sockaddr_un);
52
con->
socket
.
uds
.
addrinfo
.ai_addr= (
struct
sockaddr *)&(con->
socket
.
uds
.
sockaddr
);
53
}
Generated by
1.8.1.1