svn commit: samba r4686 - in branches/SAMBA_4_0/source/lib/socket: .
metze at samba.org
metze at samba.org
Tue Jan 11 15:19:32 GMT 2005
Author: metze
Date: 2005-01-11 15:19:32 +0000 (Tue, 11 Jan 2005)
New Revision: 4686
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4686
Log:
cerate a function to create a socket by specifying an socket_ops struct
metze
Modified:
branches/SAMBA_4_0/source/lib/socket/socket.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/socket/socket.c
===================================================================
--- branches/SAMBA_4_0/source/lib/socket/socket.c 2005-01-11 15:18:18 UTC (rev 4685)
+++ branches/SAMBA_4_0/source/lib/socket/socket.c 2005-01-11 15:19:32 UTC (rev 4686)
@@ -32,27 +32,23 @@
return 0;
}
-NTSTATUS socket_create(const char *name, enum socket_type type, struct socket_context **new_sock, uint32_t flags)
+NTSTATUS socket_create_with_ops(TALLOC_CTX *mem_ctx, const struct socket_ops *ops, struct socket_context **new_sock, uint32_t flags)
{
NTSTATUS status;
- (*new_sock) = talloc_p(NULL, struct socket_context);
+ (*new_sock) = talloc(mem_ctx, struct socket_context);
if (!(*new_sock)) {
return NT_STATUS_NO_MEMORY;
}
- (*new_sock)->type = type;
+ (*new_sock)->type = ops->type;
(*new_sock)->state = SOCKET_STATE_UNDEFINED;
(*new_sock)->flags = flags;
(*new_sock)->fd = -1;
(*new_sock)->private_data = NULL;
- (*new_sock)->ops = socket_getops_byname(name, type);
- if (!(*new_sock)->ops) {
- talloc_free(*new_sock);
- return NT_STATUS_INVALID_PARAMETER;
- }
+ (*new_sock)->ops = ops;
status = (*new_sock)->ops->fn_init((*new_sock));
if (!NT_STATUS_IS_OK(status)) {
@@ -73,6 +69,18 @@
return NT_STATUS_OK;
}
+NTSTATUS socket_create(const char *name, enum socket_type type, struct socket_context **new_sock, uint32_t flags)
+{
+ const struct socket_ops *ops;
+
+ ops = socket_getops_byname(name, type);
+ if (!ops) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ return socket_create_with_ops(NULL, ops, new_sock, flags);
+}
+
void socket_destroy(struct socket_context *sock)
{
/* the close is handled by the destructor */
More information about the samba-cvs
mailing list