summaryrefslogtreecommitdiff
path: root/libmailutils/sockaddr/create.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmailutils/sockaddr/create.c')
-rw-r--r--libmailutils/sockaddr/create.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/libmailutils/sockaddr/create.c b/libmailutils/sockaddr/create.c
new file mode 100644
index 000000000..5b49471e6
--- /dev/null
+++ b/libmailutils/sockaddr/create.c
@@ -0,0 +1,47 @@
1/* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2011 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifdef HAVE_CONFIG_H
19# include <config.h>
20#endif
21
22#include <stdlib.h>
23#include <errno.h>
24#include <string.h>
25#include <mailutils/sockaddr.h>
26
27int
28mu_sockaddr_create (struct mu_sockaddr **res,
29 struct sockaddr *addr, socklen_t len)
30{
31 struct mu_sockaddr *sa;
32
33 sa = calloc (1, sizeof (*sa));
34 if (!sa)
35 return ENOMEM;
36 sa->addr = malloc (len);
37 if (!sa->addr)
38 {
39 free (sa);
40 return ENOMEM;
41 }
42 memcpy (sa->addr, addr, len);
43 sa->addrlen = len;
44 *res = sa;
45 return 0;
46}
47

Return to:

Send suggestions and report system problems to the System administrator.