diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2009-01-26 21:56:16 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2009-01-26 21:56:16 +0000 |
commit | c39a0d1bc89de3368f815b27706ae4e00d66c252 (patch) | |
tree | a0843fb765c0673a2ea645e37f2139ecb11b311c | |
parent | fbcefd4a9b43719f72cdcb48271957a443d17f86 (diff) |
move aldap_close in aldap.c, where it belongs.
discussed with aschrijver@
-rw-r--r-- | usr.sbin/ypldap/aldap.c | 23 | ||||
-rw-r--r-- | usr.sbin/ypldap/aldap.h | 5 | ||||
-rw-r--r-- | usr.sbin/ypldap/ldapclient.c | 14 |
3 files changed, 22 insertions, 20 deletions
diff --git a/usr.sbin/ypldap/aldap.c b/usr.sbin/ypldap/aldap.c index dd0a1acb51d..e71afb9682a 100644 --- a/usr.sbin/ypldap/aldap.c +++ b/usr.sbin/ypldap/aldap.c @@ -1,5 +1,5 @@ -/* $Id: aldap.c,v 1.11 2009/01/16 13:11:15 aschrijver Exp $ */ -/* $OpenBSD: aldap.c,v 1.11 2009/01/16 13:11:15 aschrijver Exp $ */ +/* $Id: aldap.c,v 1.12 2009/01/26 21:56:15 pyr Exp $ */ +/* $OpenBSD: aldap.c,v 1.12 2009/01/26 21:56:15 pyr Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> @@ -22,6 +22,7 @@ #include <inttypes.h> #include <string.h> #include <stdlib.h> +#include <unistd.h> #include "aldap.h" @@ -48,6 +49,18 @@ void ldap_debug_elements(struct ber_element *); #define LDAP_DEBUG(x, y) do { } while (0) #endif +int +aldap_close(struct aldap *al) +{ + if(close(al->ber.fd) == -1) + return (-1); + + free(al); + + return (0); +} + + struct aldap * aldap_init(int fd) { @@ -431,11 +444,11 @@ aldap_free_url(struct aldap_url *lu) int aldap_parse_url(char *url, struct aldap_url *lu) { - char *dup, *p, *forward, *forward2; + char *dupstr, *p, *forward, *forward2; const char *errstr = NULL; int i; - p = dup = strdup(url); + p = dupstr = strdup(url); /* protocol */ if(strncasecmp(LDAP_URL, p, strlen(LDAP_URL)) != 0) @@ -521,7 +534,7 @@ aldap_parse_url(char *url, struct aldap_url *lu) lu->filter = strdup(p); done: - free(dup); + free(dupstr); return (1); fail: free(dup); diff --git a/usr.sbin/ypldap/aldap.h b/usr.sbin/ypldap/aldap.h index 5619d7dfec7..f2b96122f96 100644 --- a/usr.sbin/ypldap/aldap.h +++ b/usr.sbin/ypldap/aldap.h @@ -1,5 +1,5 @@ -/* $Id: aldap.h,v 1.4 2008/10/14 21:41:03 aschrijver Exp $ */ -/* $OpenBSD: aldap.h,v 1.4 2008/10/14 21:41:03 aschrijver Exp $ */ +/* $Id: aldap.h,v 1.5 2009/01/26 21:56:15 pyr Exp $ */ +/* $OpenBSD: aldap.h,v 1.5 2009/01/26 21:56:15 pyr Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> @@ -176,6 +176,7 @@ enum subfilter { }; struct aldap *aldap_init(int fd); +int aldap_close(struct aldap *); struct aldap_message *aldap_parse(struct aldap *); void aldap_freemsg(struct aldap_message *); diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c index 98e74becc1c..3ed54c82c2b 100644 --- a/usr.sbin/ypldap/ldapclient.c +++ b/usr.sbin/ypldap/ldapclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapclient.c,v 1.9 2008/10/28 13:47:22 aschrijver Exp $ */ +/* $OpenBSD: ldapclient.c,v 1.10 2009/01/26 21:56:15 pyr Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> @@ -54,18 +54,6 @@ int client_addr_init(struct idm *); int client_addr_free(struct idm *); struct aldap *aldap_open(struct ypldap_addr *); -int aldap_close(struct aldap *); - -int -aldap_close(struct aldap *al) -{ - if(close(al->ber.fd) == -1) - return (-1); - - free(al); - - return (0); -} struct aldap * aldap_open(struct ypldap_addr *addr) |