From 4b8ceaeb50e1e194d39d20a11d50fdddbe8cf1ed Mon Sep 17 00:00:00 2001 From: mdw Date: Thu, 23 Apr 1998 13:29:33 +0000 Subject: [PATCH] New interface to YP server. Only bind once, and never unbind. Introduced because Linux libc-5.4.33's YP interface dumps core in yp_unbind for no particularly good reason. --- src/ypstuff.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ypstuff.h | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 src/ypstuff.c create mode 100644 src/ypstuff.h diff --git a/src/ypstuff.c b/src/ypstuff.c new file mode 100644 index 0000000..0c07833 --- /dev/null +++ b/src/ypstuff.c @@ -0,0 +1,87 @@ +/* -*-c-*- + * + * $Id: ypstuff.c,v 1.1 1998/04/23 13:29:33 mdw Exp $ + * + * YP support functions + * + * (c) 1998 EBI + */ + +/*----- Licensing notice --------------------------------------------------* + * + * This file is part of `become' + * + * `Become' is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * `Become' is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with `become'; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/*----- Revision history --------------------------------------------------* + * + * $Log: ypstuff.c,v $ + * Revision 1.1 1998/04/23 13:29:33 mdw + * New interface to YP server. Only bind once, and never unbind. + * Introduced because Linux libc-5.4.33's YP interface dumps core in + * yp_unbind for no particularly good reason. + * + */ + +/*----- Header files ------------------------------------------------------*/ + +/* --- ANSI headers --- */ + +#include +#include +#include +#include + +/* --- Local headers --- */ + +#include "config.h" +#include "ypstuff.h" + +/*----- Global variables --------------------------------------------------*/ + +char *yp_domain; +static int ypstuff__tried; + +/*----- Main code ---------------------------------------------------------*/ + +#ifdef HAVE_YP + +/* --- @ypstuff_bind@ --- * + * + * Arguments: --- + * + * Returns: --- + * + * Use: Attempts to bind to a YP server, just once. If it fails, + * @yp_domain@ will be null; otherwise it's a pointer to the + * default YP domain name. + */ + +void ypstuff_bind(void) +{ + char *dom; + + if (ypstuff__tried) + return; + ypstuff__tried = 1; + if (yp_get_default_domain(&dom) || yp_bind(dom)) + return; + yp_domain = dom; +} + +#endif + +/*----- That's all, folks -------------------------------------------------*/ diff --git a/src/ypstuff.h b/src/ypstuff.h new file mode 100644 index 0000000..8a246da --- /dev/null +++ b/src/ypstuff.h @@ -0,0 +1,87 @@ +/* -*-c-*- + * + * $Id: ypstuff.h,v 1.1 1998/04/23 13:29:33 mdw Exp $ + * + * YP support functions + * + * (c) 1998 EBI + */ + +/*----- Licensing notice --------------------------------------------------* + * + * This file is part of `become' + * + * `Become' is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * `Become' is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with `become'; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/*----- Revision history --------------------------------------------------* + * + * $Log: ypstuff.h,v $ + * Revision 1.1 1998/04/23 13:29:33 mdw + * New interface to YP server. Only bind once, and never unbind. + * Introduced because Linux libc-5.4.33's YP interface dumps core in + * yp_unbind for no particularly good reason. + * + */ + +#ifndef YPSTUFF_H +#define YPSTUFF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/*----- Required headers --------------------------------------------------*/ + +#ifndef CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_YP +# include +# include +# include +#endif + +/*----- Global variables --------------------------------------------------*/ + +#ifdef HAVE_YP +extern char *yp_domain; +#endif + +/*----- Functions provided ------------------------------------------------*/ + +/* --- @ypstuff_bind@ --- * + * + * Arguments: --- + * + * Returns: --- + * + * Use: Attempts to bind to a YP server, just once. If it fails, + * @yp_domain@ will be null; otherwise it's a pointer to the + * default YP domain name. + */ + +#ifdef HAVE_YP +extern void ypstuff_bind(void); +#endif + +/*----- That's all, folks -------------------------------------------------*/ + +#ifdef __cplusplus + } +#endif + +#endif -- 2.11.0