New interface to YP server. Only bind once, and never unbind.
authormdw <mdw>
Thu, 23 Apr 1998 13:29:33 +0000 (13:29 +0000)
committermdw <mdw>
Thu, 23 Apr 1998 13:29:33 +0000 (13:29 +0000)
Introduced because Linux libc-5.4.33's YP interface dumps core in
yp_unbind for no particularly good reason.

src/ypstuff.c [new file with mode: 0644]
src/ypstuff.h [new file with mode: 0644]

diff --git a/src/ypstuff.c b/src/ypstuff.c
new file mode 100644 (file)
index 0000000..0c07833
--- /dev/null
@@ -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 <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* --- 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 (file)
index 0000000..8a246da
--- /dev/null
@@ -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 <rpc/rpc.h>
+#  include <rpcsvc/ypclnt.h>
+#  include <rpcsvc/yp_prot.h>
+#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