Index: rvices/Makefile
===================================================================
--- services/Makefile	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,18 +1,0 @@
-#
-#  $Id$
-#
-
-include ../config.inc
-
-include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
-include $(RTEMS_CUSTOM)
-include $(RTEMS_SHARE)/make/directory.cfg
-
-# servers
-SUBDIRS  = mghttpd
-SUBDIRS += telnetd
-SUBDIRS += ftpd
-# client services
-SUBDIRS += ftpfs
-SUBDIRS += librpc
-# SUBDIRS += nfsclient
Index: rvices/ftpd/Makefile
===================================================================
--- services/ftpd/Makefile	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,38 +1,0 @@
-include ../../config.inc
-
-include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
-include $(RTEMS_CUSTOM)
-include $(PROJECT_ROOT)/make/leaf.cfg
-
-CFLAGS += -I $(INSTALL_BASE)/include
-
-CFLAGS += -w 
-CFLAGS += -I include 
-CFLAGS += -std=gnu99
-CFLAGS += -MT $@ -MD -MP -MF $(basename $@).d
-
-C_FILES =
-C_FILES += ftpd.c
-
-C_O_FILES = $(C_FILES:%.c=%.o)
-C_D_FILES = $(C_FILES:%.c=%.d)
-
-LIB = libftpd.a
-
-all: $(LIB)
-
-$(LIB): $(C_O_FILES)
-	$(AR) rcu $@ $^
-
-install: $(LIB)
-	install -d $(INSTALL_BASE)/include/rtems
-	install -c -m 644 ftpd.h $(INSTALL_BASE)/
-	install -c -m 644 $(LIB) $(INSTALL_BASE)
-
-clean:
-	rm -f $(LIB) $(C_O_FILES) $(C_D_FILES) $(GEN_FILES)
-
--include $(C_D_FILES)
-
-doc: 
-
Index: rvices/ftpd/ftpd.c
===================================================================
--- services/ftpd/ftpd.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,2113 +1,0 @@
-/* FIXME: 1. Parse command is a hack.  We can do better.
- *        2. OSV: hooks support seems to be bad, as it requires storing of
- *           entire input file in memory.  Seem to be better to change it to
- *           something more reasonable, like having
- *           'hook_write(void const *buf, int count)' routine that will be
- *           called multiple times while file is being received.
- *        3. OSV: Remove hack with "/dev/null"?
- *
- *  FTP Server Daemon
- *
- *  Submitted by: Jake Janovetz <janovetz@tempest.ece.uiuc.edu>
- *
- *  Changed by:   Sergei Organov <osv@javad.ru> (OSV)
- *                Arnout Vandecappelle <arnout@mind.be> (AV)
- *                Sebastien Bourdeauducq <sebastien@milkymist.org> (MM)
- *                
- *
- *  Changes:
- *
- *    2010-12-02        Sebastien Bourdeauducq <sebastien@milkymist.org>
- *
- *      * Support spaces in filenames
- * 
- *    2010-04-29        Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
- * 
- *      * Added USER/PASS authentication.
- * 
- *    2001-01-31        Sergei Organov <osv@javad.ru>
- *
- *      * Hacks with current dir and root dir removed in favor of new libio
- *        support for task-local current and root directories.
- *
- *    2001-01-30        Sergei Organov <osv@javad.ru>
- *
- *      * Bug in `close_data_socket()' introduced by previous change fixed.
- *      * `command_pasv()' changed to set timeout on socket we are listening on
- *        and code fixed to don't close socket twice on error.
- *      * `serr()' changed to clear `errno'.
- *      * `data_socket()' changed to clear `errno' before `bind()'.
- *      * `session()' changed to clear `errno' before processing session.
- *
- *    2001-01-29        Sergei Organov <osv@javad.ru>
- *
- *      * `close_data_socket()' fixed to close both active and passive sockets
- *      * Initialize info->data_socket to -1 in `daemon()'
- *      * Initialize `fname' to empty string  in `exec_command()'
- *
- *    2001-01-22        Sergei Organov <osv@javad.ru>
- *
- *      * Timeouts on sockets implemented. 'idle' field added to
- *        configuration. No timeout by default to keep backward compatibility.
- *        Note: SITE IDLE command not implemented yet.
- *      * Basic global access control implemented. 'access' field added to
- *        configuration. No access limitations by default to keep backward
- *        compatibility.
- *
- *    2001-01-17        Sergei Organov <osv@javad.ru>
- *
- *      * Anchor data socket for active mode (using self IP and port 20.)
- *      * Fixed default data port support (still not tested).
- *      * Don't allow IP address different from originating host in
- *        PORT command to improve security.
- *      * Fixed bug in MDTM command.
- *      * Check for correctness of parsing of argument in command_port().
- *      * Fixed squeeze_path() to don't allow names like 'NAME/smth' where
- *        'NAME' is not a directory.
- *      * Command parsing a little bit improved: command names are now
- *        converted to upper-case to be more compatible with RFC (command
- *        names are not case-sensitive.)
- *      * Reformat comments so that they have RTEMS look-and-feel.
- *
- *    2001-01-16        Sergei Organov <osv@javad.ru>
- *
- *      * Fixed DELE, SITE CHMOD, RMD, MKD broken by previous changes
- *      * True ASCII mode implemented (doesn't work for hooks and /dev/null)
- *      * Passive mode implemented, PASV command added.
- *      * Default port for data connection could be used (untested, can't find
- *        ftp client that doesn't send PORT command)
- *      * SYST reply changed to UNIX, as former RTEMS isn't registered name.
- *      * Reply codes reviewed and fixed.
- *
- *    2001-01-08        Sergei Organov <osv@javad.ru>
- *
- *      * use pool of pre-created threads to handle sessions
- *      * LIST output now similar to what "/bin/ls -al" would output, thus
- *        FTP clients could parse it.
- *      * LIST NAME now works (both for files and directories)
- *      * keep track of CWD for every session separately
- *      * ability to specify root directory name in configuration table
- *      * options sent in commands are ignored, thus LIST -al FILE works
- *      * added support for NLST, CDUP and MDTM commands
- *      * buffers are allocated on stack instead of heap where possible
- *      * drop using of task notepad to pass parameters - use function
- *        arguments instead
- *      * various bug-fixes, e.g., use of PF_INET in socket() instead of
- *        AF_INET, use snprintf() instead of sprintf() everywhere for safety,
- *        etc.
- */
-
-/*************************************************************************
- *                                 ftpd.c
- *************************************************************************
- * Description:
- *
- *    This file contains the daemon which services requests that appear
- *    on the FTP port.  This server is compatible with FTP, but it
- *    also provides 'hooks' to make it usable in situations where files
- *    are not used/necessary.  Once the server is started, it runs
- *    forever.
- *
- *
- *    Organization:
- *
- *       The FTP daemon is started upon boot along with a (configurable)
- *       number of tasks to handle sessions.  It runs all the time and
- *       waits for connections on the known FTP port (21).  When
- *       a connection is made, it wakes-up a 'session' task.  That
- *       session then interacts with the remote host.  When the session
- *       is complete, the session task goes to sleep.  The daemon still
- *       runs, however.
- *
- *
- * Supported commands are:
- *
- * RETR xxx     - Sends a file from the client.
- * STOR xxx     - Receives a file from the client.  xxx = filename.
- * LIST xxx     - Sends a file list to the client.
- * NLST xxx     - Sends a file list to the client.
- * USER         - Does nothing.
- * PASS         - Does nothing.
- * SYST         - Replies with the system type (`RTEMS').
- * DELE xxx     - Delete file xxx.
- * MKD xxx      - Create directory xxx.
- * RMD xxx      - Remove directory xxx.
- * PWD          - Print working directory.
- * CWD xxx      - Change working directory.
- * CDUP         - Change to upper directory.
- * SITE CHMOD xxx yyy - Change permissions on file yyy to xxx.
- * PORT a,b,c,d,x,y   - Setup for a data port to IP address a.b.c.d
- *                      and port (x*256 + y).
- * MDTM xxx     - Send file modification date/time to the client.
- *                xxx = filename.
- * PASV         - Use passive mode data connection.
- *
- *
- * The public routines contained in this file are:
- *
- *    rtems_initialize_ftpd - Initializes and starts the server daemon,
- *                            then returns to its caller.
- *
- *------------------------------------------------------------------------
- * Jake Janovetz
- * University of Illinois
- * 1406 West Green Street
- * Urbana IL  61801
- *************************************************************************
- * Change History:
- *  12/01/97   - Creation (JWJ)
- *  2001-01-08 - Changes by OSV
- *  2010-04-29 - Authentication added by AV
- *************************************************************************/
-
-/*************************************************************************
- * Meanings of first and second digits of reply codes:
- *
- * Reply:  Description:
- *-------- --------------
- *  1yz    Positive preliminary reply.  The action is being started but
- *         expect another reply before sending another command.
- *  2yz    Positive completion reply.  A new command can be sent.
- *  3yz    Positive intermediate reply.  The command has been accepted
- *         but another command must be sent.
- *  4yz    Transient negative completion reply.  The requested action did
- *         not take place, but the error condition is temporary so the
- *         command can be reissued later.
- *  5yz    Permanent negative completion reply.  The command was not
- *         accepted and should not be retried.
- *-------------------------------------------------------------------------
- *  x0z    Syntax errors.
- *  x1z    Information.
- *  x2z    Connections.  Replies referring to the control or data
- *         connections.
- *  x3z    Authentication and accounting.  Replies for the login or
- *         accounting commands.
- *  x4z    Unspecified.
- *  x5z    Filesystem status.
- *************************************************************************/
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#include <ctype.h>
-
-#include <rtems.h>
-#include <rtems/rtems_bsdnet.h>
-#include <rtems/error.h>
-#include <rtems/libio.h>
-#include <rtems/userenv.h>
-#include <syslog.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/ftp.h>
-#include <netinet/in.h>
-
-#include "ftpd.h"
-
-
-#ifdef __GNUC__
-/* change to #if 1 to disable syslog entirely */
-#if 0
-#undef  syslog
-#define syslog(a, b, ...) while(0){}
-#endif
-#endif
-
-#define FTPD_SERVER_MESSAGE  "RTEMS FTP server (Version 1.1-JWJ) ready."
-
-#define FTPD_SYSTYPE "UNIX Type: L8"
-
-/* Seem to be unused */
-#if 0
-#define FTPD_WELCOME_MESSAGE \
-   "Welcome to the RTEMS FTP server.\n" \
-   "\n" \
-   "Login accepted.\n"
-#endif
-
-/* Event to be used by session tasks for waiting */
-enum
-{
-  FTPD_RTEMS_EVENT = RTEMS_EVENT_1
-};
-
-/* Configuration table */
-extern struct rtems_ftpd_configuration rtems_ftpd_configuration;
-
-/* this is not prototyped in strict ansi mode */
-FILE *fdopen (int fildes, const char *mode);
-
-/*SessionInfo structure.
- *
- * The following structure is allocated for each session.
- */
-typedef struct
-{
-  struct sockaddr_in  ctrl_addr;   /* Control connection self address */
-  struct sockaddr_in  data_addr;   /* Data address set by PORT command */
-  struct sockaddr_in  def_addr;    /* Default address for data */
-  int                 use_default; /* 1 - use default address for data */
-  FILE                *ctrl_fp;    /* File pointer for control connection */
-  int                 ctrl_socket; /* Socket for ctrl connection */
-  int                 pasv_socket; /* Socket for PASV connection */
-  int                 data_socket; /* Socket for data connection */
-  int                 idle;        /* Timeout in seconds */
-  int                 xfer_mode;   /* Transfer mode (ASCII/binary) */
-  rtems_id            tid;         /* Task id */
-  char                *user;       /* user name (0 if not supplied) */
-  char                *pass;       /* password (0 if not supplied) */
-  bool                auth;        /* true if user/pass was valid, false if not or not supplied */
-} FTPD_SessionInfo_t;
-
-
-/*
- * TaskPool structure.
- */
-typedef struct
-{
-  FTPD_SessionInfo_t    *info;
-  FTPD_SessionInfo_t    **queue;
-  int                   count;
-  int                   head;
-  int                   tail;
-  rtems_id              mutex;
-  rtems_id              sem;
-} FTPD_TaskPool_t;
-
-/*
- * Task pool instance.
- */
-static FTPD_TaskPool_t task_pool;
-
-/*
- * Root directory
- */
-
-static char const* ftpd_root = "/";
-
-/*
- * Default idle timeout for sockets in seconds.
- */
-static int ftpd_timeout = 0;
-
-/*
- * Global access flags.
- */
-static int ftpd_access = 0;
-
-/*
- * serr
- *
- * Return error string corresponding to current 'errno'.
- *
- */
-static char const*
-serr(void)
-{
-  int err = errno;
-  errno = 0;
-  return strerror(err);
-}
-
-/*
- * Utility routines for access control.
- *
- */
-
-static int
-can_read(void)
-{
-  return (ftpd_access & FTPD_NO_READ) == 0;
-}
-
-static int
-can_write(void)
-{
-  return (ftpd_access & FTPD_NO_WRITE) == 0;
-}
-
-/*
- * Task pool management routines
- *
- */
-
-
-/*
- * task_pool_done
- *
- * Cleanup task pool.
- *
- * Input parameters:
- *   count - number of entries in task pool to cleanup
- *
- * Output parameters:
- *   NONE
- *
- */
-static void
-task_pool_done(int count)
-{
-  int i;
-  for(i = 0; i < count; ++i)
-    rtems_task_delete(task_pool.info[i].tid);
-  if(task_pool.info)
-    free(task_pool.info);
-  if(task_pool.queue)
-    free(task_pool.queue);
-  if(task_pool.mutex != (rtems_id)-1)
-    rtems_semaphore_delete(task_pool.mutex);
-  if(task_pool.sem != (rtems_id)-1)
-    rtems_semaphore_delete(task_pool.sem);
-  task_pool.info = 0;
-  task_pool.queue = 0;
-  task_pool.count = 0;
-  task_pool.sem = -1;
-  task_pool.mutex = -1;
-}
-
-/*
- * task_pool_init
- *
- * Initialize task pool.
- *
- * Input parameters:
- *   count    - number of entries in task pool to create
- *   priority - priority tasks are started with
- *
- * Output parameters:
- *   returns 1 on success, 0 on failure.
- *
- */
-static void session(rtems_task_argument arg); /* Forward declare */
-
-static int
-task_pool_init(int count, rtems_task_priority priority)
-{
-  int i;
-  rtems_status_code sc;
-  char id = 'a';
-
-  task_pool.count = 0;
-  task_pool.head = task_pool.tail = 0;
-  task_pool.mutex = (rtems_id)-1;
-  task_pool.sem   = (rtems_id)-1;
-
-  sc = rtems_semaphore_create(
-    rtems_build_name('F', 'T', 'P', 'M'),
-    1,
-    RTEMS_DEFAULT_ATTRIBUTES
-    | RTEMS_BINARY_SEMAPHORE
-    | RTEMS_INHERIT_PRIORITY
-    | RTEMS_PRIORITY,
-    RTEMS_NO_PRIORITY,
-    &task_pool.mutex);
-
-  if(sc == RTEMS_SUCCESSFUL)
-    sc = rtems_semaphore_create(
-      rtems_build_name('F', 'T', 'P', 'S'),
-      count,
-      RTEMS_DEFAULT_ATTRIBUTES,
-      RTEMS_NO_PRIORITY,
-      &task_pool.sem);
-
-  if(sc != RTEMS_SUCCESSFUL) {
-    task_pool_done(0);
-    syslog(LOG_ERR, "ftpd: Can not create semaphores");
-    return 0;
-  }
-
-  task_pool.info = (FTPD_SessionInfo_t*)
-    malloc(sizeof(FTPD_SessionInfo_t) * count);
-  task_pool.queue = (FTPD_SessionInfo_t**)
-    malloc(sizeof(FTPD_SessionInfo_t*) * count);
-  if (NULL == task_pool.info || NULL == task_pool.queue)
-  {
-    task_pool_done(0);
-    syslog(LOG_ERR, "ftpd: Not enough memory");
-    return 0;
-  }
-
-  for(i = 0; i < count; ++i)
-  {
-    FTPD_SessionInfo_t *info = &task_pool.info[i];
-    sc = rtems_task_create(rtems_build_name('F', 'T', 'P', id),
-      priority, FTPD_STACKSIZE,
-      RTEMS_PREEMPT | RTEMS_NO_TIMESLICE |
-      RTEMS_NO_ASR | RTEMS_INTERRUPT_LEVEL(0),
-      RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
-      &info->tid);
-    if (sc == RTEMS_SUCCESSFUL)
-    {
-      sc = rtems_task_start(
-        info->tid, session, (rtems_task_argument)info);
-      if (sc != RTEMS_SUCCESSFUL)
-        task_pool_done(i);
-    }
-    else
-      task_pool_done(i + 1);
-    if (sc != RTEMS_SUCCESSFUL)
-    {
-      syslog(LOG_ERR, "ftpd: Could not create/start FTPD session: %s",
-        rtems_status_text(sc));
-      return 0;
-    }
-    task_pool.queue[i] = task_pool.info + i;
-    if (++id > 'z')
-      id = 'a';
-  }
-  task_pool.count = count;
-  return 1;
-}
-
-/*
- * task_pool_obtain
- *
- * Obtain free task from task pool.
- *
- * Input parameters:
- *   NONE
- *
- * Output parameters:
- *   returns pointer to the corresponding SessionInfo structure on success,
- *           NULL if there are no free tasks in the pool.
- *
- */
-static FTPD_SessionInfo_t*
-task_pool_obtain(void)
-{
-  FTPD_SessionInfo_t* info = 0;
-  rtems_status_code sc;
-  sc = rtems_semaphore_obtain(task_pool.sem, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT);
-  if (sc == RTEMS_SUCCESSFUL)
-  {
-    rtems_semaphore_obtain(task_pool.mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
-    info = task_pool.queue[task_pool.head];
-    if(++task_pool.head >= task_pool.count)
-      task_pool.head = 0;
-    rtems_semaphore_release(task_pool.mutex);
-  }
-  return info;
-}
-
-/*
- * task_pool_release
- *
- * Return task obtained by 'obtain()' back to the task pool.
- *
- * Input parameters:
- *   info  - pointer to corresponding SessionInfo structure.
- *
- * Output parameters:
- *   NONE
- *
- */
-static void
-task_pool_release(FTPD_SessionInfo_t* info)
-{
-  rtems_semaphore_obtain(task_pool.mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
-  task_pool.queue[task_pool.tail] = info;
-  if(++task_pool.tail >= task_pool.count)
-    task_pool.tail = 0;
-  rtems_semaphore_release(task_pool.mutex);
-  rtems_semaphore_release(task_pool.sem);
-}
-
-/*
- * End of task pool routines
- */
-
-/*
- * Function: send_reply
- *
- *
- *    This procedure sends a reply to the client via the control
- *    connection.
- *
- *
- * Input parameters:
- *   code  - 3-digit reply code.
- *   text  - Reply text.
- *
- * Output parameters:
- *   NONE
- */
-static void
-send_reply(FTPD_SessionInfo_t  *info, int code, char *text)
-{
-  text = text != NULL ? text : "";
-  fprintf(info->ctrl_fp, "%d %.70s\r\n", code, text);
-  fflush(info->ctrl_fp);
-}
-
-
-/*
- * close_socket
- *
- * Close socket.
- *
- * Input parameters:
- *   s - socket descriptor.
- *   seconds - number of seconds the timeout should be,
- *             if >= 0 - infinite timeout (no timeout).
- *
- * Output parameters:
- *   returns 1 on success, 0 on failure.
- */
-static int
-set_socket_timeout(int s, int seconds)
-{
-  int res = 0;
-  struct timeval tv;
-  int len = sizeof(tv);
-
-  if(seconds < 0)
-    seconds = 0;
-  tv.tv_usec = 0;
-  tv.tv_sec  = seconds;
-  if(0 != setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, len))
-    syslog(LOG_ERR, "ftpd: Can't set send timeout on socket: %s.", serr());
-  else if(0 != setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, len))
-    syslog(LOG_ERR, "ftpd: Can't set receive timeout on socket: %s.", serr());
-  else
-    res = 1;
-  return res;
-}
-
-/*
- * close_socket
- *
- * Close socket.
- *
- * Input parameters:
- *   s - socket descriptor to be closed.
- *
- * Output parameters:
- *   returns 1 on success, 0 on failure
- */
-static int
-close_socket(int s)
-{
-  if (0 <= s)
-  {
-    if (0 != close(s))
-    {
-      shutdown(s, 2);
-      if (0 != close(s))
-        return 0;
-    }
-  }
-  return 1;
-}
-
-/*
- * data_socket
- *
- * Create data socket for session.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *
- * Output parameters:
- *   returns socket descriptor, or -1 if failure
- *
- */
-static int
-data_socket(FTPD_SessionInfo_t *info)
-{
-  int s = info->pasv_socket;
-  if(0 > s)
-  {
-    int on = 1;
-    s = socket(PF_INET, SOCK_STREAM, 0);
-    if(0 > s)
-      send_reply(info, 425, "Can't create data socket.");
-    else if(0 > setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
-    {
-      close_socket(s);
-      s = -1;
-    }
-    else
-    {
-      struct sockaddr_in data_source;
-      int tries;
-
-      /* anchor socket to avoid multi-homing problems */
-      data_source = info->ctrl_addr;
-      data_source.sin_port = htons(20); /* ftp-data port */
-      for(tries = 1; tries < 10; ++tries)
-      {
-        errno = 0;
-        if(bind(s, (struct sockaddr *)&data_source, sizeof(data_source)) >= 0)
-          break;
-        if (errno != EADDRINUSE)
-          tries = 10;
-        else
-          rtems_task_wake_after(tries * 10);
-      }
-      if(tries >= 10)
-      {
-        send_reply(info, 425, "Can't bind data socket.");
-        close_socket(s);
-        s = -1;
-      }
-      else
-      {
-        struct sockaddr_in *data_dest =
-          (info->use_default) ? &info->def_addr : &info->data_addr;
-        if(0 > connect(s, (struct sockaddr *)data_dest, sizeof(*data_dest)))
-        {
-          send_reply(info, 425, "Can't connect data socket.");
-          close_socket(s);
-          s = -1;
-        }
-      }
-    }
-  }
-  info->data_socket = s;
-  info->use_default = 1;
-  if(s >= 0)
-    set_socket_timeout(s, info->idle);
-  return s;
-}
-
-/*
- * close_data_socket
- *
- * Close data socket for session.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *
- * Output parameters:
- *   NONE
- *
- */
-static void
-close_data_socket(FTPD_SessionInfo_t *info)
-{
-  /* As at most one data socket could be open simultaneously and in some cases
-     data_socket == pasv_socket, we select socket to close, then close it. */
-  int s = info->data_socket;
-  if(0 > s)
-    s = info->pasv_socket;
-  if(!close_socket(s))
-    syslog(LOG_ERR, "ftpd: Error closing data socket.");
-  info->data_socket = -1;
-  info->pasv_socket = -1;
-  info->use_default = 1;
-}
-
-/*
- * close_stream
- *
- * Close control stream of session.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *
- * Output parameters:
- *   NONE
- *
- */
-static void
-close_stream(FTPD_SessionInfo_t* info)
-{
-  if (NULL != info->ctrl_fp)
-  {
-    if (0 != fclose(info->ctrl_fp))
-    {
-      syslog(LOG_ERR, "ftpd: Could not close control stream: %s", serr());
-    }
-    else
-      info->ctrl_socket = -1;
-  }
-
-  if (!close_socket(info->ctrl_socket))
-    syslog(LOG_ERR, "ftpd: Could not close control socket: %s", serr());
-
-  info->ctrl_fp = NULL;
-  info->ctrl_socket = -1;
-}
-
-
-/*
- * send_mode_reply
- *
- * Sends BINARY/ASCII reply string depending on current transfer mode.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *
- * Output parameters:
- *   NONE
- *
- */
-static void
-send_mode_reply(FTPD_SessionInfo_t *info)
-{
-  if(info->xfer_mode == TYPE_I)
-    send_reply(info, 150, "Opening BINARY mode data connection.");
-  else
-    send_reply(info, 150, "Opening ASCII mode data connection.");
-}
-
-/*
- * command_retrieve
- *
- * Perform the "RETR" command (send file to client).
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *   char *filename  - source filename.
- *
- * Output parameters:
- *   NONE
- *
- */
-static void
-command_retrieve(FTPD_SessionInfo_t  *info, char const *filename)
-{
-  int                 s = -1;
-  int                 fd = -1;
-  char                buf[FTPD_DATASIZE];
-  struct stat         stat_buf;
-  int                 res = 0;
-
-  if(!can_read() || !info->auth)
-  {
-    send_reply(info, 550, "Access denied.");
-    return;
-  }
-
-  if (0 > (fd = open(filename, O_RDONLY)))
-  {
-    send_reply(info, 550, "Error opening file.");
-    return;
-  }
-
-  if (fstat(fd, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode))
-  {
-    if (-1 != fd)
-      close(fd);
-    send_reply(info, 550, "Is a directory.");
-    return;
-  }
-
-  send_mode_reply(info);
-
-  s = data_socket(info);
-
-  if (0 <= s)
-  {
-    int n = -1;
-
-    if(info->xfer_mode == TYPE_I)
-    {
-      while ((n = read(fd, buf, FTPD_DATASIZE)) > 0)
-      {
-        if(send(s, buf, n, 0) != n)
-          break;
-      }
-    }
-    else if (info->xfer_mode == TYPE_A)
-    {
-      int rest = 0;
-      while (rest == 0 && (n = read(fd, buf, FTPD_DATASIZE)) > 0)
-      {
-        char const* e = buf;
-        char const* b;
-        int i;
-        rest = n;
-        do
-        {
-          char lf = '\0';
-
-          b = e;
-          for(i = 0; i < rest; ++i, ++e)
-          {
-            if(*e == '\n')
-            {
-              lf = '\n';
-              break;
-            }
-          }
-          if(send(s, b, i, 0) != i)
-            break;
-          if(lf == '\n')
-          {
-            if(send(s, "\r\n", 2, 0) != 2)
-              break;
-            ++e;
-            ++i;
-          }
-        }
-        while((rest -= i) > 0);
-      }
-    }
-
-    if (0 == n)
-    {
-      if (0 == close(fd))
-      {
-        fd = -1;
-        res = 1;
-      }
-    }
-  }
-
-  if (-1 != fd)
-    close(fd);
-
-  if (0 == res)
-    send_reply(info, 451, "File read error.");
-  else
-    send_reply(info, 226, "Transfer complete.");
-
-  close_data_socket(info);
-
-  return;
-}
-
-
-/*
- * discard
- *
- * Analog of `write' routine that just discards passed data
- *
- * Input parameters:
- *   fd    - file descriptor (ignored)
- *   buf   - data to write (ignored)
- *   count - number of bytes in `buf'
- *
- * Output parameters:
- *   returns `count'
- *
- */
-static ssize_t
-discard(int fd, void const* buf, size_t count)
-{
-  (void)fd;
-  (void)buf;
-  return count;
-}
-
-/*
- * command_store
- *
- * Performs the "STOR" command (receive data from client).
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *   char *filename   - Destination filename.
- *
- * Output parameters:
- *   NONE
- */
-static void
-command_store(FTPD_SessionInfo_t *info, char const *filename)
-{
-  int                    s;
-  int                    n;
-  unsigned long          size = 0;
-  struct rtems_ftpd_hook *usehook = NULL;
-  char                   buf[FTPD_DATASIZE];
-  int                    res = 1;
-  int                    bare_lfs = 0;
-  int                    null = 0;
-  typedef ssize_t (*WriteProc)(int, void const*, size_t);
-  WriteProc              wrt = &write;
-
-  if(!can_write() || !info->auth)
-  {
-    send_reply(info, 550, "Access denied.");
-    return;
-  }
-
-  send_mode_reply(info);
-
-  s = data_socket(info);
-  if(0 > s)
-    return;
-
-  null = !strcmp("/dev/null", filename);
-  if (null)
-  {
-    /* File "/dev/null" just throws data away.
-     *  FIXME: this is hack.  Using `/dev/null' filesystem entry would be
-     *  better.
-     */
-    wrt = &discard;
-  }
-
-  if (!null && rtems_ftpd_configuration.hooks != NULL)
-  {
-
-    /* Search our list of hooks to see if we need to do something special. */
-    struct rtems_ftpd_hook *hook;
-    int i;
-
-    i = 0;
-    hook = &rtems_ftpd_configuration.hooks[i++];
-    while (hook->filename != NULL)
-    {
-      if (!strcmp(hook->filename, filename))
-      {
-        usehook = hook;
-        break;
-      }
-      hook = &rtems_ftpd_configuration.hooks[i++];
-    }
-  }
-
-  if (usehook != NULL)
-  {
-    /*
-     * OSV: FIXME: Small buffer could be used and hook routine
-     * called multiple times instead.  Alternatively, the support could be
-     * removed entirely in favor of configuring RTEMS pseudo-device with
-     * given name.
-     */
-
-    char                *bigBufr;
-    size_t filesize = rtems_ftpd_configuration.max_hook_filesize + 1;
-
-    /*
-     * Allocate space for our "file".
-     */
-    bigBufr = (char *)malloc(filesize);
-    if (bigBufr == NULL)
-    {
-      send_reply(info, 451, "Local resource failure: malloc.");
-      close_data_socket(info);
-      return;
-    }
-
-    /*
-     * Retrieve the file into our buffer space.
-     */
-    size = 0;
-    while ((n = recv(s, bigBufr + size, filesize - size, 0)) > 0)
-    {
-      size += n;
-    }
-    if (size >= filesize)
-    {
-      send_reply(info, 451, "File too long: buffer size exceeded.");
-      free(bigBufr);
-      close_data_socket(info);
-      return;
-    }
-
-    /*
-     * Call our hook.
-     */
-    res = (usehook->hook_function)(bigBufr, size) == 0;
-    free(bigBufr);
-    if(!res)
-    {
-      send_reply(info, 451, "File processing failed.");
-      close_data_socket(info);
-      return;
-    }
-  }
-  else
-  {
-    /* Data transfer to regular file or /dev/null. */
-    int fd = 0;
-
-    if(!null)
-      fd = creat(filename,
-        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
-
-    if (0 > fd)
-    {
-      send_reply(info, 550, "Error creating file.");
-      close_data_socket(info);
-      return;
-    }
-
-    if(info->xfer_mode == TYPE_I)
-    {
-      while ((n = recv(s, buf, FTPD_DATASIZE, 0)) > 0)
-      {
-        if (wrt(fd, buf, n) != n)
-        {
-          res = 0;
-          break;
-        }
-      }
-    }
-    else if(info->xfer_mode == TYPE_A)
-    {
-      int rest = 0;
-      int pended_cr = 0;
-      while (res && rest == 0 && (n = recv(s, buf, FTPD_DATASIZE, 0)) > 0)
-      {
-        char const* e = buf;
-        char const* b;
-        int i;
-
-        rest = n;
-        if(pended_cr && *e != '\n')
-        {
-          char const lf = '\r';
-          pended_cr = 0;
-          if(wrt(fd, &lf, 1) != 1)
-          {
-            res = 0;
-            break;
-          }
-        }
-        do
-        {
-          int count;
-          int sub = 0;
-
-          b = e;
-          for(i = 0; i < rest; ++i, ++e)
-          {
-            int pcr = pended_cr;
-            pended_cr = 0;
-            if(*e == '\r')
-            {
-              pended_cr = 1;
-            }
-            else if(*e == '\n')
-            {
-              if(pcr)
-              {
-                sub = 2;
-                ++i;
-                ++e;
-                break;
-              }
-              ++bare_lfs;
-            }
-          }
-          if(res == 0)
-            break;
-          count = i - sub - pended_cr;
-          if(count > 0 && wrt(fd, b, count) != count)
-          {
-            res = 0;
-            break;
-          }
-          if(sub == 2 && wrt(fd, e - 1, 1) != 1)
-            res = 0;
-        }
-        while((rest -= i) > 0);
-      }
-    }
-
-    if (0 > close(fd) || res == 0)
-    {
-      send_reply(info, 452, "Error writing file.");
-      close_data_socket(info);
-      return;
-    }
-  }
-
-  if (bare_lfs > 0)
-  {
-    snprintf(buf, FTPD_BUFSIZE,
-      "Transfer complete. WARNING! %d bare linefeeds received in ASCII mode.",
-      bare_lfs);
-    send_reply(info, 226, buf);
-  }
-  else
-    send_reply(info, 226, "Transfer complete.");
-  close_data_socket(info);
-
-}
-
-
-/*
- * send_dirline
- *
- * Sends one line of LIST command reply corresponding to single file.
- *
- * Input parameters:
- *   s - socket descriptor to send data to
- *   wide - if 0, send only file name.  If not 0, send 'stat' info as well in
- *          "ls -l" format.
- *   curTime - current time
- *   path - path to be prepended to what is given by 'add'
- *   add  - path to be appended to what is given by 'path', the resulting path
- *          is then passed to 'stat()' routine
- *   name - file name to be reported in output
- *   buf  - buffer for temporary data
- *
- * Output parameters:
- *   returns 0 on failure, 1 on success
- *
- */
-static int
-send_dirline(int s, int wide, time_t curTime, char const* path,
-  char const* add, char const* fname, char* buf)
-{
-  if(wide)
-  {
-    struct stat stat_buf;
-
-    int plen = strlen(path);
-    int alen = strlen(add);
-    if(plen == 0)
-    {
-      buf[plen++] = '/';
-      buf[plen] = '\0';
-    }
-    else
-    {
-      strcpy(buf, path);
-      if(alen > 0 && buf[plen - 1] != '/')
-      {
-        buf[plen++] = '/';
-        if(plen >= FTPD_BUFSIZE)
-          return 0;
-        buf[plen] = '\0';
-      }
-    }
-    if(plen + alen >= FTPD_BUFSIZE)
-      return 0;
-    strcpy(buf + plen, add);
-
-    if (stat(buf, &stat_buf) == 0)
-    {
-      int len;
-      struct tm bt;
-      time_t tf = stat_buf.st_mtime;
-      enum { SIZE = 80 };
-      time_t SIX_MONTHS = (365L*24L*60L*60L)/2L;
-      char timeBuf[SIZE];
-      gmtime_r(&tf, &bt);
-      if(curTime > tf + SIX_MONTHS || tf > curTime + SIX_MONTHS)
-        strftime (timeBuf, SIZE, "%b %d  %Y", &bt);
-      else
-        strftime (timeBuf, SIZE, "%b %d %H:%M", &bt);
-
-      len = snprintf(buf, FTPD_BUFSIZE,
-        "%c%c%c%c%c%c%c%c%c%c  1 %5d %5d %11u %s %s\r\n",
-        (S_ISLNK(stat_buf.st_mode)?('l'):
-          (S_ISDIR(stat_buf.st_mode)?('d'):('-'))),
-        (stat_buf.st_mode & S_IRUSR)?('r'):('-'),
-        (stat_buf.st_mode & S_IWUSR)?('w'):('-'),
-        (stat_buf.st_mode & S_IXUSR)?('x'):('-'),
-        (stat_buf.st_mode & S_IRGRP)?('r'):('-'),
-        (stat_buf.st_mode & S_IWGRP)?('w'):('-'),
-        (stat_buf.st_mode & S_IXGRP)?('x'):('-'),
-        (stat_buf.st_mode & S_IROTH)?('r'):('-'),
-        (stat_buf.st_mode & S_IWOTH)?('w'):('-'),
-        (stat_buf.st_mode & S_IXOTH)?('x'):('-'),
-        (int)stat_buf.st_uid,
-        (int)stat_buf.st_gid,
-        (int)stat_buf.st_size,
-        timeBuf,
-        fname
-      );
-
-      if(send(s, buf, len, 0) != len)
-        return 0;
-    }
-  }
-  else
-  {
-    int len = snprintf(buf, FTPD_BUFSIZE, "%s\r\n", fname);
-    if(send(s, buf, len, 0) != len)
-      return 0;
-  }
-  return 1;
-}
-
-/*
- * command_list
- *
- * Send file list to client.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *   char *fname  - File (or directory) to list.
- *
- * Output parameters:
- *   NONE
- */
-static void
-command_list(FTPD_SessionInfo_t *info, char const *fname, int wide)
-{
-  int                 s;
-  DIR                 *dirp = 0;
-  struct dirent       *dp = 0;
-  struct stat         stat_buf;
-  char                buf[FTPD_BUFSIZE];
-  time_t curTime;
-  int sc = 1;
-
-  if(!info->auth)
-  {
-    send_reply(info, 550, "Access denied.");
-    return;
-  }
-
-  send_reply(info, 150, "Opening ASCII mode data connection for LIST.");
-
-  s = data_socket(info);
-  if(0 > s)
-  {
-    syslog(LOG_ERR, "ftpd: Error connecting to data socket.");
-    return;
-  }
-
-  if(fname[0] == '\0')
-    fname = ".";
-
-  if (0 > stat(fname, &stat_buf))
-  {
-    snprintf(buf, FTPD_BUFSIZE,
-      "%s: No such file or directory.\r\n", fname);
-    send(s, buf, strlen(buf), 0);
-  }
-  else if (S_ISDIR(stat_buf.st_mode) && (NULL == (dirp = opendir(fname))))
-  {
-    snprintf(buf, FTPD_BUFSIZE,
-      "%s: Can not open directory.\r\n", fname);
-    send(s, buf, strlen(buf), 0);
-  }
-  else
-  {
-    time(&curTime);
-    if(!dirp && *fname)
-      sc = sc && send_dirline(s, wide, curTime, fname, "", fname, buf);
-    else {
-      /* FIXME: need "." and ".." only when '-a' option is given */
-      sc = sc && send_dirline(s, wide, curTime, fname, "", ".", buf);
-      sc = sc && send_dirline(s, wide, curTime, fname,
-        (strcmp(fname, ftpd_root) ? ".." : ""), "..", buf);
-      while (sc && (dp = readdir(dirp)) != NULL)
-        sc = sc &&
-          send_dirline(s, wide, curTime, fname, dp->d_name, dp->d_name, buf);
-    }
-  }
-
-  if(dirp)
-    closedir(dirp);
-  close_data_socket(info);
-
-  if(sc)
-    send_reply(info, 226, "Transfer complete.");
-  else
-    send_reply(info, 426, "Connection aborted.");
-}
-
-
-/*
- * command_cwd
- *
- * Change current working directory.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *   dir  - directory name passed in CWD command
- *
- * Output parameters:
- *   NONE
- *
- */
-static void
-command_cwd(FTPD_SessionInfo_t  *info, char *dir)
-{
-  if(!info->auth)
-  {
-    send_reply(info, 550, "Access denied.");
-    return;
-  }
-
-  if(chdir(dir) == 0)
-    send_reply(info, 250, "CWD command successful.");
-  else
-    send_reply(info, 550, "CWD command failed.");
-}
-
-
-/*
- * command_pwd
- *
- * Send current working directory to client.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *
- * Output parameters:
- *   NONE
- */
-static void
-command_pwd(FTPD_SessionInfo_t  *info)
-{
-  char buf[FTPD_BUFSIZE];
-  char const* cwd;
-  errno = 0;
-  buf[0] = '"';
-
-  if(!info->auth)
-  {
-    send_reply(info, 550, "Access denied.");
-    return;
-  }
-
-  cwd = getcwd(buf + 1, FTPD_BUFSIZE - 4);
-  if(cwd)
-  {
-    int len = strlen(cwd);
-    static char const txt[] = "\" is the current directory.";
-    int size = sizeof(txt);
-    if(len + size + 1 >= FTPD_BUFSIZE)
-      size = FTPD_BUFSIZE - len - 2;
-    memcpy(buf + len + 1, txt, size);
-    buf[len + size] = '\0';
-    send_reply(info, 250, buf);
-  }
-  else {
-    snprintf(buf, FTPD_BUFSIZE, "Error: %s.", serr());
-    send_reply(info, 452, buf);
-  }
-}
-
-/*
- * command_mdtm
- *
- * Handle FTP MDTM command (send file modification time to client)/
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *   fname - file name passed in MDTM command
- *
- * Output parameters:
- *   info->cwd is set to new CWD value.
- */
-static void
-command_mdtm(FTPD_SessionInfo_t  *info, char const* fname)
-{
-  struct stat stbuf;
-  char buf[FTPD_BUFSIZE];
-
-  if(!info->auth)
-  {
-    send_reply(info, 550, "Access denied.");
-    return;
-  }
-
-  if (0 > stat(fname, &stbuf))
-  {
-    snprintf(buf, FTPD_BUFSIZE, "%s: %s.", fname, serr());
-    send_reply(info, 550, buf);
-  }
-  else
-  {
-    struct tm *t = gmtime(&stbuf.st_mtime);
-    snprintf(buf, FTPD_BUFSIZE, "%04d%02d%02d%02d%02d%02d",
-      1900 + t->tm_year,
-      t->tm_mon+1, t->tm_mday,
-      t->tm_hour, t->tm_min, t->tm_sec);
-    send_reply(info, 213, buf);
-  }
-}
-
-/*
- * command_port
- *
- * This procedure fills address for data connection given the IP address and
- * port of the remote machine.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *   args - arguments to the "PORT" command.
- *
- * Output parameters:
- *   info->data_addr is set according to arguments of the PORT command.
- *   info->use_default is set to 0 on success, 1 on failure.
- */
-static void
-command_port(FTPD_SessionInfo_t *info, char const *args)
-{
-  enum { NUM_FIELDS = 6 };
-  unsigned int a[NUM_FIELDS];
-  int n;
-
-  close_data_socket(info);
-
-  n = sscanf(args, "%u,%u,%u,%u,%u,%u", a+0, a+1, a+2, a+3, a+4, a+5);
-  if(NUM_FIELDS == n)
-  {
-    int i;
-    union {
-      uint8_t b[NUM_FIELDS];
-      struct {
-        uint32_t ip;
-        uint16_t port;
-      } u ;
-    } ip_info;
-
-    for(i = 0; i < NUM_FIELDS; ++i)
-    {
-      if(a[i] > 255)
-        break;
-      ip_info.b[i] = (uint8_t)a[i];
-    }
-
-    if(i == NUM_FIELDS)
-    {
-      /* Note: while it contradicts with RFC959, we don't allow PORT command
-       * to specify IP address different than those of the originating client
-       * for the sake of safety. */
-      if (ip_info.u.ip == info->def_addr.sin_addr.s_addr)
-      {
-        info->data_addr.sin_addr.s_addr = ip_info.u.ip;
-        info->data_addr.sin_port        = ip_info.u.port;
-        info->data_addr.sin_family      = AF_INET;
-        memset(info->data_addr.sin_zero, 0, sizeof(info->data_addr.sin_zero));
-
-        info->use_default = 0;
-        send_reply(info, 200, "PORT command successful.");
-        return; /* success */
-      }
-      else
-      {
-        send_reply(info, 425, "Address doesn't match peer's IP.");
-        return;
-      }
-    }
-  }
-  send_reply(info, 501, "Syntax error.");
-}
-
-
-/*
- * command_pasv
- *
- * Handle FTP PASV command.
- * Open socket, listen for and accept connection on it.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *
- * Output parameters:
- *   info->pasv_socket is set to the descriptor of the data socket
- */
-static void
-command_pasv(FTPD_SessionInfo_t *info)
-{
-  int s = -1;
-  int err = 1;
-
-  close_data_socket(info);
-
-  s = socket(PF_INET, SOCK_STREAM, 0);
-  if (s < 0)
-    syslog(LOG_ERR, "ftpd: Error creating PASV socket: %s", serr());
-  else
-  {
-    struct sockaddr_in addr;
-    socklen_t addrLen = sizeof(addr);
-
-    addr = info->ctrl_addr;
-    addr.sin_port = htons(0);
-
-    if (0 > bind(s, (struct sockaddr *)&addr, addrLen))
-      syslog(LOG_ERR, "ftpd: Error binding PASV socket: %s", serr());
-    else if (0 > listen(s, 1))
-      syslog(LOG_ERR, "ftpd: Error listening on PASV socket: %s", serr());
-    else if(set_socket_timeout(s, info->idle))
-    {
-      char buf[FTPD_BUFSIZE];
-      unsigned char const *ip, *p;
-
-      getsockname(s, (struct sockaddr *)&addr, &addrLen);
-      ip = (unsigned char const*)&(addr.sin_addr);
-      p  = (unsigned char const*)&(addr.sin_port);
-      snprintf(buf, FTPD_BUFSIZE, "Entering passive mode (%u,%u,%u,%u,%u,%u).",
-        ip[0], ip[1], ip[2], ip[3], p[0], p[1]);
-      send_reply(info, 227, buf);
-
-      info->pasv_socket = accept(s, (struct sockaddr *)&addr, &addrLen);
-      if (0 > info->pasv_socket)
-        syslog(LOG_ERR, "ftpd: Error accepting PASV connection: %s", serr());
-      else
-      {
-        close_socket(s);
-        s = -1;
-        err = 0;
-      }
-    }
-  }
-  if(err)
-  {
-    /* (OSV) The note is from FreeBSD FTPD.
-     * Note: a response of 425 is not mentioned as a possible response to
-     * the PASV command in RFC959.  However, it has been blessed as a
-     * legitimate response by Jon Postel in a telephone conversation
-     * with Rick Adams on 25 Jan 89. */
-    send_reply(info, 425, "Can't open passive connection.");
-    close_socket(s);
-  }
-}
-
-
-/*
- * skip_options
- *
- * Utility routine to skip options (if any) from input command.
- *
- * Input parameters:
- *   p  - pointer to pointer to command
- *
- * Output parameters:
- *   p  - is changed to point to first non-option argument
- */
-static void
-skip_options(char **p)
-{
-  char* buf = *p;
-  char* last = NULL;
-  while(1) {
-    while(isspace((unsigned char)*buf))
-      ++buf;
-    if(*buf == '-') {
-      if(*++buf == '-') { /* `--' should terminate options */
-        if(isspace((unsigned char)*++buf)) {
-          last = buf;
-          do ++buf;
-          while(isspace((unsigned char)*buf));
-          break;
-        }
-      }
-      while(*buf && !isspace((unsigned char)*buf))
-        ++buf;
-      last = buf;
-    }
-    else
-      break;
-  }
-  if(last)
-    *last = '\0';
-  *p = buf;
-}
-
-/*
- * split_command
- *
- * Split command into command itself, options, and arguments. Command itself
- * is converted to upper case.
- *
- * Input parameters:
- *   buf - initial command string
- *
- * Output parameter:
- *   buf  - is modified by inserting '\0' at ends of split entities
- *   cmd  - upper-cased command code
- *   opts - string containing all the options
- *   args - string containing all the arguments
- */
-static void
-split_command(char *buf, char **cmd, char **opts, char **args)
-{
-  char* eoc;
-  char* p = buf;
-  while(isspace((unsigned char)*p))
-    ++p;
-  *cmd = p;
-  while(*p && !isspace((unsigned char)*p))
-  {
-    *p = toupper((unsigned char)*p);
-    ++p;
-  }
-  eoc = p;
-  if(*p)
-    *p++ = '\0';
-  while(isspace((unsigned char)*p))
-    ++p;
-  *opts = p;
-  skip_options(&p);
-  *args = p;
-  if(*opts == p)
-    *opts = eoc;
-  while(*p && *p != '\r' && *p != '\n')
-    ++p;
-  if(*p)
-    *p++ = '\0';
-}
-
-/*
- * exec_command
- *
- * Parse and execute FTP command.
- *
- * FIXME: This section is somewhat of a hack.  We should have a better
- *        way to parse commands.
- *
- * Input parameters:
- *   info - corresponding SessionInfo structure
- *   cmd  - command to be executed (upper-case)
- *   args - arguments of the command
- *
- * Output parameters:
- *    NONE
- */
-static void
-exec_command(FTPD_SessionInfo_t *info, char* cmd, char* args)
-{
-  char fname[FTPD_BUFSIZE];
-  int wrong_command = 0;
-
-  fname[0] = '\0';
-
-  if (!strcmp("PORT", cmd))
-  {
-    command_port(info, args);
-  }
-  else if (!strcmp("PASV", cmd))
-  {
-    command_pasv(info);
-  }
-  else if (!strcmp("RETR", cmd))
-  {
-    strncpy(fname, args, 254);
-    command_retrieve(info, fname);
-  }
-  else if (!strcmp("STOR", cmd))
-  {
-    strncpy(fname, args, 254);
-    command_store(info, fname);
-  }
-  else if (!strcmp("LIST", cmd))
-  {
-    strncpy(fname, args, 254);
-    command_list(info, fname, 1);
-  }
-  else if (!strcmp("NLST", cmd))
-  {
-    strncpy(fname, args, 254);
-    command_list(info, fname, 0);
-  }
-  else if (!strcmp("MDTM", cmd))
-  {
-    strncpy(fname, args, 254);
-    command_mdtm(info, fname);
-  }
-  else if (!strcmp("SYST", cmd))
-  {
-    send_reply(info, 215, FTPD_SYSTYPE);
-  }
-  else if (!strcmp("TYPE", cmd))
-  {
-    if (args[0] == 'I')
-    {
-      info->xfer_mode = TYPE_I;
-      send_reply(info, 200, "Type set to I.");
-    }
-    else if (args[0] == 'A')
-    {
-      info->xfer_mode = TYPE_A;
-      send_reply(info, 200, "Type set to A.");
-    }
-    else
-    {
-      info->xfer_mode = TYPE_I;
-      send_reply(info, 504, "Type not implemented.  Set to I.");
-    }
-  }
-  else if (!strcmp("USER", cmd))
-  {
-    sscanf(args, "%254s", fname);
-    if (info->user)
-      free(info->user);
-    if (info->pass)
-      free(info->pass);
-    info->pass = NULL;
-    info->user = strdup(fname);
-    if (rtems_ftpd_configuration.login &&
-      !rtems_ftpd_configuration.login(info->user, NULL)) {
-      info->auth = false;
-      send_reply(info, 331, "User name okay, need password.");
-    } else {
-      info->auth = true;
-      send_reply(info, 230, "User logged in.");
-    }
-  }
-  else if (!strcmp("PASS", cmd))
-  {
-    sscanf(args, "%254s", fname);
-    if (info->pass)
-      free(info->pass);
-    info->pass = strdup(fname);
-    if (!info->user) {
-      send_reply(info, 332, "Need account to log in");
-    } else {
-      if (rtems_ftpd_configuration.login &&
-        !rtems_ftpd_configuration.login(info->user, info->pass)) {
-        info->auth = false;
-        send_reply(info, 530, "Not logged in.");
-      } else {
-        info->auth = true;
-        send_reply(info, 230, "User logged in.");
-      }
-    }
-  }
-  else if (!strcmp("DELE", cmd))
-  {
-    if(!can_write() || !info->auth)
-    {
-      send_reply(info, 550, "Access denied.");
-    }
-    else if (
-      strncpy(fname, args, 254) &&
-      unlink(fname) == 0)
-    {
-      send_reply(info, 257, "DELE successful.");
-    }
-    else
-    {
-      send_reply(info, 550, "DELE failed.");
-    }
-  }
-  else if (!strcmp("SITE", cmd))
-  {
-    char* opts;
-    split_command(args, &cmd, &opts, &args);
-    if(!strcmp("CHMOD", cmd))
-    {
-      int mask;
-
-      if(!can_write() || !info->auth)
-      {
-        send_reply(info, 550, "Access denied.");
-      }
-      else {
-        char *c;
-        c = strchr(args, ' ');
-        if((c != NULL) && (sscanf(args, "%o", &mask) == 1) && strncpy(fname, c+1, 254) 
-          && (chmod(fname, (mode_t)mask) == 0))
-          send_reply(info, 257, "CHMOD successful.");
-        else
-          send_reply(info, 550, "CHMOD failed.");
-      }
-    }
-    else
-      wrong_command = 1;
-  }
-  else if (!strcmp("RMD", cmd))
-  {
-    if(!can_write() || !info->auth)
-    {
-      send_reply(info, 550, "Access denied.");
-    }
-    else if (
-      strncpy(fname, args, 254) &&
-      rmdir(fname) == 0)
-    {
-      send_reply(info, 257, "RMD successful.");
-    }
-    else
-    {
-      send_reply(info, 550, "RMD failed.");
-    }
-  }
-  else if (!strcmp("MKD", cmd))
-  {
-    if(!can_write() || !info->auth)
-    {
-      send_reply(info, 550, "Access denied.");
-    }
-    else if (
-      strncpy(fname, args, 254) &&
-      mkdir(fname, S_IRWXU | S_IRWXG | S_IRWXO) == 0)
-    {
-      send_reply(info, 257, "MKD successful.");
-    }
-    else
-    {
-      send_reply(info, 550, "MKD failed.");
-    }
-  }
-  else if (!strcmp("CWD", cmd))
-  {
-    strncpy(fname, args, 254);
-    command_cwd(info, fname);
-  }
-  else if (!strcmp("CDUP", cmd))
-  {
-    command_cwd(info, "..");
-  }
-  else if (!strcmp("PWD", cmd))
-  {
-    command_pwd(info);
-  }
-  else
-    wrong_command = 1;
-
-  if(wrong_command)
-    send_reply(info, 500, "Command not understood.");
-}
-
-
-/*
- * session
- *
- * This task handles single session.  It is waked up when the FTP daemon gets a
- * service request from a remote machine.  Here, we watch for commands that
- * will come through the control connection.  These commands are then parsed
- * and executed until the connection is closed, either unintentionally or
- * intentionally with the "QUIT" command.
- *
- * Input parameters:
- *   arg - pointer to corresponding SessionInfo.
- *
- * Output parameters:
- *   NONE
- */
-static void
-session(rtems_task_argument arg)
-{
-  FTPD_SessionInfo_t  *const info = (FTPD_SessionInfo_t  *)arg;
-  int chroot_made = 0;
-
-  rtems_libio_set_private_env();
-
-  /* chroot() can fail here because the directory may not exist yet. */
-  chroot_made = chroot(ftpd_root) == 0;
-
-  while(1)
-  {
-    rtems_event_set set;
-
-    rtems_event_receive(FTPD_RTEMS_EVENT, RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT,
-      &set);
-
-    chroot_made = chroot_made || chroot(ftpd_root) == 0;
-
-    errno = 0;
-
-    send_reply(info, 220, FTPD_SERVER_MESSAGE);
-
-    while (1)
-    {
-      char buf[FTPD_BUFSIZE];
-      char *cmd, *opts, *args;
-
-      if (fgets(buf, FTPD_BUFSIZE, info->ctrl_fp) == NULL)
-      {
-        syslog(LOG_INFO, "ftpd: Connection aborted.");
-        break;
-      }
-
-      split_command(buf, &cmd, &opts, &args);
-
-      if (!strcmp("QUIT", cmd))
-      {
-        send_reply(info, 221, "Goodbye.");
-        break;
-      }
-      else
-      {
-        exec_command(info, cmd, args);
-      }
-    }
-
-    /* Close connection and put ourselves back into the task pool. */
-    close_data_socket(info);
-    close_stream(info);
-    free(info->user);
-    free(info->pass);
-    task_pool_release(info);
-
-    chdir("/");
-  }
-}
-
-
-/*
- * daemon
- *
- * This task runs forever.  It waits for service requests on the FTP port
- * (port 21 by default).  When a request is received, it opens a new session
- * to handle those requests until the connection is closed.
- *
- * Input parameters:
- *   NONE
- *
- * Output parameters:
- *   NONE
- */
-static void
-daemon(rtems_task_argument args __attribute__((unused)))
-{
-  int                 s;
-  socklen_t	      addrLen;
-  struct sockaddr_in  addr;
-  FTPD_SessionInfo_t  *info = NULL;
-
-
-  s = socket(PF_INET, SOCK_STREAM, 0);
-  if (s < 0)
-    syslog(LOG_ERR, "ftpd: Error creating socket: %s", serr());
-
-  addr.sin_family      = AF_INET;
-  addr.sin_port        = htons(rtems_ftpd_configuration.port);
-  addr.sin_addr.s_addr = htonl(INADDR_ANY);
-  memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
-
-  if (0 > bind(s, (struct sockaddr *)&addr, sizeof(addr)))
-    syslog(LOG_ERR, "ftpd: Error binding control socket: %s", serr());
-  else if (0 > listen(s, 1))
-    syslog(LOG_ERR, "ftpd: Error listening on control socket: %s", serr());
-  else while (1)
-  {
-    int ss;
-    addrLen = sizeof(addr);
-    ss = accept(s, (struct sockaddr *)&addr, &addrLen);
-    if (0 > ss)
-      syslog(LOG_ERR, "ftpd: Error accepting control connection: %s", serr());
-    else if(!set_socket_timeout(ss, ftpd_timeout))
-      close_socket(ss);
-    else
-    {
-      info = task_pool_obtain();
-      if (NULL == info)
-      {
-        close_socket(ss);
-      }
-      else
-      {
-        info->ctrl_socket = ss;
-        if ((info->ctrl_fp = fdopen(info->ctrl_socket, "r+")) == NULL)
-        {
-          syslog(LOG_ERR, "ftpd: fdopen() on socket failed: %s", serr());
-          close_stream(info);
-          task_pool_release(info);
-        }
-        else
-        {
-          /* Initialize corresponding SessionInfo structure */
-          info->def_addr = addr;
-          if(0 > getsockname(ss, (struct sockaddr *)&addr, &addrLen))
-          {
-            syslog(LOG_ERR, "ftpd: getsockname(): %s", serr());
-            close_stream(info);
-            task_pool_release(info);
-          }
-          else
-          {
-            info->use_default = 1;
-            info->ctrl_addr  = addr;
-            info->pasv_socket = -1;
-            info->data_socket = -1;
-            info->xfer_mode   = TYPE_A;
-            info->data_addr.sin_port =
-              htons(ntohs(info->ctrl_addr.sin_port) - 1);
-            info->idle = ftpd_timeout;
-            info->user = NULL;
-            info->pass = NULL;
-            if (rtems_ftpd_configuration.login)
-              info->auth = false;
-            else
-              info->auth = true;
-            /* Wakeup the session task.  The task will call task_pool_release
-               after it closes connection. */
-            rtems_event_send(info->tid, FTPD_RTEMS_EVENT);
-          }
-        }
-      }
-    }
-  }
-  rtems_task_delete(RTEMS_SELF);
-}
-
-
-/*
- * rtems_ftpd_start
- *
- * Here, we start the FTPD task which waits for FTP requests and services
- * them.  This procedure returns to its caller once the task is started.
- *
- *
- * Input parameters:
- *
- * Output parameters:
- *    returns RTEMS_SUCCESSFUL on successful start of the daemon.
- */
-int
-rtems_initialize_ftpd(void)
-{
-  rtems_status_code   sc;
-  rtems_id            tid;
-  rtems_task_priority priority;
-  int count;
-
-  if (rtems_ftpd_configuration.port == 0)
-  {
-    rtems_ftpd_configuration.port = FTPD_CONTROL_PORT;
-  }
-
-  if (rtems_ftpd_configuration.priority == 0)
-  {
-    rtems_ftpd_configuration.priority = 40;
-  }
-  priority = rtems_ftpd_configuration.priority;
-
-  ftpd_timeout = rtems_ftpd_configuration.idle;
-  if (ftpd_timeout < 0)
-    ftpd_timeout = 0;
-  rtems_ftpd_configuration.idle = ftpd_timeout;
-
-  ftpd_access = rtems_ftpd_configuration.access;
-
-  ftpd_root = "/";
-  if ( rtems_ftpd_configuration.root &&
-       rtems_ftpd_configuration.root[0] == '/' )
-    ftpd_root = rtems_ftpd_configuration.root;
-
-  rtems_ftpd_configuration.root = ftpd_root;
-
-  if (rtems_ftpd_configuration.tasks_count <= 0)
-    rtems_ftpd_configuration.tasks_count = 1;
-  count = rtems_ftpd_configuration.tasks_count;
-
-  if (!task_pool_init(count, priority))
-  {
-    syslog(LOG_ERR, "ftpd: Could not initialize task pool.");
-    return RTEMS_UNSATISFIED;
-  }
-
-  sc = rtems_task_create(rtems_build_name('F', 'T', 'P', 'D'),
-    priority, RTEMS_MINIMUM_STACK_SIZE,
-    RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR |
-    RTEMS_INTERRUPT_LEVEL(0),
-    RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
-    &tid);
-
-  if (sc == RTEMS_SUCCESSFUL)
-  {
-    sc = rtems_task_start(tid, daemon, 0);
-    if (sc != RTEMS_SUCCESSFUL)
-      rtems_task_delete(tid);
-  }
-
-  if (sc != RTEMS_SUCCESSFUL)
-  {
-    task_pool_done(count);
-    syslog(LOG_ERR, "ftpd: Could not create/start FTP daemon: %s",
-      rtems_status_text(sc));
-    return RTEMS_UNSATISFIED;
-  }
-
-  syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)",
-    count, ((count > 1) ? "s" : ""));
-
-  return RTEMS_SUCCESSFUL;
-}
Index: rvices/ftpd/ftpd.h
===================================================================
--- services/ftpd/ftpd.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,74 +1,0 @@
-/*
- *  FTP Server Information
- */
-
-#ifndef _RTEMS_FTPD_H
-#define _RTEMS_FTPD_H
-
-#include <rtems.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define FTPD_CONTROL_PORT   21
-
-/* Various buffer sizes */
-enum {
-  FTPD_BUFSIZE  = 256,       /* Size for temporary buffers */
-  FTPD_DATASIZE = 4 * 1024,      /* Size for file transfer buffers */
-  FTPD_STACKSIZE = RTEMS_MINIMUM_STACK_SIZE + FTPD_DATASIZE /* Tasks stack size */
-};
-
-/* FTPD access control flags */
-enum
-{
-  FTPD_NO_WRITE = 0x1,
-  FTPD_NO_READ  = 0x2,
-  FTPD_NO_RW    = FTPD_NO_WRITE | FTPD_NO_READ
-};
-
-typedef int (*rtems_ftpd_hookfunction)(char *, size_t);
-
-#include <rtems/shell.h>
-
-struct rtems_ftpd_hook
-{
-   char                    *filename;
-   rtems_ftpd_hookfunction hook_function;
-};
-
-struct rtems_ftpd_configuration
-{
-   rtems_task_priority     priority;           /* FTPD task priority  */
-   unsigned long           max_hook_filesize;  /* Maximum buffersize  */
-                                               /*    for hooks        */
-   int                     port;               /* Well-known port     */
-   struct rtems_ftpd_hook  *hooks;             /* List of hooks       */
-   char const              *root;              /* Root for FTPD or 0 for / */
-   int                     tasks_count;        /* Max. connections    */
-   int                     idle;               /* Idle timeout in seoconds
-                                                  or 0 for no (inf) timeout */
-   int                     access;             /* 0 - r/w, 1 - read-only,
-                                                  2 - write-only,
-                                                  3 - browse-only */
-   rtems_shell_login_check_t login;            /* Login check or 0 to ignore
-                                                  user/passwd. */
-};
-
-/*
- * Reply codes.
- */
-#define PRELIM          1       /* positive preliminary */
-#define COMPLETE        2       /* positive completion */
-#define CONTINUE        3       /* positive intermediate */
-#define TRANSIENT       4       /* transient negative completion */
-#define ERROR           5       /* permanent negative completion */
-
-int rtems_initialize_ftpd(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* _RTEMS_FTPD_H */
Index: rvices/ftpfs/Makefile
===================================================================
--- services/ftpfs/Makefile	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,38 +1,0 @@
-include ../../config.inc
-
-include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
-include $(RTEMS_CUSTOM)
-include $(PROJECT_ROOT)/make/leaf.cfg
-
-CFLAGS += -I $(INSTALL_BASE)/include
-
-CFLAGS += -w 
-CFLAGS += -I include 
-CFLAGS += -std=gnu99
-CFLAGS += -MT $@ -MD -MP -MF $(basename $@).d
-
-C_FILES =
-C_FILES += ftpfs.c
-
-C_O_FILES = $(C_FILES:%.c=%.o)
-C_D_FILES = $(C_FILES:%.c=%.d)
-
-LIB = libftpfs.a
-
-all: $(LIB)
-
-$(LIB): $(C_O_FILES)
-	$(AR) rcu $@ $^
-
-install: $(LIB)
-	install -d $(INSTALL_BASE)/include/rtems
-	install -c -m 644 include/rtems/ftpfs.h $(INSTALL_BASE)/
-	install -c -m 644 $(LIB) $(INSTALL_BASE)
-
-clean:
-	rm -f $(LIB) $(C_O_FILES) $(C_D_FILES) $(GEN_FILES)
-
--include $(C_D_FILES)
-
-doc: 
-
Index: rvices/ftpfs/ftpfs.c
===================================================================
--- services/ftpfs/ftpfs.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,1317 +1,0 @@
-/**
- * @file
- *
- * File Transfer Protocol file system (FTP client).
- */
-
-/*
- * Copyright (c) 2009-2012
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * (c) Copyright 2002
- * Thomas Doerfler
- * IMD Ingenieurbuero fuer Microcomputertechnik
- * Herbststr. 8
- * 82178 Puchheim, Germany
- * <Thomas.Doerfler@imd-systems.de>
- *
- * Modified by Sebastian Huber <sebastian.huber@embedded-brains.de>.
- *
- * This code has been created after closly inspecting "tftpdriver.c" from Eric
- * Norum.
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <malloc.h>
-#include <netdb.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/select.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <rtems.h>
-#include <rtems/ftpfs.h>
-#include <rtems/libio_.h>
-#include <rtems/rtems_bsdnet.h>
-#include <rtems/seterr.h>
-
-#ifdef DEBUG
-  #define DEBUG_PRINTF(...) printf(__VA_ARGS__)
-#else
-  #define DEBUG_PRINTF(...)
-#endif
-
-/**
- * Connection entry for each open file stream.
- */
-typedef struct {
-  /**
-   * Control connection socket.
-   */
-  int ctrl_socket;
-
-  /**
-   * Data transfer socket.
-   */
-  int data_socket;
-
-  /**
-   * Current index into the reply buffer.
-   */
-  size_t reply_current;
-
-  /**
-   * End index of the reply buffer.
-   */
-  size_t reply_end;
-
-  /**
-   * Buffer for relpy data.
-   */
-  char reply_buffer [128];
-
-  /**
-   * End of file flag.
-   */
-  bool eof;
-} rtems_ftpfs_entry;
-
-/**
- * Mount entry for each file system instance.
- */
-typedef struct {
-  /**
-   * Verbose mode enabled or disabled.
-   */
-  bool verbose;
-
-  /**
-   * Timeout value
-   */
-  struct timeval timeout;
-} rtems_ftpfs_mount_entry;
-
-static const rtems_filesystem_operations_table rtems_ftpfs_ops;
-
-static const rtems_filesystem_file_handlers_r rtems_ftpfs_handlers;
-
-static const rtems_filesystem_file_handlers_r rtems_ftpfs_root_handlers;
-
-static bool rtems_ftpfs_use_timeout(const struct timeval *to)
-{
-  return to->tv_sec != 0 || to->tv_usec != 0;
-}
-
-static int rtems_ftpfs_set_connection_timeout(
-  int socket,
-  const struct timeval *to
-)
-{
-  if (rtems_ftpfs_use_timeout(to)) {
-    int rv = 0;
-    
-    rv = setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, to, sizeof(*to));
-    if (rv != 0) {
-      return EIO;
-    }
-
-    rv = setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, to, sizeof(*to));
-    if (rv != 0) {
-      return EIO;
-    }
-  }
-
-  return 0;
-}
-
-static rtems_status_code rtems_ftpfs_do_ioctl(
-  const char *mount_point,
-  ioctl_command_t req,
-  ...
-)
-{
-  rtems_status_code sc = RTEMS_SUCCESSFUL;
-  int rv = 0;
-  int fd = 0;
-  va_list ap;
-
-  if (mount_point == NULL) {
-    mount_point = RTEMS_FTPFS_MOUNT_POINT_DEFAULT;
-  }
-
-  fd = open(mount_point, O_RDWR);
-  if (fd < 0) {
-    return RTEMS_INVALID_NAME;
-  }
-  
-  va_start(ap, req);
-  rv = ioctl(fd, req, va_arg(ap, void *));
-  va_end(ap);
-  if (rv != 0) {
-    sc = RTEMS_INVALID_NUMBER;
-  }
-
-  rv = close(fd);
-  if (rv != 0 && sc == RTEMS_SUCCESSFUL) {
-    sc = RTEMS_IO_ERROR;
-  }
-  
-  return sc;
-}
-
-rtems_status_code rtems_ftpfs_get_verbose(const char *mount_point, bool *verbose)
-{
-  return rtems_ftpfs_do_ioctl(
-    mount_point,
-    RTEMS_FTPFS_IOCTL_GET_VERBOSE,
-    verbose
-  );
-}
-
-rtems_status_code rtems_ftpfs_set_verbose(const char *mount_point, bool verbose)
-{
-  return rtems_ftpfs_do_ioctl(
-    mount_point,
-    RTEMS_FTPFS_IOCTL_SET_VERBOSE,
-    &verbose
-  );
-}
-
-rtems_status_code rtems_ftpfs_get_timeout(
-  const char *mount_point,
-  struct timeval *timeout
-)
-{
-  return rtems_ftpfs_do_ioctl(
-    mount_point,
-    RTEMS_FTPFS_IOCTL_GET_TIMEOUT,
-    timeout
-  );
-}
-
-rtems_status_code rtems_ftpfs_set_timeout(
-  const char *mount_point,
-  const struct timeval *timeout
-)
-{
-  return rtems_ftpfs_do_ioctl(
-    mount_point,
-    RTEMS_FTPFS_IOCTL_SET_TIMEOUT,
-    timeout
-  );
-}
-
-typedef void (*rtems_ftpfs_reply_parser)(
-  const char * /* reply fragment */,
-  size_t /* reply fragment length */,
-  void * /* parser argument */
-);
-
-typedef enum {
-  RTEMS_FTPFS_REPLY_START,
-  RTEMS_FTPFS_REPLY_SINGLE_LINE,
-  RTEMS_FTPFS_REPLY_DONE,
-  RTEMS_FTPFS_REPLY_MULTI_LINE,
-  RTEMS_FTPFS_REPLY_MULTI_LINE_START
-} rtems_ftpfs_reply_state;
-
-typedef enum {
-  RTEMS_FTPFS_REPLY_ERROR = 0,
-  RTEMS_FTPFS_REPLY_1 = '1',
-  RTEMS_FTPFS_REPLY_2 = '2',
-  RTEMS_FTPFS_REPLY_3 = '3',
-  RTEMS_FTPFS_REPLY_4 = '4',
-  RTEMS_FTPFS_REPLY_5 = '5'
-} rtems_ftpfs_reply;
-
-#define RTEMS_FTPFS_REPLY_SIZE 3
-
-static bool rtems_ftpfs_is_reply_code_valid(unsigned char *reply)
-{
-  return isdigit(reply [0]) && isdigit(reply [1]) && isdigit(reply [2]);
-}
-
-static rtems_ftpfs_reply rtems_ftpfs_get_reply(
-  rtems_ftpfs_entry *e,
-  rtems_ftpfs_reply_parser parser,
-  void *parser_arg,
-  bool verbose
-)
-{
-  rtems_ftpfs_reply_state state = RTEMS_FTPFS_REPLY_START;
-  unsigned char reply_code [RTEMS_FTPFS_REPLY_SIZE] = { 'a', 'a', 'a' };
-  size_t reply_code_index = 0;
-
-  while (state != RTEMS_FTPFS_REPLY_DONE) {
-    char *buf = NULL;
-    size_t i = 0;
-    size_t n = 0;
-
-    /* Receive reply fragment from socket */
-    if (e->reply_current == e->reply_end) {
-      ssize_t rv = 0;
-
-      e->reply_current = 0;
-      e->reply_end = 0;
-
-      rv = recv(
-        e->ctrl_socket,
-        &e->reply_buffer [0],
-        sizeof(e->reply_buffer),
-        0
-      );
-
-      if (rv > 0) {
-        e->reply_end = (size_t) rv;
-      } else {
-        return RTEMS_FTPFS_REPLY_ERROR;
-      }
-    }
-
-    buf = &e->reply_buffer [e->reply_current];
-    n = e->reply_end - e->reply_current;
-
-    /* Invoke parser if necessary */
-    if (parser != NULL) {
-      parser(buf, n, parser_arg);
-    }
-
-    /* Parse reply fragment */
-    for (i = 0; i < n && state != RTEMS_FTPFS_REPLY_DONE; ++i) {
-      char c = buf [i];
-
-      switch (state) {
-        case RTEMS_FTPFS_REPLY_START:
-          if (reply_code_index < RTEMS_FTPFS_REPLY_SIZE) {
-            reply_code [reply_code_index] = c;
-            ++reply_code_index;
-          } else if (rtems_ftpfs_is_reply_code_valid(reply_code)) {
-            if (c == '-') {
-              state = RTEMS_FTPFS_REPLY_MULTI_LINE;
-            } else {
-              state = RTEMS_FTPFS_REPLY_SINGLE_LINE;
-            }
-          } else {
-            return RTEMS_FTPFS_REPLY_ERROR;
-          }
-          break;
-        case RTEMS_FTPFS_REPLY_SINGLE_LINE:
-          if (c == '\n') {
-            state = RTEMS_FTPFS_REPLY_DONE;
-          }
-          break;
-        case RTEMS_FTPFS_REPLY_MULTI_LINE:
-          if (c == '\n') {
-            state = RTEMS_FTPFS_REPLY_MULTI_LINE_START;
-            reply_code_index = 0;
-          }
-          break;
-        case RTEMS_FTPFS_REPLY_MULTI_LINE_START:
-          if (reply_code_index < RTEMS_FTPFS_REPLY_SIZE) {
-            if (reply_code [reply_code_index] == c) {
-              ++reply_code_index;
-            } else {
-              state = RTEMS_FTPFS_REPLY_MULTI_LINE;
-            }
-          } else {
-            if (c == ' ') {
-              state = RTEMS_FTPFS_REPLY_SINGLE_LINE;
-            } else {
-              state = RTEMS_FTPFS_REPLY_MULTI_LINE;
-            }
-          }
-          break;
-        default:
-          return RTEMS_FTPFS_REPLY_ERROR;
-      }
-    }
-
-    /* Be verbose if necessary */
-    if (verbose) {
-      write(STDERR_FILENO, buf, i);
-    }
-
-    /* Update reply index */
-    e->reply_current += i;
-  }
-
-  return reply_code [0];
-}
-
-static rtems_ftpfs_reply rtems_ftpfs_send_command_with_parser(
-  rtems_ftpfs_entry *e,
-  const char *cmd,
-  const char *arg,
-  rtems_ftpfs_reply_parser parser,
-  void *parser_arg,
-  bool verbose
-)
-{
-  rtems_ftpfs_reply reply = RTEMS_FTPFS_REPLY_ERROR;
-  size_t cmd_len = strlen(cmd);
-  size_t arg_len = arg != NULL ? strlen(arg) : 0;
-  size_t len = cmd_len + arg_len + 2;
-  char *buf = malloc(len);
-
-  if (buf != NULL) {
-    ssize_t n = 0;
-    char *buf_arg = buf + cmd_len;
-    char *buf_eol = buf_arg + arg_len;
-
-    memcpy(buf, cmd, cmd_len);
-    memcpy(buf_arg, arg, arg_len);
-    buf_eol [0] = '\r';
-    buf_eol [1] = '\n';
-
-    /* Send */
-    n = send(e->ctrl_socket, buf, len, 0);
-    if (n == (ssize_t) len) {
-      if (verbose) {
-        write(STDERR_FILENO, buf, len);
-      }
-
-      /* Reply */
-      reply = rtems_ftpfs_get_reply(e, parser, parser_arg, verbose);
-    }
-
-    free(buf);
-  }
-
-  return reply;
-}
-
-static rtems_ftpfs_reply rtems_ftpfs_send_command(
-  rtems_ftpfs_entry *e,
-  const char *cmd,
-  const char *arg,
-  bool verbose
-)
-{
-  return rtems_ftpfs_send_command_with_parser(
-    e,
-    cmd,
-    arg,
-    NULL,
-    NULL,
-    verbose
-  );
-}
-
-typedef enum {
-  STATE_USER_NAME,
-  STATE_START_PASSWORD,
-  STATE_START_HOST_NAME,
-  STATE_START_HOST_NAME_OR_PATH,
-  STATE_START_PATH,
-  STATE_PASSWORD,
-  STATE_HOST_NAME,
-  STATE_DONE,
-  STATE_INVALID
-} split_state;
-
-static bool rtems_ftpfs_split_names (
-  char *s,
-  const char **user,
-  const char **password,
-  const char **hostname,
-  const char **path
-)
-{
-  split_state state = STATE_USER_NAME;
-  size_t len = strlen(s);
-  size_t i = 0;
-
-  *user = s;
-  *password = NULL;
-  *hostname = NULL;
-  *path = NULL;
-
-  for (i = 0; i < len; ++i) {
-    char c = s [i];
-
-    switch (state) {
-      case STATE_USER_NAME:
-        if (c == ':') {
-          state = STATE_START_PASSWORD;
-          s [i] = '\0';
-        } else if (c == '@') {
-          state = STATE_START_HOST_NAME;
-          s [i] = '\0';
-        } else if (c == '/') {
-          state = STATE_START_HOST_NAME_OR_PATH;
-          s [i] = '\0';
-        }
-        break;
-      case STATE_START_PASSWORD:
-        state = STATE_PASSWORD;
-        *password = &s [i];
-        --i;
-        break;
-      case STATE_START_HOST_NAME:
-        state = STATE_HOST_NAME;
-        *hostname = &s [i];
-        --i;
-        break;
-      case STATE_START_HOST_NAME_OR_PATH:
-        if (c == '@') {
-          state = STATE_START_HOST_NAME;
-        } else {
-          state = STATE_DONE;
-          *path = &s [i];
-          goto done;
-        }
-        break;
-      case STATE_START_PATH:
-        state = STATE_DONE;
-        *path = &s [i];
-        goto done;
-      case STATE_PASSWORD:
-        if (c == '@') {
-          state = STATE_START_HOST_NAME;
-          s [i] = '\0';
-        } else if (c == '/') {
-          state = STATE_START_HOST_NAME_OR_PATH;
-          s [i] = '\0';
-        }
-        break;
-      case STATE_HOST_NAME:
-        if (c == '/') {
-          state = STATE_START_PATH;
-          s [i] = '\0';
-        }
-        break;
-      default:
-        state = STATE_INVALID;
-        goto done;
-    }
-  }
-
-done:
-
-  /* This is a special case with no username and password */
-  if (*hostname == NULL) {
-    *hostname = &s [0];
-    *user = "anonymous";
-    *password = *user;
-  }
-
-  /* If we have no password use the user name */
-  if (*password == NULL) {
-    *password = *user;
-  }
-
-  return state == STATE_DONE;
-}
-
-static socklen_t rtems_ftpfs_create_address(
-  struct sockaddr_in *sa,
-  unsigned long address,
-  unsigned short port
-)
-{
-  memset(sa, sizeof(*sa), 0);
-
-  sa->sin_family = AF_INET;
-  sa->sin_addr.s_addr = address;
-  sa->sin_port = port;
-  sa->sin_len = sizeof(*sa);
-
-  return sizeof(*sa);
-}
-
-static int rtems_ftpfs_terminate(rtems_libio_t *iop, bool error)
-{
-  int eno = 0;
-  int rv = 0;
-  rtems_ftpfs_entry *e = iop->data1;
-  rtems_ftpfs_mount_entry *me = iop->pathinfo.mt_entry->fs_info;
-  bool verbose = me->verbose;
-  rtems_ftpfs_reply reply = RTEMS_FTPFS_REPLY_ERROR;
-
-  if (e != NULL) {
-    /* Close data connection if necessary */
-    if (e->data_socket >= 0) {
-      rv = close(e->data_socket);
-      if (rv != 0) {
-        eno = EIO;
-      }
-
-      /* For write connections we have to obtain the transfer reply  */
-      if (
-        e->ctrl_socket >= 0
-          && (iop->flags & LIBIO_FLAGS_WRITE) != 0
-          && !error
-      ) {
-        reply = rtems_ftpfs_get_reply(e, NULL, NULL, verbose);
-        if (reply != RTEMS_FTPFS_REPLY_2) {
-          eno = EIO;
-        }
-      }
-    }
-
-    /* Close control connection if necessary */
-    if (e->ctrl_socket >= 0) {
-      reply = rtems_ftpfs_send_command(e, "QUIT", NULL, verbose);
-      if (reply != RTEMS_FTPFS_REPLY_2) {
-        eno = EIO;
-      }
-
-      rv = close(e->ctrl_socket);
-      if (rv != 0) {
-        eno = EIO;
-      }
-    }
-
-    /* Free connection entry */
-    free(e);
-  }
-
-  /* Invalidate IO entry */
-  iop->data1 = NULL;
-
-  return eno;
-}
-
-static int rtems_ftpfs_open_ctrl_connection(
-  rtems_ftpfs_entry *e,
-  const char *user,
-  const char *password,
-  const char *hostname,
-  uint32_t *client_address,
-  bool verbose,
-  const struct timeval *timeout
-)
-{
-  int rv = 0;
-  int eno = 0;
-  rtems_ftpfs_reply reply = RTEMS_FTPFS_REPLY_ERROR;
-  struct in_addr address = { .s_addr = 0 };
-  struct sockaddr_in sa;
-  socklen_t size = 0;
-
-  /* Create the socket for the control connection */
-  e->ctrl_socket = socket(AF_INET, SOCK_STREAM, 0);
-  if (e->ctrl_socket < 0) {
-    return ENOMEM;
-  }
-
-  /* Set up the server address from the hostname */
-  if (inet_aton(hostname, &address) == 0) {
-    /* Try to get the address by name */
-    struct hostent *he = gethostbyname(hostname);
-
-    if (he != NULL) {
-      memcpy(&address, he->h_addr, sizeof(address));
-    } else {
-      return ENOENT;
-    }
-  }
-  rtems_ftpfs_create_address(&sa, address.s_addr, htons(RTEMS_FTPFS_CTRL_PORT));
-  DEBUG_PRINTF("server = %s\n", inet_ntoa(sa.sin_addr));
-
-  /* Open control connection */
-  rv = connect(
-    e->ctrl_socket,
-    (struct sockaddr *) &sa,
-    sizeof(sa)
-  );
-  if (rv != 0) {
-    return ENOENT;
-  }
-
-  /* Set control connection timeout */
-  eno = rtems_ftpfs_set_connection_timeout(e->ctrl_socket, timeout);
-  if (eno != 0) {
-    return eno;
-  }
-
-  /* Get client address */
-  size = rtems_ftpfs_create_address(&sa, INADDR_ANY, 0);
-  rv = getsockname(
-    e->ctrl_socket,
-    (struct sockaddr *) &sa,
-    &size
-  );
-  if (rv != 0) {
-    return ENOMEM;
-  }
-  *client_address = ntohl(sa.sin_addr.s_addr);
-  DEBUG_PRINTF("client = %s\n", inet_ntoa(sa.sin_addr));
-
-  /* Now we should get a welcome message from the server */
-  reply = rtems_ftpfs_get_reply(e, NULL, NULL, verbose);
-  if (reply != RTEMS_FTPFS_REPLY_2) {
-    return ENOENT;
-  }
-
-  /* Send USER command */
-  reply = rtems_ftpfs_send_command(e, "USER ", user, verbose);
-  if (reply == RTEMS_FTPFS_REPLY_3) {
-    /* Send PASS command */
-    reply = rtems_ftpfs_send_command(e, "PASS ", password, verbose);
-    if (reply != RTEMS_FTPFS_REPLY_2) {
-      return EACCES;
-    }
-
-    /* TODO: Some server may require an account */
-  } else if (reply != RTEMS_FTPFS_REPLY_2) {
-    return EACCES;
-  }
-
-  /* Send TYPE command to set binary mode for all data transfers */
-  reply = rtems_ftpfs_send_command(e, "TYPE I", NULL, verbose);
-  if (reply != RTEMS_FTPFS_REPLY_2) {
-    return EIO;
-  }
-
-  return 0;
-}
-
-static int rtems_ftpfs_open_data_connection_active(
-  rtems_ftpfs_entry *e,
-  uint32_t client_address,
-  const char *file_command,
-  const char *filename,
-  bool verbose,
-  const struct timeval *timeout
-)
-{
-  int rv = 0;
-  int eno = 0;
-  rtems_ftpfs_reply reply = RTEMS_FTPFS_REPLY_ERROR;
-  struct sockaddr_in sa;
-  socklen_t size = 0;
-  int port_socket = -1;
-  char port_command [] = "PORT 000,000,000,000,000,000";
-  uint16_t data_port = 0;
-
-  /* Create port socket to establish a data data connection */
-  port_socket = socket(AF_INET, SOCK_STREAM, 0);
-  if (port_socket < 0) {
-    eno = ENOMEM;
-    goto cleanup;
-  }
-
-  /* Bind port socket */
-  rtems_ftpfs_create_address(&sa, INADDR_ANY, 0);
-  rv = bind(
-    port_socket,
-    (struct sockaddr *) &sa,
-    sizeof(sa)
-  );
-  if (rv != 0) {
-    eno = EBUSY;
-    goto cleanup;
-  }
-
-  /* Get port number for data socket */
-  size = rtems_ftpfs_create_address(&sa, INADDR_ANY, 0);
-  rv = getsockname(
-    port_socket,
-    (struct sockaddr *) &sa,
-    &size
-  );
-  if (rv != 0) {
-    eno = ENOMEM;
-    goto cleanup;
-  }
-  data_port = ntohs(sa.sin_port);
-
-  /* Send PORT command to set data connection port for server */
-  snprintf(
-    port_command,
-    sizeof(port_command),
-    "PORT %lu,%lu,%lu,%lu,%lu,%lu",
-    (client_address >> 24) & 0xffUL,
-    (client_address >> 16) & 0xffUL,
-    (client_address >> 8) & 0xffUL,
-    (client_address >> 0) & 0xffUL,
-    (data_port >> 8) & 0xffUL,
-    (data_port >> 0) & 0xffUL
-  );
-  reply = rtems_ftpfs_send_command(e, port_command, NULL, verbose);
-  if (reply != RTEMS_FTPFS_REPLY_2) {
-    eno = ENOTSUP;
-    goto cleanup;
-  }
-
-  /* Listen on port socket for incoming data connections */
-  rv = listen(port_socket, 1);
-  if (rv != 0) {
-    eno = EBUSY;
-    goto cleanup;
-  }
-
-  /* Send RETR or STOR command with filename */
-  reply = rtems_ftpfs_send_command(e, file_command, filename, verbose);
-  if (reply != RTEMS_FTPFS_REPLY_1) {
-    eno = EIO;
-    goto cleanup;
-  }
-
-  /* Wait for connect on data connection if necessary */
-  if (rtems_ftpfs_use_timeout(timeout)) {
-    struct timeval to = *timeout;
-    fd_set fds;
-
-    FD_ZERO(&fds);
-    FD_SET(port_socket, &fds);
-
-    rv = select(port_socket + 1, &fds, NULL, NULL, &to);
-    if (rv <= 0) {
-      eno = EIO;
-      goto cleanup;
-    }
-  }
-
-  /* Accept data connection  */
-  size = sizeof(sa);
-  e->data_socket = accept(
-    port_socket,
-    (struct sockaddr *) &sa,
-    &size
-  );
-  if (e->data_socket < 0) {
-    eno = EIO;
-    goto cleanup;
-  }
-
-cleanup:
-
-  /* Close port socket if necessary */
-  if (port_socket >= 0) {
-    rv = close(port_socket);
-    if (rv != 0) {
-      eno = EIO;
-    }
-  }
-
-  return eno;
-}
-
-typedef enum {
-  RTEMS_FTPFS_PASV_START = 0,
-  RTEMS_FTPFS_PASV_JUNK,
-  RTEMS_FTPFS_PASV_DATA,
-  RTEMS_FTPFS_PASV_DONE
-} rtems_ftpfs_pasv_state;
-
-typedef struct {
-  rtems_ftpfs_pasv_state state;
-  uint8_t data [6];
-  size_t index;
-} rtems_ftpfs_pasv_entry;
-
-static void rtems_ftpfs_pasv_parser(
-  const char* buf,
-  size_t len,
-  void *arg
-)
-{
-  rtems_ftpfs_pasv_entry *e = arg;
-  size_t i = 0;
-
-  for (i = 0; i < len; ++i) {
-    int c = buf [i];
-
-    switch (e->state) {
-      case RTEMS_FTPFS_PASV_START:
-        if (!isdigit(c)) {
-          e->state = RTEMS_FTPFS_PASV_JUNK;
-          e->index = 0;
-        }
-        break;
-      case RTEMS_FTPFS_PASV_JUNK:
-        if (isdigit(c)) {
-          e->state = RTEMS_FTPFS_PASV_DATA;
-          e->data [e->index] = (uint8_t) (c - '0');
-        }
-        break;
-      case RTEMS_FTPFS_PASV_DATA:
-        if (isdigit(c)) {
-          e->data [e->index] = (uint8_t) (e->data [e->index] * 10 + c - '0');
-        } else if (c == ',') {
-          ++e->index;
-          if (e->index < sizeof(e->data)) {
-            e->data [e->index] = 0;
-          } else {
-            e->state = RTEMS_FTPFS_PASV_DONE;
-          }
-        } else {
-          e->state = RTEMS_FTPFS_PASV_DONE;
-        }
-        break;
-      default:
-        return;
-    }
-  }
-}
-
-static int rtems_ftpfs_open_data_connection_passive(
-  rtems_ftpfs_entry *e,
-  uint32_t client_address,
-  const char *file_command,
-  const char *filename,
-  bool verbose,
-  const struct timeval *timeout
-)
-{
-  int rv = 0;
-  rtems_ftpfs_reply reply = RTEMS_FTPFS_REPLY_ERROR;
-  struct sockaddr_in sa;
-  uint32_t data_address = 0;
-  uint16_t data_port = 0;
-
-  rtems_ftpfs_pasv_entry pe = {
-    .state = RTEMS_FTPFS_PASV_START
-  };
-
-  /* Send PASV command */
-  reply = rtems_ftpfs_send_command_with_parser(
-    e,
-    "PASV",
-    NULL,
-    rtems_ftpfs_pasv_parser,
-    &pe,
-    verbose
-  );
-  if (reply != RTEMS_FTPFS_REPLY_2) {
-    return ENOTSUP;
-  }
-  data_address = ((uint32_t)(pe.data [0]) << 24) + ((uint32_t)(pe.data [1]) << 16)
-    + ((uint32_t)(pe.data [2]) << 8) + ((uint32_t)(pe.data [3]));
-  data_port = (uint16_t) ((pe.data [4] << 8) + pe.data [5]);
-  rtems_ftpfs_create_address(&sa, htonl(data_address), htons(data_port));
-  DEBUG_PRINTF(
-    "server data = %s:%u\n",
-    inet_ntoa(sa.sin_addr),
-    (unsigned) ntohs(sa.sin_port)
-  );
-
-  /* Create data socket */
-  e->data_socket = socket(AF_INET, SOCK_STREAM, 0);
-  if (e->data_socket < 0) {
-    return ENOMEM;
-  }
-
-  /* Open data connection */
-  rv = connect(
-    e->data_socket,
-    (struct sockaddr *) &sa,
-    sizeof(sa)
-  );
-  if (rv != 0) {
-    return EIO;
-  }
-
-  /* Send RETR or STOR command with filename */
-  reply = rtems_ftpfs_send_command(e, file_command, filename, verbose);
-  if (reply != RTEMS_FTPFS_REPLY_1) {
-    return EIO;
-  }
-
-  return 0;
-}
-
-static int rtems_ftpfs_open(
-  rtems_libio_t *iop,
-  const char *path,
-  int oflag,
-  mode_t mode
-)
-{
-  int eno = 0;
-  bool ok = false;
-  rtems_ftpfs_entry *e = NULL;
-  rtems_ftpfs_mount_entry *me = iop->pathinfo.mt_entry->fs_info;
-  bool verbose = me->verbose;
-  const struct timeval *timeout = &me->timeout;
-  const char *user = NULL;
-  const char *password = NULL;
-  const char *hostname = NULL;
-  const char *filename = NULL;
-  const char *file_command = (iop->flags & LIBIO_FLAGS_WRITE) != 0
-    ? "STOR "
-    : "RETR ";
-  uint32_t client_address = 0;
-  char *location = iop->pathinfo.node_access;
-
-  /* Invalidate data handle */
-  iop->data1 = NULL;
-
-  /* Split location into parts */
-  ok = rtems_ftpfs_split_names(
-      location,
-      &user,
-      &password,
-      &hostname,
-      &filename
-  );
-  if (!ok) {
-    rtems_set_errno_and_return_minus_one(ENOENT);
-  }
-  DEBUG_PRINTF(
-    "user = '%s', password = '%s', filename = '%s'\n",
-    user,
-    password,
-    filename
-  );
-
-  /* Check for either read-only or write-only flags */
-  if (
-    (iop->flags & LIBIO_FLAGS_WRITE) != 0
-      && (iop->flags & LIBIO_FLAGS_READ) != 0
-  ) {
-    rtems_set_errno_and_return_minus_one(ENOTSUP);
-  }
-
-  /* Allocate connection entry */
-  e = calloc(1, sizeof(*e));
-  if (e == NULL) {
-    rtems_set_errno_and_return_minus_one(ENOMEM);
-  }
-
-  /* Initialize connection entry */
-  e->ctrl_socket = -1;
-  e->data_socket = -1;
-
-  /* Save connection state */
-  iop->data1 = e;
-
-  /* Open control connection */
-  eno = rtems_ftpfs_open_ctrl_connection(
-    e,
-    user,
-    password,
-    hostname,
-    &client_address,
-    verbose,
-    timeout
-  );
-  if (eno != 0) {
-    goto cleanup;
-  }
-
-  /* Open passive data connection */
-  eno = rtems_ftpfs_open_data_connection_passive(
-    e,
-    client_address,
-    file_command,
-    filename,
-    verbose,
-    timeout
-  );
-  if (eno == ENOTSUP) {
-    /* Open active data connection */
-    eno = rtems_ftpfs_open_data_connection_active(
-      e,
-      client_address,
-      file_command,
-      filename,
-      verbose,
-      timeout
-    );
-  }
-  if (eno != 0) {
-    goto cleanup;
-  }
-
-  /* Set data connection timeout */
-  eno = rtems_ftpfs_set_connection_timeout(e->data_socket, timeout);
-
-cleanup:
-
-  if (eno == 0) {
-    return 0;
-  } else {
-    /* Free all resources if an error occured */
-    rtems_ftpfs_terminate(iop, true);
-
-    rtems_set_errno_and_return_minus_one(eno);
-  }
-}
-
-static ssize_t rtems_ftpfs_read(
-  rtems_libio_t *iop,
-  void *buffer,
-  size_t count
-)
-{
-  rtems_ftpfs_entry *e = iop->data1;
-  rtems_ftpfs_mount_entry *me = iop->pathinfo.mt_entry->fs_info;
-  bool verbose = me->verbose;
-  char *in = buffer;
-  size_t todo = count;
-
-  if (e->eof) {
-    return 0;
-  }
-
-  while (todo > 0) {
-    ssize_t rv = recv(e->data_socket, in, todo, 0);
-
-    if (rv <= 0) {
-      if (rv == 0) {
-        rtems_ftpfs_reply reply =
-          rtems_ftpfs_get_reply(e, NULL, NULL, verbose);
-
-        if (reply == RTEMS_FTPFS_REPLY_2) {
-          e->eof = true;
-          break;
-        }
-      }
-
-      rtems_set_errno_and_return_minus_one(EIO);
-    }
-
-    in += rv;
-    todo -= (size_t) rv;
-  }
-
-  return (ssize_t) (count - todo);
-}
-
-static ssize_t rtems_ftpfs_write(
-  rtems_libio_t *iop,
-  const void *buffer,
-  size_t count
-)
-{
-  rtems_ftpfs_entry *e = iop->data1;
-  const char *out = buffer;
-  size_t todo = count;
-
-  while (todo > 0) {
-    ssize_t rv = send(e->data_socket, out, todo, 0);
-
-    if (rv <= 0) {
-      if (rv == 0) {
-        break;
-      } else {
-        rtems_set_errno_and_return_minus_one(EIO);
-      }
-    }
-
-    out += rv;
-    todo -= (size_t) rv;
-  }
-
-  return (ssize_t) (count - todo);
-}
-
-static int rtems_ftpfs_close(rtems_libio_t *iop)
-{
-  int eno = rtems_ftpfs_terminate(iop, false);
-
-  if (eno == 0) {
-    return 0;
-  } else {
-    rtems_set_errno_and_return_minus_one(eno);
-  }
-}
-
-/* Dummy version to let fopen(*,"w") work properly */
-static int rtems_ftpfs_ftruncate(rtems_libio_t *iop, off_t count)
-{
-  return 0;
-}
-
-static void rtems_ftpfs_eval_path(
-  rtems_filesystem_eval_path_context_t *self
-)
-{
-  rtems_filesystem_eval_path_eat_delimiter(self);
-
-  if (rtems_filesystem_eval_path_has_path(self)) {
-    const char *path = rtems_filesystem_eval_path_get_path(self);
-    size_t pathlen = rtems_filesystem_eval_path_get_pathlen(self);
-    char *pathdup = malloc(pathlen + 1);
-
-    rtems_filesystem_eval_path_clear_path(self);
-
-    if (pathdup != NULL) {
-      rtems_filesystem_location_info_t *currentloc =
-        rtems_filesystem_eval_path_get_currentloc(self);
-
-      memcpy(pathdup, path, pathlen);
-      pathdup [pathlen] = '\0';
-      currentloc->node_access = pathdup;
-      currentloc->handlers = &rtems_ftpfs_handlers;
-    } else {
-      rtems_filesystem_eval_path_error(self, ENOMEM);
-    }
-  }
-}
-
-static void rtems_ftpfs_free_node(const rtems_filesystem_location_info_t *loc)
-{
-  free(loc->node_access);
-}
-
-static rtems_filesystem_node_types_t rtems_ftpfs_node_type(
-  const rtems_filesystem_location_info_t *loc
-)
-{
-  return RTEMS_FILESYSTEM_MEMORY_FILE;
-}
-
-int rtems_ftpfs_initialize(
-  rtems_filesystem_mount_table_entry_t *e,
-  const void                           *d
-)
-{
-  rtems_ftpfs_mount_entry *me = malloc(sizeof(rtems_ftpfs_mount_entry));
-
-  /* Mount entry for FTP file system instance */
-  e->fs_info = me;
-  if (e->fs_info == NULL) {
-    rtems_set_errno_and_return_minus_one(ENOMEM);
-  }
-  me->verbose = false;
-  me->timeout.tv_sec = 0;
-  me->timeout.tv_usec = 0;
-
-  /* Set handler and oparations table */
-  e->mt_fs_root->location.handlers = &rtems_ftpfs_root_handlers;
-  e->ops = &rtems_ftpfs_ops;
-
-  /* We maintain no real file system nodes, so there is no real root */
-  e->mt_fs_root->location.node_access = NULL;
-
-  return 0;
-}
-
-static void rtems_ftpfs_unmount_me(
-  rtems_filesystem_mount_table_entry_t *e
-)
-{
-  free(e->fs_info);
-}
-
-static int rtems_ftpfs_ioctl(
-  rtems_libio_t *iop,
-  uint32_t command,
-  void *arg
-)
-{
-  rtems_ftpfs_mount_entry *me = iop->pathinfo.mt_entry->fs_info;
-  bool *verbose = arg;
-  struct timeval *timeout = arg;
-
-  if (arg == NULL) {
-    rtems_set_errno_and_return_minus_one(EINVAL);
-  }
-
-  switch (command) {
-    case RTEMS_FTPFS_IOCTL_GET_VERBOSE:
-      *verbose = me->verbose;
-      break;
-    case RTEMS_FTPFS_IOCTL_SET_VERBOSE:
-      me->verbose = *verbose;
-      break;
-    case RTEMS_FTPFS_IOCTL_GET_TIMEOUT:
-      *timeout = me->timeout;
-      break;
-    case RTEMS_FTPFS_IOCTL_SET_TIMEOUT:
-      me->timeout = *timeout;
-      break;
-    default:
-      rtems_set_errno_and_return_minus_one(EINVAL);
-  }
-
-  return 0;
-}
-
-/*
- * The stat() support is intended only for the cp shell command.  Each request
- * will return that we have a regular file with read, write and execute
- * permissions for every one.  The node index uses a global counter to support
- * a remote to remote copy.  This is not a very sophisticated method.
- */
-static int rtems_ftpfs_fstat(
-  const rtems_filesystem_location_info_t *loc,
-  struct stat *st
-)
-{
-  static unsigned ino = 0;
-
-  /* FIXME */
-  st->st_ino = ++ino;
-  st->st_dev = rtems_filesystem_make_dev_t(0xcc494cd6U, 0x1d970b4dU);
-
-  st->st_mode = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;
-
-  return 0;
-}
-
-static const rtems_filesystem_operations_table rtems_ftpfs_ops = {
-  .lock_h = rtems_filesystem_default_lock,
-  .unlock_h = rtems_filesystem_default_unlock,
-  .eval_path_h = rtems_ftpfs_eval_path,
-  .link_h = rtems_filesystem_default_link,
-  .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal,
-  .node_type_h = rtems_ftpfs_node_type,
-  .mknod_h = rtems_filesystem_default_mknod,
-  .rmnod_h = rtems_filesystem_default_rmnod,
-  .fchmod_h = rtems_filesystem_default_fchmod,
-  .chown_h = rtems_filesystem_default_chown,
-  .clonenod_h = rtems_filesystem_default_clonenode,
-  .freenod_h = rtems_ftpfs_free_node,
-  .mount_h = rtems_filesystem_default_mount,
-  .fsmount_me_h = rtems_ftpfs_initialize,
-  .unmount_h = rtems_filesystem_default_unmount,
-  .fsunmount_me_h = rtems_ftpfs_unmount_me,
-  .utime_h = rtems_filesystem_default_utime,
-  .symlink_h = rtems_filesystem_default_symlink,
-  .readlink_h = rtems_filesystem_default_readlink,
-  .rename_h = rtems_filesystem_default_rename,
-  .statvfs_h = rtems_filesystem_default_statvfs
-};
-
-static const rtems_filesystem_file_handlers_r rtems_ftpfs_handlers = {
-  .open_h = rtems_ftpfs_open,
-  .close_h = rtems_ftpfs_close,
-  .read_h = rtems_ftpfs_read,
-  .write_h = rtems_ftpfs_write,
-  .ioctl_h = rtems_filesystem_default_ioctl,
-  .lseek_h = rtems_filesystem_default_lseek,
-  .fstat_h = rtems_ftpfs_fstat,
-  .ftruncate_h = rtems_ftpfs_ftruncate,
-  .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
-  .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-  .fcntl_h = rtems_filesystem_default_fcntl
-};
-
-static const rtems_filesystem_file_handlers_r rtems_ftpfs_root_handlers = {
-  .open_h = rtems_filesystem_default_open,
-  .close_h = rtems_filesystem_default_close,
-  .read_h = rtems_filesystem_default_read,
-  .write_h = rtems_filesystem_default_write,
-  .ioctl_h = rtems_ftpfs_ioctl,
-  .lseek_h = rtems_filesystem_default_lseek,
-  .fstat_h = rtems_filesystem_default_fstat,
-  .ftruncate_h = rtems_filesystem_default_ftruncate,
-  .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
-  .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-  .fcntl_h = rtems_filesystem_default_fcntl
-};
Index: rvices/ftpfs/include/rtems/ftpfs.h
===================================================================
--- services/ftpfs/include/rtems/ftpfs.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,160 +1,0 @@
-/**
- * @file
- *
- * @brief File Transfer Protocol file system (FTP client).
- */
-
-/*
- * Copyright (c) 2009
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * (c) Copyright 2002
- * Thomas Doerfler
- * IMD Ingenieurbuero fuer Microcomputertechnik
- * Herbststr. 8
- * 82178 Puchheim, Germany
- * <Thomas.Doerfler@imd-systems.de>
- *
- * Modified by Sebastian Huber <sebastian.huber@embedded-brains.de>.
- *
- * This code has been created after closly inspecting "tftpdriver.c" from Eric
- * Norum.
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifndef _RTEMS_FTPFS_H
-#define _RTEMS_FTPFS_H
-
-#include <sys/time.h>
-#include <sys/ioctl.h>
-
-#include <rtems/libio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup rtems_ftpfs File Transfer Protocol File System
- *
- * @brief The FTP file system (FTP client) can be used to transfer files from
- * or to remote hosts.
- *
- * You can mount the FTP file system with a call to mount() or
- * mount_and_make_target_path() with the @ref RTEMS_FILESYSTEM_TYPE_FTPFS file
- * system type.
- *
- * You have to add @ref CONFIGURE_FILESYSTEM_FTPFS to your application
- * configuration.
- *
- * You can open files either read-only or write-only.  A seek is not allowed.
- * A close terminates the control and data connections.
- *
- * To open a file @c file.txt in the directory @c dir (relative to home
- * directory of the server) on a server named @c host using the user name
- * @c user and the password @c pw you must specify the following path:
- * <tt>/FTP/user:pw@@host/dir/file.txt</tt>.
- *
- * If the server is the default server specified in BOOTP, it can be ommitted:
- * <tt>/FTP/user:pw/dir/file.txt</tt>.
- *
- * The user name will be used for the password if it is ommitted:
- * <tt>/FTP/user@@host/dir/file.txt</tt>.
- *
- * For the data transfer passive (= default) and active (= fallback) mode are
- * supported.
- *
- * @{
- */
-
-/**
- * @brief Well-known port number for FTP control connection.
- */
-#define RTEMS_FTPFS_CTRL_PORT 21
-
-/**
- * @brief Default mount point for FTP file system.
- */
-#define RTEMS_FTPFS_MOUNT_POINT_DEFAULT "/FTP"
-
-/**
- * @brief FTP file system IO control requests.
- */
-typedef enum {
-  RTEMS_FTPFS_IOCTL_GET_VERBOSE = _IOR( 'd', 1, bool *),
-  RTEMS_FTPFS_IOCTL_SET_VERBOSE = _IOW( 'd', 1, bool *),
-  RTEMS_FTPFS_IOCTL_GET_TIMEOUT = _IOR( 'd', 2, struct timeval *),
-  RTEMS_FTPFS_IOCTL_SET_TIMEOUT = _IOW( 'd', 2, struct timeval *)
-} rtems_ftpfs_ioctl_numbers;
-
-/**
- * @brief Returns in @a verbose if the verbose mode is enabled or disabled for
- * the file system at @a mount_point.
- *
- * If @a mount_point is @c NULL the default mount point
- * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used.
- */
-rtems_status_code rtems_ftpfs_get_verbose( const char *mount_point, bool *verbose);
-
-/**
- * @brief Enables or disables the verbose mode if @a verbose is @c true or
- * @c false respectively for the file system at @a mount_point.
- *
- * In the enabled verbose mode the commands and replies of the FTP control
- * connections will be printed to standard error.
- *
- * If @a mount_point is @c NULL the default mount point
- * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used.
- */
-rtems_status_code rtems_ftpfs_set_verbose( const char *mount_point, bool verbose);
-
-/**
- * @brief Returns the current timeout value in @a timeout for the file system
- * at @a mount_point.
- *
- * If @a mount_point is @c NULL the default mount point
- * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used.
- */
-rtems_status_code rtems_ftpfs_get_timeout(
-  const char *mount_point,
-  struct timeval *timeout
-);
-
-/**
- * @brief Sets the timeout value to @a timeout for the file system at
- * @a mount_point.
- *
- * The timeout value will be used during connection establishment of active
- * data connections.  It will be also used for send and receive operations on
- * data and control connections.
- *
- * If @a mount_point is @c NULL the default mount point
- * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used.
- */
-rtems_status_code rtems_ftpfs_set_timeout(
-  const char *mount_point,
-  const struct timeval *timeout
-);
-
-/** @} */
-
-/**
- * @brief Do not call directly, use mount().
- */
-int rtems_ftpfs_initialize(
-  rtems_filesystem_mount_table_entry_t *mt_entry,
-  const void *data
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
Index: rvices/librpc/Makefile
===================================================================
--- services/librpc/Makefile	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,87 +1,0 @@
-include ../../config.inc
-
-include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
-include $(RTEMS_CUSTOM)
-include $(PROJECT_ROOT)/make/leaf.cfg
-
-CFLAGS += -I $(INSTALL_BASE)/include
-
-CFLAGS += -w 
-CFLAGS += -I include 
-CFLAGS += -std=gnu99
-CFLAGS += -D_RTEMS_RPC_INTERNAL_
-CFLAGS += -MT $@ -MD -MP -MF $(basename $@).d
-
-C_FILES =
-# RPC Files
-C_FILES += src/rpc/auth_none.c
-C_FILES += src/rpc/auth_unix.c
-C_FILES += src/rpc/authunix_prot.c
-C_FILES += src/rpc/bindresvport.c
-C_FILES += src/rpc/clnt_generic.c
-C_FILES += src/rpc/clnt_perror.c
-C_FILES += src/rpc/clnt_raw.c
-C_FILES += src/rpc/clnt_simple.c
-C_FILES += src/rpc/clnt_tcp.c
-C_FILES += src/rpc/clnt_udp.c
-C_FILES += src/rpc/get_myaddress.c
-C_FILES += src/rpc/getrpcent.c
-C_FILES += src/rpc/getrpcport.c
-C_FILES += src/rpc/netname.c
-C_FILES += src/rpc/netnamer.c
-C_FILES += src/rpc/pmap_clnt.c
-C_FILES += src/rpc/pmap_getmaps.c
-C_FILES += src/rpc/pmap_getport.c
-C_FILES += src/rpc/pmap_prot2.c
-C_FILES += src/rpc/pmap_prot.c
-C_FILES += src/rpc/pmap_rmt.c
-C_FILES += src/rpc/rpc_callmsg.c
-C_FILES += src/rpc/rpc_commondata.c
-C_FILES += src/rpc/rpcdname.c
-C_FILES += src/rpc/rpc_dtablesize.c
-C_FILES += src/rpc/rpc_prot.c
-C_FILES += src/rpc/rtems_portmapper.c
-C_FILES += src/rpc/rtems_rpc.c
-C_FILES += src/rpc/rtime.c
-C_FILES += src/rpc/svc_auth.c
-C_FILES += src/rpc/svc_auth_unix.c
-C_FILES += src/rpc/svc.c
-C_FILES += src/rpc/svc_raw.c
-C_FILES += src/rpc/svc_run.c
-C_FILES += src/rpc/svc_simple.c
-C_FILES += src/rpc/svc_tcp.c
-C_FILES += src/rpc/svc_udp.c
-# XDR Files
-C_FILES += src/xdr/xdr_array.c
-C_FILES += src/xdr/xdr.c
-C_FILES += src/xdr/xdr_float.c
-C_FILES += src/xdr/xdr_mem.c
-C_FILES += src/xdr/xdr_rec.c
-C_FILES += src/xdr/xdr_reference.c
-C_FILES += src/xdr/xdr_sizeof.c
-C_FILES += src/xdr/xdr_stdio.c
-
-C_O_FILES = $(C_FILES:%.c=%.o)
-C_D_FILES = $(C_FILES:%.c=%.d)
-
-LIB = libxdr.a
-
-all: $(LIB)
-
-$(LIB): $(C_O_FILES)
-	$(AR) rcu $@ $^
-
-install: $(LIB)
-	install -d $(INSTALL_BASE)/include/rpc
-	install -d $(INSTALL_BASE)/include/xdr
-	cd include; for i in `find . -name '*.h'` ; do \
-	  install -c -m 644 -D "$$i" "$(INSTALL_BASE)/include/$$i" ; done
-	install -c -m 644 $(LIB) $(INSTALL_BASE)
-
-clean:
-	rm -f $(LIB) $(C_O_FILES) $(C_D_FILES) $(GEN_FILES)
-
--include $(C_D_FILES)
-
-doc: 
-
Index: rvices/librpc/README_RTEMS
===================================================================
--- services/librpc/README_RTEMS	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,64 +1,0 @@
-USING RPC/XDR ON RTEMS
-======================
-For the most part, programmers using RPC/XDR routines on RTEMS
-can proceed as if they were to be using a POSIX/UNIX system.
-The only significant changes are those to start the portmapper
-and to allow use of RPC/XDR by multiple threads.
-
-Starting the portmapper
-=======================
-The SUN portmapper program has been modified to run as an RTEMS
-task.  Applications which need the portmapper can start this
-task by calling:
-	int rtems_rpc_start_portmapper (int priority);
-The return value is an RTEMS status code.
-
-Multi-threaded operation
-========================
-The RPC/XDR package has been modified to allow for multiple RTEMS
-tasks to use RPC/XDR routines.  If more than one task is to call
-an RPC/XDR routine, the additional tasks must call:
-	int rtems_rpc_task_init(void);
-before calling any RPC/XDR routines.  For example, the portmapper
-calls this routine since the portmapper uses RPC/XDR routines in
-a separate thread.
-The return value is an RTEMS status code.
-
-
-Porting Notes
-=============
-Most of the FreeBSD rpc library ports to RTEMS with little
-or no modification beyond that required to provide for operation
-in a multitasking environment.  Multitasking operation was
-provided by moving all `static persistence' variables into
-a single structure and using an RTEMS task variable to point
-to that structure.  
-
-Some of the library, however, has not made it into the RTEMS
-implementation.  FreeBSD source files which have been left out include:
-- Files which provide RPC to the AF_UNIX address family:
-	clnt_unix.c
-	svc_unix.c
-  An `ifndef __rtems__' was added to clnt_generic.c because clnt_unix.c
-  was omitted.
-- Files which need NIS:
-	auth_time.c
-- Files which provide DES authentication:
-	auth_des.c
-	authdes_prot.c
-	crypt_client.c
-	des_crypt.c
-	des_soft.c
-	getpublickey.c
-	key_call.c
-	key_prot_xdr.c
-	svc_auth_des.c
-
-The FreeBSD xdr source compiles and runs on RTEMS without modification.
-
-The original source was obtained from:
-	ftp://ftp.FreeBSD.org/pub/FreeBSD/
-		        branches/4.0-stable/src/lib/libc/rpc
-			branches/4.0-stable/src/lib/libc/xdr
-			branches/4.0-stable/src/include/rpc
-			branches/4.0-stable/src/include/rpcsvc
Index: rvices/librpc/include/rpc/pmap_rmt.h
===================================================================
--- services/librpc/include/rpc/pmap_rmt.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- *
- *	from: @(#)pmap_rmt.h 1.2 88/02/08 SMI
- *	from: @(#)pmap_rmt.h	2.1 88/07/29 4.0 RPCSRC
- * $FreeBSD: src/include/rpc/pmap_rmt.h,v 1.10 1999/08/27 23:45:05 peter Exp $
- */
-
-/*
- * Structures and XDR routines for parameters to and replies from
- * the portmapper remote-call-service.
- *
- * Copyright (C) 1986, Sun Microsystems, Inc.
- */
-
-#ifndef _RPC_PMAPRMT_H
-#define _RPC_PMAPRMT_H
-#include <sys/cdefs.h>
-#include <rpc/xdr.h>
-
-struct rmtcallargs {
-	u_long prog, vers, proc, arglen;
-	caddr_t args_ptr;
-	xdrproc_t xdr_args;
-};
-
-struct rmtcallres {
-	u_long *port_ptr;
-	u_long resultslen;
-	caddr_t results_ptr;
-	xdrproc_t xdr_results;
-};
-
-__BEGIN_DECLS
-extern bool_t xdr_rmtcall_args	(XDR *, struct rmtcallargs *);
-extern bool_t xdr_rmtcallres	(XDR *, struct rmtcallres *);
-__END_DECLS
-
-#endif /* !_RPC_PMAPRMT_H */
Index: rvices/librpc/include/rpc/rpc_com.h
===================================================================
--- services/librpc/include/rpc/rpc_com.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*	$NetBSD: rpc_com.h,v 1.3 2000/12/10 04:10:08 christos Exp $	*/
-/*	$FreeBSD: src/include/rpc/rpc_com.h,v 1.6 2003/01/16 07:13:51 mbr Exp $ */
-
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
- */
- 
-/*
- * rpc_com.h, Common definitions for both the server and client side.
- * All for the topmost layer of rpc
- *
- */
-
-#ifndef _RPC_RPCCOM_H
-#define	_RPC_RPCCOM_H
-
-#include <sys/cdefs.h>
-
-/* #pragma ident	"@(#)rpc_com.h	1.11	93/07/05 SMI" */
-
-/*
- * The max size of the transport, if the size cannot be determined
- * by other means.
- */
-#define	RPC_MAXDATASIZE 9000
-#define	RPC_MAXADDRSIZE 1024
-
-__BEGIN_DECLS
-extern u_int __rpc_get_a_size(int);
-#ifndef __rtems__
-	/* XXX defined in old.. in new rpc.h as internal */
-	extern u_int __rpc_get_t_size(int, long);
-#endif
-extern int __rpc_dtbsize(void);
-extern int _rpc_dtablesize(void);
-extern  int  _rpc_get_default_domain(char **);
-__END_DECLS
-
-#endif /* _RPC_RPCCOM_H */
Index: rvices/librpc/include/rpcsvc/bootparam_prot.x
===================================================================
--- services/librpc/include/rpcsvc/bootparam_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,103 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * RPC for bootparms service.
- * There are two procedures:
- *   WHOAMI takes a net address and returns a client name and also a
- *	likely net address for routing
- *   GETFILE takes a client name and file identifier and returns the
- *	server name, server net address and pathname for the file.
- *   file identifiers typically include root, swap, pub and dump
- */
-
-#ifdef RPC_HDR
-%#include <rpc/types.h>
-%#include <sys/time.h>
-%#include <sys/errno.h>
-%#include <sys/param.h>
-%#include <sys/syslimits.h>
-%#include <sys/ucred.h>
-#else
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)bootparam_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/bootparam_prot.x,v 1.5 1999/08/27 23:45:07 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const MAX_MACHINE_NAME  = 255;
-const MAX_PATH_LEN	= 1024;
-const MAX_FILEID	= 32;
-const IP_ADDR_TYPE	= 1;
-
-typedef	string	bp_machine_name_t<MAX_MACHINE_NAME>;
-typedef	string	bp_path_t<MAX_PATH_LEN>;
-typedef	string	bp_fileid_t<MAX_FILEID>;
-
-struct	ip_addr_t {
-	char	net;
-	char	host;
-	char	lh;
-	char	impno;
-};
-
-union bp_address switch (int address_type) {
-	case IP_ADDR_TYPE:
-		ip_addr_t	ip_addr;
-};
-
-struct bp_whoami_arg {
-	bp_address		client_address;
-};
-
-struct bp_whoami_res {
-	bp_machine_name_t	client_name;
-	bp_machine_name_t	domain_name;
-	bp_address		router_address;
-};
-
-struct bp_getfile_arg {
-	bp_machine_name_t	client_name;
-	bp_fileid_t		file_id;
-};
-	
-struct bp_getfile_res {
-	bp_machine_name_t	server_name;
-	bp_address		server_address;
-	bp_path_t		server_path;
-};
-
-program BOOTPARAMPROG {
-	version BOOTPARAMVERS {
-		bp_whoami_res	BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1;
-		bp_getfile_res	BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2;
-	} = 1;
-} = 100026;
Index: rvices/librpc/include/rpcsvc/crypt.x
===================================================================
--- services/librpc/include/rpcsvc/crypt.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,91 +1,0 @@
-/*
- * Copyright (c) 1996
- *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/include/rpcsvc/crypt.x,v 1.3 1999/08/27 23:45:08 peter Exp $
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/crypt.x,v 1.3 1999/08/27 23:45:08 peter Exp $";
-%#endif
-#endif
-
-/*
- * This protocol definition exists because of the U.S. government and
- * its stupid export laws. We can't export DES code from the United
- * States to other countries (even though the code already exists
- * outside the U.S. -- go figure that one out) but we need to make
- * Secure RPC work. The normal way around this is to break the DES
- * code out into a shared library; we can then provide a dummy lib
- * in the base OS and provide the real lib in the secure dist, which
- * the user can install later. But we need Secure RPC for NIS+, and
- * there are several system programs that use NIS+ which are statically
- * linked. We would have to provide replacements for these programs
- * in the secure dist, but there are a lot, and this is a pain. The
- * shared lib trick won't work for these programs, and we can't change
- * them once they're compiled.
- *
- * One solution for this problem is to do the DES encryption as a system
- * call; no programs need to be changed and we can even supply the DES
- * support as an LKM. But this bloats the kernel. Maybe if we have
- * Secure NFS one day this will be worth it, but for now we should keep
- * this mess in user space.
- *
- * So we have this second solution: we provide a server that does the
- * DES encryption for us. In this case, the server is keyserv (we need
- * it to make Secure RPC work anyway) and we use this protocol to ship
- * the data back and forth between keyserv and the application.
- */
-
-enum des_dir { ENCRYPT_DES, DECRYPT_DES };
-enum des_mode { CBC_DES, ECB_DES };
-
-struct desargs {
-	u_char des_key[8];	/* key (with low bit parity) */
-	des_dir des_dir;	/* direction */
-	des_mode des_mode;	/* mode */
-	u_char des_ivec[8];	/* input vector */
-	opaque desbuf<>;
-};
-
-struct desresp {
-	opaque desbuf<>;
-	u_char des_ivec[8];
-	int stat;
-};
-
-program CRYPT_PROG {
-	version CRYPT_VERS {
-		desresp
-		DES_CRYPT(desargs) = 1;
-	} = 1;
-} = 600100029;
Index: rvices/librpc/include/rpcsvc/key_prot.x
===================================================================
--- services/librpc/include/rpcsvc/key_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,282 +1,0 @@
-%/*
-% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
-% * unrestricted use provided that this legend is included on all tape
-% * media and as a part of the software program in whole or part.  Users
-% * may copy or modify Sun RPC without charge, but are not authorized
-% * to license or distribute it to anyone else except as part of a product or
-% * program developed by the user.
-% *
-% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
-% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
-% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-% *
-% * Sun RPC is provided with no support and without any obligation on the
-% * part of Sun Microsystems, Inc. to assist in its use, correction,
-% * modification or enhancement.
-% *
-% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
-% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
-% * OR ANY PART THEREOF.
-% *
-% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
-% * or profits or other special, indirect and consequential damages, even if
-% * Sun has been advised of the possibility of such damages.
-% *
-% * Sun Microsystems, Inc.
-% * 2550 Garcia Avenue
-% * Mountain View, California  94043
-% */
-/*
- * Key server protocol definition
- * Copyright (C) 1990, 1991 Sun Microsystems, Inc.
- *
- * The keyserver is a public key storage/encryption/decryption service
- * The encryption method used is based on the Diffie-Hellman exponential
- * key exchange technology.
- *
- * The key server is local to each machine, akin to the portmapper.
- * Under TI-RPC, communication with the keyserver is through the
- * loopback transport.
- *
- * NOTE: This .x file generates the USER level headers for the keyserver.
- * the KERNEL level headers are created by hand as they kernel has special
- * requirements.
- */
-
-%/* From: #pragma ident	"@(#)key_prot.x	1.7	94/04/29 SMI" */
-%
-%/* Copyright (c)  1990, 1991 Sun Microsystems, Inc. */
-%
-%/* 
-% * Compiled from key_prot.x using rpcgen.
-% * DO NOT EDIT THIS FILE!
-% * This is NOT source code!
-% */
-
-/*
- * PROOT and MODULUS define the way the Diffie-Hellman key is generated.
- *
- * MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1,
- * where p is also prime.
- *
- * PROOT satisfies the following two conditions:
- * (1) (PROOT ** 2) % MODULUS != 1
- * (2) (PROOT ** p) % MODULUS != 1
- *
- */
-
-const PROOT = 3;
-const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b";
-
-const HEXKEYBYTES = 48;		/* HEXKEYBYTES == strlen(HEXMODULUS) */
-const KEYSIZE = 192;		/* KEYSIZE == bit length of key */
-const KEYBYTES = 24;		/* byte length of key */
-
-/*
- * The first 16 hex digits of the encrypted secret key are used as
- * a checksum in the database.
- */
-const KEYCHECKSUMSIZE = 16;
-
-/*
- * status of operation
- */
-enum keystatus {
-	KEY_SUCCESS,	/* no problems */
-	KEY_NOSECRET,	/* no secret key stored */
-	KEY_UNKNOWN,	/* unknown netname */
-	KEY_SYSTEMERR 	/* system error (out of memory, encryption failure) */
-};
-
-typedef opaque keybuf[HEXKEYBYTES];	/* store key in hex */
-
-typedef string netnamestr<MAXNETNAMELEN>;
-
-/*
- * Argument to ENCRYPT or DECRYPT 
- */
-struct cryptkeyarg {
-	netnamestr remotename;
-	des_block deskey;
-};
-
-/*
- * Argument to ENCRYPT_PK or DECRYPT_PK
- */
-struct cryptkeyarg2 {
-	netnamestr remotename;
-	netobj	remotekey;	/* Contains a length up to 1024 bytes */
-	des_block deskey;
-};
-
-
-/*
- * Result of ENCRYPT, DECRYPT, ENCRYPT_PK, and DECRYPT_PK
- */
-union cryptkeyres switch (keystatus status) {
-case KEY_SUCCESS:
-	des_block deskey;
-default:
-	void;
-};
-
-const MAXGIDS  = 16;	/* max number of gids in gid list */
-
-/*
- * Unix credential 
- */	
-struct unixcred {
-	u_int uid;
-	u_int gid;
-	u_int gids<MAXGIDS>;	
-};
-
-/*
- * Result returned from GETCRED
- */
-union getcredres switch (keystatus status) {
-case KEY_SUCCESS:
-	unixcred cred;
-default:
-	void;
-};
-/*
- * key_netstarg;
- */
-
-struct key_netstarg {
-	keybuf st_priv_key;
-	keybuf st_pub_key;
-	netnamestr st_netname;
-};
-
-union key_netstres switch (keystatus status){
-case KEY_SUCCESS:
-	key_netstarg knet;
-default:
-	void;
-};	
-
-#ifdef RPC_HDR
-%
-%#ifndef opaque
-%#define opaque char
-%#endif
-%
-#endif
-program KEY_PROG {
-	version KEY_VERS {
-
-		/*
-		 * This is my secret key.
-	 	 * Store it for me.
-		 */
-		keystatus 
-		KEY_SET(keybuf) = 1;	
-	
-		/*
-		 * I want to talk to X.
-		 * Encrypt a conversation key for me.
-	 	 */
-		cryptkeyres
-		KEY_ENCRYPT(cryptkeyarg) = 2;	
-
-		/*
-		 * X just sent me a message.
-		 * Decrypt the conversation key for me.
-		 */
-		cryptkeyres
-		KEY_DECRYPT(cryptkeyarg) = 3;
-
-		/*
-		 * Generate a secure conversation key for me
-		 */
-		des_block 
-		KEY_GEN(void) = 4;
-
-		/*
-		 * Get me the uid, gid and group-access-list associated
-		 * with this netname (for kernel which cannot use NIS)
-		 */
-		getcredres
-		KEY_GETCRED(netnamestr) = 5;
-	} = 1;
-	version KEY_VERS2 {
-
-		/*
-		 * #######
-		 * Procedures 1-5 are identical to version 1
-		 * #######
-		 */
-
-		/*
-		 * This is my secret key.
-	 	 * Store it for me.
-		 */
-		keystatus 
-		KEY_SET(keybuf) = 1;	
-	
-		/*
-		 * I want to talk to X.
-		 * Encrypt a conversation key for me.
-	 	 */
-		cryptkeyres
-		KEY_ENCRYPT(cryptkeyarg) = 2;	
-
-		/*
-		 * X just sent me a message.
-		 * Decrypt the conversation key for me.
-		 */
-		cryptkeyres
-		KEY_DECRYPT(cryptkeyarg) = 3;
-
-		/*
-		 * Generate a secure conversation key for me
-		 */
-		des_block 
-		KEY_GEN(void) = 4;
-
-		/*
-		 * Get me the uid, gid and group-access-list associated
-		 * with this netname (for kernel which cannot use NIS)
-		 */
-		getcredres
-		KEY_GETCRED(netnamestr) = 5;
-		
-		/*
-		 * I want to talk to X. and I know X's public key
-		 * Encrypt a conversation key for me.
-	 	 */
-		cryptkeyres
-		KEY_ENCRYPT_PK(cryptkeyarg2) = 6;	
-
-		/*
-		 * X just sent me a message. and I know X's public key
-		 * Decrypt the conversation key for me.
-		 */
-		cryptkeyres
-		KEY_DECRYPT_PK(cryptkeyarg2) = 7;
-		
-		/* 
-		 * Store my public key, netname and private key. 
-		 */
-		keystatus
-		KEY_NET_PUT(key_netstarg) = 8;
-		
-		/*
-		 * Retrieve my public key, netname and private key. 
-		 */
- 		key_netstres
-		KEY_NET_GET(void) = 9;
-		
-		/*
-		 * Return me the conversation key that is constructed 
-		 * from my secret key and this publickey. 
-		 */
-
-		cryptkeyres 
-		KEY_GET_CONV(keybuf) = 10; 
-
-		
-	} = 2;
-} = 100029;
Index: rvices/librpc/include/rpcsvc/klm_prot.x
===================================================================
--- services/librpc/include/rpcsvc/klm_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,139 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Kernel/lock manager protocol definition
- * Copyright (C) 1986 Sun Microsystems, Inc.
- *
- * protocol used between the UNIX kernel (the "client") and the
- * local lock manager.  The local lock manager is a deamon running
- * above the kernel.
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)klm_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/klm_prot.x,v 1.6 1999/08/27 23:45:08 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const	LM_MAXSTRLEN = 1024;
-
-/*
- * lock manager status returns
- */
-enum klm_stats {
-	klm_granted = 0,	/* lock is granted */
-	klm_denied = 1,		/* lock is denied */
-	klm_denied_nolocks = 2, /* no lock entry available */
-	klm_working = 3 	/* lock is being processed */
-};
-
-/*
- * lock manager lock identifier
- */
-struct klm_lock {
-	string server_name<LM_MAXSTRLEN>;
-	netobj fh;		/* a counted file handle */
-	int pid;		/* holder of the lock */
-	unsigned l_offset;	/* beginning offset of the lock */
-	unsigned l_len;		/* byte length of the lock;
-				 * zero means through end of file */
-};
-
-/*
- * lock holder identifier
- */
-struct klm_holder {
-	bool exclusive;		/* FALSE if shared lock */
-	int svid;		/* holder of the lock (pid) */
-	unsigned l_offset;	/* beginning offset of the lock */
-	unsigned l_len;		/* byte length of the lock;
-				 * zero means through end of file */
-};
-
-/*
- * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL
- */
-struct klm_stat {
-	klm_stats stat;
-};
-
-/*
- * reply to a KLM_TEST call
- */
-union klm_testrply switch (klm_stats stat) {
-	case klm_denied:
-		struct klm_holder holder;
-	default: /* All other cases return no arguments */
-		void;
-};
-
-
-/*
- * arguments to KLM_LOCK
- */
-struct klm_lockargs {
-	bool block;
-	bool exclusive;
-	struct klm_lock alock;
-};
-
-/*
- * arguments to KLM_TEST
- */
-struct klm_testargs {
-	bool exclusive;
-	struct klm_lock alock;
-};
-
-/*
- * arguments to KLM_UNLOCK
- */
-struct klm_unlockargs {
-	struct klm_lock alock;
-};
-
-program KLM_PROG {
-	version KLM_VERS {
-
-		klm_testrply	KLM_TEST (struct klm_testargs) =	1;
-
-		klm_stat	KLM_LOCK (struct klm_lockargs) =	2;
-
-		klm_stat	KLM_CANCEL (struct klm_lockargs) =	3;
-		/* klm_granted=> the cancel request fails due to lock is already granted */
-		/* klm_denied=> the cancel request successfully aborts
-lock request  */
-
-		klm_stat	KLM_UNLOCK (struct klm_unlockargs) =	4;
-	} = 1;
-} = 100020;
Index: rvices/librpc/include/rpcsvc/mount.x
===================================================================
--- services/librpc/include/rpcsvc/mount.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,257 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Protocol description for the mount program
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)mount.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/mount.x,v 1.6 1999/08/27 23:45:08 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const MNTPATHLEN = 1024;	/* maximum bytes in a pathname argument */
-const MNTNAMLEN = 255;		/* maximum bytes in a name argument */
-const FHSIZE = 32;		/* size in bytes of a file handle */
-#ifdef WANT_NFS3
-const FHSIZE3 = 64;		/* size in bytes of a file handle (v3) */
-#endif
-
-/*
- * The fhandle is the file handle that the server passes to the client.
- * All file operations are done using the file handles to refer to a file
- * or a directory. The file handle can contain whatever information the
- * server needs to distinguish an individual file.
- */
-typedef opaque fhandle[FHSIZE];	
-#ifdef WANT_NFS3
-typedef opaque fhandle3<FHSIZE3>;
-#endif
-
-/*
- * If a status of zero is returned, the call completed successfully, and 
- * a file handle for the directory follows. A non-zero status indicates
- * some sort of error. The status corresponds with UNIX error numbers.
- */
-union fhstatus switch (unsigned fhs_status) {
-case 0:
-	fhandle fhs_fhandle;
-default:
-	void;
-};
-
-#ifdef WANT_NFS3
-/*
- * Status codes returned by the version 3 mount call.
- */
-enum mountstat3 {
-	MNT3_OK = 0,                 /* no error */
-	MNT3ERR_PERM = 1,            /* Not owner */
-	MNT3ERR_NOENT = 2,           /* No such file or directory */
-	MNT3ERR_IO = 5,              /* I/O error */
-	MNT3ERR_ACCES = 13,          /* Permission denied */
-	MNT3ERR_NOTDIR = 20,         /* Not a directory */
-	MNT3ERR_INVAL = 22,          /* Invalid argument */
-	MNT3ERR_NAMETOOLONG = 63,    /* Filename too long */
-	MNT3ERR_NOTSUPP = 10004,     /* Operation not supported */
-	MNT3ERR_SERVERFAULT = 10006  /* A failure on the server */
-};
-
-struct mountres3_ok {
-	fhandle3	fhandle;
-	int		auth_flavors<>;
-};
-
-union mountres3 switch (mountstat3 fhs_status) {
-case 0:
-	mountres3_ok	mountinfo;
-default:
-	void;
-};
-#endif
-
-/*
- * The type dirpath is the pathname of a directory
- */
-typedef string dirpath<MNTPATHLEN>;
-
-/*
- * The type name is used for arbitrary names (hostnames, groupnames)
- */
-typedef string name<MNTNAMLEN>;
-
-/*
- * A list of who has what mounted
- */
-typedef struct mountbody *mountlist;
-struct mountbody {
-	name ml_hostname;
-	dirpath ml_directory;
-	mountlist ml_next;
-};
-
-/*
- * A list of netgroups
- */
-typedef struct groupnode *groups;
-struct groupnode {
-	name gr_name;
-	groups gr_next;
-};
-
-/*
- * A list of what is exported and to whom
- */
-typedef struct exportnode *exports;
-struct exportnode {
-	dirpath ex_dir;
-	groups ex_groups;
-	exports ex_next;
-};
-
-program MOUNTPROG {
-	/*
-	 * Version one of the mount protocol communicates with version two
-	 * of the NFS protocol. Version three communicates with
-	 * version three of the NFS protocol. The only connecting
-	 * point is the fhandle structure, which is the same for both
-	 * protocols.
-	 */
-	version MOUNTVERS {
-		/*
-		 * Does no work. It is made available in all RPC services
-		 * to allow server reponse testing and timing
-		 */
-		void
-		MOUNTPROC_NULL(void) = 0;
-
-		/*	
-		 * If fhs_status is 0, then fhs_fhandle contains the
-	 	 * file handle for the directory. This file handle may
-		 * be used in the NFS protocol. This procedure also adds
-		 * a new entry to the mount list for this client mounting
-		 * the directory.
-		 * Unix authentication required.
-		 */
-		fhstatus 
-		MOUNTPROC_MNT(dirpath) = 1;
-
-		/*
-		 * Returns the list of remotely mounted filesystems. The 
-		 * mountlist contains one entry for each hostname and 
-		 * directory pair.
-		 */
-		mountlist
-		MOUNTPROC_DUMP(void) = 2;
-
-		/*
-		 * Removes the mount list entry for the directory
-		 * Unix authentication required.
-		 */
-		void
-		MOUNTPROC_UMNT(dirpath) = 3;
-
-		/*
-		 * Removes all of the mount list entries for this client
-		 * Unix authentication required.
-		 */
-		void
-		MOUNTPROC_UMNTALL(void) = 4;
-
-		/*
-		 * Returns a list of all the exported filesystems, and which
-		 * machines are allowed to import it.
-		 */
-		exports
-		MOUNTPROC_EXPORT(void)  = 5;
-
-		/*
-		 * Identical to MOUNTPROC_EXPORT above
-		 */
-		exports
-		MOUNTPROC_EXPORTALL(void) = 6;
-	} = 1;
-#ifdef WANT_NFS3
-	version MOUNTVERS3 {
-		/*
-		 * Does no work. It is made available in all RPC services
-		 * to allow server reponse testing and timing
-		 */
-		void
-		MOUNTPROC_NULL(void) = 0;
-
-		/*
-		 * If mountres3.fhs_status is MNT3_OK, then
-		 * mountres3.mountinfo contains the file handle for
-		 * the directory and a list of acceptable
-		 * authentication flavors.  This file handle may only
-		 * be used in the NFS version 3 protocol.  This
-		 * procedure also results in the server adding a new
-		 * entry to its mount list recording that this client
-		 * has mounted the directory. AUTH_UNIX authentication
-		 * or better is required.
-		 */
-		mountres3
-		MOUNTPROC_MNT(dirpath) = 1;
-
-		/*
-		 * Returns the list of remotely mounted filesystems. The 
-		 * mountlist contains one entry for each hostname and 
-		 * directory pair.
-		 */
-		mountlist
-		MOUNTPROC_DUMP(void) = 2;
-
-		/*
-		 * Removes the mount list entry for the directory
-		 * Unix authentication required.
-		 */
-		void
-		MOUNTPROC_UMNT(dirpath) = 3;
-
-		/*
-		 * Removes all of the mount list entries for this client
-		 * Unix authentication required.
-		 */
-		void
-		MOUNTPROC_UMNTALL(void) = 4;
-
-		/*
-		 * Returns a list of all the exported filesystems, and which
-		 * machines are allowed to import it.
-		 */
-		exports
-		MOUNTPROC_EXPORT(void)  = 5;
-	} = 3;
-#endif
-} = 100005;
Index: rvices/librpc/include/rpcsvc/nfs_prot.x
===================================================================
--- services/librpc/include/rpcsvc/nfs_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,1265 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)nfs_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/nfs_prot.x,v 1.7 1999/08/27 23:45:08 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const NFS_PORT          = 2049;
-const NFS_MAXDATA       = 8192;
-const NFS_MAXPATHLEN    = 1024;
-const NFS_MAXNAMLEN	= 255;
-const NFS_FHSIZE	= 32;
-const NFS_COOKIESIZE	= 4;
-const NFS_FIFO_DEV	= -1;	/* size kludge for named pipes */
-
-/*
- * File types
- */
-const NFSMODE_FMT  = 0170000;	/* type of file */
-const NFSMODE_DIR  = 0040000;	/* directory */
-const NFSMODE_CHR  = 0020000;	/* character special */
-const NFSMODE_BLK  = 0060000;	/* block special */
-const NFSMODE_REG  = 0100000;	/* regular */
-const NFSMODE_LNK  = 0120000;	/* symbolic link */
-const NFSMODE_SOCK = 0140000;	/* socket */
-const NFSMODE_FIFO = 0010000;	/* fifo */
-
-/*
- * Error status
- */
-enum nfsstat {
-	NFS_OK= 0,		/* no error */
-	NFSERR_PERM=1,		/* Not owner */
-	NFSERR_NOENT=2,		/* No such file or directory */
-	NFSERR_IO=5,		/* I/O error */
-	NFSERR_NXIO=6,		/* No such device or address */
-	NFSERR_ACCES=13,	/* Permission denied */
-	NFSERR_EXIST=17,	/* File exists */
-	NFSERR_NODEV=19,	/* No such device */
-	NFSERR_NOTDIR=20,	/* Not a directory*/
-	NFSERR_ISDIR=21,	/* Is a directory */
-	NFSERR_FBIG=27,		/* File too large */
-	NFSERR_NOSPC=28,	/* No space left on device */
-	NFSERR_ROFS=30,		/* Read-only file system */
-	NFSERR_NAMETOOLONG=63,	/* File name too long */
-	NFSERR_NOTEMPTY=66,	/* Directory not empty */
-	NFSERR_DQUOT=69,	/* Disc quota exceeded */
-	NFSERR_STALE=70,	/* Stale NFS file handle */
-	NFSERR_WFLUSH=99	/* write cache flushed */
-};
-
-/*
- * File types
- */
-enum ftype {
-	NFNON = 0,	/* non-file */
-	NFREG = 1,	/* regular file */
-	NFDIR = 2,	/* directory */
-	NFBLK = 3,	/* block special */
-	NFCHR = 4,	/* character special */
-	NFLNK = 5,	/* symbolic link */
-	NFSOCK = 6,	/* unix domain sockets */
-	NFBAD = 7,	/* unused */
-	NFFIFO = 8 	/* named pipe */
-};
-
-/*
- * File access handle
- */
-struct nfs_fh {
-	opaque data[NFS_FHSIZE];
-};
-
-/* 
- * Timeval
- */
-struct nfstime {
-	unsigned seconds;
-	unsigned useconds;
-};
-
-
-/*
- * File attributes
- */
-struct fattr {
-	ftype type;		/* file type */
-	unsigned mode;		/* protection mode bits */
-	unsigned nlink;		/* # hard links */
-	unsigned uid;		/* owner user id */
-	unsigned gid;		/* owner group id */
-	unsigned size;		/* file size in bytes */
-	unsigned blocksize;	/* prefered block size */
-	unsigned rdev;		/* special device # */
-	unsigned blocks;	/* Kb of disk used by file */
-	unsigned fsid;		/* device # */
-	unsigned fileid;	/* inode # */
-	nfstime	atime;		/* time of last access */
-	nfstime	mtime;		/* time of last modification */
-	nfstime	ctime;		/* time of last change */
-};
-
-/*
- * File attributes which can be set
- */
-struct sattr {
-	unsigned mode;	/* protection mode bits */
-	unsigned uid;	/* owner user id */
-	unsigned gid;	/* owner group id */
-	unsigned size;	/* file size in bytes */
-	nfstime	atime;	/* time of last access */
-	nfstime	mtime;	/* time of last modification */
-};
-
-
-typedef string filename<NFS_MAXNAMLEN>; 
-typedef string nfspath<NFS_MAXPATHLEN>;
-
-/*
- * Reply status with file attributes
- */
-union attrstat switch (nfsstat status) {
-case NFS_OK:
-	fattr attributes;
-default:
-	void;
-};
-
-struct sattrargs {
-	nfs_fh file;
-	sattr attributes;
-};
-
-/*
- * Arguments for directory operations
- */
-struct diropargs {
-	nfs_fh	dir;	/* directory file handle */
-	filename name;		/* name (up to NFS_MAXNAMLEN bytes) */
-};
-
-struct diropokres {
-	nfs_fh file;
-	fattr attributes;
-};
-
-/*
- * Results from directory operation
- */
-union diropres switch (nfsstat status) {
-case NFS_OK:
-	diropokres diropres;
-default:
-	void;
-};
-
-union readlinkres switch (nfsstat status) {
-case NFS_OK:
-	nfspath data;
-default:
-	void;
-};
-
-/*
- * Arguments to remote read
- */
-struct readargs {
-	nfs_fh file;		/* handle for file */
-	unsigned offset;	/* byte offset in file */
-	unsigned count;		/* immediate read count */
-	unsigned totalcount;	/* total read count (from this offset)*/
-};
-
-/*
- * Status OK portion of remote read reply
- */
-struct readokres {
-	fattr	attributes;	/* attributes, need for pagin*/
-	opaque data<NFS_MAXDATA>;
-};
-
-union readres switch (nfsstat status) {
-case NFS_OK:
-	readokres reply;
-default:
-	void;
-};
-
-/*
- * Arguments to remote write 
- */
-struct writeargs {
-	nfs_fh	file;		/* handle for file */
-	unsigned beginoffset;	/* beginning byte offset in file */
-	unsigned offset;	/* current byte offset in file */
-	unsigned totalcount;	/* total write count (to this offset)*/
-	opaque data<NFS_MAXDATA>;
-};
-
-struct createargs {
-	diropargs where;
-	sattr attributes;
-};
-
-struct renameargs {
-	diropargs from;
-	diropargs to;
-};
-
-struct linkargs {
-	nfs_fh from;
-	diropargs to;
-};
-
-struct symlinkargs {
-	diropargs from;
-	nfspath to;
-	sattr attributes;
-};
-
-
-typedef opaque nfscookie[NFS_COOKIESIZE];
-
-/*
- * Arguments to readdir
- */
-struct readdirargs {
-	nfs_fh dir;		/* directory handle */
-	nfscookie cookie;
-	unsigned count;		/* number of directory bytes to read */
-};
-
-struct entry {
-	unsigned fileid;
-	filename name;
-	nfscookie cookie;
-	entry *nextentry;
-};
-
-struct dirlist {
-	entry *entries;
-	bool eof;
-};
-
-union readdirres switch (nfsstat status) {
-case NFS_OK:
-	dirlist reply;
-default:
-	void;
-};
-
-struct statfsokres {
-	unsigned tsize;	/* preferred transfer size in bytes */
-	unsigned bsize;	/* fundamental file system block size */
-	unsigned blocks;	/* total blocks in file system */
-	unsigned bfree;	/* free blocks in fs */
-	unsigned bavail;	/* free blocks avail to non-superuser */
-};
-
-union statfsres switch (nfsstat status) {
-case NFS_OK:
-	statfsokres reply;
-default:
-	void;
-};
-
-#ifdef WANT_NFS3
-
-/*
- * NFSv3 constants and types
- */
-const NFS3_FHSIZE	= 64;	/* maximum size in bytes of a file handle */
-const NFS3_COOKIEVERFSIZE = 8;	/* size of a cookie verifier for READDIR */
-const NFS3_CREATEVERFSIZE = 8;	/* size of the verifier used for CREATE */
-const NFS3_WRITEVERFSIZE = 8;	/* size of the verifier used for WRITE */
-
-typedef unsigned hyper uint64;
-typedef hyper int64;
-typedef unsigned long uint32;
-typedef long int32;
-typedef string filename3<>;
-typedef string nfspath3<>;
-typedef uint64 fileid3;
-typedef uint64 cookie3;
-typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
-typedef opaque createverf3[NFS3_CREATEVERFSIZE];
-typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
-typedef uint32 uid3;
-typedef uint32 gid3;
-typedef uint64 size3;
-typedef uint64 offset3;
-typedef uint32 mode3;
-typedef uint32 count3;
-
-/*
- * Error status (v3)
- */
-enum nfsstat3 {
-	NFS3_OK	= 0,
-	NFS3ERR_PERM		= 1,
-	NFS3ERR_NOENT		= 2,
-	NFS3ERR_IO		= 5,
-	NFS3ERR_NXIO		= 6,
-	NFS3ERR_ACCES		= 13,
-	NFS3ERR_EXIST		= 17,
-	NFS3ERR_XDEV		= 18,
-	NFS3ERR_NODEV		= 19,
-	NFS3ERR_NOTDIR		= 20,
-	NFS3ERR_ISDIR		= 21,
-	NFS3ERR_INVAL		= 22,
-	NFS3ERR_FBIG		= 27,
-	NFS3ERR_NOSPC		= 28,
-	NFS3ERR_ROFS		= 30,
-	NFS3ERR_MLINK		= 31,
-	NFS3ERR_NAMETOOLONG	= 63,
-	NFS3ERR_NOTEMPTY	= 66,
-	NFS3ERR_DQUOT		= 69,
-	NFS3ERR_STALE		= 70,
-	NFS3ERR_REMOTE		= 71,
-	NFS3ERR_BADHANDLE	= 10001,
-	NFS3ERR_NOT_SYNC	= 10002,
-	NFS3ERR_BAD_COOKIE	= 10003,
-	NFS3ERR_NOTSUPP		= 10004,
-	NFS3ERR_TOOSMALL	= 10005,
-	NFS3ERR_SERVERFAULT	= 10006,
-	NFS3ERR_BADTYPE		= 10007,
-	NFS3ERR_JUKEBOX		= 10008
-};
-
-/*
- * File types (v3)
- */
-enum ftype3 {
-	NF3REG	= 1,		/* regular file */
-	NF3DIR	= 2,		/* directory */
-	NF3BLK	= 3,		/* block special */
-	NF3CHR	= 4,		/* character special */
-	NF3LNK	= 5,		/* symbolic link */
-	NF3SOCK	= 6,		/* unix domain sockets */
-	NF3FIFO	= 7		/* named pipe */
-};
-
-struct specdata3 {
-	uint32	specdata1;
-	uint32	specdata2;
-};
-
-/*
- * File access handle (v3)
- */
-struct nfs_fh3 {
-	opaque data<NFS3_FHSIZE>;
-};
-
-/* 
- * Timeval (v3)
- */
-struct nfstime3 {
-	uint32	seconds;
-	uint32	nseconds;
-};
-
-
-/*
- * File attributes (v3)
- */
-struct fattr3 {
-	ftype3	type;		/* file type */
-	mode3	mode;		/* protection mode bits */
-	uint32	nlink;		/* # hard links */
-	uid3	uid;		/* owner user id */
-	gid3	gid;		/* owner group id */
-	size3	size;		/* file size in bytes */
-	size3	used;		/* prefered block size */
-	specdata3 rdev;		/* special device # */
-	uint64 fsid;		/* device # */
-	fileid3	fileid;		/* inode # */
-	nfstime3 atime;		/* time of last access */
-	nfstime3 mtime;		/* time of last modification */
-	nfstime3 ctime;		/* time of last change */
-};
-
-union post_op_attr switch (bool attributes_follow) {
-case TRUE:
-	fattr3	attributes;
-case FALSE:
-	void;
-};
-
-struct wcc_attr {
-	size3	size;
-	nfstime3 mtime;
-	nfstime3 ctime;
-};
-
-union pre_op_attr switch (bool attributes_follow) {
-case TRUE:
-	wcc_attr attributes;
-case FALSE:
-	void;
-};
-
-struct wcc_data {
-	pre_op_attr before;
-	post_op_attr after;
-};
-
-union post_op_fh3 switch (bool handle_follows) {
-case TRUE:
-	nfs_fh3	handle;
-case FALSE:
-	void;
-};
-
-/*
- * File attributes which can be set (v3)
- */
-enum time_how {
-	DONT_CHANGE		= 0,
-	SET_TO_SERVER_TIME	= 1,
-	SET_TO_CLIENT_TIME	= 2
-};
-
-union set_mode3 switch (bool set_it) {
-case TRUE:
-	mode3	mode;
-default:
-	void;
-};
-
-union set_uid3 switch (bool set_it) {
-case TRUE:
-	uid3	uid;
-default:
-	void;
-};
-
-union set_gid3 switch (bool set_it) {
-case TRUE:
-	gid3	gid;
-default:
-	void;
-};
-
-union set_size3 switch (bool set_it) {
-case TRUE:
-	size3	size;
-default:
-	void;
-};
-
-union set_atime switch (time_how set_it) {
-case SET_TO_CLIENT_TIME:
-	nfstime3	atime;
-default:
-	void;
-};
-
-union set_mtime switch (time_how set_it) {
-case SET_TO_CLIENT_TIME:
-	nfstime3	mtime;
-default:
-	void;
-};
-
-struct sattr3 {
-	set_mode3	mode;
-	set_uid3	uid;
-	set_gid3	gid;
-	set_size3	size;
-	set_atime	atime;
-	set_mtime	mtime;
-};
-
-/*
- * Arguments for directory operations (v3)
- */
-struct diropargs3 {
-	nfs_fh3	dir;		/* directory file handle */
-	filename3 name;		/* name (up to NFS_MAXNAMLEN bytes) */
-};
-
-/*
- * Arguments to getattr (v3).
- */
-struct GETATTR3args {
-	nfs_fh3		object;
-};
-
-struct GETATTR3resok {
-	fattr3		obj_attributes;
-};
-
-union GETATTR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	GETATTR3resok	resok;
-default:
-	void;
-};
-
-/*
- * Arguments to setattr (v3).
- */
-union sattrguard3 switch (bool check) {
-case TRUE:
-	nfstime3	obj_ctime;
-case FALSE:
-	void;
-};
-
-struct SETATTR3args {
-	nfs_fh3		object;
-	sattr3		new_attributes;
-	sattrguard3	guard;
-};
-
-struct SETATTR3resok {
-	wcc_data	obj_wcc;
-};
-
-struct SETATTR3resfail {
-	wcc_data	obj_wcc;
-};
-
-union SETATTR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	SETATTR3resok	resok;
-default:
-	SETATTR3resfail	resfail;
-};
-
-/*
- * Arguments to lookup (v3).
- */
-struct LOOKUP3args {
-	diropargs3	what;
-};
-
-struct LOOKUP3resok {
-	nfs_fh3		object;
-	post_op_attr	obj_attributes;
-	post_op_attr	dir_attributes;
-};
-
-struct LOOKUP3resfail {
-	post_op_attr	dir_attributes;
-};
-
-union LOOKUP3res switch (nfsstat3 status) {
-case NFS3_OK:
-	LOOKUP3resok	resok;
-default:
-	LOOKUP3resfail	resfail;
-};
-
-/*
- * Arguments to access (v3).
- */
-const ACCESS3_READ	= 0x0001;
-const ACCESS3_LOOKUP	= 0x0002;
-const ACCESS3_MODIFY	= 0x0004;
-const ACCESS3_EXTEND	= 0x0008;
-const ACCESS3_DELETE	= 0x0010;
-const ACCESS3_EXECUTE	= 0x0020;
-
-struct ACCESS3args {
-	nfs_fh3		object;
-	uint32		access;
-};
-
-struct ACCESS3resok {
-	post_op_attr	obj_attributes;
-	uint32		access;
-};
-
-struct ACCESS3resfail {
-	post_op_attr	obj_attributes;
-};
-
-union ACCESS3res switch (nfsstat3 status) {
-case NFS3_OK:
-	ACCESS3resok	resok;
-default:
-	ACCESS3resfail	resfail;
-};
-
-/*
- * Arguments to readlink (v3).
- */
-struct READLINK3args {
-	nfs_fh3		symlink;
-};
-
-struct READLINK3resok {
-	post_op_attr	symlink_attributes;
-	nfspath3	data;
-};
-
-struct READLINK3resfail {
-	post_op_attr	symlink_attributes;
-};
-
-union READLINK3res switch (nfsstat3 status) {
-case NFS3_OK:
-	READLINK3resok	resok;
-default:
-	READLINK3resfail resfail;
-};
-
-/*
- * Arguments to read (v3).
- */
-struct READ3args {
-	nfs_fh3		file;
-	offset3		offset;
-	count3		count;
-};
-
-struct READ3resok {
-	post_op_attr	file_attributes;
-	count3		count;
-	bool		eof;
-	opaque		data<>;
-};
-
-struct READ3resfail {
-	post_op_attr	file_attributes;
-};
-
-/* XXX: solaris 2.6 uses ``nfsstat'' here */
-union READ3res switch (nfsstat3 status) {
-case NFS3_OK:
-	READ3resok	resok;
-default:
-	READ3resfail	resfail;
-};
-
-/*
- * Arguments to write (v3).
- */
-enum stable_how {
-	UNSTABLE	= 0,
-	DATA_SYNC	= 1,
-	FILE_SYNC	= 2
-};
-
-struct WRITE3args {
-	nfs_fh3		file;
-	offset3		offset;
-	count3		count;
-	stable_how	stable;
-	opaque		data<>;
-};
-
-struct WRITE3resok {
-	wcc_data	file_wcc;
-	count3		count;
-	stable_how	committed;
-	writeverf3	verf;
-};
-
-struct WRITE3resfail {
-	wcc_data	file_wcc;
-};
-
-union WRITE3res switch (nfsstat3 status) {
-case NFS3_OK:
-	WRITE3resok	resok;
-default:
-	WRITE3resfail	resfail;
-};
-
-/*
- * Arguments to create (v3).
- */
-enum createmode3 {
-	UNCHECKED	= 0,
-	GUARDED		= 1,
-	EXCLUSIVE	= 2
-};
-
-union createhow3 switch (createmode3 mode) {
-case UNCHECKED:
-case GUARDED:
-	sattr3		obj_attributes;
-case EXCLUSIVE:
-	createverf3	verf;
-};
-
-struct CREATE3args {
-	diropargs3	where;
-	createhow3	how;
-};
-
-struct CREATE3resok {
-	post_op_fh3	obj;
-	post_op_attr	obj_attributes;
-	wcc_data	dir_wcc;
-};
-
-struct CREATE3resfail {
-	wcc_data	dir_wcc;
-};
-
-union CREATE3res switch (nfsstat3 status) {
-case NFS3_OK:
-	CREATE3resok	resok;
-default:
-	CREATE3resfail	resfail;
-};
-
-/*
- * Arguments to mkdir (v3).
- */
-struct MKDIR3args {
-	diropargs3	where;
-	sattr3		attributes;
-};
-
-struct MKDIR3resok {
-	post_op_fh3	obj;
-	post_op_attr	obj_attributes;
-	wcc_data	dir_wcc;
-};
-
-struct MKDIR3resfail {
-	wcc_data	dir_wcc;
-};
-
-union MKDIR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	MKDIR3resok	resok;
-default:
-	MKDIR3resfail	resfail;
-};
-
-/*
- * Arguments to symlink (v3).
- */
-struct symlinkdata3 {
-	sattr3		symlink_attributes;
-	nfspath3	symlink_data;
-};
-
-struct SYMLINK3args {
-	diropargs3	where;
-	symlinkdata3	symlink;
-};
-
-struct SYMLINK3resok {
-	post_op_fh3	obj;
-	post_op_attr	obj_attributes;
-	wcc_data	dir_wcc;
-};
-
-struct SYMLINK3resfail {
-	wcc_data	dir_wcc;
-};
-
-union SYMLINK3res switch (nfsstat3 status) {
-case NFS3_OK:
-	SYMLINK3resok	resok;
-default:
-	SYMLINK3resfail	resfail;
-};
-
-/*
- * Arguments to mknod (v3).
- */
-struct devicedata3 {
-	sattr3		dev_attributes;
-	specdata3	spec;
-};
-
-union mknoddata3 switch (ftype3 type) {
-case NF3CHR:
-case NF3BLK:
-	devicedata3	device;
-case NF3SOCK:
-case NF3FIFO:
-	sattr3		pipe_attributes;
-default:
-	void;
-};
-
-struct MKNOD3args {
-	diropargs3	where;
-	mknoddata3	what;
-};
-
-struct MKNOD3resok {
-	post_op_fh3	obj;
-	post_op_attr	obj_attributes;
-	wcc_data	dir_wcc;
-};
-
-struct MKNOD3resfail {
-	wcc_data	dir_wcc;
-};
-
-union MKNOD3res switch (nfsstat3 status) {
-case NFS3_OK:
-	MKNOD3resok	resok;
-default:
-	MKNOD3resfail	resfail;
-};
-
-/*
- * Arguments to remove (v3).
- */
-struct REMOVE3args {
-	diropargs3	object;
-};
-
-struct REMOVE3resok {
-	wcc_data	dir_wcc;
-};
-
-struct REMOVE3resfail {
-	wcc_data	dir_wcc;
-};
-
-union REMOVE3res switch (nfsstat3 status) {
-case NFS3_OK:
-	REMOVE3resok	resok;
-default:
-	REMOVE3resfail	resfail;
-};
-
-/*
- * Arguments to rmdir (v3).
- */
-struct RMDIR3args {
-	diropargs3	object;
-};
-
-struct RMDIR3resok {
-	wcc_data	dir_wcc;
-};
-
-struct RMDIR3resfail {
-	wcc_data	dir_wcc;
-};
-
-union RMDIR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	RMDIR3resok	resok;
-default:
-	RMDIR3resfail	resfail;
-};
-
-/*
- * Arguments to rename (v3).
- */
-struct RENAME3args {
-	diropargs3	from;
-	diropargs3	to;
-};
-
-struct RENAME3resok {
-	wcc_data	fromdir_wcc;
-	wcc_data	todir_wcc;
-};
-
-struct RENAME3resfail {
-	wcc_data	fromdir_wcc;
-	wcc_data	todir_wcc;
-};
-
-union RENAME3res switch (nfsstat3 status) {
-case NFS3_OK:
-	RENAME3resok	resok;
-default:
-	RENAME3resfail	resfail;
-};
-
-/*
- * Arguments to link (v3).
- */
-struct LINK3args {
-	nfs_fh3		file;
-	diropargs3	link;
-};
-
-struct LINK3resok {
-	post_op_attr	file_attributes;
-	wcc_data	linkdir_wcc;
-};
-
-struct LINK3resfail {
-	post_op_attr	file_attributes;
-	wcc_data	linkdir_wcc;
-};
-
-union LINK3res switch (nfsstat3 status) {
-case NFS3_OK:
-	LINK3resok	resok;
-default:
-	LINK3resfail	resfail;
-};
-
-/*
- * Arguments to readdir (v3).
- */
-struct READDIR3args {
-	nfs_fh3		dir;
-	cookie3		cookie;
-	cookieverf3	cookieverf;
-	count3		count;
-};
-
-struct entry3 {
-	fileid3		fileid;
-	filename3	name;
-	cookie3		cookie;
-	entry3		*nextentry;
-};
-
-struct dirlist3 {
-	entry3		*entries;
-	bool		eof;
-};
-
-struct READDIR3resok {
-	post_op_attr	dir_attributes;
-	cookieverf3	cookieverf;
-	dirlist3	reply;
-};
-
-struct READDIR3resfail {
-	post_op_attr	dir_attributes;
-};
-
-union READDIR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	READDIR3resok	resok;
-default:
-	READDIR3resfail	resfail;
-};
-
-/*
- * Arguments to readdirplus (v3).
- */
-struct READDIRPLUS3args {
-	nfs_fh3		dir;
-	cookie3		cookie;
-	cookieverf3	cookieverf;
-	count3		dircount;
-	count3		maxcount;
-};
-
-struct entryplus3 {
-	fileid3		fileid;
-	filename3	name;
-	cookie3		cookie;
-	post_op_attr	name_attributes;
-	post_op_fh3	name_handle;
-	entryplus3	*nextentry;
-};
-
-struct dirlistplus3 {
-	entryplus3	*entries;
-	bool		eof;
-};
-
-struct READDIRPLUS3resok {
-	post_op_attr	dir_attributes;
-	cookieverf3	cookieverf;
-	dirlistplus3	reply;
-};
-
-struct READDIRPLUS3resfail {
-	post_op_attr	dir_attributes;
-};
-
-union READDIRPLUS3res switch (nfsstat3 status) {
-case NFS3_OK:
-	READDIRPLUS3resok	resok;
-default:
-	READDIRPLUS3resfail	resfail;
-};
-
-/*
- * Arguments to fsstat (v3).
- */
-struct FSSTAT3args {
-	nfs_fh3		fsroot;
-};
-
-struct FSSTAT3resok {
-	post_op_attr	obj_attributes;
-	size3		tbytes;
-	size3		fbytes;
-	size3		abytes;
-	size3		tfiles;
-	size3		ffiles;
-	size3		afiles;
-	uint32		invarsec;
-};
-
-struct FSSTAT3resfail {
-	post_op_attr	obj_attributes;
-};
-
-union FSSTAT3res switch (nfsstat3 status) {
-case NFS3_OK:
-	FSSTAT3resok	resok;
-default:
-	FSSTAT3resfail	resfail;
-};
-
-/*
- * Arguments to fsinfo (v3).
- */
-const FSF3_LINK		= 0x0001;
-const FSF3_SYMLINK	= 0x0002;
-const FSF3_HOMOGENEOUS	= 0x0008;
-const FSF3_CANSETTIME	= 0x0010;
-
-struct FSINFO3args {
-	nfs_fh3		fsroot;
-};
-
-struct FSINFO3resok {
-	post_op_attr	obj_attributes;
-	uint32		rtmax;
-	uint32		rtpref;
-	uint32		rtmult;
-	uint32		wtmax;
-	uint32		wtpref;
-	uint32		wtmult;
-	uint32		dtpref;
-	size3		maxfilesize;
-	nfstime3	time_delta;
-	uint32		properties;
-};
-
-struct FSINFO3resfail {
-	post_op_attr	obj_attributes;
-};
-
-union FSINFO3res switch (nfsstat3 status) {
-case NFS3_OK:
-	FSINFO3resok	resok;
-default:
-	FSINFO3resfail	resfail;
-};
-
-/*
- * Arguments to pathconf (v3).
- */
-struct PATHCONF3args {
-	nfs_fh3		object;
-};
-
-struct PATHCONF3resok {
-	post_op_attr	obj_attributes;
-	uint32		linkmax;
-	uint32		name_max;
-	bool		no_trunc;
-	bool		chown_restricted;
-	bool		case_insensitive;
-	bool		case_preserving;
-};
-
-struct PATHCONF3resfail {
-	post_op_attr	obj_attributes;
-};
-
-union PATHCONF3res switch (nfsstat3 status) {
-case NFS3_OK:
-	PATHCONF3resok	resok;
-default:
-	PATHCONF3resfail	resfail;
-};
-
-/*
- * Arguments to commit (v3).
- */
-struct COMMIT3args {
-	nfs_fh3		file;
-	offset3		offset;
-	count3		count;
-};
-
-struct COMMIT3resok {
-	wcc_data	file_wcc;
-	writeverf3	verf;
-};
-
-struct COMMIT3resfail {
-	wcc_data	file_wcc;
-};
-
-union COMMIT3res switch (nfsstat3 status) {
-case NFS3_OK:
-	COMMIT3resok	resok;
-default:
-	COMMIT3resfail	resfail;
-};
-
-#endif /* WANT_NFS3 */
-
-/*
- * Remote file service routines
- */
-program NFS_PROGRAM {
-	version NFS_VERSION {
-		void 
-		NFSPROC_NULL(void) = 0;
-
-		attrstat 
-		NFSPROC_GETATTR(nfs_fh) =	1;
-
-		attrstat 
-		NFSPROC_SETATTR(sattrargs) = 2;
-
-		void 
-		NFSPROC_ROOT(void) = 3;
-
-		diropres 
-		NFSPROC_LOOKUP(diropargs) = 4;
-
-		readlinkres 
-		NFSPROC_READLINK(nfs_fh) = 5;
-
-		readres 
-		NFSPROC_READ(readargs) = 6;
-
-		void 
-		NFSPROC_WRITECACHE(void) = 7;
-
-		attrstat
-		NFSPROC_WRITE(writeargs) = 8;
-
-		diropres
-		NFSPROC_CREATE(createargs) = 9;
-
-		nfsstat
-		NFSPROC_REMOVE(diropargs) = 10;
-
-		nfsstat
-		NFSPROC_RENAME(renameargs) = 11;
-
-		nfsstat
-		NFSPROC_LINK(linkargs) = 12;
-
-		nfsstat
-		NFSPROC_SYMLINK(symlinkargs) = 13;
-
-		diropres
-		NFSPROC_MKDIR(createargs) = 14;
-
-		nfsstat
-		NFSPROC_RMDIR(diropargs) = 15;
-
-		readdirres
-		NFSPROC_READDIR(readdirargs) = 16;
-
-		statfsres
-		NFSPROC_STATFS(nfs_fh) = 17;
-	} = 2;
-} = 100003;
-#ifdef WANT_NFS3
-program NFS3_PROGRAM {
-	version NFS_V3 {
-		void
-		NFSPROC3_NULL(void)			= 0;
-
-		GETATTR3res
-		NFSPROC3_GETATTR(GETATTR3args)		= 1;
-
-		SETATTR3res
-		NFSPROC3_SETATTR(SETATTR3args)		= 2;
-
-		LOOKUP3res
-		NFSPROC3_LOOKUP(LOOKUP3args)		= 3;
-
-		ACCESS3res
-		NFSPROC3_ACCESS(ACCESS3args)		= 4;
-
-		READLINK3res
-		NFSPROC3_READLINK(READLINK3args)	= 5;
-
-		READ3res
-		NFSPROC3_READ(READ3args)		= 6;
-
-		WRITE3res
-		NFSPROC3_WRITE(WRITE3args)		= 7;
-
-		CREATE3res
-		NFSPROC3_CREATE(CREATE3args)		= 8;
-
-		MKDIR3res
-		NFSPROC3_MKDIR(MKDIR3args)		= 9;
-
-		SYMLINK3res
-		NFSPROC3_SYMLINK(SYMLINK3args)		= 10;
-
-		MKNOD3res
-		NFSPROC3_MKNOD(MKNOD3args)		= 11;
-
-		REMOVE3res
-		NFSPROC3_REMOVE(REMOVE3args)		= 12;
-
-		RMDIR3res
-		NFSPROC3_RMDIR(RMDIR3args)		= 13;
-
-		RENAME3res
-		NFSPROC3_RENAME(RENAME3args)		= 14;
-
-		LINK3res
-		NFSPROC3_LINK(LINK3args)		= 15;
-
-		READDIR3res
-		NFSPROC3_READDIR(READDIR3args)		= 16;
-
-		READDIRPLUS3res
-		NFSPROC3_READDIRPLUS(READDIRPLUS3args)	= 17;
-
-		FSSTAT3res
-		NFSPROC3_FSSTAT(FSSTAT3args)		= 18;
-
-		FSINFO3res
-		NFSPROC3_FSINFO(FSINFO3args)		= 19;
-
-		PATHCONF3res
-		NFSPROC3_PATHCONF(PATHCONF3args)	= 20;
-
-		COMMIT3res
-		NFSPROC3_COMMIT(COMMIT3args)		= 21;
-	} = 3;
-} = 100003;
-#endif
Index: rvices/librpc/include/rpcsvc/nis.x
===================================================================
--- services/librpc/include/rpcsvc/nis.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,466 +1,0 @@
-%/*
-% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
-% * unrestricted use provided that this legend is included on all tape
-% * media and as a part of the software program in whole or part.  Users
-% * may copy or modify Sun RPC without charge, but are not authorized
-% * to license or distribute it to anyone else except as part of a product or
-% * program developed by the user or with the express written consent of
-% * Sun Microsystems, Inc.
-% *
-% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
-% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
-% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-% *
-% * Sun RPC is provided with no support and without any obligation on the
-% * part of Sun Microsystems, Inc. to assist in its use, correction,
-% * modification or enhancement.
-% *
-% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
-% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
-% * OR ANY PART THEREOF.
-% *
-% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
-% * or profits or other special, indirect and consequential damages, even if
-% * Sun has been advised of the possibility of such damages.
-% *
-% * Sun Microsystems, Inc.
-% * 2550 Garcia Avenue
-% * Mountain View, California  94043
-% */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/nis.x,v 1.3 1999/08/27 23:45:09 peter Exp $";
-%#endif /* not lint */
-#endif
-
-/* 
- * From 4.1 : @(#)nis.x	1.61 Copyright 1989 Sun Microsystems
- *
- * RPC Language Protocol description file for NIS Plus
- * This version : 1.61
- * Last Modified : 3/19/91
- */
-#ifdef RPC_HDR
-%/*
-% *	nis.h
-% *
-% *	This file is the main include file for NIS clients. It contains
-% *	both the client library function defines and the various data
-% * 	structures used by the NIS service. It includes the file nis_tags.h
-% *	which defines the tag values. This allows the tags to change without
-% *	having to change the nis.x file.
-% * 	
-% *	NOTE : DO NOT EDIT THIS FILE! It is automatically generated when
-% *	       rpcgen is run on the nis.x file. Note that there is a 
-% *	       simple sed script to remove some unneeded lines. (See the
-% *	       Makefile target nis.h)
-% *
-% */
-%#include <rpcsvc/nis_tags.h>
-#endif
-
-/* This gets stuffed into the source files. */
-#if RPC_HDR
-%#include <rpc/xdr.h>
-#endif
-/*
- * This is just pointless.
- */
-#ifdef SUN_STUPIDITY
-#if RPC_SVC
-%#include "nis_svc.h"
-#endif
-#endif
-
-/* Include the RPC Language description of NIS objects */
-#include "nis_object.x"
-
-/* Errors  that can be returned by the service */
-enum nis_error {
-	NIS_SUCCESS = 0,	/* A-ok, let's rock n roll 	*/
-	NIS_S_SUCCESS = 1,	/* Name found (maybe)	   	*/
-	NIS_NOTFOUND = 2,	/* Name definitely not found 	*/
-	NIS_S_NOTFOUND = 3,	/* Name maybe not found 	*/
-	NIS_CACHEEXPIRED = 4,	/* Name exists but cache out of date */
-	NIS_NAMEUNREACHABLE = 5, /* Can't get there from here */
-	NIS_UNKNOWNOBJ = 6,	/* Object type is bogus */
-	NIS_TRYAGAIN = 7,	/* I'm busy, call back */
-	NIS_SYSTEMERROR = 8,	/* Out of band failure */
-	NIS_CHAINBROKEN = 9,	/* First/Next warning */
-	NIS_PERMISSION = 10,	/* Not enough permission to access */
-	NIS_NOTOWNER = 11,	/* You don't own it, sorry */
-	NIS_NOT_ME = 12,	/* I don't serve this name */
-	NIS_NOMEMORY = 13,	/* Outta VM! Help! */
-	NIS_NAMEEXISTS = 14,	/* Can't create over another name */
-	NIS_NOTMASTER = 15,	/* I'm justa secondaray, don't ask me */
-	NIS_INVALIDOBJ = 16,	/* Object is broken somehow */
-	NIS_BADNAME = 17,	/* Unparsable name */
-	NIS_NOCALLBACK = 18,	/* Couldn't talk to call back proc */
-	NIS_CBRESULTS = 19,	/* Results being called back to you */
-	NIS_NOSUCHNAME = 20,	/* Name unknown */
-	NIS_NOTUNIQUE = 21,	/* Value is not uniques (entry) */
-	NIS_IBMODERROR = 22,	/* Inf. Base. Modify error. */
-	NIS_NOSUCHTABLE = 23,	/* Name for table was wrong */
-	NIS_TYPEMISMATCH = 24, 	/* Entry and table type mismatch */
-	NIS_LINKNAMEERROR = 25,	/* Link points to bogus name */
-	NIS_PARTIAL = 26,	/* Partial success, found table */
-	NIS_TOOMANYATTRS = 27,	/* Too many attributes */
-	NIS_RPCERROR = 28,	/* RPC error encountered */
-	NIS_BADATTRIBUTE = 29,	/* Bad or invalid attribute */
-	NIS_NOTSEARCHABLE = 30,	/* Non-searchable object searched */
-	NIS_CBERROR = 31,	/* Error during callback (svc crash) */
-	NIS_FOREIGNNS = 32,	/* Foreign Namespace */
-	NIS_BADOBJECT = 33,	/* Malformed object structure */
-	NIS_NOTSAMEOBJ = 34,	/* Object swapped during deletion */
-	NIS_MODFAIL = 35,	/* Failure during a Modify. */
-	NIS_BADREQUEST = 36,	/* Illegal query for table */
-	NIS_NOTEMPTY = 37,	/* Attempt to remove a non-empty tbl */
-	NIS_COLDSTART_ERR = 38, /* Error accesing the cold start file */
-	NIS_RESYNC = 39,	/* Transaction log too far out of date */
-	NIS_FAIL = 40,		/* NIS operation failed. */
-	NIS_UNAVAIL = 41,	/* NIS+ service is unavailable (client) */
-	NIS_RES2BIG = 42,	/* NIS+ result too big for datagram */
-	NIS_SRVAUTH = 43,	/* NIS+ server wasn't authenticated. */
-	NIS_CLNTAUTH = 44,	/* NIS+ Client wasn't authenticated. */
-	NIS_NOFILESPACE = 45,	/* NIS+ server ran out of disk space */
-	NIS_NOPROC = 46,	/* NIS+ server couldn't create new proc */
-	NIS_DUMPLATER = 47	/* NIS+ server already has dump child */
-};
-
-
-/* 
- * Structure definitions for the parameters and results of the actual
- * NIS RPC calls.
- *
- * This is the standard result (in the protocol) of most of the nis 
- * requests.
- */
-
-struct nis_result {
-	nis_error	status;		/* Status of the response */
-	nis_object	objects<>;	/* objects found 	  */
-	netobj		cookie;		/* Cookie Data 		  */
-	u_long		zticks;		/* server ticks	 	  */
-	u_long		dticks;		/* DBM ticks.		  */
-	u_long		aticks;		/* Cache (accel) ticks	  */
-	u_long		cticks;		/* Client ticks		  */
-};
-
-/* 
- * A Name Service request 
- * This request is used to access the name space, ns_name is the name 
- * of the object within the namespace and the object is it's value, for
- * add/modify, a copy of the original for remove. 
- */
-
-struct ns_request {
-	nis_name	ns_name;	/* Name in the NIS name space	*/
-	nis_object	ns_object<1>;	/* Optional Object (add/remove)	*/
-};
-
-/* 
- * An information base request
- * This request includes the NIS name of the table we wish to search, the
- * search criteria in the form of attribute/value pairs and an optional
- * callback program number. If the callback program number is provided
- * the server will send back objects one at a time, otherwise it will
- * return them all in the response.
- */
-
-struct ib_request {
-	nis_name  	ibr_name;	/* The name of the Table 	*/
-	nis_attr  	ibr_srch<>; 	/* The search critereia 	*/
-	u_long		ibr_flags;	/* Optional flags 		*/
-	nis_object	ibr_obj<1>;	/* optional object (add/modify) */
-	nis_server	ibr_cbhost<1>;	/* Optional callback info	*/
-	u_long		ibr_bufsize;	/* Optional first/next bufsize	*/
-	netobj		ibr_cookie;	/* The first/next cookie	*/
-};
-
-/*
- * This argument to the PING call notifies the replicas that something in 
- * a directory has changed and this is it's timestamp. The replica will use
- * the timestamp to determine if its resync operation was successful.
- */
-struct ping_args {
-	nis_name	dir;	/* Directory that had the change */
-	u_long		stamp;	/* timestamp of the transaction  */
-};
-
-/* 
- * These are the type of entries that are stored in the transaction log, 
- * note that modifications will appear as two entries, for names, they have
- * a "OLD" entry followed by a "NEW" entry. For entries in tables, there
- * is a remove followed by an add. It is done this way so that we can read
- * the log backwards to back out transactions and forwards to propogate
- * updated.
- */
-enum log_entry_t {
-	LOG_NOP = 0,
-	ADD_NAME = 1,		/* Name Added to name space 		  */
-	REM_NAME = 2,		/* Name removed from name space 	  */
-	MOD_NAME_OLD = 3,	/* Name was modified in the name space 	  */
-	MOD_NAME_NEW = 4,	/* Name was modified in the name space 	  */
-	ADD_IBASE = 5,		/* Entry added to information base 	  */
-	REM_IBASE = 6,		/* Entry removed from information base    */
-	MOD_IBASE = 7,		/* Entry was modified in information base */
-	UPD_STAMP = 8		/* Update timestamp (used as fenceposts)  */
-};
-	
-/*
- * This result is returned from the name service when it is requested to 
- * dump logged entries from its transaction log. Information base updates
- * will have the name of the information base in the le_name field and
- * a canonical set of attribute/value pairs to fully specify the entry's
- * 'name'. 
- */
-struct log_entry {
-	u_long		le_time;	/* Time in seconds 		*/
-	log_entry_t	le_type;	/* Type of log entry 		*/
-	nis_name	le_princp;	/* Principal making the change	*/
-	nis_name	le_name;	/* Name of table/dir involved 	*/
-	nis_attr	le_attrs<>;	/* List of AV pairs.		*/
-	nis_object	le_object;	/* Actual object value 		*/
-};
-
-struct log_result {
-	nis_error 	lr_status;	/* The status itself 	 	*/
-	netobj		lr_cookie;	/* Used by the dump callback	*/
-	log_entry	lr_entries<>;	/* zero or more entries 	*/
-};
-	
-struct cp_result {
-	nis_error	cp_status;	/* Status of the checkpoint 	*/
-	u_long		cp_zticks;	/* Service 'ticks' 	    	*/
-	u_long		cp_dticks;	/* Database 'ticks'	    	*/
-};
-
-/*
- * This structure defines a generic NIS tag list. The taglist contains
- * zero or tags, each of which is a type and a value. (u_long). 
- * These are used to report statistics (see tag definitions below)
- * and to set or reset state variables.
- */
-struct nis_tag {
-	u_long	tag_type;	/* Statistic tag (may vary) 	 */
-	string	tag_val<1024>;	/* Statistic value may also vary */
-};
-
-struct nis_taglist {
-	nis_tag tags<>;		/* List of tags */
-};
-
-struct dump_args {
-	nis_name	da_dir;		/* Directory to dump 	*/
-	u_long		da_time;	/* From this timestamp	*/
-	nis_server	da_cbhost<1>;	/* Callback to use.	*/
-};
-
-struct fd_args {
-	nis_name	dir_name;  /* The directory we're looking for */
-	nis_name	requester; /* Host principal name for signature */
-};
-
-struct fd_result {
-	nis_error	status;		/* Status returned by function	*/
-	nis_name	source;		/* Source of this answer   	*/
-	opaque		dir_data<>;	/* Directory Data (XDR'ed) 	*/ 
-	opaque		signature<>;	/* Signature of the source 	*/
-};
-
-
-/* 
- * What's going on here? Well, it's like this. When the service
- * is being compiled it wants to have the service definition specific
- * info included, and when the client is being compiled it wants that
- * info. This includes the appropriate file which was generated by
- * make in the protocols directory (probably /usr/include/rpcsvc).
- *
- * Uhm... guys? With RPC, you aren't supposed to have seperate
- * server-specific and client-specific header files. You have one header
- * file that's suitable for both. If your code doesn't work using just
- * the one header file, I submit to you that it's broken.
- *							-Bill
- */
-#ifdef SUN_STUPIDITY
-#ifdef RPC_SVC
-%#include "nis_svc.h"
-#endif
-#ifdef RPC_CLNT
-%#include "nis_clnt.h"
-#endif
-#endif
-
-program  NIS_PROG {
-
-	/* RPC Language description of the NIS+ protocol */
-	version NIS_VERSION {
-		/* The name service functions */
-		nis_result  NIS_LOOKUP(ns_request) = 1;
-		nis_result  NIS_ADD(ns_request) = 2;
-		nis_result  NIS_MODIFY(ns_request) = 3;
-		nis_result  NIS_REMOVE(ns_request) = 4;
-
-		/* The information base functions */
-		nis_result  NIS_IBLIST(ib_request) = 5;
-		nis_result  NIS_IBADD(ib_request) = 6;
-		nis_result  NIS_IBMODIFY(ib_request) = 7;
-		nis_result  NIS_IBREMOVE(ib_request) = 8;
-		nis_result  NIS_IBFIRST(ib_request) = 9;
-		nis_result  NIS_IBNEXT(ib_request) = 10;
-
-		/* NIS Administrative functions */
-		fd_result   NIS_FINDDIRECTORY(fd_args) = 12;
-
-		/* If fetch and optionally reset statistics */
-		nis_taglist  NIS_STATUS(nis_taglist) = 14;
-		
-		/* Dump changes to directory since time in da_time */
-		log_result  NIS_DUMPLOG(dump_args) = 15;
-		
-		/* Dump contents of directory named */
-		log_result  NIS_DUMP(dump_args) = 16;
-
-		/* Check status of callback thread */
-		bool	    NIS_CALLBACK(netobj) = 17;
-
-		/* Return last update time for named dir */
-		u_long      NIS_CPTIME(nis_name) = 18;
-
-		/* Checkpoint directory or table named */
-		cp_result   NIS_CHECKPOINT(nis_name) = 19;
-
-		/* Send 'status changed' ping to replicates */
-		void	    NIS_PING(ping_args) = 20;
-	
-		/* Modify server behaviour (such as debugging) */
-		nis_taglist NIS_SERVSTATE(nis_taglist) = 21;
-	
-		/* Create a Directory */
-		nis_error   NIS_MKDIR(nis_name) = 22;
-	
-		/* Remove a Directory */
-		nis_error   NIS_RMDIR(nis_name) = 23;
-		
-		/* Update public keys of a directory object */
-		nis_error   NIS_UPDKEYS(nis_name) = 24;
-	} = 3;
-} = 100300;
-
-/*
- * Included below are the defines that become part of nis.h,
- * they are technically not part of the protocol, but do define
- * key aspects of the implementation and are therefore useful
- * in building a conforming server or client.
- */
-#if RPC_HDR
-%/*
-% * Generic "hash" datastructures, used by all types of hashed data.
-% */
-%struct nis_hash_data {
-%	nis_name		name;	   /* NIS name of hashed item      */
-%	int			keychain;  /* It's hash key (for pop)      */
-%	struct nis_hash_data	*next;	   /* Hash collision pointer       */
-%	struct nis_hash_data	*prv_item; /* A serial, doubly linked list */
-%	struct nis_hash_data	*nxt_item; /* of items in the hash table   */
-%};
-%typedef struct nis_hash_data NIS_HASH_ITEM;
-%
-%struct nis_hash_table {
-%	NIS_HASH_ITEM	*keys[64];	/* A hash table of items           */
-%	NIS_HASH_ITEM	*first;		/* The first "item" in serial list */
-%};
-%typedef struct nis_hash_table NIS_HASH_TABLE;
-%
-%/* Structure for storing dynamically allocated static data */
-%struct nis_sdata {
-%	void	*buf;	/* Memory allocation pointer 	*/
-%	u_long	size;	/* Buffer size			*/
-%};
-%
-%/* Generic client creating flags */
-%#define ZMH_VC		1
-%#define ZMH_DG		2
-%#define ZMH_AUTH	4
-%
-%/* Testing Access rights for objects */
-%
-%#define NIS_READ_ACC		1
-%#define NIS_MODIFY_ACC		2
-%#define NIS_CREATE_ACC		4
-%#define NIS_DESTROY_ACC	8
-%/* Test macros. a == access rights, m == desired rights. */
-%#define WORLD(a, m)	(((a) & (m)) != 0)
-%#define GROUP(a, m)	(((a) & ((m) << 8)) != 0)
-%#define OWNER(a, m)	(((a) & ((m) << 16)) != 0)
-%#define NOBODY(a, m)	(((a) & ((m) << 24)) != 0)
-%
-%#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype)
-%#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
-%#define WORLD_DEFAULT (NIS_READ_ACC)
-%#define GROUP_DEFAULT (NIS_READ_ACC << 8)
-%#define OWNER_DEFAULT ((NIS_READ_ACC +\
-			 NIS_MODIFY_ACC +\
-			 NIS_CREATE_ACC +\
-			 NIS_DESTROY_ACC) << 16)
-%#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
-%
-%/* Result manipulation defines ... */
-%#define NIS_RES_NUMOBJ(x)	((x)->objects.objects_len)
-%#define NIS_RES_OBJECT(x)	((x)->objects.objects_val)
-%#define NIS_RES_COOKIE(x)	((x)->cookie)
-%#define NIS_RES_STATUS(x)	((x)->status)
-%
-%/* These defines make getting at the variant part of the object easier. */
-%#define TA_data zo_data.objdata_u.ta_data
-%#define EN_data zo_data.objdata_u.en_data
-%#define DI_data zo_data.objdata_u.di_data
-%#define LI_data zo_data.objdata_u.li_data
-%#define GR_data zo_data.objdata_u.gr_data
-%
-%#define __type_of(o) ((o)->zo_data.zo_type)
-%
-%/* Declarations for the internal subroutines in nislib.c */
-%enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME};
-%typedef enum name_pos name_pos;
-%
-%/*
-% * Defines for getting at column data in entry objects. Because RPCGEN
-% * generates some rather wordy structures, we create some defines that
-% * collapse the needed keystrokes to access a particular value using
-% * these definitions they take an nis_object *, and an int and return
-% * a u_char * for Value, and an int for length.
-% */
-%#define ENTRY_VAL(obj, col) \
-	(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
-%#define ENTRY_LEN(obj, col) \
-	(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
-%
-%#ifdef __cplusplus
-%}
-%#endif
-%
-%/* Prototypes, and extern declarations for the NIS library functions. */
-%#include <rpcsvc/nislib.h>
-%#endif /* __NIS_RPCGEN_H */
-%/* EDIT_START */
-%
-%/*
-% * nis_3.h
-% * 
-% * This file contains definitions that are only of interest to the actual
-% * service daemon and client stubs. Normal users of NIS will not include
-% * this file.
-% *
-% * NOTE : This include file is automatically created by a combination 
-% * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead
-% * and then remake this file.
-% */
-%#ifndef __nis_3_h
-%#define __nis_3_h
-%#ifdef __cplusplus
-%extern "C" {
-%#endif
-#endif
Index: rvices/librpc/include/rpcsvc/nis_cache.x
===================================================================
--- services/librpc/include/rpcsvc/nis_cache.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,87 +1,0 @@
-%/*
-% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
-% * unrestricted use provided that this legend is included on all tape
-% * media and as a part of the software program in whole or part.  Users
-% * may copy or modify Sun RPC without charge, but are not authorized
-% * to license or distribute it to anyone else except as part of a product or
-% * program developed by the user or with the express written consent of
-% * Sun Microsystems, Inc.
-% *
-% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
-% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
-% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-% *
-% * Sun RPC is provided with no support and without any obligation on the
-% * part of Sun Microsystems, Inc. to assist in its use, correction,
-% * modification or enhancement.
-% *
-% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
-% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
-% * OR ANY PART THEREOF.
-% *
-% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
-% * or profits or other special, indirect and consequential damages, even if
-% * Sun has been advised of the possibility of such damages.
-% *
-% * Sun Microsystems, Inc.
-% * 2550 Garcia Avenue
-% * Mountain View, California  94043
-% */
-
-/*
- *	nis_cache.x
- *
- *	Copyright (c) 1988-1992 Sun Microsystems Inc
- *	All Rights Reserved.
- */
-
-/* From: %#pragma ident	"@(#)nis_cache.x	1.11	94/05/03 SMI" */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/nis_cache.x,v 1.3 1999/08/27 23:45:09 peter Exp $";
-%#endif /* not lint */
-#endif
-
-#ifdef RPC_HDR
-%#include <rpc/types.h>
-%#include <rpcsvc/nis.h>
-%
-%/* default cache file */
-%#define CACHEFILE "/var/nis/NIS_SHARED_DIRCACHE" 
-%
-%/* clients have to read-lock the cache file, and SVR4 locking requires that */
-%/*   the file be writable, but we don't want a world-writable cache file.   */
-%/*   So... everyone agrees to use a different, world-writable file for the  */
-%/*   locking operations, but the data is in CACHEFILE.                      */
-%#define CACHELOCK "/usr/tmp/.NIS_DIR_CACHELOCK"
-%
-%/* the file containing one trusted XDR'ed directory object.
-% * This has to be present for the system to work.
-% */
-%#define COLD_START_FILE "/var/nis/NIS_COLD_START"
-%
-%enum pc_status {HIT, MISS, NEAR_MISS};
-%
-%extern int __nis_debuglevel;
-%
-%
-#endif
-
-#ifdef RPC_CLNT
-#ifdef SOLARIS
-%#include "../gen/nis_clnt.h"
-#else
-%#include "nis.h"
-#endif
-#endif
-
-program CACHEPROG {
-	version CACHE_VER_1 {
-		void NIS_CACHE_ADD_ENTRY(fd_result) = 1;
-		void NIS_CACHE_REMOVE_ENTRY(directory_obj) = 2;
-		void NIS_CACHE_READ_COLDSTART(void) = 3;
-		void NIS_CACHE_REFRESH_ENTRY(string<>) = 4;
-	} = 1;
-} = 100301;
Index: rvices/librpc/include/rpcsvc/nis_callback.x
===================================================================
--- services/librpc/include/rpcsvc/nis_callback.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,76 +1,0 @@
-%/*
-% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
-% * unrestricted use provided that this legend is included on all tape
-% * media and as a part of the software program in whole or part.  Users
-% * may copy or modify Sun RPC without charge, but are not authorized
-% * to license or distribute it to anyone else except as part of a product or
-% * program developed by the user or with the express written consent of
-% * Sun Microsystems, Inc.
-% *
-% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
-% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
-% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-% *
-% * Sun RPC is provided with no support and without any obligation on the
-% * part of Sun Microsystems, Inc. to assist in its use, correction,
-% * modification or enhancement.
-% *
-% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
-% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
-% * OR ANY PART THEREOF.
-% *
-% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
-% * or profits or other special, indirect and consequential damages, even if
-% * Sun has been advised of the possibility of such damages.
-% *
-% * Sun Microsystems, Inc.
-% * 2550 Garcia Avenue
-% * Mountain View, California  94043
-% */
-
-/*
- *	nis_callback.x
- *
- *	Copyright (c) 1988-1992 Sun Microsystems Inc
- *	All Rights Reserved.
- */
-
-/* From: %#pragma ident	"@(#)nis_callback.x	1.7	94/05/03 SMI" */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/nis_callback.x,v 1.3 1999/08/27 23:45:09 peter Exp $";
-%#endif /* not lint */
-#endif
-
-/*
- * "@(#)zns_cback.x 1.2 90/09/10 Copyr 1990 Sun Micro" 
- *
- * RPCL description of the Callback Service.
- */
-
-#ifdef RPC_HDR
-%#include <rpcsvc/nis.h>
-#endif
-#ifdef RPC_XDR
-#ifdef SOLARIS
-%#include "nis_clnt.h"
-#else
-%#include "nis.h"
-#endif
-#endif
-
-typedef nis_object	*obj_p;
-
-struct cback_data {
-	obj_p		entries<>;	/* List of objects */
-};
-
-program CB_PROG {
-	version CB_VERS {
-		bool	CBPROC_RECEIVE(cback_data) = 1;
-		void	CBPROC_FINISH(void) = 2;
-		void	CBPROC_ERROR(nis_error) = 3;
-	} = 1;
-} = 100302;
Index: rvices/librpc/include/rpcsvc/nis_db.h
===================================================================
--- services/librpc/include/rpcsvc/nis_db.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,164 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- *
- * $FreeBSD: src/include/rpcsvc/nis_db.h,v 1.5 1999/08/27 23:45:09 peter Exp $
- */
-
-/*
- * Copyright (c) 1991, by Sun Microsystems Inc.
- */
-
-/*
- * This header file defines the interface to the NIS database. All
- * implementations of the database must export at least these routines.
- * They must also follow the conventions set herein. See the implementors
- * guide for specific semantics that are required.
- */
-
-#ifndef	_RPCSVC_NIS_DB_H
-#define	_RPCSVC_NIS_DB_H
-
-
-/* From: #pragma ident	"@(#)nis_db.h	1.8	94/05/03 SMI" */
-
-/*
- * Note: although the version of <rpcsvc/nis_db.h> shipped with Solaris
- * 2.5/2.5.x is actually older than this one (according to the ident
- * string), it contains changes and a few added functions. Those changes
- * have been hand merged into this file to bring it up to date.
- */
-
-#include <rpc/rpc.h>
-#include <rpcsvc/nis.h>
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-enum db_status {
-	DB_SUCCESS = 0,
-	DB_NOTFOUND = 1,
-	DB_NOTUNIQUE = 2,
-	DB_BADTABLE = 3,
-	DB_BADQUERY = 4,
-	DB_BADOBJECT = 5,
-	DB_MEMORY_LIMIT = 6,
-	DB_STORAGE_LIMIT = 7,
-	DB_INTERNAL_ERROR = 8,
-	_DB_STATUS = 0xffffffff
-};
-typedef enum db_status db_status;
-
-enum db_action {
-	DB_LOOKUP = 0,
-	DB_REMOVE = 1,
-	DB_ADD = 2,
-	DB_FIRST = 3,
-	DB_NEXT = 4,
-	DB_ALL = 5,
-	DB_RESET_NEXT = 6,
-	_DB_ACTION = 0xffffffff
-};
-typedef enum db_action db_action;
-
-typedef entry_obj *entry_object_p;
-
-typedef struct {
-	u_int db_next_desc_len;
-	char *db_next_desc_val;
-} db_next_desc;
-
-struct db_result {
-	db_status status;
-	db_next_desc nextinfo;
-	struct {
-		u_int objects_len;
-		entry_object_p *objects_val;
-	} objects;
-	long ticks;
-};
-typedef struct db_result db_result;
-
-/*
- * Prototypes for the database functions.
- */
-
-#if (__STDC__)
-
-extern bool_t db_initialize(char *);
-#ifdef ORIGINAL_DECLS
-extern bool_t db_create_table(char *, table_obj *);
-extern bool_t db_destroy_table(char *);
-#else
-extern db_status db_create_table(char *, table_obj *);
-extern db_status db_destroy_table(char *);
-#endif
-extern db_result *db_first_entry(char *, int, nis_attr *);
-extern db_result *db_next_entry(char *, db_next_desc *);
-extern db_result *db_reset_next_entry(char *, db_next_desc *);
-extern db_result *db_list_entries(char *, int, nis_attr *);
-extern db_result *db_add_entry(char *, int,  nis_attr *, entry_obj *);
-extern db_result *db_remove_entry(char *, int, nis_attr *);
-extern db_status db_checkpoint(char *);
-extern db_status db_standby(char *);
-#ifndef ORIGINAL_DECLS
-extern db_status db_table_exists(char *);
-extern db_status db_unload_table(char *);
-extern void db_free_result(db_result *);
-#endif
-
-#else /* Non-prototype definitions */
-
-extern bool_t db_initialize();
-#ifdef ORIGINAL_DECLS
-extern bool_t db_create_table();
-extern bool_t db_destroy_table();
-#else
-extern db_status db_create_table();
-extern db_status db_destroy_table();
-#endif
-extern db_result *db_first_entry();
-extern db_result *db_next_entry();
-extern db_result *db_reset_next_entry();
-extern db_result *db_list_entries();
-extern db_result *db_add_entry();
-extern db_result *db_remove_entry();
-extern db_status db_checkpoint();
-extern db_status db_standby();
-#ifndef ORIGINAL_DECLS
-extern db_status db_table_exists();
-extern db_status db_unload_table();
-extern void db_free_result();
-#endif
-#endif  /* __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _RPCSVC_NIS_DB_H */
Index: rvices/librpc/include/rpcsvc/nis_object.x
===================================================================
--- services/librpc/include/rpcsvc/nis_object.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,317 +1,0 @@
-%/*
-% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
-% * unrestricted use provided that this legend is included on all tape
-% * media and as a part of the software program in whole or part.  Users
-% * may copy or modify Sun RPC without charge, but are not authorized
-% * to license or distribute it to anyone else except as part of a product or
-% * program developed by the user or with the express written consent of
-% * Sun Microsystems, Inc.
-% *
-% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
-% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
-% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-% *
-% * Sun RPC is provided with no support and without any obligation on the
-% * part of Sun Microsystems, Inc. to assist in its use, correction,
-% * modification or enhancement.
-% *
-% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
-% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
-% * OR ANY PART THEREOF.
-% *
-% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
-% * or profits or other special, indirect and consequential damages, even if
-% * Sun has been advised of the possibility of such damages.
-% *
-% * Sun Microsystems, Inc.
-% * 2550 Garcia Avenue
-% * Mountain View, California  94043
-% */
-
-/*
- *	nis_object.x
- *
- *	Copyright (c) 1988-1992 Sun Microsystems Inc
- *	All Rights Reserved.
- */
-
-/* From: %#pragma ident	"@(#)nis_object.x	1.10	94/05/03 SMI" */
-
-#if RPC_HDR
-%
-%#ifndef __nis_object_h
-%#define __nis_object_h
-%
-#endif
-/* 
- * 	This file defines the format for a NIS object in RPC language.
- * It is included by the main .x file and the database access protocol
- * file. It is common because both of them need to deal with the same
- * type of object. Generating the actual code though is a bit messy because
- * the nis.x file and the nis_dba.x file will generate xdr routines to 
- * encode/decode objects when only one set is needed. Such is life when
- * one is using rpcgen.
- *
- * Note, the protocol doesn't specify any limits on such things as
- * maximum name length, number of attributes, etc. These are enforced
- * by the database backend. When you hit them you will no. Also see
- * the db_getlimits() function for fetching the limit values.
- *
- */
-
-/* Some manifest constants, chosen to maximize flexibility without
- * plugging the wire full of data.
- */
-const NIS_MAXSTRINGLEN = 255;
-const NIS_MAXNAMELEN   = 1024;
-const NIS_MAXATTRNAME  = 32;
-const NIS_MAXATTRVAL   = 2048;
-const NIS_MAXCOLUMNS   = 64;
-const NIS_MAXATTR      = 16;
-const NIS_MAXPATH      = 1024;
-const NIS_MAXREPLICAS  = 128;
-const NIS_MAXLINKS     = 16;
-
-const NIS_PK_NONE      = 0;	/* no public key (unix/sys auth) */
-const NIS_PK_DH	       = 1;	/* Public key is Diffie-Hellman type */
-const NIS_PK_RSA       = 2;	/* Public key if RSA type */
-const NIS_PK_KERB      = 3;	/* Use kerberos style authentication */
-
-/*
- * The fundamental name type of NIS. The name may consist of two parts,
- * the first being the fully qualified name, and the second being an 
- * optional set of attribute/value pairs.
- */
-struct nis_attr {
-	string	zattr_ndx<>;	/* name of the index 		*/
-	opaque	zattr_val<>;	/* Value for the attribute. 	*/
-};
-
-typedef string nis_name<>;	/* The NIS name itself. */
-
-/* NIS object types are defined by the following enumeration. The numbers
- * they use are based on the following scheme :
- *		     0 - 1023 are reserved for Sun,
- * 		1024 - 2047 are defined to be private to a particular tree.
- *		2048 - 4095 are defined to be user defined.
- *		4096 - ...  are reserved for future use.
- */
-
-enum zotypes {
-	BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
-	NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
-	DIRECTORY_OBJ 	= 2,	/* Directory object describing domain 	*/
-	GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
-	TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
-	ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
-	LINK_OBJ   	= 6, 	/* A name link.				*/
-	PRIVATE_OBJ   	= 7 	/* Private object (all opaque data) 	*/
-};
-
-/*
- * The types of Name services NIS knows about. They are enumerated
- * here. The Binder code will use this type to determine if it has
- * a set of library routines that will access the indicated name service.
- */
-enum nstype {
-	UNKNOWN = 0,
-	NIS = 1,	/* Nis Plus Service		*/
-	SUNYP = 2,	/* Old NIS Service		*/
-	IVY = 3,	/* Nis Plus Plus Service	*/
-	DNS = 4,	/* Domain Name Service		*/
-	X500 = 5,	/* ISO/CCCIT X.500 Service	*/
-	DNANS = 6,	/* Digital DECNet Name Service	*/
-	XCHS = 7,	/* Xerox ClearingHouse Service	*/
-	CDS= 8
-};
-
-/*
- * DIRECTORY - The name service object. These objects identify other name
- * servers that are serving some portion of the name space. Each has a
- * type associated with it. The resolver library will note whether or not
- * is has the needed routines to access that type of service. 
- * The oarmask structure defines an access rights mask on a per object 
- * type basis for the name spaces. The only bits currently used are 
- * create and destroy. By enabling or disabling these access rights for
- * a specific object type for a one of the accessor entities (owner,
- * group, world) the administrator can control what types of objects 
- * may be freely added to the name space and which require the 
- * administrator's approval.
- */
-struct oar_mask {
-	u_long	oa_rights;	/* Access rights mask 	*/
-	zotypes	oa_otype;	/* Object type 		*/
-};
-
-struct endpoint {
-	string		uaddr<>;
-	string		family<>;   /* Transport family (INET, OSI, etc) */
-	string		proto<>;    /* Protocol (TCP, UDP, CLNP,  etc)   */
-};
-
-/*
- * Note: pkey is a netobj which is limited to 1024 bytes which limits the
- * keysize to 8192 bits. This is consider to be a reasonable limit for
- * the expected lifetime of this service.
- */
-struct nis_server {
-	nis_name	name; 	 	/* Principal name of the server  */
-	endpoint	ep<>;  		/* Universal addr(s) for server  */
-	u_long		key_type;	/* Public key type		 */
-	netobj		pkey;		/* server's public key  	 */
-};
-
-struct directory_obj {
-	nis_name   do_name;	 /* Name of the directory being served   */
-	nstype	   do_type;	 /* one of NIS, DNS, IVY, YP, or X.500 	 */
-	nis_server do_servers<>; /* <0> == Primary name server     	 */
-	u_long	   do_ttl;	 /* Time To Live (for caches) 		 */
-	oar_mask   do_armask<>;  /* Create/Destroy rights by object type */
-};
-
-/* 
- * ENTRY - This is one row of data from an information base. 
- * The type value is used by the client library to convert the entry to 
- * it's internal structure representation. The Table name is a back pointer
- * to the table where the entry is stored. This allows the client library 
- * to determine where to send a request if the client wishes to change this
- * entry but got to it through a LINK rather than directly.
- * If the entry is a "standalone" entry then this field is void.
- */
-const EN_BINARY   = 1;	/* Indicates value is binary data 	*/
-const EN_CRYPT    = 2;	/* Indicates the value is encrypted	*/
-const EN_XDR      = 4;	/* Indicates the value is XDR encoded	*/
-const EN_MODIFIED = 8;	/* Indicates entry is modified. 	*/
-const EN_ASN1     = 64;	/* Means contents use ASN.1 encoding    */
-
-struct entry_col {
-	u_long	ec_flags;	/* Flags for this value */
-	opaque	ec_value<>;	/* It's textual value	*/
-};
-
-struct entry_obj {
-	string 	en_type<>;	/* Type of entry such as "passwd" */
-	entry_col en_cols<>;	/* Value for the entry		  */
-};
-
-/*
- * GROUP - The group object contains a list of NIS principal names. Groups
- * are used to authorize principals. Each object has a set of access rights
- * for members of its group. Principal names in groups are in the form 
- * name.directory and recursive groups are expressed as @groupname.directory
- */
-struct group_obj {
-	u_long		gr_flags;	/* Flags controlling group	*/
-	nis_name	gr_members<>;  	/* List of names in group 	*/
-};
-
-/*
- * LINK - This is the LINK object. It is quite similar to a symbolic link
- * in the UNIX filesystem. The attributes in the main object structure are
- * relative to the LINK data and not what it points to (like the file system)
- * "modify" privleges here indicate the right to modify what the link points
- * at and not to modify that actual object pointed to by the link.
- */
-struct link_obj {
-	zotypes	 li_rtype;	/* Real type of the object	*/
-	nis_attr li_attrs<>;	/* Attribute/Values for tables	*/
-	nis_name li_name; 	/* The object's real NIS name	*/
-};
-
-/*
- * TABLE - This is the table object. It implements a simple 
- * data base that applications and use for configuration or 
- * administration purposes. The role of the table is to group together
- * a set of related entries. Tables are the simple database component
- * of NIS. Like many databases, tables are logically divided into columns
- * and rows. The columns are labeled with indexes and each ENTRY makes
- * up a row. Rows may be addressed within the table by selecting one
- * or more indexes, and values for those indexes. Each row which has
- * a value for the given index that matches the desired value is returned.
- * Within the definition of each column there is a flags variable, this
- * variable contains flags which determine whether or not the column is
- * searchable, contains binary data, and access rights for the entry objects
- * column value. 
- */
-
-const TA_BINARY     = 1;	/* Means table data is binary 		*/
-const TA_CRYPT      = 2;	/* Means value should be encrypted 	*/
-const TA_XDR        = 4;	/* Means value is XDR encoded		*/
-const TA_SEARCHABLE = 8;	/* Means this column is searchable	*/
-const TA_CASE       = 16;	/* Means this column is Case Sensitive	*/
-const TA_MODIFIED   = 32;	/* Means this columns attrs are modified*/
-const TA_ASN1       = 64;	/* Means contents use ASN.1 encoding     */
-
-struct table_col {
-	string	tc_name<64>;	/* Column Name 	 	   */
-	u_long	tc_flags;	/* control flags	   */
-	u_long	tc_rights;	/* Access rights mask	   */
-};
-
-struct table_obj {
-	string 	  ta_type<64>;	 /* Table type such as "passwd"	*/
-	int	  ta_maxcol;	 /* Total number of columns	*/
-	u_char	  ta_sep;	 /* Separator character 	*/
-	table_col ta_cols<>; 	 /* The number of table indexes */
-	string	  ta_path<>;	 /* A search path for this table */
-};
-
-/*
- * This union joins together all of the currently known objects. 
- */
-union objdata switch (zotypes zo_type) {
-        case DIRECTORY_OBJ :
-                struct directory_obj di_data;
-        case GROUP_OBJ :
-                struct group_obj gr_data;
-        case TABLE_OBJ :
-                struct table_obj ta_data;
-        case ENTRY_OBJ:
-                struct entry_obj en_data;
-        case LINK_OBJ :
-                struct link_obj li_data;
-        case PRIVATE_OBJ :
-                opaque	po_data<>;
-	case NO_OBJ :
-		void;
-        case BOGUS_OBJ :
-		void;
-        default :
-                void;
-};
-
-/*
- * This is the basic NIS object data type. It consists of a generic part
- * which all objects contain, and a specialized part which varies depending
- * on the type of the object. All of the specialized sections have been
- * described above. You might have wondered why they all start with an 
- * integer size, followed by the useful data. The answer is, when the 
- * server doesn't recognize the type returned it treats it as opaque data. 
- * And the definition for opaque data is {int size; char *data;}. In this
- * way, servers and utility routines that do not understand a given type
- * may still pass it around. One has to be careful in setting
- * this variable accurately, it must take into account such things as
- * XDR padding of structures etc. The best way to set it is to note one's
- * position in the XDR encoding stream, encode the structure, look at the
- * new position and calculate the size. 
- */
-struct nis_oid {
-	u_long	ctime;		/* Time of objects creation 	*/
-	u_long	mtime;		/* Time of objects modification */
-};
-
-struct nis_object {
-	nis_oid	 zo_oid;	/* object identity verifier.		*/ 
-	nis_name zo_name;	/* The NIS name for this object		*/
-	nis_name zo_owner;	/* NIS name of object owner.		*/
-	nis_name zo_group;	/* NIS name of access group.		*/
-	nis_name zo_domain;	/* The administrator for the object	*/
-	u_long	 zo_access;	/* Access rights (owner, group, world)	*/
-	u_long	 zo_ttl;	/* Object's time to live in seconds.	*/
-	objdata	 zo_data;	/* Data structure for this type 	*/
-};
-#if RPC_HDR
-%
-%#endif /* if __nis_object_h */
-%
-#endif
Index: rvices/librpc/include/rpcsvc/nis_tags.h
===================================================================
--- services/librpc/include/rpcsvc/nis_tags.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,137 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Copyright (c) 1991, Sun Microsystems Inc.
- */
-
-/*
- *	nis_tags.h
- *
- *	This file contains the tags and statistics definitions. It is
- *	automatically included by nis.h
- */
-
-#ifndef	_RPCSVC_NIS_TAGS_H
-#define	_RPCSVC_NIS_TAGS_H
-
-/* From: #pragma ident	"@(#)nis_tags.h	1.10	94/05/03 SMI" */
-/* from file: zns_tags.h	1.7 Copyright (c) 1990 Sun Microsystems */
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#ifndef ORIGINAL_DECLS
-#define		NIS_DIR "data"
-#endif
-
-/* Lookup and List function flags */
-#define	FOLLOW_LINKS	(1<<0)	/* Follow link objects 			*/
-#define	FOLLOW_PATH	(1<<1)	/* Follow the path in a table 		*/
-#define	HARD_LOOKUP	(1<<2)	/* Block until successful 		*/
-#define	ALL_RESULTS	(1<<3)	/* Retrieve all results 		*/
-#define	NO_CACHE	(1<<4)	/* Do not return 'cached' results 	*/
-#define	MASTER_ONLY	(1<<5)	/* Get value only from master server	*/
-#define	EXPAND_NAME	(1<<6)	/* Expand partitially qualified names	*/
-
-/* Semantic modification for table operations flags */
-#define	RETURN_RESULT	(1<<7)	/* Return resulting object to client    */
-#define	ADD_OVERWRITE	(1<<8)	/* Allow overwrites on ADD		*/
-#define	REM_MULTIPLE	(1<<9)	/* Allow wildcard deletes		*/
-#define	MOD_SAMEOBJ	(1<<10)	/* Check modified object before write	*/
-#define	ADD_RESERVED	(1<<11)	/* Spare ADD semantic			*/
-#define	REM_RESERVED	(1<<12)	/* Spare REM semantic			*/
-#ifdef ORIGINAL_DECLS
-#define	MOD_RESERVED	(1<<13)	/* Spare MOD semantic			*/
-#else
-#define	MOD_EXCLUSIVE	(1<<13)	/* Modify no overwrite on modified keys	*/
-#endif
-
-/* Transport specific modifications to the operation */
-#define	USE_DGRAM	(1<<16) /* Use a datagram transport 		*/
-#define	NO_AUTHINFO	(1<<17) /* Don't bother attaching auth info	*/
-
-/*
- * Declarations for "standard" NIS+ tags
- * State variable tags have values	0 - 2047
- * Statistic tags have values		2048 - 65535
- * User Tags have values		>2^16
- */
-#define	TAG_DEBUG	1	/* set debug level 		*/
-#define	TAG_STATS	2	/* Enable/disable statistics 	*/
-#define	TAG_GCACHE	3	/* Flush the Group Cache	*/
-#ifndef ORIGINAL_DECLS
-#define	TAG_GCACHE_ALL	TAG_GCACHE
-#endif
-#define	TAG_DCACHE	4	/* Flush the directory cache	*/
-#ifndef ORIGINAL_DECLS
-#define	TAG_DCACHE_ONE	TAG_DCACHE
-#endif
-#define	TAG_OCACHE	5	/* Flush the Object Cache	*/
-#define	TAG_SECURE	6	/* Set the security level 	*/
-#ifndef ORIGINAL_DECLS
-#define	TAG_TCACHE_ONE	7	/* Flush the table cache	*/
-#define	TAG_DCACHE_ALL	8	/* Flush entire directory cache */
-#define TAG_TCACHE_ALL	9	/* Flush entire table cache	*/
-#define	TAG_GCACHE_ONE	10	/* Flush one group object	*/
-#define	TAG_DCACHE_ONE_REFRESH 11 /* Flush and refresh one DO	*/
-#endif
-
-#define	TAG_OPSTATS	2048	/* NIS+ operations statistics   */
-#define	TAG_THREADS	2049	/* Child process/thread status  */
-#define	TAG_HEAP	2050	/* Heap usage statistics	*/
-#define	TAG_UPDATES	2051	/* Updates to this service	*/
-#define	TAG_VISIBLE	2052	/* First update that isn't replicated */
-#define	TAG_S_DCACHE	2053	/* Directory cache statistics	*/
-#define	TAG_S_OCACHE	2054	/* Object cache statistics	*/
-#define	TAG_S_GCACHE	2055	/* Group cache statistics	*/
-#define	TAG_S_STORAGE	2056	/* Group cache statistics	*/
-#define	TAG_UPTIME	2057	/* Time that server has been up */
-#ifndef ORIGINAL_DECLS
-#define	TAG_DIRLIST	2058    /* Dir served by this server	*/
-#define	TAG_NISCOMPAT	2059    /* Whether supports NIS compat mode */
-#define	TAG_DNSFORWARDING 2060	/* Whether DNS forwarding supported*/
-#define	TAG_SECURITY_LEVEL 2061 /* Security level of the server */
-#define	TAG_ROOTSERVER	2062	/* Whether root server		*/
-#endif
-
-/*
- * Declarations for the Group object flags. Currently
- * there are only 3.
- */
-#define	IMPMEM_GROUPS  1	/* Implicit Membership allowed 	*/
-#define	RECURS_GROUPS  2	/* Recursive Groups allowed 	*/
-#define	NEGMEM_GROUPS  4	/* Negative Groups allowed	*/
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* _RPCSVC_NIS_TAGS_H */
Index: rvices/librpc/include/rpcsvc/nislib.h
===================================================================
--- services/librpc/include/rpcsvc/nislib.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,317 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Copyright (c) 1991, Sun Microsystems Inc.
- */
-
-/*
- * This file contains the interfaces that are visible in the SunOS 5.x
- * implementation of NIS Plus. When using C++ the defined __cplusplus and
- * __STDC__ should both be true.
- */
-
-#ifndef	_RPCSVC_NISLIB_H
-#define	_RPCSVC_NISLIB_H
-
-/* From: #pragma ident	"@(#)nislib.h	1.16	94/05/03 SMI" */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct signature {
-	int signature_len;
-	char *signature_val;
-};
-
-#ifdef __STDC__
-extern void nis_freeresult(nis_result *);
-extern nis_result * nis_lookup(nis_name, u_long);
-extern nis_result * nis_list(nis_name, u_long,
-	int (*)(nis_name, nis_object *, void *), void *);
-extern nis_result * nis_add(nis_name, nis_object *);
-extern nis_result * nis_remove(nis_name, nis_object *);
-extern nis_result * nis_modify(nis_name, nis_object *);
-
-extern nis_result * nis_add_entry(nis_name, nis_object *, u_long);
-extern nis_result * nis_remove_entry(nis_name, nis_object *, u_long);
-extern nis_result * nis_modify_entry(nis_name, nis_object *, u_long);
-extern nis_result * nis_first_entry(nis_name);
-extern nis_result * nis_next_entry(nis_name, netobj *);
-
-extern nis_error nis_mkdir(nis_name, nis_server *);
-extern nis_error nis_rmdir(nis_name, nis_server *);
-extern name_pos nis_dir_cmp(nis_name, nis_name);
-
-extern nis_name * nis_getnames(nis_name);
-extern void nis_freenames(nis_name *);
-extern nis_name nis_domain_of(nis_name);
-extern nis_name nis_leaf_of(nis_name);
-extern nis_name nis_leaf_of_r(const nis_name, char *, size_t);
-extern nis_name nis_name_of(nis_name);
-extern nis_name nis_local_group(void);
-extern nis_name nis_local_directory(void);
-extern nis_name nis_local_principal(void);
-extern nis_name nis_local_host(void);
-
-extern void nis_destroy_object(nis_object *);
-extern nis_object * nis_clone_object(nis_object *, nis_object *);
-extern void nis_print_object(nis_object *);
-
-extern char * nis_sperrno(nis_error);
-extern void nis_perror(nis_error, char *);
-extern char * nis_sperror(nis_error, char *);
-extern void nis_lerror(nis_error, char *);
-
-extern void nis_print_group_entry(nis_name);
-extern bool_t nis_ismember(nis_name, nis_name);
-extern nis_error nis_creategroup(nis_name, u_long);
-extern nis_error nis_destroygroup(nis_name);
-extern nis_error nis_addmember(nis_name, nis_name);
-extern nis_error nis_removemember(nis_name, nis_name);
-extern nis_error nis_verifygroup(nis_name);
-
-extern void nis_freeservlist(nis_server **);
-extern nis_server ** nis_getservlist(nis_name);
-extern nis_error nis_stats(nis_server *, nis_tag *, int, nis_tag **);
-extern nis_error nis_servstate(nis_server *, nis_tag *, int, nis_tag **);
-extern void nis_freetags(nis_tag *, int);
-
-extern nis_result * nis_checkpoint(nis_name);
-extern void nis_ping(nis_name, u_long, nis_object *);
-
-/*
- * XXX: PLEASE NOTE THAT THE FOLLOWING FUNCTIONS ARE INTERNAL
- * TO NIS+ AND SHOULD NOT BE USED BY ANY APPLICATION PROGRAM.
- * THEIR SEMANTICS AND/OR SIGNATURE CAN CHANGE WITHOUT NOTICE.
- * SO, PLEASE DO NOT USE THEM.  YOU ARE WARNED!!!!
- */
-
-extern char ** __break_name(nis_name, int *);
-extern int __name_distance(char **, char **);
-extern nis_result * nis_make_error(nis_error, u_long, u_long, u_long, u_long);
-extern nis_attr * __cvt2attr(int *, char **);
-extern void nis_free_request(ib_request *);
-extern nis_error nis_get_request(nis_name, nis_object *, netobj*, ib_request*);
-extern nis_object * nis_read_obj(char *);
-extern int nis_write_obj(char *, nis_object *);
-extern int nis_in_table(nis_name, NIS_HASH_TABLE *, int *);
-extern int nis_insert_item(NIS_HASH_ITEM *, NIS_HASH_TABLE *);
-extern NIS_HASH_ITEM * nis_find_item(nis_name, NIS_HASH_TABLE *);
-extern NIS_HASH_ITEM * nis_remove_item(nis_name, NIS_HASH_TABLE *);
-extern void nis_insert_name(nis_name, NIS_HASH_TABLE *);
-extern void nis_remove_name(nis_name, NIS_HASH_TABLE *);
-extern CLIENT * nis_make_rpchandle(nis_server *, int, u_long, u_long, u_long,
-								int, int);
-extern void * nis_get_static_storage(struct nis_sdata *, u_long, u_long);
-extern char * nis_data(char *);
-extern void nis_print_rights(u_long);
-extern void nis_print_directory(directory_obj *);
-extern void nis_print_group(group_obj *);
-extern void nis_print_table(table_obj *);
-extern void nis_print_link(link_obj *);
-extern void nis_print_entry(entry_obj *);
-extern nis_object * nis_get_object(char *, char *, char *, u_long, u_long,
-								    zotypes);
-extern nis_server * __nis_init_callback(CLIENT *,
-    int (*)(nis_name, nis_object *, void *), void *);
-extern int nis_getdtblsize(void);
-extern int __nis_run_callback(netobj *, u_long, struct timeval *, CLIENT *);
-
-extern log_result *nis_dumplog(nis_server *, nis_name, u_long);
-extern log_result *nis_dump(nis_server *, nis_name,
-    int (*)(nis_name, nis_object *, void *));
-
-extern bool_t __do_ismember(nis_name, nis_name,
-    nis_result *(*)(nis_name, u_long));
-extern nis_name __nis_map_group(nis_name);
-extern nis_name __nis_map_group_r(nis_name, char*, size_t);
-
-extern nis_error __nis_CacheBind(char *, directory_obj *);
-extern nis_error __nis_CacheSearch(char *, directory_obj *);
-extern bool_t __nis_CacheRemoveEntry(directory_obj *);
-extern void __nis_CacheRestart(void);
-extern void __nis_CachePrint(void);
-extern void __nis_CacheDumpStatistics(void);
-extern bool_t writeColdStartFile(directory_obj *);
-
-extern CLIENT * __get_ti_clnt(char *, CLIENT *, char **, pid_t *);
-extern int __strcmp_case_insens(char *, char *);
-extern int __strncmp_case_insens(char *, char *);
-
-extern fd_result * nis_finddirectory(directory_obj *, nis_name);
-extern int __start_clock(int);
-extern u_long __stop_clock(int);
-
-/*
- * This particular function is part of the FreeBSD NIS+ implementation
- * only. Ideally it should be somewhere else, but it is used by both
- * rpc.nisd and nis_cachemgr, and there aren't that many headers common
- * to both programs.
- */
-
-extern struct signature *__nis_calculate_encrypted_cksum(unsigned char *, unsigned int, char *, int);
-
-#else
-
-/* Non-prototype definitions (old fashioned C) */
-
-extern void nis_freeresult();
-extern nis_result * nis_lookup();
-extern nis_result * nis_list();
-extern nis_result * nis_add();
-extern nis_result * nis_remove();
-extern nis_result * nis_modify();
-
-extern nis_result * nis_add_entry();
-extern nis_result * nis_remove_entry();
-extern nis_result * nis_modify_entry();
-extern nis_result * nis_first_entry();
-extern nis_result * nis_next_entry();
-
-extern nis_error nis_mkdir();
-extern nis_error nis_rmdir();
-extern name_pos nis_dir_cmp();
-
-extern nis_name *nis_getnames();
-extern void nis_freenames();
-extern nis_name nis_domain_of();
-extern nis_name nis_leaf_of();
-extern nis_name nis_leaf_of_r();
-extern nis_name nis_name_of();
-extern nis_name nis_local_group();
-extern nis_name nis_local_directory();
-extern nis_name nis_local_principal();
-extern nis_name nis_local_host();
-
-extern void nis_destroy_object();
-extern nis_object * nis_clone_object();
-extern void nis_print_object();
-
-extern char * nis_sperrno();
-extern void nis_perror();
-extern char * nis_sperror();
-extern void nis_lerror();
-
-extern void nis_print_group_entry();
-extern bool_t nis_ismember();
-extern nis_error nis_creategroup();
-extern nis_error nis_destroygroup();
-extern nis_error nis_addmember();
-extern nis_error nis_removemember();
-extern nis_error nis_verifygroup();
-
-extern void nis_freeservlist();
-extern nis_server ** nis_getservlist();
-extern nis_error nis_stats();
-extern nis_error nis_servstate();
-extern void nis_freetags();
-
-extern nis_result * nis_checkpoint();
-extern void nis_ping();
-
-/*
- * XXX: PLEASE NOTE THAT THE FOLLOWING FUNCTIONS ARE INTERNAL
- * TO NIS+ AND SHOULD NOT BE USED BY ANY APPLICATION PROGRAM.
- * THEIR SEMANTICS AND/OR SIGNATURE CAN CHANGE WITHOUT NOTICE.
- * SO, PLEASE DO NOT USE THEM.  YOU ARE WARNED!!!!
- */
-extern char ** __break_name();
-extern int __name_distance();
-extern nis_result * nis_make_error();
-extern nis_attr * __cvt2attr();
-extern void nis_free_request();
-extern nis_error nis_get_request();
-extern nis_object * nis_read_obj();
-extern int nis_write_obj();
-extern int nis_in_table();
-extern int nis_insert_item();
-extern NIS_HASH_ITEM * nis_find_item();
-extern NIS_HASH_ITEM * nis_remove_item();
-extern void nis_insert_name();
-extern void nis_remove_name();
-extern CLIENT * nis_make_rpchandle();
-extern void * nis_get_static_storage();
-extern char * nis_data();
-
-extern void nis_print_rights();
-extern void nis_print_directory();
-extern void nis_print_group();
-extern void nis_print_table();
-extern void nis_print_link();
-extern void nis_print_entry();
-extern nis_object * nis_get_object();
-
-extern nis_server * __nis_init_callback();
-extern int nis_getdtblsize();
-extern int __nis_run_callback();
-
-extern log_result * nis_dump();
-extern log_result * nis_dumplog();
-
-extern bool_t __do_ismember();
-extern nis_name __nis_map_group();
-extern nis_name __nis_map_group_r();
-
-
-extern nis_error __nis_CacheBind();
-extern directory_obj * __nis_CacheSearch();
-extern bool_t __nis_CacheRemoveEntry();
-extern void __nis_CacheRestart();
-extern void __nis_CachePrint();
-extern void __nis_CacheDumpStatistics();
-extern bool_t writeColdStartFile();
-
-extern CLIENT * __get_ti_clnt();
-extern int __strcmp_case_insens();
-extern int __strncmp_case_insens();
-
-extern fd_result * nis_finddirectory();
-extern int __start_clock();
-extern u_long __stop_clock();
-
-/*
- * This particular function is part of the FreeBSD NIS+ implementation
- * only. Ideally it should be somewhere else, but it is used by both
- * rpc.nisd and nis_cachemgr, and there aren't that many headers common
- * to both programs.
- */
-
-extern struct signature *__nis_calculate_encrypted_cksum();
-
-#endif
-
-#define	NUL '\0'
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* _RPCSVC_NISLIB_H */
Index: rvices/librpc/include/rpcsvc/nlm_prot.x
===================================================================
--- services/librpc/include/rpcsvc/nlm_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,183 +1,0 @@
-/* @(#)nlm_prot.x	2.1 88/08/01 4.0 RPCSRC */
-/* @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro */
-
-/*
- * Network lock manager protocol definition
- * Copyright (C) 1986 Sun Microsystems, Inc.
- *
- * protocol used between local lock manager and remote lock manager
- */
-
-#ifdef RPC_HDR
-%#define LM_MAXSTRLEN	1024
-%#define MAXNAMELEN	LM_MAXSTRLEN+1
-#else
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/nlm_prot.x,v 1.8 1999/08/27 23:45:10 peter Exp $";
-%#endif /* not lint */
-#endif
-
-/*
- * status of a call to the lock manager
- */
-enum nlm_stats {
-	nlm_granted = 0,
-	nlm_denied = 1,
-	nlm_denied_nolocks = 2,
-	nlm_blocked = 3,
-	nlm_denied_grace_period = 4
-};
-
-struct nlm_holder {
-	bool exclusive;
-	int svid;
-	netobj oh;
-	unsigned l_offset;
-	unsigned l_len;
-};
-
-union nlm_testrply switch (nlm_stats stat) {
-	case nlm_denied:
-		struct nlm_holder holder;
-	default:
-		void;
-};
-
-struct nlm_stat {
-	nlm_stats stat;
-};
-
-struct nlm_res {
-	netobj cookie;
-	nlm_stat stat;
-};
-
-struct nlm_testres {
-	netobj cookie;
-	nlm_testrply stat;
-};
-
-struct nlm_lock {
-	string caller_name<LM_MAXSTRLEN>;
-	netobj fh;		/* identify a file */
-	netobj oh;		/* identify owner of a lock */
-	int svid;		/* generated from pid for svid */
-	unsigned l_offset;
-	unsigned l_len;
-};
-
-struct nlm_lockargs {
-	netobj cookie;
-	bool block;
-	bool exclusive;
-	struct nlm_lock alock;
-	bool reclaim;		/* used for recovering locks */
-	int state;		/* specify local status monitor state */
-};
-
-struct nlm_cancargs {
-	netobj cookie;		
-	bool block;
-	bool exclusive;
-	struct nlm_lock alock;
-};
-
-struct nlm_testargs {
-	netobj cookie;		
-	bool exclusive;
-	struct nlm_lock alock;
-};
-
-struct nlm_unlockargs {
-	netobj cookie;		
-	struct nlm_lock alock;
-};
-
-
-#ifdef RPC_HDR
-%/*
-% * The following enums are actually bit encoded for efficient
-% * boolean algebra.... DON'T change them.....
-% */
-#endif
-enum	fsh_mode {
-	fsm_DN  = 0,	/* deny none */
-	fsm_DR  = 1,	/* deny read */
-	fsm_DW  = 2,	/* deny write */
-	fsm_DRW = 3	/* deny read/write */
-};
-
-enum	fsh_access {
-	fsa_NONE = 0,	/* for completeness */
-	fsa_R    = 1,	/* read only */
-	fsa_W    = 2,	/* write only */
-	fsa_RW   = 3	/* read/write */
-};
-
-struct	nlm_share {
-	string caller_name<LM_MAXSTRLEN>;
-	netobj	fh;
-	netobj	oh;
-	fsh_mode	mode;
-	fsh_access	access;
-};
-
-struct	nlm_shareargs {
-	netobj	cookie;
-	nlm_share	share;
-	bool	reclaim;
-};
-
-struct	nlm_shareres {
-	netobj	cookie;
-	nlm_stats	stat;
-	int	sequence;
-};
-
-struct	nlm_notify {
-	string name<MAXNAMELEN>;
-	long state;
-};
-
-/*
- * Over-the-wire protocol used between the network lock managers
- */
-
-program NLM_PROG {
-	version NLM_VERS {
-
-		nlm_testres	NLM_TEST(struct nlm_testargs) =	1;
-
-		nlm_res		NLM_LOCK(struct nlm_lockargs) =	2;
-
-		nlm_res		NLM_CANCEL(struct nlm_cancargs) = 3;
-		nlm_res		NLM_UNLOCK(struct nlm_unlockargs) =	4;
-
-		/*
-		 * remote lock manager call-back to grant lock
-		 */
-		nlm_res		NLM_GRANTED(struct nlm_testargs)= 5;
-		/*
-		 * message passing style of requesting lock
-		 */
-		void		NLM_TEST_MSG(struct nlm_testargs) = 6;
-		void		NLM_LOCK_MSG(struct nlm_lockargs) = 7;
-		void		NLM_CANCEL_MSG(struct nlm_cancargs) =8;
-		void		NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9;
-		void		NLM_GRANTED_MSG(struct nlm_testargs) = 10;
-		void		NLM_TEST_RES(nlm_testres) = 11;
-		void		NLM_LOCK_RES(nlm_res) = 12;
-		void		NLM_CANCEL_RES(nlm_res) = 13;
-		void		NLM_UNLOCK_RES(nlm_res) = 14;
-		void		NLM_GRANTED_RES(nlm_res) = 15;
-	} = 1;
-
-	version NLM_VERSX {
-		nlm_shareres	NLM_SHARE(nlm_shareargs) = 20;
-		nlm_shareres	NLM_UNSHARE(nlm_shareargs) = 21;
-		nlm_res		NLM_NM_LOCK(nlm_lockargs) = 22;
-		void		NLM_FREE_ALL(nlm_notify) = 23;
-	} = 3;
-
-} = 100021;
Index: rvices/librpc/include/rpcsvc/pmap_prot.x
===================================================================
--- services/librpc/include/rpcsvc/pmap_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,284 +1,0 @@
-%/*
-% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
-% * unrestricted use provided that this legend is included on all tape
-% * media and as a part of the software program in whole or part.  Users
-% * may copy or modify Sun RPC without charge, but are not authorized
-% * to license or distribute it to anyone else except as part of a product or
-% * program developed by the user.
-% *
-% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
-% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
-% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-% *
-% * Sun RPC is provided with no support and without any obligation on the
-% * part of Sun Microsystems, Inc. to assist in its use, correction,
-% * modification or enhancement.
-% *
-% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
-% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
-% * OR ANY PART THEREOF.
-% *
-% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
-% * or profits or other special, indirect and consequential damages, even if
-% * Sun has been advised of the possibility of such damages.
-% *
-% * Sun Microsystems, Inc.
-% * 2550 Garcia Avenue
-% * Mountain View, California  94043
-% */
-%/*
-% * Copyright (c) 1984,1989 by Sun Microsystems, Inc.
-% */
-
-%/* from pmap_prot.x */
-
-#ifdef RPC_HDR
-%
-%#pragma ident	"@(#)pmap_prot.x	1.6	94/04/29 SMI"
-%
-%#ifndef _KERNEL
-%
-#endif
-
-/*
- * Port Mapper Protocol Specification (in RPC Language)
- * derived from RFC 1057
- */
-
-%/*
-% * Protocol for the local binder service, or pmap.
-% *
-% * Copyright (C) 1984, Sun Microsystems, Inc.
-% *
-% * The following procedures are supported by the protocol:
-% *
-% * PMAPPROC_NULL() returns ()
-% * 	takes nothing, returns nothing
-% *
-% * PMAPPROC_SET(struct pmap) returns (bool_t)
-% * 	TRUE is success, FALSE is failure.  Registers the tuple
-% *	[prog, vers, prot, port].
-% *
-% * PMAPPROC_UNSET(struct pmap) returns (bool_t)
-% *	TRUE is success, FALSE is failure.  Un-registers pair
-% *	[prog, vers].  prot and port are ignored.
-% *
-% * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
-% *	0 is failure.  Otherwise returns the port number where the pair
-% *	[prog, vers] is registered.  It may lie!
-% *
-% * PMAPPROC_DUMP() RETURNS (struct pmaplist_ptr)
-% *
-% * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
-% * 	RETURNS (port, string<>);
-% * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc,
-% *						encapsulatedargs);
-% * 	Calls the procedure on the local machine.  If it is not registered,
-% *	this procedure is quite; ie it does not return error information!!!
-% *	This procedure only is supported on rpc/udp and calls via
-% *	rpc/udp.  This routine only passes null authentication parameters.
-% *	This file has no interface to xdr routines for PMAPPROC_CALLIT.
-% *
-% * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
-% */
-%
-const PMAPPORT = 111;	/* portmapper port number */
-%
-%
-%/*
-% * A mapping of (program, version, protocol) to port number
-% */
-
-struct pmap {
-	unsigned long pm_prog;
-	unsigned long pm_vers;
-	unsigned long pm_prot;
-	unsigned long pm_port;
-};
-#ifdef RPC_HDR
-%
-%typedef pmap PMAP;
-%
-#endif
-%
-%/*
-% * Supported values for the "prot" field
-% */
-%
-const PMAP_IPPROTO_TCP = 6;	/* protocol number for TCP/IP */
-const PMAP_IPPROTO_UDP = 17;	/* protocol number for UDP/IP */
-%
-%
-%/*
-% * A list of mappings
-% *
-% * Below are two definitions for the pmaplist structure.  This is done because
-% * xdr_pmaplist() is specified to take a struct pmaplist **, rather than a
-% * struct pmaplist * that rpcgen would produce.  One version of the pmaplist
-% * structure (actually called pm__list) is used with rpcgen, and the other is
-% * defined only in the header file for compatibility with the specified
-% * interface.
-% */
-
-struct pm__list {
-	pmap pml_map;
-	struct pm__list *pml_next;
-};
-
-typedef pm__list *pmaplist_ptr;		/* results of PMAPPROC_DUMP */
-
-#ifdef RPC_HDR
-%
-%typedef struct pm__list pmaplist;
-%typedef struct pm__list PMAPLIST;
-%
-%#ifndef __cplusplus
-%struct pmaplist {
-%	PMAP pml_map;
-%	struct pmaplist *pml_next;
-%};
-%#endif
-%
-%#ifdef __cplusplus
-%extern "C" {
-%#endif
-%#ifdef __STDC__
-%extern  bool_t xdr_pmaplist(XDR *, pmaplist**);
-%#else /* K&R C */
-%bool_t xdr_pmaplist();
-%#endif
-%#ifdef	__cplusplus
-%}
-%#endif
-%
-#endif
-
-%
-%/*
-% * Arguments to callit
-% */
-
-struct rmtcallargs {
-	unsigned long prog;
-	unsigned long vers;
-	unsigned long proc;
-	opaque args<>;
-};
-#ifdef RPC_HDR
-%
-%/*
-% * Client-side only representation of rmtcallargs structure.
-% *
-% * The routine that XDRs the rmtcallargs structure must deal with the
-% * opaque arguments in the "args" structure.  xdr_rmtcall_args() needs to be
-% * passed the XDR routine that knows the args' structure.  This routine
-% * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since
-% * the application being called knows the args structure already.  So we use a
-% * different "XDR" structure on the client side, p_rmtcallargs, which includes
-% * the args' XDR routine.
-% */
-%struct p_rmtcallargs {
-%	u_long prog;
-%	u_long vers;
-%	u_long proc;
-%	struct {
-%		u_int args_len;
-%		char *args_val;
-%	} args;
-%	xdrproc_t	xdr_args;	/* encodes args */
-%};
-%
-#endif	/* def RPC_HDR */
-%
-%
-%/*
-% * Results of callit
-% */
-
-struct rmtcallres {
-	unsigned long port;
-	opaque res<>;
-};
-#ifdef RPC_HDR
-%
-%/*
-% * Client-side only representation of rmtcallres structure.
-% */
-%struct p_rmtcallres {
-%	u_long port;
-%	struct {
-%		u_int res_len;
-%		char *res_val;
-%	} res;
-%	xdrproc_t	xdr_res;	/* decodes res */
-%};
-%
-#endif	/* def RPC_HDR */
-
-/*
- * Port mapper procedures
- */
-
-program PMAPPROG {
-   version PMAPVERS {
-	void
-	PMAPPROC_NULL(void)	= 0;
-
-	bool
-	PMAPPROC_SET(pmap)	= 1;
-
-	bool
-	PMAPPROC_UNSET(pmap)	= 2;
-
-	unsigned long
-	PMAPPROC_GETPORT(pmap)	= 3;
-
-	pmaplist_ptr
-	PMAPPROC_DUMP(void)	= 4;
-
-	rmtcallres
-	PMAPPROC_CALLIT(rmtcallargs)  = 5;
-   } = 2;
-} = 100000;
-%
-#ifdef RPC_HDR
-%#define PMAPVERS_PROTO		((u_long)2)
-%#define PMAPVERS_ORIG		((u_long)1)
-%
-%#else		/* ndef _KERNEL */
-%
-%#include <rpc/pmap_rmt.h>
-%
-%#ifdef __cplusplus
-%extern "C" {
-%#endif
-%
-%#define	PMAPPORT 111
-%
-%struct pmap {
-%	long unsigned pm_prog;
-%	long unsigned pm_vers;
-%	long unsigned pm_prot;
-%	long unsigned pm_port;
-%};
-%typedef struct pmap PMAP;
-%#ifdef __STDC__
-%extern bool_t xdr_pmap (XDR *, struct pmap *);
-%#else
-%extern bool_t xdr_pmap ();
-%#endif
-%
-%struct pmaplist {
-%	struct pmap pml_map;
-%	struct pmaplist *pml_next;
-%};
-%typedef struct pmaplist PMAPLIST;
-%typedef struct pmaplist *pmaplist_ptr;
-%
-%
-%#ifdef __cplusplus
-%}
-%#endif
-%
-%#endif		/* ndef _KERNEL */
-#endif
Index: rvices/librpc/include/rpcsvc/rex.x
===================================================================
--- services/librpc/include/rpcsvc/rex.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,235 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Remote execution (rex) protocol specification
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)rex.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/rex.x,v 1.6 1999/08/27 23:45:10 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const STRINGSIZE = 1024;
-typedef string rexstring<1024>;
-
-/*
- * values to pass to REXPROC_SIGNAL
- */
-const SIGINT = 2;	/* interrupt */
-
-/*
- * Values for rst_flags, below 
- */
-const REX_INTERACTIVE = 1;	/* interactive mode */
-
-struct rex_start {
-	rexstring rst_cmd<>;	/* list of command and args */
-	rexstring rst_host;	/* working directory host name */
-	rexstring rst_fsname;	/* working directory file system name */
-	rexstring rst_dirwithin;/* working directory within file system */
-	rexstring rst_env<>;	/* list of environment */
-	unsigned int rst_port0;	/* port for stdin */
-	unsigned int rst_port1;	/* port for stdout */
-	unsigned int rst_port2;	/* port for stderr */
-	unsigned int rst_flags;	/* options - see const above */
-};
-
-struct rex_result {
-   	int rlt_stat;		/* integer status code */
-	rexstring rlt_message;	/* string message for human consumption */
-};
-
-
-struct sgttyb {
-	unsigned four;	/* always equals 4 */
-	opaque chars[4];
-	/* chars[0] == input speed */
-	/* chars[1] == output speed */
-	/* chars[2] == kill character */
-	/* chars[3] == erase character */
-	unsigned flags;
-};
-/* values for speeds above (baud rates)  */
-const B0  = 0;
-const B50 = 1;
-const B75 = 2;
-const B110 = 3;
-const B134 = 4;
-const B150 = 5;
-const B200 = 6;
-const B300 = 7;
-const B600 = 8;
-const B1200 = 9;
-const B1800 = 10;
-const B2400 = 11;
-const B4800 = 12;
-const B9600 = 13;
-const B19200 = 14;
-const B38400 = 15;
-
-/* values for flags above */
-const TANDEM = 0x00000001; /* send stopc on out q full */
-const CBREAK = 0x00000002; /* half-cooked mode */
-const LCASE = 0x00000004; /* simulate lower case */
-const ECHO = 0x00000008; /* echo input */
-const CRMOD = 0x00000010; /* map \r to \r\n on output */
-const RAW = 0x00000020; /* no i/o processing */
-const ODDP = 0x00000040; /* get/send odd parity */
-const EVENP = 0x00000080; /* get/send even parity */
-const ANYP = 0x000000c0; /* get any parity/send none */
-const NLDELAY = 0x00000300; /* \n delay */
-const  NL0 = 0x00000000;
-const  NL1 = 0x00000100; /* tty 37 */
-const  NL2 = 0x00000200; /* vt05 */
-const  NL3 = 0x00000300;
-const TBDELAY = 0x00000c00; /* horizontal tab delay */
-const  TAB0 = 0x00000000;
-const  TAB1 = 0x00000400; /* tty 37 */
-const  TAB2 = 0x00000800;
-const XTABS = 0x00000c00; /* expand tabs on output */
-const CRDELAY = 0x00003000; /* \r delay */
-const  CR0 = 0x00000000;
-const  CR1 = 0x00001000; /* tn 300 */
-const  CR2 = 0x00002000; /* tty 37 */
-const  CR3 = 0x00003000; /* concept 100 */
-const VTDELAY = 0x00004000; /* vertical tab delay */
-const  FF0 = 0x00000000;
-const  FF1 = 0x00004000; /* tty 37 */
-const BSDELAY = 0x00008000; /* \b delay */
-const  BS0 = 0x00000000;
-const  BS1 = 0x00008000;
-const CRTBS = 0x00010000; /* do backspacing for crt */
-const PRTERA = 0x00020000; /* \ ... / erase */
-const CRTERA = 0x00040000; /* " \b " to wipe out char */
-const TILDE = 0x00080000; /* hazeltine tilde kludge */
-const MDMBUF = 0x00100000; /* start/stop output on carrier intr */
-const LITOUT = 0x00200000; /* literal output */
-const TOSTOP = 0x00400000; /* SIGTTOU on background output */
-const FLUSHO = 0x00800000; /* flush output to terminal */
-const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */
-const L001000 = 0x02000000;
-const CRTKIL = 0x04000000; /* kill line with " \b " */
-const PASS8 = 0x08000000;
-const CTLECH = 0x10000000; /* echo control chars as ^X */
-const PENDIN = 0x20000000; /* tp->t_rawq needs reread */
-const DECCTQ = 0x40000000; /* only ^Q starts after ^S */
-const NOFLSH = 0x80000000; /* no output flush on signal */
-
-struct tchars {
-	unsigned six;	/* always equals 6 */
-	opaque chars[6];
-	/* chars[0] == interrupt char */
-	/* chars[1] == quit char */
-	/* chars[2] == start output char */
-	/* chars[3] == stop output char */
-	/* chars[4] == end-of-file char */
-	/* chars[5] == input delimeter (like nl) */
-};
-
-struct ltchars {
-	unsigned six;	/* always equals 6 */
-	opaque chars[6];
-	/* chars[0] == stop process signal */
-	/* chars[1] == delayed stop process signal */
-	/* chars[2] == reprint line */
-	/* chars[3] == flush output */
-	/* chars[4] == word erase */
-	/* chars[5] == literal next character */
-	unsigned mode;
-};
-
-struct rex_ttysize {
-	int ts_lines;
-	int ts_cols;
-};
-
-struct rex_ttymode {
-    sgttyb basic;    /* standard unix tty flags */
-    tchars more; /* interrupt, kill characters, etc. */
-    ltchars yetmore; /* special Berkeley characters */
-    unsigned andmore;     /* and Berkeley modes */
-};
-
-/* values for andmore above */
-const LCRTBS = 0x0001;	/* do backspacing for crt */
-const LPRTERA = 0x0002;	/* \ ... / erase */
-const LCRTERA = 0x0004;	/* " \b " to wipe out char */
-const LTILDE = 0x0008;	/* hazeltine tilde kludge */
-const LMDMBUF = 0x0010;	/* start/stop output on carrier intr */
-const LLITOUT = 0x0020;	/* literal output */
-const LTOSTOP = 0x0040;	/* SIGTTOU on background output */
-const LFLUSHO = 0x0080;	/* flush output to terminal */
-const LNOHANG = 0x0100;	/* no SIGHUP on carrier drop */
-const LL001000 = 0x0200;
-const LCRTKIL = 0x0400;	/* kill line with " \b " */
-const LPASS8 = 0x0800;
-const LCTLECH = 0x1000;	/* echo control chars as ^X */
-const LPENDIN = 0x2000;	/* needs reread */
-const LDECCTQ = 0x4000;	/* only ^Q starts after ^S */
-const LNOFLSH = 0x8000;	/* no output flush on signal */
-
-program REXPROG {
-	version REXVERS {
-
-		/*
-		 * Start remote execution
-		 */
-		rex_result 
-		REXPROC_START(rex_start) = 1;
-
-		/*
-		 * Wait for remote execution to terminate
-		 */
-		rex_result
-		REXPROC_WAIT(void) = 2;
-
-		/*
-		 * Send tty modes
-		 */
-		void
-		REXPROC_MODES(rex_ttymode) = 3;
-
-		/*
-		 * Send window size change
-		 */
-		void
-		REXPROC_WINCH(rex_ttysize) = 4;
-
-		/*
-		 * Send other signal
-		 */
-		void
-		REXPROC_SIGNAL(int) = 5;
-	} = 1;
-} = 100017;
Index: rvices/librpc/include/rpcsvc/rnusers.x
===================================================================
--- services/librpc/include/rpcsvc/rnusers.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,122 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Find out about remote users
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)rnusers.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/rnusers.x,v 1.6 1999/08/27 23:45:10 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const MAXUSERS = 100;
-const MAXUTLEN = 256;
-
-struct utmp {
-	string ut_line<MAXUTLEN>;
-	string ut_name<MAXUTLEN>;
-	string ut_host<MAXUTLEN>;
-	int ut_time;
-};
-
-
-struct utmpidle {
-	utmp ui_utmp;
-	unsigned int ui_idle;
-};
-
-typedef utmp utmparr<MAXUSERS>;
-
-typedef utmpidle utmpidlearr<MAXUSERS>;
-
-const RUSERS_MAXUSERLEN = 32;
-const RUSERS_MAXLINELEN = 32;
-const RUSERS_MAXHOSTLEN = 257;
-
-struct rusers_utmp {
-	string ut_user<RUSERS_MAXUSERLEN>;	/* aka ut_name */
-	string ut_line<RUSERS_MAXLINELEN>;	/* device */
-	string ut_host<RUSERS_MAXHOSTLEN>;	/* host user logged on from */
-	int ut_type;				/* type of entry */
-	int ut_time;				/* time entry was made */
-	unsigned int ut_idle;			/* minutes idle */
-};
-
-typedef rusers_utmp utmp_array<>;
-
-program RUSERSPROG {
-	/*
-	 * Old version does not include idle information
-	 */
-	version RUSERSVERS_ORIG {
-		int
-		RUSERSPROC_NUM(void) = 1;
-
-		utmparr
-		RUSERSPROC_NAMES(void) = 2;
-
-		utmparr
-		RUSERSPROC_ALLNAMES(void) = 3;
-	} = 1;
-
-	/*
-	 * Includes idle information
-	 */
-	version RUSERSVERS_IDLE {
-		int
-		RUSERSPROC_NUM(void) = 1;
-
-		utmpidlearr
-		RUSERSPROC_NAMES(void) = 2;
-
-		utmpidlearr
-		RUSERSPROC_ALLNAMES(void) = 3;
-	} = 2;
-
-	/*
-	 * Version 3 rusers procedures (from Solaris).
-	 * (Thanks a lot Sun.)
-	 */
-	version RUSERSVERS_3 {
-		int
-		RUSERSPROC_NUM(void) = 1;
-
-		utmp_array
-		RUSERSPROC_NAMES(void) = 2;
-
-		utmp_array
-		RUSERSPROC_ALLNAMES(void) = 3;
-	} = 3;
-
-} = 100002;
Index: rvices/librpc/include/rpcsvc/rquota.x
===================================================================
--- services/librpc/include/rpcsvc/rquota.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,67 +1,0 @@
-/*
- * Remote quota protocol
- * Requires unix authentication
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)rquota.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/rquota.x,v 1.6 1999/08/27 23:45:10 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const RQ_PATHLEN = 1024;
-
-struct getquota_args {
-	string gqa_pathp<RQ_PATHLEN>;  	/* path to filesystem of interest */
-	int gqa_uid;	        	/* inquire about quota for uid */
-};
-
-/*
- * remote quota structure
- */
-struct rquota {
-	int rq_bsize;			/* block size for block counts */
-	bool rq_active;  		/* indicates whether quota is active */
-	unsigned int rq_bhardlimit;	/* absolute limit on disk blks alloc */
-	unsigned int rq_bsoftlimit;	/* preferred limit on disk blks */
-	unsigned int rq_curblocks;	/* current block count */
-	unsigned int rq_fhardlimit;	/* absolute limit on allocated files */
-	unsigned int rq_fsoftlimit;	/* preferred file limit */
-	unsigned int rq_curfiles;	/* current # allocated files */
-	unsigned int rq_btimeleft;	/* time left for excessive disk use */
-	unsigned int rq_ftimeleft;	/* time left for excessive files */
-};	
-
-enum gqr_status {
-	Q_OK = 1,		/* quota returned */
-	Q_NOQUOTA = 2,  	/* noquota for uid */
-	Q_EPERM = 3		/* no permission to access quota */
-};
-
-union getquota_rslt switch (gqr_status status) {
-case Q_OK:
-	rquota gqr_rquota;	/* valid if status == Q_OK */
-case Q_NOQUOTA:
-	void;
-case Q_EPERM:
-	void;
-};
-
-program RQUOTAPROG {
-	version RQUOTAVERS {
-		/*
-		 * Get all quotas
-		 */
-		getquota_rslt
-		RQUOTAPROC_GETQUOTA(getquota_args) = 1;
-
-		/*
-	 	 * Get active quotas only
-		 */
-		getquota_rslt
-		RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2;
-	} = 1;
-} = 100011;
Index: rvices/librpc/include/rpcsvc/rstat.x
===================================================================
--- services/librpc/include/rpcsvc/rstat.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,151 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Gather statistics on remote machines
- */
-
-#ifdef RPC_HDR
-
-%#ifndef FSCALE
-%/*
-% * Scale factor for scaled integers used to count load averages.
-% */
-%#define FSHIFT  8               /* bits to right of fixed binary point */
-%#define FSCALE  (1<<FSHIFT)
-%
-%#endif /* ndef FSCALE */
-
-#else
-
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)rstat.x	2.2 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/rstat.x,v 1.6 1999/08/27 23:45:11 peter Exp $";
-%#endif /* not lint */
-
-#endif /* def RPC_HDR */
-
-const RSTAT_CPUSTATES = 4;
-const RSTAT_DK_NDRIVE = 4;
-
-/*
- * GMT since 0:00, January 1, 1970
- */
-struct rstat_timeval {
-	unsigned int tv_sec;	/* seconds */
-	unsigned int tv_usec;	/* and microseconds */
-};
-
-struct statstime {				/* RSTATVERS_TIME */
-	int cp_time[RSTAT_CPUSTATES];
-	int dk_xfer[RSTAT_DK_NDRIVE];
-	unsigned int v_pgpgin;	/* these are cumulative sum */
-	unsigned int v_pgpgout;
-	unsigned int v_pswpin;
-	unsigned int v_pswpout;
-	unsigned int v_intr;
-	int if_ipackets;
-	int if_ierrors;
-	int if_oerrors;
-	int if_collisions;
-	unsigned int v_swtch;
-	int avenrun[3];         /* scaled by FSCALE */
-	rstat_timeval boottime;
-	rstat_timeval curtime;
-	int if_opackets;
-};
-
-struct statsswtch {			/* RSTATVERS_SWTCH */
-	int cp_time[RSTAT_CPUSTATES];
-	int dk_xfer[RSTAT_DK_NDRIVE];
-	unsigned int v_pgpgin;	/* these are cumulative sum */
-	unsigned int v_pgpgout;
-	unsigned int v_pswpin;
-	unsigned int v_pswpout;
-	unsigned int v_intr;
-	int if_ipackets;
-	int if_ierrors;
-	int if_oerrors;
-	int if_collisions;
-	unsigned int v_swtch;
-	unsigned int avenrun[3];/* scaled by FSCALE */
-	rstat_timeval boottime;
-	int if_opackets;
-};
-
-struct stats {				/* RSTATVERS_ORIG */
-	int cp_time[RSTAT_CPUSTATES];
-	int dk_xfer[RSTAT_DK_NDRIVE];
-	unsigned int v_pgpgin;	/* these are cumulative sum */
-	unsigned int v_pgpgout;
-	unsigned int v_pswpin;
-	unsigned int v_pswpout;
-	unsigned int v_intr;
-	int if_ipackets;
-	int if_ierrors;
-	int if_oerrors;
-	int if_collisions;
-	int if_opackets;
-};
-
-
-program RSTATPROG {
-	/*
-	 * Newest version includes current time and context switching info
-	 */
-	version RSTATVERS_TIME {
-		statstime
-		RSTATPROC_STATS(void) = 1;
-
-		unsigned int
-		RSTATPROC_HAVEDISK(void) = 2;
-	} = 3;
-	/*
-	 * Does not have current time
-	 */
-	version RSTATVERS_SWTCH {
-		statsswtch
-		RSTATPROC_STATS(void) = 1;
-
-		unsigned int
-		RSTATPROC_HAVEDISK(void) = 2;
-	} = 2;
-	/*
-	 * Old version has no info about current time or context switching
-	 */
-	version RSTATVERS_ORIG {
-		stats
-		RSTATPROC_STATS(void) = 1;
-
-		unsigned int
-		RSTATPROC_HAVEDISK(void) = 2;
-	} = 1;
-} = 100001;
Index: rvices/librpc/include/rpcsvc/rwall.x
===================================================================
--- services/librpc/include/rpcsvc/rwall.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,57 +1,0 @@
-%/*
-% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
-% * unrestricted use provided that this legend is included on all tape
-% * media and as a part of the software program in whole or part.  Users
-% * may copy or modify Sun RPC without charge, but are not authorized
-% * to license or distribute it to anyone else except as part of a product or
-% * program developed by the user or with the express written consent of
-% * Sun Microsystems, Inc.
-% *
-% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
-% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
-% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-% *
-% * Sun RPC is provided with no support and without any obligation on the
-% * part of Sun Microsystems, Inc. to assist in its use, correction,
-% * modification or enhancement.
-% *
-% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
-% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
-% * OR ANY PART THEREOF.
-% *
-% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
-% * or profits or other special, indirect and consequential damages, even if
-% * Sun has been advised of the possibility of such damages.
-% *
-% * Sun Microsystems, Inc.
-% * 2550 Garcia Avenue
-% * Mountain View, California  94043
-% */
-
-%/*
-% * Copyright (c) 1984, 1990 by Sun Microsystems, Inc.
-% */
-%
-%/* from @(#)rwall.x	1.6 91/03/11 TIRPC 1.0 */
-
-#ifdef RPC_HDR
-%
-%#ifndef _rpcsvc_rwall_h
-%#define _rpcsvc_rwall_h
-%
-%typedef char *wrapstring;
-%
-#endif
-
-program WALLPROG {
-	version WALLVERS {
-		void	
-		WALLPROC_WALL(wrapstring) = 2;
-
-	} = 1;
-} = 100008;
-
-#ifdef RPC_HDR
-%
-%#endif /* ! _rpcsvc_rwall_h */
-#endif
Index: rvices/librpc/include/rpcsvc/sm_inter.x
===================================================================
--- services/librpc/include/rpcsvc/sm_inter.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,122 +1,0 @@
-/* @(#)sm_inter.x	2.2 88/08/01 4.0 RPCSRC */
-/* @(#)sm_inter.x 1.7 87/06/24 Copyr 1987 Sun Micro */
-
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Status monitor protocol specification
- * Copyright (C) 1986 Sun Microsystems, Inc.
- *
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/sm_inter.x,v 1.8 1999/08/27 23:45:11 peter Exp $";
-%#endif /* not lint */
-#endif
-
-program SM_PROG { 
-	version SM_VERS  {
-		/* res_stat = stat_succ if status monitor agrees to monitor */
-		/* res_stat = stat_fail if status monitor cannot monitor */
-		/* if res_stat == stat_succ, state = state number of site sm_name */
-		struct sm_stat_res			 SM_STAT(struct sm_name) = 1;
-
-		/* res_stat = stat_succ if status monitor agrees to monitor */
-		/* res_stat = stat_fail if status monitor cannot monitor */
-		/* stat consists of state number of local site */
-		struct sm_stat_res			 SM_MON(struct mon) = 2;
-
-		/* stat consists of state number of local site */
-		struct sm_stat				 SM_UNMON(struct mon_id) = 3;
-
-		/* stat consists of state number of local site */
-		struct sm_stat				 SM_UNMON_ALL(struct my_id) = 4;
-
-		void					 SM_SIMU_CRASH(void) = 5;
-
-	} = 1;
-} = 100024;
-
-const	SM_MAXSTRLEN = 1024;
-
-struct sm_name {
-	string mon_name<SM_MAXSTRLEN>;
-};
-
-struct my_id {
-	string	 my_name<SM_MAXSTRLEN>;		/* name of the site iniates the monitoring request*/
-	int	my_prog;			/* rpc program # of the requesting process */
-	int	my_vers;			/* rpc version # of the requesting process */
-	int	my_proc;			/* rpc procedure # of the requesting process */
-};
-
-struct mon_id {
-	string	mon_name<SM_MAXSTRLEN>;		/* name of the site to be monitored */
-	struct my_id my_id;
-};
-
-
-struct mon{
-	struct mon_id mon_id;
-	opaque priv[16]; 		/* private information to store at monitor for requesting process */
-};
-
-
-/*
- * state # of status monitor monitonically increases each time
- * status of the site changes:
- * an even number (>= 0) indicates the site is down and
- * an odd number (> 0) indicates the site is up;
- */
-struct sm_stat {
-	int state;		/* state # of status monitor */
-};
-
-enum res {
-	stat_succ = 0,		/* status monitor agrees to monitor */
-	stat_fail = 1		/* status monitor cannot monitor */
-};
-
-struct sm_stat_res {
-	res res_stat;
-	int state;
-};
-
-/* 
- * structure of the status message sent back by the status monitor
- * when monitor site status changes
- */
-struct status {
-	string mon_name<SM_MAXSTRLEN>;
-	int state;
-	opaque priv[16];		/* stored private information */
-};
Index: rvices/librpc/include/rpcsvc/spray.x
===================================================================
--- services/librpc/include/rpcsvc/spray.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Spray a server with packets
- * Useful for testing flakiness of network interfaces
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)spray.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/spray.x,v 1.6 1999/08/27 23:45:11 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const SPRAYMAX = 8845;	/* max amount can spray */
-
-/*
- * GMT since 0:00, 1 January 1970
- */
-struct spraytimeval {
-	unsigned int sec;
-	unsigned int usec;
-};
-
-/*
- * spray statistics
- */
-struct spraycumul {
-	unsigned int counter;
-	spraytimeval clock;
-};
-
-/*
- * spray data
- */
-typedef opaque sprayarr<SPRAYMAX>;
-
-program SPRAYPROG {
-	version SPRAYVERS {
-		/*
-		 * Just throw away the data and increment the counter
-		 * This call never returns, so the client should always 
-		 * time it out.
-		 */
-		void
-		SPRAYPROC_SPRAY(sprayarr) = 1;
-
-		/*
-		 * Get the value of the counter and elapsed time  since
-		 * last CLEAR.
-		 */
-		spraycumul	
-		SPRAYPROC_GET(void) = 2;
-
-		/*
-		 * Clear the counter and reset the elapsed time
-		 */
-		void
-		SPRAYPROC_CLEAR(void) = 3;
-	} = 1;
-} = 100012;
Index: rvices/librpc/include/rpcsvc/yp.x
===================================================================
--- services/librpc/include/rpcsvc/yp.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,379 +1,0 @@
-/* @(#)yp.x	2.1 88/08/01 4.0 RPCSRC */
-
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Protocol description file for the Yellow Pages Service
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/yp.x,v 1.12 1999/08/27 23:45:12 peter Exp $";
-%#endif /* not lint */
-#endif
-
-const YPMAXRECORD = 1024;
-const YPMAXDOMAIN = 64;
-const YPMAXMAP = 64;
-const YPMAXPEER = 64;
-
-
-enum ypstat {
-	YP_TRUE		=  1,
-	YP_NOMORE	=  2,
-	YP_FALSE	=  0,
-	YP_NOMAP	= -1,
-	YP_NODOM	= -2,
-	YP_NOKEY	= -3,
-	YP_BADOP	= -4,
-	YP_BADDB	= -5,
-	YP_YPERR	= -6,
-	YP_BADARGS	= -7,
-	YP_VERS		= -8
-};
-
-
-enum ypxfrstat {
-	YPXFR_SUCC	=  1,
-	YPXFR_AGE	=  2,
-	YPXFR_NOMAP	= -1,
-	YPXFR_NODOM	= -2,
-	YPXFR_RSRC	= -3,
-	YPXFR_RPC	= -4,
-	YPXFR_MADDR	= -5,
-	YPXFR_YPERR	= -6,
-	YPXFR_BADARGS	= -7,
-	YPXFR_DBM	= -8,
-	YPXFR_FILE	= -9,
-	YPXFR_SKEW	= -10,
-	YPXFR_CLEAR	= -11,
-	YPXFR_FORCE	= -12,
-	YPXFR_XFRERR	= -13,
-	YPXFR_REFUSED	= -14
-};
-
-
-typedef string domainname<YPMAXDOMAIN>;
-typedef string mapname<YPMAXMAP>;
-typedef string peername<YPMAXPEER>;
-typedef opaque keydat<YPMAXRECORD>;
-typedef opaque valdat<YPMAXRECORD>;
-
-
-struct ypmap_parms {
-	domainname domain;	
-	mapname map;
-	unsigned int ordernum;
-	peername peer;
-};
-
-struct ypreq_key {
-	domainname domain;
-	mapname map;
-	keydat key;
-};
-
-struct ypreq_nokey {
-	domainname domain;	
-	mapname map;
-};
-	
-struct ypreq_xfr {
-	ypmap_parms map_parms;
-	unsigned int transid;
-	unsigned int prog;
-	unsigned int port;
-};
-
-
-struct ypresp_val {
-	ypstat stat;
-	valdat val;
-};
-
-struct ypresp_key_val {
-	ypstat stat;
-#ifdef STUPID_SUN_BUG /* These are backwards */
-	keydat key;
-	valdat val;
-#else
-	valdat val;
-	keydat key;
-#endif
-};
-
-
-struct ypresp_master {
-	ypstat stat;	
-	peername peer;
-};
-
-struct ypresp_order {
-	ypstat stat;
-	unsigned int ordernum;
-};
-
-union ypresp_all switch (bool more) {
-case TRUE:
-	ypresp_key_val val;
-case FALSE:
-	void;
-};
-
-struct ypresp_xfr {
-	unsigned int transid;
-	ypxfrstat xfrstat;
-};
-
-struct ypmaplist {
-	mapname map;
-	ypmaplist *next;
-};
-
-struct ypresp_maplist {
-	ypstat stat;
-	ypmaplist *maps;
-};
-
-enum yppush_status {
-	YPPUSH_SUCC	=  1,	/* Success */
-	YPPUSH_AGE 	=  2,	/* Master's version not newer */
-	YPPUSH_NOMAP	= -1,	/* Can't find server for map */
-	YPPUSH_NODOM	= -2,	/* Domain not supported */
-	YPPUSH_RSRC	= -3,	/* Local resource alloc failure */
-	YPPUSH_RPC	= -4,	/* RPC failure talking to server */
-	YPPUSH_MADDR 	= -5,	/* Can't get master address */
-	YPPUSH_YPERR	= -6,	/* YP server/map db error */
-	YPPUSH_BADARGS	= -7,	/* Request arguments bad */
-	YPPUSH_DBM	= -8,	/* Local dbm operation failed */
-	YPPUSH_FILE	= -9,	/* Local file I/O operation failed */
-	YPPUSH_SKEW	= -10,	/* Map version skew during transfer */
-	YPPUSH_CLEAR	= -11,	/* Can't send "Clear" req to local ypserv */
-	YPPUSH_FORCE	= -12,	/* No local order number in map  use -f flag. */
-	YPPUSH_XFRERR 	= -13,	/* ypxfr error */
-	YPPUSH_REFUSED	= -14 	/* Transfer request refused by ypserv */
-};
-
-struct yppushresp_xfr {
-	unsigned transid;
-	yppush_status status;
-};
-
-/*
- * Response structure and overall result status codes.  Success and failure
- * represent two separate response message types.
- */
- 
-enum ypbind_resptype {
-	YPBIND_SUCC_VAL = 1, 
-	YPBIND_FAIL_VAL = 2
-};
- 
-struct ypbind_binding {
-    opaque ypbind_binding_addr[4]; /* In network order */
-    opaque ypbind_binding_port[2]; /* In network order */
-};   
-
-union ypbind_resp switch (ypbind_resptype ypbind_status) {
-case YPBIND_FAIL_VAL:
-        unsigned ypbind_error;
-case YPBIND_SUCC_VAL:
-        ypbind_binding ypbind_bindinfo;
-};     
-
-/* Detailed failure reason codes for response field ypbind_error*/
- 
-const YPBIND_ERR_ERR    = 1;	/* Internal error */
-const YPBIND_ERR_NOSERV = 2;	/* No bound server for passed domain */
-const YPBIND_ERR_RESC   = 3;	/* System resource allocation failure */
- 
- 
-/*
- * Request data structure for ypbind "Set domain" procedure.
- */
-struct ypbind_setdom {
-	domainname ypsetdom_domain;
-	ypbind_binding ypsetdom_binding;
-	unsigned ypsetdom_vers;
-};
-
-
-/*
- * NIS v1 support for backwards compatibility
- */
-enum ypreqtype {
-	YPREQ_KEY = 1,
-	YPREQ_NOKEY = 2,
-	YPREQ_MAP_PARMS = 3
-};
-
-enum ypresptype {
-	YPRESP_VAL = 1,
-	YPRESP_KEY_VAL = 2,
-	YPRESP_MAP_PARMS = 3
-};
-
-union yprequest switch (ypreqtype yp_reqtype) {
-case YPREQ_KEY:
-	ypreq_key yp_req_keytype;
-case YPREQ_NOKEY:
-	ypreq_nokey yp_req_nokeytype;
-case YPREQ_MAP_PARMS:
-	ypmap_parms yp_req_map_parmstype;
-};
-
-union ypresponse switch (ypresptype yp_resptype) {
-case YPRESP_VAL:
-	ypresp_val yp_resp_valtype;
-case YPRESP_KEY_VAL:
-	ypresp_key_val yp_resp_key_valtype;
-case YPRESP_MAP_PARMS:
-	ypmap_parms yp_resp_map_parmstype;
-};
-
-#if !defined(YPBIND_ONLY) && !defined(YPPUSH_ONLY)
-/*
- * YP access protocol
- */
-program YPPROG {
-/*
- * NIS v1 support for backwards compatibility
- */
-	version YPOLDVERS {
-		void
-		YPOLDPROC_NULL(void) = 0;
-
-		bool
-		YPOLDPROC_DOMAIN(domainname) = 1;
-
-		bool
-		YPOLDPROC_DOMAIN_NONACK(domainname) = 2;
-
-		ypresponse
-		YPOLDPROC_MATCH(yprequest) = 3;
-
-		ypresponse
-		YPOLDPROC_FIRST(yprequest) = 4;
-
-		ypresponse
-		YPOLDPROC_NEXT(yprequest) = 5;
-
-		ypresponse
-		YPOLDPROC_POLL(yprequest) = 6;
-
-		ypresponse
-		YPOLDPROC_PUSH(yprequest) = 7;
-
-		ypresponse
-		YPOLDPROC_PULL(yprequest) = 8;
-
-		ypresponse
-		YPOLDPROC_GET(yprequest) = 9;
-	} = 1;
-
-	version YPVERS {
-		void 
-		YPPROC_NULL(void) = 0;
-
-		bool 
-		YPPROC_DOMAIN(domainname) = 1;	
-
-		bool
-		YPPROC_DOMAIN_NONACK(domainname) = 2;
-
-		ypresp_val
-		YPPROC_MATCH(ypreq_key) = 3;
-
-		ypresp_key_val 
-#ifdef STUPID_SUN_BUG /* should be ypreq_nokey */
-		YPPROC_FIRST(ypreq_key) = 4;
-#else
-		YPPROC_FIRST(ypreq_nokey) = 4;
-#endif
-		ypresp_key_val 
-		YPPROC_NEXT(ypreq_key) = 5;
-
-		ypresp_xfr
-		YPPROC_XFR(ypreq_xfr) = 6;
-
-		void
-		YPPROC_CLEAR(void) = 7;
-
-		ypresp_all
-		YPPROC_ALL(ypreq_nokey) = 8;
-
-		ypresp_master
-		YPPROC_MASTER(ypreq_nokey) = 9;
-
-		ypresp_order
-		YPPROC_ORDER(ypreq_nokey) = 10;
-
-		ypresp_maplist 
-		YPPROC_MAPLIST(domainname) = 11;
-	} = 2;
-} = 100004;
-#endif
-#if !defined(YPSERV_ONLY) && !defined(YPBIND_ONLY)
-/*
- * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR
- */
-program YPPUSH_XFRRESPPROG {
-	version YPPUSH_XFRRESPVERS {
-		void
-		YPPUSHPROC_NULL(void) = 0;
-#ifdef STUPID_SUN_BUG /* argument and return value are backwards */
-		yppushresp_xfr	
-		YPPUSHPROC_XFRRESP(void) = 1;
-#else
-		void
-		YPPUSHPROC_XFRRESP(yppushresp_xfr) = 1;
-#endif
-	} = 1;
-} = 0x40000000;	/* transient: could be anything up to 0x5fffffff */
-#endif
-#if !defined(YPSERV_ONLY) && !defined(YPPUSH_ONLY)
-/*
- * YP binding protocol
- */
-program YPBINDPROG {
-	version YPBINDVERS {
-		void
-		YPBINDPROC_NULL(void) = 0;
-	
-		ypbind_resp
-		YPBINDPROC_DOMAIN(domainname) = 1;
-
-		void
-		YPBINDPROC_SETDOM(ypbind_setdom) = 2;
-	} = 2;
-} = 100007;
-
-#endif
Index: rvices/librpc/include/rpcsvc/yp_prot.h
===================================================================
--- services/librpc/include/rpcsvc/yp_prot.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,332 +1,0 @@
-/*
- * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/include/rpcsvc/yp_prot.h,v 1.10 1999/08/27 23:45:12 peter Exp $
- */
-
-#ifndef _RPCSVC_YP_PROT_H_
-#define _RPCSVC_YP_PROT_H_
-
-/*
- * YPSERV PROTOCOL:
- *
- * ypserv supports the following procedures:
- *
- * YPPROC_NULL		takes (void), returns (void).
- * 			called to check if server is alive.
- * YPPROC_DOMAIN	takes (char *), returns (bool_t).
- * 			true if ypserv serves the named domain.
- * YPPROC_DOMAIN_NOACK	takes (char *), returns (bool_t).
- * 			true if ypserv serves the named domain.
- *			used for broadcasts, does not ack if ypserv
- *			doesn't handle named domain.
- * YPPROC_MATCH		takes (struct ypreq_key), returns (struct ypresp_val)
- * 			does a lookup.
- * YPPROC_FIRST		takes (struct ypreq_nokey) returns (ypresp_key_val).
- * 			gets the first key/datum from the map.
- * YPPROC_NEXT		takes (struct ypreq_key) returns (ypresp_key_val).
- * 			gets the next key/datum from the map.
- * YPPROC_XFR		takes (struct ypreq_xfr), returns (void).
- * 			tells ypserv to check if there is a new version of
- *			the map.
- * YPPROC_CLEAR		takes (void), returns (void).
- * 			tells ypserv to flush it's file cache, so that
- *			newly transferred files will get read.
- * YPPROC_ALL		takes (struct ypreq_nokey), returns (bool_t and
- *			struct ypresp_key_val).
- * 			returns an array of data, with the bool_t being
- * 			false on the last datum. read the source, it's
- *			convoluted.
- * YPPROC_MASTER	takes (struct ypreq_nokey), returns (ypresp_master).
- * YPPROC_ORDER		takes (struct ypreq_nokey), returns (ypresp_order).
- * YPPROC_MAPLIST	takes (char *), returns (struct ypmaplist *).
- */
-
-/* old code
-#ifndef BOOL_DEFINED
-typedef u_int bool;
-#define BOOL_DEFINED
-#endif
-*/
-
-/* Program and version symbols, magic numbers */
-
-#define YPPROG		((u_long)100004)
-#define YPVERS		((u_long)2)
-#define YPVERS_ORIG	((u_long)1)
-#define YPMAXRECORD	((u_long)1024)
-#define YPMAXDOMAIN	((u_long)64)
-#define YPMAXMAP	((u_long)64)
-#define YPMAXPEER	((u_long)256)
-
-/*
- * I don't know if anything of sun's depends on this, or if they
- * simply defined it so that their own code wouldn't try to send
- * packets over the ethernet MTU. This YP code doesn't use it.
- */
-#define YPMSGSZ		1600
-
-#ifndef DATUM
-typedef struct {
-	char	*dptr;
-	int	dsize;
-} datum;
-#define DATUM
-#endif
-
-struct ypmap_parms {
-	char *domain;
-	char *map;
-	u_long ordernum;
-	char *owner;
-};
-
-struct ypreq_key {
-	char *domain;
-	char *map;
-	datum keydat;
-};
-
-struct ypreq_nokey {
-	char *domain;
-	char *map;
-};
-
-struct ypreq_xfr {
-	struct ypmap_parms map_parms;
-	u_long transid;
-	u_long proto;
-	u_short port;
-};
-#define ypxfr_domain	map_parms.domain
-#define ypxfr_map	map_parms.map
-#define ypxfr_ordernum	map_parms.ordernum
-#define ypxfr_owner	map_parms.owner
-
-struct ypresp_val {
-	u_long status;
-	datum valdat;
-};
-
-struct ypresp_key_val {
-	u_long status;
-	datum keydat;
-	datum valdat;
-};
-
-struct ypresp_master {
-	u_long status;
-	char *master;
-};
-
-struct ypresp_order {
-	u_long status;
-	u_long ordernum;
-};
-
-struct ypmaplist {
-	char ypml_name[YPMAXMAP + 1];
-	struct ypmaplist *ypml_next;
-};
-
-struct ypresp_maplist {
-	u_long status;
-	struct ypmaplist *list;
-};
-
-/* ypserv procedure numbers */
-#define YPPROC_NULL		((u_long)0)
-#define YPPROC_DOMAIN		((u_long)1)
-#define YPPROC_DOMAIN_NONACK	((u_long)2)
-#define YPPROC_MATCH		((u_long)3)
-#define YPPROC_FIRST		((u_long)4)
-#define YPPROC_NEXT		((u_long)5)
-#define YPPROC_XFR		((u_long)6)
-#define YPPROC_CLEAR		((u_long)7)
-#define YPPROC_ALL		((u_long)8)
-#define YPPROC_MASTER		((u_long)9)
-#define YPPROC_ORDER		((u_long)10)
-#define YPPROC_MAPLIST		((u_long)11)
-
-/* ypserv procedure return status values */
-#define YP_TRUE	 	((long)1)	/* general purpose success code */
-#define YP_NOMORE 	((long)2)	/* no more entries in map */
-#define YP_FALSE 	((long)0)	/* general purpose failure code */
-#define YP_NOMAP 	((long)-1)	/* no such map in domain */
-#define YP_NODOM 	((long)-2)	/* domain not supported */
-#define YP_NOKEY 	((long)-3)	/* no such key in map */
-#define YP_BADOP 	((long)-4)	/* invalid operation */
-#define YP_BADDB 	((long)-5)	/* server data base is bad */
-#define YP_YPERR 	((long)-6)	/* YP server error */
-#define YP_BADARGS 	((long)-7)	/* request arguments bad */
-#define YP_VERS		((long)-8)	/* YP server version mismatch */
-
-/*
- * Sun's header file says:
- * "Domain binding data structure, used by ypclnt package and ypserv modules.
- * Users of the ypclnt package (or of this protocol) don't HAVE to know about
- * it, but it must be available to users because _yp_dobind is a public
- * interface."
- *
- * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is
- * a public interface, and I don't know any reason anyone would want to call
- * it. But, just in case anyone does actually expect it to be available..
- * we provide this.. exactly as Sun wants it.
- */
-struct dom_binding {
-	struct dom_binding *dom_pnext;
-	char dom_domain[YPMAXDOMAIN + 1];
-	struct sockaddr_in dom_server_addr;
-	u_short dom_server_port;
-	int dom_socket;
-	CLIENT *dom_client;
-	u_short dom_local_port;
-	long dom_vers;
-};
-
-/*
- * YPBIND PROTOCOL:
- *
- * ypbind supports the following procedures:
- *
- * YPBINDPROC_NULL	takes (void), returns (void).
- *			to check if ypbind is running.
- * YPBINDPROC_DOMAIN	takes (char *), returns (struct ypbind_resp).
- *			requests that ypbind start to serve the
- *			named domain (if it doesn't already)
- * YPBINDPROC_SETDOM	takes (struct ypbind_setdom), returns (void).
- *			used by ypset.
- */
-
-#define YPBINDPROG		((u_long)100007)
-#define YPBINDVERS		((u_long)2)
-#define YPBINDVERS_ORIG		((u_long)1)
-
-/* ypbind procedure numbers */
-#define YPBINDPROC_NULL		((u_long)0)
-#define YPBINDPROC_DOMAIN	((u_long)1)
-#define YPBINDPROC_SETDOM	((u_long)2)
-
-/* error code in ypbind_resp.ypbind_status */
-enum ypbind_resptype {
-	YPBIND_SUCC_VAL = 1,
-	YPBIND_FAIL_VAL = 2,
-	_YPBIND_RESPTYPE = 0xffffffff
-};
-
-/* network order, of course */
-struct ypbind_binding {
-	struct in_addr	ypbind_binding_addr;
-	u_short		ypbind_binding_port;
-};
-
-struct ypbind_resp {
-	enum ypbind_resptype	ypbind_status;
-	union {
-		u_long			ypbind_error;
-		struct ypbind_binding	ypbind_bindinfo;
-	} ypbind_respbody;
-};
-
-/* error code in ypbind_resp.ypbind_respbody.ypbind_error */
-#define YPBIND_ERR_ERR		1	/* internal error */
-#define YPBIND_ERR_NOSERV	2	/* no bound server for passed domain */
-#define YPBIND_ERR_RESC		3	/* system resource allocation failure */
-
-/*
- * Request data structure for ypbind "Set domain" procedure.
- */
-struct ypbind_setdom {
-	char ypsetdom_domain[YPMAXDOMAIN + 1];
-	struct ypbind_binding ypsetdom_binding;
-	u_short ypsetdom_vers;
-};
-#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
-#define ypsetdom_port ypsetdom_binding.ypbind_binding_port
-
-/*
- * YPPUSH PROTOCOL:
- *
- * Sun says:
- * "Protocol between clients (ypxfr, only) and yppush
- *  yppush speaks a protocol in the transient range, which
- *  is supplied to ypxfr as a command-line parameter when it
- *  is activated by ypserv."
- *
- * This protocol is not implemented, naturally, because this YP
- * implementation only does the client side.
- */
-#define YPPUSHVERS		((u_long)1)
-#define YPPUSHVERS_ORIG		((u_long)1)
-
-/* yppush procedure numbers */
-#define YPPUSHPROC_NULL		((u_long)0)
-#define YPPUSHPROC_XFRRESP	((u_long)1)
-
-struct yppushresp_xfr {
-	u_long	transid;
-	u_long	status;
-};
-
-/* yppush status value in yppushresp_xfr.status */
-#define YPPUSH_SUCC	((long)1)	/* Success */
-#define YPPUSH_AGE	((long)2)	/* Master's version not newer */
-#define YPPUSH_NOMAP 	((long)-1)	/* Can't find server for map */
-#define YPPUSH_NODOM 	((long)-2)	/* Domain not supported */
-#define YPPUSH_RSRC 	((long)-3)	/* Local resource alloc failure */
-#define YPPUSH_RPC 	((long)-4)	/* RPC failure talking to server */
-#define YPPUSH_MADDR	((long)-5)	/* Can't get master address */
-#define YPPUSH_YPERR 	((long)-6)	/* YP server/map db error */
-#define YPPUSH_BADARGS 	((long)-7)	/* Request arguments bad */
-#define YPPUSH_DBM	((long)-8)	/* Local dbm operation failed */
-#define YPPUSH_FILE	((long)-9)	/* Local file I/O operation failed */
-#define YPPUSH_SKEW	((long)-10)	/* Map version skew during transfer */
-#define YPPUSH_CLEAR	((long)-11)	/* Can't send "Clear" req to local ypserv */
-#define YPPUSH_FORCE	((long)-12)	/* No local order number in map - use -f */
-#define YPPUSH_XFRERR	((long)-13)	/* ypxfr error */
-#define YPPUSH_REFUSED	((long)-14)	/* Transfer request refused by ypserv */
-
-struct inaddr;
-__BEGIN_DECLS
-bool_t	xdr_datum (XDR *, datum *);
-bool_t	xdr_ypreq_key (XDR *, struct ypreq_key *);
-bool_t	xdr_ypreq_nokey (XDR *, struct ypreq_nokey *);
-bool_t	xdr_ypreq_xfr (XDR *, struct ypreq_xfr *);
-bool_t	xdr_ypresp_val (XDR *, struct ypresp_val *);
-bool_t	xdr_ypresp_key_val (XDR *, struct ypresp_key_val *);
-bool_t	xdr_ypbind_resp (XDR *, struct ypbind_resp *);
-bool_t	xdr_ypbind_setdom (XDR *, struct ypbind_setdom *);
-bool_t	xdr_yp_inaddr (XDR *, struct inaddr *);
-bool_t	xdr_ypmap_parms (XDR *, struct ypmap_parms *);
-bool_t	xdr_yppushresp_xfr (XDR *, struct yppushresp_xfr *);
-bool_t	xdr_ypresp_order (XDR *, struct ypresp_order *);
-bool_t	xdr_ypresp_master (XDR *, struct ypresp_master *);
-bool_t	xdr_ypresp_maplist (XDR *, struct ypresp_maplist *);
-__END_DECLS
-
-#endif /* _RPCSVC_YP_PROT_H_ */
Index: rvices/librpc/include/rpcsvc/ypclnt.h
===================================================================
--- services/librpc/include/rpcsvc/ypclnt.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/*
- * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/include/rpcsvc/ypclnt.h,v 1.11 1999/08/27 23:45:12 peter Exp $
- */
-
-#ifndef _RPCSVC_YPCLNT_H_
-#define _RPCSVC_YPCLNT_H_
-
-#include <sys/cdefs.h>
-
-#define YPERR_BADARGS	1		/* args to function are bad */
-#define YPERR_RPC	2		/* RPC failure */
-#define YPERR_DOMAIN	3		/* can't bind to a server for domain */
-#define YPERR_MAP	4		/* no such map in server's domain */
-#define YPERR_KEY	5		/* no such key in map */
-#define YPERR_YPERR	6		/* some internal YP server or client error */
-#define YPERR_RESRC	7		/* local resource allocation failure */
-#define YPERR_NOMORE	8		/* no more records in map database */
-#define YPERR_PMAP	9		/* can't communicate with portmapper */
-#define YPERR_YPBIND	10		/* can't communicate with ypbind */
-#define YPERR_YPSERV	11		/* can't communicate with ypserv */
-#define YPERR_NODOM	12		/* local domain name not set */
-#define YPERR_BADDB	13		/* YP data base is bad */
-#define YPERR_VERS	14		/* YP version mismatch */
-#define YPERR_ACCESS	15		/* access violation */
-#define YPERR_BUSY	16		/* database is busy */
-
-/*
- * Types of update operations
- */
-#define YPOP_CHANGE	1		/* change, do not add */
-#define YPOP_INSERT	2		/* add, do not change */
-#define YPOP_DELETE	3		/* delete this entry */
-#define YPOP_STORE 	4		/* add, or change */
-
-struct ypall_callback {
-	/* return non-0 to stop getting called */
-	int (*foreach) (unsigned long, char *, int, char *, int, void *);
-	char *data;		/* opaque pointer for use of callback fn */
-};
-
-struct dom_binding;
-
-__BEGIN_DECLS
-int	yp_bind		(char *dom);
-int	_yp_dobind	(char *dom, struct dom_binding **ypdb);
-void	yp_unbind	(char *dom);
-int	yp_get_default_domain (char **domp);
-int	yp_match 	(char *indomain, char *inmap,
-			    const char *inkey, int inkeylen, char **outval,
-			    int *outvallen);
-int	yp_first 	(char *indomain, char *inmap,
-			    char **outkey, int *outkeylen, char **outval,
-			    int *outvallen);
-int	yp_next		(char *indomain, char *inmap,
-			    char *inkey, int inkeylen, char **outkey,
-			    int *outkeylen, char **outval, int *outvallen);
-int	yp_master	(char *indomain, char *inmap, char **outname);
-int	yp_order	(char *indomain, char *inmap, int *outorder);
-int	yp_all		(char *indomain, char *inmap,
-			    struct ypall_callback *incallback);
-char *	yperr_string	(int incode);
-char *	ypbinderr_string (int incode);
-int	ypprot_err	(unsigned int incode);
-__END_DECLS
-
-#endif /* _RPCSVC_YPCLNT_H_ */
Index: rvices/librpc/include/rpcsvc/yppasswd.x
===================================================================
--- services/librpc/include/rpcsvc/yppasswd.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,75 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * YP password update protocol
- * Requires unix authentication
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)yppasswd.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/yppasswd.x,v 1.6 1999/08/27 23:45:12 peter Exp $";
-%#endif /* not lint */
-#endif
-
-program YPPASSWDPROG {
-	version YPPASSWDVERS {
-		/*
-		 * Update my passwd entry 
-		 */
-		int
-		YPPASSWDPROC_UPDATE(yppasswd) = 1;
-	} = 1;
-} = 100009;
-
-
-struct x_passwd {
-	string pw_name<>;	/* username */
-	string pw_passwd<>;	/* encrypted password */
-	int pw_uid;		/* user id */
-	int pw_gid;		/* group id */
-	string pw_gecos<>;	/* in real life name */
-	string pw_dir<>;	/* home directory */
-	string pw_shell<>;	/* default shell */
-};
-
-struct yppasswd {
-	string oldpass<>;	/* unencrypted old password */
-	x_passwd newpw;		/* new passwd entry */
-};
-
-
-#ifdef RPC_HDR
-%#include <sys/cdefs.h>
-%extern int _yppasswd ( char * , struct x_passwd * );
-%#define yppasswd(x,y) _yppasswd(x,y)
-#endif
Index: rvices/librpc/include/rpcsvc/ypupdate_prot.x
===================================================================
--- services/librpc/include/rpcsvc/ypupdate_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,88 +1,0 @@
-%/*
-% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
-% * unrestricted use provided that this legend is included on all tape
-% * media and as a part of the software program in whole or part.  Users
-% * may copy or modify Sun RPC without charge, but are not authorized
-% * to license or distribute it to anyone else except as part of a product or
-% * program developed by the user or with the express written consent of
-% * Sun Microsystems, Inc.
-% *
-% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
-% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
-% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-% *
-% * Sun RPC is provided with no support and without any obligation on the
-% * part of Sun Microsystems, Inc. to assist in its use, correction,
-% * modification or enhancement.
-% *
-% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
-% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
-% * OR ANY PART THEREOF.
-% *
-% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
-% * or profits or other special, indirect and consequential damages, even if
-% * Sun has been advised of the possibility of such damages.
-% *
-% * Sun Microsystems, Inc.
-% * 2550 Garcia Avenue
-% * Mountain View, California  94043
-% */
-
-%/*
-% * Copyright (c) 1986, 1990 by Sun Microsystems, Inc.
-% */
-%
-%/* from @(#)ypupdate_prot.x	1.3 91/03/11 TIRPC 1.0 */
-#ifndef RPC_HDR
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/ypupdate_prot.x,v 1.3 1999/08/27 23:45:13 peter Exp $";
-%#endif
-#endif
-%
-%/*
-% * Compiled from ypupdate_prot.x using rpcgen
-% * This is NOT source code!
-% * DO NOT EDIT THIS FILE!
-% */
-
-/*
- * YP update service protocol
- */
-#ifdef RPC_HDR
-%
-%#ifndef _rpcsvc_ypupdate_prot_h
-%#define _rpcsvc_ypupdate_prot_h
-%
-#endif
-
-const MAXMAPNAMELEN = 255;
-const MAXYPDATALEN  = 1023;
-const MAXERRMSGLEN  = 255;
-
-program YPU_PROG {
-	version YPU_VERS {
-		u_int YPU_CHANGE(ypupdate_args) = 1;
-		u_int YPU_INSERT(ypupdate_args) = 2;
-		u_int YPU_DELETE(ypdelete_args) = 3;
-		u_int YPU_STORE(ypupdate_args)  = 4;
-	} = 1;
-} = 100028;
-
-typedef opaque yp_buf<MAXYPDATALEN>;
-
-struct ypupdate_args {
-	string mapname<MAXMAPNAMELEN>;
-	yp_buf key;
-	yp_buf datum;
-};
-
-struct ypdelete_args {
-	string mapname<MAXMAPNAMELEN>;
-	yp_buf key;
-};
-
-#ifdef RPC_HDR
-%
-%#endif /* !_rpcsvc_ypupdate_prot_h */
-#endif
Index: rvices/librpc/include/rpcsvc/ypxfrd.x
===================================================================
--- services/librpc/include/rpcsvc/ypxfrd.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,173 +1,0 @@
-/*
- * Copyright (c) 1995, 1996
- *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/include/rpcsvc/ypxfrd.x,v 1.7 1999/08/27 23:45:13 peter Exp $
- */
-
-/*
- * This protocol definition file describes a file transfer
- * system used to very quickly move NIS maps from one host to
- * another. This is similar to what Sun does with their ypxfrd
- * protocol, but it must be stressed that this protocol is _NOT_
- * compatible with Sun's. There are a couple of reasons for this:
- *
- * 1) Sun's protocol is proprietary. The protocol definition is
- *    not freely available in any of the SunRPC source distributions,
- *    even though the NIS v2 protocol is.
- *
- * 2) The idea here is to transfer entire raw files rather than
- *    sending just the records. Sun uses ndbm for its NIS map files,
- *    while FreeBSD uses Berkeley DB. Both are hash databases, but the
- *    formats are incompatible, making it impossible for them to
- *    use each others' files. Even if FreeBSD adopted ndbm for its
- *    database format, FreeBSD/i386 is a little-endian OS and
- *    SunOS/SPARC is big-endian; ndbm is byte-order sensitive and
- *    not very smart about it, which means an attempt to read a
- *    database on a little-endian box that was created on a big-endian
- *    box (or vice-versa) can cause the ndbm code to eat itself.
- *    Luckily, Berkeley DB is able to deal with this situation in
- *    a more graceful manner.
- *
- * While the protocol is incompatible, the idea is the same: we just open
- * up a TCP pipe to the client and transfer the raw map database 
- * from the master server to the slave. This is many times faster than
- * the standard yppush/ypxfr transfer method since it saves us from
- * having to recreate the map databases via the DB library each time.
- * For example: creating a passwd database with 30,000 entries with yp_mkdb
- * can take a couple of minutes, but to just copy the file takes only a few
- * seconds.
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%static const char rcsid[] =
-%  "$FreeBSD: src/include/rpcsvc/ypxfrd.x,v 1.7 1999/08/27 23:45:13 peter Exp $";
-%#endif /* not lint */
-#endif
-
-/* XXX cribbed from yp.x */
-const _YPMAXRECORD = 1024;
-const _YPMAXDOMAIN = 64;
-const _YPMAXMAP = 64;
-const _YPMAXPEER = 64;
-
-/* Suggested default -- not necesarrily the one used. */
-const YPXFRBLOCK = 32767;
-
-/*
- * Possible return codes from the remote server.
- */
-enum xfrstat {
-	XFR_REQUEST_OK	= 1,	/* Transfer request granted */
-	XFR_DENIED	= 2,	/* Transfer request denied */
-	XFR_NOFILE	= 3,	/* Requested map file doesn't exist */
-	XFR_ACCESS	= 4,	/* File exists, but I couldn't access it */
-	XFR_BADDB	= 5,	/* File is not a hash database */
-	XFR_READ_OK	= 6,	/* Block read successfully */
-	XFR_READ_ERR	= 7,	/* Read error during transfer */
-	XFR_DONE	= 8,	/* Transfer completed */
-	XFR_DB_ENDIAN_MISMATCH	= 9,	/* Database byte order mismatch */
-	XFR_DB_TYPE_MISMATCH	= 10	/* Database type mismatch */
-};
-
-/*
- * Database type specifications. The client can use this to ask
- * the server for a particular type of database or just take whatever
- * the server has to offer.
- */
-enum xfr_db_type {
-	XFR_DB_ASCII		= 1,	/* Flat ASCII text */
-	XFR_DB_BSD_HASH		= 2,	/* Berkeley DB, hash method */
-	XFR_DB_BSD_BTREE	= 3,	/* Berkeley DB, btree method */
-	XFR_DB_BSD_RECNO	= 4,	/* Berkeley DB, recno method */
-	XFR_DB_BSD_MPOOL	= 5,	/* Berkeley DB, mpool method */
-	XFR_DB_BSD_NDBM		= 6,	/* Berkeley DB, hash, ndbm compat */
-	XFR_DB_GNU_GDBM		= 7,	/* GNU GDBM */
-	XFR_DB_DBM		= 8,	/* Old, deprecated dbm format */
-	XFR_DB_NDBM		= 9,	/* ndbm format (used by Sun's NISv2) */
-	XFR_DB_OPAQUE		= 10,	/* Mystery format -- just pass along */
-	XFR_DB_ANY		= 11,	/* I'll take any format you've got */
-	XFR_DB_UNKNOWN		= 12	/* Unknown format */
-};
-
-/*
- * Machine byte order specification. This allows the client to check
- * that it's copying a map database from a machine of similar byte sex.
- * This is necessary for handling database libraries that are fatally
- * byte order sensitive.
- *
- * The XFR_ENDIAN_ANY type is for use with the Berkeley DB database
- * formats; Berkeley DB is smart enough to make up for byte order
- * differences, so byte sex isn't important.
- */
-enum xfr_byte_order {
-	XFR_ENDIAN_BIG		= 1,	/* We want big endian */
-	XFR_ENDIAN_LITTLE	= 2,	/* We want little endian */
-	XFR_ENDIAN_ANY		= 3	/* We'll take whatever you got */
-};
-
-typedef string xfrdomain<_YPMAXDOMAIN>;
-typedef string xfrmap<_YPMAXMAP>;
-typedef string xfrmap_filename<_YPMAXMAP>;	/* actual name of map file */
-
-/*
- * Ask the remote ypxfrd for a map using this structure.
- * Note: we supply both a map name and a map file name. These are not
- * the same thing. In the case of ndbm, maps are stored in two files:
- * map.bykey.pag and may.bykey.dir. We may also have to deal with
- * file extensions (on the off chance that the remote server is supporting
- * multiple DB formats). To handle this, we tell the remote server both
- * what map we want and, in the case of ndbm, whether we want the .dir
- * or the .pag part. This name should not be a fully qualified path:
- * it's up to the remote server to decide which directories to look in.
- */
-struct ypxfr_mapname {
-	xfrmap xfrmap;
-	xfrdomain xfrdomain;
-	xfrmap_filename xfrmap_filename;
-	xfr_db_type xfr_db_type;
-	xfr_byte_order xfr_byte_order;
-};
-
-/* Read response using this structure. */
-union xfr switch (bool ok) {
-case TRUE:
-	opaque xfrblock_buf<>;
-case FALSE:
-	xfrstat xfrstat;
-};
-
-program YPXFRD_FREEBSD_PROG {
-	version YPXFRD_FREEBSD_VERS {
-		union xfr
-		YPXFRD_GETMAP(ypxfr_mapname) = 1;
-	} = 1;
-} = 600100069;	/* 100069 + 60000000 -- 100069 is the Sun ypxfrd prog number */
Index: rvices/librpc/src/rpc/DISCLAIMER
===================================================================
--- services/librpc/src/rpc/DISCLAIMER	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,28 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
Index: rvices/librpc/src/rpc/README
===================================================================
--- services/librpc/src/rpc/README	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,233 +1,0 @@
-RPCSRC 4.0 7/11/89
-
-This distribution contains Sun Microsystem's implementation of the
-RPC and XDR protocols and is compatible with 4.2BSD and 4.3BSD.  Also
-included is complete documentation, utilities, RPC service
-specification files, and demonstration services in the format used by
-the RPC protocol compiler (rpcgen).  See WHAT'S NEW below for
-details.
-
-NOTE ABOUT SECURE RPC:
-
-This release of RPCSRC contains most of the code needed to implement
-Secure RPC (see "DES Authentication" in the RPC Protocol Specification,
-doc/rpc.rfc.ms).  Due to legal considerations, we are unable to
-distribute an implementation of DES, the Data Encryption Standard, which
-Secure RPC requires.  For this reason, all of the files, documentation, and
-programs associated with Secure RPC have been placed into a separate
-directory, secure_rpc.  The RPC library contained in the main body of this
-release *DOES NOT* support Secure RPC.  See secure_rpc/README for more
-details.  (A DES library was posted in Volume 18 of comp.sources.unix.)
-
-If you wish to report bugs found in this release, send mail to:
-
-Portable ONC/NFS
-Sun Microsystems, Inc
-MS 12-33
-2550 Garcia Avenue
-Mountain View, CA  94043
-
-or send Email to nfsnet@sun.com (the Internet) or sun!nfsnet (Usenet).
-
-ROADMAP
-
-The directory hierarchy is as follows:
-
-    demo/       Various demonstration services
-    demo/dir        Remote directory lister
-    demo/msg        Remote console message delivery service
-    demo/sort       Remote sort service
-
-    doc/        Documentation for RPC, XDR and NFS in "-ms" format.
-
-    etc/        Utilities (rpcinfo and portmap).  portmap must be
-                started by root before any other RPC network services are
-                used.  SEE BELOW FOR BUGFIX TO 4.3BSD COMPILER.
-
-    man/        Manual pages for RPC library, rpcgen, and utilities.
-
-    rpc/        The RPC and XDR library.  SEE BELOW
-                FOR BUGFIX TO 4.2BSD COMPILER.
-
-    rpcgen/     The RPC Language compiler (for .x files)
-
-    rpcsvc/     Service definition files for various services and the
-                server and client code for the Remote Status service.
-
-    secure_rpc/ The files in this directory are used to build a version of
-                the RPC library with DES Authentication.  See the README
-                file in that directory for more details.
-
-BUILD INSTRUCTIONS
-
-Makefiles can be found in all directories except for man.  The
-Makefile in the top directory will cause these others to be invoked
-(except for in the doc, man and demo directories), in turn building the
-entire release.
-
-WARNING!  THE DEFAULT INSTALLATION PROCEDURES WILL INSTALL FILES
-IN /usr/include, /usr/lib, /usr/bin and /etc.
-
-The master RPC include file, rpc/rpc.h, is used by all programs and
-routines that use RPC.  It includes other RPC and system include files
-needed by the RPC system.  PLEASE NOTE: If your system has NFS, it
-may have been based on Sun's NFS Source.  The include files installed
-by this package may duplicate include files you will find on your NFS
-system.  The RPCSRC 4.0 include files are upwardly compatible to all
-NFS Source include files as of the date of this distribution (not
-including any new definitions or declarations added by your system
-vendor).  HOWEVER: Please read the comments towards the end of
-rpc/rpc.h regarding rpc/netdb.h.  You may need to uncomment the
-inclusion of that file if the structures it defines are already
-defined by your system's include files.
-
-After making any compiler fixes that are needed (see below), at
-the top directory, type:
-
-    make install
-
-For all installations, the Makefile macro DESTDIR is prepended to the
-installation path.  It is defined to be null in the Makefiles, so
-installations are relative to root.  (You will probably need root
-privileges for installing the files under the default path.)  To
-install the files under some other tree (e.g., /usr/local), use the
-command:
-
-    make install DESTDIR=/usr/local
-
-This will place the include files in /usr/local/usr/include, the RPC
-library in /usr/local/usr/lib, rpcgen in /usr/local/usr/bin, and the
-utilities in /usr/local/etc.  You'll have to edit the Makefiles or
-install the files by hand if you want to do anything other than this
-kind of relocation of the installation tree.
-
-The RPC library will be built and installed first.  By default it is
-installed in /usr/lib as "librpclib.a".  The directory
-/usr/include/rpc will also be created, and several header files will
-be installed there.  ALL RPC SERVICES INCLUDE THESE HEADER FILES.
-
-The programs in etc/ link in routines from librpclib.a.  If you change
-where it is installed, be sure to edit etc/'s Makefile to reflect this.
-These programs are installed in /etc.  PORTMAP MUST BE RUNNING ON
-YOUR SYSTEM BEFORE YOU START ANY OTHER RPC SERVICE.
-
-rpcgen is installed in /usr/bin.  This program is required to build
-the demonstration services in demo and the rstat client and server in
-rpcsvc/.
-
-The rpcsvc/ directory will install its files in the directory
-/usr/include/rpcsvc.  The Remote Status service (rstat_svc) will be
-compiled and installed in /etc.  If you wish to make this service
-available, you should either start this service when needed or have
-it started at boot time by invoking it in your /etc/rc.local script.
-(Be sure that portmap is started first!)  Sun has modified its
-version of inetd to automatically start RPC services.  (Use "make
-LIB=" when building rstat on a Sun Workstation.)  The Remote Status
-client (rstat) will be installed in /usr/bin.  This program queries
-the rstat_svc on a remote host and prints a system status summary
-similar to the one printed by "uptime".
-
-The documentation is not built during the "make install" command.
-Typing "make" in the doc directory will cause all of the manuals to
-be formatted using nroff into a single file.  We have had a report
-that certain "troff" equivalents have trouble processing the full
-manual.  If you have trouble, try building the manuals individually
-(see the Makefile).
-
-The demonstration services in the demo directory are not built by the
-top-level "make install" command.  To build these, cd to the demo
-directory and enter "make".  The three services will be built.
-RPCGEN MUST BE INSTALLED in a path that make can find.  To run the
-services, start the portmap program as root and invoke the service
-(you probably will want to put it in the background).  rpcinfo can be
-used to check that the service succeeded in getting registered with
-portmap, and to ping the service (see rpcinfo's man page).  You can
-then use the corresponding client program to exercise the service.
-To build these services on a Sun workstation, you must prevent the
-Makefile from trying to link the RPC library (as these routines are
-already a part of Sun's libc).  Use: "make LIB=".
-
-BUGFIX FOR 4.3BSD COMPILER
-
-The use of a 'void *' declaration for one of the arguments in
-the reply_proc() procedure in etc/rpcinfo.c will trigger a bug
-in the 4.3BSD compiler.  The bug is fixed by the following change to
-the compiler file mip/manifest.h:
-
-*** manifest.h.r1.1	Thu Apr 30 13:52:25 1987
---- manifest.h.r1.2	Mon Nov 23 18:58:17 1987
-***************
-*** 21,27 ****
-  /*
-   * Bogus type values
-   */
-! #define TNULL	PTR		/* pointer to UNDEF */
-  #define TVOID	FTN		/* function returning UNDEF (for void) */
-  
-  /*
---- 21,27 ----
-  /*
-   * Bogus type values
-   */
-! #define TNULL	INCREF(MOETY)	/* pointer to MOETY -- impossible type */
-  #define TVOID	FTN		/* function returning UNDEF (for void) */
-  
-  /*
-
-If you cannot fix your compiler, change the declaration in reply_proc()
-from 'void *' to 'char *'.
-
-BUGFIX FOR 4.2BSD COMPILER
-
-Unpatched 4.2BSD compilers complain about valid C.  You can make old
-compilers happy by changing some voids to ints.  However, the fix to
-the 4.2 VAX compiler is as follows (to mip/trees.c):
-
-*** trees.c.r1.1	Mon May 11 13:47:58 1987
---- trees.c.r1.2	Wed Jul  2 18:28:52 1986
-***************
-*** 1247,1253 ****
-  		if(o==CAST && mt1==0)return(TYPL+TYMATCH);
-  		if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
-  		else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN );
-! 		else if( mt12 == 0 ) break;
-  		else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN );
-  		else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
-  		break;
---- 1261,1269 ----
-  		if(o==CAST && mt1==0)return(TYPL+TYMATCH);
-  		if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
-  		else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN );
-! 		/* if right is TVOID and looks like a CALL, is not ok */
-! 		else if (mt2 == 0 && (p->in.right->in.op == CALL || p->in.right->in.op == UNARY CALL))
-! 			break;
-  		else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN );
-  		else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
-  		break;
-
-WHAT'S NEW IN THIS RELEASE: RPCSRC 4.0
-
-The previous release was RPCSRC 3.9.  As with all previous releases,
-this release is based directly on files from Sun Microsystem's
-implementation.
-
-Upgrade from RPCSRC 3.9
-
-1)  RPCSRC 4.0 upgrades RPCSRC 3.9.  Improvements from SunOS 4.0 have
-    been integrated into this release.
-
-Secure RPC (in the secure_rpc/ directory)
-
-2)  DES Authentication routines and programs are provided.
-3)  A new manual, "Secure NFS" is provided, which describes Secure RPC
-    and Secure NFS.
-4)  Skeleton routines and manual pages are provided which describe the
-    DES encryption procedures required by Secure RPC.  HOWEVER, NO DES
-    ROUTINE IS PROVIDED.
-
-New Functionality
-
-5)  rpcinfo can now be used to de-register services from the portmapper
-    which may have terminated abnormally.
-6)  A new client, rstat, is provided which queries the rstat_svc and
-    prints a status line similar to the one displayed by "uptime".
Index: rvices/librpc/src/rpc/auth_none.c
===================================================================
--- services/librpc/src/rpc/auth_none.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,137 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)auth_none.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/auth_none.c,v 1.9 1999/08/28 00:00:32 peter Exp $";
-#endif
-
-/*
- * auth_none.c
- * Creates a client authentication handle for passing "null"
- * credentials and verifiers to remote systems.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/auth.h>
-#define MAX_MARSHAL_SIZE 20
-
-/*
- * Authenticator operations routines
- */
-static void	authnone_verf(AUTH*);
-static void	authnone_destroy(AUTH*);
-static int	authnone_marshal(AUTH*, XDR*);
-static int	authnone_validate(AUTH*, struct opaque_auth *);
-static int	authnone_refresh(AUTH*);
-
-static struct auth_ops ops = {
-	authnone_verf,
-	authnone_marshal,
-	authnone_validate,
-	authnone_refresh,
-	authnone_destroy
-};
-
-static struct authnone_private {
-	AUTH	no_client;
-	char	marshalled_client[MAX_MARSHAL_SIZE];
-	u_int	mcnt;
-} *authnone_private;
-
-AUTH *
-authnone_create(void)
-{
-	struct authnone_private *ap = authnone_private;
-	XDR xdr_stream;
-	XDR *xdrs;
-
-	if (ap == 0) {
-		ap = (struct authnone_private *)calloc(1, sizeof (*ap));
-		if (ap == 0)
-			return (0);
-		authnone_private = ap;
-	}
-	if (!ap->mcnt) {
-		ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
-		ap->no_client.ah_ops = &ops;
-		xdrs = &xdr_stream;
-		xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHAL_SIZE,
-		    XDR_ENCODE);
-		(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
-		(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
-		ap->mcnt = XDR_GETPOS(xdrs);
-		XDR_DESTROY(xdrs);
-	}
-	return (&ap->no_client);
-}
-
-/*ARGSUSED*/
-static int
-authnone_marshal(AUTH *client, XDR *xdrs)
-{
-	struct authnone_private *ap = authnone_private;
-
-	if (ap == 0)
-		return (0);
-	return ((*xdrs->x_ops->x_putbytes)(xdrs,
-	    ap->marshalled_client, ap->mcnt));
-}
-
-static void
-authnone_verf(AUTH *client)
-{
-}
-
-static int
-authnone_validate(AUTH *client, struct opaque_auth *opaque)
-{
-
-	return (TRUE);
-}
-
-static int
-authnone_refresh(AUTH *client)
-{
-
-	return (FALSE);
-}
-
-static void
-authnone_destroy(AUTH *client)
-{
-}
Index: rvices/librpc/src/rpc/auth_unix.c
===================================================================
--- services/librpc/src/rpc/auth_unix.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,345 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)auth_unix.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/auth_unix.c,v 1.12 1999/12/29 05:04:16 peter Exp $";
-#endif
-
-/*
- * auth_unix.c, Implements UNIX style authentication parameters.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * The system is very weak.  The client uses no encryption for it's
- * credentials and only sends null verifiers.  The server sends backs
- * null verifiers or optionally a verifier that suggests a new short hand
- * for the credentials.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/param.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/auth.h>
-#include <rpc/auth_unix.h>
-
-/*
- * Unix authenticator operations vector
- */
-static void	authunix_nextverf(AUTH*);
-static int	authunix_marshal(AUTH*, XDR*);
-static int	authunix_validate(AUTH*, struct opaque_auth *);
-static int	authunix_refresh(AUTH*);
-static void	authunix_destroy(AUTH*);
-
-static struct auth_ops auth_unix_ops = {
-	authunix_nextverf,
-	authunix_marshal,
-	authunix_validate,
-	authunix_refresh,
-	authunix_destroy
-};
-
-/*
- * This struct is pointed to by the ah_private field of an auth_handle.
- */
-struct audata {
-	struct opaque_auth	au_origcred;	/* original credentials */
-	struct opaque_auth	au_shcred;	/* short hand cred */
-	u_long			au_shfaults;	/* short hand cache faults */
-	char			au_marshed[MAX_AUTH_BYTES];
-	u_int			au_mpos;	/* xdr pos at end of marshed */
-};
-#define	AUTH_PRIVATE(auth)	((struct audata *)auth->ah_private)
-
-static void marshal_new_auth(AUTH *);
-
-/*
- * This goop is here because some servers refuse to accept a
- * credential with more than some number (usually 8) supplementary
- * groups.  Blargh!
- */
-static int authunix_maxgrouplist = 0;
-
-void
-set_rpc_maxgrouplist(int num)
-{
-	authunix_maxgrouplist = num;
-}
-
-/*
- * Create a unix style authenticator.
- * Returns an auth handle with the given stuff in it.
- */
-AUTH *
-authunix_create(
-	char *machname,
-	int uid,
-	int gid,
-	int len,
-	int *aup_gids)
-{
-	struct authunix_parms aup;
-	char mymem[MAX_AUTH_BYTES];
-	struct timeval now;
-	XDR xdrs;
-	register AUTH *auth;
-	register struct audata *au;
-
-	/*
-	 * Allocate and set up auth handle
-	 */
-	auth = (AUTH *)mem_alloc(sizeof(*auth));
-#ifndef _KERNEL
-	if (auth == NULL) {
-		(void)fprintf(stderr, "authunix_create: out of memory\n");
-		return (NULL);
-	}
-#endif
-	au = (struct audata *)mem_alloc(sizeof(*au));
-#ifndef _KERNEL
-	if (au == NULL) {
-		(void)fprintf(stderr, "authunix_create: out of memory\n");
-		return (NULL);
-	}
-#endif
-	auth->ah_ops = &auth_unix_ops;
-	auth->ah_private = (caddr_t)au;
-	auth->ah_verf = au->au_shcred = _null_auth;
-	au->au_shfaults = 0;
-
-	/*
-	 * fill in param struct from the given params
-	 */
-	(void)gettimeofday(&now,  (struct timezone *)0);
-	aup.aup_time = now.tv_sec;
-	aup.aup_machname = machname;
-	aup.aup_uid = uid;
-	aup.aup_gid = gid;
-	/* GW: continuation of max group list hack */
-	if(authunix_maxgrouplist != 0) {
-		aup.aup_len = ((len < authunix_maxgrouplist) ? len
-			       : authunix_maxgrouplist);
-	} else {
-		aup.aup_len = (u_int)len;
-	}
-	aup.aup_gids = aup_gids;
-
-	/*
-	 * Serialize the parameters into origcred
-	 */
-	xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE);
-	if (! xdr_authunix_parms(&xdrs, &aup))
-		abort();
-	au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs);
-	au->au_origcred.oa_flavor = AUTH_UNIX;
-#ifdef _KERNEL
-	au->au_origcred.oa_base = mem_alloc((u_int) len);
-#else
-	if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) {
-		(void)fprintf(stderr, "authunix_create: out of memory\n");
-		return (NULL);
-	}
-#endif
-	memcpy(au->au_origcred.oa_base, mymem, (u_int)len);
-
-	/*
-	 * set auth handle to reflect new cred.
-	 */
-	auth->ah_cred = au->au_origcred;
-	marshal_new_auth(auth);
-	return (auth);
-}
-
-/*
- * Returns an auth handle with parameters determined by doing lots of
- * syscalls.
- */
-AUTH *
-authunix_create_default(void)
-{
-	register int len;
-	char machname[MAX_MACHINE_NAME + 1];
-	register int uid;
-	register int gid;
-	int gids[NGRPS];
-	int i;
-	gid_t real_gids[NGROUPS];
-
-	if (gethostname(machname, MAX_MACHINE_NAME) == -1)
-		abort();
-	machname[MAX_MACHINE_NAME] = 0;
-	uid = (int)geteuid();
-	gid = (int)getegid();
-	if ((len = getgroups(NGROUPS, real_gids)) < 0)
-		abort();
-	if(len > NGRPS) len = NGRPS; /* GW: turn `gid_t's into `int's */
-	for(i = 0; i < len; i++) {
-		gids[i] = (int)real_gids[i];
-	}
-	return (authunix_create(machname, uid, gid, len, gids));
-}
-
-/*
- * authunix operations
- */
-
-static void
-authunix_nextverf(AUTH *auth)
-{
-	/* no action necessary */
-}
-
-static int
-authunix_marshal(AUTH *auth, XDR *xdrs)
-{
-	struct audata *au = AUTH_PRIVATE(auth);
-
-	return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos));
-}
-
-static int
-authunix_validate( AUTH *auth, struct opaque_auth *verf )
-{
-	register struct audata *au;
-	XDR xdrs;
-
-	if (verf->oa_flavor == AUTH_SHORT) {
-		au = AUTH_PRIVATE(auth);
-		xdrmem_create(&xdrs, verf->oa_base, verf->oa_length, XDR_DECODE);
-
-		if (au->au_shcred.oa_base != NULL) {
-			mem_free(au->au_shcred.oa_base,
-			    au->au_shcred.oa_length);
-			au->au_shcred.oa_base = NULL;
-		}
-		if (xdr_opaque_auth(&xdrs, &au->au_shcred)) {
-			auth->ah_cred = au->au_shcred;
-		} else {
-			xdrs.x_op = XDR_FREE;
-			(void)xdr_opaque_auth(&xdrs, &au->au_shcred);
-			au->au_shcred.oa_base = NULL;
-			auth->ah_cred = au->au_origcred;
-		}
-		marshal_new_auth(auth);
-	}
-	return (TRUE);
-}
-
-static int
-authunix_refresh(AUTH *auth)
-{
-	struct audata *au = AUTH_PRIVATE(auth);
-	struct authunix_parms aup;
-	struct timeval now;
-	XDR xdrs;
-	int stat;
-
-	if (auth->ah_cred.oa_base == au->au_origcred.oa_base) {
-		/* there is no hope.  Punt */
-		return (FALSE);
-	}
-	au->au_shfaults ++;
-
-	/* first deserialize the creds back into a struct authunix_parms */
-	aup.aup_machname = NULL;
-	aup.aup_gids = (int *)NULL;
-	xdrmem_create(&xdrs, au->au_origcred.oa_base,
-	    au->au_origcred.oa_length, XDR_DECODE);
-	stat = xdr_authunix_parms(&xdrs, &aup);
-	if (! stat)
-		goto done;
-
-	/* update the time and serialize in place */
-	(void)gettimeofday(&now, (struct timezone *)0);
-	aup.aup_time = now.tv_sec;
-	xdrs.x_op = XDR_ENCODE;
-	XDR_SETPOS(&xdrs, 0);
-	stat = xdr_authunix_parms(&xdrs, &aup);
-	if (! stat)
-		goto done;
-	auth->ah_cred = au->au_origcred;
-	marshal_new_auth(auth);
-done:
-	/* free the struct authunix_parms created by deserializing */
-	xdrs.x_op = XDR_FREE;
-	(void)xdr_authunix_parms(&xdrs, &aup);
-	XDR_DESTROY(&xdrs);
-	return (stat);
-}
-
-static void
-authunix_destroy(AUTH *auth)
-{
-	struct audata *au = AUTH_PRIVATE(auth);
-
-	mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length);
-
-	if (au->au_shcred.oa_base != NULL)
-		mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length);
-
-	mem_free(auth->ah_private, sizeof(struct audata));
-
-	if (auth->ah_verf.oa_base != NULL)
-		mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length);
-
-	mem_free((caddr_t)auth, sizeof(*auth));
-}
-
-/*
- * Marshals (pre-serializes) an auth struct.
- * sets private data, au_marshed and au_mpos
- */
-static void
-marshal_new_auth(AUTH *auth)
-{
-	XDR		xdr_stream;
-	XDR	*xdrs = &xdr_stream;
-	struct audata *au = AUTH_PRIVATE(auth);
-
-	xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
-	if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) ||
-	    (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) {
-		perror("auth_none.c - Fatal marshalling problem");
-	} else {
-		au->au_mpos = XDR_GETPOS(xdrs);
-	}
-	XDR_DESTROY(xdrs);
-}
Index: rvices/librpc/src/rpc/authunix_prot.c
===================================================================
--- services/librpc/src/rpc/authunix_prot.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,71 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)authunix_prot.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/authunix_prot.c,v 1.6 1999/08/28 00:00:33 peter Exp $";
-#endif
-
-/*
- * authunix_prot.c
- * XDR for UNIX style authentication parameters for RPC
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/auth.h>
-#include <rpc/auth_unix.h>
-
-/*
- * XDR for unix authentication parameters.
- */
-bool_t
-xdr_authunix_parms(
-	XDR *xdrs,
-	struct authunix_parms *p)
-{
-
-	if (xdr_u_long(xdrs, &(p->aup_time))
-	    && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME)
-	    && xdr_int(xdrs, &(p->aup_uid))
-	    && xdr_int(xdrs, &(p->aup_gid))
-	    && xdr_array(xdrs, (caddr_t *)(void *)&(p->aup_gids),
-		    &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t) xdr_int) ) {
-		return (TRUE);
-	}
-	return (FALSE);
-}
Index: rvices/librpc/src/rpc/bindresvport.3
===================================================================
--- services/librpc/src/rpc/bindresvport.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,106 +1,0 @@
-.\" @(#)bindresvport.3n	2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI
-.\" $FreeBSD: src/lib/libc/rpc/bindresvport.3,v 1.10 2000/01/27 02:55:01 bde Exp $
-.\"
-.Dd January 27, 2000
-.Dt BINDRESVPORT 3
-.Os
-.Sh NAME
-.Nm bindresvport ,
-.Nm bindresvport_sa
-.Ndbind a socket to a privileged IP port
-.Sh SYNOPSIS
-.Fd #include <rpc/rpc.h>
-.Ft int
-.Fn bindresvport "int sd" "struct sockaddr_in *sin"
-.Ft int
-.Fn bindresvport_sa "int sd" "struct sockaddr *sa"
-.Sh DESCRIPTION
-.Fn bindresvport
-and
-.Fn bindresvport_sa
-are used to bind a socket descriptor to a privileged
-.Tn IP
-port, that is, a
-port number in the range 0-1023.
-.Pp
-Only root can bind to a privileged port; this call will fail for any
-other users.
-.Pp
-When
-.Va sin
-is not null,
-.Va sin->sin_family
-must be initialized to the address family of the socket, passed by
-.Va sd .
-If the value of sin->sin_port is non-zero
-.Fn bindresvport
-will attempt to use that specific port.  If it fails, it chooses another
-privileged port automatically.
-.Pp
-It is legal to pass null pointer to
-.Va sin .
-In this case, the caller cannot get the port number
-.Fn bindresvport
-has picked.
-.Pp
-Function prototype of
-.Fn bindresvport
-is biased to
-.Dv AF_INET
-socket.
-.Fn bindresvport_sa
-acts exactly the same, with more neutral function prototype.
-Note that both functions behave exactly the same, and
-both support
-.Dv AF_INET6
-sockets as well as
-.Dv AF_INET
-sockets.
-.Sh RETURN VALUES
-.Fn bindresvport
-and
-.Fn bindresvport_sa
-return 0 if they are successful, otherwise \-1 is returned and
-.Va errno
-set to reflect the cause of the error.
-.Sh ERRORS
-The
-.Fn bindresvport
-and
-.Fn bindresvport_sa
-functions fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-.Fa sd
-is not a valid descriptor.
-.It Bq Er ENOTSOCK
-.Fa sd
-is not a socket.
-.It Bq Er EADDRNOTAVAIL
-The specified address is not available from the local machine.
-.It Bq Er EADDRINUSE
-The specified address is already in use.
-.It Bq Er EINVAL
-The socket is already bound to an address,
-or the socket family and the family of specified address mismatch.
-.It Bq Er EACCES
-The requested address is protected, and the current user
-has inadequate permission to access it.
-.It Bq Er EFAULT
-The
-.Fa name
-parameter is not in a valid part of the user
-address space.
-.It Bq Er ENOBUFS
-Insufficient resources were available in the system
-to perform the operation.
-.It Bq Er EPFNOSUPPORT
-The protocol family has not been configured into the
-system, no implementation for it exists,
-or address family did not match between arguments.
-.El
-.Sh "SEE ALSO"
-.Xr bind 2 ,
-.Xr socket 2 ,
-.Xr rresvport 3 ,
-.Xr rresvport_af 3
Index: rvices/librpc/src/rpc/bindresvport.c
===================================================================
--- services/librpc/src/rpc/bindresvport.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,160 +1,0 @@
-/*	$NetBSD: bindresvport.c,v 1.19 2000/07/06 03:03:59 christos Exp $	*/
-
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";*/
-/*static char *sccsid = "from: @(#)bindresvport.c	2.2 88/07/29 4.0 RPCSRC";*/
-/*from: OpenBSD: bindresvport.c,v 1.7 1996/07/30 16:25:47 downsj Exp */
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/bindresvport.c,v 1.12 2000/01/26 09:02:42 shin Exp $";
-#endif
-
-/*
- * Copyright (c) 1987 by Sun Microsystems, Inc.
- *
- * Portions Copyright(C) 1996, Jason Downs.  All rights reserved.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <rpc/rpc.h>
-
-/*
- * Bind a socket to a privileged IP port
- */
-int
-bindresvport(
-	int sd,
-	struct sockaddr_in *sin)
-{
-	return bindresvport_sa(sd, (struct sockaddr *)sin);
-}
-
-/*
- * Bind a socket to a privileged IP port
- */
-int
-bindresvport_sa(
-	int sd,
-	struct sockaddr *sa)
-{
-	int old, error, af;
-	struct sockaddr myaddr;
-	struct sockaddr_in *sin;
-#ifdef INET6
-	struct sockaddr_in6 *sin6;
-#endif
-	int proto, portrange, portlow;
-	u_int16_t port;
-	socklen_t salen;
-
-	if (sa == NULL) {
-		salen = sizeof(myaddr);
-		sa = (struct sockaddr *)&myaddr;
-
-		if (getsockname(sd, sa, &salen) == -1)
-			return -1;	/* errno is correctly set */
-
-		af = sa->sa_family;
-		memset(&myaddr, 0, salen);
-	} else
-		af = sa->sa_family;
-
-	switch (af) {
-	case AF_INET:
-		proto = IPPROTO_IP;
-		portrange = IP_PORTRANGE;
-		portlow = IP_PORTRANGE_LOW;
-		sin = (struct sockaddr_in *)sa;
-		salen = sizeof(struct sockaddr_in);
-		port = sin->sin_port;
-		break;
-#ifdef INET6
-	case AF_INET6:
-		proto = IPPROTO_IPV6;
-		portrange = IPV6_PORTRANGE;
-		portlow = IPV6_PORTRANGE_LOW;
-		sin6 = (struct sockaddr_in6 *)sa;
-		salen = sizeof(struct sockaddr_in6);
-		port = sin6->sin6_port;
-		break;
-#endif
-	default:
-		errno = EPFNOSUPPORT;
-		return (-1);
-	}
-	sa->sa_family = af;
-	sa->sa_len = salen;
-
-	if (port == 0) {
-		socklen_t oldlen = sizeof(old);
-
-		error = getsockopt(sd, proto, portrange, &old, &oldlen);
-		if (error < 0)
-			return (error);
-
-		error = setsockopt(sd, proto, portrange, &portlow,
-		    sizeof(portlow));
-		if (error < 0)
-			return (error);
-	}
-
-	error = bind(sd, sa, salen);
-
-	if (port == 0) {
-		int saved_errno = errno;
-
-		if (error) {
-			if (setsockopt(sd, proto, portrange, &old,
-			    sizeof(old)) < 0)
-				errno = saved_errno;
-			return (error);
-		}
-
-		if (sa != (struct sockaddr *)&myaddr) {
-			/* Hmm, what did the kernel assign? */
-			if (getsockname(sd, sa, &salen) < 0)
-				errno = saved_errno;
-			return (error);
-		}
-	}
-	return (error);
-}
Index: rvices/librpc/src/rpc/clnt_generic.c
===================================================================
--- services/librpc/src/rpc/clnt_generic.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,146 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";*/
-/*static char *sccsid = "from: @(#)clnt_generic.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_generic.c,v 1.9 1999/08/28 00:00:35 peter Exp $";
-#endif
-
-/*
- * Copyright (C) 1987, Sun Microsystems, Inc.
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#include <rpc/rpc.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <netdb.h>
-#include <string.h>
-
-/*
- * Generic client creation: takes (hostname, program-number, protocol) and
- * returns client handle. Default options are set, which the user can
- * change using the rpc equivalent of ioctl()'s.
- */
-CLIENT *
-clnt_create(
-	const char *hostname,
-	rpcprog_t prog,
-	rpcvers_t vers,
-	const char *proto)
-{
-	struct hostent *h;
-	struct protoent *p;
-	struct sockaddr_in sin;
-#ifndef __rtems__
-	struct sockaddr_un sun;
-#endif
-	int sock;
-	struct timeval tv;
-	CLIENT *client;
-
-#ifndef __rtems__
-	if (!strcmp(proto, "unix")) {
-		bzero((char *)&sun, sizeof(sun));
-		sun.sun_family = AF_UNIX;
-		strcpy(sun.sun_path, hostname);
-		sun.sun_len = sizeof(sun.sun_len) + sizeof(sun.sun_family) +
-				strlen(sun.sun_path) + 1;
-		sock = RPC_ANYSOCK;
-		client = clntunix_create(&sun, prog, vers, &sock, 0, 0);
-		if (client == NULL)
-			return(NULL);
-		tv.tv_sec = 25;
-		tv.tv_usec = 0;
-		clnt_control(client, CLSET_TIMEOUT, &tv);
-		return(client);
-	}
-#endif
-
-	h = gethostbyname(hostname);
-	if (h == NULL) {
-		rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
-		return (NULL);
-	}
-	if (h->h_addrtype != AF_INET) {
-		/*
-		 * Only support INET for now
-		 */
-		rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-		rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
-		return (NULL);
-	}
-	memset(&sin, 0, sizeof(sin));
-	sin.sin_len = sizeof(struct sockaddr_in);
-	sin.sin_family = h->h_addrtype;
-	sin.sin_port = 0;
-	memcpy((char*)&sin.sin_addr, h->h_addr, h->h_length);
-	p = getprotobyname(proto);
-	if (p == NULL) {
-		rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
-		rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
-		return (NULL);
-	}
-	sock = RPC_ANYSOCK;
-	switch (p->p_proto) {
-	case IPPROTO_UDP:
-		tv.tv_sec = 5;
-		tv.tv_usec = 0;
-		client = clntudp_create(&sin, prog, vers, tv, &sock);
-		if (client == NULL) {
-			return (NULL);
-		}
-#if 0	/* XXX do we need this? */
-		tv.tv_sec = 25;
-		tv.tv_usec = 0;
-		clnt_control(client, CLSET_TIMEOUT, &tv);
-#endif
-		break;
-	case IPPROTO_TCP:
-		client = clnttcp_create(&sin, prog, vers, &sock, 0, 0);
-		if (client == NULL) {
-			return (NULL);
-		}
-#if 0	/* XXX do we need this? */
-		tv.tv_sec = 25;
-		tv.tv_usec = 0;
-		clnt_control(client, CLSET_TIMEOUT, &tv);
-#endif
-		break;
-	default:
-		rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-		rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
-		return (NULL);
-	}
-	return (client);
-}
Index: rvices/librpc/src/rpc/clnt_perror.c
===================================================================
--- services/librpc/src/rpc/clnt_perror.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,262 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)clnt_perror.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_perror.c,v 1.11 1999/08/28 00:00:35 peter Exp $";
-#endif
-
-/*
- * clnt_perror.c
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#include <rpc/types.h>
-#include <rpc/auth.h>
-#include <rpc/clnt.h>
-#ifdef __rtems__
-#include <rpc/rpc_rtems.h>
-#endif
-
-static char *auth_errmsg(enum auth_stat stat);
-#define CLNT_PERROR_BUFLEN 256
-
-#define buf (rtems_rpc_task_variables->clnt_perror_buf)
-
-static char *
-_buf(void)
-{
-
-	if (buf == 0)
-		buf = (char *)malloc(CLNT_PERROR_BUFLEN);
-	return (buf);
-}
-
-/*
- * Print reply error info
- */
-char *
-clnt_sperror(
-	CLIENT *rpch,
-	const char *s)
-{
-	struct rpc_err e;
-	char *err;
-	char *str = _buf();
-	char *strstart = str;
-
-	if (str == 0)
-		return (0);
-	CLNT_GETERR(rpch, &e);
-
-	(void) sprintf(str, "%s: %s", s, clnt_sperrno(e.re_status));
-	str += strlen(str);
-
-	switch (e.re_status) {
-	case RPC_SUCCESS:
-	case RPC_CANTENCODEARGS:
-	case RPC_CANTDECODERES:
-	case RPC_TIMEDOUT:
-	case RPC_PROGUNAVAIL:
-	case RPC_PROCUNAVAIL:
-	case RPC_CANTDECODEARGS:
-	case RPC_SYSTEMERROR:
-	case RPC_UNKNOWNHOST:
-	case RPC_UNKNOWNPROTO:
-	case RPC_PMAPFAILURE:
-	case RPC_PROGNOTREGISTERED:
-	case RPC_FAILED:
-		break;
-
-	case RPC_CANTSEND:
-	case RPC_CANTRECV:
-		(void) snprintf(str, CLNT_PERROR_BUFLEN - (str - strstart),
-			"; errno = %s\n", strerror(e.re_errno));
-		break;
-
-	case RPC_VERSMISMATCH:
-		(void) sprintf(str,
-			"; low version = %lu, high version = %lu\n",
-			(u_long)e.re_vers.low, (u_long)e.re_vers.high);
-		break;
-
-	case RPC_AUTHERROR:
-		err = auth_errmsg(e.re_why);
-		(void) sprintf(str,"; why = ");
-		str += strlen(str);
-		if (err != NULL) {
-			(void) sprintf(str, "%s\n",err);
-		} else {
-			(void) sprintf(str,
-				"(unknown authentication error - %d)\n",
-				(int) e.re_why);
-		}
-		break;
-
-	case RPC_PROGVERSMISMATCH:
-		(void) sprintf(str,
-			"; low version = %lu, high version = %lu\n",
-			(u_long)e.re_vers.low, (u_long)e.re_vers.high);
-		break;
-
-	default:	/* unknown */
-		(void) sprintf(str,
-			"; s1 = %lu, s2 = %lu\n",
-			(long)e.re_lb.s1, (long)e.re_lb.s2);
-		break;
-	}
-	strstart[CLNT_PERROR_BUFLEN-2] = '\n';
-	strstart[CLNT_PERROR_BUFLEN-1] = '\0';
-	return(strstart) ;
-}
-
-void
-clnt_perror(
-	CLIENT *rpch,
-	const char *s)
-{
-	(void) fprintf(stderr,"%s\n",clnt_sperror(rpch,s));
-}
-
-
-static const char *const rpc_errlist[] = {
-	"RPC: Success",				/*  0 - RPC_SUCCESS */
-	"RPC: Can't encode arguments",		/*  1 - RPC_CANTENCODEARGS */
-	"RPC: Can't decode result",		/*  2 - RPC_CANTDECODERES */
-	"RPC: Unable to send",			/*  3 - RPC_CANTSEND */
-	"RPC: Unable to receive",		/*  4 - RPC_CANTRECV */
-	"RPC: Timed out",			/*  5 - RPC_TIMEDOUT */
-	"RPC: Incompatible versions of RPC",	/*  6 - RPC_VERSMISMATCH */
-	"RPC: Authentication error",		/*  7 - RPC_AUTHERROR */
-	"RPC: Program unavailable",		/*  8 - RPC_PROGUNAVAIL */
-	"RPC: Program/version mismatch",	/*  9 - RPC_PROGVERSMISMATCH */
-	"RPC: Procedure unavailable",		/* 10 - RPC_PROCUNAVAIL */
-	"RPC: Server can't decode arguments",	/* 11 - RPC_CANTDECODEARGS */
-	"RPC: Remote system error",		/* 12 - RPC_SYSTEMERROR */
-	"RPC: Unknown host",			/* 13 - RPC_UNKNOWNHOST */
-	"RPC: Port mapper failure",		/* 14 - RPC_PMAPFAILURE */
-	"RPC: Program not registered",		/* 15 - RPC_PROGNOTREGISTERED */
-	"RPC: Failed (unspecified error)",	/* 16 - RPC_FAILED */
-	"RPC: Unknown protocol"			/* 17 - RPC_UNKNOWNPROTO */
-};
-
-
-/*
- * This interface for use by clntrpc
- */
-char *
-clnt_sperrno(
-	enum clnt_stat stat)
-{
-	unsigned int errnum = stat;
-
-	if (errnum < (sizeof(rpc_errlist)/sizeof(rpc_errlist[0])))
-		return (char *)rpc_errlist[errnum];
-
-	return ("RPC: (unknown error code)");
-}
-
-void
-clnt_perrno(
-	enum clnt_stat num)
-{
-	(void) fprintf(stderr,"%s\n",clnt_sperrno(num));
-}
-
-
-char *
-clnt_spcreateerror(
-	const char *s)
-{
-	char *str = _buf();
-
-	if (str == 0)
-		return(0);
-	switch (rpc_createerr.cf_stat) {
-	case RPC_PMAPFAILURE:
-		(void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s - %s\n", s,
-		    clnt_sperrno(rpc_createerr.cf_stat),
-		    clnt_sperrno(rpc_createerr.cf_error.re_status));
-		break;
-
-	case RPC_SYSTEMERROR:
-		(void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s - %s\n", s,
-		    clnt_sperrno(rpc_createerr.cf_stat),
-		    strerror(rpc_createerr.cf_error.re_errno));
-		break;
-	default:
-		(void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s\n", s,
-		clnt_sperrno(rpc_createerr.cf_stat));
-		break;
-	}
-	str[CLNT_PERROR_BUFLEN-2] = '\n';
-	str[CLNT_PERROR_BUFLEN-1] = '\0';
-	return (str);
-}
-
-void
-clnt_pcreateerror(
-	const char *s)
-{
-	(void) fprintf(stderr,"%s\n",clnt_spcreateerror(s));
-}
-
-static const char *const auth_errlist[] = {
-	"Authentication OK",			/* 0 - AUTH_OK */
-	"Invalid client credential",		/* 1 - AUTH_BADCRED */
-	"Server rejected credential",		/* 2 - AUTH_REJECTEDCRED */
-	"Invalid client verifier",		/* 3 - AUTH_BADVERF */
-	"Server rejected verifier",		/* 4 - AUTH_REJECTEDVERF */
-	"Client credential too weak",		/* 5 - AUTH_TOOWEAK */
-	"Invalid server verifier",		/* 6 - AUTH_INVALIDRESP */
-	"Failed (unspecified error)"		/* 7 - AUTH_FAILED */
-};
-
-static char *
-auth_errmsg(
-	enum auth_stat stat)
-{
-	unsigned int errnum = stat;
-
-	if (errnum < (sizeof(auth_errlist)/sizeof(auth_errlist[0])))
-		return (char *)auth_errlist[errnum];
-
-	return(NULL);
-}
Index: rvices/librpc/src/rpc/clnt_raw.c
===================================================================
--- services/librpc/src/rpc/clnt_raw.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,251 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)clnt_raw.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_raw.c,v 1.10 1999/08/28 00:00:36 peter Exp $";
-#endif
-
-/*
- * clnt_raw.c
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * Memory based rpc for simple testing and timing.
- * Interface to create an rpc client and server in the same process.
- * This lets us similate rpc and get round trip overhead, without
- * any interference from the kernel.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#include <stdlib.h>
-#include <stdio.h>
-#ifdef __rtems__
-#include <rpc/rpc_rtems.h>
-#endif
-
-#define MCALL_MSG_SIZE 24
-
-/*
- * This is the "network" we will be moving stuff over.
- */
-struct clnt_raw_private {
-	CLIENT	client_object;
-	XDR	xdr_stream;
-	char	_raw_buf[UDPMSGSIZE];
-	union {
-	    struct rpc_msg	mashl_rpcmsg;
-	    char 		mashl_callmsg[MCALL_MSG_SIZE];
-	} u;
-	u_int	mcnt;
-};
-#define clntraw_private (rtems_rpc_task_variables->clnt_raw_private)
-
-static enum clnt_stat	clntraw_call(CLIENT *h, rpcproc_t proc, xdrproc_t xargs, void *argsp, xdrproc_t xresults, void *resultsp, struct timeval timeout);
-static void		clntraw_abort(void);
-static void		clntraw_geterr(CLIENT *h, struct rpc_err*);
-static bool_t		clntraw_freeres(CLIENT *, xdrproc_t, void*);
-static bool_t		clntraw_control(CLIENT *, int, char *);
-static void		clntraw_destroy(CLIENT *);
-
-static struct clnt_ops client_ops = {
-	clntraw_call,
-	clntraw_abort,
-	clntraw_geterr,
-	clntraw_freeres,
-	clntraw_destroy,
-	clntraw_control
-};
-
-/*
- * Create a client handle for memory based rpc.
- */
-CLIENT *
-clntraw_create(
-	u_long prog,
-	u_long vers )
-{
-	struct clnt_raw_private *clp = clntraw_private;
-	struct rpc_msg call_msg;
-	XDR *xdrs = &clp->xdr_stream;
-	CLIENT	*client = &clp->client_object;
-
-	if (clp == 0) {
-		clp = (struct clnt_raw_private *)calloc(1, sizeof (*clp));
-		if (clp == 0)
-			return (0);
-		clntraw_private = clp;
-	}
-	/*
-	 * pre-serialize the static part of the call msg and stash it away
-	 */
-	call_msg.rm_direction = CALL;
-	call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
-	call_msg.rm_call.cb_prog = prog;
-	call_msg.rm_call.cb_vers = vers;
-	xdrmem_create(xdrs, clp->u.mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
-	if (! xdr_callhdr(xdrs, &call_msg)) {
-		perror("clnt_raw.c - Fatal header serialization error.");
-	}
-	clp->mcnt = XDR_GETPOS(xdrs);
-	XDR_DESTROY(xdrs);
-
-	/*
-	 * Set xdrmem for client/server shared buffer
-	 */
-	xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE);
-
-	/*
-	 * create client handle
-	 */
-	client->cl_ops = &client_ops;
-	client->cl_auth = authnone_create();
-	return (client);
-}
-
-static enum clnt_stat
-clntraw_call(
-	CLIENT *h,
-	rpcproc_t proc,
-	xdrproc_t xargs,
-	void *argsp,
-	xdrproc_t xresults,
-	void *resultsp,
-	struct timeval timeout )
-{
-	struct clnt_raw_private *clp = clntraw_private;
-	XDR *xdrs = &clp->xdr_stream;
-	struct rpc_msg msg;
-	enum clnt_stat status;
-	struct rpc_err error;
-
-	if (clp == 0)
-		return (RPC_FAILED);
-call_again:
-	/*
-	 * send request
-	 */
-	xdrs->x_op = XDR_ENCODE;
-	XDR_SETPOS(xdrs, 0);
-	clp->u.mashl_rpcmsg.rm_xid ++ ;
-	if ((! XDR_PUTBYTES(xdrs, clp->u.mashl_callmsg, clp->mcnt)) ||
-	    (! XDR_PUTLONG(xdrs, (long *)&proc)) ||
-	    (! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
-	    (! (*xargs)(xdrs, argsp))) {
-		return (RPC_CANTENCODEARGS);
-	}
-	(void)XDR_GETPOS(xdrs);  /* called just to cause overhead */
-
-	/*
-	 * We have to call server input routine here because this is
-	 * all going on in one process. Yuk.
-	 */
-	svc_getreq(1);
-
-	/*
-	 * get results
-	 */
-	xdrs->x_op = XDR_DECODE;
-	XDR_SETPOS(xdrs, 0);
-	msg.acpted_rply.ar_verf = _null_auth;
-	msg.acpted_rply.ar_results.where = resultsp;
-	msg.acpted_rply.ar_results.proc = xresults;
-	if (! xdr_replymsg(xdrs, &msg))
-		return (RPC_CANTDECODERES);
-	_seterr_reply(&msg, &error);
-	status = error.re_status;
-
-	if (status == RPC_SUCCESS) {
-		if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
-			status = RPC_AUTHERROR;
-		}
-	}  /* end successful completion */
-	else {
-		if (AUTH_REFRESH(h->cl_auth, &msg))
-			goto call_again;
-	}  /* end of unsuccessful completion */
-
-	if (status == RPC_SUCCESS) {
-		if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
-			status = RPC_AUTHERROR;
-		}
-		if (msg.acpted_rply.ar_verf.oa_base != NULL) {
-			xdrs->x_op = XDR_FREE;
-			(void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf));
-		}
-	}
-
-	return (status);
-}
-
-static void
-clntraw_geterr(CLIENT *cl, struct rpc_err *err)
-{
-}
-
-
-static bool_t
-clntraw_freeres(
-	CLIENT *cl,
-	xdrproc_t xdr_res,
-	void *res_ptr )
-{
-	struct clnt_raw_private *clp = clntraw_private;
-	XDR *xdrs = &clp->xdr_stream;
-	bool_t rval;
-
-	if (clp == 0)
-	{
-		rval = (bool_t) RPC_FAILED;
-		return (rval);
-	}
-	xdrs->x_op = XDR_FREE;
-	return ((*xdr_res)(xdrs, res_ptr));
-}
-
-static void
-clntraw_abort(void)
-{
-}
-
-static bool_t
-clntraw_control(CLIENT *cl, int request, char *info)
-{
-	return (FALSE);
-}
-
-static void
-clntraw_destroy(CLIENT *cl)
-{
-}
Index: rvices/librpc/src/rpc/clnt_simple.c
===================================================================
--- services/librpc/src/rpc/clnt_simple.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,130 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)clnt_simple.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_simple.c,v 1.12 2000/01/27 23:06:35 jasone Exp $";
-#endif
-
-/*
- * clnt_simple.c
- * Simplified front end to rpc.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/param.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#ifdef __rtems__
-#include <rpc/rpc_rtems.h>
-#endif
-
-struct call_rpc_private {
-	CLIENT	*client;
-	int	socket;
-	int	oldprognum, oldversnum, valid;
-	char	*oldhost;
-};
-#define callrpc_private (rtems_rpc_task_variables->call_rpc_private)
-
-int
-callrpc(
-	const char *host,
-	int prognum, int versnum, int procnum,
-	xdrproc_t inproc, void *in,
-	xdrproc_t outproc, void *out )
-{
-	register struct call_rpc_private *crp = callrpc_private;
-	struct sockaddr_in server_addr;
-	enum clnt_stat clnt_stat;
-	struct hostent *hp;
-	struct timeval timeout, tottimeout;
-
-	if (crp == 0) {
-		crp = (struct call_rpc_private *)calloc(1, sizeof (*crp));
-		if (crp == 0)
-			return (0);
-		callrpc_private = crp;
-	}
-	if (crp->oldhost == NULL) {
-		crp->oldhost = malloc(MAXHOSTNAMELEN);
-		crp->oldhost[0] = 0;
-		crp->socket = RPC_ANYSOCK;
-	}
-	if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum
-		&& strcmp(crp->oldhost, host) == 0) {
-		/* reuse old client */
-	} else {
-		crp->valid = 0;
-		if (crp->socket != -1)
-			(void)_RPC_close(crp->socket);
-		crp->socket = RPC_ANYSOCK;
-		if (crp->client) {
-			clnt_destroy(crp->client);
-			crp->client = NULL;
-		}
-		if ((hp = gethostbyname(host)) == NULL)
-			return ((int) RPC_UNKNOWNHOST);
-		timeout.tv_usec = 0;
-		timeout.tv_sec = 5;
-		memset(&server_addr, 0, sizeof(server_addr));
-		memcpy((char *)&server_addr.sin_addr, hp->h_addr, hp->h_length);
-		server_addr.sin_len = sizeof(struct sockaddr_in);
-		server_addr.sin_family = AF_INET;
-		server_addr.sin_port =  0;
-		if ((crp->client = clntudp_create(&server_addr, (u_long)prognum,
-		    (u_long)versnum, timeout, &crp->socket)) == NULL)
-			return ((int) rpc_createerr.cf_stat);
-		crp->valid = 1;
-		crp->oldprognum = prognum;
-		crp->oldversnum = versnum;
-		(void) strcpy(crp->oldhost, host);
-	}
-	tottimeout.tv_sec = 25;
-	tottimeout.tv_usec = 0;
-	clnt_stat = clnt_call(crp->client, procnum, inproc, in,
-	    outproc, out, tottimeout);
-	/*
-	 * if call failed, empty cache
-	 */
-	if (clnt_stat != RPC_SUCCESS)
-		crp->valid = 0;
-	return ((int) clnt_stat);
-}
Index: rvices/librpc/src/rpc/clnt_tcp.c
===================================================================
--- services/librpc/src/rpc/clnt_tcp.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,608 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)clnt_tcp.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_tcp.c,v 1.14 2000/01/27 23:06:36 jasone Exp $";
-#endif
-
-/*
- * clnt_tcp.c, Implements a TCP/IP based, client side RPC.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * TCP based RPC supports 'batched calls'.
- * A sequence of calls may be batched-up in a send buffer.  The rpc call
- * return immediately to the client even though the call was not necessarily
- * sent.  The batching occurs if the results' xdr routine is NULL (0) AND
- * the rpc timeout value is zero (see clnt.h, rpc).
- *
- * Clients should NOT casually batch calls that in fact return results; that is,
- * the server side should be aware that a call is batched and not produce any
- * return message.  Batched calls that produce many result messages can
- * deadlock (netlock) the client and the server....
- *
- * Now go hang yourself.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <errno.h>
-#include <rpc/pmap_clnt.h>
-#include <sys/select.h>
-
-#define MCALL_MSG_SIZE 24
-
-static int	readtcp(char *, char*, int);
-static int	writetcp(char *, char*, int);
-
-static enum clnt_stat	clnttcp_call(CLIENT *, rpcproc_t, xdrproc_t, void*, xdrproc_t, void*, struct timeval);
-static void		clnttcp_abort(void);
-static void		clnttcp_geterr(CLIENT *, struct rpc_err*);
-static bool_t		clnttcp_freeres(CLIENT *, xdrproc_t, void*);
-static bool_t           clnttcp_control(CLIENT *, int, char *);
-static void		clnttcp_destroy(CLIENT *);
-
-static struct clnt_ops tcp_ops = {
-	clnttcp_call,
-	clnttcp_abort,
-	clnttcp_geterr,
-	clnttcp_freeres,
-	clnttcp_destroy,
-	clnttcp_control
-};
-
-struct ct_data {
-	int		ct_sock;
-	bool_t		ct_closeit;	/* close it on destroy */
-	struct timeval	ct_wait;	/* wait interval in milliseconds */
-	bool_t          ct_waitset;       /* wait set by clnt_control? */
-	struct sockaddr_in ct_addr;
-	struct rpc_err	ct_error;
-	union {
-		char	ct_mcallc[MCALL_MSG_SIZE];	/* marshalled callmsg */
-		u_int32_t ct_mcalli;
-	} ct_u;
-	u_int		ct_mpos;			/* pos after marshal */
-	XDR		ct_xdrs;	/* XDR stream */
-};
-
-/*
- * Create a client handle for a tcp/ip connection.
- * If *sockp<0, *sockp is set to a newly created TCP socket and it is
- * connected to raddr.  If *sockp non-negative then
- * raddr is ignored.  The rpc/tcp package does buffering
- * similar to stdio, so the client must pick send and receive buffer sizes,];
- * 0 => use the default.
- * If raddr->sin_port is 0, then a binder on the remote machine is
- * consulted for the right port number.
- * NB: *sockp is copied into a private area.
- * NB: It is the clients responsibility to close *sockp.
- * NB: The rpch->cl_auth is set null authentication.  Caller may wish to set this
- * something more useful.
- */
-CLIENT *
-clnttcp_create(
-	struct sockaddr_in *raddr,
-	u_long prog,		/* program number */
-	u_long vers,		/* version number */
-	int *sockp,
-	u_int sendsz,
-	u_int recvsz)
-{
-	CLIENT *h;
-	struct ct_data *ct = NULL;	/* client handle */
-	struct timeval now;
-	struct rpc_msg call_msg;
-	static uintptr_t disrupt;
-
-	if (disrupt == 0)
-		disrupt = (uintptr_t)raddr;
-
-	h  = (CLIENT *)mem_alloc(sizeof(*h));
-	if (h == NULL) {
-		(void)fprintf(stderr, "clnttcp_create: out of memory\n");
-		rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-		rpc_createerr.cf_error.re_errno = errno;
-		goto fooy;
-	}
-	ct = (struct ct_data *)mem_alloc(sizeof (*ct));
-	if (ct == NULL) {
-		(void)fprintf(stderr, "clnttcp_create: out of memory\n");
-		rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-		rpc_createerr.cf_error.re_errno = errno;
-		goto fooy;
-	}
-
-	/*
-	 * If no port number given ask the pmap for one
-	 */
-	if (raddr->sin_port == 0) {
-		u_short port;
-		if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) {
-			mem_free((caddr_t)ct, sizeof(struct ct_data));
-			mem_free((caddr_t)h, sizeof(CLIENT));
-			return ((CLIENT *)NULL);
-		}
-		raddr->sin_port = htons(port);
-	}
-
-	/*
-	 * If no socket given, open one
-	 */
-	if (*sockp < 0) {
-		*sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-		(void)bindresvport(*sockp, (struct sockaddr_in *)0);
-		if ((*sockp < 0)
-		    || (connect(*sockp, (struct sockaddr *)raddr,
-		    sizeof(*raddr)) < 0)) {
-			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-			rpc_createerr.cf_error.re_errno = errno;
-			if (*sockp != -1)
-				(void)_RPC_close(*sockp);
-			goto fooy;
-		}
-		ct->ct_closeit = TRUE;
-	} else {
-		ct->ct_closeit = FALSE;
-	}
-
-	/*
-	 * Set up private data struct
-	 */
-	ct->ct_sock = *sockp;
-	ct->ct_wait.tv_usec = 0;
-	ct->ct_waitset = FALSE;
-	ct->ct_addr = *raddr;
-
-	/*
-	 * Initialize call message
-	 */
-	(void)gettimeofday(&now, (struct timezone *)0);
-	call_msg.rm_xid = (++disrupt) ^ getpid() ^ now.tv_sec ^ now.tv_usec;
-	call_msg.rm_direction = CALL;
-	call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
-	call_msg.rm_call.cb_prog = prog;
-	call_msg.rm_call.cb_vers = vers;
-
-	/*
-	 * pre-serialize the static part of the call msg and stash it away
-	 */
-	xdrmem_create(&(ct->ct_xdrs), ct->ct_u.ct_mcallc, MCALL_MSG_SIZE,
-	    XDR_ENCODE);
-	if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
-		if (ct->ct_closeit) {
-			(void)_RPC_close(*sockp);
-		}
-		goto fooy;
-	}
-	ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs));
-	XDR_DESTROY(&(ct->ct_xdrs));
-
-	/*
-	 * Create a client handle which uses xdrrec for serialization
-	 * and authnone for authentication.
-	 */
-	xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz,
-	    (caddr_t)ct, readtcp, writetcp);
-	h->cl_ops = &tcp_ops;
-	h->cl_private = (caddr_t) ct;
-	h->cl_auth = authnone_create();
-	return (h);
-
-fooy:
-	/*
-	 * Something goofed, free stuff and barf
-	 */
-	if (ct)
-		mem_free((caddr_t)ct, sizeof(struct ct_data));
-	if (h)
-		mem_free((caddr_t)h, sizeof(CLIENT));
-	return ((CLIENT *)NULL);
-}
-
-static enum clnt_stat
-clnttcp_call(
-	CLIENT *h,
-	rpcproc_t proc,
-	xdrproc_t xdr_args,
-	void *args_ptr,
-	xdrproc_t xdr_results,
-	void *results_ptr,
-	struct timeval timeout)
-{
-	struct ct_data *ct = (struct ct_data *) h->cl_private;
-	XDR *xdrs = &(ct->ct_xdrs);
-	struct rpc_msg reply_msg;
-	u_int32_t x_id;
-	u_int32_t *msg_x_id = &ct->ct_u.ct_mcalli;	/* yuk */
-	bool_t shipnow;
-	int refreshes = 2;
-
-	if (!ct->ct_waitset) {
-		ct->ct_wait = timeout;
-	}
-
-	shipnow =
-	    (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0
-	    && timeout.tv_usec == 0) ? FALSE : TRUE;
-
-call_again:
-	xdrs->x_op = XDR_ENCODE;
-	ct->ct_error.re_status = RPC_SUCCESS;
-	x_id = ntohl(--(*msg_x_id));
-	if ((! XDR_PUTBYTES(xdrs, ct->ct_u.ct_mcallc, ct->ct_mpos)) ||
-	    (! XDR_PUTLONG(xdrs, (long *)&proc)) ||
-	    (! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
-	    (! (*xdr_args)(xdrs, args_ptr))) {
-		if (ct->ct_error.re_status == RPC_SUCCESS)
-			ct->ct_error.re_status = RPC_CANTENCODEARGS;
-		(void)xdrrec_endofrecord(xdrs, TRUE);
-		return (ct->ct_error.re_status);
-	}
-	if (! xdrrec_endofrecord(xdrs, shipnow)) {
-		return (ct->ct_error.re_status = RPC_CANTSEND);
-	}
-	if (! shipnow) {
-		return (RPC_SUCCESS);
-	}
-	/*
-	 * Hack to provide rpc-based message passing
-	 */
-	if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
-		return(ct->ct_error.re_status = RPC_TIMEDOUT);
-	}
-
-
-	/*
-	 * Keep receiving until we get a valid transaction id
-	 */
-	xdrs->x_op = XDR_DECODE;
-	while (TRUE) {
-		reply_msg.acpted_rply.ar_verf = _null_auth;
-		reply_msg.acpted_rply.ar_results.where = NULL;
-		reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
-		if (! xdrrec_skiprecord(xdrs))
-			return (ct->ct_error.re_status);
-		/* now decode and validate the response header */
-		if (! xdr_replymsg(xdrs, &reply_msg)) {
-			if (ct->ct_error.re_status == RPC_SUCCESS)
-				continue;
-			return (ct->ct_error.re_status);
-		}
-		if (reply_msg.rm_xid == x_id)
-			break;
-	}
-
-	/*
-	 * process header
-	 */
-	_seterr_reply(&reply_msg, &(ct->ct_error));
-	if (ct->ct_error.re_status == RPC_SUCCESS) {
-		if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
-			ct->ct_error.re_status = RPC_AUTHERROR;
-			ct->ct_error.re_why = AUTH_INVALIDRESP;
-		} else if (! (*xdr_results)(xdrs, results_ptr)) {
-			if (ct->ct_error.re_status == RPC_SUCCESS)
-				ct->ct_error.re_status = RPC_CANTDECODERES;
-		}
-		/* free verifier ... */
-		if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
-			xdrs->x_op = XDR_FREE;
-			(void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
-		}
-	}  /* end successful completion */
-	else {
-		/* maybe our credentials need to be refreshed ... */
-		if (refreshes-- && AUTH_REFRESH(h->cl_auth, &reply_msg))
-			goto call_again;
-	}  /* end of unsuccessful completion */
-	return (ct->ct_error.re_status);
-}
-
-static void
-clnttcp_geterr(
-	CLIENT *h,
-	struct rpc_err *errp)
-{
-	struct ct_data *ct;
-
-	ct = (struct ct_data *) h->cl_private;
-	*errp = ct->ct_error;
-}
-
-static bool_t
-clnttcp_freeres(
-	CLIENT *cl,
-	xdrproc_t xdr_res,
-	void *res_ptr)
-{
-	struct ct_data *ct;
-	XDR *xdrs;
-
-	ct = (struct ct_data *)cl->cl_private;
-	xdrs = &(ct->ct_xdrs);
-	
-	xdrs->x_op = XDR_FREE;
-	return ((*xdr_res)(xdrs, res_ptr));
-}
-
-static void
-clnttcp_abort(void)
-{
-}
-
-
-static bool_t
-clnttcp_control(
-	CLIENT *cl,
-	int request,
-	char *info)
-{
-	struct ct_data *ct;
-	struct timeval *tv;
-	socklen_t len;
-	
-	ct = (struct ct_data *)cl->cl_private;
-
-	switch (request) {
-	case CLSET_FD_CLOSE:
-		ct->ct_closeit = TRUE;
-		break;
-	case CLSET_FD_NCLOSE:
-		ct->ct_closeit = FALSE;
-		break;
-	case CLSET_TIMEOUT:
-		if (info == NULL)
-			return(FALSE);
-		tv = (struct timeval *)info;
-		ct->ct_wait.tv_sec = tv->tv_sec;
-		ct->ct_wait.tv_usec = tv->tv_usec;
-		ct->ct_waitset = TRUE;
-		break;
-	case CLGET_TIMEOUT:
-		if (info == NULL)
-			return(FALSE);
-		*(struct timeval *)info = ct->ct_wait;
-		break;
-	case CLGET_SERVER_ADDR:
-		if (info == NULL)
-			return(FALSE);
-		*(struct sockaddr_in *)info = ct->ct_addr;
-		break;
-	case CLGET_FD:
-		if (info == NULL)
-			return(FALSE);
-		*(int *)info = ct->ct_sock;
-		break;
-	case CLGET_XID:
-		/*
-		 * use the knowledge that xid is the
-		 * first element in the call structure
-		 * This will get the xid of the PREVIOUS call
-		 */
-		if (info == NULL)
-			return(FALSE);
-		*(u_int32_t *)info =
-			ntohl(*(u_int32_t *)&ct->ct_u.ct_mcalli);
-		break;
-	case CLSET_XID:
-		/* This will set the xid of the NEXT call */
-		if (info == NULL)
-			return(FALSE);
-		*(u_int32_t *)&ct->ct_u.ct_mcalli =
-			htonl(*((u_int32_t *)info) + 1);
-		/* decrement by 1 as clnttcp_call() increments once */
-	case CLGET_VERS:
-		/*
-		 * This RELIES on the information that, in the call body,
-		 * the version number field is the fifth field from the
-		 * begining of the RPC header. MUST be changed if the
-		 * call_struct is changed
-		 */
-		if (info == NULL)
-			return(FALSE);
-		*(u_int32_t *)info =
-			ntohl(*(u_int32_t *)(ct->ct_u.ct_mcallc +
-						4 * BYTES_PER_XDR_UNIT));
-		break;
-	case CLSET_VERS:
-		if (info == NULL)
-			return(FALSE);
-		*(u_int32_t *)(ct->ct_u.ct_mcallc +
-			4 * BYTES_PER_XDR_UNIT) =
-			htonl(*(u_int32_t *)info);
-		break;
-
-	case CLGET_PROG:
-		/*
-		 * This RELIES on the information that, in the call body,
-		 * the program number field is the fourth field from the
-		 * begining of the RPC header. MUST be changed if the
-		 * call_struct is changed
-		 */
-		if (info == NULL)
-			return(FALSE);
-		*(u_int32_t *)info = ntohl(*(u_int32_t *)(ct->ct_u.ct_mcallc +
-						3 * BYTES_PER_XDR_UNIT));
-		break;
-
-	case CLSET_PROG:
-		if (info == NULL)
-			return(FALSE);
-		*(u_int32_t *)(ct->ct_u.ct_mcallc + 3 * BYTES_PER_XDR_UNIT)
-				= htonl(*(u_int32_t *)info);
-		break;
-
-#ifndef __rtems__
-	/* XXX defined in old.. not new */
-	case CLGET_LOCAL_ADDR:
-		len = sizeof(struct sockaddr);
-		if (getsockname(ct->ct_sock, (struct sockaddr *)info, &len) <0)
-			return(FALSE);
-		break;
-#endif
-
-	case CLGET_RETRY_TIMEOUT:
-	case CLSET_RETRY_TIMEOUT:
-	case CLGET_SVC_ADDR:
-	case CLSET_SVC_ADDR:
-	case CLSET_PUSH_TIMOD:
-	case CLSET_POP_TIMOD:
-	default:
-		return (FALSE);
-	}
-	return (TRUE);
-}
-
-
-static void
-clnttcp_destroy(
-	CLIENT *h)
-{
-	struct ct_data *ct =
-	    (struct ct_data *) h->cl_private;
-
-	if (ct->ct_closeit) {
-		(void)_RPC_close(ct->ct_sock);
-	}
-	XDR_DESTROY(&(ct->ct_xdrs));
-	mem_free(ct, sizeof(struct ct_data));
-	mem_free(h, sizeof(CLIENT));
-}
-
-/*
- * Interface between xdr serializer and tcp connection.
- * Behaves like the system calls, read & write, but keeps some error state
- * around for the rpc level.
- */
-static int
-readtcp(
-	char *_ct,
-	char *buf,
-	int len)
-{
-	struct ct_data *ct = (struct ct_data*) _ct;
-	fd_set *fds, readfds;
-	struct timeval start, after, duration, delta, tmp, tv;
-	int r, save_errno;
-
-	if (len == 0)
-		return (0);
-
-	if (ct->ct_sock + 1 > FD_SETSIZE) {
-		int bytes = howmany(ct->ct_sock + 1, NFDBITS) * sizeof(fd_mask);
-		fds = (fd_set *)malloc(bytes);
-		if (fds == NULL)
-			return (-1);
-		memset(fds, 0, bytes);
-	} else {
-		fds = &readfds;
-		FD_ZERO(fds);
-	}
-
-	gettimeofday(&start, NULL);
-	delta = ct->ct_wait;
-	while (TRUE) {
-		/* XXX we know the other bits are still clear */
-		FD_SET(ct->ct_sock, fds);
-		tv = delta;	/* in case select writes back */
-		r = select(ct->ct_sock+1, fds, NULL, NULL, &tv);
-		save_errno = errno;
-
-		gettimeofday(&after, NULL);
-		timersub(&start, &after, &duration);
-		timersub(&ct->ct_wait, &duration, &tmp);
-		delta = tmp;
-		if (delta.tv_sec < 0 || !timerisset(&delta))
-			r = 0;
-
-		switch (r) {
-		case 0:
-			if (fds != &readfds)
-				free(fds);
-			ct->ct_error.re_status = RPC_TIMEDOUT;
-			return (-1);
-
-		case -1:
-			if (errno == EINTR)
-				continue;
-			if (fds != &readfds)
-				free(fds);
-			ct->ct_error.re_status = RPC_CANTRECV;
-			ct->ct_error.re_errno = save_errno;
-			return (-1);
-		}
-		break;
-	}
-	switch (len = _RPC_read(ct->ct_sock, buf, len)) {
-
-	case 0:
-		/* premature eof */
-		ct->ct_error.re_errno = ECONNRESET;
-		ct->ct_error.re_status = RPC_CANTRECV;
-		len = -1;  /* it's really an error */
-		break;
-
-	case -1:
-		ct->ct_error.re_errno = errno;
-		ct->ct_error.re_status = RPC_CANTRECV;
-		break;
-	}
-	return (len);
-}
-
-static int
-writetcp(
-	char *_ct,
-	char *buf,
-	int len)
-{
-	struct ct_data *ct = (struct ct_data *) _ct;
-	int i, cnt;
-
-	for (cnt = len; cnt > 0; cnt -= i, buf += i) {
-		if ((i = _RPC_write(ct->ct_sock, buf, cnt)) == -1) {
-			ct->ct_error.re_errno = errno;
-			ct->ct_error.re_status = RPC_CANTSEND;
-			return (-1);
-		}
-	}
-	return (len);
-}
Index: rvices/librpc/src/rpc/clnt_udp.c
===================================================================
--- services/librpc/src/rpc/clnt_udp.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,582 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)clnt_udp.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_udp.c,v 1.15 2000/01/27 23:06:36 jasone Exp $";
-#endif
-
-/*
- * clnt_udp.c, Implements a UDP/IP based, client side RPC.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netdb.h>
-#include <errno.h>
-#include <rpc/pmap_clnt.h>
-#include <sys/select.h>
-
-/*
- * UDP bases client side rpc operations
- */
-static enum clnt_stat	clntudp_call(CLIENT *, rpcproc_t, xdrproc_t, void*, xdrproc_t, void*, struct timeval);
-static void		clntudp_abort(void);
-static void		clntudp_geterr(CLIENT *, struct rpc_err*);
-static bool_t		clntudp_freeres(CLIENT *, xdrproc_t, void*);
-static bool_t           clntudp_control(CLIENT *, int, char *);
-static void		clntudp_destroy(CLIENT *);
-
-static struct clnt_ops udp_ops = {
-	clntudp_call,
-	clntudp_abort,
-	clntudp_geterr,
-	clntudp_freeres,
-	clntudp_destroy,
-	clntudp_control
-};
-
-/*
- * Private data kept per client handle
- */
-struct cu_data {
-	int		   cu_sock;
-	bool_t			cu_closeit;	/* opened by library */
-	struct sockaddr_in cu_raddr;
-	int		   cu_rlen;
-	struct timeval		cu_wait;	/* retransmit interval */
-	struct timeval		cu_total;	/* total time for the call */
-	struct rpc_err	   cu_error;
-	XDR		   cu_outxdrs;
-	u_int		   cu_xdrpos;
-	u_int			cu_sendsz;	/* send size */
-	union {
-	  u_int32_t	   *i32;
-	  char		   *c;
-	} _cu_outbuf;
-#define cu_outbuf _cu_outbuf.c
-	u_int			cu_recvsz;	/* recv size */
-	union {
-	  u_int32_t	*i32;
-	  char		c[1];
-	} _cu_inbuf;
-#define cu_inbuf _cu_inbuf.c
-};
-
-/*
- * Create a UDP based client handle.
- * If *sockp<0, *sockp is set to a newly created UPD socket.
- * If raddr->sin_port is 0 a binder on the remote machine
- * is consulted for the correct port number.
- * NB: It is the clients responsibility to close *sockp.
- * NB: The rpch->cl_auth is initialized to null authentication.
- *     Caller may wish to set this something more useful.
- *
- * wait is the amount of time used between retransmitting a call if
- * no response has been heard;  retransmition occurs until the actual
- * rpc call times out.
- *
- * sendsz and recvsz are the maximum allowable packet sizes that can be
- * sent and received.
- */
-CLIENT *
-clntudp_bufcreate(
-	struct sockaddr_in *raddr,
-	u_long program,		/* program number */
-	u_long version,		/* version number */
-	struct timeval wait,
-	int *sockp,
-	u_int sendsz,
-	u_int recvsz)
-{
-	CLIENT *cl = NULL;		/* client handle */
-	struct cu_data *cu = NULL;	/* private data */
-	struct timeval now;
-	struct rpc_msg call_msg;
-	static uintptr_t disrupt;
-
-	if (disrupt == 0)
-		disrupt = (uintptr_t)raddr;
-
-	cl = (CLIENT *)mem_alloc(sizeof(CLIENT));
-	if (cl == NULL) {
-		(void) fprintf(stderr, "clntudp_create: out of memory\n");
-		rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-		rpc_createerr.cf_error.re_errno = errno;
-		goto fooy;
-	}
-	sendsz = ((sendsz + 3) / 4) * 4;
-	recvsz = ((recvsz + 3) / 4) * 4;
-	cu = mem_alloc(sizeof (*cu) + sendsz + recvsz);
-	if (cu == NULL) {
-		(void) fprintf(stderr, "clntudp_create: out of memory\n");
-		rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-		rpc_createerr.cf_error.re_errno = errno;
-		goto fooy;
-	}
-	cu->cu_outbuf = &cu->cu_inbuf[recvsz];
-
-	(void)gettimeofday(&now, (struct timezone *)0);
-	if (raddr->sin_port == 0) {
-		u_short port;
-		if ((port =
-		    pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
-			goto fooy;
-		}
-		raddr->sin_port = htons(port);
-	}
-	cl->cl_ops = &udp_ops;
-	cl->cl_private = (caddr_t)cu;
-	cu->cu_raddr = *raddr;
-	cu->cu_rlen = sizeof (cu->cu_raddr);
-	cu->cu_wait = wait;
-	cu->cu_total.tv_sec = -1;
-	cu->cu_total.tv_usec = -1;
-	cu->cu_sendsz = sendsz;
-	cu->cu_recvsz = recvsz;
-	call_msg.rm_xid = (++disrupt) ^ getpid() ^ now.tv_sec ^ now.tv_usec;
-	call_msg.rm_direction = CALL;
-	call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
-	call_msg.rm_call.cb_prog = program;
-	call_msg.rm_call.cb_vers = version;
-	xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf,
-	    sendsz, XDR_ENCODE);
-	if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) {
-		goto fooy;
-	}
-	cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
-	if (*sockp < 0) {
-		int dontblock = 1;
-
-		*sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-		if (*sockp < 0) {
-			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-			rpc_createerr.cf_error.re_errno = errno;
-			goto fooy;
-		}
-		/* attempt to bind to priv port */
-		(void)bindresvport(*sockp, (struct sockaddr_in *)0);
-		/* the sockets rpc controls are non-blocking */
-		(void)ioctl(*sockp, FIONBIO, (char *) &dontblock);
-		cu->cu_closeit = TRUE;
-	} else {
-		cu->cu_closeit = FALSE;
-	}
-	cu->cu_sock = *sockp;
-	cl->cl_auth = authnone_create();
-	return (cl);
-fooy:
-	if (cu)
-		mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz);
-	if (cl)
-		mem_free((caddr_t)cl, sizeof(CLIENT));
-	return ((CLIENT *)NULL);
-}
-
-CLIENT *
-clntudp_create(
-	struct sockaddr_in *raddr,
-	u_long program,		/* program number */
-	u_long version,		/* version number */
-	struct timeval wait,
-	int *sockp)
-{
-
-	return(clntudp_bufcreate(raddr, program, version, wait, sockp,
-	    UDPMSGSIZE, UDPMSGSIZE));
-}
-
-static enum clnt_stat
-clntudp_call(
-	CLIENT	*cl,			/* client handle */
-	rpcproc_t	proc,		/* procedure number */
-	xdrproc_t	xargs,		/* xdr routine for args */
-	void		*argsp,		/* pointer to args */
-	xdrproc_t	xresults,	/* xdr routine for results */
-	void		*resultsp,	/* pointer to results */
-	struct timeval	utimeout )	/* seconds to wait before giving up */
-{
-	struct cu_data *cu = (struct cu_data *)cl->cl_private;
-	XDR *xdrs;
-	size_t outlen = 0;
-	int inlen;
-	socklen_t fromlen;
-	fd_set *fds, readfds;
-	struct sockaddr_in from;
-	struct rpc_msg reply_msg;
-	XDR reply_xdrs;
-	struct timeval time_waited, start, after, tmp1, tmp2, tv;
-	bool_t ok;
-	int nrefreshes = 2;	/* number of times to refresh cred */
-	struct timeval timeout;
-
-	if (cu->cu_total.tv_usec == -1)
-		timeout = utimeout;     /* use supplied timeout */
-	else
-		timeout = cu->cu_total; /* use default timeout */
-
-	if (cu->cu_sock + 1 > FD_SETSIZE) {
-		int bytes = howmany(cu->cu_sock + 1, NFDBITS) * sizeof(fd_mask);
-		fds = (fd_set *)malloc(bytes);
-		if (fds == NULL)
-			return (cu->cu_error.re_status = RPC_CANTSEND);
-		memset(fds, 0, bytes);
-	} else {
-		fds = &readfds;
-		FD_ZERO(fds);
-	}
-
-	timerclear(&time_waited);
-
-call_again:
-	xdrs = &(cu->cu_outxdrs);
-	xdrs->x_op = XDR_ENCODE;
-	XDR_SETPOS(xdrs, cu->cu_xdrpos);
-	/*
-	 * the transaction is the first thing in the out buffer
-	 */
-	(*(u_short *)(cu->cu_outbuf))++;
-	if ((! XDR_PUTLONG(xdrs, (long *)&proc)) ||
-	    (! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
-	    (! (*xargs)(xdrs, argsp))) {
-		if (fds != &readfds)
-			free(fds);
-		return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
-	}
-	outlen = (size_t)XDR_GETPOS(xdrs);
-
-send_again:
-	if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0,
-	    (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) != outlen) {
-		cu->cu_error.re_errno = errno;
-		if (fds != &readfds)
-			free(fds);
-		return (cu->cu_error.re_status = RPC_CANTSEND);
-	}
-
-	/*
-	 * Hack to provide rpc-based message passing
-	 */
-	if (!timerisset(&timeout)) {
-		if (fds != &readfds)
-			free(fds);
-		return (cu->cu_error.re_status = RPC_TIMEDOUT);
-	}
-	/*
-	 * sub-optimal code appears here because we have
-	 * some clock time to spare while the packets are in flight.
-	 * (We assume that this is actually only executed once.)
-	 */
-	reply_msg.acpted_rply.ar_verf = _null_auth;
-	reply_msg.acpted_rply.ar_results.where = resultsp;
-	reply_msg.acpted_rply.ar_results.proc = xresults;
-
-	gettimeofday(&start, NULL);
-	for (;;) {
-		/* XXX we know the other bits are still clear */
-		FD_SET(cu->cu_sock, fds);
-		tv = cu->cu_wait;
-		switch (select(cu->cu_sock+1, fds, NULL, NULL, &tv)) {
-
-		case 0:
-			timeradd(&time_waited, &cu->cu_wait, &tmp1);
-			time_waited = tmp1;
-			if (timercmp(&time_waited, &timeout, <))
-				goto send_again;
-			if (fds != &readfds)
-				free(fds);
-			return (cu->cu_error.re_status = RPC_TIMEDOUT);
-
-		case -1:
-			if (errno == EINTR) {
-				gettimeofday(&after, NULL);
-				timersub(&after, &start, &tmp1);
-				timeradd(&time_waited, &tmp1, &tmp2);
-				time_waited = tmp2;
-				if (timercmp(&time_waited, &timeout, <))
-					continue;
-				if (fds != &readfds)
-					free(fds);
-				return (cu->cu_error.re_status = RPC_TIMEDOUT);
-			}
-			cu->cu_error.re_errno = errno;
-			if (fds != &readfds)
-				free(fds);
-			return (cu->cu_error.re_status = RPC_CANTRECV);
-		}
-
-		do {
-			fromlen = sizeof(struct sockaddr);
-			inlen = recvfrom(cu->cu_sock, cu->cu_inbuf,
-				(int) cu->cu_recvsz, 0,
-				(struct sockaddr *)&from, &fromlen);
-		} while (inlen < 0 && errno == EINTR);
-		if (inlen < 0) {
-			if (errno == EWOULDBLOCK)
-				continue;
-			cu->cu_error.re_errno = errno;
-			if (fds != &readfds)
-				free(fds);
-			return (cu->cu_error.re_status = RPC_CANTRECV);
-		}
-		if (inlen < sizeof(u_int32_t))
-			continue;
-		/* see if reply transaction id matches sent id */
-		if (*(cu->_cu_inbuf.i32) != *(cu->_cu_outbuf.i32))
-			continue;
-		/* we now assume we have the proper reply */
-		break;
-	}
-
-	/*
-	 * now decode and validate the response
-	 */
-	xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE);
-	ok = xdr_replymsg(&reply_xdrs, &reply_msg);
-	/* XDR_DESTROY(&reply_xdrs);  save a few cycles on noop destroy */
-	if (ok) {
-		_seterr_reply(&reply_msg, &(cu->cu_error));
-		if (cu->cu_error.re_status == RPC_SUCCESS) {
-			if (! AUTH_VALIDATE(cl->cl_auth,
-				&reply_msg.acpted_rply.ar_verf)) {
-				cu->cu_error.re_status = RPC_AUTHERROR;
-				cu->cu_error.re_why = AUTH_INVALIDRESP;
-			}
-			if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
-				xdrs->x_op = XDR_FREE;
-				(void)xdr_opaque_auth(xdrs,
-				    &(reply_msg.acpted_rply.ar_verf));
-			}
-		}  /* end successful completion */
-		else {
-			/* maybe our credentials need to be refreshed ... */
-			if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth, &reply_msg)) {
-				nrefreshes--;
-				goto call_again;
-			}
-		}  /* end of unsuccessful completion */
-	}  /* end of valid reply message */
-	else {
-		/*
-		 * It's possible for xdr_replymsg() to fail partway
-		 * through its attempt to decode the result from the
-		 * server. If this happens, it will leave the reply
-		 * structure partially populated with dynamically
-		 * allocated memory. (This can happen if someone uses
-		 * clntudp_bufcreate() to create a CLIENT handle and
-		 * specifies a receive buffer size that is too small.)
-		 * This memory must be free()ed to avoid a leak.
-		 */
-		int op = reply_xdrs.x_op;
-		reply_xdrs.x_op = XDR_FREE;
-		xdr_replymsg(&reply_xdrs, &reply_msg);
-		reply_xdrs.x_op = op;
-		cu->cu_error.re_status = RPC_CANTDECODERES;
-	}
-	if (fds != &readfds)
-		free(fds);
-	return (cu->cu_error.re_status);
-}
-
-static void
-clntudp_geterr(
-	CLIENT *cl,
-	struct rpc_err *errp)
-{
-	struct cu_data *cu = (struct cu_data *)cl->cl_private;
-
-	*errp = cu->cu_error;
-}
-
-
-static bool_t
-clntudp_freeres(
-	CLIENT *cl,
-	xdrproc_t xdr_res,
-	void *res_ptr)
-{
-	struct cu_data *cu = (struct cu_data *)cl->cl_private;
-	XDR *xdrs = &(cu->cu_outxdrs);
-
-	xdrs->x_op = XDR_FREE;
-	return ((*xdr_res)(xdrs, res_ptr));
-}
-
-static void
-clntudp_abort(void)
-{
-}
-
-
-static bool_t
-clntudp_control(
-	CLIENT *cl,
-	int request,
-	char *info)
-{
-	struct cu_data *cu = (struct cu_data *)cl->cl_private;
-	struct timeval *tv;
-	socklen_t len;
-
-	switch (request) {
-	case CLSET_FD_CLOSE:
-		cu->cu_closeit = TRUE;
-		break;
-	case CLSET_FD_NCLOSE:
-		cu->cu_closeit = FALSE;
-		break;
-	case CLSET_TIMEOUT:
-		if (info == NULL)
-			return(FALSE);
-		tv = (struct timeval *)info;
-		cu->cu_total.tv_sec = tv->tv_sec;
-		cu->cu_total.tv_usec = tv->tv_usec;
-		break;
-	case CLGET_TIMEOUT:
-		if (info == NULL)
-			return(FALSE);
-		*(struct timeval *)info = cu->cu_total;
-		break;
-	case CLSET_RETRY_TIMEOUT:
-		if (info == NULL)
-			return(FALSE);
-		tv = (struct timeval *)info;
-		cu->cu_wait.tv_sec = tv->tv_sec;
-		cu->cu_wait.tv_usec = tv->tv_usec;
-		break;
-	case CLGET_RETRY_TIMEOUT:
-		if (info == NULL)
-			return(FALSE);
-		*(struct timeval *)info = cu->cu_wait;
-		break;
-	case CLGET_SERVER_ADDR:
-		if (info == NULL)
-			return(FALSE);
-		*(struct sockaddr_in *)info = cu->cu_raddr;
-		break;
-	case CLGET_FD:
-		if (info == NULL)
-			return(FALSE);
-		*(int *)info = cu->cu_sock;
-		break;
-	case CLGET_XID:
-		/*
-		 * use the knowledge that xid is the
-		 * first element in the call structure *.
-		 * This will get the xid of the PREVIOUS call
-		 */
-		if (info == NULL)
-			return(FALSE);
-		*(u_long *)info = ntohl(*(u_long *)cu->cu_outbuf);
-		break;
-	case CLSET_XID:
-		/* This will set the xid of the NEXT call */
-		if (info == NULL)
-			return(FALSE);
-		*(u_long *)cu->cu_outbuf =  htonl(*(u_long *)info - 1);
-		/* decrement by 1 as clntudp_call() increments once */
-	case CLGET_VERS:
-		/*
-		 * This RELIES on the information that, in the call body,
-		 * the version number field is the fifth field from the
-		 * begining of the RPC header. MUST be changed if the
-		 * call_struct is changed
-		 */
-		if (info == NULL)
-			return(FALSE);
-		*(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
-						4 * BYTES_PER_XDR_UNIT));
-		break;
-	case CLSET_VERS:
-		if (info == NULL)
-			return(FALSE);
-		*(u_long *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT)
-				= htonl(*(u_long *)info);
-		break;
-	case CLGET_PROG:
-		/*
-		 * This RELIES on the information that, in the call body,
-		 * the program number field is the fourth field from the
-		 * begining of the RPC header. MUST be changed if the
-		 * call_struct is changed
-		 */
-		if (info == NULL)
-			return(FALSE);
-		*(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
-						3 * BYTES_PER_XDR_UNIT));
-		break;
-	case CLSET_PROG:
-		if (info == NULL)
-			return(FALSE);
-		*(u_long *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT)
-				= htonl(*(u_long *)info);
-		break;
-#ifndef __rtems__
-	/* XXX defined in old.. not new */
-	case CLGET_LOCAL_ADDR:
-		len = sizeof(struct sockaddr);
-		if (getsockname(cu->cu_sock, (struct sockaddr *)info, &len) <0)
-			return(FALSE);
-		break;
-#endif
-	case CLGET_SVC_ADDR:
-	case CLSET_SVC_ADDR:
-	case CLSET_PUSH_TIMOD:
-	case CLSET_POP_TIMOD:
-	default:
-		return (FALSE);
-	}
-	return (TRUE);
-}
-
-static void
-clntudp_destroy(
-	CLIENT *cl)
-{
-	struct cu_data *cu = (struct cu_data *)cl->cl_private;
-
-	if (cu->cu_closeit) {
-		(void)_RPC_close(cu->cu_sock);
-	}
-	XDR_DESTROY(&(cu->cu_outxdrs));
-	mem_free(cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz));
-	mem_free(cl, sizeof (CLIENT));
-}
Index: rvices/librpc/src/rpc/des_crypt.3
===================================================================
--- services/librpc/src/rpc/des_crypt.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,130 +1,0 @@
-.\" @(#)des_crypt.3	2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI;
-.\" $FreeBSD: src/lib/libc/rpc/des_crypt.3,v 1.4 2000/03/02 09:13:45 sheldonh Exp $
-.\"
-.TH DES_CRYPT 3  "6 October 1987"
-.SH NAME
-des_crypt, ecb_crypt, cbc_crypt, des_setparity \- fast DES encryption
-.SH SYNOPSIS
-.nf
-.B #include <des_crypt.h>
-.LP
-.B int ecb_crypt(key, data, datalen, mode)
-.B char *key;
-.B char *data;
-.B unsigned datalen;
-.B unsigned mode;
-.LP
-.B int cbc_crypt(key, data, datalen, mode, ivec)
-.B char *key;
-.B char *data;
-.B unsigned datalen;
-.B unsigned mode;
-.B char *ivec;
-.LP
-.B void des_setparity(key)
-.B char *key;
-.fi
-.SH DESCRIPTION
-.IX encryption cbc_crypt "" \fLcbc_crypt\fP
-.IX "des encryption" cbc_crypt "DES encryption" \fLcbc_crypt\fP
-.IX encryption des_setparity "" \fLdes_setparity\fP
-.IX "des encryption" des_setparity "DES encryption" \fLdes_setparity\fP
-.B ecb_crypt(\|)
-and
-.B cbc_crypt(\|)
-implement the
-.SM NBS
-.SM DES
-(Data Encryption Standard).
-These routines are faster and more general purpose than
-.BR crypt (3).
-They also are able to utilize
-.SM DES
-hardware if it is available.
-.B ecb_crypt(\|)
-encrypts in
-.SM ECB
-(Electronic Code Book)
-mode, which encrypts blocks of data independently.
-.B cbc_crypt(\|)
-encrypts in
-.SM CBC
-(Cipher Block Chaining)
-mode, which chains together
-successive blocks.
-.SM CBC
-mode protects against insertions, deletions and
-substitutions of blocks.
-Also, regularities in the clear text will
-not appear in the cipher text.
-.LP
-Here is how to use these routines.  The first parameter,
-.IR key ,
-is the 8-byte encryption key with parity.
-To set the key's parity, which for
-.SM DES
-is in the low bit of each byte, use
-.IR des_setparity .
-The second parameter,
-.IR data ,
-contains the data to be encrypted or decrypted.
-The
-third parameter,
-.IR datalen ,
-is the length in bytes of
-.IR data ,
-which must be a multiple of 8. The fourth parameter,
-.IR mode ,
-is formed by
-.SM OR\s0'ing
-together some things.  For the encryption direction 'or' in either
-.SM DES_ENCRYPT
-or
-.SM DES_DECRYPT\s0.
-For software versus hardware
-encryption, 'or' in either
-.SM DES_HW
-or
-.SM DES_SW\s0.
-If
-.SM DES_HW
-is specified, and there is no hardware, then the encryption is performed
-in software and the routine returns
-.SM DESERR_NOHWDEVICE\s0.
-For
-.IR cbc_crypt ,
-the parameter
-.I ivec
-is the the 8-byte initialization
-vector for the chaining.  It is updated to the next initialization
-vector upon return.
-.LP
-.SH "SEE ALSO"
-.BR des (1),
-.BR crypt (3)
-.SH DIAGNOSTICS
-.PD 0
-.TP 20
-.SM DESERR_NONE
-No error.
-.TP
-.SM DESERR_NOHWDEVICE
-Encryption succeeded, but done in software instead of the requested hardware.
-.TP
-.SM DESERR_HWERR
-An error occurred in the hardware or driver.
-.TP
-.SM DESERR_BADPARAM
-Bad parameter to routine.
-.PD
-.LP
-Given a result status
-.IR stat ,
-the macro
-.SM DES_FAILED\c
-.BR ( stat )
-is false only for the first two statuses.
-.SH RESTRICTIONS
-These routines are not available in RPCSRC 4.0.
-This information is provided to describe the DES interface expected by
-Secure RPC.
Index: rvices/librpc/src/rpc/get_myaddress.c
===================================================================
--- services/librpc/src/rpc/get_myaddress.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,122 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)get_myaddress.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/get_myaddress.c,v 1.17 2000/01/27 23:06:37 jasone Exp $";
-#endif
-
-/*
- * get_myaddress.c
- *
- * Get client's IP address via ioctl.  This avoids using the yellowpages.
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/pmap_prot.h>
-#include <sys/socket.h>
-#include <stdio.h>
-#include <unistd.h>
-#ifndef __rtems__
-	/* XXX old.. not new */
-	#include <sys/mbuf.h>
-#else
-	#include <freebsd/sys/mbuf.h>
-#endif
-#include <net/if.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-/*
- * don't use gethostbyname, which would invoke yellow pages
- *
- * Avoid loopback interfaces.  We return information from a loopback
- * interface only if there are no other possible interfaces.
- */
-int
-get_myaddress(
-	struct sockaddr_in *addr)
-{
-	int s;
-	char buf[BUFSIZ];
-	struct ifconf ifc;
-	struct ifreq ifreq, *ifr, *end;
-	int loopback = 0, gotit = 0;
-
-	if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-		return(-1);
-	}
-	ifc.ifc_len = sizeof (buf);
-	ifc.ifc_buf = buf;
-	if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
-		_RPC_close(s);
-		return(-1);
-	}
-again:
-	ifr = ifc.ifc_req;
-	end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-
-	while (ifr < end) {
-		ifreq = *ifr;
-		if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
-			_RPC_close(s);
-			return(-1);
-		}
-		if (((ifreq.ifr_flags & IFF_UP) &&
-		    ifr->ifr_addr.sa_family == AF_INET &&
-			!(ifreq.ifr_flags & IFF_LOOPBACK)) ||
-		    (loopback == 1 && (ifreq.ifr_flags & IFF_LOOPBACK)
-			&& (ifr->ifr_addr.sa_family == AF_INET)
-			&& (ifreq.ifr_flags &  IFF_UP))) {
-			*addr = *((struct sockaddr_in *)&ifr->ifr_addr);
-			addr->sin_port = htons(PMAPPORT);
-			gotit = 1;
-			break;
-		}
-		if (ifr->ifr_addr.sa_len)
-			ifr = (struct ifreq *) ((caddr_t) ifr +
-			      ifr->ifr_addr.sa_len -
-			      sizeof(struct sockaddr));
-		ifr++;
-	}
-	if (gotit == 0 && loopback == 0) {
-		loopback = 1;
-		goto again;
-	}
-	(void)_RPC_close(s);
-	return (gotit ? 0 : -1);
-}
Index: rvices/librpc/src/rpc/getrpcent.3
===================================================================
--- services/librpc/src/rpc/getrpcent.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,98 +1,0 @@
-.\" @(#)getrpcent.3n	2.2 88/08/02 4.0 RPCSRC; from 1.11 88/03/14 SMI
-.\" $FreeBSD: src/lib/libc/rpc/getrpcent.3,v 1.11 1999/08/28 00:00:39 peter Exp $
-.\"
-.Dd December 14, 1987
-.Dt GETRPCENT 3
-.Os
-.Sh NAME
-.Nm getrpcent ,
-.Nm getrpcbyname ,
-.Nm getrpcbynumber ,
-.Nm endrpcent ,
-.Nm setrpcent
-.Nd get RPC entry
-.Sh SYNOPSIS
-.Fd #include <rpc/rpc.h>
-.Ft struct rpcent *
-.Fn getrpcent void
-.Ft struct rpcent *
-.Fn getrpcbyname "char *name"
-.Ft struct rpcent *
-.Fn getrpcbynumber "int number"
-.Ft void
-.Fn setrpcent "int stayopen"
-.Ft void
-.Fn endrpcent void
-.Sh DESCRIPTION
-The
-.Fn getrpcent ,
-.Fn getrpcbyname ,
-and
-.Fn getrpcbynumber
-functions each return a pointer to an object with the
-following structure
-containing the broken-out
-fields of a line in the rpc program number data base,
-.Pa /etc/rpc .
-.Bd -literal
-
-struct	rpcent {
-	char	*r_name;	/* name of server for this rpc program */
-	char	**r_aliases;	/* alias list */
-	long	r_number;	/* rpc program number */
-};
-.Ed
-.Pp
-The members of this structure are:
-.Bl -tag -width r_aliasesxxx
-.It Fa r_name
-The name of the server for this rpc program.
-.It Fa r_aliases
-A zero terminated list of alternate names for the rpc program.
-.It Fa r_number
-The rpc program number for this service.
-.El
-.Pp
-The
-.Fn getrpcent
-function reads the next line of the file, opening the file if necessary.
-The
-.Nm getrpcent
-function opens and rewinds the file.  If the
-.Fa stayopen
-flag is non-zero,
-the net data base will not be closed after each call to
-.Fn getrpcent
-(either directly, or indirectly through one of
-the other 
-.Fn getrpcent
-function family.
-.Pp
-.Fn endrpcent
-closes the file.
-.Pp
-.Fn getrpcbyname
-and
-.Fn getrpcbynumber
-sequentially search from the beginning
-of the file until a matching rpc program name or
-program number is found, or until end-of-file is encountered.
-.Sh FILES
-.Bl -tag -width /etc/rpc -compact
-.It Pa /etc/rpc
-.El
-.Sh "SEE ALSO"
-.Xr rpc 5 ,
-.Xr rpcinfo 8 ,
-.Xr ypserv 8
-.Sh DIAGNOSTICS
-A
-.Dv NULL
-pointer is returned on 
-.Dv EOF
-or error.
-.Sh BUGS
-All information
-is contained in a static area
-so it must be copied if it is
-to be saved.
Index: rvices/librpc/src/rpc/getrpcent.c
===================================================================
--- services/librpc/src/rpc/getrpcent.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,301 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user or with the express written consent of
- * Sun Microsystems, Inc.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getrpcent.c 1.14 91/03/11 Copyr 1984 Sun Micro";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/getrpcent.c,v 1.10 1999/08/28 00:00:39 peter Exp $";
-#endif
-
-/*
- * Copyright (c) 1984 by Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#ifdef YP
-#include <rpcsvc/yp_prot.h>
-#include <rpcsvc/ypclnt.h>
-#endif
-
-/*
- * Internet version.
- */
-struct rpcdata {
-	FILE	*rpcf;
-	int	stayopen;
-#define	MAXALIASES	35
-	char	*rpc_aliases[MAXALIASES];
-	struct	rpcent rpc;
-	char	line[BUFSIZ+1];
-#ifdef	YP
-	char	*domain;
-	char	*current;
-	int	currentlen;
-#endif
-} *rpcdata;
-
-#ifdef	YP
-static int	__yp_nomap = 0;
-extern int _yp_check(char **);
-#endif	/* YP */
-
-static	struct rpcent *interpret(char *val, int len);
-
-static char RPCDB[] = "/etc/rpc";
-
-static struct rpcdata *
-_rpcdata(void)
-{
-	register struct rpcdata *d = rpcdata;
-
-	if (d == 0) {
-		d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata));
-		rpcdata = d;
-	}
-	return (d);
-}
-
-struct rpcent *
-getrpcbynumber(int number)
-{
-	register struct rpcdata *d = _rpcdata();
-	register struct rpcent *p;
-#ifdef	YP
-	int reason;
-	char adrstr[16];
-#endif
-
-	if (d == 0)
-		return (0);
-#ifdef	YP
-        if (!__yp_nomap && _yp_check(&d->domain)) {
-                sprintf(adrstr, "%d", number);
-                reason = yp_match(d->domain, "rpc.bynumber", adrstr, strlen(adrstr),
-                                  &d->current, &d->currentlen);
-                switch(reason) {
-                case 0:
-                        break;
-                case YPERR_MAP:
-                        __yp_nomap = 1;
-                        goto no_yp;
-                        break;
-                default:
-                        return(0);
-                        break;
-                }
-                d->current[d->currentlen] = '\0';
-                p = interpret(d->current, d->currentlen);
-                (void) free(d->current);
-                return p;
-        }
-no_yp:
-#endif	/* YP */
-	setrpcent(0);
-	while ((p = getrpcent())) {
-		if (p->r_number == number)
-			break;
-	}
-	endrpcent();
-	return (p);
-}
-
-struct rpcent *
-getrpcbyname(char *name)
-{
-	struct rpcent *rpc = NULL;
-	char **rp;
-
-	setrpcent(0);
-	while ((rpc = getrpcent())) {
-		if (strcmp(rpc->r_name, name) == 0)
-			goto done;
-		for (rp = rpc->r_aliases; *rp != NULL; rp++) {
-			if (strcmp(*rp, name) == 0)
-				goto done;
-		}
-	}
-done:
-	endrpcent();
-	return (rpc);
-}
-
-void
-setrpcent(int f)
-{
-	register struct rpcdata *d = _rpcdata();
-
-	if (d == 0)
-		return;
-#ifdef	YP
-        if (!__yp_nomap && _yp_check(NULL)) {
-                if (d->current)
-                        free(d->current);
-                d->current = NULL;
-                d->currentlen = 0;
-                return;
-        }
-        __yp_nomap = 0;
-#endif	/* YP */
-	if (d->rpcf == NULL)
-		d->rpcf = fopen(RPCDB, "r");
-	else
-		rewind(d->rpcf);
-	d->stayopen |= f;
-}
-
-void
-endrpcent(void)
-{
-	register struct rpcdata *d = _rpcdata();
-
-	if (d == 0)
-		return;
-#ifdef	YP
-        if (!__yp_nomap && _yp_check(NULL)) {
-        	if (d->current && !d->stayopen)
-                        free(d->current);
-                d->current = NULL;
-                d->currentlen = 0;
-                return;
-        }
-        __yp_nomap = 0;
-#endif	/* YP */
-	if (d->rpcf && !d->stayopen) {
-		fclose(d->rpcf);
-		d->rpcf = NULL;
-	}
-}
-
-struct rpcent *
-getrpcent(void)
-{
-	register struct rpcdata *d = _rpcdata();
-#ifdef	YP
-	struct rpcent *hp;
-	int reason;
-	char *val = NULL;
-	int vallen;
-#endif
-
-	if (d == 0)
-		return(NULL);
-#ifdef	YP
-        if (!__yp_nomap && _yp_check(&d->domain)) {
-                if (d->current == NULL && d->currentlen == 0) {
-                        reason = yp_first(d->domain, "rpc.bynumber",
-                                          &d->current, &d->currentlen,
-                                          &val, &vallen);
-                } else {
-                        reason = yp_next(d->domain, "rpc.bynumber",
-                                         d->current, d->currentlen,
-                                         &d->current, &d->currentlen,
-                                         &val, &vallen);
-                }
-                switch(reason) {
-                case 0:
-                        break;
-                case YPERR_MAP:
-                        __yp_nomap = 1;
-                        goto no_yp;
-                        break;
-                default:
-                        return(0);
-                        break;
-                }
-                val[vallen] = '\0';
-                hp = interpret(val, vallen);
-                (void) free(val);
-                return hp;
-        }
-no_yp:
-#endif	/* YP */
-	if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
-		return (NULL);
-	/* -1 so there is room to append a \n below */
-        if (fgets(d->line, BUFSIZ - 1, d->rpcf) == NULL)
-		return (NULL);
-	return (interpret(d->line, strlen(d->line)));
-}
-
-static struct rpcent *
-interpret(
-	char *val,
-	int len)
-{
-	register struct rpcdata *d = _rpcdata();
-	char *p;
-	register char *cp, **q;
-
-	if (d == 0)
-		return (0);
-	(void) strncpy(d->line, val, BUFSIZ);
-	d->line[BUFSIZ] = '\0';
-	p = d->line;
-	p[len] = '\n';
-	if (*p == '#')
-		return (getrpcent());
-	cp = strpbrk(p, "#\n");
-	if (cp == NULL)
-		return (getrpcent());
-	*cp = '\0';
-	cp = strpbrk(p, " \t");
-	if (cp == NULL)
-		return (getrpcent());
-	*cp++ = '\0';
-	/* THIS STUFF IS INTERNET SPECIFIC */
-	d->rpc.r_name = d->line;
-	while (*cp == ' ' || *cp == '\t')
-		cp++;
-	d->rpc.r_number = atoi(cp);
-	q = d->rpc.r_aliases = d->rpc_aliases;
-	cp = strpbrk(cp, " \t");
-	if (cp != NULL)
-		*cp++ = '\0';
-	while (cp && *cp) {
-		if (*cp == ' ' || *cp == '\t') {
-			cp++;
-			continue;
-		}
-		if (q < &(d->rpc_aliases[MAXALIASES - 1]))
-			*q++ = cp;
-		cp = strpbrk(cp, " \t");
-		if (cp != NULL)
-			*cp++ = '\0';
-	}
-	*q = NULL;
-	return (&d->rpc);
-}
Index: rvices/librpc/src/rpc/getrpcport.3
===================================================================
--- services/librpc/src/rpc/getrpcport.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,31 +1,0 @@
-.\" @(#)getrpcport.3r	2.2 88/08/02 4.0 RPCSRC; from 1.12 88/02/26 SMI
-.\" $FreeBSD: src/lib/libc/rpc/getrpcport.3,v 1.6 1999/08/28 00:00:40 peter Exp $
-.\"
-.Dd October 6, 1987
-.Dt GETRPCPORT 3
-.Os
-.Sh NAME
-.Nm getrpcport
-.Nd get RPC port number
-.Sh SYNOPSIS
-.Ft int
-.Fn getrpcport "char *host" "int prognum" "int versnum" "int proto"
-.Sh DESCRIPTION
-.Fn getrpcport
-returns the port number for version
-.Fa versnum
-of the RPC program
-.Fa prognum
-running on
-.Fa host
-and using protocol
-.Fa proto .
-It returns 0 if it cannot contact the portmapper, or if
-.Fa prognum
-is not registered.  If
-.Fa prognum
-is registered but not with version
-.Fa versnum ,
-it will still return a port number (for some version of the program)
-indicating that the program is indeed registered.
-The version mismatch will be detected upon the first call to the service.
Index: rvices/librpc/src/rpc/getrpcport.c
===================================================================
--- services/librpc/src/rpc/getrpcport.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getrpcport.c 1.3 87/08/11 SMI";*/
-/*static char *sccsid = "from: @(#)getrpcport.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/getrpcport.c,v 1.10 1999/08/28 00:00:40 peter Exp $";
-#endif
-
-/*
- * Copyright (c) 1985 by Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#include <netdb.h>
-#include <sys/socket.h>
-
-int
-getrpcport(
-	char *host,
-	int prognum, 
-	int versnum, 
-	int proto )
-{
-	struct sockaddr_in addr;
-	struct hostent *hp;
-
-	if ((hp = gethostbyname(host)) == NULL)
-		return (0);
-	memset(&addr, 0, sizeof(addr));
-	addr.sin_len = sizeof(struct sockaddr_in);
-	addr.sin_family = AF_INET;
-	addr.sin_port =  0;
-	memcpy((char *)&addr.sin_addr, hp->h_addr, hp->h_length);
-	return (pmap_getport(&addr, prognum, versnum, proto));
-}
Index: rvices/librpc/src/rpc/netname.c
===================================================================
--- services/librpc/src/rpc/netname.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,139 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user or with the express written consent of
- * Sun Microsystems, Inc.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)netname.c 1.8 91/03/11 Copyr 1986 Sun Micro";
-#endif
-
-/*
- * netname utility routines
- * convert from unix names to network names and vice-versa
- * This module is operating system dependent!
- * What we define here will work with any unix system that has adopted
- * the sun NIS domain architecture.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/param.h>
-#include <rpc/rpc.h>
-#include <rpc/rpc_com.h>
-#ifdef YP
-#include <rpcsvc/yp_prot.h>
-#include <rpcsvc/ypclnt.h>
-#endif
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
-#ifndef NGROUPS
-#define NGROUPS 16
-#endif
-
-static char *OPSYS = "unix";
-
-/*
- * Figure out my fully qualified network name
- */
-int
-getnetname(char name[MAXNETNAMELEN+1])
-{
-	uid_t uid;
-
-	uid = geteuid();
-	if (uid == 0) {
-		return (host2netname(name, (char *) NULL, (char *) NULL));
-	} else {
-		return (user2netname(name, uid, (char *) NULL));
-	}
-}
-
-
-/*
- * Convert unix cred to network-name
- */
-int
-user2netname(
-	char netname[MAXNETNAMELEN + 1],
-	const uid_t uid,
-	const char *domain)
-{
-	char *dfltdom;
-
-#define MAXIPRINT	(11)	/* max length of printed integer */
-
-	if (domain == NULL) {
-		if (_rpc_get_default_domain(&dfltdom) != 0) {
-			return (0);
-		}
-		domain = dfltdom;
-	}
-	if (strlen(domain) + 1 + MAXIPRINT > MAXNETNAMELEN) {
-		return (0);
-	}
-	(void) sprintf(netname, "%s.%ld@%s", OPSYS, (u_long)uid, domain);	
-	return (1);
-}
-
-
-/*
- * Convert host to network-name
- */
-int
-host2netname(
-	char netname[MAXNETNAMELEN + 1],
-	const char *host,
-	const char *domain)
-{
-	char *dfltdom;
-	char hostname[MAXHOSTNAMELEN+1];
-
-	if (domain == NULL) {
-		if (_rpc_get_default_domain(&dfltdom) != 0) {
-			return (0);
-		}
-		domain = dfltdom;
-	}
-	if (host == NULL) {
-		(void) gethostname(hostname, sizeof(hostname));
-		host = hostname;
-	}
-	if (strlen(domain) + 1 + strlen(host) > MAXNETNAMELEN) {
-		return (0);
-	} 
-	(void) sprintf(netname, "%s.%s@%s", OPSYS, host, domain);
-	return (1);
-}
Index: rvices/librpc/src/rpc/netnamer.c
===================================================================
--- services/librpc/src/rpc/netnamer.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,331 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user or with the express written consent of
- * Sun Microsystems, Inc.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)netnamer.c 1.13 91/03/11 Copyr 1986 Sun Micro";
-#endif
-/*
- * netname utility routines convert from unix names to network names and
- * vice-versa This module is operating system dependent! What we define here
- * will work with any unix system that has adopted the sun NIS domain
- * architecture.
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/param.h>
-#include <rpc/rpc.h>
-#include <rpc/rpc_com.h>
-#ifdef YP
-#include <rpcsvc/yp_prot.h>
-#include <rpcsvc/ypclnt.h>
-#endif
-#include <ctype.h>
-#include <stdio.h>
-#include <grp.h>
-#include <pwd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static char    *OPSYS = "unix";
-#ifdef YP
-static char    *NETID = "netid.byname";
-#endif
-static char    *NETIDFILE = "/etc/netid";
-
-static int getnetid ( char *, char * );
-static int _getgroups ( char *, gid_t * );
-
-#ifndef NGROUPS
-#define NGROUPS 16
-#endif
-
-/*
- * Convert network-name into unix credential
- */
-int
-netname2user(
-	char            netname[MAXNETNAMELEN + 1],
-	uid_t            *uidp,
-	gid_t            *gidp,
-	int            *gidlenp,
-	gid_t	       *gidlist)
-{
-	char           *p;
-	int             gidlen;
-	uid_t           uid;
-	long		luid;
-	struct passwd  *pwd;
-	char            val[1024];
-	char           *val1, *val2;
-	char           *domain;
-	int             vallen;
-	int             err;
-
-	if (getnetid(netname, val)) {
-		p = strtok(val, ":");
-		if (p == NULL)
-			return (0);
-		*uidp = (uid_t) atol(val);
-		p = strtok(NULL, "\n,");
-		*gidp = (gid_t) atol(p);
-		if (p == NULL) {
-			return (0);
-		}
-		gidlen = 0;
-		for (gidlen = 0; gidlen < NGROUPS; gidlen++) {
-			p = strtok(NULL, "\n,");
-			if (p == NULL)
-				break;
-			gidlist[gidlen] = (gid_t) atol(p);
-		}
-		*gidlenp = gidlen;
-
-		return (1);
-	}
-	val1 = strchr(netname, '.');
-	if (val1 == NULL)
-		return (0);
-	if (strncmp(netname, OPSYS, (val1-netname)))
-		return (0);
-	val1++;
-	val2 = strchr(val1, '@');
-	if (val2 == NULL)
-		return (0);
-	vallen = val2 - val1;
-	if (vallen > (1024 - 1))
-		vallen = 1024 - 1;
-	(void) strncpy(val, val1, 1024);
-	val[vallen] = 0;
-
-	err = _rpc_get_default_domain(&domain);	/* change to rpc */
-	if (err)
-		return (0);
-
-	if (strcmp(val2 + 1, domain))
-		return (0);	/* wrong domain */
-
-	if (sscanf(val, "%ld", &luid) != 1)
-		return (0);
-	uid = luid;
-
-	/* use initgroups method */
-	pwd = getpwuid(uid);
-	if (pwd == NULL)
-		return (0);
-	*uidp = pwd->pw_uid;
-	*gidp = pwd->pw_gid;
-	*gidlenp = _getgroups(pwd->pw_name, gidlist);
-	return (1);
-}
-
-/*
- * initgroups
- */
-
-static int
-_getgroups(
-	char           *uname,
-	gid_t          groups[NGROUPS])
-{
-	gid_t           ngroups = 0;
-	register struct group *grp;
-	register int    i;
-	register int    j;
-	int             filter;
-
-	setgrent();
-	while ((grp = getgrent())) {
-		for (i = 0; grp->gr_mem[i]; i++)
-			if (!strcmp(grp->gr_mem[i], uname)) {
-				if (ngroups == NGROUPS) {
-#ifdef DEBUG
-					fprintf(stderr,
-				"initgroups: %s is in too many groups\n", uname);
-#endif
-					goto toomany;
-				}
-				/* filter out duplicate group entries */
-				filter = 0;
-				for (j = 0; j < ngroups; j++)
-					if (groups[j] == grp->gr_gid) {
-						filter++;
-						break;
-					}
-				if (!filter)
-					groups[ngroups++] = grp->gr_gid;
-			}
-	}
-toomany:
-	endgrent();
-	return (ngroups);
-}
-
-/*
- * Convert network-name to hostname
- */
-int
-netname2host(
-	char            netname[MAXNETNAMELEN + 1],
-	char           *hostname,
-	int             hostlen)
-{
-	int             err;
-	char            valbuf[1024];
-	char           *val;
-	char           *val2;
-	int             vallen;
-	char           *domain;
-
-	if (getnetid(netname, valbuf)) {
-		val = valbuf;
-		if ((*val == '0') && (val[1] == ':')) {
-			(void) strncpy(hostname, val + 2, hostlen);
-			return (1);
-		}
-	}
-	val = strchr(netname, '.');
-	if (val == NULL)
-		return (0);
-	if (strncmp(netname, OPSYS, (val - netname)))
-		return (0);
-	val++;
-	val2 = strchr(val, '@');
-	if (val2 == NULL)
-		return (0);
-	vallen = val2 - val;
-	if (vallen > (hostlen - 1))
-		vallen = hostlen - 1;
-	(void) strncpy(hostname, val, vallen);
-	hostname[vallen] = 0;
-
-	err = _rpc_get_default_domain(&domain);	/* change to rpc */
-	if (err)
-		return (0);
-
-	if (strcmp(val2 + 1, domain))
-		return (0);	/* wrong domain */
-	else
-		return (1);
-}
-
-/*
- * reads the file /etc/netid looking for a + to optionally go to the
- * network information service.
- */
-int
-getnetid(
-	char *key, 
-	char *ret)
-{
-	char            buf[1024];	/* big enough */
-	char           *res;
-	char           *mkey;
-	char           *mval;
-	FILE           *fd;
-#ifdef YP
-	char           *domain;
-	int             err;
-	char           *lookup;
-	int             len;
-#endif
-
-	fd = fopen(NETIDFILE, "r");
-	if (fd == (FILE *) 0) {
-#ifdef YP
-		res = "+";
-		goto getnetidyp;
-#else
-		return (0);
-#endif
-	}
-	for (;;) {
-		if (fd == (FILE *) 0)
-			return (0);	/* getnetidyp brings us here */
-		res = fgets(buf, 1024, fd);
-		if (res == 0) {
-			fclose(fd);
-			return (0);
-		}
-		if (res[0] == '#')
-			continue;
-		else if (res[0] == '+') {
-#ifdef YP
-	getnetidyp:
-			err = yp_get_default_domain(&domain);
-			if (err) {
-				continue;
-			}
-			lookup = NULL;
-			err = yp_match(domain, NETID, key,
-				strlen(key), &lookup, &len);
-			if (err) {
-#ifdef DEBUG
-				fprintf(stderr, "match failed error %d\n", err);
-#endif
-				continue;
-			}
-			lookup[len] = 0;
-			strcpy(ret, lookup);
-			free(lookup);
-			if (fd != NULL)
-				fclose(fd);
-			return (2);
-#else	/* YP */
-#ifdef DEBUG
-			fprintf(stderr,
-"Bad record in %s '+' -- NIS not supported in this library copy\n",
-				NETIDFILE);
-#endif
-			continue;
-#endif	/* YP */
-		} else {
-			mkey = strtok(buf, "\t ");
-			if (mkey == NULL) {
-				fprintf(stderr,
-		"Bad record in %s -- %s", NETIDFILE, buf);
-				continue;
-			}
-			mval = strtok(NULL, " \t#\n");
-			if (mval == NULL) {
-				fprintf(stderr,
-		"Bad record in %s val problem - %s", NETIDFILE, buf);
-				continue;
-			}
-			if (strcmp(mkey, key) == 0) {
-				strcpy(ret, mval);
-				fclose(fd);
-				return (1);
-
-			}
-		}
-	}
-}
Index: rvices/librpc/src/rpc/pmap_clnt.c
===================================================================
--- services/librpc/src/rpc/pmap_clnt.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,151 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)pmap_clnt.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_clnt.c,v 1.11 2000/01/27 23:06:39 jasone Exp $";
-#endif
-
-/*
- * pmap_clnt.c
- * Client interface to pmap rpc service.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_prot.h>
-#include <rpc/pmap_clnt.h>
-#include <netinet/in.h>
-
-static struct timeval timeout = { 5, 0 };
-static struct timeval tottimeout = { 60, 0 };
-
-#ifndef PORTMAPSOCK
-#define PORTMAPSOCK "/var/run/portmapsock"
-#endif
-
-/*
- * Set a mapping between program,version and port.
- * Calls the pmap service remotely to do the mapping.
- */
-bool_t
-pmap_set(
-	u_long program,
-	u_long version,
-	int protocol,
-	int port)    /* was u_short but changed to match prototype */
-{
-	struct sockaddr_in myaddress;
-	int socket = -1;
-	CLIENT *client;
-	struct pmap parms;
-	bool_t rslt;
-	struct stat st;
-
-	/*
-	 * Temporary hack for backwards compatibility. Eventually
-	 * this test will go away and we'll use only the "unix" transport.
-	 */
-	if (stat(PORTMAPSOCK, &st) == 0 && st.st_mode & S_IFSOCK)
-		client = clnt_create(PORTMAPSOCK, PMAPPROG, PMAPVERS, "unix");
-	else  {
-		if (get_myaddress(&myaddress) != 0)
-			return (FALSE);
-		myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-		client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
-	    		timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
-	}
-
-	if (client == (CLIENT *)NULL)
-		return (FALSE);
-	parms.pm_prog = program;
-	parms.pm_vers = version;
-	parms.pm_prot = protocol;
-	parms.pm_port = port;
-	if (CLNT_CALL(client, PMAPPROC_SET, (xdrproc_t)xdr_pmap, &parms, (xdrproc_t)xdr_bool, &rslt,
-	    tottimeout) != RPC_SUCCESS) {
-		clnt_perror(client, "Cannot register service");
-		return (FALSE);
-	}
-	CLNT_DESTROY(client);
-	if (socket != -1)
-		(void)_RPC_close(socket);
-	return (rslt);
-}
-
-/*
- * Remove the mapping between program, version and port.
- * Calls the pmap service remotely to do the un-mapping.
- */
-bool_t
-pmap_unset(
-	u_long program,
-	u_long version)
-{
-	struct sockaddr_in myaddress;
-	int socket = -1;
-	register CLIENT *client;
-	struct pmap parms;
-	bool_t rslt;
-	struct stat st;
-
-	/*
-	 * Temporary hack for backwards compatibility. Eventually
-	 * this test will go away and we'll use only the "unix" transport.
-	 */
-	if (stat(PORTMAPSOCK, &st) == 0 && st.st_mode & S_IFSOCK)
-		client = clnt_create(PORTMAPSOCK, PMAPPROG, PMAPVERS, "unix");
-	else {
-		if (get_myaddress(&myaddress) != 0)
-			return (FALSE);
-		myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-		client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
-	    		timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
-	}
-	if (client == (CLIENT *)NULL)
-		return (FALSE);
-	parms.pm_prog = program;
-	parms.pm_vers = version;
-	parms.pm_port = parms.pm_prot = 0;
-	CLNT_CALL(client, PMAPPROC_UNSET, (xdrproc_t)xdr_pmap, &parms, (xdrproc_t)xdr_bool, &rslt,
-	    tottimeout);
-	CLNT_DESTROY(client);
-	if (socket != -1)
-		(void)_RPC_close(socket);
-	return (rslt);
-}
Index: rvices/librpc/src/rpc/pmap_getmaps.c
===================================================================
--- services/librpc/src/rpc/pmap_getmaps.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)pmap_getmaps.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_getmaps.c,v 1.11 2000/01/27 23:06:39 jasone Exp $";
-#endif
-
-/*
- * pmap_getmap.c
- * Client interface to pmap rpc service.
- * contains pmap_getmaps, which is only tcp service involved
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#include <rpc/pmap_prot.h>
-#include <rpc/pmap_clnt.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#ifndef __rtems__
-	/* XXX fix for new location */
-	#include <sys/mbuf.h>
-#else
-	#include <freebsd/sys/mbuf.h>
-#endif
-#include <net/if.h>
-#include <sys/ioctl.h>
-#define NAMELEN 255
-#define MAX_BROADCAST_SIZE 1400
-
-/*
- * Get a copy of the current port maps.
- * Calls the pmap service remotely to do get the maps.
- */
-struct pmaplist *
-pmap_getmaps(struct sockaddr_in *address)
-{
-	struct pmaplist *head = NULL;
-	int socket = -1;
-	struct timeval minutetimeout;
-	CLIENT *client;
-
-	minutetimeout.tv_sec = 60;
-	minutetimeout.tv_usec = 0;
-	address->sin_port = htons(PMAPPORT);
-	client = clnttcp_create(address, PMAPPROG,
-	    PMAPVERS, &socket, 50, 500);
-	if (client != NULL) {
-		if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_DUMP, 
-		    (xdrproc_t)xdr_void, NULL,
-		    (xdrproc_t)xdr_pmaplist, &head, minutetimeout) !=
-		    RPC_SUCCESS) {
-			clnt_perror(client, "pmap_getmaps rpc problem");
-		}
-		CLNT_DESTROY(client);
-	}
-	if (socket != -1)
-		(void)_RPC_close(socket);
-	address->sin_port = 0;
-	return (head);
-}
Index: rvices/librpc/src/rpc/pmap_getport.c
===================================================================
--- services/librpc/src/rpc/pmap_getport.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,103 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)pmap_getport.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_getport.c,v 1.10 2000/01/27 23:06:40 jasone Exp $";
-#endif
-
-/*
- * pmap_getport.c
- * Client interface to pmap rpc service.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#include <rpc/pmap_prot.h>
-#include <rpc/pmap_clnt.h>
-#include <sys/socket.h>
-#ifndef __rtems__
-	/* XXX fix for new location */
-	#include <sys/mbuf.h>
-#else
-	#include <freebsd/sys/mbuf.h>
-#endif
-#include <net/if.h>
-#include <unistd.h>
-
-static const struct timeval timeout = { 5, 0 };
-static const struct timeval tottimeout = { 60, 0 };
-
-/*
- * Find the mapped port for program,version.
- * Calls the pmap service remotely to do the lookup.
- * Returns 0 if no map exists.
- */
-u_short
-pmap_getport(
-	struct sockaddr_in *address,
-	u_long program,
-	u_long version,
-	u_int protocol )
-{
-	u_short port = 0;
-	int socket = -1;
-	CLIENT *client;
-	struct pmap parms;
-
-	address->sin_port = htons(PMAPPORT);
-	client = clntudp_bufcreate(address, PMAPPROG,
-	    PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
-	if (client != NULL) {
-		parms.pm_prog = program;
-		parms.pm_vers = version;
-		parms.pm_prot = protocol;
-		parms.pm_port = 0;  /* not needed or used */
-		if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_GETPORT,
-		    (xdrproc_t)xdr_pmap,
-		    &parms, (xdrproc_t)xdr_u_short, &port, tottimeout) !=
-		    RPC_SUCCESS){
-			rpc_createerr.cf_stat = RPC_PMAPFAILURE;
-			clnt_geterr(client, &rpc_createerr.cf_error);
-		} else if (port == 0) {
-			rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
-		}
-		CLNT_DESTROY(client);
-	}
-	if (socket != -1)
-		(void)_RPC_close(socket);
-	address->sin_port = 0;
-	return (port);
-}
Index: rvices/librpc/src/rpc/pmap_prot.c
===================================================================
--- services/librpc/src/rpc/pmap_prot.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,63 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)pmap_prot.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_prot.c,v 1.6 1999/08/28 00:00:42 peter Exp $";
-#endif
-
-/*
- * pmap_prot.c
- * Protocol for the local binder service, or pmap.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/pmap_prot.h>
-
-
-bool_t
-xdr_pmap(
-	XDR *xdrs,
-	struct pmap *regs)
-{
-
-	if (xdr_u_long(xdrs, &regs->pm_prog) &&
-		xdr_u_long(xdrs, &regs->pm_vers) &&
-		xdr_u_long(xdrs, &regs->pm_prot))
-		return (xdr_u_long(xdrs, &regs->pm_port));
-	return (FALSE);
-}
Index: rvices/librpc/src/rpc/pmap_prot2.c
===================================================================
--- services/librpc/src/rpc/pmap_prot2.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,126 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)pmap_prot2.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_prot2.c,v 1.7 1999/08/28 00:00:42 peter Exp $";
-#endif
-
-/*
- * pmap_prot2.c
- * Protocol for the local binder service, or pmap.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifndef __rtems__
-	/* XXX not needed in old.. */
-	#include <sys/types.h>
-#endif
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/pmap_prot.h>
-
-
-/*
- * What is going on with linked lists? (!)
- * First recall the link list declaration from pmap_prot.h:
- *
- * struct pmaplist {
- *	struct pmap pml_map;
- *	struct pmaplist *pml_map;
- * };
- *
- * Compare that declaration with a corresponding xdr declaration that
- * is (a) pointer-less, and (b) recursive:
- *
- * typedef union switch (bool_t) {
- *
- *	case TRUE: struct {
- *		struct pmap;
- * 		pmaplist_t foo;
- *	};
- *
- *	case FALSE: struct {};
- * } pmaplist_t;
- *
- * Notice that the xdr declaration has no nxt pointer while
- * the C declaration has no bool_t variable.  The bool_t can be
- * interpreted as ``more data follows me''; if FALSE then nothing
- * follows this bool_t; if TRUE then the bool_t is followed by
- * an actual struct pmap, and then (recursively) by the
- * xdr union, pamplist_t.
- *
- * This could be implemented via the xdr_union primitive, though this
- * would cause a one recursive call per element in the list.  Rather than do
- * that we can ``unwind'' the recursion
- * into a while loop and do the union arms in-place.
- *
- * The head of the list is what the C programmer wishes to past around
- * the net, yet is the data that the pointer points to which is interesting;
- * this sounds like a job for xdr_reference!
- */
-bool_t
-xdr_pmaplist(
-	XDR *xdrs,
-	struct pmaplist **rp)
-{
-	/*
-	 * more_elements is pre-computed in case the direction is
-	 * XDR_ENCODE or XDR_FREE.  more_elements is overwritten by
-	 * xdr_bool when the direction is XDR_DECODE.
-	 */
-	bool_t more_elements;
-	register int freeing = (xdrs->x_op == XDR_FREE);
-	register struct pmaplist **next = NULL;
-
-	while (TRUE) {
-		more_elements = (bool_t)(*rp != NULL);
-		if (! xdr_bool(xdrs, &more_elements))
-			return (FALSE);
-		if (! more_elements)
-			return (TRUE);  /* we are done */
-		/*
-		 * the unfortunate side effect of non-recursion is that in
-		 * the case of freeing we must remember the next object
-		 * before we free the current object ...
-		 */
-		if (freeing)
-			next = &((*rp)->pml_next);
-		if (! xdr_reference(xdrs, (caddr_t *)rp,
-		    (u_int)sizeof(struct pmaplist), (xdrproc_t) xdr_pmap))
-			return (FALSE);
-		rp = (freeing) ? next : &((*rp)->pml_next);
-	}
-}
Index: rvices/librpc/src/rpc/pmap_rmt.c
===================================================================
--- services/librpc/src/rpc/pmap_rmt.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,444 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)pmap_rmt.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_rmt.c,v 1.15 2000/01/27 23:06:40 jasone Exp $";
-#endif
-
-/*
- * pmap_rmt.c
- * Client interface to pmap rpc service.
- * remote call and broadcast service
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <rpc/rpc.h>
-#include <rpc/pmap_prot.h>
-#include <rpc/pmap_clnt.h>
-#include <rpc/pmap_rmt.h>
-
-#include <stdlib.h>
-#include <sys/select.h>
-
-#define MAX_BROADCAST_SIZE 1400
-
-static const struct timeval timeout = { 3, 0 };
-
-/*
- * pmapper remote-call-service interface.
- * This routine is used to call the pmapper remote call service
- * which will look up a service program in the port maps, and then
- * remotely call that routine with the given parameters.  This allows
- * programs to do a lookup and call in one step.
-*/
-enum clnt_stat
-pmap_rmtcall(
-	struct sockaddr_in *addr,
-	u_long prog,
-	u_long vers,
-	u_long proc,
-	xdrproc_t xdrargs,
-	caddr_t argsp,
-	xdrproc_t xdrres,
-	caddr_t resp,
-	struct timeval tout,
-	u_long *port_ptr)
-{
-	int sock = -1;
-	CLIENT *client;
-	struct rmtcallargs a;
-	struct rmtcallres r;
-	enum clnt_stat stat;
-
-	assert(addr != NULL);
-	assert(port_ptr != NULL);
-
-	addr->sin_port = htons(PMAPPORT);
-	client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &sock);
-	if (client != NULL) {
-		a.prog = prog;
-		a.vers = vers;
-		a.proc = proc;
-		a.args_ptr = argsp;
-		a.xdr_args = xdrargs;
-		r.port_ptr = port_ptr;
-		r.results_ptr = resp;
-		r.xdr_results = xdrres;
-		stat = CLNT_CALL(client, (rpcproc_t)PMAPPROC_CALLIT,
-		    (xdrproc_t)xdr_rmtcall_args, &a, (xdrproc_t)xdr_rmtcallres, 
-		    &r, tout);
-		CLNT_DESTROY(client);
-	} else {
-		stat = RPC_FAILED;
-	}
-	if (sock != -1)
-		(void)_RPC_close(sock);
-	addr->sin_port = 0;
-	return (stat);
-}
-
-
-/*
- * XDR remote call arguments
- * written for XDR_ENCODE direction only
- */
-bool_t
-xdr_rmtcall_args(
-	XDR *xdrs,
-	struct rmtcallargs *cap)
-{
-	u_int lenposition, argposition, position;
-
-	assert(xdrs != NULL);
-	assert(cap != NULL);
-
-	if (xdr_u_long(xdrs, &(cap->prog)) &&
-	    xdr_u_long(xdrs, &(cap->vers)) &&
-	    xdr_u_long(xdrs, &(cap->proc))) {
-		lenposition = XDR_GETPOS(xdrs);
-		if (! xdr_u_long(xdrs, &(cap->arglen)))
-		    return (FALSE);
-		argposition = XDR_GETPOS(xdrs);
-		if (! (*(cap->xdr_args))(xdrs, cap->args_ptr))
-		    return (FALSE);
-		position = XDR_GETPOS(xdrs);
-		cap->arglen = (u_long)position - (u_long)argposition;
-		XDR_SETPOS(xdrs, lenposition);
-		if (! xdr_u_long(xdrs, &(cap->arglen)))
-		    return (FALSE);
-		XDR_SETPOS(xdrs, position);
-		return (TRUE);
-	}
-	return (FALSE);
-}
-
-/*
- * XDR remote call results
- * written for XDR_DECODE direction only
- */
-bool_t
-xdr_rmtcallres(
-	XDR *xdrs,
-	struct rmtcallres *crp)
-{
-	caddr_t port_ptr;
-
-	assert(xdrs != NULL);
-	assert(crp != NULL);
-
-	port_ptr = (caddr_t)(void *)crp->port_ptr;
-	if (xdr_reference(xdrs, &port_ptr, sizeof (u_long),
-	    (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) {
-		crp->port_ptr = (u_long *)(void *)port_ptr;
-		return ((*(crp->xdr_results))(xdrs, crp->results_ptr));
-	}
-	return (FALSE);
-}
-
-
-/*
- * The following is kludged-up support for simple rpc broadcasts.
- * Someday a large, complicated system will replace these trivial
- * routines which only support udp/ip .
- */
-
-static int
-getbroadcastnets(
-	struct in_addr *addrs,
-	int sock,  /* any valid socket will do */
-	char *buf  /* why allocxate more when we can use existing... */  )
-{
-	struct ifconf ifc;
-	struct ifreq ifreq, *ifr;
-	struct sockaddr_in *sin;
-	struct	in_addr addr;
-	char *cp, *cplim;
-	int n, i = 0;
-
-        ifc.ifc_len = UDPMSGSIZE;
-        ifc.ifc_buf = buf;
-        if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
-                perror("broadcast: ioctl (get interface configuration)");
-                return (0);
-        }
-#define max(a, b) (a > b ? a : b)
-#define size(p)	max((p).sa_len, sizeof(p))
-	cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
-	for (cp = buf; cp < cplim;
-			cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) {
-		ifr = (struct ifreq *)cp;
-		if (ifr->ifr_addr.sa_family != AF_INET)
-			continue;
-		ifreq = *ifr;
-                if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
-                        perror("broadcast: ioctl (get interface flags)");
-                        continue;
-                }
-                if ((ifreq.ifr_flags & IFF_BROADCAST) &&
-		    (ifreq.ifr_flags & IFF_UP)) {
-			sin = (struct sockaddr_in *)&ifr->ifr_addr;
-#ifdef SIOCGIFBRDADDR   /* 4.3BSD */
-			if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) {
-				addr =
-				    inet_makeaddr(inet_netof(sin->sin_addr),
-				    INADDR_ANY);
-			} else {
-				addr = ((struct sockaddr_in*)
-				  &ifreq.ifr_addr)->sin_addr;
-			}
-#else /* 4.2 BSD */
-			addr = inet_makeaddr(inet_netof(sin->sin_addr),
-			    INADDR_ANY);
-#endif
-			for (n=i-1; n>=0; n--) {
-				if (addr.s_addr == addrs[n].s_addr)
-					break;
-			}
-			if (n<0) {
-				addrs[i++] = addr;
-			}
-		}
-	}
-	return (i);
-}
-
-#ifndef __rtems__
-/* XXX now defined in rpc/clnt.h */
-typedef bool_t (*resultproc_t)(caddr_t, struct sockaddr_in *);
-#endif
-
-enum clnt_stat
-clnt_broadcast(
-	u_long		prog,		/* program number */
-	u_long		vers,		/* version number */
-	u_long		proc,		/* procedure number */
-	xdrproc_t	xargs,		/* xdr routine for args */
-	void *		argsp,		/* pointer to args */
-	xdrproc_t	xresults,	/* xdr routine for results */
-	void *		resultsp,	/* pointer to results */
-	resultproc_t	eachresult	/* call with each result obtained */ )
-{
-	enum clnt_stat stat = RPC_SUCCESS; /* to avoid warning */
-	AUTH *unix_auth = authunix_create_default();
-	XDR xdr_stream;
-	register XDR *xdrs = &xdr_stream;
-	int outlen, inlen, nets;
-	socklen_t fromlen;
-	register int sock;
-	int on = 1;
-	fd_set *fds = 0, readfds; /* initialized to avoid warning */
-	register int i;
-	bool_t done = FALSE;
-	register u_long xid;
-	u_long port;
-	struct in_addr addrs[20];
-	struct sockaddr_in baddr, raddr; /* broadcast and response addresses */
-	struct rmtcallargs a;
-	struct rmtcallres r;
-	struct rpc_msg msg;
-	struct timeval t, tv;
-	char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE];
-	static uintptr_t disrupt;
-
-	if (disrupt == 0)
-		disrupt = (uintptr_t) resultsp;
-
-	/*
-	 * initialization: create a socket, a broadcast address, and
-	 * preserialize the arguments into a send buffer.
-	 */
-	if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
-		perror("Cannot create socket for broadcast rpc");
-		stat = RPC_CANTSEND;
-		goto done_broad;
-	}
-#ifdef SO_BROADCAST
-	if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) {
-		perror("Cannot set socket option SO_BROADCAST");
-		stat = RPC_CANTSEND;
-		goto done_broad;
-	}
-#endif /* def SO_BROADCAST */
-	if (sock + 1 > FD_SETSIZE) {
-		int bytes = howmany(sock + 1, NFDBITS) * sizeof(fd_mask);
-		fds = (fd_set *)malloc(bytes);
-		if (fds == NULL) {
-			stat = RPC_CANTSEND;
-			goto done_broad;
-		}
-		memset(fds, 0, bytes);
-	} else {
-		fds = &readfds;
-		FD_ZERO(fds);
-	}
-
-	nets = getbroadcastnets(addrs, sock, inbuf);
-	memset(&baddr, 0, sizeof (baddr));
-	baddr.sin_len = sizeof(struct sockaddr_in);
-	baddr.sin_family = AF_INET;
-	baddr.sin_port = htons(PMAPPORT);
-	baddr.sin_addr.s_addr = htonl(INADDR_ANY);
-	(void)gettimeofday(&t, (struct timezone *)0);
-	msg.rm_xid = xid = (++disrupt) ^ getpid() ^ t.tv_sec ^ t.tv_usec;
-	t.tv_usec = 0;
-	msg.rm_direction = CALL;
-	msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
-	msg.rm_call.cb_prog = PMAPPROG;
-	msg.rm_call.cb_vers = PMAPVERS;
-	msg.rm_call.cb_proc = PMAPPROC_CALLIT;
-	msg.rm_call.cb_cred = unix_auth->ah_cred;
-	msg.rm_call.cb_verf = unix_auth->ah_verf;
-	a.prog = prog;
-	a.vers = vers;
-	a.proc = proc;
-	a.xdr_args = xargs;
-	a.args_ptr = argsp;
-	r.port_ptr = &port;
-	r.xdr_results = xresults;
-	r.results_ptr = resultsp;
-	xdrmem_create(xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE);
-	if ((! xdr_callmsg(xdrs, &msg)) || (! xdr_rmtcall_args(xdrs, &a))) {
-		stat = RPC_CANTENCODEARGS;
-		goto done_broad;
-	}
-	outlen = (int)xdr_getpos(xdrs);
-	xdr_destroy(xdrs);
-	/*
-	 * Basic loop: broadcast a packet and wait a while for response(s).
-	 * The response timeout grows larger per iteration.
-	 *
-	 * XXX This will loop about 5 times the stop. If there are
-	 * lots of signals being received by the process it will quit
-	 * send them all in one quick burst, not paying attention to
-	 * the intended function of sending them slowly over half a
-	 * minute or so
-	 */
-	for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2) {
-		for (i = 0; i < nets; i++) {
-			baddr.sin_addr = addrs[i];
-			if (sendto(sock, outbuf, outlen, 0,
-				(struct sockaddr *)&baddr,
-				sizeof (struct sockaddr)) != outlen) {
-				perror("Cannot send broadcast packet");
-				stat = RPC_CANTSEND;
-				goto done_broad;
-			}
-		}
-		if (eachresult == NULL) {
-			stat = RPC_SUCCESS;
-			goto done_broad;
-		}
-	recv_again:
-		msg.acpted_rply.ar_verf = _null_auth;
-		msg.acpted_rply.ar_results.where = (caddr_t)&r;
-		msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_rmtcallres;
-		/* XXX we know the other bits are still clear */
-		FD_SET(sock, fds);
-		tv = t;		/* for select() that copies back */
-		switch (select(sock + 1, fds, NULL, NULL, &tv)) {
-
-		case 0:  /* timed out */
-			stat = RPC_TIMEDOUT;
-			continue;
-
-		case -1:  /* some kind of error */
-			if (errno == EINTR)
-				goto recv_again;
-			perror("Broadcast select problem");
-			stat = RPC_CANTRECV;
-			goto done_broad;
-
-		}  /* end of select results switch */
-	try_again:
-		fromlen = sizeof(struct sockaddr);
-		inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0,
-			(struct sockaddr *)&raddr, &fromlen);
-		if (inlen < 0) {
-			if (errno == EINTR)
-				goto try_again;
-			perror("Cannot receive reply to broadcast");
-			stat = RPC_CANTRECV;
-			goto done_broad;
-		}
-		if (inlen < sizeof(u_int32_t))
-			goto recv_again;
-		/*
-		 * see if reply transaction id matches sent id.
-		 * If so, decode the results.
-		 */
-		xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE);
-		if (xdr_replymsg(xdrs, &msg)) {
-			if ((msg.rm_xid == xid) &&
-				(msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
-				(msg.acpted_rply.ar_stat == SUCCESS)) {
-				raddr.sin_port = htons((u_short)port);
-				done = (*eachresult)(resultsp, &raddr);
-			}
-			/* otherwise, we just ignore the errors ... */
-		}
-		xdrs->x_op = XDR_FREE;
-		msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_void;
-		(void)xdr_replymsg(xdrs, &msg);
-		(void)(*xresults)(xdrs, resultsp);
-		xdr_destroy(xdrs);
-		if (done) {
-			stat = RPC_SUCCESS;
-			goto done_broad;
-		} else {
-			goto recv_again;
-		}
-	}
-done_broad:
-	if (fds != &readfds)
-		free(fds);
-	if (sock >= 0)
-		(void)_RPC_close(sock);
-	AUTH_DESTROY(unix_auth);
-	return (stat);
-}
Index: rvices/librpc/src/rpc/publickey.3
===================================================================
--- services/librpc/src/rpc/publickey.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,47 +1,0 @@
-.\" @(#)publickey.3r	2.1 88/08/07 4.0 RPCSRC
-.\" $FreeBSD: src/lib/libc/rpc/publickey.3,v 1.4 2000/03/02 09:13:46 sheldonh Exp $
-.\"
-.TH PUBLICKEY 3R  "6 October 1987"
-.SH NAME
-publickey, getpublickey, getsecretkey \- get public or secret key
-.SH SYNOPSIS
-.nf
-.B #include <rpc/rpc.h>
-.B #include <rpc/key_prot.h>
-.LP
-.B getpublickey(netname, publickey)
-.B	char netname[\s-1MAXNETNAMELEN\s0+1];
-.B	char publickey[\s-1HEXKEYBYTES\s0+1];
-.LP
-.B getsecretkey(netname, secretkey, passwd)
-.B	char netname[\s-1MAXNETNAMELEN\s0+1];
-.B	char secretkey[\s-1HEXKEYBYTES\s0+1];
-.B	char *passwd;
-.fi
-.SH DESCRIPTION
-.IX "getpublickey function" "" "\fLgetpublickey()\fP function"
-.IX "getsecretkey function" "" "\fLgetsecretkey()\fP function"
-These routines are used to get public and secret keys from the
-.SM YP
-database.
-.B getsecretkey(\|)
-has an extra argument,
-.IR passwd ,
-which is used to decrypt the encrypted secret key stored in the database.
-Both routines return 1 if they are successful in finding the key, 0 otherwise.
-The keys are returned as
-.SM NULL\s0-terminated,
-hexadecimal strings.
-If the password supplied to
-.B getsecretkey(\|)
-fails to decrypt the secret key, the routine will return 1 but the
-.I secretkey
-argument will be a
-.SM NULL
-string (``'').
-.SH "SEE ALSO"
-.BR publickey (5)
-.LP
-.I \s-1RPC\s0 Programmer's Manual
-in
-.TX NETP
Index: rvices/librpc/src/rpc/publickey.5
===================================================================
--- services/librpc/src/rpc/publickey.5	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,38 +1,0 @@
-.\" $FreeBSD: src/lib/libc/rpc/publickey.5,v 1.5 2000/03/02 09:13:46 sheldonh Exp $
-.\" @(#)publickey.5	2.1 88/08/07 4.0 RPCSRC; from 1.6 88/02/29 SMI;
-.TH PUBLICKEY 5 "19 October 1987"
-.SH NAME
-publickey \- public key database
-.SH SYNOPSIS
-.B /etc/publickey
-.SH DESCRIPTION
-.LP
-.B /etc/publickey
-is the public key database used for secure
-networking.
-Each entry in
-the database consists of a network user
-name (which may either refer to
-a user or a hostname), followed by the user's
-public key (in hex
-notation), a colon, and then the user's
-secret key encrypted with
-its login password (also in hex notation).
-.LP
-This file is altered either by the user through the
-.BR chkey (1)
-command or by the system administrator through the
-.BR newkey (8)
-command.
-The file
-.B /etc/publickey
-should only contain data on the NIS master machine, where it
-is converted into the
-.SM NIS
-database
-.BR publickey.byname .
-.SH SEE ALSO
-.BR chkey (1),
-.BR publickey (3R),
-.BR newkey (8),
-.BR ypupdated (8C)
Index: rvices/librpc/src/rpc/rpc.3
===================================================================
--- services/librpc/src/rpc/rpc.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,1767 +1,0 @@
-.\" @(#)rpc.3n	2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
-.\" $FreeBSD: src/lib/libc/rpc/rpc.3,v 1.11 2000/03/02 09:13:47 sheldonh Exp $
-.\"
-.TH RPC 3 "16 February 1988"
-.SH NAME
-rpc \- library routines for remote procedure calls
-.SH SYNOPSIS AND DESCRIPTION
-These routines allow C programs to make procedure
-calls on other machines across the network.
-First, the client calls a procedure to send a
-data packet to the server.
-Upon receipt of the packet, the server calls a dispatch routine
-to perform the requested service, and then sends back a
-reply.
-Finally, the procedure call returns to the client.
-.LP
-Routines that are used for Secure RPC (DES authentication) are described in
-.BR rpc_secure (3).
-Secure RPC can be used only if DES encryption is available.
-.LP
-.ft B
-.nf
-.sp .5
-#include <rpc/rpc.h>
-.fi
-.ft R
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-void
-auth_destroy(auth)
-\s-1AUTH\s0 *auth;
-.fi
-.ft R
-.IP
-A macro that destroys the authentication information associated with
-.IR auth .
-Destruction usually involves deallocation of private data
-structures.
-The use of
-.I auth
-is undefined after calling
-.BR auth_destroy(\|) .
-.br
-.if t .ne 6
-.LP
-.ft B
-.nf
-.sp .5
-\s-1AUTH\s0 *
-authnone_create(\|)
-.fi
-.ft R
-.IP
-Create and returns an
-.SM RPC
-authentication handle that passes nonusable authentication
-information with each remote procedure call.
-This is the
-default authentication used by
-.SM RPC.
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-\s-1AUTH\s0 *
-authunix_create(host, uid, gid, len, aup_gids)
-char *host;
-int uid, gid, len, *aup.gids;
-.fi
-.ft R
-.IP
-Create and return an
-.SM RPC
-authentication handle that contains
-.UX
-authentication information.
-The parameter
-.I host
-is the name of the machine on which the information was
-created;
-.I uid
-is the user's user
-.SM ID ;
-.I gid
-is the user's current group
-.SM ID ;
-.I len
-and
-.I aup_gids
-refer to a counted array of groups to which the user belongs.
-It is easy to impersonate a user.
-.br
-.if t .ne 5
-.LP
-.ft B
-.nf
-.sp .5
-\s-1AUTH\s0 *
-authunix_create_default(\|)
-.fi
-.ft R
-.IP
-Calls
-.B authunix_create(\|)
-with the appropriate parameters.
-.br
-.if t .ne 13
-.LP
-.ft B
-.nf
-.sp .5
-callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
-char *host;
-u_long prognum, versnum, procnum;
-char *in, *out;
-xdrproc_t inproc, outproc;
-.fi
-.ft R
-.IP
-Call the remote procedure associated with
-.IR prognum ,
-.IR versnum ,
-and
-.I procnum
-on the machine,
-.IR host .
-The parameter
-.I in
-is the address of the procedure's argument(s), and
-.I out
-is the address of where to place the result(s);
-.I inproc
-is used to encode the procedure's parameters, and
-.I outproc
-is used to decode the procedure's results.
-This routine returns zero if it succeeds, or the value of
-.B "enum clnt_stat"
-cast to an integer if it fails.
-The routine
-.B clnt_perrno(\|)
-is handy for translating failure statuses into messages.
-.IP
-Warning: calling remote procedures with this routine
-uses
-.SM UDP/IP
-as a transport; see
-.B clntudp_create(\|)
-for restrictions.
-You do not have control of timeouts or authentication using
-this routine.
-.br
-.if t .ne 16
-.LP
-.ft B
-.nf
-.sp .5
-enum clnt_stat
-clnt_broadcast(prognum, versnum, procnum, inproc, in, outproc, out, eachresult)
-u_long prognum, versnum, procnum;
-char *in, *out;
-xdrproc_t inproc, outproc;
-resultproc_t eachresult;
-.fi
-.ft R
-.IP
-Like
-.BR callrpc(\|) ,
-except the call message is broadcast to all locally
-connected broadcast nets.
-Each time it receives a
-response, this routine calls
-.BR eachresult(\|) ,
-whose form is:
-.IP
-.RS 1i
-.ft B
-.nf
-eachresult(out, addr)
-char *out;
-struct sockaddr_in *addr;
-.ft R
-.fi
-.RE
-.IP
-where
-.I out
-is the same as
-.I out
-passed to
-.BR clnt_broadcast(\|) ,
-except that the remote procedure's output is decoded there;
-.I addr
-points to the address of the machine that sent the results.
-If
-.B eachresult(\|)
-returns zero,
-.B clnt_broadcast(\|)
-waits for more replies; otherwise it returns with appropriate
-status.
-.IP
-Warning: broadcast sockets are limited in size to the
-maximum transfer unit of the data link.
-For ethernet,
-this value is 1500 bytes.
-.br
-.if t .ne 13
-.LP
-.ft B
-.nf
-.sp .5
-enum clnt_stat
-clnt_call(clnt, procnum, inproc, in, outproc, out, tout)
-\s-1CLIENT\s0 *clnt;
-u_long
-procnum;
-xdrproc_t inproc, outproc;
-char *in, *out;
-struct timeval tout;
-.fi
-.ft R
-.IP
-A macro that calls the remote procedure
-.I procnum
-associated with the client handle,
-.IR clnt ,
-which is obtained with an
-.SM RPC
-client creation routine such as
-.BR clnt_create(\|) .
-The parameter
-.I in
-is the address of the procedure's argument(s), and
-.I out
-is the address of where to place the result(s);
-.I inproc
-is used to encode the procedure's parameters, and
-.I outproc
-is used to decode the procedure's results;
-.I tout
-is the time allowed for results to come back.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-clnt_destroy(clnt)
-\s-1CLIENT\s0 *clnt;
-.fi
-.ft R
-.IP
-A macro that destroys the client's
-.SM RPC
-handle.
-Destruction usually involves deallocation
-of private data structures, including
-.I clnt
-itself.  Use of
-.I clnt
-is undefined after calling
-.BR clnt_destroy(\|) .
-If the
-.SM RPC
-library opened the associated socket, it will close it also.
-Otherwise, the socket remains open.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-\s-1CLIENT\s0 *
-clnt_create(host, prog, vers, proto)
-char *host;
-u_long prog, vers;
-char *proto;
-.fi
-.ft R
-.IP
-Generic client creation routine.
-.I host
-identifies the name of the remote host where the server
-is located.
-.I proto
-indicates which kind of transport protocol to use.
-The
-currently supported values for this field are \(lqudp\(rq
-and \(lqtcp\(rq.
-Default timeouts are set, but can be modified using
-.BR clnt_control(\|) .
-.IP
-Warning: Using
-.SM UDP
-has its shortcomings.  Since
-.SM UDP\s0-based
-.SM RPC
-messages can only hold up to 8 Kbytes of encoded data,
-this transport cannot be used for procedures that take
-large arguments or return huge results.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-bool_t
-clnt_control(cl, req, info)
-\s-1CLIENT\s0 *cl;
-u_int req;
-char *info;
-.fi
-.ft R
-.IP
-A macro used to change or retrieve various information
-about a client object.
-.I req
-indicates the type of operation, and
-.I info
-is a pointer to the information.
-For both
-.SM UDP
-and
-.SM TCP\s0,
-the supported values of
-.I req
-and their argument types and what they do are:
-.IP
-.nf
-.ta +2.0i +2.0i +2.0i
-.SM CLSET_TIMEOUT\s0	struct timeval	set total timeout
-.SM CLGET_TIMEOUT\s0	struct timeval	get total timeout
-.fi
-.IP
-Note: if you set the timeout using
-.BR clnt_control(\|) ,
-the timeout parameter passed to
-.B clnt_call(\|)
-will be ignored in all future calls.
-.IP
-.nf
-.SM CLGET_SERVER_ADDR\s0	struct sockaddr_in 	get server's address
-.fi
-.br
-.IP
-The following operations are valid for
-.SM UDP
-only:
-.IP
-.nf
-.ta +2.0i ; +2.0i ; +2.0i
-.SM CLSET_RETRY_TIMEOUT\s0		struct timeval	set the retry timeout
-.SM CLGET_RETRY_TIMEOUT\s0		struct timeval	get the retry timeout
-.fi
-.br
-.IP
-The retry timeout is the time that
-.SM "UDP RPC"
-waits for the server to reply before
-retransmitting the request.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-clnt_freeres(clnt, outproc, out)
-\s-1CLIENT\s0 *clnt;
-xdrproc_t outproc;
-char *out;
-.fi
-.ft R
-.IP
-A macro that frees any data allocated by the
-.SM RPC/XDR
-system when it decoded the results of an
-.SM RPC
-call.  The
-parameter
-.I out
-is the address of the results, and
-.I outproc
-is the
-.SM XDR
-routine describing the results.
-This routine returns one if the results were successfully
-freed,
-and zero otherwise.
-.br
-.if t .ne 6
-.LP
-.ft B
-.nf
-.sp .5
-void
-clnt_geterr(clnt, errp)
-\s-1CLIENT\s0 *clnt;
-struct rpc_err *errp;
-.fi
-.ft R
-.IP
-A macro that copies the error structure out of the client
-handle
-to the structure at address
-.IR errp .
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-void
-clnt_pcreateerror(s)
-char *s;
-.fi
-.ft R
-.IP
-Print a message to standard error indicating
-why a client
-.SM RPC
-handle could not be created.
-The message is prepended with string
-.I s
-and a colon.
-Used when a
-.BR clnt_create(\|) ,
-.BR clntraw_create(\|) ,
-.BR clnttcp_create(\|) ,
-or
-.B clntudp_create(\|)
-call fails.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-void
-clnt_perrno(stat)
-enum clnt_stat stat;
-.fi
-.ft R
-.IP
-Print a message to standard error corresponding
-to the condition indicated by
-.IR stat .
-Used after
-.BR callrpc(\|) .
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-clnt_perror(clnt, s)
-\s-1CLIENT\s0 *clnt;
-char *s;
-.fi
-.ft R
-.IP
-Print a message to standard error indicating why an
-.SM RPC
-call failed;
-.I clnt
-is the handle used to do the call.
-The message is prepended with string
-.I s
-and a colon.
-Used after
-.BR clnt_call(\|) .
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-char *
-clnt_spcreateerror
-char *s;
-.fi
-.ft R
-.IP
-Like
-.BR clnt_pcreateerror(\|) ,
-except that it returns a string
-instead of printing to the standard error.
-.IP
-Bugs: returns pointer to static data that is overwritten
-on each call.
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-char *
-clnt_sperrno(stat)
-enum clnt_stat stat;
-.fi
-.ft R
-.IP
-Take the same arguments as
-.BR clnt_perrno(\|) ,
-but instead of sending a message to the standard error
-indicating why an
-.SM RPC
-call failed, return a pointer to a string which contains
-the message.  The string ends with a
-.SM NEWLINE\s0.
-.IP
-.B clnt_sperrno(\|)
-is used instead of
-.B clnt_perrno(\|)
-if the program does not have a standard error (as a program
-running as a server quite likely does not), or if the
-programmer
-does not want the message to be output with
-.BR printf ,
-or if a message format different from that supported by
-.B clnt_perrno(\|)
-is to be used.
-Note: unlike
-.B clnt_sperror(\|)
-and
-.BR clnt_spcreaterror(\|) ,
-.B clnt_sperrno(\|)
-returns pointer to static data, but the
-result will not get overwritten on each call.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-char *
-clnt_sperror(rpch, s)
-\s-1CLIENT\s0 *rpch;
-char *s;
-.fi
-.ft R
-.IP
-Like
-.BR clnt_perror(\|) ,
-except that (like
-.BR clnt_sperrno(\|) )
-it returns a string instead of printing to standard error.
-.IP
-Bugs: returns pointer to static data that is overwritten
-on each call.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-\s-1CLIENT\s0 *
-clntraw_create(prognum, versnum)
-u_long prognum, versnum;
-.fi
-.ft R
-.IP
-This routine creates a toy
-.SM RPC
-client for the remote program
-.IR prognum ,
-version
-.IR versnum .
-The transport used to pass messages to the service is
-actually a buffer within the process's address space, so the
-corresponding
-.SM RPC
-server should live in the same address space; see
-.BR svcraw_create(\|) .
-This allows simulation of
-.SM RPC
-and acquisition of
-.SM RPC
-overheads, such as round trip times, without any
-kernel interference.
-This routine returns
-.SM NULL
-if it fails.
-.br
-.if t .ne 15
-.LP
-.ft B
-.nf
-.sp .5
-\s-1CLIENT\s0 *
-clnttcp_create(addr, prognum, versnum, sockp, sendsz, recvsz)
-struct sockaddr_in *addr;
-u_long prognum, versnum;
-int *sockp;
-u_int sendsz, recvsz;
-.fi
-.ft R
-.IP
-This routine creates an
-.SM RPC
-client for the remote program
-.IR prognum ,
-version
-.IR versnum ;
-the client uses
-.SM TCP/IP
-as a transport.
-The remote program is located at Internet
-address
-.IR *addr .
-If
-.\"The following in-line font conversion is necessary for the hyphen indicator
-\fB\%addr\->sin_port\fR
-is zero, then it is set to the actual port that the remote
-program is listening on (the remote
-.B portmap
-service is consulted for this information). The parameter
-.I sockp
-is a socket; if it is
-.BR \s-1RPC_ANYSOCK\s0 ,
-then this routine opens a new one and sets
-.IR sockp .
-Since
-.SM TCP\s0-based
-.SM RPC
-uses buffered
-.SM I/O ,
-the user may specify the size of the send and receive buffers
-with the parameters
-.I sendsz
-and
-.IR recvsz ;
-values of zero choose suitable defaults.
-This routine returns
-.SM NULL
-if it fails.
-.br
-.if t .ne 15
-.LP
-.ft B
-.nf
-.sp .5
-\s-1CLIENT\s0 *
-clntudp_create(addr, prognum, versnum, wait, sockp)
-struct sockaddr_in *addr;
-u_long prognum, versnum;
-struct timeval wait;
-int *sockp;
-.fi
-.ft R
-.IP
-This routine creates an
-.SM RPC
-client for the remote program
-.IR prognum ,
-version
-.IR versnum ;
-the client uses
-.SM UDP/IP
-as a transport.
-The remote program is located at Internet
-address
-.IR addr .
-If
-\fB\%addr\->sin_port\fR
-is zero, then it is set to actual port that the remote
-program is listening on (the remote
-.B portmap
-service is consulted for this information). The parameter
-.I sockp
-is a socket; if it is
-.BR \s-1RPC_ANYSOCK\s0 ,
-then this routine opens a new one and sets
-.IR sockp .
-The
-.SM UDP
-transport resends the call message in intervals of
-.B wait
-time until a response is received or until the call times
-out.
-The total time for the call to time out is specified by
-.BR clnt_call(\|) .
-.IP
-Warning: since
-.SM UDP\s0-based
-.SM RPC
-messages can only hold up to 8 Kbytes
-of encoded data, this transport cannot be used for procedures
-that take large arguments or return huge results.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-\s-1CLIENT\s0 *
-clntudp_bufcreate(addr, prognum, versnum, wait, sockp, sendsize, recosize)
-struct sockaddr_in *addr;
-u_long prognum, versnum;
-struct timeval wait;
-int *sockp;
-unsigned int sendsize;
-unsigned int recosize;
-.fi
-.ft R
-.IP
-This routine creates an
-.SM RPC
-client for the remote program
-.IR prognum ,
-on
-.IR versnum ;
-the client uses
-.SM UDP/IP
-as a transport.
-The remote program is located at Internet
-address
-.IR addr .
-If
-\fB\%addr\->sin_port\fR
-is zero, then it is set to actual port that the remote
-program is listening on (the remote
-.B portmap
-service is consulted for this information). The parameter
-.I sockp
-is a socket; if it is
-.BR \s-1RPC_ANYSOCK\s0 ,
-then this routine opens a new one and sets
-.BR sockp .
-The
-.SM UDP
-transport resends the call message in intervals of
-.B wait
-time until a response is received or until the call times
-out.
-The total time for the call to time out is specified by
-.BR clnt_call(\|) .
-.IP
-This allows the user to specify the maximum packet size for sending and receiving 
-.SM UDP\s0-based
-.SM RPC
-messages.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-int
-get_myaddress(addr)
-struct sockaddr_in *addr;
-.fi
-.ft R
-.IP
-Stuff the machine's
-.SM IP
-address into
-.IR *addr ,
-without consulting the library routines that deal with
-.BR /etc/hosts .
-The port number is always set to
-.BR htons(\s-1PMAPPORT\s0) .
-Returns zero on success, non-zero on failure.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-struct pmaplist *
-pmap_getmaps(addr)
-struct sockaddr_in *addr;
-.fi
-.ft R
-.IP
-A user interface to the
-.B portmap
-service, which returns a list of the current
-.SM RPC
-program-to-port mappings
-on the host located at
-.SM IP
-address
-.IR *addr .
-This routine can return
-.SM NULL .
-The command
-.RB ` "rpcinfo \-p" '
-uses this routine.
-.br
-.if t .ne 12
-.LP
-.ft B
-.nf
-.sp .5
-u_short
-pmap_getport(addr, prognum, versnum, protocol)
-struct sockaddr_in *addr;
-u_long prognum, versnum, protocol;
-.fi
-.ft R
-.IP
-A user interface to the
-.B portmap
-service, which returns the port number
-on which waits a service that supports program number
-.IR prognum ,
-version
-.IR versnum ,
-and speaks the transport protocol associated with
-.IR protocol .
-The value of
-.I protocol
-is most likely
-.B
-.SM IPPROTO_UDP
-or 
-.BR \s-1IPPROTO_TCP\s0 .
-A return value of zero means that the mapping does not exist
-or that
-the
-.SM RPC
-system failed to contact the remote
-.B portmap
-service.  In the latter case, the global variable
-.B rpc_createerr(\|)
-contains the
-.SM RPC
-status.
-.br
-.if t .ne 15
-.LP
-.ft B
-.nf
-.sp .5
-enum clnt_stat
-pmap_rmtcall(addr, prognum, versnum, procnum, inproc, in, outproc, out, tout, portp)
-struct sockaddr_in *addr;
-u_long prognum, versnum, procnum;
-char *in, *out;
-xdrproc_t inproc, outproc;
-struct timeval tout;
-u_long *portp;
-.fi
-.ft R
-.IP
-A user interface to the
-.B portmap
-service, which instructs
-.B portmap
-on the host at
-.SM IP
-address
-.I *addr
-to make an
-.SM RPC
-call on your behalf to a procedure on that host.
-The parameter
-.I *portp
-will be modified to the program's port number if the
-procedure
-succeeds.
-The definitions of other parameters are discussed
-in
-.B callrpc(\|)
-and
-.BR clnt_call(\|) .
-This procedure should be used for a \(lqping\(rq and nothing
-else.
-See also
-.BR clnt_broadcast(\|) .
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-pmap_set(prognum, versnum, protocol, port)
-u_long prognum, versnum, protocol;
-u_short port;
-.fi
-.ft R
-.IP
-A user interface to the
-.B portmap
-service, which establishes a mapping between the triple
-.RI [ prognum , versnum , protocol\fR]
-and
-.I port
-on the machine's
-.B portmap
-service.
-The value of
-.I protocol
-is most likely
-.B
-.SM IPPROTO_UDP
-or 
-.BR \s-1IPPROTO_TCP\s0 .
-This routine returns one if it succeeds, zero otherwise.
-Automatically done by
-.BR svc_register(\|) .
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-pmap_unset(prognum, versnum)
-u_long prognum, versnum;
-.fi
-.ft R
-.IP
-A user interface to the
-.B portmap
-service, which destroys all mapping between the triple
-.RI [ prognum , versnum , *\fR]
-and
-.B ports
-on the machine's
-.B portmap
-service.
-This routine returns one if it succeeds, zero
-otherwise.
-.br
-.if t .ne 15
-.LP
-.ft B
-.nf
-.sp .5
-registerrpc(prognum, versnum, procnum, procname, inproc, outproc)
-u_long prognum, versnum, procnum;
-char *(*procname) (\|) ;
-xdrproc_t inproc, outproc;
-.fi
-.ft R
-.IP
-Register procedure
-.I procname
-with the
-.SM RPC
-service package.  If a request arrives for program
-.IR prognum ,
-version
-.IR versnum ,
-and procedure
-.IR procnum ,
-.I procname
-is called with a pointer to its parameter(s);
-.I progname
-should return a pointer to its static result(s);
-.I inproc
-is used to decode the parameters while
-.I outproc
-is used to encode the results.
-This routine returns zero if the registration succeeded, \-1
-otherwise.
-.IP
-Warning: remote procedures registered in this form
-are accessed using the
-.SM UDP/IP
-transport; see
-.B svcudp_create(\|)
-for restrictions.
-.br
-.if t .ne 5
-.LP
-.ft B
-.nf
-.sp .5
-struct rpc_createerr     rpc_createerr;
-.fi
-.ft R
-.IP
-A global variable whose value is set by any
-.SM RPC
-client creation routine
-that does not succeed.  Use the routine
-.B clnt_pcreateerror(\|)
-to print the reason why.
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-svc_destroy(xprt)
-\s-1SVCXPRT\s0 *
-xprt;
-.fi
-.ft R
-.IP
-A macro that destroys the
-.SM RPC
-service transport handle,
-.IR xprt .
-Destruction usually involves deallocation
-of private data structures, including
-.I xprt
-itself.  Use of
-.I xprt
-is undefined after calling this routine.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-fd_set svc_fdset;
-.fi
-.ft R
-.IP
-A global variable reflecting the
-.SM RPC
-service side's
-read file descriptor bit mask; it is suitable as a template parameter
-to the
-.B select
-system call.
-This is only of interest
-if a service implementor does not call
-.BR svc_run(\|) ,
-but rather does his own asynchronous event processing.
-This variable is read-only (do not pass its address to
-.BR select !),
-yet it may change after calls to
-.B svc_getreqset(\|)
-or any creation routines.
-.br
-As well, note that if the process has descriptor limits
-which are extended beyond
-.BR FD_SETSIZE ,
-this variable will only be usable for the first
-.BR FD_SETSIZE
-descriptors.
-.br
-.if t .ne 6
-.LP
-.ft B
-.nf
-.sp .5
-int svc_fds;
-.fi
-.ft R
-.IP
-Similar to
-.BR svc_fedset(\|) ,
-but limited to 32 descriptors.
-This
-interface is obsoleted by
-.BR svc_fdset(\|) .
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-svc_freeargs(xprt, inproc, in)
-\s-1SVCXPRT\s0 *xprt;
-xdrproc_t inproc;
-char *in;
-.fi
-.ft R
-.IP
-A macro that frees any data allocated by the
-.SM RPC/XDR
-system when it decoded the arguments to a service procedure
-using
-.BR svc_getargs(\|) .
-This routine returns 1 if the results were successfully
-freed,
-and zero otherwise.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-svc_getargs(xprt, inproc, in)
-\s-1SVCXPRT\s0 *xprt;
-xdrproc_t inproc;
-char *in;
-.fi
-.ft R
-.IP
-A macro that decodes the arguments of an
-.SM RPC
-request
-associated with the
-.SM RPC
-service transport handle,
-.IR xprt .
-The parameter
-.I in
-is the address where the arguments will be placed;
-.I inproc
-is the
-.SM XDR
-routine used to decode the arguments.
-This routine returns one if decoding succeeds, and zero
-otherwise.
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-struct sockaddr_in *
-svc_getcaller(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-The approved way of getting the network address of the caller
-of a procedure associated with the
-.SM RPC
-service transport handle,
-.IR xprt .
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-svc_getreqset(rdfds)
-fd_set *rdfds;
-.fi
-.ft R
-.IP
-This routine is only of interest if a service implementor
-does not call
-.BR svc_run(\|) ,
-but instead implements custom asynchronous event processing.
-It is called when the
-.B select
-system call has determined that an
-.SM RPC
-request has arrived on some
-.SM RPC
-.B socket(s) ;
-.I rdfds
-is the resultant read file descriptor bit mask.
-The routine returns when all sockets associated with the
-value of
-.I rdfds
-have been serviced.
-.br
-.if t .ne 6
-.LP
-.ft B
-.nf
-.sp .5
-svc_getreq(rdfds)
-int rdfds;
-.fi
-.ft R
-.IP
-Similar to
-.BR svc_getreqset(\|) ,
-but limited to 32 descriptors.
-This interface is obsoleted by
-.BR svc_getreqset(\|) .
-.br
-.if t .ne 17
-.LP
-.ft B
-.nf
-.sp .5
-svc_register(xprt, prognum, versnum, dispatch, protocol)
-\s-1SVCXPRT\s0 *xprt;
-u_long prognum, versnum;
-void (*dispatch) (\|);
-u_long protocol;
-.fi
-.ft R
-.IP
-Associates
-.I prognum
-and
-.I versnum
-with the service dispatch procedure,
-.IR dispatch .
-If
-.I protocol
-is zero, the service is not registered with the
-.B portmap
-service.  If
-.I protocol
-is non-zero, then a mapping of the triple
-.RI [ prognum , versnum , protocol\fR]
-to
-\fB\%xprt\->xp_port\fR
-is established with the local
-.B portmap
-service (generally
-.I protocol
-is zero,
-.B
-.SM IPPROTO_UDP
-or 
-.B
-.SM IPPROTO_TCP
-).
-The procedure
-.I dispatch
-has the following form:
-.RS 1i
-.ft B
-.nf
-dispatch(request, xprt)
-struct svc_req *request;
-\s-1SVCXPRT\s0 *xprt;
-.ft R
-.fi
-.RE
-.IP
-The
-.B svc_register(\|)
-routine returns one if it succeeds, and zero otherwise.
-.br
-.if t .ne 6
-.LP
-.ft B
-.nf
-.sp .5
-svc_run(\|)
-.fi
-.ft R
-.IP
-This routine never returns.
-It waits for
-.SM RPC
-requests to arrive, and calls the appropriate service
-procedure using
-.B svc_getreq(\|)
-when one arrives.
-This procedure is usually waiting for a
-.B select(\|)
-system call to return.
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-svc_sendreply(xprt, outproc, out)
-\s-1SVCXPRT\s0 *xprt;
-xdrproc_t outproc;
-char *out;
-.fi
-.ft R
-.IP
-Called by an
-.SM RPC
-service's dispatch routine to send the results of a
-remote procedure call.  The parameter
-.I xprt
-is the request's associated transport handle;
-.I outproc
-is the
-.SM XDR
-routine which is used to encode the results; and
-.I out
-is the address of the results.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-void
-svc_unregister(prognum, versnum)
-u_long prognum, versnum;
-.fi
-.ft R
-.IP
-Remove all mapping of the double
-.RI [ prognum , versnum ]
-to dispatch routines, and of the triple
-.RI [ prognum , versnum , *\fR]
-to port number.
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-void
-svcerr_auth(xprt, why)
-\s-1SVCXPRT\s0 *xprt;
-enum auth_stat why;
-.fi
-.ft R
-.IP
-Called by a service dispatch routine that refuses to perform
-a remote procedure call due to an authentication error.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-void
-svcerr_decode(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-Called by a service dispatch routine that cannot successfully
-decode its parameters.
-See also
-.BR svc_getargs(\|) .
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-void
-svcerr_noproc(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-Called by a service dispatch routine that does not implement
-the procedure number that the caller requests.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-void
-svcerr_noprog(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-Called when the desired program is not registered with the
-.SM RPC
-package.
-Service implementors usually do not need this routine.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-void
-svcerr_progvers(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-Called when the desired version of a program is not registered
-with the
-.SM RPC
-package.
-Service implementors usually do not need this routine.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-void
-svcerr_systemerr(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-Called by a service dispatch routine when it detects a system
-error
-not covered by any particular protocol.
-For example, if a service can no longer allocate storage,
-it may call this routine.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-void
-svcerr_weakauth(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-Called by a service dispatch routine that refuses to perform
-a remote procedure call due to insufficient
-authentication parameters.  The routine calls
-.BR "svcerr_auth(xprt, \s-1AUTH_TOOWEAK\s0)" .
-.br
-.if t .ne 11
-.LP
-.ft B
-.nf
-.sp .5
-\s-1SVCXPRT\s0 *
-svcraw_create(\|)
-.fi
-.ft R
-.IP
-This routine creates a toy
-.SM RPC
-service transport, to which it returns a pointer.  The
-transport
-is really a buffer within the process's address space,
-so the corresponding
-.SM RPC
-client should live in the same
-address space;
-see
-.BR clntraw_create(\|) .
-This routine allows simulation of
-.SM RPC
-and acquisition of
-.SM RPC
-overheads (such as round trip times), without any kernel
-interference.
-This routine returns
-.SM NULL
-if it fails.
-.br
-.if t .ne 11
-.LP
-.ft B
-.nf
-.sp .5
-\s-1SVCXPRT\s0 *
-svctcp_create(sock, send_buf_size, recv_buf_size)
-int sock;
-u_int send_buf_size, recv_buf_size;
-.fi
-.ft R
-.IP
-This routine creates a
-.SM TCP/IP\s0-based
-.SM RPC
-service transport, to which it returns a pointer.
-The transport is associated with the socket
-.IR sock ,
-which may be
-.BR \s-1RPC_ANYSOCK\s0 ,
-in which case a new socket is created.
-If the socket is not bound to a local
-.SM TCP
-port, then this routine binds it to an arbitrary port.  Upon
-completion,
-\fB\%xprt\->xp_fd\fR
-is the transport's socket descriptor, and
-\fB\%xprt\->xp_port\fR
-is the transport's port number.
-This routine returns
-.SM NULL
-if it fails.
-Since
-.SM TCP\s0-based
-.SM RPC
-uses buffered
-.SM I/O ,
-users may specify the size of buffers; values of zero
-choose suitable defaults.
-.br
-.if t .ne 11
-.LP
-.ft B
-.nf
-.sp .5
-\s-1SVCXPRT\s0 *
-svcfd_create(fd, sendsize, recvsize)
-int fd;
-u_int sendsize;
-u_int recvsize;
-.fi
-.ft R
-.IP
-Create a service on top of any open descriptor.
-Typically,
-this
-descriptor is a connected socket for a stream protocol such
-as
-.SM TCP\s0.
-.I sendsize
-and
-.I recvsize
-indicate sizes for the send and receive buffers.  If they are
-zero, a reasonable default is chosen.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-\s-1SVCXPRT\s0 *
-svcudp_bufcreate(sock, sendsize, recosize)
-int sock;
-.fi
-.ft R
-.IP
-This routine creates a
-.SM UDP/IP\s0-based
-.SM RPC
-service transport, to which it returns a pointer.
-The transport is associated with the socket
-.IR sock ,
-which may be
-.B \s-1RPC_ANYSOCK\s0 ,
-in which case a new socket is created.
-If the socket is not bound to a local
-.SM UDP
-port, then this routine binds it to an arbitrary port.
-Upon
-completion,
-\fB\%xprt\->xp_fd\fR
-is the transport's socket descriptor, and
-\fB\%xprt\->xp_port\fR
-is the transport's port number.
-This routine returns
-.SM NULL
-if it fails.
-.IP
-This allows the user to specify the maximum packet size for sending and 
-receiving
-.SM UDP\s0-based
-.SM RPC messages.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_accepted_reply(xdrs, ar)
-\s-1XDR\s0 *xdrs;
-struct accepted_reply *ar;
-.fi
-.ft R
-.IP
-Used for encoding
-.SM RPC
-reply messages.
-This routine is useful for users who
-wish to generate
-\s-1RPC\s0-style
-messages without using the
-.SM RPC
-package.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_authunix_parms(xdrs, aupp)
-\s-1XDR\s0 *xdrs;
-struct authunix_parms *aupp;
-.fi
-.ft R
-.IP
-Used for describing
-.SM UNIX
-credentials.
-This routine is useful for users
-who wish to generate these credentials without using the
-.SM RPC
-authentication package.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-void
-xdr_callhdr(xdrs, chdr)
-\s-1XDR\s0 *xdrs;
-struct rpc_msg *chdr;
-.fi
-.ft R
-.IP
-Used for describing
-.SM RPC
-call header messages.
-This routine is useful for users who wish to generate
-.SM RPC\s0-style
-messages without using the
-.SM RPC
-package.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_callmsg(xdrs, cmsg)
-\s-1XDR\s0 *xdrs;
-struct rpc_msg *cmsg;
-.fi
-.ft R
-.IP
-Used for describing
-.SM RPC
-call messages.
-This routine is useful for users who wish to generate
-.SM RPC\s0-style
-messages without using the
-.SM RPC
-package.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_opaque_auth(xdrs, ap)
-\s-1XDR\s0 *xdrs;
-struct opaque_auth *ap;
-.fi
-.ft R
-.IP
-Used for describing
-.SM RPC
-authentication information messages.
-This routine is useful for users who wish to generate
-.SM RPC\s0-style
-messages without using the
-.SM RPC
-package.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_pmap(xdrs, regs)
-\s-1XDR\s0 *xdrs;
-struct pmap *regs;
-.fi
-.ft R
-.IP
-Used for describing parameters to various
-.B portmap
-procedures, externally.
-This routine is useful for users who wish to generate
-these parameters without using the
-.B pmap
-interface.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_pmaplist(xdrs, rp)
-\s-1XDR\s0 *xdrs;
-struct pmaplist **rp;
-.fi
-.ft R
-.IP
-Used for describing a list of port mappings, externally.
-This routine is useful for users who wish to generate
-these parameters without using the
-.B pmap
-interface.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_rejected_reply(xdrs, rr)
-\s-1XDR\s0 *xdrs;
-struct rejected_reply *rr;
-.fi
-.ft R
-.IP
-Used for describing
-.SM RPC
-reply messages.
-This routine is useful for users who wish to generate
-.SM RPC\s0-style
-messages without using the
-.SM RPC
-package.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-xdr_replymsg(xdrs, rmsg)
-\s-1XDR\s0 *xdrs;
-struct rpc_msg *rmsg;
-.fi
-.ft R
-.IP
-Used for describing
-.SM RPC
-reply messages.
-This routine is useful for users who wish to generate
-.SM RPC
-style messages without using the
-.SM RPC
-package.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-void
-xprt_register(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-After
-.SM RPC
-service transport handles are created,
-they should register themselves with the
-.SM RPC
-service package.
-This routine modifies the global variable
-.BR svc_fds(\|) .
-Service implementors usually do not need this routine.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-void
-xprt_unregister(xprt)
-\s-1SVCXPRT\s0 *xprt;
-.fi
-.ft R
-.IP
-Before an
-.SM RPC
-service transport handle is destroyed,
-it should unregister itself with the
-.SM RPC
-service package.
-This routine modifies the global variable
-.BR svc_fds(\|) .
-Service implementors usually do not need this routine.
-.SH SEE ALSO
-.BR rpc_secure (3),
-.BR xdr (3)
-.br
-The following manuals:
-.RS
-.ft I
-Remote Procedure Calls: Protocol Specification
-.br
-Remote Procedure Call Programming Guide
-.br
-rpcgen Programming Guide
-.br
-.ft R
-.RE
-.IR "\s-1RPC\s0: Remote Procedure Call Protocol Specification" ,
-.SM RFC1050, Sun Microsystems, Inc.,
-.SM USC-ISI\s0.
-
Index: rvices/librpc/src/rpc/rpc.5
===================================================================
--- services/librpc/src/rpc/rpc.5	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,35 +1,0 @@
-.\" $FreeBSD: src/lib/libc/rpc/rpc.5,v 1.6 1999/08/28 00:00:44 peter Exp $
-.\" @(#)rpc.5	2.2 88/08/03 4.0 RPCSRC; from 1.4 87/11/27 SMI;
-.Dd September 26, 1985
-.Dt RPC 5
-.Sh NAME
-.Nm rpc
-.Nd rpc program number data base
-.Sh SYNOPSIS
-/etc/rpc
-.Sh DESCRIPTION
-The
-.Pa /etc/rpc
-file contains user readable names that
-can be used in place of rpc program numbers.
-Each line has the following information:
-.Pp
-.Bl -bullet -compact
-.It
-name of server for the rpc program
-.It
-rpc program number
-.It
-aliases
-.El
-.Pp
-Items are separated by any number of blanks and/or
-tab characters.
-A ``#'' indicates the beginning of a comment; characters up to the end of
-the line are not interpreted by routines which search the file.
-.Sh FILES
-.Bl -tag -compact -width /etc/rpc
-.Pa /etc/rpc
-.El
-.Sh "SEE ALSO"
-.Xr getrpcent 3
Index: rvices/librpc/src/rpc/rpc_callmsg.c
===================================================================
--- services/librpc/src/rpc/rpc_callmsg.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,196 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)rpc_callmsg.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/rpc_callmsg.c,v 1.9 1999/08/28 00:00:45 peter Exp $";
-#endif
-
-/*
- * rpc_callmsg.c
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/param.h>
-#include <stdlib.h>
-#include <string.h>
-#include <rpc/rpc.h>
-
-/*
- * XDR a call message
- */
-bool_t
-xdr_callmsg(
-	XDR *xdrs,
-	struct rpc_msg *cmsg)
-{
-	register int32_t *buf;
-	register struct opaque_auth *oa;
-
-	if (xdrs->x_op == XDR_ENCODE) {
-		if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) {
-			return (FALSE);
-		}
-		if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
-			return (FALSE);
-		}
-		buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
-			+ RNDUP(cmsg->rm_call.cb_cred.oa_length)
-			+ 2 * BYTES_PER_XDR_UNIT
-			+ RNDUP(cmsg->rm_call.cb_verf.oa_length));
-		if (buf != NULL) {
-			IXDR_PUT_LONG(buf, cmsg->rm_xid);
-			IXDR_PUT_ENUM(buf, cmsg->rm_direction);
-			if (cmsg->rm_direction != CALL) {
-				return (FALSE);
-			}
-			IXDR_PUT_LONG(buf, cmsg->rm_call.cb_rpcvers);
-			if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
-				return (FALSE);
-			}
-			IXDR_PUT_LONG(buf, cmsg->rm_call.cb_prog);
-			IXDR_PUT_LONG(buf, cmsg->rm_call.cb_vers);
-			IXDR_PUT_LONG(buf, cmsg->rm_call.cb_proc);
-			oa = &cmsg->rm_call.cb_cred;
-			IXDR_PUT_ENUM(buf, oa->oa_flavor);
-			IXDR_PUT_LONG(buf, oa->oa_length);
-			if (oa->oa_length) {
-				memcpy((caddr_t)buf, oa->oa_base, oa->oa_length);
-				buf += RNDUP(oa->oa_length) / sizeof (int32_t);
-			}
-			oa = &cmsg->rm_call.cb_verf;
-			IXDR_PUT_ENUM(buf, oa->oa_flavor);
-			IXDR_PUT_LONG(buf, oa->oa_length);
-			if (oa->oa_length) {
-				memcpy((caddr_t)buf, oa->oa_base, oa->oa_length);
-				/* no real need....
-				buf += RNDUP(oa->oa_length) / sizeof (int32_t);
-				*/
-			}
-			return (TRUE);
-		}
-	}
-	if (xdrs->x_op == XDR_DECODE) {
-		buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
-		if (buf != NULL) {
-			cmsg->rm_xid = IXDR_GET_LONG(buf);
-			cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
-			if (cmsg->rm_direction != CALL) {
-				return (FALSE);
-			}
-			cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG(buf);
-			if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
-				return (FALSE);
-			}
-			cmsg->rm_call.cb_prog = IXDR_GET_LONG(buf);
-			cmsg->rm_call.cb_vers = IXDR_GET_LONG(buf);
-			cmsg->rm_call.cb_proc = IXDR_GET_LONG(buf);
-			oa = &cmsg->rm_call.cb_cred;
-			oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
-			oa->oa_length = IXDR_GET_LONG(buf);
-			if (oa->oa_length) {
-				if (oa->oa_length > MAX_AUTH_BYTES) {
-					return (FALSE);
-				}
-				if (oa->oa_base == NULL) {
-					oa->oa_base = (caddr_t)
-						mem_alloc(oa->oa_length);
-				}
-				buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
-				if (buf == NULL) {
-					if (xdr_opaque(xdrs, oa->oa_base,
-					    oa->oa_length) == FALSE) {
-						return (FALSE);
-					}
-				} else {
-					memcpy(oa->oa_base, (caddr_t)buf,
-					    oa->oa_length);
-					/* no real need....
-					buf += RNDUP(oa->oa_length) /
-						sizeof (int32_t);
-					*/
-				}
-			}
-			oa = &cmsg->rm_call.cb_verf;
-			buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
-			if (buf == NULL) {
-				if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
-				    xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
-					return (FALSE);
-				}
-			} else {
-				oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
-				oa->oa_length = IXDR_GET_LONG(buf);
-			}
-			if (oa->oa_length) {
-				if (oa->oa_length > MAX_AUTH_BYTES) {
-					return (FALSE);
-				}
-				if (oa->oa_base == NULL) {
-					oa->oa_base = (caddr_t)
-						mem_alloc(oa->oa_length);
-				}
-				buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
-				if (buf == NULL) {
-					if (xdr_opaque(xdrs, oa->oa_base,
-					    oa->oa_length) == FALSE) {
-						return (FALSE);
-					}
-				} else {
-					memcpy(oa->oa_base, (caddr_t)buf,
-					    oa->oa_length);
-					/* no real need...
-					buf += RNDUP(oa->oa_length) /
-						sizeof (int32_t);
-					*/
-				}
-			}
-			return (TRUE);
-		}
-	}
-	if (
-	    xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) &&
-	    xdr_enum(xdrs, (enum_t *)(void *)&(cmsg->rm_direction)) &&
-	    (cmsg->rm_direction == CALL) &&
-	    xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
-	    (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
-	    xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) &&
-	    xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)) &&
-	    xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_proc)) &&
-	    xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
-	    return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
-	return (FALSE);
-}
Index: rvices/librpc/src/rpc/rpc_commondata.c
===================================================================
--- services/librpc/src/rpc/rpc_commondata.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)rpc_commondata.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/rpc_commondata.c,v 1.7 1999/08/28 00:00:45 peter Exp $";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#ifdef __rtems__
-	#include <rpc/clnt.h>
-#endif
-
-/*
- * This file should only contain common data (global data) that is exported
- * by public interfaces
- */
-struct opaque_auth _null_auth;
-struct rpc_createerr rpc_createerr;
Index: rvices/librpc/src/rpc/rpc_dtablesize.c
===================================================================
--- services/librpc/src/rpc/rpc_dtablesize.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,65 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";*/
-/*static char *sccsid = "from: @(#)rpc_dtablesize.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/rpc_dtablesize.c,v 1.10 1999/08/28 00:00:45 peter Exp $";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/types.h>
-#include <unistd.h>
-
-/*
- * Cache the result of getdtablesize(), so we don't have to do an
- * expensive system call every time.
- */
-/*
- * XXX In FreeBSD 2.x, you can have the maximum number of open file
- * descriptors be greater than FD_SETSIZE (which us 256 by default).
- *
- * Since old programs tend to use this call to determine the first arg
- * for select(), having this return > FD_SETSIZE is a Bad Idea(TM)!
- */
-int
-_rpc_dtablesize(void)
-{
-	static int size;
-
-	if (size == 0) {
-		size = getdtablesize();
-		if (size > FD_SETSIZE)
-			size = FD_SETSIZE;
-	}
-	return (size);
-}
Index: rvices/librpc/src/rpc/rpc_prot.c
===================================================================
--- services/librpc/src/rpc/rpc_prot.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,336 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)rpc_prot.c	2.3 88/08/07 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/rpc_prot.c,v 1.8 1999/08/28 00:00:46 peter Exp $";
-#endif
-
-/*
- * rpc_prot.c
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * This set of routines implements the rpc message definition,
- * its serializer and some common rpc utility routines.
- * The routines are meant for various implementations of rpc -
- * they are NOT for the rpc client or rpc service implementations!
- * Because authentication stuff is easy and is part of rpc, the opaque
- * routines are also in this program.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <assert.h>
-#include <sys/param.h>
-
-#include <rpc/rpc.h>
-
-static void accepted(enum accept_stat, struct rpc_err *);
-static void rejected(enum reject_stat, struct rpc_err *);
-
-/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */
-
-extern struct opaque_auth _null_auth;
-
-/*
- * XDR an opaque authentication struct
- * (see auth.h)
- */
-bool_t
-xdr_opaque_auth(
-	XDR *xdrs,
-	struct opaque_auth *ap)
-{
-
-	assert(xdrs != NULL);
-	assert(ap != NULL);
-
-	if (xdr_enum(xdrs, &(ap->oa_flavor)))
-		return (xdr_bytes(xdrs, &ap->oa_base,
-			&ap->oa_length, MAX_AUTH_BYTES));
-	return (FALSE);
-}
-
-/*
- * XDR a DES block
- */
-bool_t
-xdr_des_block(
-	XDR *xdrs,
-	des_block *blkp)
-{
-
-	assert(xdrs != NULL);
-	assert(blkp != NULL);
-
-	return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block)));
-}
-
-/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
-
-/*
- * XDR the MSG_ACCEPTED part of a reply message union
- */
-bool_t
-xdr_accepted_reply(
-	XDR *xdrs,
-	struct accepted_reply *ar)
-{
-
-	/* personalized union, rather than calling xdr_union */
-	if (! xdr_opaque_auth(xdrs, &(ar->ar_verf)))
-		return (FALSE);
-	if (! xdr_enum(xdrs, (enum_t *)(void *)&(ar->ar_stat)))
-		return (FALSE);
-	switch (ar->ar_stat) {
-
-	case SUCCESS:
-		return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
-
-	case PROG_MISMATCH:
-		if (! xdr_u_int32_t(xdrs, &(ar->ar_vers.low)))
-			return (FALSE);
-		return (xdr_u_int32_t(xdrs, &(ar->ar_vers.high)));
-
-	case GARBAGE_ARGS:
-	case SYSTEM_ERR:
-	case PROC_UNAVAIL:
-	case PROG_UNAVAIL:
-		break;
-	}
-	return (TRUE);  /* TRUE => open ended set of problems */
-}
-
-/*
- * XDR the MSG_DENIED part of a reply message union
- */
-bool_t
-xdr_rejected_reply(
-	XDR *xdrs,
-	struct rejected_reply *rr )
-{
-
-	/* personalized union, rather than calling xdr_union */
-	if (! xdr_enum(xdrs, (enum_t *)(void *)&(rr->rj_stat)))
-		return (FALSE);
-	switch (rr->rj_stat) {
-
-	case RPC_MISMATCH:
-		if (! xdr_u_int32_t(xdrs, &(rr->rj_vers.low)))
-			return (FALSE);
-		return (xdr_u_int32_t(xdrs, &(rr->rj_vers.high)));
-
-	case AUTH_ERROR:
-		return (xdr_enum(xdrs, (enum_t *)(void *)&(rr->rj_why)));
-	}
-	return (FALSE);
-}
-
-static const struct xdr_discrim reply_dscrm[3] = {
-	{ (int)MSG_ACCEPTED, (xdrproc_t)xdr_accepted_reply },
-	{ (int)MSG_DENIED, (xdrproc_t)xdr_rejected_reply },
-	{ __dontcare__, NULL_xdrproc_t } };
-
-/*
- * XDR a reply message
- */
-bool_t
-xdr_replymsg(
-	XDR *xdrs,
-	struct rpc_msg *rmsg)
-{
-	if (
-	    xdr_u_int32_t(xdrs, &(rmsg->rm_xid)) &&
-	    xdr_enum(xdrs, (enum_t *)(void *)&(rmsg->rm_direction)) &&
-	    (rmsg->rm_direction == REPLY) )
-		return (xdr_union(xdrs, (enum_t *)(void *)&(rmsg->rm_reply.rp_stat),
-		   (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t));
-	return (FALSE);
-}
-
-
-/*
- * Serializes the "static part" of a call message header.
- * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
- * The rm_xid is not really static, but the user can easily munge on the fly.
- */
-bool_t
-xdr_callhdr(
-	XDR *xdrs,
-	struct rpc_msg *cmsg)
-{
-
-	cmsg->rm_direction = CALL;
-	cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
-	if (
-	    (xdrs->x_op == XDR_ENCODE) &&
-	    xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) &&
-	    xdr_enum(xdrs, (enum_t *)(void *)&(cmsg->rm_direction)) &&
-	    xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
-	    xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) )
-	    return (xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)));
-	return (FALSE);
-}
-
-/* ************************** Client utility routine ************* */
-
-static void
-accepted(
-	enum accept_stat acpt_stat,
-	struct rpc_err *error)
-{
-
-	assert(error != NULL);
-
-	switch (acpt_stat) {
-
-	case PROG_UNAVAIL:
-		error->re_status = RPC_PROGUNAVAIL;
-		return;
-
-	case PROG_MISMATCH:
-		error->re_status = RPC_PROGVERSMISMATCH;
-		return;
-
-	case PROC_UNAVAIL:
-		error->re_status = RPC_PROCUNAVAIL;
-		return;
-
-	case GARBAGE_ARGS:
-		error->re_status = RPC_CANTDECODEARGS;
-		return;
-
-	case SYSTEM_ERR:
-		error->re_status = RPC_SYSTEMERROR;
-		return;
-
-	case SUCCESS:
-		error->re_status = RPC_SUCCESS;
-		return;
-	}
-	/* something's wrong, but we don't know what ... */
-	error->re_status = RPC_FAILED;
-	error->re_lb.s1 = (int32_t)MSG_ACCEPTED;
-	error->re_lb.s2 = (int32_t)acpt_stat;
-}
-
-static void
-rejected(
-	enum reject_stat rjct_stat,
-	struct rpc_err *error)
-{
-
-	assert(error != NULL);
-
-	switch (rjct_stat) {
-	case RPC_MISMATCH:
-		error->re_status = RPC_VERSMISMATCH;
-		return;
-
-	case AUTH_ERROR:
-		error->re_status = RPC_AUTHERROR;
-		return;
-	}
-	/* something's wrong, but we don't know what ... */
-	error->re_status = RPC_FAILED;
-	error->re_lb.s1 = (int32_t)MSG_DENIED;
-	error->re_lb.s2 = (int32_t)rjct_stat;
-}
-
-/*
- * given a reply message, fills in the error
- */
-void
-_seterr_reply(
-	struct rpc_msg *msg,
-	struct rpc_err *error)
-{
-
-	assert(msg != NULL);
-	assert(error != NULL);
-
-	/* optimized for normal, SUCCESSful case */
-	switch (msg->rm_reply.rp_stat) {
-
-	case MSG_ACCEPTED:
-		if (msg->acpted_rply.ar_stat == SUCCESS) {
-			error->re_status = RPC_SUCCESS;
-			return;
-		}
-		accepted(msg->acpted_rply.ar_stat, error);
-		break;
-
-	case MSG_DENIED:
-		rejected(msg->rjcted_rply.rj_stat, error);
-		break;
-
-	default:
-		error->re_status = RPC_FAILED;
-		error->re_lb.s1 = (int32_t)(msg->rm_reply.rp_stat);
-		break;
-	}
-	switch (error->re_status) {
-
-	case RPC_VERSMISMATCH:
-		error->re_vers.low = msg->rjcted_rply.rj_vers.low;
-		error->re_vers.high = msg->rjcted_rply.rj_vers.high;
-		break;
-
-	case RPC_AUTHERROR:
-		error->re_why = msg->rjcted_rply.rj_why;
-		break;
-
-	case RPC_PROGVERSMISMATCH:
-		error->re_vers.low = msg->acpted_rply.ar_vers.low;
-		error->re_vers.high = msg->acpted_rply.ar_vers.high;
-		break;
-
-	case RPC_FAILED:
-	case RPC_SUCCESS:
-	case RPC_PROGNOTREGISTERED:
-	case RPC_PMAPFAILURE:
-	case RPC_UNKNOWNPROTO:
-	case RPC_UNKNOWNHOST:
-	case RPC_SYSTEMERROR:
-	case RPC_CANTDECODEARGS:
-	case RPC_PROCUNAVAIL:
-	case RPC_PROGUNAVAIL:
-	case RPC_TIMEDOUT:
-	case RPC_CANTRECV:
-	case RPC_CANTSEND:
-	case RPC_CANTDECODERES:
-	case RPC_CANTENCODEARGS:
-	default:
-		break;
-	}
-}
Index: rvices/librpc/src/rpc/rpc_secure.3
===================================================================
--- services/librpc/src/rpc/rpc_secure.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,254 +1,0 @@
-.\" @(#)rpc_secure.3n	2.1 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
-.\" $FreeBSD: src/lib/libc/rpc/rpc_secure.3,v 1.6 2000/03/02 09:13:48 sheldonh Exp $
-.\"
-.Dd February 16, 1988
-.Dt RPC 3
-.Sh NAME
-.Nm rpc_secure
-.Nd library routines for secure remote procedure calls
-.Sh SYNOPSIS
-.Fd #include <rpc/rpc.h>
-.Ft AUTH *
-.Fo authdes_create
-.Fa "char *name"
-.Fa "unsigned window"
-.Fa "struct sockaddr *addr"
-.Fa "des_block *ckey"
-.Fc
-.Ft int
-.Fn authdes_getucred "struct authdes_cred *adc" "uid_t *uid" "gid_t *gid" "int *grouplen" "gid_t *groups"
-.Ft int
-.Fn getnetname "char *name"
-.Ft int
-.Fn host2netname "char *name" "char *host" "char *domain"
-.Ft int
-.Fn key_decryptsession "const char *remotename" "des_block *deskey"
-.Ft int
-.Fn key_encryptsession "const char *remotename" "des_block *deskey"
-.Ft int
-.Fn key_gendes "des_block *deskey"
-.Ft int
-.Fn key_setsecret "const char *key"
-.Ft int
-.Fn netname2host "char *name" "char *host" "int hostlen"
-.Ft int
-.Fn netname2user "char *name" "uid_t *uidp" "gid_t *gidp" "int *gidlenp" "gid_t *gidlist"
-.Ft int
-.Fn user2netname "char *name" "uid_t uid" "char *domain"
-.Sh DESCRIPTION
-These routines are part of the
-.Tn RPC
-library.  They implement
-.Tn DES
-Authentication.  See
-.Xr rpc 3
-for further details about
-.Tn RPC .
-.Pp
-The
-.Fn authdes_create
-is the first of two routines which interface to the
-.Tn RPC
-secure authentication system, known as
-.Tn DES
-authentication.
-The second is
-.Fn authdes_getucred ,
-below.
-.Pp
-Note: the keyserver daemon
-.Xr keyserv 8
-must be running for the
-.Tn DES
-authentication system to work.
-.Pp
-.Fn Authdes_create ,
-used on the client side, returns an authentication handle that
-will enable the use of the secure authentication system.
-The first parameter
-.Fa name
-is the network name, or
-.Fa netname ,
-of the owner of the server process.
-This field usually
-represents a
-.Fa hostname
-derived from the utility routine
-.Fn host2netname ,
-but could also represent a user name using
-.Fn user2netname .
-The second field is window on the validity of
-the client credential, given in seconds.  A small
-window is more secure than a large one, but choosing
-too small of a window will increase the frequency of
-resynchronizations because of clock drift.
-The third
-parameter
-.Fa addr
-is optional.  If it is
-.Dv NULL ,
-then the authentication system will assume
-that the local clock is always in sync with the server's
-clock, and will not attempt resynchronizations.
-If an address
-is supplied, however, then the system will use the address
-for consulting the remote time service whenever
-resynchronization
-is required.
-This parameter is usually the
-address of the
-.Tn RPC
-server itself.
-The final parameter
-.Fa ckey
-is also optional.  If it is
-.Dv NULL ,
-then the authentication system will
-generate a random
-.Tn DES
-key to be used for the encryption of credentials.
-If it is supplied, however, then it will be used instead.
-.Pp
-.Fn Authdes_getucred ,
-the second of the two
-.Tn DES
-authentication routines,
-is used on the server side for converting a
-.Tn DES
-credential, which is
-operating system independent, into a
-.Ux
-credential.
-This routine differs from utility routine
-.Fn netname2user
-in that
-.Fn authdes_getucred
-pulls its information from a cache, and does not have to do a
-Yellow Pages lookup every time it is called to get its information.
-.Pp
-.Fn Getnetname
-installs the unique, operating-system independent netname of
-the
-caller in the fixed-length array
-.Fa name .
-Returns
-.Dv TRUE
-if it succeeds and
-.Dv FALSE
-if it fails.
-.Pp
-.Fn Host2netname
-converts from a domain-specific hostname to an
-operating-system independent netname.
-Returns
-.Dv TRUE
-if it succeeds and
-.Dv FALSE
-if it fails.
-Inverse of
-.Fn netname2host .
-.Pp
-.Fn Key_decryptsession
-is an interface to the keyserver daemon, which is associated
-with
-.Tn RPC Ns 's
-secure authentication system (
-.Tn DES
-authentication).
-User programs rarely need to call it, or its associated routines
-.Fn key_encryptsession ,
-.Fn key_gendes
-and
-.Fn key_setsecret .
-System commands such as
-.Xr login 1
-and the
-.Tn RPC
-library are the main clients of these four routines.
-.Pp
-.Fn Key_decryptsession
-takes a server netname and a
-.Tn DES
-key, and decrypts the key by
-using the the public key of the the server and the secret key
-associated with the effective uid of the calling process.  It
-is the inverse of
-.Fn key_encryptsession .
-.Pp
-.Fn Key_encryptsession
-is a keyserver interface routine.
-It
-takes a server netname and a des key, and encrypts
-it using the public key of the the server and the secret key
-associated with the effective uid of the calling process.  It
-is the inverse of
-.Fn key_decryptsession .
-.Pp
-.Fn Key_gendes
-is a keyserver interface routine.
-It
-is used to ask the keyserver for a secure conversation key.
-Choosing one
-.Qq random
-is usually not good enough,
-because
-the common ways of choosing random numbers, such as using the
-current time, are very easy to guess.
-.Pp
-.Fn Key_setsecret
-is a keyserver interface routine.
-It is used to set the key for
-the effective
-.Fa uid
-of the calling process.
-.Pp
-.Fn Netname2host
-converts from an operating-system independent netname to a
-domain-specific hostname.
-Returns
-.Dv TRUE
-if it succeeds and
-.Dv FALSE
-if it fails.  Inverse of
-.Fn host2netname .
-.Pp
-.Fn Netname2user
-converts from an operating-system independent netname to a
-domain-specific user ID.
-Returns
-.Dv TRUE
-if it succeeds and
-.Dv FALSE
-if it fails.
-Inverse of
-.Fn user2netname .
-.Pp
-.Fn User2netname
-converts from a domain-specific username to an operating-system
-independent netname.
-Returns
-.Dv TRUE
-if it succeeds and
-.Dv FALSE
-if it fails.
-Inverse of
-.Fn netname2user .
-.Sh SEE ALSO
-.Xr rpc 3 ,
-.Xr xdr 3 ,
-.Xr keyserv 8
-.Pp
-The following manuals:
-.Rs
-.%B Remote Procedure Calls: Protocol Specification
-.Re
-.Rs
-.%B Remote Procedure Call Programming Guide
-.Re
-.Rs
-.%B Rpcgen Programming Guide
-.Re
-.Rs
-.%B RPC: Remote Procedure Call Protocol Specification
-.%O RFC1050, Sun Microsystems Inc., USC-ISI
-.Re
Index: rvices/librpc/src/rpc/rpcdname.c
===================================================================
--- services/librpc/src/rpc/rpcdname.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,88 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user or with the express written consent of
- * Sun Microsystems, Inc.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)rpcdname.c 1.7 91/03/11 Copyr 1989 Sun Micro";
-#endif
-
-/*
- * rpcdname.c
- * Gets the default domain name
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#ifdef __rtems__
-	/* XXX in rpc.h in old .. not new */
-	#include <rpc/rpc_rtems.h>
-#endif
-
-int getdomainname(char *, size_t);
-
-#define default_domain (rtems_rpc_task_variables->rpcdname_default_domain)
-
-static char *
-get_default_domain(void)
-{
-	char temp[256];
-
-	if (default_domain)
-		return (default_domain);
-	if (getdomainname(temp, sizeof(temp)) < 0)
-		return (0);
-	if (strlen(temp) > 0) {
-		default_domain = (char *)malloc((strlen(temp)+(size_t)1));
-		if (default_domain == 0)
-			return (0);
-		(void) strcpy(default_domain, temp);
-		return (default_domain);
-	}
-	return (0);
-}
-
-/*
- * This is a wrapper for the system call getdomainname which returns a
- * ypclnt.h error code in the failure case.  It also checks to see that
- * the domain name is non-null, knowing that the null string is going to
- * get rejected elsewhere in the NIS client package.
- */
-int
-_rpc_get_default_domain(
-	char **domain )
-{
-	if ((*domain = get_default_domain()) != 0)
-		return (0);
-	return (-1);
-}
Index: rvices/librpc/src/rpc/rstat.1
===================================================================
--- services/librpc/src/rpc/rstat.1	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,58 +1,0 @@
-.\" $FreeBSD: src/lib/libc/rpc/rstat.1,v 1.5 1999/08/28 00:00:46 peter Exp $
-.\" @(#)rstat.1	2.1 88/08/03 4.0 RPCSRC
-.TH RSTAT 1 "3 August 1988"
-.SH NAME
-rstat \- remote status display
-.SH SYNOPSIS
-.B rstat
-.B host
-.SH DESCRIPTION
-.LP
-.B rstat
-displays a summary of the current system status of a particular
-.BR host .
-The output shows the current time of day, how long the system has
-been up,
-and the load averages.
-The load average numbers give the number of jobs in the run queue
-averaged over 1, 5 and 15 minutes.
-.PP
-The
-.B rstat_svc(8)
-daemon must be running on the remote host for this command to
-work.
-.B rstat
-uses an RPC protocol defined in /usr/include/rpcsvc/rstat.x.
-.SH EXAMPLE
-.RS
-.ft B
-.nf
-example% rstat otherhost
-7:36am  up 6 days, 16:45,  load average: 0.20, 0.23, 0.18
-example%
-.ft R
-.fi
-.RE
-.SH DIAGNOSTICS
-.LP
-rstat: RPC: Program not registered
-.IP
-The
-.B rstat_svc
-daemon has not been started on the remote host.
-.LP
-rstat: RPC: Timed out
-.IP
-A communication error occurred.  Either the network is
-excessively congested, or the
-.B rstat_svc
-daemon has terminated on the remote host.
-.LP
-rstat: RPC: Port mapper failure - RPC: Timed out
-.IP
-The remote host is not running the portmapper (see
-.BR portmap(8) ),
-and cannot accommodate any RPC-based services.  The host may be down.
-.SH "SEE ALSO"
-.BR portmap (8),
-.BR rstat_svc (8)
Index: rvices/librpc/src/rpc/rstat_svc.8
===================================================================
--- services/librpc/src/rpc/rstat_svc.8	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,22 +1,0 @@
-.\" $FreeBSD: src/lib/libc/rpc/rstat_svc.8,v 1.5 1999/08/28 00:00:47 peter Exp $
-.\" @(#)rstat_svc.8c	2.2 88/08/03 4.0 RPCSRC; from 1.10 87/09/09 SMI
-.TH RSTAT_SVC 8 "24 November 1987"
-.SH NAME
-rstat_svc \- kernel statistics server
-.SH SYNOPSIS
-.B /etc/rstat_svc
-.SH DESCRIPTION
-.LP
-.B rstat_svc
-is a server which returns performance statistics
-obtained from the kernel.
-These statistics are graphically displayed by the Sun Microsystems program,
-.BR perfmeter (1).
-The
-.B rstat_svc
-daemon is normally invoked at boot time through /etc/rc.local.
-.PP
-.B rstat_svc
-uses an RPC protocol defined in /usr/include/rpcsvc/rstat.x.
-.\" .SH "SEE ALSO"
-.\" .BR rstat (1),
Index: rvices/librpc/src/rpc/rtems_portmapper.c
===================================================================
--- services/librpc/src/rpc/rtems_portmapper.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,500 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#include <rpc/pmap_prot.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <malloc.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-#include <sys/signal.h>
-
-static void reg_service(struct svc_req *rqstp, SVCXPRT *xprt);
-static void callit(struct svc_req *rqstp, SVCXPRT *xprt);
-static struct pmaplist *pmaplist;
-static int debugging = 0;
-
-#include <rtems.h>
-#define fork()	(-1)
-
-
-static rtems_task rtems_portmapper (rtems_task_argument unused)
-{
-	SVCXPRT *xprt;
-	int sock;
-	struct sockaddr_in addr;
-	int len = sizeof(struct sockaddr_in);
-	register struct pmaplist *pml;
-
-	rtems_rpc_task_init ();
-	if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
-		perror("portmap cannot create socket");
-		rtems_task_delete (RTEMS_SELF);
-	}
-
-	addr.sin_addr.s_addr = 0;
-	addr.sin_family = AF_INET;
-	addr.sin_port = htons(PMAPPORT);
-	if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
-		perror("portmap cannot bind");
-		close (sock);
-		rtems_task_delete (RTEMS_SELF);
-	}
-
-	if ((xprt = svcudp_create(sock)) == (SVCXPRT *)NULL) {
-		fprintf(stderr, "couldn't do udp_create\n");
-		close (sock);
-		rtems_task_delete (RTEMS_SELF);
-	}
-	/* make an entry for ourself */
-	pml = (struct pmaplist *)malloc(sizeof(struct pmaplist));
-	pml->pml_next = 0;
-	pml->pml_map.pm_prog = PMAPPROG;
-	pml->pml_map.pm_vers = PMAPVERS;
-	pml->pml_map.pm_prot = IPPROTO_UDP;
-	pml->pml_map.pm_port = PMAPPORT;
-	pmaplist = pml;
-
-	if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
-		perror("portmap cannot create socket");
-		close (sock);
-		rtems_task_delete (RTEMS_SELF);
-	}
-	if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
-		perror("portmap cannot bind");
-		close (sock);
-		rtems_task_delete (RTEMS_SELF);
-	}
-	if ((xprt = svctcp_create(sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE))
-	    == (SVCXPRT *)NULL) {
-		fprintf(stderr, "couldn't do tcp_create\n");
-		close (sock);
-		rtems_task_delete (RTEMS_SELF);
-	}
-	/* make an entry for ourself */
-	pml = (struct pmaplist *)malloc(sizeof(struct pmaplist));
-	pml->pml_map.pm_prog = PMAPPROG;
-	pml->pml_map.pm_vers = PMAPVERS;
-	pml->pml_map.pm_prot = IPPROTO_TCP;
-	pml->pml_map.pm_port = PMAPPORT;
-	pml->pml_next = pmaplist;
-	pmaplist = pml;
-
-	(void)svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE);
-
-	svc_run();
-	fprintf(stderr, "run_svc returned unexpectedly\n");
-	close (sock);
-	rtems_task_delete (RTEMS_SELF);
-}
-
-static struct pmaplist *
-find_service(
-  u_long prog,
-  u_long vers,
-  int prot )
-{
-  register struct pmaplist *hit = NULL;
-  register struct pmaplist *pml;
-
-  for (pml = pmaplist; pml != NULL; pml = pml->pml_next) {
-	if ((pml->pml_map.pm_prog != prog) ||
-		(pml->pml_map.pm_prot != prot))
-		continue;
-	hit = pml;
-	if (pml->pml_map.pm_vers == vers)
-	    break;
-  }
-  return (hit);
-}
-
-/* 
- * 1 OK, 0 not
- */
-static void reg_service(
-	struct svc_req *rqstp,
-	SVCXPRT *xprt )
-{
-	struct pmap reg;
-	struct pmaplist *pml, *prevpml, *fnd;
-	int ans, port;
-	caddr_t t;
-	
-#ifdef DEBUG
-	fprintf(stderr, "server: about do a switch\n");
-#endif
-	switch (rqstp->rq_proc) {
-
-	case PMAPPROC_NULL:
-		/*
-		 * Null proc call
-		 */
-		if ((!svc_sendreply(xprt, (xdrproc_t) xdr_void, NULL)) &&
-		     debugging) {
-			abort();
-		}
-		break;
-
-	case PMAPPROC_SET:
-		/*
-		 * Set a program,version to port mapping
-		 */
-		if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (caddr_t)&reg))
-			svcerr_decode(xprt);
-		else {
-			/*
-			 * check to see if already used
-			 * find_service returns a hit even if
-			 * the versions don't match, so check for it
-			 */
-			fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot);
-			if (fnd && fnd->pml_map.pm_vers == reg.pm_vers) {
-				if (fnd->pml_map.pm_port == reg.pm_port) {
-					ans = 1;
-					goto done;
-				}
-				else {
-					ans = 0;
-					goto done;
-				}
-			} else {
-				/* 
-				 * add to END of list
-				 */
-				pml = (struct pmaplist *)
-				    malloc(sizeof(struct pmaplist));
-				pml->pml_map = reg;
-				pml->pml_next = 0;
-				if (pmaplist == 0) {
-					pmaplist = pml;
-				} else {
-					for (fnd= pmaplist; fnd->pml_next != 0;
-					    fnd = fnd->pml_next);
-					fnd->pml_next = pml;
-				}
-				ans = 1;
-			}
-		done:
-			if ((!svc_sendreply(xprt, (xdrproc_t) xdr_long, (caddr_t)&ans)) &&
-			    debugging) {
-				fprintf(stderr, "svc_sendreply\n");
-				abort();
-			}
-		}
-		break;
-
-	case PMAPPROC_UNSET:
-		/*
-		 * Remove a program,version to port mapping.
-		 */
-		if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (caddr_t)&reg))
-			svcerr_decode(xprt);
-		else {
-			ans = 0;
-			for (prevpml = NULL, pml = pmaplist; pml != NULL; ) {
-				if ((pml->pml_map.pm_prog != reg.pm_prog) ||
-					(pml->pml_map.pm_vers != reg.pm_vers)) {
-					/* both pml & prevpml move forwards */
-					prevpml = pml;
-					pml = pml->pml_next;
-					continue;
-				}
-				/* found it; pml moves forward, prevpml stays */
-				ans = 1;
-				t = (caddr_t)pml;
-				pml = pml->pml_next;
-				if (prevpml == NULL)
-					pmaplist = pml;
-				else
-					prevpml->pml_next = pml;
-				free(t);
-			}
-			if ((!svc_sendreply(xprt, (xdrproc_t) xdr_long, (caddr_t)&ans)) &&
-			    debugging) {
-				fprintf(stderr, "svc_sendreply\n");
-				abort();
-			}
-		}
-		break;
-
-	case PMAPPROC_GETPORT:
-		/*
-		 * Lookup the mapping for a program,version and return its port
-		 */
-		if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (caddr_t)&reg))
-			svcerr_decode(xprt);
-		else {
-			fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot);
-			if (fnd)
-				port = fnd->pml_map.pm_port;
-			else
-				port = 0;
-			if ((!svc_sendreply(xprt, (xdrproc_t) xdr_long, (caddr_t)&port)) &&
-			    debugging) {
-				fprintf(stderr, "svc_sendreply\n");
-				abort();
-			}
-		}
-		break;
-
-	case PMAPPROC_DUMP:
-		/*
-		 * Return the current set of mapped program,version
-		 */
-		if (!svc_getargs(xprt, (xdrproc_t) xdr_void, NULL))
-			svcerr_decode(xprt);
-		else {
-			if ((!svc_sendreply(xprt, (xdrproc_t) xdr_pmaplist,
-			    (caddr_t)&pmaplist)) && debugging) {
-				fprintf(stderr, "svc_sendreply\n");
-				abort();
-			}
-		}
-		break;
-
-	case PMAPPROC_CALLIT:
-		/*
-		 * Calls a procedure on the local machine.  If the requested
-		 * procedure is not registered this procedure does not return
-		 * error information!!
-		 * This procedure is only supported on rpc/udp and calls via 
-		 * rpc/udp.  It passes null authentication parameters.
-		 */
-		callit(rqstp, xprt);
-		break;
-
-	default:
-		svcerr_noproc(xprt);
-		break;
-	}
-}
-
-
-/*
- * Stuff for the rmtcall service
- */
-#define ARGSIZE 9000
-
-struct encap_parms {
-	u_long arglen;
-	char *args;
-};
-
-static bool_t
-xdr_encap_parms(
-	XDR *xdrs,
-	struct encap_parms *epp )
-{
-
-	u_int temp_epp_arglen = epp->arglen;
-	return (xdr_bytes(xdrs, &(epp->args), &temp_epp_arglen, ARGSIZE));
-}
-
-struct rmtcallargs {
-	u_long	rmt_prog;
-	u_long	rmt_vers;
-	u_long	rmt_port;
-	u_long	rmt_proc;
-	struct encap_parms rmt_args;
-};
-
-static bool_t
-xdr_rmtcall_args(
-	register XDR *xdrs,
-	register struct rmtcallargs *cap )
-{
-
-	/* does not get a port number */
-	if (xdr_u_long(xdrs, &(cap->rmt_prog)) &&
-	    xdr_u_long(xdrs, &(cap->rmt_vers)) &&
-	    xdr_u_long(xdrs, &(cap->rmt_proc))) {
-		return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
-	}
-	return (FALSE);
-}
-
-static bool_t
-xdr_rmtcall_result(
-	register XDR *xdrs,
-	register struct rmtcallargs *cap )
-{
-	if (xdr_u_long(xdrs, &(cap->rmt_port)))
-		return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
-	return (FALSE);
-}
-
-/*
- * only worries about the struct encap_parms part of struct rmtcallargs.
- * The arglen must already be set!!
- */
-static bool_t
-xdr_opaque_parms(
-	XDR *xdrs,
-	void *args,
-	... )
-{
-        struct rmtcallargs *cap = (struct rmtcallargs *) args;
-
-	return (xdr_opaque(xdrs, cap->rmt_args.args, cap->rmt_args.arglen));
-}
-
-/*
- * This routine finds and sets the length of incoming opaque paraters
- * and then calls xdr_opaque_parms.
- */
-static bool_t
-xdr_len_opaque_parms(
-	XDR *xdrs,
-	void *args, 
-	... )
-{
-        struct rmtcallargs *cap = (struct rmtcallargs *) args;
-	register u_int beginpos, lowpos, highpos, currpos, pos;
-
-	beginpos = lowpos = pos = xdr_getpos(xdrs);
-	highpos = lowpos + ARGSIZE;
-	while ((int)(highpos - lowpos) >= 0) {
-		currpos = (lowpos + highpos) / 2;
-		if (xdr_setpos(xdrs, currpos)) {
-			pos = currpos;
-			lowpos = currpos + 1;
-		} else {
-			highpos = currpos - 1;
-		}
-	}
-	xdr_setpos(xdrs, beginpos);
-	cap->rmt_args.arglen = pos - beginpos;
-	return (xdr_opaque_parms(xdrs, cap));
-}
-
-/*
- * Call a remote procedure service
- * This procedure is very quiet when things go wrong.
- * The proc is written to support broadcast rpc.  In the broadcast case,
- * a machine should shut-up instead of complain, less the requestor be
- * overrun with complaints at the expense of not hearing a valid reply ...
- *
- * This now forks so that the program & process that it calls can call 
- * back to the portmapper.
- */
-static void
-callit(
-	struct svc_req *rqstp,
-	SVCXPRT *xprt )
-{
-	struct rmtcallargs a;
-	struct pmaplist *pml;
-	u_short port;
-	struct sockaddr_in me;
-	int pid, socket = -1;
-	CLIENT *client;
-	struct authunix_parms *au = (struct authunix_parms *)rqstp->rq_clntcred;
-	struct timeval timeout;
-	char buf[ARGSIZE];
-
-	timeout.tv_sec = 5;
-	timeout.tv_usec = 0;
-	a.rmt_args.args = buf;
-	if (!svc_getargs(xprt, (xdrproc_t) xdr_rmtcall_args, (caddr_t)&a))
-	    return;
-	if ((pml = find_service(a.rmt_prog, a.rmt_vers, IPPROTO_UDP)) == NULL)
-	    return;
-	/*
-	 * fork a child to do the work.  Parent immediately returns.
-	 * Child exits upon completion.
-	 */
-	if ((pid = fork()) != 0) {
-		if (debugging && (pid < 0)) {
-			fprintf(stderr, "portmap CALLIT: cannot fork.\n");
-		}
-		return;
-	}
-	port = pml->pml_map.pm_port;
-	get_myaddress(&me);
-	me.sin_port = htons(port);
-	client = clntudp_create(&me, a.rmt_prog, a.rmt_vers, timeout, &socket);
-	if (client != (CLIENT *)NULL) {
-		if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) {
-			client->cl_auth = authunix_create(au->aup_machname,
-			   au->aup_uid, au->aup_gid, au->aup_len, au->aup_gids);
-		}
-		a.rmt_port = (u_long)port;
-		if (clnt_call(client, a.rmt_proc, xdr_opaque_parms, &a,
-		    xdr_len_opaque_parms, &a, timeout) == RPC_SUCCESS) {
-			svc_sendreply(xprt, (xdrproc_t) xdr_rmtcall_result, (caddr_t)&a);
-		}
-		AUTH_DESTROY(client->cl_auth);
-		clnt_destroy(client);
-	}
-	(void)close(socket);
-	exit(0);
-}
-
-/*
- * Start the RPC portmapper
- */
-int rtems_rpc_start_portmapper (int priority)
-{
-	rtems_mode mode;
-	rtems_status_code sc;
-	rtems_id tid;
-	static int started;
-
-	rtems_task_mode (RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &mode);
-	if (started) {
-		rtems_task_mode (mode, RTEMS_PREEMPT_MASK, &mode);
-		return RTEMS_SUCCESSFUL;
-	}
-	sc = rtems_task_create (rtems_build_name('P', 'M', 'A', 'P'),
-		priority,
-		ARGSIZE + 8000,
-		RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
-		RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
-		&tid);
-	if (sc != RTEMS_SUCCESSFUL) {
-		rtems_task_mode (mode, RTEMS_PREEMPT_MASK, &mode);
-		return sc;
-	}
-	sc = rtems_task_start (tid, rtems_portmapper, 0);
-	if (sc != RTEMS_SUCCESSFUL) {
-		rtems_task_mode (mode, RTEMS_PREEMPT_MASK, &mode);
-		return sc;
-	}
-	started = 1;
-	rtems_task_mode (mode, RTEMS_PREEMPT_MASK, &mode);
-	return RTEMS_SUCCESSFUL;
-}
Index: rvices/librpc/src/rpc/rtems_rpc.c
===================================================================
--- services/librpc/src/rpc/rtems_rpc.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,99 +1,0 @@
-/*
- * RTEMS multi-tasking support
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#include <rtems.h>
-#include <stdlib.h>
-#ifdef __rtems__
-	/* XXX in rpc.h in old .. not new */
-	#include <rpc/rpc_rtems.h>
-#endif
-
-/*
- * RPC variables for single-thread
- */
-static struct _rtems_rpc_task_variables rpc_default = {
-	-1,		/* svc_maxfd */
-	{{0}},		/* svc_svc_fdset */
-	NULL,		/* svc_xports */
-	0,		/* svc_xportssize */
-	0,		/* svc__svc_fdsetsize */		
-	0,		/* svc__svc_fdset */
-	NULL,		/* svc_svc_head */
-	0,		/* clnt_perror_buf */
-	0,		/* clnt_raw_private */
-	0,		/* call_rpc_private */
-	0,		/* svc_raw_private */
-
-	0,		/* svc_simple_proglst */
-	0,		/* svc_simple_pl */
-	0,		/* svc_simple_transp */
-
-	0,		/* rpcdname_default_domain */
-	0		/* svc_auths_Auths */
-};
-
-/*
- * RPC values for initializing a new per-task set of variables
- */
-static const struct _rtems_rpc_task_variables rpc_init = {
-	-1,		/* svc_maxfd */
-	{{0}},		/* svc_svc_fdset */
-	NULL,		/* svc_xports */
-	0,		/* svc_xportssize */
-	0,		/* svc__svc_fdsetsize */		
-	0,		/* svc__svc_fdset */
-	NULL,		/* svc_svc_head */
-	0,		/* clnt_perror_buf */
-	0,		/* clnt_raw_private */
-	0,		/* call_rpc_private */
-	0,		/* svc_raw_private */
-
-	0,		/* svc_simple_proglst */
-	0,		/* svc_simple_pl */
-	0,		/* svc_simple_transp */
-
-	0,		/* rpcdname_default_domain */
-	0		/* svc_auths_Auths */
-};
-
-/*
- * Per-task pointer to RPC data
- */
-struct _rtems_rpc_task_variables *rtems_rpc_task_variables = &rpc_default;
-
-/*
- * Set up per-task RPC variables
- */
-int rtems_rpc_task_init (void)
-{
-	rtems_status_code sc;
-	struct _rtems_rpc_task_variables *tvp;
-
-	if (rtems_rpc_task_variables == &rpc_default) {
-		tvp = malloc (sizeof *tvp);
-		if (tvp == NULL)
-			return RTEMS_NO_MEMORY;
-		/*
-		 * FIXME: Should have destructor which cleans up
-		 * all RPC stuff:
-		 *	- Close all files
-		 *	- Go through and free linked list elements
-		 *	- Free other allocated memory (e.g. clnt_perror_buf)
-		 */
-		sc = rtems_task_variable_add (
-			RTEMS_SELF, (void *)&rtems_rpc_task_variables, NULL);
-		if (sc != RTEMS_SUCCESSFUL) {
-			free (tvp);
-			return sc;
-		}
-		*tvp = rpc_init;
-		rtems_rpc_task_variables = tvp;
-	}
-	return RTEMS_SUCCESSFUL;
-}
Index: rvices/librpc/src/rpc/rtime.3
===================================================================
--- services/librpc/src/rpc/rtime.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,47 +1,0 @@
-.\" @(#)rtime.3n	2.1 88/08/08 4.0 RPCSRC; from 1.5 88/02/08 SMI
-.\" $FreeBSD: src/lib/libc/rpc/rtime.3,v 1.4 2000/03/02 09:13:48 sheldonh Exp $
-.\"
-.TH RTIME 3  "22 November 1987"
-.SH NAME
-rtime \- get remote time
-.SH SYNOPSIS
-.nf
-.B #include <sys/types.h>
-.B #include <sys/time.h>
-.B #include <netinet/in.h>
-.LP
-.B int rtime(addrp, timep, timeout)
-.B struct sockaddr_in \(**addrp;
-.B struct timeval \(**timep;
-.B struct timeval \(**timeout;
-.fi
-.SH DESCRIPTION
-.B rtime(\|)
-consults the Internet Time Server at the address pointed to by
-.I addrp
-and returns the remote time in the
-.B timeval
-struct pointed to by
-.IR timep .
-Normally, the
-.SM UDP
-protocol is used when consulting the Time Server.
-The
-.I timeout
-parameter specifies how long the
-routine should wait before giving
-up when waiting for a reply.  If
-.I timeout
-is specified as
-.SM NULL\s0,
-however, the routine will instead use
-.SM TCP
-and block until a reply is received from the time server.
-.LP
-The routine returns 0 if it is successful.
-Otherwise,
-it returns \-1 and
-.B errno
-is set to reflect the cause of the error.
-.SH "SEE ALSO"
-.BR timed (8c)
Index: rvices/librpc/src/rpc/rtime.c
===================================================================
--- services/librpc/src/rpc/rtime.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,163 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
-
- */
-
-/*
- * rtime - get time from remote machine
- *
- * gets time, obtaining value from host
- * on the udp/time socket.  Since timeserver returns
- * with time of day in seconds since Jan 1, 1900,  must
- * subtract seconds before Jan 1, 1970 to get
- * what unix uses.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <sys/select.h>
-#include <inttypes.h>
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/* from: static char sccsid[] = 	"@(#)rtime.c	2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 SMI"; */
-static const char rcsid[] = "$FreeBSD: src/lib/libc/rpc/rtime.c,v 1.5 2000/01/27 23:06:41 jasone Exp $";
-#endif
-
-extern int _rpc_dtablesize( void );
-
-#define NYEARS	(UINT32_C(1970) - UINT32_C(1900))
-#define TOFFSET (UINT32_C(60)*UINT32_C(60)*UINT32_C(24)*(UINT32_C(365)*NYEARS + (NYEARS/UINT32_C(4))))
-
-static void do_close( int );
-
-int
-rtime(
-	struct sockaddr_in *addrp,
-	struct timeval *timep,
-	struct timeval *timeout )
-{
-	int s;
-	fd_set readfds;
-	int res;
-	uint32_t thetime;
-	struct sockaddr_in from;
-	socklen_t fromlen;
-	int type;
-	struct servent *serv;
-
-	if (timeout == NULL) {
-		type = SOCK_STREAM;
-	} else {
-		type = SOCK_DGRAM;
-	}
-	s = socket(AF_INET, type, 0);
-	if (s < 0) {
-		return(-1);
-	}
-	addrp->sin_family = AF_INET;
-
-	/* TCP and UDP port are the same in this case */
-	if ((serv = getservbyname("time", "tcp")) == NULL) {
-		return(-1);
-	}
-
-	addrp->sin_port = serv->s_port;
-
-	if (type == SOCK_DGRAM) {
-		res = sendto(s, (char *)&thetime, sizeof(thetime), 0, 
-			     (struct sockaddr *)addrp, sizeof(*addrp));
-		if (res < 0) {
-			do_close(s);
-			return(-1);	
-		}
-		do {
-			FD_ZERO(&readfds);
-			FD_SET(s, &readfds);
-			res = select(_rpc_dtablesize(), &readfds,
-				     (fd_set *)NULL, (fd_set *)NULL, timeout);
-		} while (res < 0 && errno == EINTR);
-		if (res <= 0) {
-			if (res == 0) {
-				errno = ETIMEDOUT;
-			}
-			do_close(s);
-			return(-1);	
-		}
-		fromlen = sizeof(from);
-		res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0, 
-			       (struct sockaddr *)&from, &fromlen);
-		do_close(s);
-		if (res < 0) {
-			return(-1);	
-		}
-	} else {
-		if (connect(s, (struct sockaddr *)addrp, sizeof(*addrp)) < 0) {
-			do_close(s);
-			return(-1);
-		}
-		res = _RPC_read(s, (char *)&thetime, sizeof(thetime));
-		do_close(s);
-		if (res < 0) {
-			return(-1);
-		}
-	}
-	if (res != sizeof(thetime)) {
-		errno = EIO;
-		return(-1);	
-	}
-	thetime = ntohl(thetime);
-	timep->tv_sec = thetime - TOFFSET;
-	timep->tv_usec = 0;
-	return(0);
-}
-
-static void
-do_close(int s)
-{
-	int save;
-
-	save = errno;
-	(void)_RPC_close(s);
-	errno = save;
-}
Index: rvices/librpc/src/rpc/svc.c
===================================================================
--- services/librpc/src/rpc/svc.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,503 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)svc.c	2.4 88/08/11 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc.c,v 1.14 1999/08/28 00:00:48 peter Exp $";
-#endif
-
-/*
- * svc.c, Server-side remote procedure call interface.
- *
- * There are two sets of procedures here.  The xprt routines are
- * for handling transport handles.  The svc routines handle the
- * list of service routines.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#ifdef HAVE_STRINGS_H
-#include <strings.h> /* for ffs */
-#endif
-#include <stdlib.h>
-#include <sys/errno.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#ifdef __rtems__
-	/* XXX in rpc.h in old .. not new */
-	#include <rpc/rpc_rtems.h>
-#endif
-
-#define xports (rtems_rpc_task_variables->svc_xports)
-#define xportssize (rtems_rpc_task_variables->svc_xportssize)
-
-#define NULL_SVC ((struct svc_callout *)0)
-#define	RQCRED_SIZE	400		/* this size is excessive */
-
-#define max(a, b) (a > b ? a : b)
-
-/*
- * The services list
- * Each entry represents a set of procedures (an rpc program).
- * The dispatch routine takes request structs and runs the
- * apropriate procedure.
- */
-struct svc_callout {
-	struct svc_callout *sc_next;
-	u_long		    sc_prog;
-	u_long		    sc_vers;
-	void		    (*sc_dispatch)(struct svc_req *r, SVCXPRT *xprt);
-};
-#define svc_head (rtems_rpc_task_variables->svc_svc_head)
-
-static struct svc_callout *svc_find(u_long prog, u_long vers, 
-  struct svc_callout **prev);
-
-/* ***************  SVCXPRT related stuff **************** */
-
-/*
- * Activate a transport handle.
- */
-void
-xprt_register(
-	SVCXPRT *xprt )
-{
-	register int sock = xprt->xp_fd;
-
-	if (sock + 1 > __svc_fdsetsize) {
-		int bytes = sizeof (fd_set);
-		fd_set *fds;
-
-		fds = (fd_set *)malloc(bytes);
-		memset(fds, 0, bytes);
-		if (__svc_fdset) {
-			memcpy(fds, __svc_fdset, bytes);
-			free(__svc_fdset);
-		}
-		__svc_fdset = fds;
-		__svc_fdsetsize = bytes * NBBY;
-	}
-
-	if (sock < FD_SETSIZE)
-		FD_SET(sock, &svc_fdset);
-	FD_SET(sock, __svc_fdset);
-
-	if (xports == NULL || sock + 1 > xportssize) {
-		SVCXPRT **xp;
-		int size = FD_SETSIZE;
-
-		if (sock + 1 > size)
-			size = sock + 1;
-		xp = (SVCXPRT **)mem_alloc(size * sizeof(SVCXPRT *));
-		memset(xp, 0, size * sizeof(SVCXPRT *));
-		if (xports) {
-			memcpy(xp, xports, xportssize * sizeof(SVCXPRT *));
-			free(xports);
-		}
-		xportssize = size;
-		xports = xp;
-	}
-	xports[sock] = xprt;
-	svc_maxfd = max(svc_maxfd, sock);
-}
-
-/*
- * De-activate a transport handle.
- */
-void
-xprt_unregister(
-	SVCXPRT *xprt )
-{
-	register int sock = xprt->xp_fd;
-
-	if (xports[sock] == xprt) {
-		xports[sock] = (SVCXPRT *)0;
-		if (sock < FD_SETSIZE)
-			FD_CLR(sock, &svc_fdset);
-		FD_CLR(sock, __svc_fdset);
-		if (sock == svc_maxfd) {
-			for (svc_maxfd--; svc_maxfd >= 0; svc_maxfd--)
-				if (xports[svc_maxfd])
-					break;
-		}
-		/*
-		 * XXX could use svc_maxfd as a hint to
-		 * decrease the size of __svc_fdset
-		 */
-	}
-}
-
-
-/* ********************** CALLOUT list related stuff ************* */
-
-/*
- * Add a service program to the callout list.
- * The dispatch routine will be called when a rpc request for this
- * program number comes in.
- */
-bool_t
-svc_register(
-	SVCXPRT *xprt,
-	u_long prog,
-	u_long vers,
-	void (*dispatch)(struct svc_req *r, SVCXPRT *xprt),
-	int protocol )
-{
-	struct svc_callout *prev;
-	register struct svc_callout *s;
-
-	if ((s = svc_find(prog, vers, &prev)) != NULL_SVC) {
-		if (s->sc_dispatch == dispatch)
-			goto pmap_it;  /* he is registering another xptr */
-		return (FALSE);
-	}
-	s = (struct svc_callout *)mem_alloc(sizeof(struct svc_callout));
-	if (s == (struct svc_callout *)0) {
-		return (FALSE);
-	}
-	s->sc_prog = prog;
-	s->sc_vers = vers;
-	s->sc_dispatch = dispatch;
-	s->sc_next = svc_head;
-	svc_head = s;
-pmap_it:
-	/* now register the information with the local binder service */
-	if (protocol) {
-		return (pmap_set(prog, vers, protocol, xprt->xp_port));
-	}
-	return (TRUE);
-}
-
-/*
- * Remove a service program from the callout list.
- */
-void
-svc_unregister(
-	u_long prog,
-	u_long vers )
-{
-	struct svc_callout *prev;
-	register struct svc_callout *s;
-
-	if ((s = svc_find(prog, vers, &prev)) == NULL_SVC)
-		return;
-	if (prev == NULL_SVC) {
-		svc_head = s->sc_next;
-	} else {
-		prev->sc_next = s->sc_next;
-	}
-	s->sc_next = NULL_SVC;
-	mem_free((char *) s, (u_int) sizeof(struct svc_callout));
-	/* now unregister the information with the local binder service */
-	(void)pmap_unset(prog, vers);
-}
-
-/*
- * Search the callout list for a program number, return the callout
- * struct.
- */
-static struct svc_callout *
-svc_find(
-	u_long prog,
-	u_long vers,
-	struct svc_callout **prev )
-{
-	register struct svc_callout *s, *p;
-
-	p = NULL_SVC;
-	for (s = svc_head; s != NULL_SVC; s = s->sc_next) {
-		if ((s->sc_prog == prog) && (s->sc_vers == vers))
-			goto done;
-		p = s;
-	}
-done:
-	*prev = p;
-	return (s);
-}
-
-/* ******************* REPLY GENERATION ROUTINES  ************ */
-
-/*
- * Send a reply to an rpc request
- */
-bool_t
-svc_sendreply(
-	register SVCXPRT *xprt,
-	xdrproc_t xdr_results,
-	void *xdr_location )
-{
-	struct rpc_msg rply;
-
-	rply.rm_direction = REPLY;
-	rply.rm_reply.rp_stat = MSG_ACCEPTED;
-	rply.acpted_rply.ar_verf = xprt->xp_verf;
-	rply.acpted_rply.ar_stat = SUCCESS;
-	rply.acpted_rply.ar_results.where = xdr_location;
-	rply.acpted_rply.ar_results.proc = xdr_results;
-	return (SVC_REPLY(xprt, &rply));
-}
-
-/*
- * No procedure error reply
- */
-void
-svcerr_noproc(
-	register SVCXPRT *xprt )
-{
-	struct rpc_msg rply;
-
-	rply.rm_direction = REPLY;
-	rply.rm_reply.rp_stat = MSG_ACCEPTED;
-	rply.acpted_rply.ar_verf = xprt->xp_verf;
-	rply.acpted_rply.ar_stat = PROC_UNAVAIL;
-	SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Can't decode args error reply
- */
-void
-svcerr_decode(
-	register SVCXPRT *xprt )
-{
-	struct rpc_msg rply;
-
-	rply.rm_direction = REPLY;
-	rply.rm_reply.rp_stat = MSG_ACCEPTED;
-	rply.acpted_rply.ar_verf = xprt->xp_verf;
-	rply.acpted_rply.ar_stat = GARBAGE_ARGS;
-	SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Some system error
- */
-void
-svcerr_systemerr(
-	register SVCXPRT *xprt )
-{
-	struct rpc_msg rply;
-
-	rply.rm_direction = REPLY;
-	rply.rm_reply.rp_stat = MSG_ACCEPTED;
-	rply.acpted_rply.ar_verf = xprt->xp_verf;
-	rply.acpted_rply.ar_stat = SYSTEM_ERR;
-	SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Authentication error reply
- */
-void
-svcerr_auth(
-	SVCXPRT *xprt,
-	enum auth_stat why )
-{
-	struct rpc_msg rply;
-
-	rply.rm_direction = REPLY;
-	rply.rm_reply.rp_stat = MSG_DENIED;
-	rply.rjcted_rply.rj_stat = AUTH_ERROR;
-	rply.rjcted_rply.rj_why = why;
-	SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Auth too weak error reply
- */
-void
-svcerr_weakauth(
-	SVCXPRT *xprt )
-{
-
-	svcerr_auth(xprt, AUTH_TOOWEAK);
-}
-
-/*
- * Program unavailable error reply
- */
-void
-svcerr_noprog(
-	register SVCXPRT *xprt )
-{
-	struct rpc_msg rply;
-
-	rply.rm_direction = REPLY;
-	rply.rm_reply.rp_stat = MSG_ACCEPTED;
-	rply.acpted_rply.ar_verf = xprt->xp_verf;
-	rply.acpted_rply.ar_stat = PROG_UNAVAIL;
-	SVC_REPLY(xprt, &rply);
-}
-
-/*
- * Program version mismatch error reply
- */
-void
-svcerr_progvers(
-	register SVCXPRT *xprt,
-	rpcvers_t low_vers,
-	rpcvers_t high_vers )
-{
-	struct rpc_msg rply;
-
-	rply.rm_direction = REPLY;
-	rply.rm_reply.rp_stat = MSG_ACCEPTED;
-	rply.acpted_rply.ar_verf = xprt->xp_verf;
-	rply.acpted_rply.ar_stat = PROG_MISMATCH;
-	rply.acpted_rply.ar_vers.low = low_vers;
-	rply.acpted_rply.ar_vers.high = high_vers;
-	SVC_REPLY(xprt, &rply);
-}
-
-/* ******************* SERVER INPUT STUFF ******************* */
-
-/*
- * Get server side input from some transport.
- *
- * Statement of authentication parameters management:
- * This function owns and manages all authentication parameters, specifically
- * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and
- * the "cooked" credentials (rqst->rq_clntcred).
- * However, this function does not know the structure of the cooked
- * credentials, so it make the following assumptions:
- *   a) the structure is contiguous (no pointers), and
- *   b) the cred structure size does not exceed RQCRED_SIZE bytes.
- * In all events, all three parameters are freed upon exit from this routine.
- * The storage is trivially management on the call stack in user land, but
- * is mallocated in kernel land.
- */
-
-void
-svc_getreq(
-	int rdfds )
-{
-	fd_set readfds;
-
-	FD_ZERO(&readfds);
-	readfds.fds_bits[0] = rdfds;
-	svc_getreqset(&readfds);
-}
-
-void
-svc_getreqset(
-	fd_set *readfds )
-{
-	svc_getreqset2(readfds, FD_SETSIZE);
-}
-
-void
-svc_getreqset2(
-	fd_set *readfds,
-	int width )
-{
-	enum xprt_stat stat;
-	struct rpc_msg msg;
-	int prog_found;
-	u_long low_vers;
-	u_long high_vers;
-	struct svc_req r;
-	register SVCXPRT *xprt;
-	register int bit;
-	register int sock;
-	register fd_mask mask, *maskp;
-	char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE];
-	msg.rm_call.cb_cred.oa_base = cred_area;
-	msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
-	r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]);
-
-
-	maskp = readfds->fds_bits;
-	for (sock = 0; sock < width; sock += NFDBITS) {
-	    for (mask = *maskp++; (bit = ffs(mask)); mask ^= (1 << (bit - 1))) {
-		/* sock has input waiting */
-		xprt = xports[sock + bit - 1];
-		if (xprt == NULL)
-			/* But do we control sock? */
-			continue;
-		/* now receive msgs from xprtprt (support batch calls) */
-		do {
-			if (SVC_RECV(xprt, &msg)) {
-
-				/* now find the exported program and call it */
-				register struct svc_callout *s;
-				enum auth_stat why;
-
-				r.rq_xprt = xprt;
-				r.rq_prog = msg.rm_call.cb_prog;
-				r.rq_vers = msg.rm_call.cb_vers;
-				r.rq_proc = msg.rm_call.cb_proc;
-				r.rq_cred = msg.rm_call.cb_cred;
-				/* first authenticate the message */
-				if ((why= _authenticate(&r, &msg)) != AUTH_OK) {
-					svcerr_auth(xprt, why);
-					goto call_done;
-				}
-				/* now match message with a registered service*/
-				prog_found = FALSE;
-				low_vers = (u_long) - 1;
-				high_vers = 0;
-				for (s = svc_head; s != NULL_SVC; s = s->sc_next) {
-					if (s->sc_prog == r.rq_prog) {
-						if (s->sc_vers == r.rq_vers) {
-							(*s->sc_dispatch)(&r, xprt);
-							goto call_done;
-						}  /* found correct version */
-						prog_found = TRUE;
-						if (s->sc_vers < low_vers)
-							low_vers = s->sc_vers;
-						if (s->sc_vers > high_vers)
-							high_vers = s->sc_vers;
-					}   /* found correct program */
-				}
-				/*
-				 * if we got here, the program or version
-				 * is not served ...
-				 */
-				if (prog_found)
-					svcerr_progvers(xprt,
-					low_vers, high_vers);
-				else
-					 svcerr_noprog(xprt);
-				/* Fall through to ... */
-			}
-		call_done:
-			if ((stat = SVC_STAT(xprt)) == XPRT_DIED){
-				SVC_DESTROY(xprt);
-				break;
-			}
-		} while (stat == XPRT_MOREREQS);
-	    }
-	}
-}
Index: rvices/librpc/src/rpc/svc_auth.c
===================================================================
--- services/librpc/src/rpc/svc_auth.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,224 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-/*
- * Copyright (c) 1986-1991 by Sun Microsystems Inc. 
- */
-
-/* #ident	"@(#)svc_auth.c	1.16	94/04/24 SMI" */
-
-#if !defined(lint) && defined(SCCSIDS)
-#if 0
-static char sccsid[] = "@(#)svc_auth.c 1.26 89/02/07 Copyr 1984 Sun Micro";
-#else
-static const char rcsid[] =
- "$FreeBSD: src/lib/libc/rpc/svc_auth.c,v 1.7 1999/12/29 05:04:16 peter Exp $";
-#endif
-#endif
-
-/*
- * svc_auth.c, Server-side rpc authenticator interface.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef _KERNEL
-#include <sys/param.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/auth.h>
-#include <rpc/clnt.h>
-#include <rpc/rpc_msg.h>
-#include <rpc/svc.h>
-#include <rpc/svc_auth.h>
-#else
-#include <stdlib.h>
-#include <rpc/rpc.h>
-#endif
-#include <sys/types.h>
-#ifdef __rtems__
-	/* XXX in rpc.h in old .. not new */
-	#include <rpc/rpc_rtems.h>
-#endif
-
-/*
- * svcauthsw is the bdevsw of server side authentication.
- *
- * Server side authenticators are called from authenticate by
- * using the client auth struct flavor field to index into svcauthsw.
- * The server auth flavors must implement a routine that looks
- * like:
- *
- *	enum auth_stat
- *	flavorx_auth(rqst, msg)
- *		register struct svc_req *rqst;
- *		register struct rpc_msg *msg;
- *
- */
-
-enum auth_stat _svcauth_null(struct svc_req *rqst, struct rpc_msg *msg);	/* no authentication */
-enum auth_stat _svcauth_unix(struct svc_req *rqst, struct rpc_msg *msg);		/* (system) unix style (uid, gids) */
-enum auth_stat _svcauth_short(struct svc_req *rqst, struct rpc_msg *msg);	/* short hand unix style */
-enum auth_stat _svcauth_des(struct svc_req *rqst, struct rpc_msg *msg);		/* des style */
-
-/* declarations to allow servers to specify new authentication flavors */
-struct authsvc {
-	int	flavor;
-	enum	auth_stat (*handler)(struct svc_req *rqst, struct rpc_msg *msg);
-	struct	authsvc	  *next;
-};
-#define Auths (rtems_rpc_task_variables->svc_auths_Auths)
-
-/*
- * The call rpc message, msg has been obtained from the wire.  The msg contains
- * the raw form of credentials and verifiers.  authenticate returns AUTH_OK
- * if the msg is successfully authenticated.  If AUTH_OK then the routine also
- * does the following things:
- * set rqst->rq_xprt->verf to the appropriate response verifier;
- * sets rqst->rq_client_cred to the "cooked" form of the credentials.
- *
- * NB: rqst->rq_cxprt->verf must be pre-alloctaed;
- * its length is set appropriately.
- *
- * The caller still owns and is responsible for msg->u.cmb.cred and
- * msg->u.cmb.verf.  The authentication system retains ownership of
- * rqst->rq_client_cred, the cooked credentials.
- *
- * There is an assumption that any flavour less than AUTH_NULL is
- * invalid.
- */
-enum auth_stat
-_authenticate(
-	struct svc_req *rqst,
-	struct rpc_msg *msg )
-{
-	register int cred_flavor;
-	register struct authsvc *asp;
-
-	rqst->rq_cred = msg->rm_call.cb_cred;
-	rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor;
-	rqst->rq_xprt->xp_verf.oa_length = 0;
-	cred_flavor = rqst->rq_cred.oa_flavor;
-	switch (cred_flavor) {
-	case AUTH_NULL:
-		return(_svcauth_null(rqst, msg));
-	case AUTH_UNIX:
-		return(_svcauth_unix(rqst, msg));
-	case AUTH_SHORT:
-		return(_svcauth_short(rqst, msg));
-	/*
-	 * We leave AUTH_DES turned off by default because svcauth_des()
-	 * needs getpublickey(), which is in librpcsvc, not libc. If we
- 	 * included AUTH_DES as a built-in flavor, programs that don't
-	 * have -lrpcsvc in their Makefiles wouldn't link correctly, even
-	 * though they don't use AUTH_DES. And I'm too lazy to go through
-	 * the tree looking for all of them.
-	 */
-#ifdef DES_BUILTIN
-	case AUTH_DES:
-		return(_svcauth_des(rqst, msg));
-#endif
-	}
-
-	/* flavor doesn't match any of the builtin types, so try new ones */
-	for (asp = Auths; asp; asp = asp->next) {
-		if (asp->flavor == cred_flavor) {
-			enum auth_stat as;
-
-			as = (*asp->handler)(rqst, msg);
-			return (as);
-		}
-	}
-
-	return (AUTH_REJECTEDCRED);
-}
-
-/*ARGSUSED*/
-enum auth_stat
-_svcauth_null(
-	struct svc_req *rqst,
-	struct rpc_msg *msg)
-{
-	return (AUTH_OK);
-}
-
-/*
- *  Allow the rpc service to register new authentication types that it is
- *  prepared to handle.  When an authentication flavor is registered,
- *  the flavor is checked against already registered values.  If not
- *  registered, then a new Auths entry is added on the list.
- *
- *  There is no provision to delete a registration once registered.
- *
- *  This routine returns:
- *	 0 if registration successful
- *	 1 if flavor already registered
- *	-1 if can't register (errno set)
- */
-
-int
-svc_auth_reg(
-	int cred_flavor,
-	enum auth_stat (*handler)(struct svc_req *rqst, struct rpc_msg *msg))
-{
-	register struct authsvc *asp;
-
-	switch (cred_flavor) {
-	    case AUTH_NULL:
-	    case AUTH_UNIX:
-	    case AUTH_SHORT:
-#ifdef DES_BUILTIN
-	    case AUTH_DES:
-#endif
-		/* already registered */
-		return (1);
-
-	    default:
-		for (asp = Auths; asp; asp = asp->next) {
-			if (asp->flavor == cred_flavor) {
-				/* already registered */
-				return (1);
-			}
-		}
-
-		/* this is a new one, so go ahead and register it */
-		asp = (struct authsvc *)mem_alloc(sizeof (*asp));
-		if (asp == NULL) {
-			return (-1);
-		}
-		asp->flavor = cred_flavor;
-		asp->handler = handler;
-		asp->next = Auths;
-		Auths = asp;
-		break;
-	}
-	return (0);
-}
Index: rvices/librpc/src/rpc/svc_auth_unix.c
===================================================================
--- services/librpc/src/rpc/svc_auth_unix.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,152 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)svc_auth_unix.c	2.3 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_auth_unix.c,v 1.8 1999/08/28 00:00:49 peter Exp $";
-#endif
-
-/*
- * svc_auth_unix.c
- * Handles UNIX flavor authentication parameters on the service side of rpc.
- * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT.
- * _svcauth_unix does full blown unix style uid,gid+gids auth,
- * _svcauth_short uses a shorthand auth to index into a cache of longhand auths.
- * Note: the shorthand has been gutted for efficiency.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <rpc/rpc.h>
-
-/*
- * Unix longhand authenticator
- */
-enum auth_stat
-_svcauth_unix(
-	struct svc_req *rqst,
-	struct rpc_msg *msg )
-{
-	register enum auth_stat stat;
-	XDR xdrs;
-	register struct authunix_parms *aup;
-	register int32_t *buf;
-	struct area {
-		struct authunix_parms area_aup;
-		char area_machname[MAX_MACHINE_NAME+1];
-		int area_gids[NGRPS];
-	} *area;
-	u_int auth_len;
-	int str_len, gid_len;
-	register int i;
-
-	area = (struct area *) rqst->rq_clntcred;
-	aup = &area->area_aup;
-	aup->aup_machname = area->area_machname;
-	aup->aup_gids = area->area_gids;
-	auth_len = (u_int)msg->rm_call.cb_cred.oa_length;
-	xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE);
-	buf = XDR_INLINE(&xdrs, auth_len);
-	if (buf != NULL) {
-		aup->aup_time = IXDR_GET_LONG(buf);
-		str_len = IXDR_GET_U_LONG(buf);
-		if (str_len > MAX_MACHINE_NAME) {
-			stat = AUTH_BADCRED;
-			goto done;
-		}
-		memcpy(aup->aup_machname, (caddr_t)buf, (u_int)str_len);
-		aup->aup_machname[str_len] = 0;
-		str_len = RNDUP(str_len);
-		buf += str_len / sizeof (int32_t);
-		aup->aup_uid = IXDR_GET_LONG(buf);
-		aup->aup_gid = IXDR_GET_LONG(buf);
-		gid_len = IXDR_GET_U_LONG(buf);
-		if (gid_len > NGRPS) {
-			stat = AUTH_BADCRED;
-			goto done;
-		}
-		aup->aup_len = gid_len;
-		for (i = 0; i < gid_len; i++) {
-			aup->aup_gids[i] = IXDR_GET_LONG(buf);
-		}
-		/*
-		 * five is the smallest unix credentials structure -
-		 * timestamp, hostname len (0), uid, gid, and gids len (0).
-		 */
-		if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) {
-			(void) printf("bad auth_len gid %d str %d auth %d\n",
-			    gid_len, str_len, auth_len);
-			stat = AUTH_BADCRED;
-			goto done;
-		}
-	} else if (! xdr_authunix_parms(&xdrs, aup)) {
-		xdrs.x_op = XDR_FREE;
-		(void)xdr_authunix_parms(&xdrs, aup);
-		stat = AUTH_BADCRED;
-		goto done;
-	}
-
-	/* get the verifier */
-	if ((u_int)msg->rm_call.cb_verf.oa_length) {
-		rqst->rq_xprt->xp_verf.oa_flavor = 
-			msg->rm_call.cb_verf.oa_flavor;
-		rqst->rq_xprt->xp_verf.oa_base = 
-			msg->rm_call.cb_verf.oa_base;
-		rqst->rq_xprt->xp_verf.oa_length = 
-			msg->rm_call.cb_verf.oa_length;
-	} else {
-		rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL;
-		rqst->rq_xprt->xp_verf.oa_length = 0;
-	}
-	stat = AUTH_OK;
-done:
-	XDR_DESTROY(&xdrs);
-	return (stat);
-}
-
-
-/*
- * Shorthand unix authenticator
- * Looks up longhand in a cache.
- */
-/*ARGSUSED*/
-enum auth_stat
-_svcauth_short(
-	struct svc_req *rqst,
-	struct rpc_msg *msg )
-{
-	return (AUTH_REJECTEDCRED);
-}
Index: rvices/librpc/src/rpc/svc_raw.c
===================================================================
--- services/librpc/src/rpc/svc_raw.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,177 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)svc_raw.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_raw.c,v 1.7 1999/08/28 00:00:49 peter Exp $";
-#endif
-
-/*
- * svc_raw.c,   This a toy for simple testing and timing.
- * Interface to create an rpc client and server in the same UNIX process.
- * This lets us similate rpc and get rpc (round trip) overhead, without
- * any interference from the kernal.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#include <stdlib.h>
-#ifdef __rtems__
-	/* XXX in rpc.h in old .. not new */
-	#include <rpc/rpc_rtems.h>
-#endif
-
-/*
- * This is the "network" that we will be moving data over
- */
-struct svc_raw_private {
-	char	_raw_buf[UDPMSGSIZE];
-	SVCXPRT	server;
-	XDR	xdr_stream;
-	char	verf_body[MAX_AUTH_BYTES];
-};
-#define svcraw_private ((struct svc_raw_private *)(rtems_rpc_task_variables)->svc_raw_private)
-
-static bool_t		svcraw_recv(SVCXPRT *xprt, struct rpc_msg *msg);
-static enum xprt_stat 	svcraw_stat(SVCXPRT *xprt);
-static bool_t		svcraw_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr);
-static bool_t		svcraw_reply(SVCXPRT *xprt, struct rpc_msg *msg);
-static bool_t		svcraw_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr);
-static void		svcraw_destroy(SVCXPRT *xprt);
-
-static struct xp_ops server_ops = {
-	svcraw_recv,
-	svcraw_stat,
-	svcraw_getargs,
-	svcraw_reply,
-	svcraw_freeargs,
-	svcraw_destroy
-};
-
-SVCXPRT *
-svcraw_create(void)
-{
-	register struct svc_raw_private *srp = svcraw_private;
-
-	if (srp == 0) {
-		srp = (struct svc_raw_private *)calloc(1, sizeof (*srp));
-		if (srp == 0)
-			return (0);
-	}
-	srp->server.xp_fd = 0;
-	srp->server.xp_port = 0;
-	srp->server.xp_ops = &server_ops;
-	srp->server.xp_verf.oa_base = srp->verf_body;
-	xdrmem_create(&srp->xdr_stream, srp->_raw_buf, UDPMSGSIZE, XDR_FREE);
-	return (&srp->server);
-}
-
-static enum xprt_stat
-svcraw_stat(SVCXPRT *xprt)
-{
-
-	return (XPRT_IDLE);
-}
-
-static bool_t
-svcraw_recv(
-	SVCXPRT *xprt,
-	struct rpc_msg *msg)
-{
-	register struct svc_raw_private *srp = svcraw_private;
-	register XDR *xdrs;
-
-	if (srp == 0)
-		return (0);
-	xdrs = &srp->xdr_stream;
-	xdrs->x_op = XDR_DECODE;
-	XDR_SETPOS(xdrs, 0);
-	if (! xdr_callmsg(xdrs, msg))
-	       return (FALSE);
-	return (TRUE);
-}
-
-static bool_t
-svcraw_reply(
-	SVCXPRT *xprt,
-	struct rpc_msg *msg)
-{
-	register struct svc_raw_private *srp = svcraw_private;
-	register XDR *xdrs;
-
-	if (srp == 0)
-		return (FALSE);
-	xdrs = &srp->xdr_stream;
-	xdrs->x_op = XDR_ENCODE;
-	XDR_SETPOS(xdrs, 0);
-	if (! xdr_replymsg(xdrs, msg))
-	       return (FALSE);
-	(void)XDR_GETPOS(xdrs);  /* called just for overhead */
-	return (TRUE);
-}
-
-static bool_t
-svcraw_getargs(
-	SVCXPRT *xprt,
-	xdrproc_t xdr_args,
-	caddr_t args_ptr)
-{
-	register struct svc_raw_private *srp = svcraw_private;
-
-	if (srp == 0)
-		return (FALSE);
-	return ((*xdr_args)(&srp->xdr_stream, args_ptr));
-}
-
-static bool_t
-svcraw_freeargs(
-	SVCXPRT *xprt,
-	xdrproc_t xdr_args,
-	caddr_t args_ptr)
-{
-	register struct svc_raw_private *srp = svcraw_private;
-	register XDR *xdrs;
-
-	if (srp == 0)
-		return (FALSE);
-	xdrs = &srp->xdr_stream;
-	xdrs->x_op = XDR_FREE;
-	return ((*xdr_args)(xdrs, args_ptr));
-}
-
-static void
-svcraw_destroy(SVCXPRT *xprt)
-{
-}
Index: rvices/librpc/src/rpc/svc_run.c
===================================================================
--- services/librpc/src/rpc/svc_run.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)svc_run.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_run.c,v 1.10 1999/08/28 00:00:49 peter Exp $";
-#endif
-
-/*
- * This is the rpc server side idle loop
- * Wait for input, call server program.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/rpc.h>
-#include <stdio.h>
-#include <sys/errno.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/select.h>
-#ifdef __rtems__
-#include <rpc/rpc_rtems.h>
-#endif
-
-void
-svc_run(void)
-{
-	fd_set *fds;
-
-	for (;;) {
-		if (__svc_fdset) {
-			int bytes = sizeof (fd_set);
-			fds = (fd_set *)malloc(bytes);
-			memcpy(fds, __svc_fdset, bytes);
-		} else
-			fds = NULL;
-		switch (select(svc_maxfd + 1, fds, NULL, NULL,
-				(struct timeval *)0)) {
-		case -1:
-			if (errno == EINTR) {
-				if (fds)
-					free(fds);
-				continue;
-			}
-			perror("svc_run: - select failed");
-			if (fds)
-				free(fds);
-			return;
-		case 0:
-			if (fds)
-				free(fds);
-			continue;
-		default:
-			/* if fds == NULL, select() can't return a result */
-			svc_getreqset2(fds, svc_maxfd + 1);
-			free(fds);
-		}
-	}
-}
Index: rvices/librpc/src/rpc/svc_simple.c
===================================================================
--- services/librpc/src/rpc/svc_simple.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,164 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)svc_simple.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_simple.c,v 1.9 1999/08/28 00:00:50 peter Exp $";
-#endif
-
-/*
- * svc_simple.c
- * Simplified front end to rpc.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
-#include <inttypes.h> /* for PRIxx printf formats */
-#ifdef __rtems__
-#include <rpc/rpc_rtems.h>
-#endif
-
-struct prog_lst {
-	char *(*p_progname)(char *);
-	rpcprog_t  p_prognum;
-	rpcproc_t  p_procnum;
-	xdrproc_t p_inproc, p_outproc;
-	struct prog_lst *p_nxt;
-};
-static void universal(struct svc_req *, SVCXPRT *);
-#define proglst (rtems_rpc_task_variables->svc_simple_proglst)
-#define pl (rtems_rpc_task_variables->svc_simple_pl)
-#define transp (rtems_rpc_task_variables->svc_simple_transp)
-
-int
-registerrpc(
-	int prognum,
-	int versnum,
-	int procnum,
-	char *(*progname)(char *),
-	xdrproc_t inproc,
-	xdrproc_t outproc )
-{
-
-	if (procnum == NULLPROC) {
-		(void) fprintf(stderr,
-		    "can't reassign procedure number %" PRIu32 "\n", NULLPROC);
-		return (-1);
-	}
-	if (transp == 0) {
-		transp = svcudp_create(RPC_ANYSOCK);
-		if (transp == NULL) {
-			(void) fprintf(stderr, "couldn't create an rpc server\n");
-			return (-1);
-		}
-	}
-	(void) pmap_unset((u_long)prognum, (u_long)versnum);
-	if (!svc_register(transp, (u_long)prognum, (u_long)versnum,
-	    universal, IPPROTO_UDP)) {
-	    	(void) fprintf(stderr, "couldn't register prog %d vers %d\n",
-		    prognum, versnum);
-		return (-1);
-	}
-	pl = (struct prog_lst *)malloc(sizeof(struct prog_lst));
-	if (pl == NULL) {
-		(void) fprintf(stderr, "registerrpc: out of memory\n");
-		return (-1);
-	}
-	pl->p_progname = progname;
-	pl->p_prognum = prognum;
-	pl->p_procnum = procnum;
-	pl->p_inproc = inproc;
-	pl->p_outproc = outproc;
-	pl->p_nxt = proglst;
-	proglst = pl;
-	return (0);
-}
-
-static void
-universal(
-	struct svc_req *rqstp,
-	SVCXPRT *atransp )
-{
-	int prog, proc;
-	char *outdata;
-	char xdrbuf[UDPMSGSIZE];
-	struct prog_lst *lpl;
-
-	/*
-	 * enforce "procnum 0 is echo" convention
-	 */
-	if (rqstp->rq_proc == NULLPROC) {
-		if (svc_sendreply(atransp, (xdrproc_t) xdr_void, NULL) == FALSE) {
-			(void) fprintf(stderr, "xxx\n");
-			exit(1);
-		}
-		return;
-	}
-	prog = rqstp->rq_prog;
-	proc = rqstp->rq_proc;
-	for (lpl = proglst; lpl != NULL; lpl = lpl->p_nxt)
-		if (lpl->p_prognum == prog && lpl->p_procnum == proc) {
-			/* decode arguments into a CLEAN buffer */
-			memset(xdrbuf, 0, sizeof(xdrbuf)); /* required ! */
-			if (!svc_getargs(atransp, lpl->p_inproc, xdrbuf)) {
-				svcerr_decode(atransp);
-				return;
-			}
-			outdata = (*(lpl->p_progname))(xdrbuf);
-			if (outdata == NULL &&
-			    lpl->p_outproc != (xdrproc_t) xdr_void)
-				/* there was an error */
-				return;
-			if (!svc_sendreply(atransp, lpl->p_outproc, outdata)) {
-				(void) fprintf(stderr,
-				    "trouble replying to prog %" PRIu32 "\n",
-				    lpl->p_prognum);
-				exit(1);
-			}
-			/* free the decoded arguments */
-			(void)svc_freeargs(atransp, lpl->p_inproc, xdrbuf);
-			return;
-		}
-	(void) fprintf(stderr, "never registered prog %d\n", prog);
-	exit(1);
-}
Index: rvices/librpc/src/rpc/svc_tcp.c
===================================================================
--- services/librpc/src/rpc/svc_tcp.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,492 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)svc_tcp.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_tcp.c,v 1.18 2000/01/27 23:06:41 jasone Exp $";
-#endif
-
-/*
- * svc_tcp.c, Server side for TCP/IP based RPC.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * Actually implements two flavors of transporter -
- * a tcp rendezvouser (a listner and connection establisher)
- * and a record/tcp stream.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <sys/select.h>
-#ifdef __rtems__
-#include <rpc/rpc_rtems.h>
-#endif
-
-/*
- * Ops vector for TCP/IP based rpc service handle
- */
-static bool_t		svctcp_recv(SVCXPRT *xprt, struct rpc_msg *msg);
-static enum xprt_stat	svctcp_stat(SVCXPRT *xprt);
-static bool_t		svctcp_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr);
-static bool_t		svctcp_reply(SVCXPRT *xprt, struct rpc_msg *msg);
-static bool_t		svctcp_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr);
-static void		svctcp_destroy(SVCXPRT *xprt);
-
-static struct xp_ops svctcp_op = {
-	svctcp_recv,
-	svctcp_stat,
-	svctcp_getargs,
-	svctcp_reply,
-	svctcp_freeargs,
-	svctcp_destroy
-};
-
-/*
- * Ops vector for TCP/IP rendezvous handler
- */
-static bool_t		rendezvous_request(SVCXPRT *xprt, struct rpc_msg *msg);
-static enum xprt_stat	rendezvous_stat(SVCXPRT *xprt);
-
-static struct xp_ops svctcp_rendezvous_op = {
-	rendezvous_request,
-	rendezvous_stat,
-	(bool_t (*)(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr))abort,
-	(bool_t (*)(SVCXPRT *xprt, struct rpc_msg *msg))abort,
-	(bool_t (*)(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr))abort,
-	svctcp_destroy
-};
-
-static int readtcp(char *, char*, int), writetcp(char *, char*, int);
-static SVCXPRT *makefd_xprt( int fd, u_int sendsize, u_int recvsize);
-
-struct tcp_rendezvous { /* kept in xprt->xp_p1 */
-	u_int sendsize;
-	u_int recvsize;
-};
-
-struct tcp_conn {  /* kept in xprt->xp_p1 */
-	enum xprt_stat strm_stat;
-	u_long x_id;
-	XDR xdrs;
-	char verf_body[MAX_AUTH_BYTES];
-};
-
-/*
- * Usage:
- *	xprt = svctcp_create(sock, send_buf_size, recv_buf_size);
- *
- * Creates, registers, and returns a (rpc) tcp based transporter.
- * Once *xprt is initialized, it is registered as a transporter
- * see (svc.h, xprt_register).  This routine returns
- * a NULL if a problem occurred.
- *
- * If sock<0 then a socket is created, else sock is used.
- * If the socket, sock is not bound to a port then svctcp_create
- * binds it to an arbitrary port.  The routine then starts a tcp
- * listener on the socket's associated port.  In any (successful) case,
- * xprt->xp_fd is the registered socket number and xprt->xp_port is the
- * associated port number.
- *
- * Since tcp streams do buffered io similar to stdio, the caller can specify
- * how big the send and receive buffers are via the second and third parms;
- * 0 => use the system default.
- */
-SVCXPRT *
-svctcp_create(
-	int sock,
-	u_int sendsize,
-	u_int recvsize)
-{
-	bool_t madesock = FALSE;
-	register SVCXPRT *xprt;
-	register struct tcp_rendezvous *r;
-	struct sockaddr_in addr;
-	socklen_t len = sizeof(struct sockaddr_in);
-	int on;
-
-	if (sock == RPC_ANYSOCK) {
-		if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
-			perror("svctcp_.c - udp socket creation problem");
-			return ((SVCXPRT *)NULL);
-		}
-		madesock = TRUE;
-	}
-	on = 1;
-	if (ioctl(sock, FIONBIO, &on) < 0) {
-		perror("svc_tcp.c - cannot turn on non-blocking mode");
-		if (madesock)
-		       (void)_RPC_close(sock);
-		return ((SVCXPRT *)NULL);
-	}
-	memset(&addr, 0, sizeof (addr));
-	addr.sin_len = sizeof(struct sockaddr_in);
-	addr.sin_family = AF_INET;
-	if (bindresvport(sock, &addr)) {
-		addr.sin_port = 0;
-		(void)bind(sock, (struct sockaddr *)&addr, len);
-	}
-	if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0)  ||
-	    (listen(sock, 2) != 0)) {
-		perror("svctcp_.c - cannot getsockname or listen");
-		if (madesock)
-		       (void)_RPC_close(sock);
-		return ((SVCXPRT *)NULL);
-	}
-	r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r));
-	if (r == NULL) {
-		(void) fprintf(stderr, "svctcp_create: out of memory\n");
-		return (NULL);
-	}
-	r->sendsize = sendsize;
-	r->recvsize = recvsize;
-	xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
-	if (xprt == NULL) {
-		(void) fprintf(stderr, "svctcp_create: out of memory\n");
-		return (NULL);
-	}
-	xprt->xp_p2 = NULL;
-	xprt->xp_p1 = (caddr_t)r;
-	xprt->xp_verf = _null_auth;
-	xprt->xp_ops = &svctcp_rendezvous_op;
-	xprt->xp_port = ntohs(addr.sin_port);
-	xprt->xp_fd = sock;
-	xprt_register(xprt);
-	return (xprt);
-}
-
-/*
- * Like svtcp_create(), except the routine takes any *open* UNIX file
- * descriptor as its first input.
- */
-SVCXPRT *
-svcfd_create(
-	int fd,
-	u_int sendsize,
-	u_int recvsize)
-{
-
-	return (makefd_xprt(fd, sendsize, recvsize));
-}
-
-static SVCXPRT *
-makefd_xprt(
-	int fd,
-	u_int sendsize,
-	u_int recvsize)
-{
-	register SVCXPRT *xprt;
-	register struct tcp_conn *cd;
-
-	xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
-	if (xprt == (SVCXPRT *)NULL) {
-		(void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n");
-		goto done;
-	}
-	cd = (struct tcp_conn *)mem_alloc(sizeof(struct tcp_conn));
-	if (cd == (struct tcp_conn *)NULL) {
-		(void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n");
-		mem_free((char *) xprt, sizeof(SVCXPRT));
-		xprt = (SVCXPRT *)NULL;
-		goto done;
-	}
-	cd->strm_stat = XPRT_IDLE;
-	xdrrec_create(&(cd->xdrs), sendsize, recvsize,
-	    (caddr_t)xprt, readtcp, writetcp);
-	xprt->xp_p2 = NULL;
-	xprt->xp_p1 = (caddr_t)cd;
-	xprt->xp_verf.oa_base = cd->verf_body;
-	xprt->xp_addrlen = 0;
-	xprt->xp_ops = &svctcp_op;  /* truely deals with calls */
-	xprt->xp_port = 0;  /* this is a connection, not a rendezvouser */
-	xprt->xp_fd = fd;
-	xprt_register(xprt);
-    done:
-	return (xprt);
-}
-
-static bool_t
-rendezvous_request(
-	SVCXPRT *xprt,
-	struct rpc_msg *msg)
-{
-	int sock;
-	struct tcp_rendezvous *r;
-	struct sockaddr_in addr;
-	socklen_t len;
-	int off;
-
-	r = (struct tcp_rendezvous *)xprt->xp_p1;
-    again:
-	len = sizeof(struct sockaddr_in);
-	if ((sock = accept(xprt->xp_fd, (struct sockaddr *)&addr,
-	    &len)) < 0) {
-		if (errno == EINTR)
-			goto again;
-	       return (FALSE);
-	}
-	/*
-	 * Guard against FTP bounce attacks.
-	 */
-	if (addr.sin_port == htons(20)) {
-		_RPC_close(sock);
-		return (FALSE);
-	}
-	/*
-	 * The listening socket is in FIONBIO mode and we inherit it.
-	 */
-	off = 0;
-	if (ioctl(sock, FIONBIO, &off) < 0) {
-		_RPC_close(sock);
-		return (FALSE);
-	}
-	/*
-	 * make a new transporter (re-uses xprt)
-	 */
-	xprt = makefd_xprt(sock, r->sendsize, r->recvsize);
-	xprt->xp_raddr = addr;
-	xprt->xp_addrlen = len;
-	return (FALSE); /* there is never an rpc msg to be processed */
-}
-
-static enum xprt_stat
-rendezvous_stat(SVCXPRT *xprt)
-{
-
-	return (XPRT_IDLE);
-}
-
-static void
-svctcp_destroy(
-	SVCXPRT *xprt)
-{
-	register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1;
-
-	xprt_unregister(xprt);
-	(void)_RPC_close(xprt->xp_fd);
-	if (xprt->xp_port != 0) {
-		/* a rendezvouser socket */
-		xprt->xp_port = 0;
-	} else {
-		/* an actual connection socket */
-		XDR_DESTROY(&(cd->xdrs));
-	}
-	mem_free((caddr_t)cd, sizeof(struct tcp_conn));
-	mem_free((caddr_t)xprt, sizeof(SVCXPRT));
-}
-
-/*
- * All read operations timeout after 35 seconds.
- * A timeout is fatal for the connection.
- */
-static struct timeval wait_per_try = { 35, 0 };
-
-/*
- * reads data from the tcp conection.
- * any error is fatal and the connection is closed.
- * (And a read of zero bytes is a half closed stream => error.)
- *
- * Note: we have to be careful here not to allow ourselves to become
- * blocked too long in this routine. While we're waiting for data from one
- * client, another client may be trying to connect. To avoid this situation,
- * some code from svc_run() is transplanted here: the select() loop checks
- * all RPC descriptors including the one we want and calls svc_getreqset2()
- * to handle new requests if any are detected.
- */
-static int
-readtcp(
-	char *_xprt,
-	char *buf,
-	int len)
-{
-	SVCXPRT *xprt = (SVCXPRT*) _xprt;
-	register int sock = xprt->xp_fd;
-	struct timeval start, delta, tv;
-	struct timeval tmp1, tmp2;
-	fd_set *fds;
-
-	delta = wait_per_try;
-	fds = NULL;
-	gettimeofday(&start, NULL);
-	do {
-		int bytes = sizeof (fd_set);
-		if (fds != NULL)
-			free(fds);
-		fds = (fd_set *)malloc(bytes);
-		if (fds == NULL)
-			goto fatal_err;
-		memcpy(fds, __svc_fdset, bytes);
-
-		/* XXX we know the other bits are still clear */
-		FD_SET(sock, fds);
-		tv = delta;	/* in case select() implements writeback */
-		switch (select(svc_maxfd + 1, fds, NULL, NULL, &tv)) {
-		case -1:
-			if (errno != EINTR)
-				goto fatal_err;
-			gettimeofday(&tmp1, NULL);
-			timersub(&tmp1, &start, &tmp2);
-			timersub(&wait_per_try, &tmp2, &tmp1);
-			if (tmp1.tv_sec < 0 || !timerisset(&tmp1))
-				goto fatal_err;
-			delta = tmp1;
-			continue;
-		case 0:
-			goto fatal_err;
-		default:
-			if (!FD_ISSET(sock, fds)) {
-				svc_getreqset2(fds, svc_maxfd + 1);
-				gettimeofday(&tmp1, NULL);
-				timersub(&tmp1, &start, &tmp2);
-				timersub(&wait_per_try, &tmp2, &tmp1);
-				if (tmp1.tv_sec < 0 || !timerisset(&tmp1))
-					goto fatal_err;
-				delta = tmp1;
-				continue;
-			}
-		}
-	} while (!FD_ISSET(sock, fds));
-	if ((len = _RPC_read(sock, buf, len)) > 0) {
-		if (fds != NULL)
-			free(fds);
-		return (len);
-	}
-fatal_err:
-	((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED;
-	if (fds != NULL)
-		free(fds);
-	return (-1);
-}
-
-/*
- * writes data to the tcp connection.
- * Any error is fatal and the connection is closed.
- */
-static int
-writetcp(
-	char *_xprt,
-	char *buf,
-	int len)
-{
-	SVCXPRT *xprt = (SVCXPRT *) _xprt;
-	register int i, cnt;
-
-	for (cnt = len; cnt > 0; cnt -= i, buf += i) {
-		if ((i = _RPC_write(xprt->xp_fd, buf, cnt)) < 0) {
-			((struct tcp_conn *)(xprt->xp_p1))->strm_stat =
-			    XPRT_DIED;
-			return (-1);
-		}
-	}
-	return (len);
-}
-
-static enum xprt_stat
-svctcp_stat(
-	SVCXPRT *xprt)
-{
-	register struct tcp_conn *cd =
-	    (struct tcp_conn *)(xprt->xp_p1);
-
-	if (cd->strm_stat == XPRT_DIED)
-		return (XPRT_DIED);
-	if (! xdrrec_eof(&(cd->xdrs)))
-		return (XPRT_MOREREQS);
-	return (XPRT_IDLE);
-}
-
-static bool_t
-svctcp_recv(
-	SVCXPRT *xprt,
-	struct rpc_msg *msg)
-{
-	register struct tcp_conn *cd =
-	    (struct tcp_conn *)(xprt->xp_p1);
-	register XDR *xdrs = &(cd->xdrs);
-
-	xdrs->x_op = XDR_DECODE;
-	(void)xdrrec_skiprecord(xdrs);
-	if (xdr_callmsg(xdrs, msg)) {
-		cd->x_id = msg->rm_xid;
-		return (TRUE);
-	}
-	cd->strm_stat = XPRT_DIED;	/* XXXX */
-	return (FALSE);
-}
-
-static bool_t
-svctcp_getargs(
-	SVCXPRT *xprt,
-	xdrproc_t xdr_args,
-	caddr_t args_ptr)
-{
-
-	return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr));
-}
-
-static bool_t
-svctcp_freeargs(
-	SVCXPRT *xprt,
-	xdrproc_t xdr_args,
-	caddr_t args_ptr)
-{
-	register XDR *xdrs =
-	    &(((struct tcp_conn *)(xprt->xp_p1))->xdrs);
-
-	xdrs->x_op = XDR_FREE;
-	return ((*xdr_args)(xdrs, args_ptr));
-}
-
-static bool_t
-svctcp_reply(
-	SVCXPRT *xprt,
-	struct rpc_msg *msg)
-{
-	register struct tcp_conn *cd =
-	    (struct tcp_conn *)(xprt->xp_p1);
-	register XDR *xdrs = &(cd->xdrs);
-	register bool_t stat;
-
-	xdrs->x_op = XDR_ENCODE;
-	msg->rm_xid = cd->x_id;
-	stat = xdr_replymsg(xdrs, msg);
-	(void)xdrrec_endofrecord(xdrs, TRUE);
-	return (stat);
-}
Index: rvices/librpc/src/rpc/svc_udp.c
===================================================================
--- services/librpc/src/rpc/svc_udp.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,484 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)svc_udp.c	2.2 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_udp.c,v 1.13 2000/01/27 23:06:41 jasone Exp $";
-#endif
-
-/*
- * svc_udp.c,
- * Server side for UDP/IP based RPC.  (Does some caching in the hopes of
- * achieving execute-at-most-once semantics.)
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#include <sys/socket.h>
-#include <errno.h>
-
-#define rpc_buffer(xprt) ((xprt)->xp_p1)
-#define MAX(a, b)     ((a > b) ? a : b)
-
-static bool_t		svcudp_recv(SVCXPRT *xprt, struct rpc_msg *msg);
-static bool_t		svcudp_reply(SVCXPRT *xprt, struct rpc_msg *msg);
-static enum xprt_stat	svcudp_stat(SVCXPRT *xprt);
-static bool_t		svcudp_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr);
-static bool_t		svcudp_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr);
-static void		svcudp_destroy(SVCXPRT *xprt);
-static void		cache_set (SVCXPRT *, u_long);
-static int		cache_get (SVCXPRT *, struct rpc_msg *, char **, u_long *);
-
-static struct xp_ops svcudp_op = {
-	svcudp_recv,
-	svcudp_stat,
-	svcudp_getargs,
-	svcudp_reply,
-	svcudp_freeargs,
-	svcudp_destroy
-};
-
-/*
- * kept in xprt->xp_p2
- */
-struct svcudp_data {
-	u_int   su_iosz;	/* byte size of send.recv buffer */
-	u_long	su_xid;		/* transaction id */
-	XDR	su_xdrs;	/* XDR handle */
-	char	su_verfbody[MAX_AUTH_BYTES];	/* verifier body */
-	char * 	su_cache;	/* cached data, NULL if no cache */
-};
-#define	su_data(xprt)	((struct svcudp_data *)(xprt->xp_p2))
-
-/*
- * Usage:
- *	xprt = svcudp_create(sock);
- *
- * If sock<0 then a socket is created, else sock is used.
- * If the socket, sock is not bound to a port then svcudp_create
- * binds it to an arbitrary port.  In any (successful) case,
- * xprt->xp_fd is the registered socket number and xprt->xp_port is the
- * associated port number.
- * Once *xprt is initialized, it is registered as a transporter;
- * see (svc.h, xprt_register).
- * The routines returns NULL if a problem occurred.
- */
-SVCXPRT *
-svcudp_bufcreate(
-	int sock,
-	u_int sendsz,
-	u_int recvsz )
-{
-	bool_t madesock = FALSE;
-	register SVCXPRT *xprt;
-	register struct svcudp_data *su;
-	struct sockaddr_in addr;
-	socklen_t len = sizeof(struct sockaddr_in);
-
-	if (sock == RPC_ANYSOCK) {
-		if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
-			perror("svcudp_create: socket creation problem");
-			return ((SVCXPRT *)NULL);
-		}
-		madesock = TRUE;
-	}
-	memset((char *)&addr, 0, sizeof (addr));
-	addr.sin_len = sizeof(struct sockaddr_in);
-	addr.sin_family = AF_INET;
-	if (bindresvport(sock, &addr)) {
-		addr.sin_port = 0;
-		(void)bind(sock, (struct sockaddr *)&addr, len);
-	}
-	if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) {
-		perror("svcudp_create - cannot getsockname");
-		if (madesock)
-			(void)_RPC_close(sock);
-		return ((SVCXPRT *)NULL);
-	}
-	xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
-	if (xprt == NULL) {
-		(void)fprintf(stderr, "svcudp_create: out of memory\n");
-		return (NULL);
-	}
-	su = (struct svcudp_data *)mem_alloc(sizeof(*su));
-	if (su == NULL) {
-		(void)fprintf(stderr, "svcudp_create: out of memory\n");
-		return (NULL);
-	}
-	su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4;
-	if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) {
-		(void)fprintf(stderr, "svcudp_create: out of memory\n");
-		return (NULL);
-	}
-	xdrmem_create(
-	    &(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE);
-	su->su_cache = NULL;
-	xprt->xp_p2 = (caddr_t)su;
-	xprt->xp_verf.oa_base = su->su_verfbody;
-	xprt->xp_ops = &svcudp_op;
-	xprt->xp_port = ntohs(addr.sin_port);
-	xprt->xp_fd = sock;
-	xprt_register(xprt);
-	return (xprt);
-}
-
-SVCXPRT *
-svcudp_create(
-	int sock)
-{
-
-	return(svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE));
-}
-
-static enum xprt_stat
-svcudp_stat(
-	SVCXPRT *xprt)
-{
-
-	return (XPRT_IDLE);
-}
-
-static bool_t
-svcudp_recv(
-	SVCXPRT *xprt,
-	struct rpc_msg *msg)
-{
-	register struct svcudp_data *su = su_data(xprt);
-	register XDR *xdrs = &(su->su_xdrs);
-	register int rlen;
-	char *reply;
-	u_long replylen;
-
-    again:
-	xprt->xp_addrlen = sizeof(struct sockaddr_in);
-	rlen = recvfrom(xprt->xp_fd, rpc_buffer(xprt), (int) su->su_iosz,
-	    0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen));
-	if (rlen == -1 && errno == EINTR)
-		goto again;
-	if (rlen == -1 || rlen < 4*sizeof(u_int32_t))
-		return (FALSE);
-	xdrs->x_op = XDR_DECODE;
-	XDR_SETPOS(xdrs, 0);
-	if (! xdr_callmsg(xdrs, msg))
-		return (FALSE);
-	su->su_xid = msg->rm_xid;
-	if (su->su_cache != NULL) {
-		if (cache_get(xprt, msg, &reply, &replylen)) {
-			(void) sendto(xprt->xp_fd, reply, (int) replylen, 0,
-			  (struct sockaddr *) &xprt->xp_raddr, xprt->xp_addrlen);
-			return (TRUE);
-		}
-	}
-	return (TRUE);
-}
-
-static bool_t
-svcudp_reply(
-	SVCXPRT *xprt,
-	struct rpc_msg *msg)
-{
-	register struct svcudp_data *su = su_data(xprt);
-	register XDR *xdrs = &(su->su_xdrs);
-	register int slen;
-	register bool_t stat = FALSE;
-
-	xdrs->x_op = XDR_ENCODE;
-	XDR_SETPOS(xdrs, 0);
-	msg->rm_xid = su->su_xid;
-	if (xdr_replymsg(xdrs, msg)) {
-		slen = (int)XDR_GETPOS(xdrs);
-		if (sendto(xprt->xp_fd, rpc_buffer(xprt), slen, 0,
-		    (struct sockaddr *)&(xprt->xp_raddr), xprt->xp_addrlen)
-		    == slen) {
-			stat = TRUE;
-			if (su->su_cache && slen >= 0) {
-				cache_set(xprt, (u_long) slen);
-			}
-		}
-	}
-	return (stat);
-}
-
-static bool_t
-svcudp_getargs(
-	SVCXPRT *xprt,
-	xdrproc_t xdr_args,
-	caddr_t args_ptr)
-{
-
-	return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr));
-}
-
-static bool_t
-svcudp_freeargs(
-	SVCXPRT *xprt,
-	xdrproc_t xdr_args,
-	caddr_t args_ptr)
-{
-	register XDR *xdrs = &(su_data(xprt)->su_xdrs);
-
-	xdrs->x_op = XDR_FREE;
-	return ((*xdr_args)(xdrs, args_ptr));
-}
-
-static void
-svcudp_destroy(
-	SVCXPRT *xprt)
-{
-	register struct svcudp_data *su = su_data(xprt);
-
-	xprt_unregister(xprt);
-	(void)_RPC_close(xprt->xp_fd);
-	XDR_DESTROY(&(su->su_xdrs));
-	mem_free(rpc_buffer(xprt), su->su_iosz);
-	mem_free((caddr_t)su, sizeof(struct svcudp_data));
-	mem_free((caddr_t)xprt, sizeof(SVCXPRT));
-}
-
-
-/***********this could be a separate file*********************/
-
-/*
- * Fifo cache for udp server
- * Copies pointers to reply buffers into fifo cache
- * Buffers are sent again if retransmissions are detected.
- */
-
-#define SPARSENESS 4	/* 75% sparse */
-
-#define CACHE_PERROR(msg)	\
-	(void) fprintf(stderr,"%s\n", msg)
-
-#define ALLOC(type, size)	\
-	(type *) mem_alloc((unsigned) (sizeof(type) * (size)))
-
-#define BZERO(addr, type, size)	 \
-	memset((char *) addr, 0, sizeof(type) * (int) (size))
-
-/*
- * An entry in the cache
- */
-typedef struct cache_node *cache_ptr;
-struct cache_node {
-	/*
-	 * Index into cache is xid, proc, vers, prog and address
-	 */
-	u_long cache_xid;
-	u_long cache_proc;
-	u_long cache_vers;
-	u_long cache_prog;
-	struct sockaddr_in cache_addr;
-	/*
-	 * The cached reply and length
-	 */
-	char * cache_reply;
-	u_long cache_replylen;
-	/*
- 	 * Next node on the list, if there is a collision
-	 */
-	cache_ptr cache_next;
-};
-
-
-
-/*
- * The entire cache
- */
-struct udp_cache {
-	u_long uc_size;		/* size of cache */
-	cache_ptr *uc_entries;	/* hash table of entries in cache */
-	cache_ptr *uc_fifo;	/* fifo list of entries in cache */
-	u_long uc_nextvictim;	/* points to next victim in fifo list */
-	u_long uc_prog;		/* saved program number */
-	u_long uc_vers;		/* saved version number */
-	u_long uc_proc;		/* saved procedure number */
-	struct sockaddr_in uc_addr; /* saved caller's address */
-};
-
-
-/*
- * the hashing function
- */
-#define CACHE_LOC(transp, xid)	\
- (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size))
-
-
-/*
- * Enable use of the cache.
- * Note: there is no disable.
- */
-int svcudp_enablecache(
-	SVCXPRT *transp,
-	u_long size)
-{
-	struct svcudp_data *su = su_data(transp);
-	struct udp_cache *uc;
-
-	if (su->su_cache != NULL) {
-		CACHE_PERROR("enablecache: cache already enabled");
-		return(0);
-	}
-	uc = ALLOC(struct udp_cache, 1);
-	if (uc == NULL) {
-		CACHE_PERROR("enablecache: could not allocate cache");
-		return(0);
-	}
-	uc->uc_size = size;
-	uc->uc_nextvictim = 0;
-	uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS);
-	if (uc->uc_entries == NULL) {
-		CACHE_PERROR("enablecache: could not allocate cache data");
-		return(0);
-	}
-	BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS);
-	uc->uc_fifo = ALLOC(cache_ptr, size);
-	if (uc->uc_fifo == NULL) {
-		CACHE_PERROR("enablecache: could not allocate cache fifo");
-		return(0);
-	}
-	BZERO(uc->uc_fifo, cache_ptr, size);
-	su->su_cache = (char *) uc;
-	return(1);
-}
-
-
-/*
- * Set an entry in the cache
- */
-static void
-cache_set(
-	SVCXPRT *xprt,
-	u_long replylen)
-{
-	register cache_ptr victim;
-	register cache_ptr *vicp;
-	register struct svcudp_data *su = su_data(xprt);
-	struct udp_cache *uc = (struct udp_cache *) su->su_cache;
-	u_int loc;
-	char *newbuf;
-
-	/*
- 	 * Find space for the new entry, either by
-	 * reusing an old entry, or by mallocing a new one
-	 */
-	victim = uc->uc_fifo[uc->uc_nextvictim];
-	if (victim != NULL) {
-		loc = CACHE_LOC(xprt, victim->cache_xid);
-		for (vicp = &uc->uc_entries[loc];
-		  *vicp != NULL && *vicp != victim;
-		  vicp = &(*vicp)->cache_next)
-				;
-		if (*vicp == NULL) {
-			CACHE_PERROR("cache_set: victim not found");
-			return;
-		}
-		*vicp = victim->cache_next;	/* remote from cache */
-		newbuf = victim->cache_reply;
-	} else {
-		victim = ALLOC(struct cache_node, 1);
-		if (victim == NULL) {
-			CACHE_PERROR("cache_set: victim alloc failed");
-			return;
-		}
-		newbuf = mem_alloc(su->su_iosz);
-		if (newbuf == NULL) {
-			CACHE_PERROR("cache_set: could not allocate new rpc_buffer");
-			return;
-		}
-	}
-
-	/*
-	 * Store it away
-	 */
-	victim->cache_replylen = replylen;
-	victim->cache_reply = rpc_buffer(xprt);
-	rpc_buffer(xprt) = newbuf;
-	xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_ENCODE);
-	victim->cache_xid = su->su_xid;
-	victim->cache_proc = uc->uc_proc;
-	victim->cache_vers = uc->uc_vers;
-	victim->cache_prog = uc->uc_prog;
-	victim->cache_addr = uc->uc_addr;
-	loc = CACHE_LOC(xprt, victim->cache_xid);
-	victim->cache_next = uc->uc_entries[loc];
-	uc->uc_entries[loc] = victim;
-	uc->uc_fifo[uc->uc_nextvictim++] = victim;
-	uc->uc_nextvictim %= uc->uc_size;
-}
-
-/*
- * Try to get an entry from the cache
- * return 1 if found, 0 if not found
- */
-static int
-cache_get(
-	SVCXPRT *xprt,
-	struct rpc_msg *msg,
-	char **replyp,
-	u_long *replylenp)
-{
-	u_int loc;
-	register cache_ptr ent;
-	register struct svcudp_data *su = su_data(xprt);
-	register struct udp_cache *uc = (struct udp_cache *) su->su_cache;
-
-#	define EQADDR(a1, a2)	(memcmp(&a1, &a2, sizeof(a1)) == 0)
-
-	loc = CACHE_LOC(xprt, su->su_xid);
-	for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) {
-		if (ent->cache_xid == su->su_xid &&
-		  ent->cache_proc == uc->uc_proc &&
-		  ent->cache_vers == uc->uc_vers &&
-		  ent->cache_prog == uc->uc_prog &&
-		  EQADDR(ent->cache_addr, uc->uc_addr)) {
-			*replyp = ent->cache_reply;
-			*replylenp = ent->cache_replylen;
-			return(1);
-		}
-	}
-	/*
-	 * Failed to find entry
-	 * Remember a few things so we can do a set later
-	 */
-	uc->uc_proc = msg->rm_call.cb_proc;
-	uc->uc_vers = msg->rm_call.cb_vers;
-	uc->uc_prog = msg->rm_call.cb_prog;
-	uc->uc_addr = xprt->xp_raddr;
-	return(0);
-}
Index: rvices/librpc/src/xdr/xdr.3
===================================================================
--- services/librpc/src/xdr/xdr.3	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,837 +1,0 @@
-.\" @(#)xdr.3n	2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
-.\" $FreeBSD: src/lib/libc/xdr/xdr.3,v 1.8 2000/03/02 09:14:05 sheldonh Exp $
-.\"
-.TH XDR 3 "16 February 1988"
-.SH NAME
-xdr \- library routines for external data representation
-.SH SYNOPSIS AND DESCRIPTION
-.LP
-These routines allow C programmers to describe
-arbitrary data structures in a machine-independent fashion.
-Data for remote procedure calls are transmitted using these
-routines.
-.LP
-.ft B
-.nf
-.sp .5
-xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc)
-\s-1XDR\s0 *xdrs;
-char **arrp;
-u_int *sizep, maxsize, elsize;
-xdrproc_t elproc;
-.fi
-.ft R
-.IP
-A filter primitive that translates between variable-length
-arrays
-and their corresponding external representations.
-The
-parameter
-.I arrp
-is the address of the pointer to the array, while
-.I sizep
-is the address of the element count of the array;
-this element count cannot exceed
-.IR maxsize .
-The parameter
-.I elsize
-is the
-.I sizeof
-each of the array's elements, and
-.I elproc
-is an
-.SM XDR
-filter that translates between
-the array elements' C form, and their external
-representation.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-xdr_bool(xdrs, bp)
-\s-1XDR\s0 *xdrs;
-bool_t *bp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between booleans (C
-integers)
-and their external representations.
-When encoding data, this
-filter produces values of either one or zero.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-xdr_bytes(xdrs, sp, sizep, maxsize)
-\s-1XDR\s0 *xdrs;
-char **sp;
-u_int *sizep, maxsize;
-.fi
-.ft R
-.IP
-A filter primitive that translates between counted byte
-strings and their external representations.
-The parameter
-.I sp
-is the address of the string pointer.
-The length of the
-string is located at address
-.IR sizep ;
-strings cannot be longer than
-.IR maxsize .
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_char(xdrs, cp)
-\s-1XDR\s0 *xdrs;
-char *cp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C characters
-and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-Note: encoded characters are not packed, and occupy 4 bytes
-each.
-For arrays of characters, it is worthwhile to
-consider
-.BR xdr_bytes(\|) ,
-.B xdr_opaque(\|)
-or
-.BR xdr_string(\|) .
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-void
-xdr_destroy(xdrs)
-\s-1XDR\s0 *xdrs;
-.fi
-.ft R
-.IP
-A macro that invokes the destroy routine associated with the
-.SM XDR
-stream,
-.IR xdrs .
-Destruction usually involves freeing private data structures
-associated with the stream.  Using
-.I xdrs
-after invoking
-.B xdr_destroy(\|)
-is undefined.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_double(xdrs, dp)
-\s-1XDR\s0 *xdrs;
-double *dp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C
-.B double
-precision numbers and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_enum(xdrs, ep)
-\s-1XDR\s0 *xdrs;
-enum_t *ep;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C
-.BR enum s
-(actually integers) and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-xdr_float(xdrs, fp)
-\s-1XDR\s0 *xdrs;
-float *fp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C
-.BR float s
-and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-void
-xdr_free(proc, objp)
-xdrproc_t proc;
-char *objp;
-.fi
-.ft R
-.IP
-Generic freeing routine.
-The first argument is the
-.SM XDR
-routine for the object being freed.
-The second argument
-is a pointer to the object itself.
-Note: the pointer passed
-to this routine is
-.I not
-freed, but what it points to
-.I is
-freed (recursively).
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-u_int
-xdr_getpos(xdrs)
-\s-1XDR\s0 *xdrs;
-.fi
-.ft R
-.IP
-A macro that invokes the get-position routine
-associated with the
-.SM XDR
-stream,
-.IR xdrs .
-The routine returns an unsigned integer,
-which indicates the position of the
-.SM XDR
-byte stream.
-A desirable feature of
-.SM XDR
-streams is that simple arithmetic works with this number,
-although the
-.SM XDR
-stream instances need not guarantee this.
-.br
-.if t .ne 4
-.LP
-.ft B
-.nf
-.sp .5
-.br
-long *
-xdr_inline(xdrs, len)
-\s-1XDR\s0 *xdrs;
-int len;
-.fi
-.ft R
-.IP
-A macro that invokes the in-line routine associated with the
-.SM XDR
-stream,
-.IR xdrs .
-The routine returns a pointer
-to a contiguous piece of the stream's buffer;
-.I len
-is the byte length of the desired buffer.
-Note: pointer is cast to
-.BR "long *" .
-.IP
-Warning:
-.B xdr_inline(\|)
-may return
-.SM NULL
-(0)
-if it cannot allocate a contiguous piece of a buffer.
-Therefore the behavior may vary among stream instances;
-it exists for the sake of efficiency.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_int(xdrs, ip)
-\s-1XDR\s0 *xdrs;
-int *ip;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C integers
-and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_long(xdrs, lp)
-\s-1XDR\s0 *xdrs;
-long *lp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C
-.B long
-integers and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 12
-.LP
-.ft B
-.nf
-.sp .5
-void
-xdrmem_create(xdrs, addr, size, op)
-\s-1XDR\s0 *xdrs;
-char *addr;
-u_int size;
-enum xdr_op op;
-.fi
-.ft R
-.IP
-This routine initializes the
-.SM XDR
-stream object pointed to by
-.IR xdrs .
-The stream's data is written to, or read from,
-a chunk of memory at location
-.I addr
-whose length is no more than
-.I size
-bytes long.  The
-.I op
-determines the direction of the
-.SM XDR
-stream
-(either
-.BR \s-1XDR_ENCODE\s0 ,
-.BR \s-1XDR_DECODE\s0 ,
-or
-.BR \s-1XDR_FREE\s0 ).
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-xdr_opaque(xdrs, cp, cnt)
-\s-1XDR\s0 *xdrs;
-char *cp;
-u_int cnt;
-.fi
-.ft R
-.IP
-A filter primitive that translates between fixed size opaque
-data
-and its external representation.
-The parameter
-.I cp
-is the address of the opaque object, and
-.I cnt
-is its size in bytes.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-xdr_pointer(xdrs, objpp, objsize, xdrobj)
-\s-1XDR\s0 *xdrs;
-char **objpp;
-u_int objsize;
-xdrproc_t xdrobj;
-.fi
-.ft R
-.IP
-Like
-.B xdr_reference(\|)
-execpt that it serializes
-.SM NULL
-pointers, whereas
-.B xdr_reference(\|)
-does not.  Thus,
-.B xdr_pointer(\|)
-can represent
-recursive data structures, such as binary trees or
-linked lists.
-.br
-.if t .ne 15
-.LP
-.ft B
-.nf
-.sp .5
-void
-xdrrec_create(xdrs, sendsize, recvsize, handle, readit, writeit)
-\s-1XDR\s0 *xdrs;
-u_int sendsize, recvsize;
-char *handle;
-int (*readit) (\|), (*writeit) (\|);
-.fi
-.ft R
-.IP
-This routine initializes the
-.SM XDR
-stream object pointed to by
-.IR xdrs .
-The stream's data is written to a buffer of size
-.IR sendsize ;
-a value of zero indicates the system should use a suitable
-default.
-The stream's data is read from a buffer of size
-.IR recvsize ;
-it too can be set to a suitable default by passing a zero
-value.
-When a stream's output buffer is full,
-.I writeit
-is called.  Similarly, when a stream's input buffer is empty,
-.I readit
-is called.  The behavior of these two routines is similar to
-the
-system calls
-.B read
-and
-.BR write ,
-except that
-.I handle
-is passed to the former routines as the first parameter.
-Note: the
-.SM XDR
-stream's
-.I op
-field must be set by the caller.
-.IP
-Warning: this
-.SM XDR
-stream implements an intermediate record stream.
-Therefore there are additional bytes in the stream
-to provide record boundary information.
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-xdrrec_endofrecord(xdrs, sendnow)
-\s-1XDR\s0 *xdrs;
-int sendnow;
-.fi
-.ft R
-.IP
-This routine can be invoked only on
-streams created by
-.BR xdrrec_create(\|) .
-The data in the output buffer is marked as a completed
-record,
-and the output buffer is optionally written out if
-.I sendnow
-is non-zero.
-This routine returns one if it succeeds, zero
-otherwise.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-xdrrec_eof(xdrs)
-\s-1XDR\s0 *xdrs;
-int empty;
-.fi
-.ft R
-.IP
-This routine can be invoked only on
-streams created by
-.BR xdrrec_create(\|) .
-After consuming the rest of the current record in the stream,
-this routine returns one if the stream has no more input,
-zero otherwise.
-.br
-.if t .ne 3
-.LP
-.ft B
-.nf
-.sp .5
-xdrrec_skiprecord(xdrs)
-\s-1XDR\s0 *xdrs;
-.fi
-.ft R
-.IP
-This routine can be invoked only on
-streams created by
-.BR xdrrec_create(\|) .
-It tells the
-.SM XDR
-implementation that the rest of the current record
-in the stream's input buffer should be discarded.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 11
-.LP
-.ft B
-.nf
-.sp .5
-xdr_reference(xdrs, pp, size, proc)
-\s-1XDR\s0 *xdrs;
-char **pp;
-u_int size;
-xdrproc_t proc;
-.fi
-.ft R
-.IP
-A primitive that provides pointer chasing within structures.
-The parameter
-.I pp
-is the address of the pointer;
-.I size
-is the
-.I sizeof
-the structure that
-.I *pp
-points to; and
-.I proc
-is an
-.SM XDR
-procedure that filters the structure
-between its C form and its external representation.
-This routine returns one if it succeeds, zero otherwise.
-.IP
-Warning: this routine does not understand
-.SM NULL
-pointers.
-Use
-.B xdr_pointer(\|)
-instead.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-xdr_setpos(xdrs, pos)
-\s-1XDR\s0 *xdrs;
-u_int pos;
-.fi
-.ft R
-.IP
-A macro that invokes the set position routine associated with
-the
-.SM XDR
-stream
-.IR xdrs .
-The parameter
-.I pos
-is a position value obtained from
-.BR xdr_getpos(\|) .
-This routine returns one if the
-.SM XDR
-stream could be repositioned,
-and zero otherwise.
-.IP
-Warning: it is difficult to reposition some types of
-.SM XDR
-streams, so this routine may fail with one
-type of stream and succeed with another.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-xdr_short(xdrs, sp)
-\s-1XDR\s0 *xdrs;
-short *sp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C
-.B short
-integers and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-void
-xdrstdio_create(xdrs, file, op)
-\s-1XDR\s0 *xdrs;
-\s-1FILE\s0 *file;
-enum xdr_op op;
-.fi
-.ft R
-.IP
-This routine initializes the
-.SM XDR
-stream object pointed to by
-.IR xdrs .
-The
-.SM XDR
-stream data is written to, or read from, the Standard
-.B I/O
-stream
-.IR file .
-The parameter
-.I op
-determines the direction of the
-.SM XDR
-stream (either
-.BR \s-1XDR_ENCODE\s0 ,
-.BR \s-1XDR_DECODE\s0 ,
-or
-.BR \s-1XDR_FREE\s0 ).
-.IP
-Warning: the destroy routine associated with such
-.SM XDR
-streams calls
-.B fflush(\|)
-on the
-.I file
-stream, but never
-.BR fclose(\|) .
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-xdr_string(xdrs, sp, maxsize)
-\s-1XDR\s0
-*xdrs;
-char **sp;
-u_int maxsize;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C strings and
-their
-corresponding external representations.
-Strings cannot be longer than
-.IR maxsize .
-Note: 
-.I sp
-is the address of the string's pointer.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 8
-.LP
-.ft B
-.nf
-.sp .5
-xdr_u_char(xdrs, ucp)
-\s-1XDR\s0 *xdrs;
-unsigned char *ucp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between
-.B unsigned
-C characters and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 9
-.LP
-.ft B
-.nf
-.sp .5
-xdr_u_int(xdrs, up)
-\s-1XDR\s0 *xdrs;
-unsigned *up;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C
-.B unsigned
-integers and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_u_long(xdrs, ulp)
-\s-1XDR\s0 *xdrs;
-unsigned long *ulp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C
-.B "unsigned long"
-integers and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 7
-.LP
-.ft B
-.nf
-.sp .5
-xdr_u_short(xdrs, usp)
-\s-1XDR\s0 *xdrs;
-unsigned short *usp;
-.fi
-.ft R
-.IP
-A filter primitive that translates between C
-.B "unsigned short"
-integers and their external representations.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 16
-.LP
-.ft B
-.nf
-.sp .5
-xdr_union(xdrs, dscmp, unp, choices, dfault)
-\s-1XDR\s0 *xdrs;
-int *dscmp;
-char *unp;
-struct xdr_discrim *choices;
-bool_t (*defaultarm) (\|);  /* may equal \s-1NULL\s0 */
-.fi
-.ft R
-.IP
-A filter primitive that translates between a discriminated C
-.B union
-and its corresponding external representation.
-It first
-translates the discriminant of the union located at
-.IR dscmp .
-This discriminant is always an
-.BR enum_t .
-Next the union located at
-.I unp
-is translated.  The parameter
-.I choices
-is a pointer to an array of
-.B xdr_discrim(\|)
-structures.
-Each structure contains an ordered pair of
-.RI [ value , proc ].
-If the union's discriminant is equal to the associated
-.IR value ,
-then the
-.I proc
-is called to translate the union.  The end of the
-.B xdr_discrim(\|)
-structure array is denoted by a routine of value
-.SM NULL\s0.
-If the discriminant is not found in the
-.I choices
-array, then the
-.I defaultarm
-procedure is called (if it is not
-.SM NULL\s0).
-Returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 6
-.LP
-.ft B
-.nf
-.sp .5
-xdr_vector(xdrs, arrp, size, elsize, elproc)
-\s-1XDR\s0 *xdrs;
-char *arrp;
-u_int size, elsize;
-xdrproc_t elproc;
-.fi
-.ft R
-.IP
-A filter primitive that translates between fixed-length
-arrays
-and their corresponding external representations.  The
-parameter
-.I arrp
-is the address of the pointer to the array, while
-.I size
-is the element count of the array.  The parameter
-.I elsize
-is the
-.I sizeof
-each of the array's elements, and
-.I elproc
-is an
-.SM XDR
-filter that translates between
-the array elements' C form, and their external
-representation.
-This routine returns one if it succeeds, zero otherwise.
-.br
-.if t .ne 5
-.LP
-.ft B
-.nf
-.sp .5
-xdr_void(\|)
-.fi
-.ft R
-.IP
-This routine always returns one.
-It may be passed to
-.SM RPC
-routines that require a function parameter,
-where nothing is to be done.
-.br
-.if t .ne 10
-.LP
-.ft B
-.nf
-.sp .5
-xdr_wrapstring(xdrs, sp)
-\s-1XDR\s0 *xdrs;
-char **sp;
-.fi
-.ft R
-.IP
-A primitive that calls
-.B "xdr_string(xdrs, sp,\s-1MAXUN.UNSIGNED\s0 );"
-where
-.B
-.SM MAXUN.UNSIGNED
-is the maximum value of an unsigned integer.
-.B xdr_wrapstring(\|)
-is handy because the
-.SM RPC
-package passes a maximum of two
-.SM XDR
-routines as parameters, and
-.BR xdr_string(\|) ,
-one of the most frequently used primitives, requires three.
-Returns one if it succeeds, zero otherwise.
-.SH SEE ALSO
-.BR rpc (3)
-.LP
-The following manuals:
-.RS
-.ft I
-eXternal Data Representation Standard: Protocol Specification
-.br
-eXternal Data Representation: Sun Technical Notes
-.ft R
-.br
-.IR "\s-1XDR\s0: External Data Representation Standard" ,
-.SM RFC1014, Sun Microsystems, Inc.,
-.SM USC-ISI\s0.
Index: rvices/librpc/src/xdr/xdr.c
===================================================================
--- services/librpc/src/xdr/xdr.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,858 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)xdr.c 1.35 87/08/12";*/
-/*static char *sccsid = "from: @(#)xdr.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr.c,v 1.9 1999/08/28 00:02:55 peter Exp $";
-#endif
-
-/*
- * xdr.c, Generic XDR routines implementation.
- *
- * Copyright (C) 1986, Sun Microsystems, Inc.
- *
- * These are the "generic" xdr routines used to serialize and de-serialize
- * most common data items.  See xdr.h for more info on the interface to
- * xdr.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-
-#if defined(__rtems__)
-#define warnx(msg) fprintf(stderr, msg "\n");
-#endif
-
-/*
- * constants specific to the xdr "protocol"
- */
-#define XDR_FALSE	((long) 0)
-#define XDR_TRUE	((long) 1)
-#define LASTUNSIGNED	((u_int) 0-1)
-
-/*
- * for unit alignment
- */
-static const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
-
-/*
- * Free a data structure using XDR
- * Not a filter, but a convenient utility nonetheless
- */
-void
-xdr_free(
-	xdrproc_t proc,
-	void *objp)
-{
-	XDR x;
-
-	x.x_op = XDR_FREE;
-	(*proc)(&x, objp);
-}
-
-/*
- * XDR nothing
- */
-bool_t
-xdr_void(void)
-{
-
-	return (TRUE);
-}
-
-
-/*
- * XDR integers
- */
-bool_t
-xdr_int(
-	XDR *xdrs,
-	int *ip)
-{
-	long l;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		l = (long) *ip;
-		return (XDR_PUTLONG(xdrs, &l));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, &l)) {
-			return (FALSE);
-		}
-		*ip = (int) l;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/*
- * XDR unsigned integers
- */
-bool_t
-xdr_u_int(
-	XDR *xdrs,
-	u_int *up)
-{
-	u_long l;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		l = (u_long) *up;
-		return (XDR_PUTLONG(xdrs, (long *)&l));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, (long *)&l)) {
-			return (FALSE);
-		}
-		*up = (u_int) l;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-
-/*
- * XDR long integers
- * same as xdr_u_long - open coded to save a proc call!
- */
-bool_t
-xdr_long(
-	XDR *xdrs,
-	long *lp)
-{
-	switch (xdrs->x_op) {
-	case XDR_ENCODE:
-		return (XDR_PUTLONG(xdrs, lp));
-	case XDR_DECODE:
-		return (XDR_GETLONG(xdrs, lp));
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/*
- * XDR unsigned long integers
- * same as xdr_long - open coded to save a proc call!
- */
-bool_t
-xdr_u_long(
-	XDR *xdrs,
-	u_long *ulp)
-{
-	switch (xdrs->x_op) {
-	case XDR_ENCODE:
-		return (XDR_PUTLONG(xdrs, (long *)ulp));
-	case XDR_DECODE:
-		return (XDR_GETLONG(xdrs, (long *)ulp));
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-
-/*
- * XDR 32-bit integers
- * same as xdr_u_int32_t - open coded to save a proc call!
- */
-bool_t
-xdr_int32_t(
-	XDR *xdrs,
-	int32_t *int32_p)
-{
-	long l;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		l = (long) *int32_p;
-		return (XDR_PUTLONG(xdrs, &l));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, &l)) {
-			return (FALSE);
-		}
-		*int32_p = (int32_t) l;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/*
- * XDR unsigned 32-bit integers
- * same as xdr_int32_t - open coded to save a proc call!
- */
-bool_t
-xdr_u_int32_t(
-	XDR *xdrs,
-	u_int32_t *u_int32_p)
-{
-	u_long l;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		l = (u_long) *u_int32_p;
-		return (XDR_PUTLONG(xdrs, (long *)&l));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, (long *)&l)) {
-			return (FALSE);
-		}
-		*u_int32_p = (u_int32_t) l;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	return (FALSE);
-}
-
-/*
- * XDR short integers
- */
-bool_t
-xdr_short(
-	XDR *xdrs,
-	short *sp)
-{
-	long l;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		l = (long) *sp;
-		return (XDR_PUTLONG(xdrs, &l));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, &l)) {
-			return (FALSE);
-		}
-		*sp = (short) l;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/*
- * XDR unsigned short integers
- */
-bool_t
-xdr_u_short(
-	XDR *xdrs,
-	u_short *usp)
-{
-	u_long l;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		l = (u_long) *usp;
-		return (XDR_PUTLONG(xdrs, (long *)&l));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, (long *)&l)) {
-			return (FALSE);
-		}
-		*usp = (u_short) l;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-
-/*
- * XDR 16-bit integers
- */
-bool_t
-xdr_int16_t(
-	XDR *xdrs,
-	int16_t *int16_p)
-{
-	long l;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		l = (long) *int16_p;
-		return (XDR_PUTLONG(xdrs, &l));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, &l)) {
-			return (FALSE);
-		}
-		*int16_p = (int16_t) l;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/*
- * XDR unsigned 16-bit integers
- */
-bool_t
-xdr_u_int16_t(
-	XDR *xdrs,
-	u_int16_t *u_int16_p)
-{
-	u_long l;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		l = (u_long) *u_int16_p;
-		return (XDR_PUTLONG(xdrs, (long *)&l));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, (long *)&l)) {
-			return (FALSE);
-		}
-		*u_int16_p = (u_int16_t) l;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-
-/*
- * XDR a char
- */
-bool_t
-xdr_char(
-	XDR *xdrs,
-	char *cp)
-{
-	int i;
-
-	i = (*cp);
-	if (!xdr_int(xdrs, &i)) {
-		return (FALSE);
-	}
-	*cp = i;
-	return (TRUE);
-}
-
-/*
- * XDR an unsigned char
- */
-bool_t
-xdr_u_char(
-	XDR *xdrs,
-	u_char *cp)
-{
-	u_int u;
-
-	u = (*cp);
-	if (!xdr_u_int(xdrs, &u)) {
-		return (FALSE);
-	}
-	*cp = u;
-	return (TRUE);
-}
-
-/*
- * XDR booleans
- */
-bool_t
-xdr_bool(
-	XDR *xdrs,
-	bool_t *bp)
-{
-	long lb;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		lb = *bp ? XDR_TRUE : XDR_FALSE;
-		return (XDR_PUTLONG(xdrs, &lb));
-
-	case XDR_DECODE:
-		if (!XDR_GETLONG(xdrs, &lb)) {
-			return (FALSE);
-		}
-		*bp = (lb == XDR_FALSE) ? FALSE : TRUE;
-		return (TRUE);
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/*
- * XDR enumerations
- */
-bool_t
-xdr_enum(
-	XDR *xdrs,
-	enum_t *ep)
-{
-#ifndef lint
-	/*
-	 * enums are treated as ints
-	 */
-	if (sizeof (enum_t) == sizeof (long)) {
-		return (xdr_long(xdrs, (long *)ep));
-	} else if (sizeof (enum_t) == sizeof (int)) {
-		return (xdr_int(xdrs, (int *)ep));
-	} else if (sizeof (enum_t) == sizeof (short)) {
-		return (xdr_short(xdrs, (short *)ep));
-	} else {
-		return (FALSE);
-	}
-#else
-	(void) (xdr_short(xdrs, (short *)ep));
-	(void) (xdr_int(xdrs, (int *)ep));
-	return (xdr_long(xdrs, (long *)ep));
-#endif
-}
-
-/*
- * XDR opaque data
- * Allows the specification of a fixed size sequence of opaque bytes.
- * cp points to the opaque object and cnt gives the byte length.
- */
-bool_t
-xdr_opaque(
-	XDR *xdrs,
-	caddr_t cp,
-	u_int cnt)
-{
-	u_int rndup;
-	static int crud[BYTES_PER_XDR_UNIT];
-
-	/*
-	 * if no data we are done
-	 */
-	if (cnt == 0)
-		return (TRUE);
-
-	/*
-	 * round byte count to full xdr units
-	 */
-	rndup = cnt % BYTES_PER_XDR_UNIT;
-	if (rndup > 0)
-		rndup = BYTES_PER_XDR_UNIT - rndup;
-
-	if (xdrs->x_op == XDR_DECODE) {
-		if (!XDR_GETBYTES(xdrs, cp, cnt)) {
-			return (FALSE);
-		}
-		if (rndup == 0)
-			return (TRUE);
-		return (XDR_GETBYTES(xdrs, (caddr_t)crud, rndup));
-	}
-
-	if (xdrs->x_op == XDR_ENCODE) {
-		if (!XDR_PUTBYTES(xdrs, cp, cnt)) {
-			return (FALSE);
-		}
-		if (rndup == 0)
-			return (TRUE);
-		return (XDR_PUTBYTES(xdrs, xdr_zero, rndup));
-	}
-
-	if (xdrs->x_op == XDR_FREE) {
-		return (TRUE);
-	}
-
-	return (FALSE);
-}
-
-/*
- * XDR counted bytes
- * *cpp is a pointer to the bytes, *sizep is the count.
- * If *cpp is NULL maxsize bytes are allocated
- */
-bool_t
-xdr_bytes(
-	XDR *xdrs,
-	char **cpp,
-	u_int *sizep,
-	u_int maxsize)
-{
-	char *sp = *cpp;  /* sp is the actual string pointer */
-	u_int nodesize;
-
-	/*
-	 * first deal with the length since xdr bytes are counted
-	 */
-	if (! xdr_u_int(xdrs, sizep)) {
-		return (FALSE);
-	}
-	nodesize = *sizep;
-	if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) {
-		return (FALSE);
-	}
-
-	/*
-	 * now deal with the actual bytes
-	 */
-	switch (xdrs->x_op) {
-
-	case XDR_DECODE:
-		if (nodesize == 0) {
-			return (TRUE);
-		}
-		if (sp == NULL) {
-			*cpp = sp = mem_alloc(nodesize);
-		}
-		if (sp == NULL) {
-			warnx("xdr_bytes: out of memory");
-			return (FALSE);
-		}
-		/* FALLTHROUGH */
-
-	case XDR_ENCODE:
-		return (xdr_opaque(xdrs, sp, nodesize));
-
-	case XDR_FREE:
-		if (sp != NULL) {
-			mem_free(sp, nodesize);
-			*cpp = NULL;
-		}
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/*
- * Implemented here due to commonality of the object.
- */
-bool_t
-xdr_netobj(
-	XDR *xdrs,
-	struct netobj *np)
-{
-
-	return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
-}
-
-/*
- * XDR a descriminated union
- * Support routine for discriminated unions.
- * You create an array of xdrdiscrim structures, terminated with
- * an entry with a null procedure pointer.  The routine gets
- * the discriminant value and then searches the array of xdrdiscrims
- * looking for that value.  It calls the procedure given in the xdrdiscrim
- * to handle the discriminant.  If there is no specific routine a default
- * routine may be called.
- * If there is no specific or default routine an error is returned.
- */
-bool_t
-xdr_union(
-	XDR *xdrs,
-	enum_t *dscmp,		/* enum to decide which arm to work on */
-	char *unp,		/* the union itself */
-	const struct xdr_discrim *choices,	/* [value, xdr proc] for each arm */
-	xdrproc_t dfault)	/* default xdr routine */
-{
-	enum_t dscm;
-
-	/*
-	 * we deal with the discriminator;  it's an enum
-	 */
-	if (! xdr_enum(xdrs, dscmp)) {
-		return (FALSE);
-	}
-	dscm = *dscmp;
-
-	/*
-	 * search choices for a value that matches the discriminator.
-	 * if we find one, execute the xdr routine for that value.
-	 */
-	for (; choices->proc != NULL_xdrproc_t; choices++) {
-		if (choices->value == dscm)
-			return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED));
-	}
-
-	/*
-	 * no match - execute the default xdr routine if there is one
-	 */
-	return ((dfault == NULL_xdrproc_t) ? FALSE :
-	    (*dfault)(xdrs, unp, LASTUNSIGNED));
-}
-
-
-/*
- * Non-portable xdr primitives.
- * Care should be taken when moving these routines to new architectures.
- */
-
-
-/*
- * XDR null terminated ASCII strings
- * xdr_string deals with "C strings" - arrays of bytes that are
- * terminated by a NULL character.  The parameter cpp references a
- * pointer to storage; If the pointer is null, then the necessary
- * storage is allocated.  The last parameter is the max allowed length
- * of the string as specified by a protocol.
- */
-bool_t
-xdr_string(
-	XDR *xdrs,
-	char **cpp,
-	u_int maxsize)
-{
-	char *sp = *cpp;  /* sp is the actual string pointer */
-	u_int size = 0;
-	u_int nodesize;
-
-	/*
-	 * first deal with the length since xdr strings are counted-strings
-	 */
-	switch (xdrs->x_op) {
-	case XDR_FREE:
-		if (sp == NULL) {
-			return(TRUE);	/* already free */
-		}
-		/* FALLTHROUGH */
-	case XDR_ENCODE:
-		size = strlen(sp);
-		break;
-	case XDR_DECODE:
-		break;
-	}
-	if (! xdr_u_int(xdrs, &size)) {
-		return (FALSE);
-	}
-	if (size > maxsize) {
-		return (FALSE);
-	}
-	nodesize = size + 1;
-
-	/*
-	 * now deal with the actual bytes
-	 */
-	switch (xdrs->x_op) {
-
-	case XDR_DECODE:
-		if (nodesize == 0) {
-			return (TRUE);
-		}
-		if (sp == NULL)
-			*cpp = sp = mem_alloc(nodesize);
-		if (sp == NULL) {
-			warnx("xdr_string: out of memory");
-			return (FALSE);
-		}
-		sp[size] = 0;
-		/* FALLTHROUGH */
-
-	case XDR_ENCODE:
-		return (xdr_opaque(xdrs, sp, size));
-
-	case XDR_FREE:
-		mem_free(sp, nodesize);
-		*cpp = NULL;
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/*
- * Wrapper for xdr_string that can be called directly from
- * routines like clnt_call
- */
-bool_t
-xdr_wrapstring(
-	XDR *xdrs,
-	char **cpp)
-{
-	return xdr_string(xdrs, cpp, LASTUNSIGNED);
-}
-
-/*
- * XDR 64-bit integers
- */
-bool_t
-xdr_int64_t(
-	XDR *xdrs,
-	int64_t *int64_p)
-{
-	int64_t x;
-
-	switch (xdrs->x_op) {
-	case XDR_ENCODE:
-		return (xdr_opaque(xdrs, (caddr_t)int64_p, sizeof(int64_t)));
-	case XDR_DECODE:
-		if (!xdr_opaque(xdrs, (caddr_t)&x, sizeof x)) {
-			return (FALSE);
-		}
-		*int64_p = x;
-		return (TRUE);
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-
-/*
- * XDR unsigned 64-bit integers
- */
-bool_t
-xdr_u_int64_t(
-	XDR *xdrs,
-	u_int64_t *uint64_p)
-{
-	u_int64_t x;
-
-	switch (xdrs->x_op) {
-	case XDR_ENCODE:
-		return (xdr_opaque(xdrs, (caddr_t)uint64_p, sizeof(u_int64_t)));
-	case XDR_DECODE:
-		if (!xdr_opaque(xdrs, (caddr_t)&x, sizeof x)) {
-			return (FALSE);
-		}
-		*uint64_p = x;
-		return (TRUE);
-	case XDR_FREE:
-		return (TRUE);
-	}
-	/* NOTREACHED */
-	return (FALSE);
-}
-
-/* FIXME: RTEMS does not support u_longlong_t and longlong_t, yet */
-#if !defined(__rtems__)
-/*
- * XDR hypers
- */
-bool_t
-xdr_hyper(xdrs, llp)
-	XDR *xdrs;
-	longlong_t *llp;
-{
-
-	/*
-	 * Don't bother open-coding this; it's a fair amount of code.  Just
-	 * call xdr_int64_t().
-	 */
-	return (xdr_int64_t(xdrs, (int64_t *)llp));
-}
-
-
-/*
- * XDR unsigned hypers
- */
-bool_t
-xdr_u_hyper(xdrs, ullp)
-	XDR *xdrs;
-	u_longlong_t *ullp;
-{
-
-	/*
-	 * Don't bother open-coding this; it's a fair amount of code.  Just
-	 * call xdr_u_int64_t().
-	 */
-	return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));
-}
-
-
-/*
- * XDR longlong_t's
- */
-bool_t
-xdr_longlong_t(xdrs, llp)
-	XDR *xdrs;
-	longlong_t *llp;
-{
-
-	/*
-	 * Don't bother open-coding this; it's a fair amount of code.  Just
-	 * call xdr_int64_t().
-	 */
-	return (xdr_int64_t(xdrs, (int64_t *)llp));
-}
-
-
-/*
- * XDR u_longlong_t's
- */
-bool_t
-xdr_u_longlong_t(xdrs, ullp)
-	XDR *xdrs;
-	u_longlong_t *ullp;
-{
-
-	/*
-	 * Don't bother open-coding this; it's a fair amount of code.  Just
-	 * call xdr_u_int64_t().
-	 */
-	return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));
-}
-#endif
Index: rvices/librpc/src/xdr/xdr_array.c
===================================================================
--- services/librpc/src/xdr/xdr_array.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,160 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)xdr_array.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_array.c,v 1.8 1999/08/28 00:02:55 peter Exp $";
-#endif
-
-/*
- * xdr_array.c, Generic XDR routines impelmentation.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * These are the "non-trivial" xdr primitives used to serialize and de-serialize
- * arrays.  See xdr.h for more info on the interface to xdr.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-
-#define LASTUNSIGNED ((u_int) 0-1)
-
-/*
- * XDR an array of arbitrary elements
- * *addrp is a pointer to the array, *sizep is the number of elements.
- * If addrp is NULL (*sizep * elsize) bytes are allocated.
- * elsize is the size (in bytes) of each element, and elproc is the
- * xdr procedure to call to handle each element of the array.
- */
-bool_t
-xdr_array(
-	register XDR *xdrs,
-	caddr_t *addrp,		/* array pointer */
-	u_int *sizep,		/* number of elements */
-	u_int maxsize,		/* max numberof elements */
-	u_int elsize,		/* size in bytes of each element */
-	xdrproc_t elproc)	/* xdr routine to handle each element */
-{
-	register u_int i;
-	register caddr_t target = *addrp;
-	register u_int c;  /* the actual element count */
-	register bool_t stat = TRUE;
-	register u_int nodesize;
-
-	/* like strings, arrays are really counted arrays */
-	if (! xdr_u_int(xdrs, sizep)) {
-		return (FALSE);
-	}
-	c = *sizep;
-	if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) {
-		return (FALSE);
-	}
-	nodesize = c * elsize;
-
-	/*
-	 * if we are deserializing, we may need to allocate an array.
-	 * We also save time by checking for a null array if we are freeing.
-	 */
-	if (target == NULL)
-		switch (xdrs->x_op) {
-		case XDR_DECODE:
-			if (c == 0)
-				return (TRUE);
-			*addrp = target = mem_alloc(nodesize);
-			if (target == NULL) {
-				(void) fprintf(stderr,
-					"xdr_array: out of memory\n");
-				return (FALSE);
-			}
-			memset(target, 0, nodesize);
-			break;
-
-		case XDR_FREE:
-			return (TRUE);
-		case XDR_ENCODE:  /* to avoid warning */
-			break;
-	}
-
-	/*
-	 * now we xdr each element of array
-	 */
-	for (i = 0; (i < c) && stat; i++) {
-		stat = (*elproc)(xdrs, target, LASTUNSIGNED);
-		target += elsize;
-	}
-
-	/*
-	 * the array may need freeing
-	 */
-	if (xdrs->x_op == XDR_FREE) {
-		mem_free(*addrp, nodesize);
-		*addrp = NULL;
-	}
-	return (stat);
-}
-
-/*
- * xdr_vector():
- *
- * XDR a fixed length array. Unlike variable-length arrays,
- * the storage of fixed length arrays is static and unfreeable.
- * > basep: base of the array
- * > size: size of the array
- * > elemsize: size of each element
- * > xdr_elem: routine to XDR each element
- */
-bool_t
-xdr_vector(
-	register XDR *xdrs,
-	register char *basep,
-	register u_int nelem,
-	register u_int elemsize,
-	register xdrproc_t xdr_elem)
-{
-	register u_int i;
-	register char *elptr;
-
-	elptr = basep;
-	for (i = 0; i < nelem; i++) {
-		if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) {
-			return(FALSE);
-		}
-		elptr += elemsize;
-	}
-	return(TRUE);
-}
Index: rvices/librpc/src/xdr/xdr_float.c
===================================================================
--- services/librpc/src/xdr/xdr_float.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,343 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)xdr_float.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_float.c,v 1.7 1999/08/28 00:02:55 peter Exp $";
-#endif
-
-/*
- * xdr_float.c, Generic XDR routines impelmentation.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * These are the "floating point" xdr routines used to (de)serialize
- * most common data items.  See xdr.h for more info on the interface to
- * xdr.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-
-/*
- * NB: Not portable.
- * This routine works on machines with IEEE754 FP and Vaxen.
- */
-
-#if defined(__alpha__) || \
-    defined(_AM29K) || \
-    defined(__arm__) || \
-    defined(__H8300__) || defined(__h8300__) || \
-    defined(__hppa__) || \
-    defined(__i386__) || \
-    defined(__lm32__) || \
-    defined(__m68k__) || defined(__mc68000__) || \
-    defined(__mips__) || \
-    defined(__nios2__) || \
-    defined(__ns32k__) || \
-    defined(__sparc__) || \
-    defined(__ppc__) || defined(__PPC__) || \
-    defined(__sh__) || \
-    defined(__AVR__) || \
-    defined(__BFIN__) || \
-    defined(__m32c__) || \
-    defined(__M32R__) || \
-    defined(__v850)
-
-#include <rtems/endian.h>
-#if !defined(IEEEFP)
-#define IEEEFP
-#endif
-
-#elif defined(_TMS320C3x) || defined(_TMS320C4x)
-#error "Texas Instruments C3x/C4x Not supported."
-
-#elif defined(vax)
-
-/* What IEEE single precision floating point looks like on a Vax */
-struct	ieee_single {
-	unsigned int	mantissa: 23;
-	unsigned int	exp     : 8;
-	unsigned int	sign    : 1;
-};
-
-/* Vax single precision floating point */
-struct	vax_single {
-	unsigned int	mantissa1 : 7;
-	unsigned int	exp       : 8;
-	unsigned int	sign      : 1;
-	unsigned int	mantissa2 : 16;
-};
-
-#define VAX_SNG_BIAS	0x81
-#define IEEE_SNG_BIAS	0x7f
-
-static struct sgl_limits {
-	struct vax_single s;
-	struct ieee_single ieee;
-} sgl_limits[2] = {
-	{{ 0x7f, 0xff, 0x0, 0xffff },	/* Max Vax */
-	{ 0x0, 0xff, 0x0 }},		/* Max IEEE */
-	{{ 0x0, 0x0, 0x0, 0x0 },	/* Min Vax */
-	{ 0x0, 0x0, 0x0 }}		/* Min IEEE */
-};
-/* end of vax */
-#else
-#error "xdr_float.c: unknown CPU"
-#endif
-
-
-bool_t
-xdr_float(
-	register XDR *xdrs,
-	register float *fp)
-{
-#ifdef IEEEFP
-	bool_t rv;
-	long tmpl;
-#else
-	struct ieee_single is;
-	struct vax_single vs, *vsp;
-	struct sgl_limits *lim;
-	int i;
-#endif
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-#ifdef IEEEFP
-		tmpl = *(int32_t *)fp;
-		return (XDR_PUTLONG(xdrs, &tmpl));
-#else
-		vs = *((struct vax_single *)fp);
-		for (i = 0, lim = sgl_limits;
-			i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
-			i++, lim++) {
-			if ((vs.mantissa2 == lim->s.mantissa2) &&
-				(vs.exp == lim->s.exp) &&
-				(vs.mantissa1 == lim->s.mantissa1)) {
-				is = lim->ieee;
-				goto shipit;
-			}
-		}
-		is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
-		is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2;
-	shipit:
-		is.sign = vs.sign;
-		return (XDR_PUTLONG(xdrs, (long *)&is));
-#endif
-
-	case XDR_DECODE:
-#ifdef IEEEFP
-		rv = XDR_GETLONG(xdrs, &tmpl);
-		*(int32_t *)fp = tmpl;
-		return (rv);
-#else
-		vsp = (struct vax_single *)fp;
-		if (!XDR_GETLONG(xdrs, (long *)&is))
-			return (FALSE);
-		for (i = 0, lim = sgl_limits;
-			i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
-			i++, lim++) {
-			if ((is.exp == lim->ieee.exp) &&
-				(is.mantissa == lim->ieee.mantissa)) {
-				*vsp = lim->s;
-				goto doneit;
-			}
-		}
-		vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
-		vsp->mantissa2 = is.mantissa;
-		vsp->mantissa1 = (is.mantissa >> 16);
-	doneit:
-		vsp->sign = is.sign;
-		return (TRUE);
-#endif
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	return (FALSE);
-}
-
-#ifdef vax
-/* What IEEE double precision floating point looks like on a Vax */
-struct	ieee_double {
-	unsigned int	mantissa1 : 20;
-	unsigned int	exp       : 11;
-	unsigned int	sign      : 1;
-	unsigned int	mantissa2 : 32;
-};
-
-/* Vax double precision floating point */
-struct  vax_double {
-	unsigned int	mantissa1 : 7;
-	unsigned int	exp       : 8;
-	unsigned int	sign      : 1;
-	unsigned int	mantissa2 : 16;
-	unsigned int	mantissa3 : 16;
-	unsigned int	mantissa4 : 16;
-};
-
-#define VAX_DBL_BIAS	0x81
-#define IEEE_DBL_BIAS	0x3ff
-#define MASK(nbits)	((1 << nbits) - 1)
-
-static struct dbl_limits {
-	struct	vax_double d;
-	struct	ieee_double ieee;
-} dbl_limits[2] = {
-	{{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff },	/* Max Vax */
-	{ 0x0, 0x7ff, 0x0, 0x0 }},			/* Max IEEE */
-	{{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},		/* Min Vax */
-	{ 0x0, 0x0, 0x0, 0x0 }}				/* Min IEEE */
-};
-
-#endif /* vax */
-
-
-bool_t
-xdr_double(
-	register XDR *xdrs,
-	double *dp)
-{
-#ifdef IEEEFP
-	register int32_t *i32p;
-	bool_t rv;
-	long tmpl;
-#else
-	register long *lp;
-	struct	ieee_double id;
-	struct	vax_double vd;
-	register struct dbl_limits *lim;
-	int i;
-#endif
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-#ifdef IEEEFP
-		i32p = (int32_t *)dp;
-#if BYTE_ORDER == BIG_ENDIAN
-		tmpl = *i32p++;
-		rv = XDR_PUTLONG(xdrs, &tmpl);
-		if (!rv)
-			return (rv);
-		tmpl = *i32p;
-		rv = XDR_PUTLONG(xdrs, &tmpl);
-#else
-		tmpl = *(i32p+1);
-		rv = XDR_PUTLONG(xdrs, &tmpl);
-		if (!rv)
-			return (rv);
-		tmpl = *i32p;
-		rv = XDR_PUTLONG(xdrs, &tmpl);
-#endif
-		return (rv);
-#else
-		vd = *((struct vax_double *)dp);
-		for (i = 0, lim = dbl_limits;
-			i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
-			i++, lim++) {
-			if ((vd.mantissa4 == lim->d.mantissa4) &&
-				(vd.mantissa3 == lim->d.mantissa3) &&
-				(vd.mantissa2 == lim->d.mantissa2) &&
-				(vd.mantissa1 == lim->d.mantissa1) &&
-				(vd.exp == lim->d.exp)) {
-				id = lim->ieee;
-				goto shipit;
-			}
-		}
-		id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
-		id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3);
-		id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) |
-				(vd.mantissa3 << 13) |
-				((vd.mantissa4 >> 3) & MASK(13));
-	shipit:
-		id.sign = vd.sign;
-		lp = (long *)&id;
-		return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp));
-#endif
-
-	case XDR_DECODE:
-#ifdef IEEEFP
-		i32p = (int32_t *)dp;
-#if BYTE_ORDER == BIG_ENDIAN
-		rv = XDR_GETLONG(xdrs, &tmpl);
-		*i32p++ = tmpl;
-		if (!rv)
-			return (rv);
-		rv = XDR_GETLONG(xdrs, &tmpl);
-		*i32p = tmpl;
-#else
-		rv = XDR_GETLONG(xdrs, &tmpl);
-		*(i32p+1) = tmpl;
-		if (!rv)
-			return (rv);
-		rv = XDR_GETLONG(xdrs, &tmpl);
-		*i32p = tmpl;
-#endif
-		return (rv);
-#else
-		lp = (long *)&id;
-		if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp))
-			return (FALSE);
-		for (i = 0, lim = dbl_limits;
-			i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
-			i++, lim++) {
-			if ((id.mantissa2 == lim->ieee.mantissa2) &&
-				(id.mantissa1 == lim->ieee.mantissa1) &&
-				(id.exp == lim->ieee.exp)) {
-				vd = lim->d;
-				goto doneit;
-			}
-		}
-		vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
-		vd.mantissa1 = (id.mantissa1 >> 13);
-		vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) |
-				(id.mantissa2 >> 29);
-		vd.mantissa3 = (id.mantissa2 >> 13);
-		vd.mantissa4 = (id.mantissa2 << 3);
-	doneit:
-		vd.sign = id.sign;
-		*dp = *((double *)&vd);
-		return (TRUE);
-#endif
-
-	case XDR_FREE:
-		return (TRUE);
-	}
-	return (FALSE);
-}
Index: rvices/librpc/src/xdr/xdr_mem.c
===================================================================
--- services/librpc/src/xdr/xdr_mem.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,245 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)xdr_mem.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_mem.c,v 1.8 1999/08/28 00:02:56 peter Exp $";
-#endif
-
-/*
- * xdr_mem.h, XDR implementation using memory buffers.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * If you have some data to be interpreted as external data representation
- * or to be converted to external data representation in a memory buffer,
- * then this is the package for you.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <netinet/in.h>
-
-static bool_t	xdrmem_getlong_aligned(XDR *xdrs, long *lp);
-static bool_t	xdrmem_putlong_aligned(XDR *xdrs, const long *lp);
-static bool_t	xdrmem_getlong_unaligned(XDR *xdrs, long *lp);
-static bool_t	xdrmem_putlong_unaligned(XDR *xdrs, const long *lp);
-static bool_t	xdrmem_getbytes(XDR *xdrs, caddr_t addr, u_int len);
-static bool_t	xdrmem_putbytes(XDR *xdrs, const char *addr, u_int len);
-static u_int	xdrmem_getpos(XDR *xdrs); /* XXX w/64-bit pointers, u_int not enough! */
-static bool_t	xdrmem_setpos(XDR *xdrs, u_int pos);
-static int32_t *xdrmem_inline_aligned(XDR *xdrs, u_int len);
-static int32_t *xdrmem_inline_unaligned(XDR *xdrs, u_int len);
-static void	xdrmem_destroy(XDR *);
-
-static struct	xdr_ops xdrmem_ops_aligned = {
-	xdrmem_getlong_aligned,
-	xdrmem_putlong_aligned,
-	xdrmem_getbytes,
-	xdrmem_putbytes,
-	xdrmem_getpos,
-	xdrmem_setpos,
-	xdrmem_inline_aligned,
-	xdrmem_destroy
-};
-
-static struct	xdr_ops xdrmem_ops_unaligned = {
-	xdrmem_getlong_unaligned,
-	xdrmem_putlong_unaligned,
-	xdrmem_getbytes,
-	xdrmem_putbytes,
-	xdrmem_getpos,
-	xdrmem_setpos,
-	xdrmem_inline_unaligned,
-	xdrmem_destroy
-};
-
-/*
- * The procedure xdrmem_create initializes a stream descriptor for a
- * memory buffer.
- */
-void
-xdrmem_create(
-	XDR *xdrs,
-	char * addr,
-	u_int size,
-	enum xdr_op op)
-{
-
-	xdrs->x_op = op;
-	xdrs->x_ops = ((uintptr_t)addr & (sizeof(int32_t) - 1))
-		? &xdrmem_ops_unaligned : &xdrmem_ops_aligned;
-	xdrs->x_private = xdrs->x_base = addr;
-	xdrs->x_handy = size;
-}
-
-static void
-xdrmem_destroy(XDR *xdrs)
-{
-
-}
-
-static bool_t
-xdrmem_getlong_aligned(
-	XDR *xdrs,
-	long *lp)
-{
-
-	if ((xdrs->x_handy -= sizeof(int32_t)) < 0)
-		return (FALSE);
-	*lp = ntohl(*(int32_t *)(xdrs->x_private));
-	xdrs->x_private += sizeof(int32_t);
-	return (TRUE);
-}
-
-static bool_t
-xdrmem_putlong_aligned(
-	XDR *xdrs,
-	const long *lp)
-{
-
-	if ((xdrs->x_handy -= sizeof(int32_t)) < 0)
-		return (FALSE);
-	*(int32_t *)xdrs->x_private = htonl(*lp);
-	xdrs->x_private += sizeof(int32_t);
-	return (TRUE);
-}
-
-static bool_t
-xdrmem_getlong_unaligned(
-	XDR *xdrs,
-	long *lp)
-{
-	int32_t l;
-
-	if ((xdrs->x_handy -= sizeof(int32_t)) < 0)
-		return (FALSE);
-	memcpy(&l, xdrs->x_private, sizeof(int32_t));
-	*lp = ntohl(l);
-	xdrs->x_private += sizeof(int32_t);
-	return (TRUE);
-}
-
-static bool_t
-xdrmem_putlong_unaligned(
-	XDR *xdrs,
-	const long *lp)
-{
-	int32_t l;
-
-	if ((xdrs->x_handy -= sizeof(int32_t)) < 0)
-		return (FALSE);
-	l = htonl(*lp);
-	memcpy(xdrs->x_private, &l, sizeof(int32_t));
-	xdrs->x_private += sizeof(int32_t);
-	return (TRUE);
-}
-
-static bool_t
-xdrmem_getbytes(
-	XDR *xdrs,
-	caddr_t addr,
-	u_int len)
-{
-
-	if ((xdrs->x_handy -= len) < 0)
-		return (FALSE);
-	memcpy(addr, xdrs->x_private, len);
-	xdrs->x_private += len;
-	return (TRUE);
-}
-
-static bool_t
-xdrmem_putbytes(
-	XDR *xdrs,
-	const char *addr,
-	u_int len)
-{
-
-	if ((xdrs->x_handy -= len) < 0)
-		return (FALSE);
-	memcpy(xdrs->x_private, addr, len);
-	xdrs->x_private += len;
-	return (TRUE);
-}
-
-static u_int
-xdrmem_getpos(
-	XDR *xdrs)
-{
-
-	/* XXX w/64-bit pointers, u_int not enough! */
-	return ((uintptr_t)xdrs->x_private - (uintptr_t)xdrs->x_base);
-}
-
-static bool_t
-xdrmem_setpos(
-	XDR *xdrs,
-	u_int pos)
-{
-	void *newaddr = xdrs->x_base + pos;
-	void *lastaddr = xdrs->x_private + xdrs->x_handy;
-
-	if (newaddr > lastaddr)
-		return (FALSE);
-	xdrs->x_private = newaddr;
-	xdrs->x_handy = (intptr_t)lastaddr - (intptr_t)newaddr;
-	return (TRUE);
-}
-
-static int32_t *
-xdrmem_inline_aligned(
-	XDR *xdrs,
-	u_int len)
-{
-	int32_t *buf = 0;
-
-	if (xdrs->x_handy >= len) {
-		xdrs->x_handy -= len;
-		buf = (int32_t *)xdrs->x_private;
-		xdrs->x_private += len;
-	}
-	return (buf);
-}
-
-static int32_t *
-xdrmem_inline_unaligned(
-	XDR *xdrs,
-	u_int len)
-{
-	
-	return (0);
-}
Index: rvices/librpc/src/xdr/xdr_rec.c
===================================================================
--- services/librpc/src/xdr/xdr_rec.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,608 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)xdr_rec.c	2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_rec.c,v 1.12 2000/01/19 06:12:32 wpaul Exp $";
-#endif
-
-/*
- * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking"
- * layer above tcp (for rpc's use).
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * These routines interface XDRSTREAMS to a tcp/ip connection.
- * There is a record marking layer between the xdr stream
- * and the tcp transport level.  A record is composed on one or more
- * record fragments.  A record fragment is a thirty-two bit header followed
- * by n bytes of data, where n is contained in the header.  The header
- * is represented as a htonl(u_long).  Thegh order bit encodes
- * whether or not the fragment is the last fragment of the record
- * (1 => fragment is last, 0 => more fragments to follow.
- * The other 31 bits encode the byte length of the fragment.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <netinet/in.h>
-#include <unistd.h>   /* for lseek() */
-
-typedef struct rec_strm RECSTREAM;
-
-static u_int	fix_buf_size(u_int);
-static bool_t	flush_out(RECSTREAM *rstrm, bool_t eor);
-static bool_t	get_input_bytes(RECSTREAM *rstrm, caddr_t addr, int len);
-static bool_t	set_input_fragment(RECSTREAM *rstrm);
-static bool_t	skip_input_bytes(RECSTREAM *rstrm, long cnt);
-
-static bool_t	xdrrec_getlong(XDR *xdrs, long *lp);
-static bool_t	xdrrec_putlong(XDR *xdrs, const long *lp);
-static bool_t	xdrrec_getbytes(XDR *xdrs, caddr_t addr, u_int len);
-static bool_t	xdrrec_putbytes(XDR *xdrs, const char *addr, u_int len);
-static u_int	xdrrec_getpos(XDR *xdrs);
-static bool_t	xdrrec_setpos(XDR *xdrs, u_int pos);
-static int32_t *xdrrec_inline(XDR *xdrs, u_int len);
-static void	xdrrec_destroy(XDR *xdrs);
-
-static struct  xdr_ops xdrrec_ops = {
-	xdrrec_getlong,
-	xdrrec_putlong,
-	xdrrec_getbytes,
-	xdrrec_putbytes,
-	xdrrec_getpos,
-	xdrrec_setpos,
-	xdrrec_inline,
-	xdrrec_destroy
-};
-
-/*
- * A record is composed of one or more record fragments.
- * A record fragment is a two-byte header followed by zero to
- * 2**32-1 bytes.  The header is treated as a long unsigned and is
- * encode/decoded to the network via htonl/ntohl.  The low order 31 bits
- * are a byte count of the fragment.  The highest order bit is a boolean:
- * 1 => this fragment is the last fragment of the record,
- * 0 => this fragment is followed by more fragment(s).
- *
- * The fragment/record machinery is not general;  it is constructed to
- * meet the needs of xdr and rpc based on tcp.
- */
-
-#define LAST_FRAG ((u_int32_t)(1L << 31))
-
-struct rec_strm {
-	caddr_t tcp_handle;
-	caddr_t the_buffer;
-	/*
-	 * out-goung bits
-	 */
-	int (*writeit) (caddr_t, caddr_t, int);
-	caddr_t out_base;	/* output buffer (points to frag header) */
-	caddr_t out_finger;	/* next output position */
-	caddr_t out_boundry;	/* data cannot up to this address */
-	u_int32_t *frag_header;	/* beginning of current fragment */
-	bool_t frag_sent;	/* true if buffer sent in middle of record */
-	/*
-	 * in-coming bits
-	 */
-	int (*readit) (caddr_t, caddr_t, int);
-	u_long in_size;	/* fixed size of the input buffer */
-	caddr_t in_base;
-	caddr_t in_finger;	/* location of next byte to be had */
-	caddr_t in_boundry;	/* can read up to this location */
-	long fbtbc;		/* fragment bytes to be consumed */
-	bool_t last_frag;
-	u_int sendsize;
-	u_int recvsize;
-};
-
-
-/*
- * Create an xdr handle for xdrrec
- * xdrrec_create fills in xdrs.  Sendsize and recvsize are
- * send and recv buffer sizes (0 => use default).
- * tcp_handle is an opaque handle that is passed as the first parameter to
- * the procedures readit and writeit.  Readit and writeit are read and
- * write respectively.   They are like the system
- * calls expect that they take an opaque handle rather than an fd.
- */
-void
-xdrrec_create(
-	XDR *xdrs,
-	u_int sendsize,
-	u_int recvsize,
-	void *tcp_handle,
-	int (*readit)(void*, void*, int),  /* like read, but pass it a tcp_handle, not sock */
-	int (*writeit)(void*, void*, int)  /* like write, but pass it a tcp_handle, not sock */
-)
-{
-	RECSTREAM *rstrm =
-		(RECSTREAM *)mem_alloc(sizeof(RECSTREAM));
-
-	if (rstrm == NULL) {
-		(void)fprintf(stderr, "xdrrec_create: out of memory\n");
-		/*
-		 *  This is bad.  Should rework xdrrec_create to
-		 *  return a handle, and in this case return NULL
-		 */
-		return;
-	}
-	/*
-	 * adjust sizes and allocate buffer quad byte aligned
-	 */
-	rstrm->sendsize = sendsize = fix_buf_size(sendsize);
-	rstrm->recvsize = recvsize = fix_buf_size(recvsize);
-	rstrm->the_buffer = mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT);
-	if (rstrm->the_buffer == NULL) {
-		(void)fprintf(stderr, "xdrrec_create: out of memory\n");
-		return;
-	}
-	for (rstrm->out_base = rstrm->the_buffer;
-		(uintptr_t)rstrm->out_base % BYTES_PER_XDR_UNIT != 0;
-		rstrm->out_base++);
-	rstrm->in_base = rstrm->out_base + sendsize;
-	/*
-	 * now the rest ...
-	 */
-	xdrs->x_ops = &xdrrec_ops;
-	xdrs->x_private = (caddr_t)rstrm;
-	rstrm->tcp_handle = tcp_handle;
-	rstrm->readit = readit;
-	rstrm->writeit = writeit;
-	rstrm->out_finger = rstrm->out_boundry = rstrm->out_base;
-	rstrm->frag_header = (u_int32_t *)rstrm->out_base;
-	rstrm->out_finger += sizeof(u_int32_t);
-	rstrm->out_boundry += sendsize;
-	rstrm->frag_sent = FALSE;
-	rstrm->in_size = recvsize;
-	rstrm->in_boundry = rstrm->in_base;
-	rstrm->in_finger = (rstrm->in_boundry += recvsize);
-	rstrm->fbtbc = 0;
-	rstrm->last_frag = TRUE;
-}
-
-
-/*
- * The reoutines defined below are the xdr ops which will go into the
- * xdr handle filled in by xdrrec_create.
- */
-
-static bool_t
-xdrrec_getlong(
-	XDR *xdrs,
-	long *lp)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
-	int32_t *buflp = (int32_t *)(rstrm->in_finger);
-	int32_t mylong;
-
-	/* first try the inline, fast case */
-	if ((rstrm->fbtbc >= sizeof(int32_t)) &&
-		(((intptr_t)rstrm->in_boundry - (intptr_t)buflp) >= sizeof(int32_t))) {
-		*lp = (long)ntohl((u_int32_t)(*buflp));
-		rstrm->fbtbc -= sizeof(int32_t);
-		rstrm->in_finger += sizeof(int32_t);
-	} else {
-		if (! xdrrec_getbytes(xdrs, (caddr_t)&mylong, sizeof(int32_t)))
-			return (FALSE);
-		*lp = (long)ntohl((u_int32_t)mylong);
-	}
-	return (TRUE);
-}
-
-static bool_t
-xdrrec_putlong(
-	XDR *xdrs,
-	const long *lp)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
-	int32_t *dest_lp = ((int32_t *)(rstrm->out_finger));
-
-	if ((rstrm->out_finger += sizeof(int32_t)) > rstrm->out_boundry) {
-		/*
-		 * this case should almost never happen so the code is
-		 * inefficient
-		 */
-		rstrm->out_finger -= sizeof(int32_t);
-		rstrm->frag_sent = TRUE;
-		if (! flush_out(rstrm, FALSE))
-			return (FALSE);
-		dest_lp = ((int32_t *)(rstrm->out_finger));
-		rstrm->out_finger += sizeof(int32_t);
-	}
-	*dest_lp = (int32_t)htonl((u_int32_t)(*lp));
-	return (TRUE);
-}
-
-static bool_t  /* must manage buffers, fragments, and records */
-xdrrec_getbytes(
-	XDR *xdrs,
-	caddr_t addr,
-	u_int len)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
-	int current;
-
-	while (len > 0) {
-		current = rstrm->fbtbc;
-		if (current == 0) {
-			if (rstrm->last_frag)
-				return (FALSE);
-			if (! set_input_fragment(rstrm))
-				return (FALSE);
-			continue;
-		}
-		current = (len < current) ? len : current;
-		if (! get_input_bytes(rstrm, addr, current))
-			return (FALSE);
-		addr += current;
-		rstrm->fbtbc -= current;
-		len -= current;
-	}
-	return (TRUE);
-}
-
-static bool_t
-xdrrec_putbytes(
-	XDR *xdrs,
-	const char *addr,
-	u_int len)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
-	long current;
-
-	while (len > 0) {
-		current = (intptr_t)rstrm->out_boundry -
-			(intptr_t)rstrm->out_finger;
-		current = (len < current) ? len : current;
-		memcpy(rstrm->out_finger, addr, current);
-		rstrm->out_finger += current;
-		addr += current;
-		len -= current;
-		if (rstrm->out_finger == rstrm->out_boundry) {
-			rstrm->frag_sent = TRUE;
-			if (! flush_out(rstrm, FALSE))
-				return (FALSE);
-		}
-	}
-	return (TRUE);
-}
-
-static u_int
-xdrrec_getpos(
-	XDR *xdrs)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
-	long pos;
-
-	pos = lseek((intptr_t)rstrm->tcp_handle, (off_t) 0, 1);
-	if (pos != -1)
-		switch (xdrs->x_op) {
-
-		case XDR_ENCODE:
-			pos += rstrm->out_finger - rstrm->out_base;
-			break;
-
-		case XDR_DECODE:
-			pos -= rstrm->in_boundry - rstrm->in_finger;
-			break;
-
-		default:
-			pos = -1;
-			break;
-		}
-	return ((u_int) pos);
-}
-
-static bool_t
-xdrrec_setpos(
-	XDR *xdrs,
-	u_int pos)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
-	u_int currpos = xdrrec_getpos(xdrs);
-	int delta = currpos - pos;
-	caddr_t newpos;
-
-	if ((int)currpos != -1)
-		switch (xdrs->x_op) {
-
-		case XDR_ENCODE:
-			newpos = rstrm->out_finger - delta;
-			if ((newpos > (caddr_t)(rstrm->frag_header)) &&
-				(newpos < rstrm->out_boundry)) {
-				rstrm->out_finger = newpos;
-				return (TRUE);
-			}
-			break;
-
-		case XDR_DECODE:
-			newpos = rstrm->in_finger - delta;
-			if ((delta < (int)(rstrm->fbtbc)) &&
-				(newpos <= rstrm->in_boundry) &&
-				(newpos >= rstrm->in_base)) {
-				rstrm->in_finger = newpos;
-				rstrm->fbtbc -= delta;
-				return (TRUE);
-			}
-			break;
-		case XDR_FREE:  /* to avoid warning */
-			break;
-		}
-	return (FALSE);
-}
-
-static int32_t *
-xdrrec_inline(
-	XDR *xdrs,
-	u_int len)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
-	int32_t * buf = NULL;
-
-	switch (xdrs->x_op) {
-
-	case XDR_ENCODE:
-		if ((rstrm->out_finger + len) <= rstrm->out_boundry) {
-			buf = (int32_t *) rstrm->out_finger;
-			rstrm->out_finger += len;
-		}
-		break;
-
-	case XDR_DECODE:
-		if ((len <= rstrm->fbtbc) &&
-			((rstrm->in_finger + len) <= rstrm->in_boundry)) {
-			buf = (int32_t *) rstrm->in_finger;
-			rstrm->fbtbc -= len;
-			rstrm->in_finger += len;
-		}
-		break;
-	case XDR_FREE:  /* to avoid warning */
-		break;
-	}
-	return (buf);
-}
-
-static void
-xdrrec_destroy(
-	XDR *xdrs)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
-
-	mem_free(rstrm->the_buffer,
-		rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT);
-	mem_free((caddr_t)rstrm, sizeof(RECSTREAM));
-}
-
-
-/*
- * Exported routines to manage xdr records
- */
-
-/*
- * Before reading (deserializing from the stream, one should always call
- * this procedure to guarantee proper record alignment.
- */
-bool_t
-xdrrec_skiprecord(
-	XDR *xdrs)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
-
-	while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
-		if (! skip_input_bytes(rstrm, rstrm->fbtbc))
-			return (FALSE);
-		rstrm->fbtbc = 0;
-		if ((! rstrm->last_frag) && (! set_input_fragment(rstrm)))
-			return (FALSE);
-	}
-	rstrm->last_frag = FALSE;
-	return (TRUE);
-}
-
-/*
- * Look ahead fuction.
- * Returns TRUE iff there is no more input in the buffer
- * after consuming the rest of the current record.
- */
-bool_t
-xdrrec_eof(
-	XDR *xdrs)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
-
-	while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
-		if (! skip_input_bytes(rstrm, rstrm->fbtbc))
-			return (TRUE);
-		rstrm->fbtbc = 0;
-		if ((! rstrm->last_frag) && (! set_input_fragment(rstrm)))
-			return (TRUE);
-	}
-	if (rstrm->in_finger == rstrm->in_boundry)
-		return (TRUE);
-	return (FALSE);
-}
-
-/*
- * The client must tell the package when an end-of-record has occurred.
- * The second paraemters tells whether the record should be flushed to the
- * (output) tcp stream.  (This let's the package support batched or
- * pipelined procedure calls.)  TRUE => immmediate flush to tcp connection.
- */
-bool_t
-xdrrec_endofrecord(
-	XDR *xdrs,
-	int sendnow)
-{
-	RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
-	u_long len;  /* fragment length */
-
-	if (sendnow || rstrm->frag_sent ||
-		((uintptr_t)rstrm->out_finger + sizeof(u_int32_t) >=
-		(uintptr_t)rstrm->out_boundry)) {
-		rstrm->frag_sent = FALSE;
-		return (flush_out(rstrm, TRUE));
-	}
-	len = (uintptr_t)(rstrm->out_finger) - (uintptr_t)(rstrm->frag_header) -
-	   sizeof(u_int32_t);
-	*(rstrm->frag_header) = htonl((u_int32_t)len | LAST_FRAG);
-	rstrm->frag_header = (u_int32_t *)rstrm->out_finger;
-	rstrm->out_finger += sizeof(u_int32_t);
-	return (TRUE);
-}
-
-
-/*
- * Internal useful routines
- */
-static bool_t
-flush_out(
-	RECSTREAM *rstrm,
-	bool_t eor)
-{
-	u_int32_t eormask = (eor == TRUE) ? LAST_FRAG : 0;
-	u_int32_t len = (uintptr_t)(rstrm->out_finger) -
-		(uintptr_t)(rstrm->frag_header) - sizeof(u_int32_t);
-
-	*(rstrm->frag_header) = htonl(len | eormask);
-	len = (uintptr_t)(rstrm->out_finger) - (uintptr_t)(rstrm->out_base);
-	if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len)
-		!= (int)len)
-		return (FALSE);
-	rstrm->frag_header = (u_int32_t *)rstrm->out_base;
-	rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof(u_int32_t);
-	return (TRUE);
-}
-
-static bool_t  /* knows nothing about records!  Only about input buffers */
-fill_input_buf(
-	RECSTREAM *rstrm)
-{
-	caddr_t where;
-	u_long i;
-	long len;
-
-	where = rstrm->in_base;
-	i = (uintptr_t)rstrm->in_boundry % BYTES_PER_XDR_UNIT;
-	where += i;
-	len = rstrm->in_size - i;
-	if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1)
-		return (FALSE);
-	rstrm->in_finger = where;
-	where += len;
-	rstrm->in_boundry = where;
-	return (TRUE);
-}
-
-static bool_t  /* knows nothing about records!  Only about input buffers */
-get_input_bytes(
-	RECSTREAM *rstrm,
-	caddr_t addr,
-	int len)
-{
-	long current;
-
-	while (len > 0) {
-		current = (intptr_t)rstrm->in_boundry - (intptr_t)rstrm->in_finger;
-		if (current == 0) {
-			if (! fill_input_buf(rstrm))
-				return (FALSE);
-			continue;
-		}
-		current = (len < current) ? len : current;
-		memcpy(addr, rstrm->in_finger, current);
-		rstrm->in_finger += current;
-		addr += current;
-		len -= current;
-	}
-	return (TRUE);
-}
-
-static bool_t  /* next two bytes of the input stream are treated as a header */
-set_input_fragment(
-	RECSTREAM *rstrm)
-{
-	u_int32_t header;
-
-	if (! get_input_bytes(rstrm, (caddr_t)&header, sizeof(header)))
-		return (FALSE);
-	header = (long)ntohl(header);
-	rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE;
-	/*
-	 * Sanity check. Try not to accept wildly incorrect
-	 * record sizes. Unfortunately, the only record size
-	 * we can positively identify as being 'wildly incorrect'
-	 * is zero. Ridiculously large record sizes may look wrong,
-	 * but we don't have any way to be certain that they aren't
-	 * what the client actually intended to send us.
-	 */
-	if (header == 0)
-		return(FALSE);
-	rstrm->fbtbc = header & (~LAST_FRAG);
-	return (TRUE);
-}
-
-static bool_t  /* consumes input bytes; knows nothing about records! */
-skip_input_bytes(
-	RECSTREAM *rstrm,
-	long cnt)
-{
-	long current;
-
-	while (cnt > 0) {
-		current = (intptr_t)rstrm->in_boundry - (intptr_t)rstrm->in_finger;
-		if (current == 0) {
-			if (! fill_input_buf(rstrm))
-				return (FALSE);
-			continue;
-		}
-		current = (cnt < current) ? cnt : current;
-		rstrm->in_finger += current;
-		cnt -= current;
-	}
-	return (TRUE);
-}
-
-static u_int
-fix_buf_size(
-	u_int s)
-{
-
-	if (s < 100)
-		s = 4000;
-	return (RNDUP(s));
-}
Index: rvices/librpc/src/xdr/xdr_reference.c
===================================================================
--- services/librpc/src/xdr/xdr_reference.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,142 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)xdr_reference.c 1.11 87/08/11 SMI";*/
-/*static char *sccsid = "from: @(#)xdr_reference.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_reference.c,v 1.8 1999/08/28 00:02:56 peter Exp $";
-#endif
-
-/*
- * xdr_reference.c, Generic XDR routines impelmentation.
- *
- * Copyright (C) 1987, Sun Microsystems, Inc.
- *
- * These are the "non-trivial" xdr primitives used to serialize and de-serialize
- * "pointers".  See xdr.h for more info on the interface to xdr.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-
-#define LASTUNSIGNED ((u_int) 0-1)
-
-/*
- * XDR an indirect pointer
- * xdr_reference is for recursively translating a structure that is
- * referenced by a pointer inside the structure that is currently being
- * translated.  pp references a pointer to storage. If *pp is null
- * the  necessary storage is allocated.
- * size is the sizeof the referneced structure.
- * proc is the routine to handle the referenced structure.
- */
-bool_t
-xdr_reference(
-	register XDR *xdrs,
-	caddr_t *pp,		/* the pointer to work on */
-	u_int size,		/* size of the object pointed to */
-	xdrproc_t proc)		/* xdr routine to handle the object */
-{
-	register caddr_t loc = *pp;
-	register bool_t stat;
-
-	if (loc == NULL)
-		switch (xdrs->x_op) {
-		case XDR_FREE:
-			return (TRUE);
-
-		case XDR_DECODE:
-			*pp = loc = (caddr_t) mem_alloc(size);
-			if (loc == NULL) {
-				(void) fprintf(stderr,
-				    "xdr_reference: out of memory\n");
-				return (FALSE);
-			}
-			memset(loc, 0, (int)size);
-			break;
-		case XDR_ENCODE:  /* to avoid warning */
-			break;
-	}
-
-	stat = (*proc)(xdrs, loc, LASTUNSIGNED);
-
-	if (xdrs->x_op == XDR_FREE) {
-		mem_free(loc, size);
-		*pp = NULL;
-	}
-	return (stat);
-}
-
-
-/*
- * xdr_pointer():
- *
- * XDR a pointer to a possibly recursive data structure. This
- * differs with xdr_reference in that it can serialize/deserialiaze
- * trees correctly.
- *
- *  What's sent is actually a union:
- *
- *  union object_pointer switch (boolean b) {
- *  case TRUE: object_data data;
- *  case FALSE: void nothing;
- *  }
- *
- * > objpp: Pointer to the pointer to the object.
- * > obj_size: size of the object.
- * > xdr_obj: routine to XDR an object.
- *
- */
-bool_t
-xdr_pointer(
-	register XDR *xdrs,
-	char **objpp,
-	u_int obj_size,
-	xdrproc_t xdr_obj)
-{
-
-	bool_t more_data;
-
-	more_data = (*objpp != NULL);
-	if (! xdr_bool(xdrs,&more_data)) {
-		return (FALSE);
-	}
-	if (! more_data) {
-		*objpp = NULL;
-		return (TRUE);
-	}
-	return (xdr_reference(xdrs,objpp,obj_size,xdr_obj));
-}
Index: rvices/librpc/src/xdr/xdr_sizeof.c
===================================================================
--- services/librpc/src/xdr/xdr_sizeof.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,167 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-/*
- * xdr_sizeof.c
- *
- * Copyright 1990 Sun Microsystems, Inc.
- *
- * General purpose routine to see how much space something will use
- * when serialized using XDR.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <sys/types.h>
-#include <stdlib.h>
-
-/* ARGSUSED */
-static bool_t
-x_putlong(
-	XDR *xdrs,
-	const long *longp)
-{
-	xdrs->x_handy += BYTES_PER_XDR_UNIT;
-	return (TRUE);
-}
-
-/* ARGSUSED */
-static bool_t
-x_putbytes(
-	XDR *xdrs,
-	const char  *bp,
-	u_int len)
-{
-	xdrs->x_handy += len;
-	return (TRUE);
-}
-
-static u_int
-x_getpostn(
-	XDR *xdrs)
-{
-	return (xdrs->x_handy);
-}
-
-/* ARGSUSED */
-static bool_t
-x_setpostn(
-	XDR *xdrs,
-	u_int pos)
-{
-	/* This is not allowed */
-	return (FALSE);
-}
-
-static int32_t *
-x_inline(
-	XDR *xdrs,
-	u_int len)
-{
-	if (len == 0) {
-		return (NULL);
-	}
-	if (xdrs->x_op != XDR_ENCODE) {
-		return (NULL);
-	}
-	if (len < (intptr_t) xdrs->x_base) {
-		/* x_private was already allocated */
-		xdrs->x_handy += len;
-		return ((int32_t *) xdrs->x_private);
-	} else {
-		/* Free the earlier space and allocate new area */
-		if (xdrs->x_private)
-			free(xdrs->x_private);
-		if ((xdrs->x_private = (caddr_t) malloc(len)) == NULL) {
-			xdrs->x_base = 0;
-			return (NULL);
-		}
-		xdrs->x_base = (caddr_t)((intptr_t) len);
-		xdrs->x_handy += len;
-		return ((int32_t *) xdrs->x_private);
-	}
-}
-
-static int
-harmless(void)
-{
-	/* Always return FALSE/NULL, as the case may be */
-	return (0);
-}
-
-static void
-x_destroy(
-	XDR *xdrs)
-{
-	xdrs->x_handy = 0;
-	xdrs->x_base = 0;
-	if (xdrs->x_private) {
-		free(xdrs->x_private);
-		xdrs->x_private = NULL;
-	}
-	return;
-}
-
-unsigned long
-xdr_sizeof(
-	xdrproc_t func,
-	void *data)
-{
-	XDR x;
-	struct xdr_ops ops;
-	bool_t stat;
-	/* to stop ANSI-C compiler from complaining */
-	typedef  bool_t (* dummyfunc1)(XDR *, long *);
-	typedef  bool_t (* dummyfunc2)(XDR *, caddr_t, u_int);
-
-	ops.x_putlong = x_putlong;
-	ops.x_putbytes = x_putbytes;
-	ops.x_inline = x_inline;
-	ops.x_getpostn = x_getpostn;
-	ops.x_setpostn = x_setpostn;
-	ops.x_destroy = x_destroy;
-
-	/* the other harmless ones */
-	ops.x_getlong =  (dummyfunc1) harmless;
-	ops.x_getbytes = (dummyfunc2) harmless;
-
-	x.x_op = XDR_ENCODE;
-	x.x_ops = &ops;
-	x.x_handy = 0;
-	x.x_private = (caddr_t) NULL;
-	x.x_base = (caddr_t) 0;
-
-	stat = func(&x, data);
-	if (x.x_private)
-		free(x.x_private);
-	return (stat == TRUE ? (unsigned) x.x_handy: 0);
-}
Index: rvices/librpc/src/xdr/xdr_stdio.c
===================================================================
--- services/librpc/src/xdr/xdr_stdio.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,194 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)xdr_stdio.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_stdio.c,v 1.7 1999/08/28 00:02:56 peter Exp $";
-#endif
-
-/*
- * xdr_stdio.c, XDR implementation on standard i/o file.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * This set of routines implements a XDR on a stdio stream.
- * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes
- * from the stream.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rpc/types.h>
-#include <stdio.h>
-#include <rpc/xdr.h>
-#include <netinet/in.h>
-
-static bool_t	xdrstdio_getlong(XDR *xdrs, long *lp);
-static bool_t	xdrstdio_putlong(XDR *xdrs, const long *lp);
-static bool_t	xdrstdio_getbytes(XDR *xdrs, caddr_t addr, u_int len);
-static bool_t	xdrstdio_putbytes(XDR *xdrs, const char *addr, u_int len);
-static u_int	xdrstdio_getpos(XDR *xdrs);
-static bool_t	xdrstdio_setpos(XDR *xdrs, u_int pos);
-static int32_t *xdrstdio_inline(XDR *xdrs, u_int len);
-static void	xdrstdio_destroy(XDR *);
-
-/*
- * Ops vector for stdio type XDR
- */
-static struct xdr_ops	xdrstdio_ops = {
-	xdrstdio_getlong,	/* deseraialize a long int */
-	xdrstdio_putlong,	/* seraialize a long int */
-	xdrstdio_getbytes,	/* deserialize counted bytes */
-	xdrstdio_putbytes,	/* serialize counted bytes */
-	xdrstdio_getpos,	/* get offset in the stream */
-	xdrstdio_setpos,	/* set offset in the stream */
-	xdrstdio_inline,	/* prime stream for inline macros */
-	xdrstdio_destroy	/* destroy stream */
-};
-
-/*
- * Initialize a stdio xdr stream.
- * Sets the xdr stream handle xdrs for use on the stream file.
- * Operation flag is set to op.
- */
-void
-xdrstdio_create(
-	XDR *xdrs,
-	FILE *file,
-	enum xdr_op op)
-{
-
-	xdrs->x_op = op;
-	xdrs->x_ops = &xdrstdio_ops;
-	xdrs->x_private = (caddr_t)file;
-	xdrs->x_handy = 0;
-	xdrs->x_base = 0;
-}
-
-/*
- * Destroy a stdio xdr stream.
- * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create.
- */
-static void
-xdrstdio_destroy(
-	XDR *xdrs)
-{
-	(void)fflush((FILE *)xdrs->x_private);
-	/* xx should we close the file ?? */
-}
-
-static bool_t
-xdrstdio_getlong(
-	XDR *xdrs,
-	long *lp)
-{
-
-	if (fread((caddr_t)lp, sizeof(int32_t), 1,
-		(FILE *)xdrs->x_private) != 1)
-		return (FALSE);
-	*lp = (long)ntohl((int32_t)*lp);
-	return (TRUE);
-}
-
-static bool_t
-xdrstdio_putlong(
-	XDR *xdrs,
-	const long *lp)
-{
-
-	long mycopy = (long)htonl((int32_t)*lp);
-
-	if (fwrite((caddr_t)&mycopy, sizeof(int32_t), 1,
-		(FILE *)xdrs->x_private) != 1)
-		return (FALSE);
-	return (TRUE);
-}
-
-static bool_t
-xdrstdio_getbytes(
-	XDR *xdrs,
-	caddr_t addr,
-	u_int len )
-{
-
-	if ((len != 0) && (fread(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1))
-		return (FALSE);
-	return (TRUE);
-}
-
-static bool_t
-xdrstdio_putbytes(
-	XDR *xdrs,
-	const char *addr,
-	u_int len)
-{
-
-	if ((len != 0) && (fwrite(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1))
-		return (FALSE);
-	return (TRUE);
-}
-
-static u_int
-xdrstdio_getpos(
-	XDR *xdrs)
-{
-
-	return ((u_int) ftell((FILE *)xdrs->x_private));
-}
-
-static bool_t
-xdrstdio_setpos(
-	XDR *xdrs,
-	u_int pos)
-{
-
-	return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ?
-		FALSE : TRUE);
-}
-
-static int32_t *
-xdrstdio_inline(
-	XDR *xdrs,
-	u_int len)
-{
-
-	/*
-	 * Must do some work to implement this: must insure
-	 * enough data in the underlying stdio buffer,
-	 * that the buffer is aligned so that we can indirect through a
-	 * long *, and stuff this pointer in xdrs->x_buf.  Doing
-	 * a fread or fwrite to a scratch buffer would defeat
-	 * most of the gains to be had here and require storage
-	 * management on this buffer, so we don't do this.
-	 */
-	return (NULL);
-}
Index: rvices/mghttpd/Makefile
===================================================================
--- services/mghttpd/Makefile	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,39 +1,0 @@
-include ../../config.inc
-
-include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
-include $(RTEMS_CUSTOM)
-include $(PROJECT_ROOT)/make/leaf.cfg
-
-CFLAGS += -I $(INSTALL_BASE)/include
-
-CFLAGS += -w 
-CFLAGS += -std=gnu99
-CFLAGS += -MT $@ -MD -MP -MF $(basename $@).d
-# CFLAGS += -DHAVE_MD5
-CFLAGS += -DNO_SSL -DNO_POPEN -DNO_CGI
-
-C_FILES =
-C_FILES += mongoose.c
-
-C_O_FILES = $(C_FILES:%.c=%.o)
-C_D_FILES = $(C_FILES:%.c=%.d)
-
-LIB = libmghttpd.a
-
-all: $(LIB)
-
-$(LIB): $(C_O_FILES)
-	$(AR) rcu $@ $^
-
-install: $(LIB)
-	install -d $(INSTALL_BASE)/include/rtems
-	install -c -m 644 mongoose.h $(INSTALL_BASE)/rtems
-	install -c -m 644 $(LIB) $(INSTALL_BASE)
-
-clean:
-	rm -f $(LIB) $(C_O_FILES) $(C_D_FILES) $(GEN_FILES)
-
--include $(C_D_FILES)
-
-doc: 
-
Index: rvices/mghttpd/mongoose.1
===================================================================
--- services/mghttpd/mongoose.1	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,183 +1,0 @@
-.\" Process this file with
-.\" groff -man -Tascii mongoose.1
-.\" $Id: mongoose.1,v 1.12 2008/11/29 15:32:42 drozd Exp $
-.Dd Aug 31, 2010
-.Dt mongoose 1
-.Sh NAME
-.Nm mongoose
-.Nd lightweight web server
-.Sh SYNOPSIS
-.Nm
-.Op Ar config_file
-.Op Ar OPTIONS
-.Nm
-.Fl A Ar htpasswd_file domain_name user_name password
-.Sh DESCRIPTION
-.Nm
-is small, fast and easy to use web server with CGI, SSL, MD5 authorization,
-and basic SSI support.
-.Pp
-.Nm
-does not detach from terminal, and uses current working directory
-as the web root, unless
-.Fl r
-option is specified.
-It is possible to specify multiple ports to listen on. For example, to make
-mongoose listen on HTTP port 80 and HTTPS port 443, one should start it as:
-.Nm
-.Fl s Ar cert.pem Fl p Ar 80,443s
-.Pp
-Unlike other web servers,
-.Nm
-does not require CGI scripts be put in a special directory. CGI scripts can
-be anywhere. CGI (and SSI) files are recognized by the file name pattern.
-.Nm
-uses shell-like glob patterns with the following syntax:
-.Bl -tag -compact -width indent
-.It **
-Matches everything
-.It *
-Matches everything but slash character, '/'
-.It ?
-Matches any character
-.It $
-Matches the end of the string
-.It |
-Matches if pattern on the left side or the right side matches. Pattern on the
-left side is matched first
-.El
-All other characters in the pattern match themselves.
-.Pp
-If no arguments are given,
-.Nm
-searches for a configuration file called "mongoose.conf" in the same directory
-where mongoose binary is located. Alternatively, a file name could be
-specified in the command line. Format of the configuration file is the same
-as for the command line options except that each option must be specified
-on a separate line, leading dashes for option names must be omitted.
-Lines beginning with '#' and empty lines are ignored.
-.Pp
-.Sh OPTIONS
-.Bl -tag -width indent
-.It Fl A Ar htpasswd_file domain_name user_name password
-Add/edit user's password in the passwords file. Deleting users can be done
-with any text editor. Functionality is similar to Apache's
-.Ic htdigest
-utility.
-.It Fl C Ar cgi_pattern
-All files that fully match cgi_pattern are treated as CGI.
-Default pattern allows CGI files be
-anywhere. To restrict CGIs to certain directory, use e.g. "-C /cgi-bin/**.cgi".
-Default: "**.cgi$|**.pl$|**.php$"
-.It Fl E Ar cgi_environment
-Extra environment variables to be passed to the CGI script in addition to
-standard ones. The list must be comma-separated list of X=Y pairs, like this:
-"VARIABLE1=VALUE1,VARIABLE2=VALUE2". Default: ""
-.It Fl G Ar put_delete_passwords_file
-PUT and DELETE passwords file. This must be specified if PUT or
-DELETE methods are used. Default: ""
-.It Fl I Ar cgi_interpreter
-Use
-.Ar cgi_interpreter
-as a CGI interpreter for all CGI scripts regardless script extension.
-Mongoose decides which interpreter to use by looking at
-the first line of a CGI script.  Default: "".
-.It Fl M Ar max_request_size
-Maximum HTTP request size in bytes. Default: "16384"
-.It Fl P Ar protect_uri
-Comma separated list of URI=PATH pairs, specifying that given URIs
-must be protected with respected password files. Default: ""
-.It Fl R Ar authentication_domain
-Authorization realm. Default: "mydomain.com"
-.It Fl S Ar ssi_pattern
-All files that fully match ssi_pattern are treated as SSI.
-Unknown SSI directives are silently ignored. Currently, two SSI directives
-are supported, "include" and "exec".  Default: "**.shtml$|**.shtm$"
-.It Fl a Ar access_log_file
-Access log file. Default: "", no logging is done.
-.It Fl d Ar enable_directory_listing
-Enable/disable directory listing. Default: "yes"
-.It Fl e Ar error_log_file
-Error log file. Default: "", no errors are logged.
-.It Fl g Ar global_passwords_file
-Location of a global passwords file. If set, per-directory .htpasswd files are
-ignored, and all requests must be authorised against that file.  Default: ""
-.It Fl i Ar index_files
-Comma-separated list of files to be treated as directory index files.
-Default: "index.html,index.htm,index.cgi"
-.It Fl l Ar access_control_list
-Specify access control list (ACL). ACL is a comma separated list
-of IP subnets, each subnet is prepended by '-' or '+' sign. Plus means allow,
-minus means deny. If subnet mask is
-omitted, like "-1.2.3.4", then it means single IP address. Mask may vary
-from 0 to 32 inclusive. On each request, full list is traversed, and
-last match wins. Default setting is to allow all. For example, to allow only
-192.168/16 subnet to connect, run "mongoose -0.0.0.0/0,+192.168/16".
-Default: ""
-.It Fl m Ar extra_mime_types
-Extra mime types to recognize, in form
-"extension1=type1,extension2=type2,...". Extension must include dot.
-Example: "mongoose -m .cpp=plain/text,.java=plain/text". Default: ""
-.It Fl p Ar listening_ports
-Comma-separated list of ports to listen on. If the port is SSL, a letter 's'
-must be appeneded, for example, "-p 80,443s" will open port 80 and port 443,
-and connections on port 443 will be SSL-ed. It is possible to specify an
-IP address to bind to. In this case, an IP address and a colon must be
-prepended to the port number. For example, to bind to a loopback interface
-on port 80 and to all interfaces on HTTPS port 443, use
-"mongoose -p 127.0.0.1:80,443s". Default: "8080"
-.It Fl r Ar document_root
-Location of the WWW root directory. Default: "."
-.It Fl s Ar ssl_certificate
-Location of SSL certificate file. Default: ""
-.It Fl t Ar num_threads
-Number of worker threads to start. Default: "10"
-.It Fl u Ar run_as_user
-Switch to given user's credentials after startup. Default: ""
-.It Fl w Ar url_rewrite_patterns
-Comma-separated list of URL rewrites in the form of
-"pattern=substitution,..." If the "pattern" matches some prefix
-of the requested URL, then matched prefix gets substituted with "substitution".
-For example, "-w /config=/etc,**.doc|**.rtf=/path/to/cgi-bin/handle_doc.cgi"
-will serve all URLs that start with "/config" from the "/etc" directory, and
-call handle_doc.cgi script for .doc and .rtf file requests. If some pattern
-matches, no further matching/substitution is performed
-(first matching pattern wins). Use full paths in substitutions. Default: ""
-.It Fl x Ar thread_stack_size
-Use the given amount of stack for each thread. Default: ""
-.It Fl y Ar thread_priority
-Use the given priority for all posix threads. If this option is used without the
-thread_policy option, the systems default scheduling policy will be used for the
-threads instead of inheriting the policy of the creating thread. Default: ""
-.It Fl z Ar thread_policy
-Select the posix scheduling policy for the threads.  Possible Values are 's' for
-sporadic (not on all systems available), 'r' for round robin, 'f' for fifo or
-'o' for other scheduling strategie. If this option is used without the
-thread_priority option, the systems default priority will be used for the
-threads instead of inheriting the priority of the creating thread. Default: ""
-.El
-.Pp
-.Sh EMBEDDING
-.Nm
-was designed to be embeddable into C/C++ applications. Since the
-source code is contained in single C file, it is fairly easy to embed it
-and follow the updates. Please refer to http://code.google.com/p/mongoose
-for details.
-.Pp
-.Sh EXAMPLES
-.Bl -tag -width indent
-.It Nm Fl r Ar /var/www Fl s Ar /etc/cert.pem Fl p Ar 8080,8043s
-Start serving files from /var/www. Listen on port 8080 for HTTP, and 8043
-for HTTPS connections.  Use /etc/cert.pem as SSL certificate file.
-.It Nm Fl l Ar -0.0.0.0/0,+10.0.0.0/8,+1.2.3.4
-Deny connections from everywhere, allow only IP address 1.2.3.4 and
-all IP addresses from 10.0.0.0/8 subnet to connect.
-.It Nm Fl w Ar **=/usr/bin/script.cgi
-Invoke /usr/bin/script.cgi for every incoming request, regardless of the URL.
-.El
-.Pp
-.Sh COPYRIGHT
-.Nm
-is licensed under the terms of the MIT license.
-.Sh AUTHOR
-.An Sergey Lyubka Aq valenok@gmail.com .
Index: rvices/mghttpd/mongoose.c
===================================================================
--- services/mghttpd/mongoose.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,4317 +1,0 @@
-// Copyright (c) 2004-2011 Sergey Lyubka
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#if defined(__rtems__)
-#include <md5.h>
-#define HAVE_MD5
-#endif // __rtems__
-
-#if defined(_WIN32)
-#define _CRT_SECURE_NO_WARNINGS // Disable deprecation warning in VS2005
-#else
-#define _XOPEN_SOURCE 600     // For flockfile() on Linux
-#define _LARGEFILE_SOURCE     // Enable 64-bit file offsets
-#define __STDC_FORMAT_MACROS  // <inttypes.h> wants this for C++
-#define __STDC_LIMIT_MACROS   // C++ wants that for INT64_MAX
-#endif
-
-#if defined(__SYMBIAN32__)
-#define NO_SSL // SSL is not supported
-#define NO_CGI // CGI is not supported
-#define PATH_MAX FILENAME_MAX
-#endif // __SYMBIAN32__
-
-#ifndef _WIN32_WCE // Some ANSI #includes are not available on Windows CE
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#endif // !_WIN32_WCE
-
-#include <time.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stddef.h>
-#include <stdio.h>
-
-#if defined(_WIN32) && !defined(__SYMBIAN32__) // Windows specific
-#define _WIN32_WINNT 0x0400 // To make it link in VS2005
-#include <windows.h>
-
-#ifndef PATH_MAX
-#define PATH_MAX MAX_PATH
-#endif
-
-#ifndef _WIN32_WCE
-#include <process.h>
-#include <direct.h>
-#include <io.h>
-#else // _WIN32_WCE
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#define NO_CGI // WinCE has no pipes
-
-typedef long off_t;
-#define BUFSIZ  4096
-
-#define errno   GetLastError()
-#define strerror(x)  _ultoa(x, (char *) _alloca(sizeof(x) *3 ), 10)
-#endif // _WIN32_WCE
-
-#define MAKEUQUAD(lo, hi) ((uint64_t)(((uint32_t)(lo)) | \
-      ((uint64_t)((uint32_t)(hi))) << 32))
-#define RATE_DIFF 10000000 // 100 nsecs
-#define EPOCH_DIFF MAKEUQUAD(0xd53e8000, 0x019db1de)
-#define SYS2UNIX_TIME(lo, hi) \
-  (time_t) ((MAKEUQUAD((lo), (hi)) - EPOCH_DIFF) / RATE_DIFF)
-
-// Visual Studio 6 does not know __func__ or __FUNCTION__
-// The rest of MS compilers use __FUNCTION__, not C99 __func__
-// Also use _strtoui64 on modern M$ compilers
-#if defined(_MSC_VER) && _MSC_VER < 1300
-#define STRX(x) #x
-#define STR(x) STRX(x)
-#define __func__ "line " STR(__LINE__)
-#define strtoull(x, y, z) strtoul(x, y, z)
-#define strtoll(x, y, z) strtol(x, y, z)
-#else
-#define __func__  __FUNCTION__
-#define strtoull(x, y, z) _strtoui64(x, y, z)
-#define strtoll(x, y, z) _strtoi64(x, y, z)
-#endif // _MSC_VER
-
-#define ERRNO   GetLastError()
-#define NO_SOCKLEN_T
-#define SSL_LIB   "ssleay32.dll"
-#define CRYPTO_LIB  "libeay32.dll"
-#define DIRSEP '\\'
-#define IS_DIRSEP_CHAR(c) ((c) == '/' || (c) == '\\')
-#define O_NONBLOCK  0
-#if !defined(EWOULDBLOCK)
-#define EWOULDBLOCK  WSAEWOULDBLOCK
-#endif // !EWOULDBLOCK
-#define _POSIX_
-#define INT64_FMT  "I64d"
-
-#define WINCDECL __cdecl
-#define SHUT_WR 1
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
-#define mg_sleep(x) Sleep(x)
-
-#define pipe(x) _pipe(x, BUFSIZ, _O_BINARY)
-#define popen(x, y) _popen(x, y)
-#define pclose(x) _pclose(x)
-#define close(x) _close(x)
-#define dlsym(x,y) GetProcAddress((HINSTANCE) (x), (y))
-#define RTLD_LAZY  0
-#define fseeko(x, y, z) fseek((x), (y), (z))
-#define fdopen(x, y) _fdopen((x), (y))
-#define write(x, y, z) _write((x), (y), (unsigned) z)
-#define read(x, y, z) _read((x), (y), (unsigned) z)
-#define flockfile(x) EnterCriticalSection(&global_log_file_lock)
-#define funlockfile(x) LeaveCriticalSection(&global_log_file_lock)
-
-#if !defined(fileno)
-#define fileno(x) _fileno(x)
-#endif // !fileno MINGW #defines fileno
-
-typedef HANDLE pthread_mutex_t;
-typedef struct {HANDLE signal, broadcast;} pthread_cond_t;
-typedef DWORD pthread_t;
-#define pid_t HANDLE // MINGW typedefs pid_t to int. Using #define here.
-
-struct timespec {
-  long tv_nsec;
-  long tv_sec;
-};
-
-static int pthread_mutex_lock(pthread_mutex_t *);
-static int pthread_mutex_unlock(pthread_mutex_t *);
-static FILE *mg_fopen(const char *path, const char *mode);
-
-#if defined(HAVE_STDINT)
-#include <stdint.h>
-#else
-typedef unsigned int  uint32_t;
-typedef unsigned short  uint16_t;
-typedef unsigned __int64 uint64_t;
-typedef __int64   int64_t;
-#define INT64_MAX  9223372036854775807
-#endif // HAVE_STDINT
-
-// POSIX dirent interface
-struct dirent {
-  char d_name[PATH_MAX];
-};
-
-typedef struct DIR {
-  HANDLE   handle;
-  WIN32_FIND_DATAW info;
-  struct dirent  result;
-} DIR;
-
-#else    // UNIX  specific
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/time.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <netdb.h>
-
-#include <pwd.h>
-#include <unistd.h>
-#include <dirent.h>
-#if !defined(NO_SSL_DL) && !defined(NO_SSL)
-#include <dlfcn.h>
-#endif
-#include <pthread.h>
-#if defined(__MACH__)
-#define SSL_LIB   "libssl.dylib"
-#define CRYPTO_LIB  "libcrypto.dylib"
-#else
-#if !defined(SSL_LIB)
-#define SSL_LIB   "libssl.so"
-#endif
-#if !defined(CRYPTO_LIB)
-#define CRYPTO_LIB  "libcrypto.so"
-#endif
-#endif
-#define DIRSEP   '/'
-#define IS_DIRSEP_CHAR(c) ((c) == '/')
-#ifndef O_BINARY
-#define O_BINARY  0
-#endif // O_BINARY
-#define closesocket(a) close(a)
-#define mg_fopen(x, y) fopen(x, y)
-#define mg_mkdir(x, y) mkdir(x, y)
-#define mg_remove(x) remove(x)
-#define mg_rename(x, y) rename(x, y)
-#define mg_sleep(x) usleep((x) * 1000)
-#define ERRNO errno
-#define INVALID_SOCKET (-1)
-#define INT64_FMT PRId64
-typedef int SOCKET;
-#define WINCDECL
-
-#endif // End of Windows and UNIX specific includes
-
-#include "mongoose.h"
-
-#define MONGOOSE_VERSION "3.2"
-#define PASSWORDS_FILE_NAME ".htpasswd"
-#define CGI_ENVIRONMENT_SIZE 4096
-#define MAX_CGI_ENVIR_VARS 64
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
-
-#ifdef _WIN32
-static CRITICAL_SECTION global_log_file_lock;
-static pthread_t pthread_self(void) {
-  return GetCurrentThreadId();
-}
-#endif // _WIN32
-
-#if defined(DEBUG)
-#define DEBUG_TRACE(x) do { \
-  flockfile(stdout); \
-  printf("*** %lu.%p.%s.%d: ", \
-         (unsigned long) time(NULL), (void *) pthread_self(), \
-         __func__, __LINE__); \
-  printf x; \
-  putchar('\n'); \
-  fflush(stdout); \
-  funlockfile(stdout); \
-} while (0)
-#else
-#define DEBUG_TRACE(x)
-#endif // DEBUG
-
-// Darwin prior to 7.0 and Win32 do not have socklen_t
-#ifdef NO_SOCKLEN_T
-typedef int socklen_t;
-#endif // NO_SOCKLEN_T
-
-#if !defined(MSG_NOSIGNAL)
-#define MSG_NOSIGNAL 0
-#endif
-
-typedef void * (*mg_thread_func_t)(void *);
-
-static const char *http_500_error = "Internal Server Error";
-
-// Snatched from OpenSSL includes. I put the prototypes here to be independent
-// from the OpenSSL source installation. Having this, mongoose + SSL can be
-// built on any system with binary SSL libraries installed.
-typedef struct ssl_st SSL;
-typedef struct ssl_method_st SSL_METHOD;
-typedef struct ssl_ctx_st SSL_CTX;
-
-#define SSL_ERROR_WANT_READ 2
-#define SSL_ERROR_WANT_WRITE 3
-#define SSL_FILETYPE_PEM 1
-#define CRYPTO_LOCK  1
-
-#if defined(NO_SSL_DL)
-extern void SSL_free(SSL *);
-extern int SSL_accept(SSL *);
-extern int SSL_connect(SSL *);
-extern int SSL_read(SSL *, void *, int);
-extern int SSL_write(SSL *, const void *, int);
-extern int SSL_get_error(const SSL *, int);
-extern int SSL_set_fd(SSL *, int);
-extern SSL *SSL_new(SSL_CTX *);
-extern SSL_CTX *SSL_CTX_new(SSL_METHOD *);
-extern SSL_METHOD *SSLv23_server_method(void);
-extern int SSL_library_init(void);
-extern void SSL_load_error_strings(void);
-extern int SSL_CTX_use_PrivateKey_file(SSL_CTX *, const char *, int);
-extern int SSL_CTX_use_certificate_file(SSL_CTX *, const char *, int);
-extern int SSL_CTX_use_certificate_chain_file(SSL_CTX *, const char *);
-extern void SSL_CTX_set_default_passwd_cb(SSL_CTX *, mg_callback_t);
-extern void SSL_CTX_free(SSL_CTX *);
-extern unsigned long ERR_get_error(void);
-extern char *ERR_error_string(unsigned long, char *);
-extern int CRYPTO_num_locks(void);
-extern void CRYPTO_set_locking_callback(void (*)(int, int, const char *, int));
-extern void CRYPTO_set_id_callback(unsigned long (*)(void));
-#else
-// Dynamically loaded SSL functionality
-struct ssl_func {
-  const char *name;   // SSL function name
-  void  (*ptr)(void); // Function pointer
-};
-
-#define SSL_free (* (void (*)(SSL *)) ssl_sw[0].ptr)
-#define SSL_accept (* (int (*)(SSL *)) ssl_sw[1].ptr)
-#define SSL_connect (* (int (*)(SSL *)) ssl_sw[2].ptr)
-#define SSL_read (* (int (*)(SSL *, void *, int)) ssl_sw[3].ptr)
-#define SSL_write (* (int (*)(SSL *, const void *,int)) ssl_sw[4].ptr)
-#define SSL_get_error (* (int (*)(SSL *, int)) ssl_sw[5].ptr)
-#define SSL_set_fd (* (int (*)(SSL *, SOCKET)) ssl_sw[6].ptr)
-#define SSL_new (* (SSL * (*)(SSL_CTX *)) ssl_sw[7].ptr)
-#define SSL_CTX_new (* (SSL_CTX * (*)(SSL_METHOD *)) ssl_sw[8].ptr)
-#define SSLv23_server_method (* (SSL_METHOD * (*)(void)) ssl_sw[9].ptr)
-#define SSL_library_init (* (int (*)(void)) ssl_sw[10].ptr)
-#define SSL_CTX_use_PrivateKey_file (* (int (*)(SSL_CTX *, \
-        const char *, int)) ssl_sw[11].ptr)
-#define SSL_CTX_use_certificate_file (* (int (*)(SSL_CTX *, \
-        const char *, int)) ssl_sw[12].ptr)
-#define SSL_CTX_set_default_passwd_cb \
-  (* (void (*)(SSL_CTX *, mg_callback_t)) ssl_sw[13].ptr)
-#define SSL_CTX_free (* (void (*)(SSL_CTX *)) ssl_sw[14].ptr)
-#define SSL_load_error_strings (* (void (*)(void)) ssl_sw[15].ptr)
-#define SSL_CTX_use_certificate_chain_file \
-  (* (int (*)(SSL_CTX *, const char *)) ssl_sw[16].ptr)
-
-#define CRYPTO_num_locks (* (int (*)(void)) crypto_sw[0].ptr)
-#define CRYPTO_set_locking_callback \
-  (* (void (*)(void (*)(int, int, const char *, int))) crypto_sw[1].ptr)
-#define CRYPTO_set_id_callback \
-  (* (void (*)(unsigned long (*)(void))) crypto_sw[2].ptr)
-#define ERR_get_error (* (unsigned long (*)(void)) crypto_sw[3].ptr)
-#define ERR_error_string (* (char * (*)(unsigned long,char *)) crypto_sw[4].ptr)
-
-// set_ssl_option() function updates this array.
-// It loads SSL library dynamically and changes NULLs to the actual addresses
-// of respective functions. The macros above (like SSL_connect()) are really
-// just calling these functions indirectly via the pointer.
-static struct ssl_func ssl_sw[] = {
-  {"SSL_free",   NULL},
-  {"SSL_accept",   NULL},
-  {"SSL_connect",   NULL},
-  {"SSL_read",   NULL},
-  {"SSL_write",   NULL},
-  {"SSL_get_error",  NULL},
-  {"SSL_set_fd",   NULL},
-  {"SSL_new",   NULL},
-  {"SSL_CTX_new",   NULL},
-  {"SSLv23_server_method", NULL},
-  {"SSL_library_init",  NULL},
-  {"SSL_CTX_use_PrivateKey_file", NULL},
-  {"SSL_CTX_use_certificate_file",NULL},
-  {"SSL_CTX_set_default_passwd_cb",NULL},
-  {"SSL_CTX_free",  NULL},
-  {"SSL_load_error_strings", NULL},
-  {"SSL_CTX_use_certificate_chain_file", NULL},
-  {NULL,    NULL}
-};
-
-// Similar array as ssl_sw. These functions could be located in different lib.
-#if !defined(NO_SSL)
-static struct ssl_func crypto_sw[] = {
-  {"CRYPTO_num_locks",  NULL},
-  {"CRYPTO_set_locking_callback", NULL},
-  {"CRYPTO_set_id_callback", NULL},
-  {"ERR_get_error",  NULL},
-  {"ERR_error_string", NULL},
-  {NULL,    NULL}
-};
-#endif // NO_SSL
-#endif // NO_SSL_DL
-
-static const char *month_names[] = {
-  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-
-// Unified socket address. For IPv6 support, add IPv6 address structure
-// in the union u.
-union usa {
-  struct sockaddr sa;
-  struct sockaddr_in sin;
-#if defined(USE_IPV6)
-  struct sockaddr_in6 sin6;
-#endif
-};
-
-// Describes a string (chunk of memory).
-struct vec {
-  const char *ptr;
-  size_t len;
-};
-
-// Structure used by mg_stat() function. Uses 64 bit file length.
-struct mgstat {
-  int is_directory;  // Directory marker
-  int64_t size;      // File size
-  time_t mtime;      // Modification time
-};
-
-// Describes listening socket, or socket which was accept()-ed by the master
-// thread and queued for future handling by the worker thread.
-struct socket {
-  struct socket *next;  // Linkage
-  SOCKET sock;          // Listening socket
-  union usa lsa;        // Local socket address
-  union usa rsa;        // Remote socket address
-  int is_ssl;           // Is socket SSL-ed
-};
-
-enum {
-  CGI_EXTENSIONS, CGI_ENVIRONMENT, PUT_DELETE_PASSWORDS_FILE, CGI_INTERPRETER,
-  PROTECT_URI, AUTHENTICATION_DOMAIN, SSI_EXTENSIONS, ACCESS_LOG_FILE,
-  SSL_CHAIN_FILE, ENABLE_DIRECTORY_LISTING, ERROR_LOG_FILE,
-  GLOBAL_PASSWORDS_FILE, INDEX_FILES,
-  ENABLE_KEEP_ALIVE, ACCESS_CONTROL_LIST, MAX_REQUEST_SIZE,
-  EXTRA_MIME_TYPES, LISTENING_PORTS,
-  DOCUMENT_ROOT, SSL_CERTIFICATE, NUM_THREADS, RUN_AS_USER, REWRITE,
-  THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_POLICY,
-  NUM_OPTIONS
-};
-
-static const char *config_options[] = {
-  "C", "cgi_pattern", "**.cgi$|**.pl$|**.php$",
-  "E", "cgi_environment", NULL,
-  "G", "put_delete_passwords_file", NULL,
-  "I", "cgi_interpreter", NULL,
-  "P", "protect_uri", NULL,
-  "R", "authentication_domain", "mydomain.com",
-  "S", "ssi_pattern", "**.shtml$|**.shtm$",
-  "a", "access_log_file", NULL,
-  "c", "ssl_chain_file", NULL,
-  "d", "enable_directory_listing", "yes",
-  "e", "error_log_file", NULL,
-  "g", "global_passwords_file", NULL,
-  "i", "index_files", "index.html,index.htm,index.cgi,index.shtml,index.php",
-  "k", "enable_keep_alive", "no",
-  "l", "access_control_list", NULL,
-  "M", "max_request_size", "16384",
-  "m", "extra_mime_types", NULL,
-  "p", "listening_ports", "8080",
-  "r", "document_root",  ".",
-  "s", "ssl_certificate", NULL,
-  "t", "num_threads", "10",
-  "u", "run_as_user", NULL,
-  "w", "url_rewrite_patterns", NULL,
-  "x", "thread_stack_size", NULL,
-  "y", "thread_priority", NULL,
-  "z", "thread_policy", NULL,
-  NULL
-};
-#define ENTRIES_PER_CONFIG_OPTION 3
-
-struct mg_context {
-  volatile int stop_flag;       // Should we stop event loop
-  SSL_CTX *ssl_ctx;             // SSL context
-  char *config[NUM_OPTIONS];    // Mongoose configuration parameters
-  mg_callback_t user_callback;  // User-defined callback function
-  void *user_data;              // User-defined data
-
-  struct socket *listening_sockets;
-
-  volatile int num_threads;  // Number of threads
-  pthread_mutex_t mutex;     // Protects (max|num)_threads
-  pthread_cond_t  cond;      // Condvar for tracking workers terminations
-
-  struct socket queue[20];   // Accepted sockets
-  volatile int sq_head;      // Head of the socket queue
-  volatile int sq_tail;      // Tail of the socket queue
-  pthread_cond_t sq_full;    // Singaled when socket is produced
-  pthread_cond_t sq_empty;   // Signaled when socket is consumed
-};
-
-struct mg_connection {
-  struct mg_request_info request_info;
-  struct mg_context *ctx;
-  SSL *ssl;                   // SSL descriptor
-  struct socket client;       // Connected client
-  time_t birth_time;          // Time connection was accepted
-  int64_t num_bytes_sent;     // Total bytes sent to client
-  int64_t content_len;        // Content-Length header value
-  int64_t consumed_content;   // How many bytes of content is already read
-  char *buf;                  // Buffer for received data
-  char *path_info;            // PATH_INFO part of the URL
-  int must_close;             // 1 if connection must be closed
-  int buf_size;               // Buffer size
-  int request_len;            // Size of the request + headers in a buffer
-  int data_len;               // Total size of data in a buffer
-};
-
-const char **mg_get_valid_option_names(void) {
-  return config_options;
-}
-
-static void *call_user(struct mg_connection *conn, enum mg_event event) {
-  conn->request_info.user_data = conn->ctx->user_data;
-  return conn->ctx->user_callback == NULL ? NULL :
-    conn->ctx->user_callback(event, conn, &conn->request_info);
-}
-
-static int get_option_index(const char *name) {
-  int i;
-
-  for (i = 0; config_options[i] != NULL; i += ENTRIES_PER_CONFIG_OPTION) {
-    if (strcmp(config_options[i], name) == 0 ||
-        strcmp(config_options[i + 1], name) == 0) {
-      return i / ENTRIES_PER_CONFIG_OPTION;
-    }
-  }
-  return -1;
-}
-
-const char *mg_get_option(const struct mg_context *ctx, const char *name) {
-  int i;
-  if ((i = get_option_index(name)) == -1) {
-    return NULL;
-  } else if (ctx->config[i] == NULL) {
-    return "";
-  } else {
-    return ctx->config[i];
-  }
-}
-
-static void sockaddr_to_string(char *buf, size_t len,
-                                     const union usa *usa) {
-  buf[0] = '\0';
-#if defined(USE_IPV6)
-  inet_ntop(usa->sa.sa_family, usa->sa.sa_family == AF_INET ?
-            (void *) &usa->sin.sin_addr :
-            (void *) &usa->sin6.sin6_addr, buf, len);
-#elif defined(_WIN32)
-  // Only Windoze Vista (and newer) have inet_ntop()
-  strncpy(buf, inet_ntoa(usa->sin.sin_addr), len);
-#else
-  inet_ntop(usa->sa.sa_family, (void *) &usa->sin.sin_addr, buf, len);
-#endif
-}
-
-// Print error message to the opened error log stream.
-static void cry(struct mg_connection *conn, const char *fmt, ...) {
-  char buf[BUFSIZ], src_addr[20];
-  va_list ap;
-  FILE *fp;
-  time_t timestamp;
-
-  va_start(ap, fmt);
-  (void) vsnprintf(buf, sizeof(buf), fmt, ap);
-  va_end(ap);
-
-  // Do not lock when getting the callback value, here and below.
-  // I suppose this is fine, since function cannot disappear in the
-  // same way string option can.
-  conn->request_info.log_message = buf;
-  if (call_user(conn, MG_EVENT_LOG) == NULL) {
-    fp = conn->ctx->config[ERROR_LOG_FILE] == NULL ? NULL :
-      mg_fopen(conn->ctx->config[ERROR_LOG_FILE], "a+");
-
-    if (fp != NULL) {
-      flockfile(fp);
-      timestamp = time(NULL);
-
-      sockaddr_to_string(src_addr, sizeof(src_addr), &conn->client.rsa);
-      fprintf(fp, "[%010lu] [error] [client %s] ", (unsigned long) timestamp,
-              src_addr);
-
-      if (conn->request_info.request_method != NULL) {
-        fprintf(fp, "%s %s: ", conn->request_info.request_method,
-                conn->request_info.uri);
-      }
-
-      (void) fprintf(fp, "%s", buf);
-      fputc('\n', fp);
-      funlockfile(fp);
-      if (fp != stderr) {
-        fclose(fp);
-      }
-    }
-  }
-  conn->request_info.log_message = NULL;
-}
-
-// Return fake connection structure. Used for logging, if connection
-// is not applicable at the moment of logging.
-static struct mg_connection *fc(struct mg_context *ctx) {
-  static struct mg_connection fake_connection;
-  fake_connection.ctx = ctx;
-  return &fake_connection;
-}
-
-const char *mg_version(void) {
-  return MONGOOSE_VERSION;
-}
-
-static void mg_strlcpy(register char *dst, register const char *src, size_t n) {
-  for (; *src != '\0' && n > 1; n--) {
-    *dst++ = *src++;
-  }
-  *dst = '\0';
-}
-
-static int lowercase(const char *s) {
-  return tolower(* (const unsigned char *) s);
-}
-
-static int mg_strncasecmp(const char *s1, const char *s2, size_t len) {
-  int diff = 0;
-
-  if (len > 0)
-    do {
-      diff = lowercase(s1++) - lowercase(s2++);
-    } while (diff == 0 && s1[-1] != '\0' && --len > 0);
-
-  return diff;
-}
-
-static int mg_strcasecmp(const char *s1, const char *s2) {
-  int diff;
-
-  do {
-    diff = lowercase(s1++) - lowercase(s2++);
-  } while (diff == 0 && s1[-1] != '\0');
-
-  return diff;
-}
-
-static char * mg_strndup(const char *ptr, size_t len) {
-  char *p;
-
-  if ((p = (char *) malloc(len + 1)) != NULL) {
-    mg_strlcpy(p, ptr, len + 1);
-  }
-
-  return p;
-}
-
-static char * mg_strdup(const char *str) {
-  return mg_strndup(str, strlen(str));
-}
-
-// Like snprintf(), but never returns negative value, or the value
-// that is larger than a supplied buffer.
-// Thanks to Adam Zeldis to pointing snprintf()-caused vulnerability
-// in his audit report.
-static int mg_vsnprintf(struct mg_connection *conn, char *buf, size_t buflen,
-                        const char *fmt, va_list ap) {
-  int n;
-
-  if (buflen == 0)
-    return 0;
-
-  n = vsnprintf(buf, buflen, fmt, ap);
-
-  if (n < 0) {
-    cry(conn, "vsnprintf error");
-    n = 0;
-  } else if (n >= (int) buflen) {
-    cry(conn, "truncating vsnprintf buffer: [%.*s]",
-        n > 200 ? 200 : n, buf);
-    n = (int) buflen - 1;
-  }
-  buf[n] = '\0';
-
-  return n;
-}
-
-static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
-                       const char *fmt, ...) {
-  va_list ap;
-  int n;
-
-  va_start(ap, fmt);
-  n = mg_vsnprintf(conn, buf, buflen, fmt, ap);
-  va_end(ap);
-
-  return n;
-}
-
-// Skip the characters until one of the delimiters characters found.
-// 0-terminate resulting word. Skip the delimiter and following whitespaces if any.
-// Advance pointer to buffer to the next word. Return found 0-terminated word.
-// Delimiters can be quoted with quotechar.
-static char *skip_quoted(char **buf, const char *delimiters, const char *whitespace, char quotechar) {
-  char *p, *begin_word, *end_word, *end_whitespace;
-
-  begin_word = *buf;
-  end_word = begin_word + strcspn(begin_word, delimiters);
-
-  // Check for quotechar
-  if (end_word > begin_word) {
-    p = end_word - 1;
-    while (*p == quotechar) {
-      // If there is anything beyond end_word, copy it
-      if (*end_word == '\0') {
-        *p = '\0';
-        break;
-      } else {
-        size_t end_off = strcspn(end_word + 1, delimiters);
-        memmove (p, end_word, end_off + 1);
-        p += end_off; // p must correspond to end_word - 1
-        end_word += end_off + 1;
-      }
-    }
-    for (p++; p < end_word; p++) {
-      *p = '\0';
-    }
-  }
-
-  if (*end_word == '\0') {
-    *buf = end_word;
-  } else {
-    end_whitespace = end_word + 1 + strspn(end_word + 1, whitespace);
-
-    for (p = end_word; p < end_whitespace; p++) {
-      *p = '\0';
-    }
-
-    *buf = end_whitespace;
-  }
-
-  return begin_word;
-}
-
-// Simplified version of skip_quoted without quote char
-// and whitespace == delimiters
-static char *skip(char **buf, const char *delimiters) {
-  return skip_quoted(buf, delimiters, delimiters, 0);
-}
-
-
-// Return HTTP header value, or NULL if not found.
-static const char *get_header(const struct mg_request_info *ri,
-                              const char *name) {
-  int i;
-
-  for (i = 0; i < ri->num_headers; i++)
-    if (!mg_strcasecmp(name, ri->http_headers[i].name))
-      return ri->http_headers[i].value;
-
-  return NULL;
-}
-
-const char *mg_get_header(const struct mg_connection *conn, const char *name) {
-  return get_header(&conn->request_info, name);
-}
-
-// A helper function for traversing comma separated list of values.
-// It returns a list pointer shifted to the next value, of NULL if the end
-// of the list found.
-// Value is stored in val vector. If value has form "x=y", then eq_val
-// vector is initialized to point to the "y" part, and val vector length
-// is adjusted to point only to "x".
-static const char *next_option(const char *list, struct vec *val,
-                               struct vec *eq_val) {
-  if (list == NULL || *list == '\0') {
-    // End of the list
-    list = NULL;
-  } else {
-    val->ptr = list;
-    if ((list = strchr(val->ptr, ',')) != NULL) {
-      // Comma found. Store length and shift the list ptr
-      val->len = list - val->ptr;
-      list++;
-    } else {
-      // This value is the last one
-      list = val->ptr + strlen(val->ptr);
-      val->len = list - val->ptr;
-    }
-
-    if (eq_val != NULL) {
-      // Value has form "x=y", adjust pointers and lengths
-      // so that val points to "x", and eq_val points to "y".
-      eq_val->len = 0;
-      eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len);
-      if (eq_val->ptr != NULL) {
-        eq_val->ptr++;  // Skip over '=' character
-        eq_val->len = val->ptr + val->len - eq_val->ptr;
-        val->len = (eq_val->ptr - val->ptr) - 1;
-      }
-    }
-  }
-
-  return list;
-}
-
-static int match_prefix(const char *pattern, int pattern_len, const char *str) {
-  const char *or_str;
-  int i, j, len, res;
-
-  if ((or_str = (const char *) memchr(pattern, '|', pattern_len)) != NULL) {
-    res = match_prefix(pattern, or_str - pattern, str);
-    return res > 0 ? res :
-        match_prefix(or_str + 1, (pattern + pattern_len) - (or_str + 1), str);
-  }
-
-  i = j = 0;
-  res = -1;
-  for (; i < pattern_len; i++, j++) {
-    if (pattern[i] == '?' && str[j] != '\0') {
-      continue;
-    } else if (pattern[i] == '$') {
-      return str[j] == '\0' ? j : -1;
-    } else if (pattern[i] == '*') {
-      i++;
-      if (pattern[i] == '*') {
-        i++;
-        len = strlen(str + j);
-      } else {
-        len = strcspn(str + j, "/");
-      }
-      if (i == pattern_len) {
-        return j + len;
-      }
-      do {
-        res = match_prefix(pattern + i, pattern_len - i, str + j + len);
-      } while (res == -1 && len-- > 0);
-      return res == -1 ? -1 : j + res + len;
-    } else if (pattern[i] != str[j]) {
-      return -1;
-    }
-  }
-  return j;
-}
-
-// HTTP 1.1 assumes keep alive if "Connection:" header is not set
-// This function must tolerate situations when connection info is not
-// set up, for example if request parsing failed.
-static int should_keep_alive(const struct mg_connection *conn) {
-  const char *http_version = conn->request_info.http_version;
-  const char *header = mg_get_header(conn, "Connection");
-  if (conn->must_close ||
-      conn->request_info.status_code == 401 ||
-      mg_strcasecmp(conn->ctx->config[ENABLE_KEEP_ALIVE], "yes") != 0 ||
-      (header != NULL && mg_strcasecmp(header, "keep-alive") != 0) ||
-      (header == NULL && http_version && strcmp(http_version, "1.1"))) {
-    return 0;
-  }
-  return 1;
-}
-
-static const char *suggest_connection_header(const struct mg_connection *conn) {
-  return should_keep_alive(conn) ? "keep-alive" : "close";
-}
-
-static void send_http_error(struct mg_connection *conn, int status,
-                            const char *reason, const char *fmt, ...) {
-  char buf[BUFSIZ];
-  va_list ap;
-  int len;
-
-  conn->request_info.status_code = status;
-
-  if (call_user(conn, MG_HTTP_ERROR) == NULL) {
-    buf[0] = '\0';
-    len = 0;
-
-    // Errors 1xx, 204 and 304 MUST NOT send a body
-    if (status > 199 && status != 204 && status != 304) {
-      len = mg_snprintf(conn, buf, sizeof(buf), "Error %d: %s", status, reason);
-      cry(conn, "%s", buf);
-      buf[len++] = '\n';
-
-      va_start(ap, fmt);
-      len += mg_vsnprintf(conn, buf + len, sizeof(buf) - len, fmt, ap);
-      va_end(ap);
-    }
-    DEBUG_TRACE(("[%s]", buf));
-
-    mg_printf(conn, "HTTP/1.1 %d %s\r\n"
-              "Content-Type: text/plain\r\n"
-              "Content-Length: %d\r\n"
-              "Connection: %s\r\n\r\n", status, reason, len,
-              suggest_connection_header(conn));
-    conn->num_bytes_sent += mg_printf(conn, "%s", buf);
-  }
-}
-
-#if defined(_WIN32) && !defined(__SYMBIAN32__)
-static int pthread_mutex_init(pthread_mutex_t *mutex, void *unused) {
-  unused = NULL;
-  *mutex = CreateMutex(NULL, FALSE, NULL);
-  return *mutex == NULL ? -1 : 0;
-}
-
-static int pthread_mutex_destroy(pthread_mutex_t *mutex) {
-  return CloseHandle(*mutex) == 0 ? -1 : 0;
-}
-
-static int pthread_mutex_lock(pthread_mutex_t *mutex) {
-  return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0? 0 : -1;
-}
-
-static int pthread_mutex_unlock(pthread_mutex_t *mutex) {
-  return ReleaseMutex(*mutex) == 0 ? -1 : 0;
-}
-
-static int pthread_cond_init(pthread_cond_t *cv, const void *unused) {
-  unused = NULL;
-  cv->signal = CreateEvent(NULL, FALSE, FALSE, NULL);
-  cv->broadcast = CreateEvent(NULL, TRUE, FALSE, NULL);
-  return cv->signal != NULL && cv->broadcast != NULL ? 0 : -1;
-}
-
-static int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mutex) {
-  HANDLE handles[] = {cv->signal, cv->broadcast};
-  ReleaseMutex(*mutex);
-  WaitForMultipleObjects(2, handles, FALSE, INFINITE);
-  return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0? 0 : -1;
-}
-
-static int pthread_cond_signal(pthread_cond_t *cv) {
-  return SetEvent(cv->signal) == 0 ? -1 : 0;
-}
-
-static int pthread_cond_broadcast(pthread_cond_t *cv) {
-  // Implementation with PulseEvent() has race condition, see
-  // http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
-  return PulseEvent(cv->broadcast) == 0 ? -1 : 0;
-}
-
-static int pthread_cond_destroy(pthread_cond_t *cv) {
-  return CloseHandle(cv->signal) && CloseHandle(cv->broadcast) ? 0 : -1;
-}
-
-// For Windows, change all slashes to backslashes in path names.
-static void change_slashes_to_backslashes(char *path) {
-  int i;
-
-  for (i = 0; path[i] != '\0'; i++) {
-    if (path[i] == '/')
-      path[i] = '\\';
-    // i > 0 check is to preserve UNC paths, like \\server\file.txt
-    if (path[i] == '\\' && i > 0)
-      while (path[i + 1] == '\\' || path[i + 1] == '/')
-        (void) memmove(path + i + 1,
-            path + i + 2, strlen(path + i + 1));
-  }
-}
-
-// Encode 'path' which is assumed UTF-8 string, into UNICODE string.
-// wbuf and wbuf_len is a target buffer and its length.
-static void to_unicode(const char *path, wchar_t *wbuf, size_t wbuf_len) {
-  char buf[PATH_MAX], buf2[PATH_MAX], *p;
-
-  mg_strlcpy(buf, path, sizeof(buf));
-  change_slashes_to_backslashes(buf);
-
-  // Point p to the end of the file name
-  p = buf + strlen(buf) - 1;
-
-  // Trim trailing backslash character
-  while (p > buf && *p == '\\' && p[-1] != ':') {
-    *p-- = '\0';
-  }
-
-   // Protect from CGI code disclosure.
-   // This is very nasty hole. Windows happily opens files with
-   // some garbage in the end of file name. So fopen("a.cgi    ", "r")
-   // actually opens "a.cgi", and does not return an error!
-  if (*p == 0x20 ||               // No space at the end
-      (*p == 0x2e && p > buf) ||  // No '.' but allow '.' as full path
-      *p == 0x2b ||               // No '+'
-      (*p & ~0x7f)) {             // And generally no non-ascii chars
-    (void) fprintf(stderr, "Rejecting suspicious path: [%s]", buf);
-    wbuf[0] = L'\0';
-  } else {
-    // Convert to Unicode and back. If doubly-converted string does not
-    // match the original, something is fishy, reject.
-    memset(wbuf, 0, wbuf_len * sizeof(wchar_t));
-    MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, (int) wbuf_len);
-    WideCharToMultiByte(CP_UTF8, 0, wbuf, (int) wbuf_len, buf2, sizeof(buf2),
-                        NULL, NULL);
-    if (strcmp(buf, buf2) != 0) {
-      wbuf[0] = L'\0';
-    }
-  }
-}
-
-#if defined(_WIN32_WCE)
-static time_t time(time_t *ptime) {
-  time_t t;
-  SYSTEMTIME st;
-  FILETIME ft;
-
-  GetSystemTime(&st);
-  SystemTimeToFileTime(&st, &ft);
-  t = SYS2UNIX_TIME(ft.dwLowDateTime, ft.dwHighDateTime);
-
-  if (ptime != NULL) {
-    *ptime = t;
-  }
-
-  return t;
-}
-
-static struct tm *localtime(const time_t *ptime, struct tm *ptm) {
-  int64_t t = ((int64_t) *ptime) * RATE_DIFF + EPOCH_DIFF;
-  FILETIME ft, lft;
-  SYSTEMTIME st;
-  TIME_ZONE_INFORMATION tzinfo;
-
-  if (ptm == NULL) {
-    return NULL;
-  }
-
-  * (int64_t *) &ft = t;
-  FileTimeToLocalFileTime(&ft, &lft);
-  FileTimeToSystemTime(&lft, &st);
-  ptm->tm_year = st.wYear - 1900;
-  ptm->tm_mon = st.wMonth - 1;
-  ptm->tm_wday = st.wDayOfWeek;
-  ptm->tm_mday = st.wDay;
-  ptm->tm_hour = st.wHour;
-  ptm->tm_min = st.wMinute;
-  ptm->tm_sec = st.wSecond;
-  ptm->tm_yday = 0; // hope nobody uses this
-  ptm->tm_isdst =
-    GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_DAYLIGHT ? 1 : 0;
-
-  return ptm;
-}
-
-static struct tm *gmtime(const time_t *ptime, struct tm *ptm) {
-  // FIXME(lsm): fix this.
-  return localtime(ptime, ptm);
-}
-
-static size_t strftime(char *dst, size_t dst_size, const char *fmt,
-                       const struct tm *tm) {
-  (void) snprintf(dst, dst_size, "implement strftime() for WinCE");
-  return 0;
-}
-#endif
-
-static int mg_rename(const char* oldname, const char* newname) {
-  wchar_t woldbuf[PATH_MAX];
-  wchar_t wnewbuf[PATH_MAX];
-
-  to_unicode(oldname, woldbuf, ARRAY_SIZE(woldbuf));
-  to_unicode(newname, wnewbuf, ARRAY_SIZE(wnewbuf));
-
-  return MoveFileW(woldbuf, wnewbuf) ? 0 : -1;
-}
-
-
-static FILE *mg_fopen(const char *path, const char *mode) {
-  wchar_t wbuf[PATH_MAX], wmode[20];
-
-  to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
-  MultiByteToWideChar(CP_UTF8, 0, mode, -1, wmode, ARRAY_SIZE(wmode));
-
-  return _wfopen(wbuf, wmode);
-}
-
-static int mg_stat(const char *path, struct mgstat *stp) {
-  int ok = -1; // Error
-  wchar_t wbuf[PATH_MAX];
-  WIN32_FILE_ATTRIBUTE_DATA info;
-
-  to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
-
-  if (GetFileAttributesExW(wbuf, GetFileExInfoStandard, &info) != 0) {
-    stp->size = MAKEUQUAD(info.nFileSizeLow, info.nFileSizeHigh);
-    stp->mtime = SYS2UNIX_TIME(info.ftLastWriteTime.dwLowDateTime,
-                               info.ftLastWriteTime.dwHighDateTime);
-    stp->is_directory =
-      info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
-    ok = 0;  // Success
-  }
-
-  return ok;
-}
-
-static int mg_remove(const char *path) {
-  wchar_t wbuf[PATH_MAX];
-  to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
-  return DeleteFileW(wbuf) ? 0 : -1;
-}
-
-static int mg_mkdir(const char *path, int mode) {
-  char buf[PATH_MAX];
-  wchar_t wbuf[PATH_MAX];
-
-  mode = 0; // Unused
-  mg_strlcpy(buf, path, sizeof(buf));
-  change_slashes_to_backslashes(buf);
-
-  (void) MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, sizeof(wbuf));
-
-  return CreateDirectoryW(wbuf, NULL) ? 0 : -1;
-}
-
-// Implementation of POSIX opendir/closedir/readdir for Windows.
-static DIR * opendir(const char *name) {
-  DIR *dir = NULL;
-  wchar_t wpath[PATH_MAX];
-  DWORD attrs;
-
-  if (name == NULL) {
-    SetLastError(ERROR_BAD_ARGUMENTS);
-  } else if ((dir = (DIR *) malloc(sizeof(*dir))) == NULL) {
-    SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-  } else {
-    to_unicode(name, wpath, ARRAY_SIZE(wpath));
-    attrs = GetFileAttributesW(wpath);
-    if (attrs != 0xFFFFFFFF &&
-        ((attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)) {
-      (void) wcscat(wpath, L"\\*");
-      dir->handle = FindFirstFileW(wpath, &dir->info);
-      dir->result.d_name[0] = '\0';
-    } else {
-      free(dir);
-      dir = NULL;
-    }
-  }
-
-  return dir;
-}
-
-static int closedir(DIR *dir) {
-  int result = 0;
-
-  if (dir != NULL) {
-    if (dir->handle != INVALID_HANDLE_VALUE)
-      result = FindClose(dir->handle) ? 0 : -1;
-
-    free(dir);
-  } else {
-    result = -1;
-    SetLastError(ERROR_BAD_ARGUMENTS);
-  }
-
-  return result;
-}
-
-static struct dirent *readdir(DIR *dir) {
-  struct dirent *result = 0;
-
-  if (dir) {
-    if (dir->handle != INVALID_HANDLE_VALUE) {
-      result = &dir->result;
-      (void) WideCharToMultiByte(CP_UTF8, 0,
-          dir->info.cFileName, -1, result->d_name,
-          sizeof(result->d_name), NULL, NULL);
-
-      if (!FindNextFileW(dir->handle, &dir->info)) {
-        (void) FindClose(dir->handle);
-        dir->handle = INVALID_HANDLE_VALUE;
-      }
-
-    } else {
-      SetLastError(ERROR_FILE_NOT_FOUND);
-    }
-  } else {
-    SetLastError(ERROR_BAD_ARGUMENTS);
-  }
-
-  return result;
-}
-
-#define set_close_on_exec(fd) // No FD_CLOEXEC on Windows
-
-static int start_thread(struct mg_context *ctx, mg_thread_func_t f, void *p) {
-  return _beginthread((void (__cdecl *)(void *)) f, 0, p) == -1L ? -1 : 0;
-}
-
-static HANDLE dlopen(const char *dll_name, int flags) {
-  wchar_t wbuf[PATH_MAX];
-  flags = 0; // Unused
-  to_unicode(dll_name, wbuf, ARRAY_SIZE(wbuf));
-  return LoadLibraryW(wbuf);
-}
-
-#if !defined(NO_CGI)
-#define SIGKILL 0
-static int kill(pid_t pid, int sig_num) {
-  (void) TerminateProcess(pid, sig_num);
-  (void) CloseHandle(pid);
-  return 0;
-}
-
-static pid_t spawn_process(struct mg_connection *conn, const char *prog,
-                           char *envblk, char *envp[], int fd_stdin,
-                           int fd_stdout, const char *dir) {
-  HANDLE me;
-  char *p, *interp, cmdline[PATH_MAX], buf[PATH_MAX];
-  FILE *fp;
-  STARTUPINFOA si = { sizeof(si) };
-  PROCESS_INFORMATION pi = { 0 };
-
-  envp = NULL; // Unused
-
-  // TODO(lsm): redirect CGI errors to the error log file
-  si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
-  si.wShowWindow = SW_HIDE;
-
-  me = GetCurrentProcess();
-  (void) DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdin), me,
-      &si.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
-  (void) DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdout), me,
-      &si.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
-
-  // If CGI file is a script, try to read the interpreter line
-  interp = conn->ctx->config[CGI_INTERPRETER];
-  if (interp == NULL) {
-    buf[2] = '\0';
-    mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%c%s", dir, DIRSEP, prog);
-    if ((fp = fopen(cmdline, "r")) != NULL) {
-      (void) fgets(buf, sizeof(buf), fp);
-      if (buf[0] != '#' || buf[1] != '!') {
-        // First line does not start with "#!". Do not set interpreter.
-        buf[2] = '\0';
-      } else {
-        // Trim whitespaces in interpreter name
-        for (p = &buf[strlen(buf) - 1]; p > buf && isspace(*p); p--) {
-          *p = '\0';
-        }
-      }
-      (void) fclose(fp);
-    }
-    interp = buf + 2;
-  }
-
-  (void) mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%s%s%c%s",
-                     interp, interp[0] == '\0' ? "" : " ", dir, DIRSEP, prog);
-
-  DEBUG_TRACE(("Running [%s]", cmdline));
-  if (CreateProcessA(NULL, cmdline, NULL, NULL, TRUE,
-        CREATE_NEW_PROCESS_GROUP, envblk, dir, &si, &pi) == 0) {
-    cry(conn, "%s: CreateProcess(%s): %d",
-        __func__, cmdline, ERRNO);
-    pi.hProcess = (pid_t) -1;
-  } else {
-    (void) close(fd_stdin);
-    (void) close(fd_stdout);
-  }
-
-  (void) CloseHandle(si.hStdOutput);
-  (void) CloseHandle(si.hStdInput);
-  (void) CloseHandle(pi.hThread);
-
-  return (pid_t) pi.hProcess;
-}
-#endif // !NO_CGI
-
-static int set_non_blocking_mode(SOCKET sock) {
-  unsigned long on = 1;
-  return ioctlsocket(sock, FIONBIO, &on);
-}
-
-#else
-static int mg_stat(const char *path, struct mgstat *stp) {
-  struct stat st;
-  int ok;
-
-  if (stat(path, &st) == 0) {
-    ok = 0;
-    stp->size = st.st_size;
-    stp->mtime = st.st_mtime;
-    stp->is_directory = S_ISDIR(st.st_mode);
-  } else {
-    ok = -1;
-  }
-
-  return ok;
-}
-
-static void set_close_on_exec(int fd) {
-  (void) fcntl(fd, F_SETFD, FD_CLOEXEC);
-}
-
-static int start_thread(struct mg_context *ctx, mg_thread_func_t func,
-                        void *param) {
-  pthread_t thread_id;
-  pthread_attr_t attr;
-  int retval;
-  char* stacksize = ctx->config[THREAD_STACK_SIZE];
-  char* priority = ctx->config[THREAD_PRIORITY];
-  char* policy = ctx->config[THREAD_POLICY];
-  int noinheritsched = 0;
-
-  (void) pthread_attr_init(&attr);
-  (void) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-  // TODO(lsm): figure out why mongoose dies on Linux if next line is enabled
-  // (void) pthread_attr_setstacksize(&attr, sizeof(struct mg_connection) * 5);
-
-  if (stacksize != NULL) {
-    size_t size = atoi(stacksize);
-    (void) pthread_attr_setstacksize(&attr, size);
-  }
-
-  if (priority != NULL) {
-    struct sched_param sched_param;
-    memset(&sched_param, 0, sizeof(sched_param));
-    sched_param.sched_priority = atoi(priority);
-    (void) pthread_attr_setschedparam(&attr, &sched_param);
-    noinheritsched = 1;
-  }
-
-  if (policy != NULL) {
-    int p_policy;
-    (void) pthread_attr_getschedpolicy(&attr, &p_policy);
-
-    switch (policy[0]) {
-      case 'o':
-        p_policy = SCHED_OTHER;
-        break;
-      case 'f':
-        p_policy = SCHED_FIFO;
-        break;
-      case 'r':
-        p_policy = SCHED_RR;
-        break;
-#if defined(_POSIX_SPORADIC_SERVER) || defined(_POSIX_THREAD_SPORADIC_SERVER)
-      case 's':
-        p_policy = SCHED_SPORADIC;
-        break;
-#endif
-      default:
-        cry(fc(ctx), "%s: Unknown scheduler: %s", __func__, policy);
-        break;
-    }
-
-    (void) pthread_attr_setschedpolicy(&attr, p_policy);
-
-    noinheritsched = 1;
-  }
-
-  if (noinheritsched != 0) {
-    (void) pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
-  }
-
-  if ((retval = pthread_create(&thread_id, &attr, func, param)) != 0) {
-    cry(fc(ctx), "%s: %s", __func__, strerror(retval));
-  }
-
-  return retval;
-}
-
-#ifndef NO_CGI
-static pid_t spawn_process(struct mg_connection *conn, const char *prog,
-                           char *envblk, char *envp[], int fd_stdin,
-                           int fd_stdout, const char *dir) {
-  pid_t pid;
-  const char *interp;
-
-  envblk = NULL; // Unused
-
-  if ((pid = fork()) == -1) {
-    // Parent
-    send_http_error(conn, 500, http_500_error, "fork(): %s", strerror(ERRNO));
-  } else if (pid == 0) {
-    // Child
-    if (chdir(dir) != 0) {
-      cry(conn, "%s: chdir(%s): %s", __func__, dir, strerror(ERRNO));
-    } else if (dup2(fd_stdin, 0) == -1) {
-      cry(conn, "%s: dup2(%d, 0): %s", __func__, fd_stdin, strerror(ERRNO));
-    } else if (dup2(fd_stdout, 1) == -1) {
-      cry(conn, "%s: dup2(%d, 1): %s", __func__, fd_stdout, strerror(ERRNO));
-    } else {
-      (void) dup2(fd_stdout, 2);
-      (void) close(fd_stdin);
-      (void) close(fd_stdout);
-
-      // Execute CGI program. No need to lock: new process
-      interp = conn->ctx->config[CGI_INTERPRETER];
-      if (interp == NULL) {
-        (void) execle(prog, prog, NULL, envp);
-        cry(conn, "%s: execle(%s): %s", __func__, prog, strerror(ERRNO));
-      } else {
-        (void) execle(interp, interp, prog, NULL, envp);
-        cry(conn, "%s: execle(%s %s): %s", __func__, interp, prog,
-            strerror(ERRNO));
-      }
-    }
-    exit(EXIT_FAILURE);
-  } else {
-    // Parent. Close stdio descriptors
-    (void) close(fd_stdin);
-    (void) close(fd_stdout);
-  }
-
-  return pid;
-}
-#endif // !NO_CGI
-
-static int set_non_blocking_mode(SOCKET sock) {
-  int flags;
-
-  flags = fcntl(sock, F_GETFL, 0);
-  (void) fcntl(sock, F_SETFL, flags | O_NONBLOCK);
-
-  return 0;
-}
-#endif // _WIN32
-
-// Write data to the IO channel - opened file descriptor, socket or SSL
-// descriptor. Return number of bytes written.
-static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf,
-                    int64_t len) {
-  int64_t sent;
-  int n, k;
-
-  sent = 0;
-  while (sent < len) {
-
-    // How many bytes we send in this iteration
-    k = len - sent > INT_MAX ? INT_MAX : (int) (len - sent);
-
-    if (ssl != NULL) {
-      n = SSL_write(ssl, buf + sent, k);
-    } else if (fp != NULL) {
-      n = fwrite(buf + sent, 1, (size_t) k, fp);
-      if (ferror(fp))
-        n = -1;
-    } else {
-      n = send(sock, buf + sent, (size_t) k, MSG_NOSIGNAL);
-    }
-
-    if (n < 0)
-      break;
-
-    sent += n;
-  }
-
-  return sent;
-}
-
-// Read from IO channel - opened file descriptor, socket, or SSL descriptor.
-// Return number of bytes read.
-static int pull(FILE *fp, SOCKET sock, SSL *ssl, char *buf, int len) {
-  int nread;
-
-  if (ssl != NULL) {
-    nread = SSL_read(ssl, buf, len);
-  } else if (fp != NULL) {
-    // Use read() instead of fread(), because if we're reading from the CGI
-    // pipe, fread() may block until IO buffer is filled up. We cannot afford
-    // to block and must pass all read bytes immediately to the client.
-    nread = read(fileno(fp), buf, (size_t) len);
-    if (ferror(fp))
-      nread = -1;
-  } else {
-    nread = recv(sock, buf, (size_t) len, 0);
-  }
-
-  return nread;
-}
-
-int mg_read(struct mg_connection *conn, void *buf, size_t len) {
-  int n, buffered_len, nread;
-  const char *buffered;
-
-  assert((conn->content_len == -1 && conn->consumed_content == 0) ||
-         conn->consumed_content <= conn->content_len);
-  DEBUG_TRACE(("%p %zu %lld %lld", buf, len,
-               conn->content_len, conn->consumed_content));
-  nread = 0;
-  if (conn->consumed_content < conn->content_len) {
-
-    // Adjust number of bytes to read.
-    int64_t to_read = conn->content_len - conn->consumed_content;
-    if (to_read < (int64_t) len) {
-      len = (int) to_read;
-    }
-
-    // How many bytes of data we have buffered in the request buffer?
-    buffered = conn->buf + conn->request_len + conn->consumed_content;
-    buffered_len = conn->data_len - conn->request_len;
-    assert(buffered_len >= 0);
-
-    // Return buffered data back if we haven't done that yet.
-    if (conn->consumed_content < (int64_t) buffered_len) {
-      buffered_len -= (int) conn->consumed_content;
-      if (len < (size_t) buffered_len) {
-        buffered_len = len;
-      }
-      memcpy(buf, buffered, (size_t)buffered_len);
-      len -= buffered_len;
-      buf = (char *) buf + buffered_len;
-      conn->consumed_content += buffered_len;
-      nread = buffered_len;
-    }
-
-    // We have returned all buffered data. Read new data from the remote socket.
-    while (len > 0) {
-      n = pull(NULL, conn->client.sock, conn->ssl, (char *) buf, (int) len);
-      if (n <= 0) {
-        break;
-      }
-      buf = (char *) buf + n;
-      conn->consumed_content += n;
-      nread += n;
-      len -= n;
-    }
-  }
-  return nread;
-}
-
-int mg_write(struct mg_connection *conn, const void *buf, size_t len) {
-  return (int) push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
-                    (int64_t) len);
-}
-
-int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
-  char buf[BUFSIZ];
-  int len;
-  va_list ap;
-
-  va_start(ap, fmt);
-  len = mg_vsnprintf(conn, buf, sizeof(buf), fmt, ap);
-  va_end(ap);
-
-  return mg_write(conn, buf, (size_t)len);
-}
-
-// URL-decode input buffer into destination buffer.
-// 0-terminate the destination buffer. Return the length of decoded data.
-// form-url-encoded data differs from URI encoding in a way that it
-// uses '+' as character for space, see RFC 1866 section 8.2.1
-// http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt
-static size_t url_decode(const char *src, size_t src_len, char *dst,
-                         size_t dst_len, int is_form_url_encoded) {
-  size_t i, j;
-  int a, b;
-#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
-
-  for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) {
-    if (src[i] == '%' &&
-        isxdigit(* (const unsigned char *) (src + i + 1)) &&
-        isxdigit(* (const unsigned char *) (src + i + 2))) {
-      a = tolower(* (const unsigned char *) (src + i + 1));
-      b = tolower(* (const unsigned char *) (src + i + 2));
-      dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b));
-      i += 2;
-    } else if (is_form_url_encoded && src[i] == '+') {
-      dst[j] = ' ';
-    } else {
-      dst[j] = src[i];
-    }
-  }
-
-  dst[j] = '\0'; // Null-terminate the destination
-
-  return j;
-}
-
-// Scan given buffer and fetch the value of the given variable.
-// It can be specified in query string, or in the POST data.
-// Return NULL if the variable not found, or allocated 0-terminated value.
-// It is caller's responsibility to free the returned value.
-int mg_get_var(const char *buf, size_t buf_len, const char *name,
-               char *dst, size_t dst_len) {
-  const char *p, *e, *s;
-  size_t name_len, len;
-
-  name_len = strlen(name);
-  e = buf + buf_len;
-  len = -1;
-  dst[0] = '\0';
-
-  // buf is "var1=val1&var2=val2...". Find variable first
-  for (p = buf; p != NULL && p + name_len < e; p++) {
-    if ((p == buf || p[-1] == '&') && p[name_len] == '=' &&
-        !mg_strncasecmp(name, p, name_len)) {
-
-      // Point p to variable value
-      p += name_len + 1;
-
-      // Point s to the end of the value
-      s = (const char *) memchr(p, '&', (size_t)(e - p));
-      if (s == NULL) {
-        s = e;
-      }
-      assert(s >= p);
-
-      // Decode variable into destination buffer
-      if ((size_t) (s - p) < dst_len) {
-        len = url_decode(p, (size_t)(s - p), dst, dst_len, 1);
-      }
-      break;
-    }
-  }
-
-  return len;
-}
-
-int mg_get_cookie(const struct mg_connection *conn, const char *cookie_name,
-                  char *dst, size_t dst_size) {
-  const char *s, *p, *end;
-  int name_len, len = -1;
-
-  dst[0] = '\0';
-  if ((s = mg_get_header(conn, "Cookie")) == NULL) {
-    return 0;
-  }
-
-  name_len = strlen(cookie_name);
-  end = s + strlen(s);
-
-  for (; (s = strstr(s, cookie_name)) != NULL; s += name_len)
-    if (s[name_len] == '=') {
-      s += name_len + 1;
-      if ((p = strchr(s, ' ')) == NULL)
-        p = end;
-      if (p[-1] == ';')
-        p--;
-      if (*s == '"' && p[-1] == '"' && p > s + 1) {
-        s++;
-        p--;
-      }
-      if ((size_t) (p - s) < dst_size) {
-        len = (p - s) + 1;
-        mg_strlcpy(dst, s, (size_t)len);
-      }
-      break;
-    }
-
-  return len;
-}
-
-static int convert_uri_to_file_name(struct mg_connection *conn, char *buf,
-                                    size_t buf_len, struct mgstat *st) {
-  struct vec a, b;
-  const char *rewrite, *uri = conn->request_info.uri;
-  char *p;
-  int match_len, stat_result;
-
-  buf_len--;  // This is because memmove() for PATH_INFO may shift part
-              // of the path one byte on the right.
-  mg_snprintf(conn, buf, buf_len, "%s%s", conn->ctx->config[DOCUMENT_ROOT],
-              uri);
-
-  rewrite = conn->ctx->config[REWRITE];
-  while ((rewrite = next_option(rewrite, &a, &b)) != NULL) {
-    if ((match_len = match_prefix(a.ptr, a.len, uri)) > 0) {
-      mg_snprintf(conn, buf, buf_len, "%.*s%s", b.len, b.ptr, uri + match_len);
-      break;
-    }
-  }
-
-#if defined(_WIN32) && !defined(__SYMBIAN32__)
-  //change_slashes_to_backslashes(buf);
-#endif // _WIN32
-
-  if ((stat_result = mg_stat(buf, st)) != 0) {
-    // Support PATH_INFO for CGI scripts.
-    for (p = buf + strlen(buf); p > buf + 1; p--) {
-      if (*p == '/') {
-        *p = '\0';
-        if (match_prefix(conn->ctx->config[CGI_EXTENSIONS],
-                         strlen(conn->ctx->config[CGI_EXTENSIONS]), buf) > 0 &&
-            (stat_result = mg_stat(buf, st)) == 0) {
-          // Shift PATH_INFO block one character right, e.g.
-          //  "/x.cgi/foo/bar\x00" => "/x.cgi\x00/foo/bar\x00"
-          // conn->path_info is pointing to the local variable "path" declared
-          // in handle_request(), so PATH_INFO not valid after
-          // handle_request returns.
-          conn->path_info = p + 1;
-          memmove(p + 2, p + 1, strlen(p + 1) + 1);  // +1 is for trailing \0
-          p[1] = '/';
-          break;
-        } else {
-          *p = '/';
-          stat_result = -1;
-        }
-      }
-    }
-  }
-
-  return stat_result;
-}
-
-static int sslize(struct mg_connection *conn, int (*func)(SSL *)) {
-  return (conn->ssl = SSL_new(conn->ctx->ssl_ctx)) != NULL &&
-    SSL_set_fd(conn->ssl, conn->client.sock) == 1 &&
-    func(conn->ssl) == 1;
-}
-
-// Check whether full request is buffered. Return:
-//   -1  if request is malformed
-//    0  if request is not yet fully buffered
-//   >0  actual request length, including last \r\n\r\n
-static int get_request_len(const char *buf, int buflen) {
-  const char *s, *e;
-  int len = 0;
-
-  DEBUG_TRACE(("buf: %p, len: %d", buf, buflen));
-  for (s = buf, e = s + buflen - 1; len <= 0 && s < e; s++)
-    // Control characters are not allowed but >=128 is.
-    if (!isprint(* (const unsigned char *) s) && *s != '\r' &&
-        *s != '\n' && * (const unsigned char *) s < 128) {
-      len = -1;
-    } else if (s[0] == '\n' && s[1] == '\n') {
-      len = (int) (s - buf) + 2;
-    } else if (s[0] == '\n' && &s[1] < e &&
-        s[1] == '\r' && s[2] == '\n') {
-      len = (int) (s - buf) + 3;
-    }
-
-  return len;
-}
-
-// Convert month to the month number. Return -1 on error, or month number
-static int get_month_index(const char *s) {
-  size_t i;
-
-  for (i = 0; i < ARRAY_SIZE(month_names); i++)
-    if (!strcmp(s, month_names[i]))
-      return (int) i;
-
-  return -1;
-}
-
-// Parse UTC date-time string, and return the corresponding time_t value.
-static time_t parse_date_string(const char *datetime) {
-  static const unsigned short days_before_month[] = {
-    0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
-  };
-  char month_str[32];
-  int second, minute, hour, day, month, year, leap_days, days;
-  time_t result = (time_t) 0;
-
-  if (((sscanf(datetime, "%d/%3s/%d %d:%d:%d",
-               &day, month_str, &year, &hour, &minute, &second) == 6) ||
-       (sscanf(datetime, "%d %3s %d %d:%d:%d",
-               &day, month_str, &year, &hour, &minute, &second) == 6) ||
-       (sscanf(datetime, "%*3s, %d %3s %d %d:%d:%d",
-               &day, month_str, &year, &hour, &minute, &second) == 6) ||
-       (sscanf(datetime, "%d-%3s-%d %d:%d:%d",
-               &day, month_str, &year, &hour, &minute, &second) == 6)) &&
-      year > 1970 &&
-      (month = get_month_index(month_str)) != -1) {
-    year -= 1970;
-    leap_days = year / 4 - year / 100 + year / 400;
-    days = year * 365 + days_before_month[month] + (day - 1) + leap_days;
-    result = days * 24 * 3600 + hour * 3600 + minute * 60 + second;
-  }
-
-  return result;
-}
-
-// Protect against directory disclosure attack by removing '..',
-// excessive '/' and '\' characters
-static void remove_double_dots_and_double_slashes(char *s) {
-  char *p = s;
-
-  while (*s != '\0') {
-    *p++ = *s++;
-    if (IS_DIRSEP_CHAR(s[-1])) {
-      // Skip all following slashes and backslashes
-      while (IS_DIRSEP_CHAR(s[0])) {
-        s++;
-      }
-
-      // Skip all double-dots
-      while (*s == '.' && s[1] == '.') {
-        s += 2;
-      }
-    }
-  }
-  *p = '\0';
-}
-
-static const struct {
-  const char *extension;
-  size_t ext_len;
-  const char *mime_type;
-  size_t mime_type_len;
-} builtin_mime_types[] = {
-  {".html", 5, "text/html",   9},
-  {".htm", 4, "text/html",   9},
-  {".shtm", 5, "text/html",   9},
-  {".shtml", 6, "text/html",   9},
-  {".css", 4, "text/css",   8},
-  {".js",  3, "application/x-javascript", 24},
-  {".ico", 4, "image/x-icon",   12},
-  {".gif", 4, "image/gif",   9},
-  {".jpg", 4, "image/jpeg",   10},
-  {".jpeg", 5, "image/jpeg",   10},
-  {".png", 4, "image/png",   9},
-  {".svg", 4, "image/svg+xml",  13},
-  {".torrent", 8, "application/x-bittorrent", 24},
-  {".wav", 4, "audio/x-wav",   11},
-  {".mp3", 4, "audio/x-mp3",   11},
-  {".mid", 4, "audio/mid",   9},
-  {".m3u", 4, "audio/x-mpegurl",  15},
-  {".ram", 4, "audio/x-pn-realaudio",  20},
-  {".xml", 4, "text/xml",   8},
-  {".xslt", 5, "application/xml",  15},
-  {".ra",  3, "audio/x-pn-realaudio",  20},
-  {".doc", 4, "application/msword",  19},
-  {".exe", 4, "application/octet-stream", 24},
-  {".zip", 4, "application/x-zip-compressed", 28},
-  {".xls", 4, "application/excel",  17},
-  {".tgz", 4, "application/x-tar-gz",  20},
-  {".tar", 4, "application/x-tar",  17},
-  {".gz",  3, "application/x-gunzip",  20},
-  {".arj", 4, "application/x-arj-compressed", 28},
-  {".rar", 4, "application/x-arj-compressed", 28},
-  {".rtf", 4, "application/rtf",  15},
-  {".pdf", 4, "application/pdf",  15},
-  {".swf", 4, "application/x-shockwave-flash",29},
-  {".mpg", 4, "video/mpeg",   10},
-  {".mpeg", 5, "video/mpeg",   10},
-  {".mp4", 4, "video/mp4", 9},
-  {".m4v", 4, "video/x-m4v", 11},
-  {".asf", 4, "video/x-ms-asf",  14},
-  {".avi", 4, "video/x-msvideo",  15},
-  {".bmp", 4, "image/bmp",   9},
-  {NULL,  0, NULL,    0}
-};
-
-// Look at the "path" extension and figure what mime type it has.
-// Store mime type in the vector.
-static void get_mime_type(struct mg_context *ctx, const char *path,
-                          struct vec *vec) {
-  struct vec ext_vec, mime_vec;
-  const char *list, *ext;
-  size_t i, path_len;
-
-  path_len = strlen(path);
-
-  // Scan user-defined mime types first, in case user wants to
-  // override default mime types.
-  list = ctx->config[EXTRA_MIME_TYPES];
-  while ((list = next_option(list, &ext_vec, &mime_vec)) != NULL) {
-    // ext now points to the path suffix
-    ext = path + path_len - ext_vec.len;
-    if (mg_strncasecmp(ext, ext_vec.ptr, ext_vec.len) == 0) {
-      *vec = mime_vec;
-      return;
-    }
-  }
-
-  // Now scan built-in mime types
-  for (i = 0; builtin_mime_types[i].extension != NULL; i++) {
-    ext = path + (path_len - builtin_mime_types[i].ext_len);
-    if (path_len > builtin_mime_types[i].ext_len &&
-        mg_strcasecmp(ext, builtin_mime_types[i].extension) == 0) {
-      vec->ptr = builtin_mime_types[i].mime_type;
-      vec->len = builtin_mime_types[i].mime_type_len;
-      return;
-    }
-  }
-
-  // Nothing found. Fall back to "text/plain"
-  vec->ptr = "text/plain";
-  vec->len = 10;
-}
-
-#ifndef HAVE_MD5
-typedef struct MD5Context {
-  uint32_t buf[4];
-  uint32_t bits[2];
-  unsigned char in[64];
-} MD5_CTX;
-
-#if defined(__BYTE_ORDER) && (__BYTE_ORDER == 1234)
-#define byteReverse(buf, len) // Do nothing
-#else
-static void byteReverse(unsigned char *buf, unsigned longs) {
-  uint32_t t;
-  do {
-    t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
-      ((unsigned) buf[1] << 8 | buf[0]);
-    *(uint32_t *) buf = t;
-    buf += 4;
-  } while (--longs);
-}
-#endif
-
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-#define MD5STEP(f, w, x, y, z, data, s) \
-  ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
-
-// Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
-// initialization constants.
-static void MD5Init(MD5_CTX *ctx) {
-  ctx->buf[0] = 0x67452301;
-  ctx->buf[1] = 0xefcdab89;
-  ctx->buf[2] = 0x98badcfe;
-  ctx->buf[3] = 0x10325476;
-
-  ctx->bits[0] = 0;
-  ctx->bits[1] = 0;
-}
-
-static void MD5Transform(uint32_t buf[4], uint32_t const in[16]) {
-  register uint32_t a, b, c, d;
-
-  a = buf[0];
-  b = buf[1];
-  c = buf[2];
-  d = buf[3];
-
-  MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
-  MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
-  MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
-  MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
-  MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
-  MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
-  MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
-  MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
-  MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
-  MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
-  MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
-  MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
-  MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
-  MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
-  MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
-  MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
-  MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
-  MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
-  MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
-  MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
-  MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
-  MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
-  MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
-  MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
-  MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
-  MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
-  MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
-  MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
-  MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
-  MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
-  MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
-  MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
-  MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
-  MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
-  MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
-  MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
-  MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
-  MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
-  MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
-  MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
-  MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
-  MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
-  MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
-  MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
-  MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
-  MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
-  MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
-  MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
-  MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
-  MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
-  MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
-  MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
-  MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
-  MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
-  MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
-  MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
-  MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
-  MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
-  MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
-  MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
-  MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
-  MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
-  MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
-  MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
-  buf[0] += a;
-  buf[1] += b;
-  buf[2] += c;
-  buf[3] += d;
-}
-
-static void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len) {
-  uint32_t t;
-
-  t = ctx->bits[0];
-  if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
-    ctx->bits[1]++;
-  ctx->bits[1] += len >> 29;
-
-  t = (t >> 3) & 0x3f;
-
-  if (t) {
-    unsigned char *p = (unsigned char *) ctx->in + t;
-
-    t = 64 - t;
-    if (len < t) {
-      memcpy(p, buf, len);
-      return;
-    }
-    memcpy(p, buf, t);
-    byteReverse(ctx->in, 16);
-    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-    buf += t;
-    len -= t;
-  }
-
-  while (len >= 64) {
-    memcpy(ctx->in, buf, 64);
-    byteReverse(ctx->in, 16);
-    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-    buf += 64;
-    len -= 64;
-  }
-
-  memcpy(ctx->in, buf, len);
-}
-
-static void MD5Final(unsigned char digest[16], MD5_CTX *ctx) {
-  unsigned count;
-  unsigned char *p;
-
-  count = (ctx->bits[0] >> 3) & 0x3F;
-
-  p = ctx->in + count;
-  *p++ = 0x80;
-  count = 64 - 1 - count;
-  if (count < 8) {
-    memset(p, 0, count);
-    byteReverse(ctx->in, 16);
-    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-    memset(ctx->in, 0, 56);
-  } else {
-    memset(p, 0, count - 8);
-  }
-  byteReverse(ctx->in, 14);
-
-  ((uint32_t *) ctx->in)[14] = ctx->bits[0];
-  ((uint32_t *) ctx->in)[15] = ctx->bits[1];
-
-  MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-  byteReverse((unsigned char *) ctx->buf, 4);
-  memcpy(digest, ctx->buf, 16);
-  memset((char *) ctx, 0, sizeof(*ctx));
-}
-#endif // !HAVE_MD5
-
-// Stringify binary data. Output buffer must be twice as big as input,
-// because each byte takes 2 bytes in string representation
-static void bin2str(char *to, const unsigned char *p, size_t len) {
-  static const char *hex = "0123456789abcdef";
-
-  for (; len--; p++) {
-    *to++ = hex[p[0] >> 4];
-    *to++ = hex[p[0] & 0x0f];
-  }
-  *to = '\0';
-}
-
-// Return stringified MD5 hash for list of vectors. Buffer must be 33 bytes.
-void mg_md5(char *buf, ...) {
-  unsigned char hash[16];
-  const char *p;
-  va_list ap;
-  MD5_CTX ctx;
-
-  MD5Init(&ctx);
-
-  va_start(ap, buf);
-  while ((p = va_arg(ap, const char *)) != NULL) {
-    MD5Update(&ctx, (const unsigned char *) p, (unsigned) strlen(p));
-  }
-  va_end(ap);
-
-  MD5Final(hash, &ctx);
-  bin2str(buf, hash, sizeof(hash));
-}
-
-// Check the user's password, return 1 if OK
-static int check_password(const char *method, const char *ha1, const char *uri,
-                          const char *nonce, const char *nc, const char *cnonce,
-                          const char *qop, const char *response) {
-  char ha2[32 + 1], expected_response[32 + 1];
-
-  // Some of the parameters may be NULL
-  if (method == NULL || nonce == NULL || nc == NULL || cnonce == NULL ||
-      qop == NULL || response == NULL) {
-    return 0;
-  }
-
-  // NOTE(lsm): due to a bug in MSIE, we do not compare the URI
-  // TODO(lsm): check for authentication timeout
-  if (// strcmp(dig->uri, c->ouri) != 0 ||
-      strlen(response) != 32
-      // || now - strtoul(dig->nonce, NULL, 10) > 3600
-      ) {
-    return 0;
-  }
-
-  mg_md5(ha2, method, ":", uri, NULL);
-  mg_md5(expected_response, ha1, ":", nonce, ":", nc,
-      ":", cnonce, ":", qop, ":", ha2, NULL);
-
-  return mg_strcasecmp(response, expected_response) == 0;
-}
-
-// Use the global passwords file, if specified by auth_gpass option,
-// or search for .htpasswd in the requested directory.
-static FILE *open_auth_file(struct mg_connection *conn, const char *path) {
-  struct mg_context *ctx = conn->ctx;
-  char name[PATH_MAX];
-  const char *p, *e;
-  struct mgstat st;
-  FILE *fp;
-
-  if (ctx->config[GLOBAL_PASSWORDS_FILE] != NULL) {
-    // Use global passwords file
-    fp =  mg_fopen(ctx->config[GLOBAL_PASSWORDS_FILE], "r");
-    if (fp == NULL)
-      cry(fc(ctx), "fopen(%s): %s",
-          ctx->config[GLOBAL_PASSWORDS_FILE], strerror(ERRNO));
-  } else if (!mg_stat(path, &st) && st.is_directory) {
-    (void) mg_snprintf(conn, name, sizeof(name), "%s%c%s",
-        path, DIRSEP, PASSWORDS_FILE_NAME);
-    fp = mg_fopen(name, "r");
-  } else {
-     // Try to find .htpasswd in requested directory.
-    for (p = path, e = p + strlen(p) - 1; e > p; e--)
-      if (IS_DIRSEP_CHAR(*e))
-        break;
-    (void) mg_snprintf(conn, name, sizeof(name), "%.*s%c%s",
-        (int) (e - p), p, DIRSEP, PASSWORDS_FILE_NAME);
-    fp = mg_fopen(name, "r");
-  }
-
-  return fp;
-}
-
-// Parsed Authorization header
-struct ah {
-  char *user, *uri, *cnonce, *response, *qop, *nc, *nonce;
-};
-
-static int parse_auth_header(struct mg_connection *conn, char *buf,
-                             size_t buf_size, struct ah *ah) {
-  char *name, *value, *s;
-  const char *auth_header;
-
-  if ((auth_header = mg_get_header(conn, "Authorization")) == NULL ||
-      mg_strncasecmp(auth_header, "Digest ", 7) != 0) {
-    return 0;
-  }
-
-  // Make modifiable copy of the auth header
-  (void) mg_strlcpy(buf, auth_header + 7, buf_size);
-
-  s = buf;
-  (void) memset(ah, 0, sizeof(*ah));
-
-  // Parse authorization header
-  for (;;) {
-    // Gobble initial spaces
-    while (isspace(* (unsigned char *) s)) {
-      s++;
-    }
-    name = skip_quoted(&s, "=", " ", 0);
-    // Value is either quote-delimited, or ends at first comma or space.
-    if (s[0] == '\"') {
-      s++;
-      value = skip_quoted(&s, "\"", " ", '\\');
-      if (s[0] == ',') {
-        s++;
-      }
-    } else {
-      value = skip_quoted(&s, ", ", " ", 0);  // IE uses commas, FF uses spaces
-    }
-    if (*name == '\0') {
-      break;
-    }
-
-    if (!strcmp(name, "username")) {
-      ah->user = value;
-    } else if (!strcmp(name, "cnonce")) {
-      ah->cnonce = value;
-    } else if (!strcmp(name, "response")) {
-      ah->response = value;
-    } else if (!strcmp(name, "uri")) {
-      ah->uri = value;
-    } else if (!strcmp(name, "qop")) {
-      ah->qop = value;
-    } else if (!strcmp(name, "nc")) {
-      ah->nc = value;
-    } else if (!strcmp(name, "nonce")) {
-      ah->nonce = value;
-    }
-  }
-
-  // CGI needs it as REMOTE_USER
-  if (ah->user != NULL) {
-    conn->request_info.remote_user = mg_strdup(ah->user);
-  } else {
-    return 0;
-  }
-
-  return 1;
-}
-
-// Authorize against the opened passwords file. Return 1 if authorized.
-static int authorize(struct mg_connection *conn, FILE *fp) {
-  struct ah ah;
-  char line[256], f_user[256], ha1[256], f_domain[256], buf[BUFSIZ];
-
-  if (!parse_auth_header(conn, buf, sizeof(buf), &ah)) {
-    return 0;
-  }
-
-  // Loop over passwords file
-  while (fgets(line, sizeof(line), fp) != NULL) {
-    if (sscanf(line, "%[^:]:%[^:]:%s", f_user, f_domain, ha1) != 3) {
-      continue;
-    }
-
-    if (!strcmp(ah.user, f_user) &&
-        !strcmp(conn->ctx->config[AUTHENTICATION_DOMAIN], f_domain))
-      return check_password(
-            conn->request_info.request_method,
-            ha1, ah.uri, ah.nonce, ah.nc, ah.cnonce, ah.qop,
-            ah.response);
-  }
-
-  return 0;
-}
-
-// Return 1 if request is authorised, 0 otherwise.
-static int check_authorization(struct mg_connection *conn, const char *path) {
-  FILE *fp;
-  char fname[PATH_MAX];
-  struct vec uri_vec, filename_vec;
-  const char *list;
-  int authorized;
-
-  fp = NULL;
-  authorized = 1;
-
-  list = conn->ctx->config[PROTECT_URI];
-  while ((list = next_option(list, &uri_vec, &filename_vec)) != NULL) {
-    if (!memcmp(conn->request_info.uri, uri_vec.ptr, uri_vec.len)) {
-      (void) mg_snprintf(conn, fname, sizeof(fname), "%.*s",
-          filename_vec.len, filename_vec.ptr);
-      if ((fp = mg_fopen(fname, "r")) == NULL) {
-        cry(conn, "%s: cannot open %s: %s", __func__, fname, strerror(errno));
-      }
-      break;
-    }
-  }
-
-  if (fp == NULL) {
-    fp = open_auth_file(conn, path);
-  }
-
-  if (fp != NULL) {
-    authorized = authorize(conn, fp);
-    (void) fclose(fp);
-  }
-
-  return authorized;
-}
-
-static void send_authorization_request(struct mg_connection *conn) {
-  conn->request_info.status_code = 401;
-  (void) mg_printf(conn,
-      "HTTP/1.1 401 Unauthorized\r\n"
-      "Content-Length: 0\r\n"
-      "WWW-Authenticate: Digest qop=\"auth\", "
-      "realm=\"%s\", nonce=\"%lu\"\r\n\r\n",
-      conn->ctx->config[AUTHENTICATION_DOMAIN],
-      (unsigned long) time(NULL));
-}
-
-static int is_authorized_for_put(struct mg_connection *conn) {
-  FILE *fp;
-  int ret = 0;
-
-  fp = conn->ctx->config[PUT_DELETE_PASSWORDS_FILE] == NULL ? NULL :
-    mg_fopen(conn->ctx->config[PUT_DELETE_PASSWORDS_FILE], "r");
-
-  if (fp != NULL) {
-    ret = authorize(conn, fp);
-    (void) fclose(fp);
-  }
-
-  return ret;
-}
-
-int mg_modify_passwords_file(const char *fname, const char *domain,
-                             const char *user, const char *pass) {
-  int found;
-  char line[512], u[512], d[512], ha1[33], tmp[PATH_MAX];
-  FILE *fp, *fp2;
-
-  found = 0;
-  fp = fp2 = NULL;
-
-  // Regard empty password as no password - remove user record.
-  if (pass != NULL && pass[0] == '\0') {
-    pass = NULL;
-  }
-
-  (void) snprintf(tmp, sizeof(tmp), "%s.tmp", fname);
-
-  // Create the file if does not exist
-  if ((fp = mg_fopen(fname, "a+")) != NULL) {
-    (void) fclose(fp);
-  }
-
-  // Open the given file and temporary file
-  if ((fp = mg_fopen(fname, "r")) == NULL) {
-    return 0;
-  } else if ((fp2 = mg_fopen(tmp, "w+")) == NULL) {
-    fclose(fp);
-    return 0;
-  }
-
-  // Copy the stuff to temporary file
-  while (fgets(line, sizeof(line), fp) != NULL) {
-    if (sscanf(line, "%[^:]:%[^:]:%*s", u, d) != 2) {
-      continue;
-    }
-
-    if (!strcmp(u, user) && !strcmp(d, domain)) {
-      found++;
-      if (pass != NULL) {
-        mg_md5(ha1, user, ":", domain, ":", pass, NULL);
-        fprintf(fp2, "%s:%s:%s\n", user, domain, ha1);
-      }
-    } else {
-      (void) fprintf(fp2, "%s", line);
-    }
-  }
-
-  // If new user, just add it
-  if (!found && pass != NULL) {
-    mg_md5(ha1, user, ":", domain, ":", pass, NULL);
-    (void) fprintf(fp2, "%s:%s:%s\n", user, domain, ha1);
-  }
-
-  // Close files
-  (void) fclose(fp);
-  (void) fclose(fp2);
-
-  // Put the temp file in place of real file
-  (void) mg_remove(fname);
-  (void) mg_rename(tmp, fname);
-
-  return 1;
-}
-
-struct de {
-  struct mg_connection *conn;
-  char *file_name;
-  struct mgstat st;
-};
-
-static void url_encode(const char *src, char *dst, size_t dst_len) {
-  static const char *dont_escape = "._-$,;~()";
-  static const char *hex = "0123456789abcdef";
-  const char *end = dst + dst_len - 1;
-
-  for (; *src != '\0' && dst < end; src++, dst++) {
-    if (isalnum(*(const unsigned char *) src) ||
-        strchr(dont_escape, * (const unsigned char *) src) != NULL) {
-      *dst = *src;
-    } else if (dst + 2 < end) {
-      dst[0] = '%';
-      dst[1] = hex[(* (const unsigned char *) src) >> 4];
-      dst[2] = hex[(* (const unsigned char *) src) & 0xf];
-      dst += 2;
-    }
-  }
-
-  *dst = '\0';
-}
-
-static void print_dir_entry(struct de *de) {
-  char size[64], mod[64], href[PATH_MAX];
-
-  if (de->st.is_directory) {
-    (void) mg_snprintf(de->conn, size, sizeof(size), "%s", "[DIRECTORY]");
-  } else {
-     // We use (signed) cast below because MSVC 6 compiler cannot
-     // convert unsigned __int64 to double. Sigh.
-    if (de->st.size < 1024) {
-      (void) mg_snprintf(de->conn, size, sizeof(size),
-          "%lu", (unsigned long) de->st.size);
-    } else if (de->st.size < 1024 * 1024) {
-      (void) mg_snprintf(de->conn, size, sizeof(size),
-          "%.1fk", (double) de->st.size / 1024.0);
-    } else if (de->st.size < 1024 * 1024 * 1024) {
-      (void) mg_snprintf(de->conn, size, sizeof(size),
-          "%.1fM", (double) de->st.size / 1048576);
-    } else {
-      (void) mg_snprintf(de->conn, size, sizeof(size),
-          "%.1fG", (double) de->st.size / 1073741824);
-    }
-  }
-  (void) strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M", localtime(&de->st.mtime));
-  url_encode(de->file_name, href, sizeof(href));
-  de->conn->num_bytes_sent += mg_printf(de->conn,
-      "<tr><td><a href=\"%s%s%s\">%s%s</a></td>"
-      "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
-      de->conn->request_info.uri, href, de->st.is_directory ? "/" : "",
-      de->file_name, de->st.is_directory ? "/" : "", mod, size);
-}
-
-// This function is called from send_directory() and used for
-// sorting directory entries by size, or name, or modification time.
-// On windows, __cdecl specification is needed in case if project is built
-// with __stdcall convention. qsort always requires __cdels callback.
-static int WINCDECL compare_dir_entries(const void *p1, const void *p2) {
-  const struct de *a = (const struct de *) p1, *b = (const struct de *) p2;
-  const char *query_string = a->conn->request_info.query_string;
-  int cmp_result = 0;
-
-  if (query_string == NULL) {
-    query_string = "na";
-  }
-
-  if (a->st.is_directory && !b->st.is_directory) {
-    return -1;  // Always put directories on top
-  } else if (!a->st.is_directory && b->st.is_directory) {
-    return 1;   // Always put directories on top
-  } else if (*query_string == 'n') {
-    cmp_result = strcmp(a->file_name, b->file_name);
-  } else if (*query_string == 's') {
-    cmp_result = a->st.size == b->st.size ? 0 :
-      a->st.size > b->st.size ? 1 : -1;
-  } else if (*query_string == 'd') {
-    cmp_result = a->st.mtime == b->st.mtime ? 0 :
-      a->st.mtime > b->st.mtime ? 1 : -1;
-  }
-
-  return query_string[1] == 'd' ? -cmp_result : cmp_result;
-}
-
-static int scan_directory(struct mg_connection *conn, const char *dir,
-                          void *data, void (*cb)(struct de *, void *)) {
-  char path[PATH_MAX];
-  struct dirent *dp;
-  DIR *dirp;
-  struct de de;
-
-  if ((dirp = opendir(dir)) == NULL) {
-    return 0;
-  } else {
-    de.conn = conn;
-
-    while ((dp = readdir(dirp)) != NULL) {
-      // Do not show current dir and passwords file
-      if (!strcmp(dp->d_name, ".") ||
-          !strcmp(dp->d_name, "..") ||
-          !strcmp(dp->d_name, PASSWORDS_FILE_NAME))
-        continue;
-
-      mg_snprintf(conn, path, sizeof(path), "%s%c%s", dir, DIRSEP, dp->d_name);
-
-      // If we don't memset stat structure to zero, mtime will have
-      // garbage and strftime() will segfault later on in
-      // print_dir_entry(). memset is required only if mg_stat()
-      // fails. For more details, see
-      // http://code.google.com/p/mongoose/issues/detail?id=79
-      if (mg_stat(path, &de.st) != 0) {
-        memset(&de.st, 0, sizeof(de.st));
-      }
-      de.file_name = dp->d_name;
-
-      cb(&de, data);
-    }
-    (void) closedir(dirp);
-  }
-  return 1;
-}
-
-struct dir_scan_data {
-  struct de *entries;
-  int num_entries;
-  int arr_size;
-};
-
-static void dir_scan_callback(struct de *de, void *data) {
-  struct dir_scan_data *dsd = (struct dir_scan_data *) data;
-
-  if (dsd->entries == NULL || dsd->num_entries >= dsd->arr_size) {
-    dsd->arr_size *= 2;
-    dsd->entries = (struct de *) realloc(dsd->entries, dsd->arr_size *
-                                         sizeof(dsd->entries[0]));
-  }
-  if (dsd->entries == NULL) {
-    // TODO(lsm): propagate an error to the caller
-    dsd->num_entries = 0;
-  } else {
-    dsd->entries[dsd->num_entries].file_name = mg_strdup(de->file_name);
-    dsd->entries[dsd->num_entries].st = de->st;
-    dsd->entries[dsd->num_entries].conn = de->conn;
-    dsd->num_entries++;
-  }
-}
-
-static void handle_directory_request(struct mg_connection *conn,
-                                     const char *dir) {
-  int i, sort_direction;
-  struct dir_scan_data data = { NULL, 0, 128 };
-
-  if (!scan_directory(conn, dir, &data, dir_scan_callback)) {
-    send_http_error(conn, 500, "Cannot open directory",
-                    "Error: opendir(%s): %s", dir, strerror(ERRNO));
-    return;
-  }
-
-  sort_direction = conn->request_info.query_string != NULL &&
-    conn->request_info.query_string[1] == 'd' ? 'a' : 'd';
-
-  conn->must_close = 1;
-  mg_printf(conn, "%s",
-            "HTTP/1.1 200 OK\r\n"
-            "Connection: close\r\n"
-            "Content-Type: text/html; charset=utf-8\r\n\r\n");
-
-  conn->num_bytes_sent += mg_printf(conn,
-      "<html><head><title>Index of %s</title>"
-      "<style>th {text-align: left;}</style></head>"
-      "<body><h1>Index of %s</h1><pre><table cellpadding=\"0\">"
-      "<tr><th><a href=\"?n%c\">Name</a></th>"
-      "<th><a href=\"?d%c\">Modified</a></th>"
-      "<th><a href=\"?s%c\">Size</a></th></tr>"
-      "<tr><td colspan=\"3\"><hr></td></tr>",
-      conn->request_info.uri, conn->request_info.uri,
-      sort_direction, sort_direction, sort_direction);
-
-  // Print first entry - link to a parent directory
-  conn->num_bytes_sent += mg_printf(conn,
-      "<tr><td><a href=\"%s%s\">%s</a></td>"
-      "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
-      conn->request_info.uri, "..", "Parent directory", "-", "-");
-
-  // Sort and print directory entries
-  qsort(data.entries, (size_t) data.num_entries, sizeof(data.entries[0]),
-        compare_dir_entries);
-  for (i = 0; i < data.num_entries; i++) {
-    print_dir_entry(&data.entries[i]);
-    free(data.entries[i].file_name);
-  }
-  free(data.entries);
-
-  conn->num_bytes_sent += mg_printf(conn, "%s", "</table></body></html>");
-  conn->request_info.status_code = 200;
-}
-
-// Send len bytes from the opened file to the client.
-static void send_file_data(struct mg_connection *conn, FILE *fp, int64_t len) {
-  char buf[BUFSIZ];
-  int to_read, num_read, num_written;
-
-  while (len > 0) {
-    // Calculate how much to read from the file in the buffer
-    to_read = sizeof(buf);
-    if ((int64_t) to_read > len)
-      to_read = (int) len;
-
-    // Read from file, exit the loop on error
-    if ((num_read = fread(buf, 1, (size_t)to_read, fp)) == 0)
-      break;
-
-    // Send read bytes to the client, exit the loop on error
-    if ((num_written = mg_write(conn, buf, (size_t)num_read)) != num_read)
-      break;
-
-    // Both read and were successful, adjust counters
-    conn->num_bytes_sent += num_written;
-    len -= num_written;
-  }
-}
-
-static int parse_range_header(const char *header, int64_t *a, int64_t *b) {
-  return sscanf(header, "bytes=%" INT64_FMT "-%" INT64_FMT, a, b);
-}
-
-static void gmt_time_string(char *buf, size_t buf_len, time_t *t) {
-  strftime(buf, buf_len, "%a, %d %b %Y %H:%M:%S GMT", gmtime(t));
-}
-
-static void handle_file_request(struct mg_connection *conn, const char *path,
-                                struct mgstat *stp) {
-  char date[64], lm[64], etag[64], range[64];
-  const char *msg = "OK", *hdr;
-  time_t curtime = time(NULL);
-  int64_t cl, r1, r2;
-  struct vec mime_vec;
-  FILE *fp;
-  int n;
-
-  get_mime_type(conn->ctx, path, &mime_vec);
-  cl = stp->size;
-  conn->request_info.status_code = 200;
-  range[0] = '\0';
-
-  if ((fp = mg_fopen(path, "rb")) == NULL) {
-    send_http_error(conn, 500, http_500_error,
-        "fopen(%s): %s", path, strerror(ERRNO));
-    return;
-  }
-  set_close_on_exec(fileno(fp));
-
-  // If Range: header specified, act accordingly
-  r1 = r2 = 0;
-  hdr = mg_get_header(conn, "Range");
-  if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0) {
-    conn->request_info.status_code = 206;
-    (void) fseeko(fp, (off_t) r1, SEEK_SET);
-    cl = n == 2 ? r2 - r1 + 1: cl - r1;
-    (void) mg_snprintf(conn, range, sizeof(range),
-        "Content-Range: bytes "
-        "%" INT64_FMT "-%"
-        INT64_FMT "/%" INT64_FMT "\r\n",
-        r1, r1 + cl - 1, stp->size);
-    msg = "Partial Content";
-  }
-
-  // Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to
-  // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3
-  gmt_time_string(date, sizeof(date), &curtime);
-  gmt_time_string(lm, sizeof(lm), &stp->mtime);
-  (void) mg_snprintf(conn, etag, sizeof(etag), "%lx.%lx",
-      (unsigned long) stp->mtime, (unsigned long) stp->size);
-
-  (void) mg_printf(conn,
-      "HTTP/1.1 %d %s\r\n"
-      "Date: %s\r\n"
-      "Last-Modified: %s\r\n"
-      "Etag: \"%s\"\r\n"
-      "Content-Type: %.*s\r\n"
-      "Content-Length: %" INT64_FMT "\r\n"
-      "Connection: %s\r\n"
-      "Accept-Ranges: bytes\r\n"
-      "%s\r\n",
-      conn->request_info.status_code, msg, date, lm, etag, (int) mime_vec.len,
-      mime_vec.ptr, cl, suggest_connection_header(conn), range);
-
-  if (strcmp(conn->request_info.request_method, "HEAD") != 0) {
-    send_file_data(conn, fp, cl);
-  }
-  (void) fclose(fp);
-}
-
-void mg_send_file(struct mg_connection *conn, const char *path) {
-  struct mgstat st;
-  if (mg_stat(path, &st) == 0) {
-    handle_file_request(conn, path, &st);
-  } else {
-    send_http_error(conn, 404, "Not Found", "%s", "File not found");
-  }
-}
-
-
-// Parse HTTP headers from the given buffer, advance buffer to the point
-// where parsing stopped.
-static void parse_http_headers(char **buf, struct mg_request_info *ri) {
-  int i;
-
-  for (i = 0; i < (int) ARRAY_SIZE(ri->http_headers); i++) {
-    ri->http_headers[i].name = skip_quoted(buf, ":", " ", 0);
-    ri->http_headers[i].value = skip(buf, "\r\n");
-    if (ri->http_headers[i].name[0] == '\0')
-      break;
-    ri->num_headers = i + 1;
-  }
-}
-
-static int is_valid_http_method(const char *method) {
-  return !strcmp(method, "GET") || !strcmp(method, "POST") ||
-    !strcmp(method, "HEAD") || !strcmp(method, "CONNECT") ||
-    !strcmp(method, "PUT") || !strcmp(method, "DELETE") ||
-    !strcmp(method, "OPTIONS") || !strcmp(method, "PROPFIND");
-}
-
-// Parse HTTP request, fill in mg_request_info structure.
-static int parse_http_request(char *buf, struct mg_request_info *ri) {
-  int status = 0;
-
-  // RFC says that all initial whitespaces should be ingored
-  while (*buf != '\0' && isspace(* (unsigned char *) buf)) {
-    buf++;
-  }
-
-  ri->request_method = skip(&buf, " ");
-  ri->uri = skip(&buf, " ");
-  ri->http_version = skip(&buf, "\r\n");
-
-  if (is_valid_http_method(ri->request_method) &&
-      strncmp(ri->http_version, "HTTP/", 5) == 0) {
-    ri->http_version += 5;   // Skip "HTTP/"
-    parse_http_headers(&buf, ri);
-    status = 1;
-  }
-
-  return status;
-}
-
-// Keep reading the input (either opened file descriptor fd, or socket sock,
-// or SSL descriptor ssl) into buffer buf, until \r\n\r\n appears in the
-// buffer (which marks the end of HTTP request). Buffer buf may already
-// have some data. The length of the data is stored in nread.
-// Upon every read operation, increase nread by the number of bytes read.
-static int read_request(FILE *fp, SOCKET sock, SSL *ssl, char *buf, int bufsiz,
-                        int *nread) {
-  int request_len, n = 0;
-
-  do {
-    request_len = get_request_len(buf, *nread);
-    if (request_len == 0 &&
-        (n = pull(fp, sock, ssl, buf + *nread, bufsiz - *nread)) > 0) {
-      *nread += n;
-    }
-  } while (*nread < bufsiz && request_len == 0 && n > 0);
-
-  return request_len;
-}
-
-// For given directory path, substitute it to valid index file.
-// Return 0 if index file has been found, -1 if not found.
-// If the file is found, it's stats is returned in stp.
-static int substitute_index_file(struct mg_connection *conn, char *path,
-                                 size_t path_len, struct mgstat *stp) {
-  const char *list = conn->ctx->config[INDEX_FILES];
-  struct mgstat st;
-  struct vec filename_vec;
-  size_t n = strlen(path);
-  int found = 0;
-
-  // The 'path' given to us points to the directory. Remove all trailing
-  // directory separator characters from the end of the path, and
-  // then append single directory separator character.
-  while (n > 0 && IS_DIRSEP_CHAR(path[n - 1])) {
-    n--;
-  }
-  path[n] = DIRSEP;
-
-  // Traverse index files list. For each entry, append it to the given
-  // path and see if the file exists. If it exists, break the loop
-  while ((list = next_option(list, &filename_vec, NULL)) != NULL) {
-
-    // Ignore too long entries that may overflow path buffer
-    if (filename_vec.len > path_len - (n + 2))
-      continue;
-
-    // Prepare full path to the index file
-    (void) mg_strlcpy(path + n + 1, filename_vec.ptr, filename_vec.len + 1);
-
-    // Does it exist?
-    if (mg_stat(path, &st) == 0) {
-      // Yes it does, break the loop
-      *stp = st;
-      found = 1;
-      break;
-    }
-  }
-
-  // If no index file exists, restore directory path
-  if (!found) {
-    path[n] = '\0';
-  }
-
-  return found;
-}
-
-// Return True if we should reply 304 Not Modified.
-static int is_not_modified(const struct mg_connection *conn,
-                           const struct mgstat *stp) {
-  const char *ims = mg_get_header(conn, "If-Modified-Since");
-  return ims != NULL && stp->mtime <= parse_date_string(ims);
-}
-
-static int forward_body_data(struct mg_connection *conn, FILE *fp,
-                             SOCKET sock, SSL *ssl) {
-  const char *expect, *buffered;
-  char buf[BUFSIZ];
-  int to_read, nread, buffered_len, success = 0;
-
-  expect = mg_get_header(conn, "Expect");
-  assert(fp != NULL);
-
-  if (conn->content_len == -1) {
-    send_http_error(conn, 411, "Length Required", "");
-  } else if (expect != NULL && mg_strcasecmp(expect, "100-continue")) {
-    send_http_error(conn, 417, "Expectation Failed", "");
-  } else {
-    if (expect != NULL) {
-      (void) mg_printf(conn, "%s", "HTTP/1.1 100 Continue\r\n\r\n");
-    }
-
-    buffered = conn->buf + conn->request_len;
-    buffered_len = conn->data_len - conn->request_len;
-    assert(buffered_len >= 0);
-    assert(conn->consumed_content == 0);
-
-    if (buffered_len > 0) {
-      if ((int64_t) buffered_len > conn->content_len) {
-        buffered_len = (int) conn->content_len;
-      }
-      push(fp, sock, ssl, buffered, (int64_t) buffered_len);
-      conn->consumed_content += buffered_len;
-    }
-
-    while (conn->consumed_content < conn->content_len) {
-      to_read = sizeof(buf);
-      if ((int64_t) to_read > conn->content_len - conn->consumed_content) {
-        to_read = (int) (conn->content_len - conn->consumed_content);
-      }
-      nread = pull(NULL, conn->client.sock, conn->ssl, buf, to_read);
-      if (nread <= 0 || push(fp, sock, ssl, buf, nread) != nread) {
-        break;
-      }
-      conn->consumed_content += nread;
-    }
-
-    if (conn->consumed_content == conn->content_len) {
-      success = 1;
-    }
-
-    // Each error code path in this function must send an error
-    if (!success) {
-      send_http_error(conn, 577, http_500_error, "");
-    }
-  }
-
-  return success;
-}
-
-#if !defined(NO_CGI)
-// This structure helps to create an environment for the spawned CGI program.
-// Environment is an array of "VARIABLE=VALUE\0" ASCIIZ strings,
-// last element must be NULL.
-// However, on Windows there is a requirement that all these VARIABLE=VALUE\0
-// strings must reside in a contiguous buffer. The end of the buffer is
-// marked by two '\0' characters.
-// We satisfy both worlds: we create an envp array (which is vars), all
-// entries are actually pointers inside buf.
-struct cgi_env_block {
-  struct mg_connection *conn;
-  char buf[CGI_ENVIRONMENT_SIZE]; // Environment buffer
-  int len; // Space taken
-  char *vars[MAX_CGI_ENVIR_VARS]; // char **envp
-  int nvars; // Number of variables
-};
-
-// Append VARIABLE=VALUE\0 string to the buffer, and add a respective
-// pointer into the vars array.
-static char *addenv(struct cgi_env_block *block, const char *fmt, ...) {
-  int n, space;
-  char *added;
-  va_list ap;
-
-  // Calculate how much space is left in the buffer
-  space = sizeof(block->buf) - block->len - 2;
-  assert(space >= 0);
-
-  // Make a pointer to the free space int the buffer
-  added = block->buf + block->len;
-
-  // Copy VARIABLE=VALUE\0 string into the free space
-  va_start(ap, fmt);
-  n = mg_vsnprintf(block->conn, added, (size_t) space, fmt, ap);
-  va_end(ap);
-
-  // Make sure we do not overflow buffer and the envp array
-  if (n > 0 && n < space &&
-      block->nvars < (int) ARRAY_SIZE(block->vars) - 2) {
-    // Append a pointer to the added string into the envp array
-    block->vars[block->nvars++] = block->buf + block->len;
-    // Bump up used length counter. Include \0 terminator
-    block->len += n + 1;
-  }
-
-  return added;
-}
-
-static void prepare_cgi_environment(struct mg_connection *conn,
-                                    const char *prog,
-                                    struct cgi_env_block *blk) {
-  const char *s, *slash;
-  struct vec var_vec;
-  char *p, src_addr[20];
-  int  i;
-
-  blk->len = blk->nvars = 0;
-  blk->conn = conn;
-  sockaddr_to_string(src_addr, sizeof(src_addr), &conn->client.rsa);
-
-  addenv(blk, "SERVER_NAME=%s", conn->ctx->config[AUTHENTICATION_DOMAIN]);
-  addenv(blk, "SERVER_ROOT=%s", conn->ctx->config[DOCUMENT_ROOT]);
-  addenv(blk, "DOCUMENT_ROOT=%s", conn->ctx->config[DOCUMENT_ROOT]);
-
-  // Prepare the environment block
-  addenv(blk, "%s", "GATEWAY_INTERFACE=CGI/1.1");
-  addenv(blk, "%s", "SERVER_PROTOCOL=HTTP/1.1");
-  addenv(blk, "%s", "REDIRECT_STATUS=200"); // For PHP
-
-  // TODO(lsm): fix this for IPv6 case
-  addenv(blk, "SERVER_PORT=%d", ntohs(conn->client.lsa.sin.sin_port));
-
-  addenv(blk, "REQUEST_METHOD=%s", conn->request_info.request_method);
-  addenv(blk, "REMOTE_ADDR=%s", src_addr);
-  addenv(blk, "REMOTE_PORT=%d", conn->request_info.remote_port);
-  addenv(blk, "REQUEST_URI=%s", conn->request_info.uri);
-
-  // SCRIPT_NAME
-  assert(conn->request_info.uri[0] == '/');
-  slash = strrchr(conn->request_info.uri, '/');
-  if ((s = strrchr(prog, '/')) == NULL)
-    s = prog;
-  addenv(blk, "SCRIPT_NAME=%.*s%s", slash - conn->request_info.uri,
-         conn->request_info.uri, s);
-
-  addenv(blk, "SCRIPT_FILENAME=%s", prog);
-  addenv(blk, "PATH_TRANSLATED=%s", prog);
-  addenv(blk, "HTTPS=%s", conn->ssl == NULL ? "off" : "on");
-
-  if ((s = mg_get_header(conn, "Content-Type")) != NULL)
-    addenv(blk, "CONTENT_TYPE=%s", s);
-
-  if (conn->request_info.query_string != NULL)
-    addenv(blk, "QUERY_STRING=%s", conn->request_info.query_string);
-
-  if ((s = mg_get_header(conn, "Content-Length")) != NULL)
-    addenv(blk, "CONTENT_LENGTH=%s", s);
-
-  if ((s = getenv("PATH")) != NULL)
-    addenv(blk, "PATH=%s", s);
-
-  if (conn->path_info != NULL) {
-    addenv(blk, "PATH_INFO=%s", conn->path_info);
-  }
-
-#if defined(_WIN32)
-  if ((s = getenv("COMSPEC")) != NULL) {
-    addenv(blk, "COMSPEC=%s", s);
-  }
-  if ((s = getenv("SYSTEMROOT")) != NULL) {
-    addenv(blk, "SYSTEMROOT=%s", s);
-  }
-  if ((s = getenv("SystemDrive")) != NULL) {
-    addenv(blk, "SystemDrive=%s", s);
-  }
-#else
-  if ((s = getenv("LD_LIBRARY_PATH")) != NULL)
-    addenv(blk, "LD_LIBRARY_PATH=%s", s);
-#endif // _WIN32
-
-  if ((s = getenv("PERLLIB")) != NULL)
-    addenv(blk, "PERLLIB=%s", s);
-
-  if (conn->request_info.remote_user != NULL) {
-    addenv(blk, "REMOTE_USER=%s", conn->request_info.remote_user);
-    addenv(blk, "%s", "AUTH_TYPE=Digest");
-  }
-
-  // Add all headers as HTTP_* variables
-  for (i = 0; i < conn->request_info.num_headers; i++) {
-    p = addenv(blk, "HTTP_%s=%s",
-        conn->request_info.http_headers[i].name,
-        conn->request_info.http_headers[i].value);
-
-    // Convert variable name into uppercase, and change - to _
-    for (; *p != '=' && *p != '\0'; p++) {
-      if (*p == '-')
-        *p = '_';
-      *p = (char) toupper(* (unsigned char *) p);
-    }
-  }
-
-  // Add user-specified variables
-  s = conn->ctx->config[CGI_ENVIRONMENT];
-  while ((s = next_option(s, &var_vec, NULL)) != NULL) {
-    addenv(blk, "%.*s", var_vec.len, var_vec.ptr);
-  }
-
-  blk->vars[blk->nvars++] = NULL;
-  blk->buf[blk->len++] = '\0';
-
-  assert(blk->nvars < (int) ARRAY_SIZE(blk->vars));
-  assert(blk->len > 0);
-  assert(blk->len < (int) sizeof(blk->buf));
-}
-
-static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
-  int headers_len, data_len, i, fd_stdin[2], fd_stdout[2];
-  const char *status, *status_text;
-  char buf[16384], *pbuf, dir[PATH_MAX], *p;
-  struct mg_request_info ri;
-  struct cgi_env_block blk;
-  FILE *in, *out;
-  pid_t pid;
-
-  prepare_cgi_environment(conn, prog, &blk);
-
-  // CGI must be executed in its own directory. 'dir' must point to the
-  // directory containing executable program, 'p' must point to the
-  // executable program name relative to 'dir'.
-  (void) mg_snprintf(conn, dir, sizeof(dir), "%s", prog);
-  if ((p = strrchr(dir, DIRSEP)) != NULL) {
-    *p++ = '\0';
-  } else {
-    dir[0] = '.', dir[1] = '\0';
-    p = (char *) prog;
-  }
-
-  pid = (pid_t) -1;
-  fd_stdin[0] = fd_stdin[1] = fd_stdout[0] = fd_stdout[1] = -1;
-  in = out = NULL;
-
-  if (pipe(fd_stdin) != 0 || pipe(fd_stdout) != 0) {
-    send_http_error(conn, 500, http_500_error,
-        "Cannot create CGI pipe: %s", strerror(ERRNO));
-    goto done;
-  } else if ((pid = spawn_process(conn, p, blk.buf, blk.vars,
-          fd_stdin[0], fd_stdout[1], dir)) == (pid_t) -1) {
-    goto done;
-  } else if ((in = fdopen(fd_stdin[1], "wb")) == NULL ||
-      (out = fdopen(fd_stdout[0], "rb")) == NULL) {
-    send_http_error(conn, 500, http_500_error,
-        "fopen: %s", strerror(ERRNO));
-    goto done;
-  }
-
-  setbuf(in, NULL);
-  setbuf(out, NULL);
-
-  // spawn_process() must close those!
-  // If we don't mark them as closed, close() attempt before
-  // return from this function throws an exception on Windows.
-  // Windows does not like when closed descriptor is closed again.
-  fd_stdin[0] = fd_stdout[1] = -1;
-
-  // Send POST data to the CGI process if needed
-  if (!strcmp(conn->request_info.request_method, "POST") &&
-      !forward_body_data(conn, in, INVALID_SOCKET, NULL)) {
-    goto done;
-  }
-
-  // Now read CGI reply into a buffer. We need to set correct
-  // status code, thus we need to see all HTTP headers first.
-  // Do not send anything back to client, until we buffer in all
-  // HTTP headers.
-  data_len = 0;
-  headers_len = read_request(out, INVALID_SOCKET, NULL,
-                             buf, sizeof(buf), &data_len);
-  if (headers_len <= 0) {
-    send_http_error(conn, 500, http_500_error,
-                    "CGI program sent malformed HTTP headers: [%.*s]",
-                    data_len, buf);
-    goto done;
-  }
-  pbuf = buf;
-  buf[headers_len - 1] = '\0';
-  parse_http_headers(&pbuf, &ri);
-
-  // Make up and send the status line
-  status_text = "OK";
-  if ((status = get_header(&ri, "Status")) != NULL) {
-    conn->request_info.status_code = atoi(status);
-    status_text = status;
-    while (isdigit(* (unsigned char *) status_text) || *status_text == ' ') {
-      status_text++;
-    }
-  } else if (get_header(&ri, "Location") != NULL) {
-    conn->request_info.status_code = 302;
-  } else {
-    conn->request_info.status_code = 200;
-  }
-  if (get_header(&ri, "Connection") != NULL &&
-      !mg_strcasecmp(get_header(&ri, "Connection"), "keep-alive")) {
-    conn->must_close = 1;
-  }
-  (void) mg_printf(conn, "HTTP/1.1 %d %s\r\n", conn->request_info.status_code,
-                   status_text);
-
-  // Send headers
-  for (i = 0; i < ri.num_headers; i++) {
-    mg_printf(conn, "%s: %s\r\n",
-              ri.http_headers[i].name, ri.http_headers[i].value);
-  }
-  (void) mg_write(conn, "\r\n", 2);
-
-  // Send chunk of data that may be read after the headers
-  conn->num_bytes_sent += mg_write(conn, buf + headers_len,
-                                   (size_t)(data_len - headers_len));
-
-  // Read the rest of CGI output and send to the client
-  send_file_data(conn, out, INT64_MAX);
-
-done:
-  if (pid != (pid_t) -1) {
-    kill(pid, SIGKILL);
-  }
-  if (fd_stdin[0] != -1) {
-    (void) close(fd_stdin[0]);
-  }
-  if (fd_stdout[1] != -1) {
-    (void) close(fd_stdout[1]);
-  }
-
-  if (in != NULL) {
-    (void) fclose(in);
-  } else if (fd_stdin[1] != -1) {
-    (void) close(fd_stdin[1]);
-  }
-
-  if (out != NULL) {
-    (void) fclose(out);
-  } else if (fd_stdout[0] != -1) {
-    (void) close(fd_stdout[0]);
-  }
-}
-#endif // !NO_CGI
-
-// For a given PUT path, create all intermediate subdirectories
-// for given path. Return 0 if the path itself is a directory,
-// or -1 on error, 1 if OK.
-static int put_dir(const char *path) {
-  char buf[PATH_MAX];
-  const char *s, *p;
-  struct mgstat st;
-  int len, res = 1;
-
-  for (s = p = path + 2; (p = strchr(s, DIRSEP)) != NULL; s = ++p) {
-    len = p - path;
-    if (len >= (int) sizeof(buf)) {
-      res = -1;
-      break;
-    }
-    memcpy(buf, path, len);
-    buf[len] = '\0';
-
-    // Try to create intermediate directory
-    DEBUG_TRACE(("mkdir(%s)", buf));
-    if (mg_stat(buf, &st) == -1 && mg_mkdir(buf, 0755) != 0) {
-      res = -1;
-      break;
-    }
-
-    // Is path itself a directory?
-    if (p[1] == '\0') {
-      res = 0;
-    }
-  }
-
-  return res;
-}
-
-static void put_file(struct mg_connection *conn, const char *path) {
-  struct mgstat st;
-  const char *range;
-  int64_t r1, r2;
-  FILE *fp;
-  int rc;
-
-  conn->request_info.status_code = mg_stat(path, &st) == 0 ? 200 : 201;
-
-  if ((rc = put_dir(path)) == 0) {
-    mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n", conn->request_info.status_code);
-  } else if (rc == -1) {
-    send_http_error(conn, 500, http_500_error,
-        "put_dir(%s): %s", path, strerror(ERRNO));
-  } else if ((fp = mg_fopen(path, "wb+")) == NULL) {
-    send_http_error(conn, 500, http_500_error,
-        "fopen(%s): %s", path, strerror(ERRNO));
-  } else {
-    set_close_on_exec(fileno(fp));
-    range = mg_get_header(conn, "Content-Range");
-    r1 = r2 = 0;
-    if (range != NULL && parse_range_header(range, &r1, &r2) > 0) {
-      conn->request_info.status_code = 206;
-      // TODO(lsm): handle seek error
-      (void) fseeko(fp, (off_t) r1, SEEK_SET);
-    }
-    if (forward_body_data(conn, fp, INVALID_SOCKET, NULL))
-      (void) mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n",
-          conn->request_info.status_code);
-    (void) fclose(fp);
-  }
-}
-
-static void send_ssi_file(struct mg_connection *, const char *, FILE *, int);
-
-static void do_ssi_include(struct mg_connection *conn, const char *ssi,
-                           char *tag, int include_level) {
-  char file_name[BUFSIZ], path[PATH_MAX], *p;
-  FILE *fp;
-
-  // sscanf() is safe here, since send_ssi_file() also uses buffer
-  // of size BUFSIZ to get the tag. So strlen(tag) is always < BUFSIZ.
-  if (sscanf(tag, " virtual=\"%[^\"]\"", file_name) == 1) {
-    // File name is relative to the webserver root
-    (void) mg_snprintf(conn, path, sizeof(path), "%s%c%s",
-        conn->ctx->config[DOCUMENT_ROOT], DIRSEP, file_name);
-  } else if (sscanf(tag, " file=\"%[^\"]\"", file_name) == 1) {
-    // File name is relative to the webserver working directory
-    // or it is absolute system path
-    (void) mg_snprintf(conn, path, sizeof(path), "%s", file_name);
-  } else if (sscanf(tag, " \"%[^\"]\"", file_name) == 1) {
-    // File name is relative to the currect document
-    (void) mg_snprintf(conn, path, sizeof(path), "%s", ssi);
-    if ((p = strrchr(path, DIRSEP)) != NULL) {
-      p[1] = '\0';
-    }
-    (void) mg_snprintf(conn, path + strlen(path),
-        sizeof(path) - strlen(path), "%s", file_name);
-  } else {
-    cry(conn, "Bad SSI #include: [%s]", tag);
-    return;
-  }
-
-  if ((fp = mg_fopen(path, "rb")) == NULL) {
-    cry(conn, "Cannot open SSI #include: [%s]: fopen(%s): %s",
-        tag, path, strerror(ERRNO));
-  } else {
-    set_close_on_exec(fileno(fp));
-    if (match_prefix(conn->ctx->config[SSI_EXTENSIONS],
-                     strlen(conn->ctx->config[SSI_EXTENSIONS]), path) > 0) {
-      send_ssi_file(conn, path, fp, include_level + 1);
-    } else {
-      send_file_data(conn, fp, INT64_MAX);
-    }
-    (void) fclose(fp);
-  }
-}
-
-#if !defined(NO_POPEN)
-static void do_ssi_exec(struct mg_connection *conn, char *tag) {
-  char cmd[BUFSIZ];
-  FILE *fp;
-
-  if (sscanf(tag, " \"%[^\"]\"", cmd) != 1) {
-    cry(conn, "Bad SSI #exec: [%s]", tag);
-  } else if ((fp = popen(cmd, "r")) == NULL) {
-    cry(conn, "Cannot SSI #exec: [%s]: %s", cmd, strerror(ERRNO));
-  } else {
-    send_file_data(conn, fp, INT64_MAX);
-    (void) pclose(fp);
-  }
-}
-#endif // !NO_POPEN
-
-static void send_ssi_file(struct mg_connection *conn, const char *path,
-                          FILE *fp, int include_level) {
-  char buf[BUFSIZ];
-  int ch, len, in_ssi_tag;
-
-  if (include_level > 10) {
-    cry(conn, "SSI #include level is too deep (%s)", path);
-    return;
-  }
-
-  in_ssi_tag = 0;
-  len = 0;
-
-  while ((ch = fgetc(fp)) != EOF) {
-    if (in_ssi_tag && ch == '>') {
-      in_ssi_tag = 0;
-      buf[len++] = (char) ch;
-      buf[len] = '\0';
-      assert(len <= (int) sizeof(buf));
-      if (len < 6 || memcmp(buf, "<!--#", 5) != 0) {
-        // Not an SSI tag, pass it
-        (void) mg_write(conn, buf, (size_t)len);
-      } else {
-        if (!memcmp(buf + 5, "include", 7)) {
-          do_ssi_include(conn, path, buf + 12, include_level);
-#if !defined(NO_POPEN)
-        } else if (!memcmp(buf + 5, "exec", 4)) {
-          do_ssi_exec(conn, buf + 9);
-#endif // !NO_POPEN
-        } else {
-          cry(conn, "%s: unknown SSI " "command: \"%s\"", path, buf);
-        }
-      }
-      len = 0;
-    } else if (in_ssi_tag) {
-      if (len == 5 && memcmp(buf, "<!--#", 5) != 0) {
-        // Not an SSI tag
-        in_ssi_tag = 0;
-      } else if (len == (int) sizeof(buf) - 2) {
-        cry(conn, "%s: SSI tag is too large", path);
-        len = 0;
-      }
-      buf[len++] = ch & 0xff;
-    } else if (ch == '<') {
-      in_ssi_tag = 1;
-      if (len > 0) {
-        (void) mg_write(conn, buf, (size_t)len);
-      }
-      len = 0;
-      buf[len++] = ch & 0xff;
-    } else {
-      buf[len++] = ch & 0xff;
-      if (len == (int) sizeof(buf)) {
-        (void) mg_write(conn, buf, (size_t)len);
-        len = 0;
-      }
-    }
-  }
-
-  // Send the rest of buffered data
-  if (len > 0) {
-    (void) mg_write(conn, buf, (size_t)len);
-  }
-}
-
-static void handle_ssi_file_request(struct mg_connection *conn,
-                                    const char *path) {
-  FILE *fp;
-
-  if ((fp = mg_fopen(path, "rb")) == NULL) {
-    send_http_error(conn, 500, http_500_error, "fopen(%s): %s", path,
-                    strerror(ERRNO));
-  } else {
-    conn->must_close = 1;
-    set_close_on_exec(fileno(fp));
-    mg_printf(conn, "HTTP/1.1 200 OK\r\n"
-              "Content-Type: text/html\r\nConnection: %s\r\n\r\n",
-              suggest_connection_header(conn));
-    send_ssi_file(conn, path, fp, 0);
-    (void) fclose(fp);
-  }
-}
-
-static void send_options(struct mg_connection *conn) {
-  conn->request_info.status_code = 200;
-
-  (void) mg_printf(conn,
-      "HTTP/1.1 200 OK\r\n"
-      "Allow: GET, POST, HEAD, CONNECT, PUT, DELETE, OPTIONS\r\n"
-      "DAV: 1\r\n\r\n");
-}
-
-// Writes PROPFIND properties for a collection element
-static void print_props(struct mg_connection *conn, const char* uri,
-                        struct mgstat* st) {
-  char mtime[64];
-  gmt_time_string(mtime, sizeof(mtime), &st->mtime);
-  conn->num_bytes_sent += mg_printf(conn,
-      "<d:response>"
-       "<d:href>%s</d:href>"
-       "<d:propstat>"
-        "<d:prop>"
-         "<d:resourcetype>%s</d:resourcetype>"
-         "<d:getcontentlength>%" INT64_FMT "</d:getcontentlength>"
-         "<d:getlastmodified>%s</d:getlastmodified>"
-        "</d:prop>"
-        "<d:status>HTTP/1.1 200 OK</d:status>"
-       "</d:propstat>"
-      "</d:response>\n",
-      uri,
-      st->is_directory ? "<d:collection/>" : "",
-      st->size,
-      mtime);
-}
-
-static void print_dav_dir_entry(struct de *de, void *data) {
-  char href[PATH_MAX];
-  struct mg_connection *conn = (struct mg_connection *) data;
-  mg_snprintf(conn, href, sizeof(href), "%s%s",
-              conn->request_info.uri, de->file_name);
-  print_props(conn, href, &de->st);
-}
-
-static void handle_propfind(struct mg_connection *conn, const char* path,
-                            struct mgstat* st) {
-  const char *depth = mg_get_header(conn, "Depth");
-
-  conn->must_close = 1;
-  conn->request_info.status_code = 207;
-  mg_printf(conn, "HTTP/1.1 207 Multi-Status\r\n"
-            "Connection: close\r\n"
-            "Content-Type: text/xml; charset=utf-8\r\n\r\n");
-
-  conn->num_bytes_sent += mg_printf(conn,
-      "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
-      "<d:multistatus xmlns:d='DAV:'>\n");
-
-  // Print properties for the requested resource itself
-  print_props(conn, conn->request_info.uri, st);
-
-  // If it is a directory, print directory entries too if Depth is not 0
-  if (st->is_directory &&
-      !mg_strcasecmp(conn->ctx->config[ENABLE_DIRECTORY_LISTING], "yes") &&
-      (depth == NULL || strcmp(depth, "0") != 0)) {
-    scan_directory(conn, path, conn, &print_dav_dir_entry);
-  }
-
-  conn->num_bytes_sent += mg_printf(conn, "%s\n", "</d:multistatus>");
-}
-
-// This is the heart of the Mongoose's logic.
-// This function is called when the request is read, parsed and validated,
-// and Mongoose must decide what action to take: serve a file, or
-// a directory, or call embedded function, etcetera.
-static void handle_request(struct mg_connection *conn) {
-  struct mg_request_info *ri = &conn->request_info;
-  char path[PATH_MAX];
-  int stat_result, uri_len;
-  struct mgstat st;
-
-  if ((conn->request_info.query_string = strchr(ri->uri, '?')) != NULL) {
-    * conn->request_info.query_string++ = '\0';
-  }
-  uri_len = strlen(ri->uri);
-  url_decode(ri->uri, (size_t)uri_len, ri->uri, (size_t)(uri_len + 1), 0);
-  remove_double_dots_and_double_slashes(ri->uri);
-  stat_result = convert_uri_to_file_name(conn, path, sizeof(path), &st);
-
-  DEBUG_TRACE(("%s", ri->uri));
-  if (!check_authorization(conn, path)) {
-    send_authorization_request(conn);
-  } else if (call_user(conn, MG_NEW_REQUEST) != NULL) {
-    // Do nothing, callback has served the request
-  } else if (!strcmp(ri->request_method, "OPTIONS")) {
-    send_options(conn);
-  } else if (strstr(path, PASSWORDS_FILE_NAME)) {
-    // Do not allow to view passwords files
-    send_http_error(conn, 403, "Forbidden", "Access Forbidden");
-  } else if (conn->ctx->config[DOCUMENT_ROOT] == NULL) {
-    send_http_error(conn, 404, "Not Found", "Not Found");
-  } else if ((!strcmp(ri->request_method, "PUT") ||
-        !strcmp(ri->request_method, "DELETE")) &&
-      (conn->ctx->config[PUT_DELETE_PASSWORDS_FILE] == NULL ||
-       !is_authorized_for_put(conn))) {
-    send_authorization_request(conn);
-  } else if (!strcmp(ri->request_method, "PUT")) {
-    put_file(conn, path);
-  } else if (!strcmp(ri->request_method, "DELETE")) {
-    if (mg_remove(path) == 0) {
-      send_http_error(conn, 200, "OK", "");
-    } else {
-      send_http_error(conn, 500, http_500_error, "remove(%s): %s", path,
-                      strerror(ERRNO));
-    }
-  } else if (stat_result != 0) {
-    send_http_error(conn, 404, "Not Found", "%s", "File not found");
-  } else if (st.is_directory && ri->uri[uri_len - 1] != '/') {
-    (void) mg_printf(conn,
-        "HTTP/1.1 301 Moved Permanently\r\n"
-        "Location: %s/\r\n\r\n", ri->uri);
-  } else if (!strcmp(ri->request_method, "PROPFIND")) {
-    handle_propfind(conn, path, &st);
-  } else if (st.is_directory &&
-             !substitute_index_file(conn, path, sizeof(path), &st)) {
-    if (!mg_strcasecmp(conn->ctx->config[ENABLE_DIRECTORY_LISTING], "yes")) {
-      handle_directory_request(conn, path);
-    } else {
-      send_http_error(conn, 403, "Directory Listing Denied",
-          "Directory listing denied");
-    }
-#if !defined(NO_CGI)
-  } else if (match_prefix(conn->ctx->config[CGI_EXTENSIONS],
-                          strlen(conn->ctx->config[CGI_EXTENSIONS]),
-                          path) > 0) {
-    if (strcmp(ri->request_method, "POST") &&
-        strcmp(ri->request_method, "GET")) {
-      send_http_error(conn, 501, "Not Implemented",
-                      "Method %s is not implemented", ri->request_method);
-    } else {
-      handle_cgi_request(conn, path);
-    }
-#endif // !NO_CGI
-  } else if (match_prefix(conn->ctx->config[SSI_EXTENSIONS],
-                          strlen(conn->ctx->config[SSI_EXTENSIONS]),
-                          path) > 0) {
-    handle_ssi_file_request(conn, path);
-  } else if (is_not_modified(conn, &st)) {
-    send_http_error(conn, 304, "Not Modified", "");
-  } else {
-    handle_file_request(conn, path, &st);
-  }
-}
-
-static void close_all_listening_sockets(struct mg_context *ctx) {
-  struct socket *sp, *tmp;
-  for (sp = ctx->listening_sockets; sp != NULL; sp = tmp) {
-    tmp = sp->next;
-    (void) closesocket(sp->sock);
-    free(sp);
-  }
-}
-
-// Valid listening port specification is: [ip_address:]port[s]
-// Examples: 80, 443s, 127.0.0.1:3128,1.2.3.4:8080s
-// TODO(lsm): add parsing of the IPv6 address
-static int parse_port_string(const struct vec *vec, struct socket *so) {
-  int a, b, c, d, port, len;
-
-  // MacOS needs that. If we do not zero it, subsequent bind() will fail.
-  // Also, all-zeroes in the socket address means binding to all addresses
-  // for both IPv4 and IPv6 (INADDR_ANY and IN6ADDR_ANY_INIT).
-  memset(so, 0, sizeof(*so));
-
-  if (sscanf(vec->ptr, "%d.%d.%d.%d:%d%n", &a, &b, &c, &d, &port, &len) == 5) {
-    // Bind to a specific IPv4 address
-    so->lsa.sin.sin_addr.s_addr = htonl((a << 24) | (b << 16) | (c << 8) | d);
-  } else if (sscanf(vec->ptr, "%d%n", &port, &len) != 1 ||
-             len <= 0 ||
-             len > (int) vec->len ||
-             (vec->ptr[len] && vec->ptr[len] != 's' && vec->ptr[len] != ',')) {
-    return 0;
-  }
-
-  so->is_ssl = vec->ptr[len] == 's';
-#if defined(USE_IPV6)
-  so->lsa.sin6.sin6_family = AF_INET6;
-  so->lsa.sin6.sin6_port = htons((uint16_t) port);
-#else
-  so->lsa.sin.sin_family = AF_INET;
-  so->lsa.sin.sin_port = htons((uint16_t) port);
-#endif
-
-  return 1;
-}
-
-static int set_ports_option(struct mg_context *ctx) {
-  const char *list = ctx->config[LISTENING_PORTS];
-  int on = 1, success = 1;
-  SOCKET sock;
-  struct vec vec;
-  struct socket so, *listener;
-
-  while (success && (list = next_option(list, &vec, NULL)) != NULL) {
-    if (!parse_port_string(&vec, &so)) {
-      cry(fc(ctx), "%s: %.*s: invalid port spec. Expecting list of: %s",
-          __func__, vec.len, vec.ptr, "[IP_ADDRESS:]PORT[s|p]");
-      success = 0;
-    } else if (so.is_ssl && ctx->ssl_ctx == NULL) {
-      cry(fc(ctx), "Cannot add SSL socket, is -ssl_certificate option set?");
-      success = 0;
-    } else if ((sock = socket(so.lsa.sa.sa_family, SOCK_STREAM, 6)) ==
-               INVALID_SOCKET ||
-#if !defined(_WIN32)
-               // On Windows, SO_REUSEADDR is recommended only for
-               // broadcast UDP sockets
-               setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on,
-                          sizeof(on)) != 0 ||
-#endif // !_WIN32
-               // Set TCP keep-alive. This is needed because if HTTP-level
-               // keep-alive is enabled, and client resets the connection,
-               // server won't get TCP FIN or RST and will keep the connection
-               // open forever. With TCP keep-alive, next keep-alive
-               // handshake will figure out that the client is down and
-               // will close the server end.
-               // Thanks to Igor Klopov who suggested the patch.
-               setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *) &on,
-                          sizeof(on)) != 0 ||
-               bind(sock, &so.lsa.sa, sizeof(so.lsa)) != 0 ||
-               listen(sock, 100) != 0) {
-      closesocket(sock);
-      cry(fc(ctx), "%s: cannot bind to %.*s: %s", __func__,
-          vec.len, vec.ptr, strerror(ERRNO));
-      success = 0;
-    } else if ((listener = (struct socket *)
-                calloc(1, sizeof(*listener))) == NULL) {
-      closesocket(sock);
-      cry(fc(ctx), "%s: %s", __func__, strerror(ERRNO));
-      success = 0;
-    } else {
-      *listener = so;
-      listener->sock = sock;
-      set_close_on_exec(listener->sock);
-      listener->next = ctx->listening_sockets;
-      ctx->listening_sockets = listener;
-    }
-  }
-
-  if (!success) {
-    close_all_listening_sockets(ctx);
-  }
-
-  return success;
-}
-
-static void log_header(const struct mg_connection *conn, const char *header,
-                       FILE *fp) {
-  const char *header_value;
-
-  if ((header_value = mg_get_header(conn, header)) == NULL) {
-    (void) fprintf(fp, "%s", " -");
-  } else {
-    (void) fprintf(fp, " \"%s\"", header_value);
-  }
-}
-
-static void log_access(const struct mg_connection *conn) {
-  const struct mg_request_info *ri;
-  FILE *fp;
-  char date[64], src_addr[20];
-
-  fp = conn->ctx->config[ACCESS_LOG_FILE] == NULL ?  NULL :
-    mg_fopen(conn->ctx->config[ACCESS_LOG_FILE], "a+");
-
-  if (fp == NULL)
-    return;
-
-  strftime(date, sizeof(date), "%d/%b/%Y:%H:%M:%S %z",
-           localtime(&conn->birth_time));
-
-  ri = &conn->request_info;
-  flockfile(fp);
-
-  sockaddr_to_string(src_addr, sizeof(src_addr), &conn->client.rsa);
-  fprintf(fp, "%s - %s [%s] \"%s %s HTTP/%s\" %d %" INT64_FMT,
-          src_addr, ri->remote_user == NULL ? "-" : ri->remote_user, date,
-          ri->request_method ? ri->request_method : "-",
-          ri->uri ? ri->uri : "-", ri->http_version,
-          conn->request_info.status_code, conn->num_bytes_sent);
-  log_header(conn, "Referer", fp);
-  log_header(conn, "User-Agent", fp);
-  fputc('\n', fp);
-  fflush(fp);
-
-  funlockfile(fp);
-  fclose(fp);
-}
-
-static int isbyte(int n) {
-  return n >= 0 && n <= 255;
-}
-
-// Verify given socket address against the ACL.
-// Return -1 if ACL is malformed, 0 if address is disallowed, 1 if allowed.
-static int check_acl(struct mg_context *ctx, const union usa *usa) {
-  int a, b, c, d, n, mask, allowed;
-  char flag;
-  uint32_t acl_subnet, acl_mask, remote_ip;
-  struct vec vec;
-  const char *list = ctx->config[ACCESS_CONTROL_LIST];
-
-  if (list == NULL) {
-    return 1;
-  }
-
-  (void) memcpy(&remote_ip, &usa->sin.sin_addr, sizeof(remote_ip));
-
-  // If any ACL is set, deny by default
-  allowed = '-';
-
-  while ((list = next_option(list, &vec, NULL)) != NULL) {
-    mask = 32;
-
-    if (sscanf(vec.ptr, "%c%d.%d.%d.%d%n", &flag, &a, &b, &c, &d, &n) != 5) {
-      cry(fc(ctx), "%s: subnet must be [+|-]x.x.x.x[/x]", __func__);
-      return -1;
-    } else if (flag != '+' && flag != '-') {
-      cry(fc(ctx), "%s: flag must be + or -: [%s]", __func__, vec.ptr);
-      return -1;
-    } else if (!isbyte(a)||!isbyte(b)||!isbyte(c)||!isbyte(d)) {
-      cry(fc(ctx), "%s: bad ip address: [%s]", __func__, vec.ptr);
-      return -1;
-    } else if (sscanf(vec.ptr + n, "/%d", &mask) == 0) {
-      // Do nothing, no mask specified
-    } else if (mask < 0 || mask > 32) {
-      cry(fc(ctx), "%s: bad subnet mask: %d [%s]", __func__, n, vec.ptr);
-      return -1;
-    }
-
-    acl_subnet = (a << 24) | (b << 16) | (c << 8) | d;
-    acl_mask = mask ? 0xffffffffU << (32 - mask) : 0;
-
-    if (acl_subnet == (ntohl(remote_ip) & acl_mask)) {
-      allowed = flag;
-    }
-  }
-
-  return allowed == '+';
-}
-
-static void add_to_set(SOCKET fd, fd_set *set, int *max_fd) {
-  FD_SET(fd, set);
-  if (fd > (SOCKET) *max_fd) {
-    *max_fd = (int) fd;
-  }
-}
-
-#if !defined(_WIN32)
-static int set_uid_option(struct mg_context *ctx) {
-  struct passwd *pw;
-  const char *uid = ctx->config[RUN_AS_USER];
-  int success = 0;
-
-  if (uid == NULL) {
-    success = 1;
-  } else {
-    if ((pw = getpwnam(uid)) == NULL) {
-      cry(fc(ctx), "%s: unknown user [%s]", __func__, uid);
-    } else if (setgid(pw->pw_gid) == -1) {
-      cry(fc(ctx), "%s: setgid(%s): %s", __func__, uid, strerror(errno));
-    } else if (setuid(pw->pw_uid) == -1) {
-      cry(fc(ctx), "%s: setuid(%s): %s", __func__, uid, strerror(errno));
-    } else {
-      success = 1;
-    }
-  }
-
-  return success;
-}
-#endif // !_WIN32
-
-#if !defined(NO_SSL)
-static pthread_mutex_t *ssl_mutexes;
-
-// Return OpenSSL error message
-static const char *ssl_error(void) {
-  unsigned long err;
-  err = ERR_get_error();
-  return err == 0 ? "" : ERR_error_string(err, NULL);
-}
-
-static void ssl_locking_callback(int mode, int mutex_num, const char *file,
-                                 int line) {
-  line = 0;    // Unused
-  file = NULL; // Unused
-
-  if (mode & CRYPTO_LOCK) {
-    (void) pthread_mutex_lock(&ssl_mutexes[mutex_num]);
-  } else {
-    (void) pthread_mutex_unlock(&ssl_mutexes[mutex_num]);
-  }
-}
-
-static unsigned long ssl_id_callback(void) {
-  return (unsigned long) pthread_self();
-}
-
-#if !defined(NO_SSL_DL)
-static int load_dll(struct mg_context *ctx, const char *dll_name,
-                    struct ssl_func *sw) {
-  union {void *p; void (*fp)(void);} u;
-  void  *dll_handle;
-  struct ssl_func *fp;
-
-  if ((dll_handle = dlopen(dll_name, RTLD_LAZY)) == NULL) {
-    cry(fc(ctx), "%s: cannot load %s", __func__, dll_name);
-    return 0;
-  }
-
-  for (fp = sw; fp->name != NULL; fp++) {
-#ifdef _WIN32
-    // GetProcAddress() returns pointer to function
-    u.fp = (void (*)(void)) dlsym(dll_handle, fp->name);
-#else
-    // dlsym() on UNIX returns void *. ISO C forbids casts of data pointers to
-    // function pointers. We need to use a union to make a cast.
-    u.p = dlsym(dll_handle, fp->name);
-#endif // _WIN32
-    if (u.fp == NULL) {
-      cry(fc(ctx), "%s: %s: cannot find %s", __func__, dll_name, fp->name);
-      return 0;
-    } else {
-      fp->ptr = u.fp;
-    }
-  }
-
-  return 1;
-}
-#endif // NO_SSL_DL
-
-// Dynamically load SSL library. Set up ctx->ssl_ctx pointer.
-static int set_ssl_option(struct mg_context *ctx) {
-  struct mg_request_info request_info;
-  SSL_CTX *CTX;
-  int i, size;
-  const char *pem = ctx->config[SSL_CERTIFICATE];
-  const char *chain = ctx->config[SSL_CHAIN_FILE];
-
-  if (pem == NULL) {
-    return 1;
-  }
-
-#if !defined(NO_SSL_DL)
-  if (!load_dll(ctx, SSL_LIB, ssl_sw) ||
-      !load_dll(ctx, CRYPTO_LIB, crypto_sw)) {
-    return 0;
-  }
-#endif // NO_SSL_DL
-
-  // Initialize SSL crap
-  SSL_library_init();
-  SSL_load_error_strings();
-
-  if ((CTX = SSL_CTX_new(SSLv23_server_method())) == NULL) {
-    cry(fc(ctx), "SSL_CTX_new error: %s", ssl_error());
-  } else if (ctx->user_callback != NULL) {
-    memset(&request_info, 0, sizeof(request_info));
-    request_info.user_data = ctx->user_data;
-    ctx->user_callback(MG_INIT_SSL, (struct mg_connection *) CTX,
-                       &request_info);
-  }
-
-  if (CTX != NULL && SSL_CTX_use_certificate_file(CTX, pem,
-        SSL_FILETYPE_PEM) == 0) {
-    cry(fc(ctx), "%s: cannot open %s: %s", __func__, pem, ssl_error());
-    return 0;
-  } else if (CTX != NULL && SSL_CTX_use_PrivateKey_file(CTX, pem,
-        SSL_FILETYPE_PEM) == 0) {
-    cry(fc(ctx), "%s: cannot open %s: %s", NULL, pem, ssl_error());
-    return 0;
-  }
-
-  if (CTX != NULL && chain != NULL &&
-      SSL_CTX_use_certificate_chain_file(CTX, chain) == 0) {
-    cry(fc(ctx), "%s: cannot open %s: %s", NULL, chain, ssl_error());
-    return 0;
-  }
-
-  // Initialize locking callbacks, needed for thread safety.
-  // http://www.openssl.org/support/faq.html#PROG1
-  size = sizeof(pthread_mutex_t) * CRYPTO_num_locks();
-  if ((ssl_mutexes = (pthread_mutex_t *) malloc((size_t)size)) == NULL) {
-    cry(fc(ctx), "%s: cannot allocate mutexes: %s", __func__, ssl_error());
-    return 0;
-  }
-
-  for (i = 0; i < CRYPTO_num_locks(); i++) {
-    pthread_mutex_init(&ssl_mutexes[i], NULL);
-  }
-
-  CRYPTO_set_locking_callback(&ssl_locking_callback);
-  CRYPTO_set_id_callback(&ssl_id_callback);
-
-  // Done with everything. Save the context.
-  ctx->ssl_ctx = CTX;
-
-  return 1;
-}
-
-static void uninitialize_ssl(struct mg_context *ctx) {
-  int i;
-  if (ctx->ssl_ctx != NULL) {
-    CRYPTO_set_locking_callback(NULL);
-    for (i = 0; i < CRYPTO_num_locks(); i++) {
-      pthread_mutex_destroy(&ssl_mutexes[i]);
-    }
-    CRYPTO_set_locking_callback(NULL);
-    CRYPTO_set_id_callback(NULL);
-  }
-}
-#endif // !NO_SSL
-
-static int set_gpass_option(struct mg_context *ctx) {
-  struct mgstat mgstat;
-  const char *path = ctx->config[GLOBAL_PASSWORDS_FILE];
-  return path == NULL || mg_stat(path, &mgstat) == 0;
-}
-
-static int set_acl_option(struct mg_context *ctx) {
-  union usa fake;
-  return check_acl(ctx, &fake) != -1;
-}
-
-static void reset_per_request_attributes(struct mg_connection *conn) {
-  struct mg_request_info *ri = &conn->request_info;
-
-  // Reset request info attributes. DO NOT TOUCH is_ssl, remote_ip, remote_port
-  ri->remote_user = ri->request_method = ri->uri = ri->http_version =
-    conn->path_info = NULL;
-  ri->num_headers = 0;
-  ri->status_code = -1;
-
-  conn->num_bytes_sent = conn->consumed_content = 0;
-  conn->content_len = -1;
-  conn->request_len = conn->data_len = 0;
-  conn->must_close = 0;
-}
-
-static void close_socket_gracefully(SOCKET sock) {
-  char buf[BUFSIZ];
-  struct linger linger;
-  int n;
-
-  // Set linger option to avoid socket hanging out after close. This prevent
-  // ephemeral port exhaust problem under high QPS.
-  linger.l_onoff = 1;
-  linger.l_linger = 1;
-  setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *) &linger, sizeof(linger));
-
-  // Send FIN to the client
-  (void) shutdown(sock, SHUT_WR);
-  set_non_blocking_mode(sock);
-
-  // Read and discard pending data. If we do not do that and close the
-  // socket, the data in the send buffer may be discarded. This
-  // behaviour is seen on Windows, when client keeps sending data
-  // when server decide to close the connection; then when client
-  // does recv() it gets no data back.
-  do {
-    n = pull(NULL, sock, NULL, buf, sizeof(buf));
-  } while (n > 0);
-
-  // Now we know that our FIN is ACK-ed, safe to close
-  (void) closesocket(sock);
-}
-
-static void close_connection(struct mg_connection *conn) {
-  if (conn->ssl) {
-    SSL_free(conn->ssl);
-    conn->ssl = NULL;
-  }
-
-  if (conn->client.sock != INVALID_SOCKET) {
-    close_socket_gracefully(conn->client.sock);
-  }
-}
-
-static void discard_current_request_from_buffer(struct mg_connection *conn) {
-  char *buffered;
-  int buffered_len, body_len;
-
-  buffered = conn->buf + conn->request_len;
-  buffered_len = conn->data_len - conn->request_len;
-  assert(buffered_len >= 0);
-
-  if (conn->content_len <= 0) {
-    // Protect from negative Content-Length, too
-    body_len = 0;
-  } else if (conn->content_len < (int64_t) buffered_len) {
-    body_len = (int) conn->content_len;
-  } else {
-    body_len = buffered_len;
-  }
-
-  conn->data_len -= conn->request_len + body_len;
-  memmove(conn->buf, conn->buf + conn->request_len + body_len,
-          (size_t) conn->data_len);
-}
-
-static int is_valid_uri(const char *uri) {
-  // Conform to http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
-  // URI can be an asterisk (*) or should start with slash.
-  return uri[0] == '/' || (uri[0] == '*' && uri[1] == '\0');
-}
-
-static void process_new_connection(struct mg_connection *conn) {
-  struct mg_request_info *ri = &conn->request_info;
-  int keep_alive_enabled;
-  const char *cl;
-
-  keep_alive_enabled = !strcmp(conn->ctx->config[ENABLE_KEEP_ALIVE], "yes");
-
-  do {
-    reset_per_request_attributes(conn);
-    conn->request_len = read_request(NULL, conn->client.sock, conn->ssl,
-                                     conn->buf, conn->buf_size,
-                                     &conn->data_len);
-    assert(conn->data_len >= conn->request_len);
-    if (conn->request_len == 0 && conn->data_len == conn->buf_size) {
-      send_http_error(conn, 413, "Request Too Large", "");
-      return;
-    } if (conn->request_len <= 0) {
-      return;  // Remote end closed the connection
-    }
-
-    // Nul-terminate the request cause parse_http_request() uses sscanf
-    conn->buf[conn->request_len - 1] = '\0';
-    if (!parse_http_request(conn->buf, ri) || !is_valid_uri(ri->uri)) {
-      // Do not put garbage in the access log, just send it back to the client
-      send_http_error(conn, 400, "Bad Request",
-          "Cannot parse HTTP request: [%.*s]", conn->data_len, conn->buf);
-    } else if (strcmp(ri->http_version, "1.0") &&
-               strcmp(ri->http_version, "1.1")) {
-      // Request seems valid, but HTTP version is strange
-      send_http_error(conn, 505, "HTTP version not supported", "");
-      log_access(conn);
-    } else {
-      // Request is valid, handle it
-      cl = get_header(ri, "Content-Length");
-      conn->content_len = cl == NULL ? -1 : strtoll(cl, NULL, 10);
-      conn->birth_time = time(NULL);
-      handle_request(conn);
-      call_user(conn, MG_REQUEST_COMPLETE);
-      log_access(conn);
-      discard_current_request_from_buffer(conn);
-    }
-    if (ri->remote_user != NULL) {
-      free((void *) ri->remote_user);
-    }
-  } while (conn->ctx->stop_flag == 0 &&
-           keep_alive_enabled &&
-           should_keep_alive(conn));
-}
-
-// Worker threads take accepted socket from the queue
-static int consume_socket(struct mg_context *ctx, struct socket *sp) {
-  (void) pthread_mutex_lock(&ctx->mutex);
-  DEBUG_TRACE(("going idle"));
-
-  // If the queue is empty, wait. We're idle at this point.
-  while (ctx->sq_head == ctx->sq_tail && ctx->stop_flag == 0) {
-    pthread_cond_wait(&ctx->sq_full, &ctx->mutex);
-  }
-
-  // If we're stopping, sq_head may be equal to sq_tail.
-  if (ctx->sq_head > ctx->sq_tail) {
-    // Copy socket from the queue and increment tail
-    *sp = ctx->queue[ctx->sq_tail % ARRAY_SIZE(ctx->queue)];
-    ctx->sq_tail++;
-    DEBUG_TRACE(("grabbed socket %d, going busy", sp->sock));
-
-    // Wrap pointers if needed
-    while (ctx->sq_tail > (int) ARRAY_SIZE(ctx->queue)) {
-      ctx->sq_tail -= ARRAY_SIZE(ctx->queue);
-      ctx->sq_head -= ARRAY_SIZE(ctx->queue);
-    }
-  }
-
-  (void) pthread_cond_signal(&ctx->sq_empty);
-  (void) pthread_mutex_unlock(&ctx->mutex);
-
-  return !ctx->stop_flag;
-}
-
-static void worker_thread(struct mg_context *ctx) {
-  struct mg_connection *conn;
-  int buf_size = atoi(ctx->config[MAX_REQUEST_SIZE]);
-
-  conn = (struct mg_connection *) calloc(1, sizeof(*conn) + buf_size);
-  if (conn == NULL) {
-    cry(fc(ctx), "%s", "Cannot create new connection struct, OOM");
-    return;
-  }
-  conn->buf_size = buf_size;
-  conn->buf = (char *) (conn + 1);
-
-  // Call consume_socket() even when ctx->stop_flag > 0, to let it signal
-  // sq_empty condvar to wake up the master waiting in produce_socket()
-  while (consume_socket(ctx, &conn->client)) {
-    conn->birth_time = time(NULL);
-    conn->ctx = ctx;
-
-    // Fill in IP, port info early so even if SSL setup below fails,
-    // error handler would have the corresponding info.
-    // Thanks to Johannes Winkelmann for the patch.
-    // TODO(lsm): Fix IPv6 case
-    conn->request_info.remote_port = ntohs(conn->client.rsa.sin.sin_port);
-    memcpy(&conn->request_info.remote_ip,
-           &conn->client.rsa.sin.sin_addr.s_addr, 4);
-    conn->request_info.remote_ip = ntohl(conn->request_info.remote_ip);
-    conn->request_info.is_ssl = conn->client.is_ssl;
-
-    if (!conn->client.is_ssl ||
-        (conn->client.is_ssl && sslize(conn, SSL_accept))) {
-      process_new_connection(conn);
-    }
-
-    close_connection(conn);
-  }
-  free(conn);
-
-  // Signal master that we're done with connection and exiting
-  (void) pthread_mutex_lock(&ctx->mutex);
-  ctx->num_threads--;
-  (void) pthread_cond_signal(&ctx->cond);
-  assert(ctx->num_threads >= 0);
-  (void) pthread_mutex_unlock(&ctx->mutex);
-
-  DEBUG_TRACE(("exiting"));
-}
-
-// Master thread adds accepted socket to a queue
-static void produce_socket(struct mg_context *ctx, const struct socket *sp) {
-  (void) pthread_mutex_lock(&ctx->mutex);
-
-  // If the queue is full, wait
-  while (ctx->stop_flag == 0 &&
-         ctx->sq_head - ctx->sq_tail >= (int) ARRAY_SIZE(ctx->queue)) {
-    (void) pthread_cond_wait(&ctx->sq_empty, &ctx->mutex);
-  }
-
-  if (ctx->sq_head - ctx->sq_tail < (int) ARRAY_SIZE(ctx->queue)) {
-    // Copy socket to the queue and increment head
-    ctx->queue[ctx->sq_head % ARRAY_SIZE(ctx->queue)] = *sp;
-    ctx->sq_head++;
-    DEBUG_TRACE(("queued socket %d", sp->sock));
-  }
-
-  (void) pthread_cond_signal(&ctx->sq_full);
-  (void) pthread_mutex_unlock(&ctx->mutex);
-}
-
-static void accept_new_connection(const struct socket *listener,
-                                  struct mg_context *ctx) {
-  struct socket accepted;
-  char src_addr[20];
-  socklen_t len;
-  int allowed;
-
-  len = sizeof(accepted.rsa);
-  accepted.lsa = listener->lsa;
-  accepted.sock = accept(listener->sock, &accepted.rsa.sa, &len);
-  if (accepted.sock != INVALID_SOCKET) {
-    allowed = check_acl(ctx, &accepted.rsa);
-    if (allowed) {
-      // Put accepted socket structure into the queue
-      DEBUG_TRACE(("accepted socket %d", accepted.sock));
-      accepted.is_ssl = listener->is_ssl;
-      produce_socket(ctx, &accepted);
-    } else {
-      sockaddr_to_string(src_addr, sizeof(src_addr), &accepted.rsa);
-      cry(fc(ctx), "%s: %s is not allowed to connect", __func__, src_addr);
-      (void) closesocket(accepted.sock);
-    }
-  }
-}
-
-static void master_thread(struct mg_context *ctx) {
-  fd_set read_set;
-  struct timeval tv;
-  struct socket *sp;
-  int max_fd;
-
-  // Increase priority of the master thread
-#if defined(_WIN32)
-  SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
-#endif
-  
-#if defined(ISSUE_317)
-  struct sched_param sched_param;
-  sched_param.sched_priority = sched_get_priority_max(SCHED_RR);
-  pthread_setschedparam(pthread_self(), SCHED_RR, &sched_param);
-#endif
-
-  while (ctx->stop_flag == 0) {
-    FD_ZERO(&read_set);
-    max_fd = -1;
-
-    // Add listening sockets to the read set
-    for (sp = ctx->listening_sockets; sp != NULL; sp = sp->next) {
-      add_to_set(sp->sock, &read_set, &max_fd);
-    }
-
-    tv.tv_sec = 0;
-    tv.tv_usec = 200 * 1000;
-
-    if (select(max_fd + 1, &read_set, NULL, NULL, &tv) < 0) {
-#ifdef _WIN32
-      // On windows, if read_set and write_set are empty,
-      // select() returns "Invalid parameter" error
-      // (at least on my Windows XP Pro). So in this case, we sleep here.
-      mg_sleep(1000);
-#endif // _WIN32
-    } else {
-      for (sp = ctx->listening_sockets; sp != NULL; sp = sp->next) {
-        if (ctx->stop_flag == 0 && FD_ISSET(sp->sock, &read_set)) {
-          accept_new_connection(sp, ctx);
-        }
-      }
-    }
-  }
-  DEBUG_TRACE(("stopping workers"));
-
-  // Stop signal received: somebody called mg_stop. Quit.
-  close_all_listening_sockets(ctx);
-
-  // Wakeup workers that are waiting for connections to handle.
-  pthread_cond_broadcast(&ctx->sq_full);
-
-  // Wait until all threads finish
-  (void) pthread_mutex_lock(&ctx->mutex);
-  while (ctx->num_threads > 0) {
-    (void) pthread_cond_wait(&ctx->cond, &ctx->mutex);
-  }
-  (void) pthread_mutex_unlock(&ctx->mutex);
-
-  // All threads exited, no sync is needed. Destroy mutex and condvars
-  (void) pthread_mutex_destroy(&ctx->mutex);
-  (void) pthread_cond_destroy(&ctx->cond);
-  (void) pthread_cond_destroy(&ctx->sq_empty);
-  (void) pthread_cond_destroy(&ctx->sq_full);
-
-#if !defined(NO_SSL)
-  uninitialize_ssl(ctx);
-#endif
-
-  // Signal mg_stop() that we're done
-  ctx->stop_flag = 2;
-
-  DEBUG_TRACE(("exiting"));
-}
-
-static void free_context(struct mg_context *ctx) {
-  int i;
-
-  // Deallocate config parameters
-  for (i = 0; i < NUM_OPTIONS; i++) {
-    if (ctx->config[i] != NULL)
-      free(ctx->config[i]);
-  }
-
-  // Deallocate SSL context
-  if (ctx->ssl_ctx != NULL) {
-    SSL_CTX_free(ctx->ssl_ctx);
-  }
-#ifndef NO_SSL
-  if (ssl_mutexes != NULL) {
-    free(ssl_mutexes);
-  }
-#endif // !NO_SSL
-
-  // Deallocate context itself
-  free(ctx);
-}
-
-void mg_stop(struct mg_context *ctx) {
-  ctx->stop_flag = 1;
-
-  // Wait until mg_fini() stops
-  while (ctx->stop_flag != 2) {
-    mg_sleep(10);
-  }
-  free_context(ctx);
-
-#if defined(_WIN32) && !defined(__SYMBIAN32__)
-  (void) WSACleanup();
-#endif // _WIN32
-}
-
-struct mg_context *mg_start(mg_callback_t user_callback, void *user_data,
-                            const char **options) {
-  struct mg_context *ctx;
-  const char *name, *value, *default_value;
-  int i;
-
-#if defined(_WIN32) && !defined(__SYMBIAN32__)
-  WSADATA data;
-  WSAStartup(MAKEWORD(2,2), &data);
-  InitializeCriticalSection(&global_log_file_lock);
-#endif // _WIN32
-
-  // Allocate context and initialize reasonable general case defaults.
-  // TODO(lsm): do proper error handling here.
-  ctx = (struct mg_context *) calloc(1, sizeof(*ctx));
-  ctx->user_callback = user_callback;
-  ctx->user_data = user_data;
-
-  while (options && (name = *options++) != NULL) {
-    if ((i = get_option_index(name)) == -1) {
-      cry(fc(ctx), "Invalid option: %s", name);
-      free_context(ctx);
-      return NULL;
-    } else if ((value = *options++) == NULL) {
-      cry(fc(ctx), "%s: option value cannot be NULL", name);
-      free_context(ctx);
-      return NULL;
-    }
-    if (ctx->config[i] != NULL) {
-      cry(fc(ctx), "%s: duplicate option", name);
-    }
-    ctx->config[i] = mg_strdup(value);
-    DEBUG_TRACE(("[%s] -> [%s]", name, value));
-  }
-
-  // Set default value if needed
-  for (i = 0; config_options[i * ENTRIES_PER_CONFIG_OPTION] != NULL; i++) {
-    default_value = config_options[i * ENTRIES_PER_CONFIG_OPTION + 2];
-    if (ctx->config[i] == NULL && default_value != NULL) {
-      ctx->config[i] = mg_strdup(default_value);
-      DEBUG_TRACE(("Setting default: [%s] -> [%s]",
-                   config_options[i * ENTRIES_PER_CONFIG_OPTION + 1],
-                   default_value));
-    }
-  }
-
-  // NOTE(lsm): order is important here. SSL certificates must
-  // be initialized before listening ports. UID must be set last.
-  if (!set_gpass_option(ctx) ||
-#if !defined(NO_SSL)
-      !set_ssl_option(ctx) ||
-#endif
-      !set_ports_option(ctx) ||
-#if !defined(_WIN32)
-      !set_uid_option(ctx) ||
-#endif
-      !set_acl_option(ctx)) {
-    free_context(ctx);
-    return NULL;
-  }
-
-#if !defined(_WIN32) && !defined(__SYMBIAN32__)
-  // Ignore SIGPIPE signal, so if browser cancels the request, it
-  // won't kill the whole process.
-  (void) signal(SIGPIPE, SIG_IGN);
-  // Also ignoring SIGCHLD to let the OS to reap zombies properly.
-  (void) signal(SIGCHLD, SIG_IGN);
-#endif // !_WIN32
-
-  (void) pthread_mutex_init(&ctx->mutex, NULL);
-  (void) pthread_cond_init(&ctx->cond, NULL);
-  (void) pthread_cond_init(&ctx->sq_empty, NULL);
-  (void) pthread_cond_init(&ctx->sq_full, NULL);
-
-  // Start master (listening) thread
-  start_thread(ctx, (mg_thread_func_t) master_thread, ctx);
-
-  // Start worker threads
-  for (i = 0; i < atoi(ctx->config[NUM_THREADS]); i++) {
-    if (start_thread(ctx, (mg_thread_func_t) worker_thread, ctx) != 0) {
-      cry(fc(ctx), "Cannot start worker thread: %d", ERRNO);
-    } else {
-      ctx->num_threads++;
-    }
-  }
-
-  return ctx;
-}
Index: rvices/mghttpd/mongoose.h
===================================================================
--- services/mghttpd/mongoose.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,238 +1,0 @@
-// Copyright (c) 2004-2011 Sergey Lyubka
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef MONGOOSE_HEADER_INCLUDED
-#define  MONGOOSE_HEADER_INCLUDED
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-struct mg_context;     // Handle for the HTTP service itself
-struct mg_connection;  // Handle for the individual connection
-
-
-// This structure contains information about the HTTP request.
-struct mg_request_info {
-  void *user_data;       // User-defined pointer passed to mg_start()
-  char *request_method;  // "GET", "POST", etc
-  char *uri;             // URL-decoded URI
-  char *http_version;    // E.g. "1.0", "1.1"
-  char *query_string;    // URL part after '?' (not including '?') or NULL
-  char *remote_user;     // Authenticated user, or NULL if no auth used
-  char *log_message;     // Mongoose error log message, MG_EVENT_LOG only
-  long remote_ip;        // Client's IP address
-  int remote_port;       // Client's port
-  int status_code;       // HTTP reply status code, e.g. 200
-  int is_ssl;            // 1 if SSL-ed, 0 if not
-  int num_headers;       // Number of headers
-  struct mg_header {
-    char *name;          // HTTP header name
-    char *value;         // HTTP header value
-  } http_headers[64];    // Maximum 64 headers
-};
-
-// Various events on which user-defined function is called by Mongoose.
-enum mg_event {
-  MG_NEW_REQUEST,   // New HTTP request has arrived from the client
-  MG_HTTP_ERROR,    // HTTP error must be returned to the client
-  MG_EVENT_LOG,     // Mongoose logs an event, request_info.log_message
-  MG_INIT_SSL,      // Mongoose initializes SSL. Instead of mg_connection *,
-                    // SSL context is passed to the callback function.
-  MG_REQUEST_COMPLETE  // Mongoose has finished handling the request
-};
-
-// Prototype for the user-defined function. Mongoose calls this function
-// on every MG_* event.
-//
-// Parameters:
-//   event: which event has been triggered.
-//   conn: opaque connection handler. Could be used to read, write data to the
-//         client, etc. See functions below that have "mg_connection *" arg.
-//   request_info: Information about HTTP request.
-//
-// Return:
-//   If handler returns non-NULL, that means that handler has processed the
-//   request by sending appropriate HTTP reply to the client. Mongoose treats
-//   the request as served.
-//   If handler returns NULL, that means that handler has not processed
-//   the request. Handler must not send any data to the client in this case.
-//   Mongoose proceeds with request handling as if nothing happened.
-typedef void * (*mg_callback_t)(enum mg_event event,
-                                struct mg_connection *conn,
-                                const struct mg_request_info *request_info);
-
-
-// Start web server.
-//
-// Parameters:
-//   callback: user defined event handling function or NULL.
-//   options: NULL terminated list of option_name, option_value pairs that
-//            specify Mongoose configuration parameters.
-//
-// Side-effects: on UNIX, ignores SIGCHLD and SIGPIPE signals. If custom
-//    processing is required for these, signal handlers must be set up
-//    after calling mg_start().
-//
-//
-// Example:
-//   const char *options[] = {
-//     "document_root", "/var/www",
-//     "listening_ports", "80,443s",
-//     NULL
-//   };
-//   struct mg_context *ctx = mg_start(&my_func, NULL, options);
-//
-// Please refer to http://code.google.com/p/mongoose/wiki/MongooseManual
-// for the list of valid option and their possible values.
-//
-// Return:
-//   web server context, or NULL on error.
-struct mg_context *mg_start(mg_callback_t callback, void *user_data,
-                            const char **options);
-
-
-// Stop the web server.
-//
-// Must be called last, when an application wants to stop the web server and
-// release all associated resources. This function blocks until all Mongoose
-// threads are stopped. Context pointer becomes invalid.
-void mg_stop(struct mg_context *);
-
-
-// Get the value of particular configuration parameter.
-// The value returned is read-only. Mongoose does not allow changing
-// configuration at run time.
-// If given parameter name is not valid, NULL is returned. For valid
-// names, return value is guaranteed to be non-NULL. If parameter is not
-// set, zero-length string is returned.
-const char *mg_get_option(const struct mg_context *ctx, const char *name);
-
-
-// Return array of strings that represent valid configuration options.
-// For each option, a short name, long name, and default value is returned.
-// Array is NULL terminated.
-const char **mg_get_valid_option_names(void);
-
-
-// Add, edit or delete the entry in the passwords file.
-//
-// This function allows an application to manipulate .htpasswd files on the
-// fly by adding, deleting and changing user records. This is one of the
-// several ways of implementing authentication on the server side. For another,
-// cookie-based way please refer to the examples/chat.c in the source tree.
-//
-// If password is not NULL, entry is added (or modified if already exists).
-// If password is NULL, entry is deleted.
-//
-// Return:
-//   1 on success, 0 on error.
-int mg_modify_passwords_file(const char *passwords_file_name,
-                             const char *domain,
-                             const char *user,
-                             const char *password);
-
-// Send data to the client.
-int mg_write(struct mg_connection *, const void *buf, size_t len);
-
-
-// Send data to the browser using printf() semantics.
-//
-// Works exactly like mg_write(), but allows to do message formatting.  Note
-// that mg_printf() uses internal buffer of size BUFSIZ defined in <stdio.h>
-// (8 KiB on most Linux systems) as temporary message storage for formatting.
-// Do not print data that is bigger than that, otherwise it will be truncated.
-int mg_printf(struct mg_connection *, const char *fmt, ...)
-#ifdef __GNUC__
-__attribute__((format(printf, 2, 3)))
-#endif
-;
-
-
-// Send contents of the entire file together with HTTP headers.
-void mg_send_file(struct mg_connection *conn, const char *path);
-
-
-// Read data from the remote end, return number of bytes read.
-int mg_read(struct mg_connection *, void *buf, size_t len);
-
-
-// Get the value of particular HTTP header.
-//
-// This is a helper function. It traverses request_info->http_headers array,
-// and if the header is present in the array, returns its value. If it is
-// not present, NULL is returned.
-const char *mg_get_header(const struct mg_connection *, const char *name);
-
-
-// Get a value of particular form variable.
-//
-// Parameters:
-//   data: pointer to form-uri-encoded buffer. This could be either POST data,
-//         or request_info.query_string.
-//   data_len: length of the encoded data.
-//   var_name: variable name to decode from the buffer
-//   buf: destination buffer for the decoded variable
-//   buf_len: length of the destination buffer
-//
-// Return:
-//   On success, length of the decoded variable.
-//   On error, -1 (variable not found, or destination buffer is too small).
-//
-// Destination buffer is guaranteed to be '\0' - terminated. In case of
-// failure, dst[0] == '\0'.
-int mg_get_var(const char *data, size_t data_len,
-               const char *var_name, char *buf, size_t buf_len);
-
-// Fetch value of certain cookie variable into the destination buffer.
-//
-// Destination buffer is guaranteed to be '\0' - terminated. In case of
-// failure, dst[0] == '\0'. Note that RFC allows many occurrences of the same
-// parameter. This function returns only first occurrence.
-//
-// Return:
-//   On success, value length.
-//   On error, 0 (either "Cookie:" header is not present at all, or the
-//   requested parameter is not found, or destination buffer is too small
-//   to hold the value).
-int mg_get_cookie(const struct mg_connection *,
-                  const char *cookie_name, char *buf, size_t buf_len);
-
-
-// Return Mongoose version.
-const char *mg_version(void);
-
-
-// MD5 hash given strings.
-// Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of
-// asciiz strings. When function returns, buf will contain human-readable
-// MD5 hash. Example:
-//   char buf[33];
-//   mg_md5(buf, "aa", "bb", NULL);
-void mg_md5(char *buf, ...);
-
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif // MONGOOSE_HEADER_INCLUDED
Index: rvices/nfsclient/ChangeLog.slac
===================================================================
--- services/nfsclient/ChangeLog.slac	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,112 +1,0 @@
-Changes since RTEMS-NFS 1.4:
-LICENSE:
- - changed license terms; RTEMS-NFS is now released under the more liberal
-   'SLAC license'.
-NFS:
- - silenced compiler warnings (follow handler declaration changes in libio.h
-   by using 'size_t' instead of 'uint32_t' etc.).
-
-Changes since RTEMS-NFS 1.3:
-RPCIOD:
- - round timeout to next system clock tick and ensure it is at least
-   1 tick.
- - cap retransmission timeout to transaction lifetime.
- - BUGFIX (reported by Steven Johnson, 12/5/06): we must change the XID
-   before sending a timed-out transaction back to the requestor to prevent
-   a late reply from being accepted.
- - Made task priority run-time configurable (and read from rtems_bsdnet_config
-   by default).
-
-NFS:
- - added nfsGetTimeout() and nfsSetTimeout() to retrieve and modify,
-   respectively the (global) timeout for NFS/MOUNT operations.
- - Minor mod. to fix 'type-punned pointer' warning (can avoid pointer cast).
- - Added global variable 'nfsStBlksize' (defaults to 8k) which is now
-   used to report the file system's 'preferred' blocksize (stat(2)/st_blksize).
-   The old behavior (server's fattr.st_blksize is passed through) can be
-   obtained by setting nfsStBlksize=0.
-   The new feature lets stdio use 8k buffers (only if newlib was built with
-   HAVE_BLKSIZE defined). This enhances NFS (buffered) read performance quite
-   a bit. Thanks to Steven Johnson <sjohnson@sakuraindustries.com> for helping
-   with this.
- - Updated README (performance section).
- - Added simple performance test: nfsTest.c
-
-Changes since RTEMS-NFS 1.3_pre2:
- RPCIOD:
- - fix a problem with NFS server clusters (reply comes from an IP address
-   different from the destination of the request) by relaxing paranoia checks.
-
-Changes since RTEMS-NFS 1.2:
- NFS:
- - replaced inet_aton -> inet_pton
- - replaced unsigned32 -> uint32_t
- - added _KERNEL definition for 4.7 compilation
- - silenced compiler warnings (4.7)
- - added -Wno-unused-variable in 'proto' -- rpcgen produces a lot of them.
- - new locking scheme. The 'in-use' counters cannot be protected by a mutex
-   because files might be closed when a thread is deleted from a dispatch-disabled
-   section where mutexes must not be locked. The counters are now protected by
-   disabling interrupts.
-   The only critical race-condition I can see ATM is while the NFS is being
-   unmounted and the mount point is crossed by another thread. It should be the
-   generic FS code's responsibility to handle that (but AFAIK, it doesn't) --
-   it's out of our scope...
- - ftruncate didn't work. The functionality is achieved by nfs_sattr()
-   setting the file size to 0. However, nfs_sattr() always tried to set
-   all attributes (re-applying the current values to fields we didn't
-   want to change) which failed (EPERM) if we were not the owner.
-   Now, we restrict modifications to the requested fields (in case of
-   ftruncate this is *only* the size), adhering to rfc1094 (which states
-   that unused fields shall be set to -1).
- - lseek(SEEK_END) didn't work. The underlying RTEMS filesystem code
-   uses an internal file 'size' field to compute the offset whence SEEK_END.
-   Instead of painfully maintaining 'size' across all system calls, we
-   just tweak the offset for SEEK_END and leave 'size' unused.
- - fix: O_APPEND wasn't honoured. Note that there is no NFS 'append' call - 
-   the client simply uses the currently available idea of the file size
-   to set the write offset. This obviously is subject to race conditions
-   if multiple clients are writing the same file.
- dirutils:
- - replaced read/write calls by stdio; In case of copying to stdout, I
-   experienced occasional crashes when write(fileno(stdout),...) -- according
-   to the standard, mixing low-level i/o with stdio might produce undefined
-   results; there we go...
-
-Changes since RTEMS-NFS 1.1:
- NFS:
- - unlink() didnt work. The underlying RTEMS filesystem code evaluates
-   a '..' path on a non-directory node to find out the file's parent
-   directory. Workaround to this semantically inelegant RTEMS feature
-   was implemented.
-  
-Changes since RTEMS-NFS 1.0.beta3:
- NFS:
- - fixed possible string overrun in nfsMount
- - nfs_read_dir() must reset the 'eofreached' flag if it skipped
-   dirents present in the xdr but not fitting into the user buffer.
- - nfsMountsShow() released the wrong lock!
- RPCIO:
- - cannot delete locked binary semaphore (authlock) -- must unlock
-   first (authlock was never deleted and hence effectively leaked)
- - added ASSERT paranoia around mutex primitives
- - Relaxed paranoia check / ASSERTion failure:
-   paranoia_free() is called more than once on an ext_buf - it must
-   undo calls to paranoia_refcnt() - hence the 0 == --refcnt check
-   is too strict.
- - Added a DEBUG flag to introduce random packet losses for testing
-   retransmission.
- xdr_mbuf:
- - make sure we do a signed comparison
-
-Changes since rtemsNFS-1.0.beta2:
- - moved 'tar' command to the 'config' area; use
-   predefined 'make-tar' in individual Makefiles
- - use INSTALL_CHANGE for headers, not INSTALL_VARIANT (probably doesn't
-   matter, though)
- - use LD not LD_FOR_TARGET (to get absolute path)
- - fixed assertion failure print format
- - print requestor id if send_event fails - had just experienced this :-(
- - hint about fprintf using FP registers is probably PPC specific
- - provided implementation for xdrmbuf_getlong_aligned(). i386-rtems
-   seems to use it.
Index: rvices/nfsclient/LICENSE
===================================================================
--- services/nfsclient/LICENSE	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/* 
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
- * 	   Stanford Linear Accelerator Center, Stanford University.
- * 
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- * 
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- * 
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- * 
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.  
- * 
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- * 
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */ 
Index: rvices/nfsclient/Makefile
===================================================================
--- services/nfsclient/Makefile	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,49 +1,0 @@
-include ../../config.inc
-
-include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
-include $(RTEMS_CUSTOM)
-include $(PROJECT_ROOT)/make/leaf.cfg
-
-CFLAGS += -I $(INSTALL_BASE)/include
-
-CFLAGS += -w 
-CFLAGS += -I include 
-CFLAGS += -I proto 
-CFLAGS += -std=gnu99
-CFLAGS += -MT $@ -MD -MP -MF $(basename $@).d
-
-C_FILES =
-C_FILES += nfs.c
-C_FILES += rpcio.c
-C_FILES += sock_mbuf.c
-C_FILES += xdr_mbuf.c
-
-# CEXP additions
-# C_FILES += cexphelp.c dirutils.c nfs.modini.c rpcio.modini.c
-
-# This appears to be a test program which no longer compiles and was in
-# the wrong directory
-C_FILES += nfsTest.c
-
-C_O_FILES = $(C_FILES:%.c=%.o)
-C_D_FILES = $(C_FILES:%.c=%.d)
-
-LIB = libnfs.a
-
-all: $(LIB)
-
-$(LIB): $(C_O_FILES)
-	$(AR) rcu $@ $^
-
-install: $(LIB)
-	install -d $(INSTALL_BASE)/include/rtems
-	install -c -m 644 include/rtems/ftpfs.h $(INSTALL_BASE)/
-	install -c -m 644 $(LIB) $(INSTALL_BASE)
-
-clean:
-	rm -f $(LIB) $(C_O_FILES) $(C_D_FILES) $(GEN_FILES)
-
--include $(C_D_FILES)
-
-doc: 
-
Index: rvices/nfsclient/README
===================================================================
--- services/nfsclient/README	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,548 +1,0 @@
-RTEMS-NFS
-=========
-
-A NFS-V2 client implementation for the RTEMS real-time
-executive.
-
-Author: Till Straumann <strauman@slac.stanford.edu>, 2002
-
-Copyright 2002, Stanford University and
-                Till Straumann <strauman@slac.stanford.edu>
-
-Stanford Notice
-***************
-
-Acknowledgement of sponsorship
-* * * * * * * * * * * * * * * *
-This software was produced by the Stanford Linear Accelerator Center,
-Stanford University, under Contract DE-AC03-76SFO0515 with the Department
-of Energy.
-
-
-Contents
---------
-I   Overview
-  1) Performance
-  2) Reference Platform / Test Environment
-
-II  Usage
-  1) Initialization
-  2) Mounting Remote Server Filesystems
-  3) Unmounting
-  4) Unloading
-  5) Dumping Information / Statistics
-
-III Implementation Details
-  1) RPCIOD
-  2) NFS
-  3) RTEMS Resources Used By NFS/RPCIOD
-  4) Caveats & Bugs
-
-IV  Licensing & Disclaimers
-
-I  Overview
------------
-
-This package implements a simple non-caching NFS
-client for RTEMS. Most of the system calls are
-supported with the exception of 'mount', i.e. it
-is not possible to mount another FS on top of NFS
-(mostly because of the difficulty that arises when
-mount points are deleted on the server). It
-shouldn't be hard to do, though.
-
-Note: this client supports NFS vers. 2 / MOUNT vers. 1;
-      NFS Version 3 or higher are NOT supported.
-
-The package consists of two modules: RPCIOD and NFS
-itself.
-
- - RPCIOD is a UDP/RPC multiplexor daemon. It takes
-   RPC requests from multiple local client threads,
-   funnels them through a single socket to multiple
-   servers and dispatches the replies back to the
-   (blocked) requestor threads.
-   RPCIOD does packet retransmission and handles
-   timeouts etc.
-   Note however, that it does NOT do any XDR
-   marshalling - it is up to the requestor threads
-   to do the XDR encoding/decoding. RPCIOD _is_ RPC
-   specific, though, because its message dispatching
-   is based on the RPC transaction ID.
-
- - The NFS package maps RTEMS filesystem calls
-   to proper RPCs, it does the XDR work and
-   hands marshalled RPC requests to RPCIOD.
-   All of the calls are synchronous, i.e. they
-   block until they get a reply.
-
-1) Performance
-- - - - - - - -
-Performance sucks (due to the lack of
-readahead/delayed write and caching). On a fast
-(100Mb/s) ethernet, it takes about 20s to copy a
-10MB file from NFS to NFS.  I found, however, that
-vxWorks' NFS client doesn't seem to be any
-faster...
-
-Since there is no buffer cache with read-ahead
-implemented, all NFS reads are synchronous RPC
-calls. Every read operation involves sending a
-request and waiting for the reply. As long as the
-overhead (sending request + processing it on the
-server) is significant compared to the time it
-takes to transferring the actual data, increasing
-the amount of data per request results in better
-throughput. The UDP packet size limit imposes a
-limit of 8k per RPC call, hence reading from NFS
-in chunks of 8k is better than chunks of 1k [but
-chunks >8k are not possible, i.e., simply not
-honoured: read(a_nfs_fd, buf, 20000) returns
-8192]. This is similar to the old linux days
-(mount with rsize=8k).  You can let stdio take
-care of the buffering or use 8k buffers with
-explicit read(2) operations. Note that stdio
-honours the file-system's st_blksize field
-if newlib is compiled with HAVE_BLKSIZE defined.
-In this case, stdio uses 8k buffers for files
-on NFS transparently. The blocksize NFS 
-reports can be tuned with a global variable
-setting (see nfs.c for details).
-
-Further increase of throughput can be achieved
-with read-ahead (issuing RPC calls in parallel
-[send out request for block n+1 while you are
-waiting for data of block n to arrive]).  Since
-this is not handled by the file system itself, you
-would have to code this yourself e.g., using
-parallel threads to read from a single file from
-interleaved offsets.
-
-Another obvious improvement can be achieved if
-processing the data takes a significant amount of
-time. Then, having a pipeline of threads for
-reading data and processing them makes sense
-[thread b processes chunk n while thread a blocks
-in read(chunk n+1)].
-
-Some performance figures:
-Software: src/nfsTest.c:nfsReadTest() [data not
-          processed in any way].
-Hardware: MVME6100
-Network:  100baseT-FD
-Server:   Linux-2.6/RHEL4-smp [dell precision 420]
-File:     10MB
-
-Results:
-Single threaded ('normal') NFS read, 1k buffers: 3.46s (2.89MB/s)
-Single threaded ('normal') NFS read, 8k buffers: 1.31s (7.63MB/s)
-Multi  threaded; 2 readers, 8k buffers/xfers:    1.12s (8.9 MB/s)  
-Multi  threaded; 3 readers, 8k buffers/xfers:    1.04s (9.6 MB/s)
-
-2) Reference Platform
-- - - - - - - - - - -
-RTEMS-NFS was developed and tested on
-
- o RTEMS-ss20020301 (local patches applied)
- o PowerPC G3, G4 on Synergy SVGM series board
-   (custom 'SVGM' BSP, to be released soon)
- o PowerPC 604 on MVME23xx
-   (powerpc/shared/motorola-powerpc BSP)
- o Test Environment:
-    - RTEMS executable running CEXP
-    - rpciod/nfs dynamically loaded from TFTPfs
-    - EPICS application dynamically loaded from NFS;
-      the executing IOC accesses all of its files
-      on NFS.
-
-II Usage
----------
-
-After linking into the system and proper initialization
-(rtems-NFS supports 'magic' module initialization when
-loaded into a running system with the CEXP loader),
-you are ready for mounting NFSes from a server
-(I avoid the term NFS filesystem because NFS already
-stands for 'Network File System').
-
-You should also read the
-
-  - "RTEMS Resources Used By NFS/RPCIOD"
-  - "CAVEATS & BUGS"
-
-below.
-
-1) Initialization
-- - - - - - - - - 
-NFS consists of two modules who must be initialized:
-
- a) the RPCIO daemon package; by calling
-
-      rpcUdpInit();
-
-    note that this step must be performed prior to
-    initializing NFS:
-
- b) NFS is initialized by calling
-
-      nfsInit( smallPoolDepth, bigPoolDepth );
-
-    if you supply 0 (zero) values for the pool
-    depths, the compile-time default configuration
-    is used which should work fine.
-
-NOTE: when using CEXP to load these modules into a
-running system, initialization will be performed
-automagically.
-
-2) Mounting Remote Server Filesystems
-- - - - - - - - - - - - - - - - - - -
-
-There are two interfaces for mounting an NFS:
-
- - The (non-POSIX) RTEMS 'mount()' call:
-
-     mount( &mount_table_entry_pointer,
-            &filesystem_operations_table_pointer,
-            options,
-            device,
-            mount_point )
-
-    Note that you must specify a 'mount_table_entry_pointer'
-    (use a dummy) - RTEMS' mount() doesn't grok a NULL for
-    the first argument.
-
-     o for the 'filesystem_operations_table_pointer', supply
-
-         &nfs_fs_ops
-   
-     o options are constants (see RTEMS headers) for specifying
-       read-only / read-write mounts.
-
-     o the 'device' string specifies the remote filesystem
-       who is to be mounted. NFS expects a string conforming
-       to the following format (EBNF syntax):
-
-         [ <uid> '.' <gid> '@' ] <hostip> ':' <path>
-
-       The first optional part of the string allows you
-       to specify the credentials to be used for all
-       subsequent transactions with this server. If the
-       string is omitted, the EUID/EGID of the executing
-       thread (i.e. the thread performing the 'mount' - 
-       NFS will still 'remember' these values and use them
-       for all future communication with this server).
-       
-       The <hostip> part denotes the server IP address
-       in standard 'dot' notation. It is followed by
-       a colon and the (absolute) path on the server.
-       Note that no extra characters or whitespace must
-       be present in the string. Example 'device' strings
-       are:
-
-         "300.99@192.168.44.3:/remote/rtems/root"
-
-         "192.168.44.3:/remote/rtems/root"
-
-    o the 'mount_point' string identifies the local
-      directory (most probably on IMFS) where the NFS
-      is to be mounted. Note that the mount point must
-      already exist with proper permissions.
-
- - Alternate 'mount' interface. NFS offers a more
-   convenient wrapper taking three string arguments:
-
-	nfsMount(uidgid_at_host, server_path, mount_point)
-
-   This interface does DNS lookup (see reentrancy note
-   below) and creates the mount point if necessary.
-   
-   o the first argument specifies the server and
-     optionally the uid/gid to be used for authentication.
-     The semantics are exactly as described above:
-
-       [ <uid> '.' <gid> '@' ] <host>
-     
-     The <host> part may be either a host _name_ or
-     an IP address in 'dot' notation. In the former
-     case, nfsMount() uses 'gethostbyname()' to do
-     a DNS lookup.
-
-     IMPORTANT NOTE: gethostbyname() is NOT reentrant/
-     thread-safe and 'nfsMount()' (if not provided with an
-     IP/dot address string) is hence subject to race conditions.
- 
-   o the 'server_path' and 'mount_point' arguments
-     are described above.
-     NOTE: If the mount point does not exist yet,
-           nfsMount() tries to create it.
-
-   o if nfsMount() is called with a NULL 'uidgid_at_host'
-     argument, it lists all currently mounted NFS
-
-3) Unmounting
-- - - - - - -
-An NFS can be unmounted using RTEMS 'unmount()'
-call (yep, it is unmount() - not umount()):
-
-  unmount(mount_point)
-
-Note that you _must_ supply the mount point (string
-argument). It is _not_ possible to specify the
-'mountee' when unmounting. NFS implements no
-convenience wrapper for this (yet), essentially because
-(although this sounds unbelievable) it is non-trivial
-to lookup the path leading to an RTEMS filesystem
-directory node.
-
-4) Unloading
-- - - - - - -
-After unmounting all NFS from the system, the NFS
-and RPCIOD modules may be stopped and unloaded.
-Just call 'nfsCleanup()' and 'rpcUdpCleanup()'
-in this order. You should evaluate the return value
-of these routines which is non-zero if either
-of them refuses to yield (e.g. because there are
-still mounted filesystems).
-Again, when unloading is done by CEXP this is
-transparently handled.
-
-5) Dumping Information / Statistics
-- - - - - - - - - - - - - - - - - -
-
-Rudimentary RPCIOD statistics are printed
-to a file (stdout when NULL) by
-
-  int rpcUdpStats(FILE *f)
-
-A list of all currently mounted NFS can be
-printed to a file (stdout if NULL) using
-
-  int nfsMountsShow(FILE *f)
-
-For convenience, this routine is also called
-by nfsMount() when supplying NULL arguments.
-
-III Implementation Details
---------------------------
-
-1) RPCIOD
-- - - - -
-
-RPCIOD was created to
-
-a) avoid non-reentrant librpc calls.
-b) support 'asynchronous' operation over a single
-   socket.
-
-RPCIOD is a daemon thread handling 'transaction objects'
-(XACTs) through an UDP socket.  XACTs are marshalled RPC
-calls/replies associated with RPC servers and requestor
-threads.
-
-requestor thread:                 network:
-
-       XACT                        packet  
-        |                            |
-        V                            V
-  | message queue |              ( socket )
-        |                            |  ^
-        ---------->          <-----  |  |
-                     RPCIOD             |
-                   /       --------------
-           timeout/         (re) transmission
-                         
-
-A requestor thread drops a transaction into 
-the message queue and goes to sleep.  The XACT is
-picked up by rpciod who is listening for events from
-three sources:
-
-  o the request queue
-  o packet arrival at the socket
-  o timeouts
-
-RPCIOD sends the XACT to its destination server and
-enqueues the pending XACT into an ordered list of
-outstanding transactions.
-
-When a packet arrives, RPCIOD (based on the RPC transaction
-ID) looks up the matching XACT and wakes up the requestor
-who can then XDR-decode the RPC results found in the XACT
-object's buffer.
-
-When a timeout expires, RPCIOD examines the outstanding
-XACT that is responsible for the timeout. If its lifetime
-has not expired yet, RPCIOD resends the request. Otherwise,
-the XACT's error status is set and the requestor is woken up.
-
-RPCIOD dynamically adjusts the retransmission intervals
-based on the average round-trip time measured (on a per-server
-basis).
-
-Having the requestors event driven (rather than blocking
-e.g. on a semaphore) is geared to having many different
-requestors (one synchronization object per requestor would
-be needed otherwise).
-
-Requestors who want to do asynchronous IO need a different
-interface which will be added in the future.
-
-1.a) Reentrancy
-- - - - - - - - 
-RPCIOD does no non-reentrant librpc calls.
-
-1.b) Efficiency
-- - - - - - - - 
-We shouldn't bother about efficiency until pipelining (read-ahead/
-delayed write) and caching are implemented. The round-trip delay
-associated with every single RPC transaction clearly is a big
-performance killer.
-
-Nevertheless, I could not withstand the temptation to eliminate
-the extra copy step involved with socket IO:
-
-A user data object has to be XDR encoded into a buffer. The 
-buffer given to the socket where it is copied into MBUFs.
-(The network chip driver might even do more copying).
-
-Likewise, on reception 'recvfrom' copies MBUFS into a user
-buffer which is XDR decoded into the final user data object.
-
-Eliminating the copying into (possibly multiple) MBUFS by
-'sendto()' is actually a piece of cake. RPCIOD uses the
-'sosend()' routine [properly wrapped] supplying a single
-MBUF header who directly points to the marshalled buffer
-:-)
-
-Getting rid of the extra copy on reception was (only a little)
-harder: I derived a 'XDR-mbuf' stream from SUN's xdr_mem which
-allows for XDR-decoding out of a MBUF chain who is obtained by
-soreceive().
-
-2) NFS
-- - - -
-The actual NFS implementation is straightforward and essentially
-'passive' (no threads created). Any RTEMS task executing a
-filesystem call dispatched to NFS (such as 'opendir()', 'lseek()'
-or 'unlink()') ends up XDR encoding arguments, dropping a
-XACT into RPCIOD's message queue and going to sleep.
-When woken up by RPCIOD, the XACT is decoded (using the XDR-mbuf
-stream mentioned above) and the properly cooked-up results are
-returned.
-
-3) RTEMS Resources Used By NFS/RPCIOD
-- - - - - - - - - - - - - - - - - - -
-
-The RPCIOD/NFS package uses the following resources. Some
-parameters are compile-time configurable - consult the
-source files for details.
-
-RPCIOD:
- o 1 task 
- o 1 message queue
- o 1 socket/filedescriptor
- o 2 semaphores (a third one is temporarily created during
-   rpcUdpCleanup()).
- o 1 RTEMS EVENT (by default RTEMS_EVENT_30).
-   IMPORTANT: this event is used by _every_ thread executing
-              NFS system calls and hence is RESERVED.
- o 3 events only used by RPCIOD itself, i.e. these must not
-   be sent to RPCIOD by no other thread (except for the intended
-   use, of course). The events involved are 1,2,3.
- o preemption disabled sections:      NONE
- o sections with interrupts disabled: NONE
- o NO 'timers' are used (timer code would run in IRQ context)
- o memory usage: n.a
-
-NFS:
- o 2 message queues
- o 2 semaphores
- o 1 semaphore per mounted NFS
- o 1 slot in driver entry table (for major number)
- o preemption disabled sections:      NONE
- o sections with interrupts disabled: NONE
- o 1 task + 1 semaphore temporarily created when
-   listing mounted filesystems (rtems_filesystem_resolve_location())
-
-4) CAVEATS & BUGS
-- - - - - - - - -
-Unfortunately, some bugs crawl around in the filesystem generics.
-(Some of them might already be fixed in versions later than
-rtems-ss-20020301).
-I recommend to use the patch distributed with RTEMS-NFS.
-
- o RTEMS uses/used (Joel said it has been fixed already) a 'short'
-   ino_t which is not enough for NFS.
-   The driver detects this problem and enables a workaround. In rare
-   situations (mainly involving 'getcwd()' improper inode comparison
-   may result (due to the restricted size, stat() returns st_ino modulo
-   2^16). In most cases, however, st_dev is compared along with st_ino
-   which will give correct results (different files may yield identical
-   st_ino but they will have different st_dev). However, there is 
-   code (in getcwd(), for example) who assumes that files residing
-   in one directory must be hosted by the same device and hence omits
-   the st_dev comparison. In such a case, the workaround will fail.
- 
-   NOTE: changing the size (sys/types.h) of ino_t from 'short' to 'long'
-         is strongly recommended. It is NOT included in the patch, however
-         as this is a major change requiring ALL of your sources to
-         be recompiled.
-
-   THE ino_t SIZE IS FIXED IN GCC-3.2/NEWLIB-1.10.0-2 DISTRIBUTED BY
-   OAR.
-
- o You may work around most filesystem bugs by observing the following
-   rules:
-
-    * never use chroot() (fixed by the patch)
-    * never use getpwent(), getgrent() & friends - they are NOT THREAD
-      safe (fixed by the patch)
-    * NEVER use rtems_libio_share_private_env() - not even with the
-      patch applied. Just DONT - it is broken by design.
-    * All threads who have their own userenv (who have called
-      rtems_libio_set_private_env()) SHOULD 'chdir("/")' before
-      terminating. Otherwise, (i.e. if their cwd is on NFS), it will
-      be impossible to unmount the NFS involved.
-
- o The patch slightly changes the semantics of 'getpwent()' and
-   'getgrent()' & friends (to what is IMHO correct anyways - the patch is
-   also needed to fix another problem, however): with the patch applied,
-   the passwd and group files are always accessed from the 'current' user
-   environment, i.e. a thread who has changed its 'root' or 'uid' might
-   not be able to access these files anymore.
-      
- o NOTE: RTEMS 'mount()' / 'unmount()' are NOT THREAD SAFE.
-
- o The NFS protocol has no 'append' or 'seek_end' primitive. The client
-   must query the current file size (this client uses cached info) and
-   change the local file pointer accordingly (in 'O_APPEND' mode).
-   Obviously, this involves a race condition and hence multiple clients
-   writing the same file may lead to corruption.
-
-IV Licensing & Disclaimers
---------------------------
-
-NFS is distributed under the SLAC License - consult the
-separate 'LICENSE' file.
-
-Government disclaimer of liability
-- - - - - - - - - - - - - - - - -
-Neither the United States nor the United States Department of Energy,
-nor any of their employees, makes any warranty, express or implied,
-or assumes any legal liability or responsibility for the accuracy,
-completeness, or usefulness of any data, apparatus, product, or process
-disclosed, or represents that its use would not infringe privately
-owned rights.
-
-Stanford disclaimer of liability
-- - - - - - - - - - - - - - - - -
-Stanford University makes no representations or warranties, express or
-implied, nor assumes any liability for the use of this software.
-
-Maintenance of notice
-- - - - - - - - - - -
-In the interest of clarity regarding the origin and status of this
-software, Stanford University requests that any recipient of it maintain
-this notice affixed to any distribution by the recipient that contains a
-copy or derivative of this software.
Index: rvices/nfsclient/cexphelp.c
===================================================================
--- services/nfsclient/cexphelp.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,20 +1,0 @@
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <librtemsNfs.h>
-#include <cexpHelp.h>
-CEXP_HELP_TAB_BEGIN(rtemsNfs)
-	HELP(
-"Mount a remote filesystem (NFS). The mount point (must not be a NFS dir)\n"
-"is created on the fly if not existing already.\n"
-"uid/gid to use may be specified:\n"
-"   hostspec: [uid.gid@]hostname_or_ipaddr\n"
-	, int, nfsMount, (char *hostspec, char *exportdir, char *mntpoint)
-		),
-	HELP(
-"Print all currently mounted NFS directories to open file handle.\n"
-"Pass f = 0 to print to stdout\n"
-	, int, nfsMountsShow, (FILE *f)
-		),
-CEXP_HELP_TAB_END
Index: rvices/nfsclient/dirutils.c
===================================================================
--- services/nfsclient/dirutils.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,383 +1,0 @@
-/* very crude and basic fs utilities for testing the NFS */
-
-/* Till Straumann, <strauman@slac.stanford.edu>, 10/2002 */
-
-/*
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
- * 	   Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef __vxworks
-#include <vxWorks.h>
-#endif
-#include <stdio.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <limits.h> /* PATH_MAX */
-
-#include <inttypes.h> /* PRI* */
-
-#if SIZEOF_MODE_T == 8
-#define PRIomode_t PRIo64
-#elif SIZEOF_MODE_T == 4
-#define PRIomode_t PRIo32
-#else
-#error "unsupport size of mode_t"
-#endif
-
-#if SIZEOF_OFF_T == 8
-#define PRIdoff_t PRIo64
-#elif SIZEOF_OFF_T == 4
-#define PRIdoff_t PRIo32
-#else
-#error "unsupported size of off_t"
-#endif
-
-#ifdef HAVE_CEXP
-#include <cexpHelp.h>
-#endif
-
-#ifndef __vxworks
-int
-pwd(void)
-{
-char buf[PATH_MAX];
-
-	if ( !getcwd(buf,PATH_MAX)) {
-		perror("getcwd");
-		return -1;
-	} else {
-		printf("%s\n",buf);
-	}
-	return 0;
-}
-
-static int
-ls_r(char *path, char *chpt, char *name, struct stat *buf)
-{
-char *t;
-	sprintf(chpt, "/%s", name);
-	if (lstat(path,buf)) {
-		fprintf(stderr,"stat(%s): %s\n", path, strerror(errno));
-		return -1;
-	}
-	switch ( buf->st_mode & S_IFMT ) {
-		case S_IFSOCK:
-		case S_IFIFO:	t = "|"; break;
-
-		default:
-		case S_IFREG:
-		case S_IFBLK:
-		case S_IFCHR:
-						t = "";  break;
-		case S_IFDIR:
-						t = "/"; break;
-		case S_IFLNK:
-						t = "@"; break;
-	}
-
-	printf("%10li, %10" PRIdoff_t "b, %5i.%-5i 0%04" PRIomode_t " %s%s\n",
-				buf->st_ino,
-				buf->st_size,
-				buf->st_uid,
-				buf->st_gid,
-				buf->st_mode & ~S_IFMT,
-				name,
-				t);
-	*chpt = 0;
-	return 0;
-}
-
-int
-ls(char *dir, char *opts)
-{
-struct dirent	*de;
-char			path[PATH_MAX+1];
-char			*chpt;
-DIR				*dp  = 0;
-int				rval = -1;
-struct stat		buf;
-
-	if ( !dir )
-		dir = ".";
-
-	strncpy(path, dir, PATH_MAX);
-	path[PATH_MAX] = 0;
-	chpt = path+strlen(path);
-
-	if ( !(dp=opendir(dir)) ) {
-		perror("opendir");
-		goto cleanup;
-	}
-
-	while ( (de = readdir(dp)) ) {
-		ls_r(path, chpt, de->d_name, &buf);
-	}
-
-	rval = 0;
-
-cleanup:
-	if (dp)
-		closedir(dp);
-	return rval;
-}
-#endif
-
-#if 0
-		fprintf(stderr, "usage: cp(""from"",[""to""[,""-f""]]\n");
-		fprintf(stderr, "          ""to""==NULL -> stdout\n");
-		fprintf(stderr, "          ""-f""       -> overwrite existing file\n");
-#endif
-
-int
-cp(char *from, char *to, char *opts)
-{
-struct stat	st;
-int			rval  = -1;
-int			fd    = -1;
-FILE		*fst  = 0;
-FILE		*tst  = 0;
-int			flags = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
-
-	if (from) {
-
-	if ((fd=open(from,O_RDONLY,0)) < 0) {
-		fprintf(stderr,
-				"Opening %s for reading: %s\n",
-				from,
-				strerror(errno));
-		goto cleanup;
-	}
-
-	if (fstat(fd, &st)) {
-		fprintf(stderr,
-				"rstat(%s): %s\n",
-				from,
-				strerror(errno));
-		goto cleanup;
-	}
-
-
-	if (!S_ISREG(st.st_mode)) {
-		fprintf(stderr,"Refuse to copy a non-regular file\n");
-		errno = EINVAL;
-		goto cleanup;
-	}
-	/* Now create a stream -- I experienced occasional weirdness
-	 * when circumventing the streams attached to fildno(stdin)
-	 * by reading/writing to the underlying fd's directly ->
-	 * for now we always go through buffered I/O...
-	 */
-	if ( !(fst=fdopen(fd,"r")) ) {
-		fprintf(stderr,
-				"Opening input stream [fdopen()] failed: %s\n",
-				strerror(errno));
-		goto cleanup;
-	}
-	/* at this point, we have a stream and don't need 'fd' anymore */
-	fd = -1;
-
-	} else {
-		fst			= stdin;
-		st.st_mode	= 0644;
-	}
-
-	if (opts && strchr(opts,'f'))
-		flags &= ~ O_EXCL;
-
-	if (to) {
-		if ( (fd=open(to,flags,st.st_mode)) < 0 ) {
-			fprintf(stderr,
-					"Opening %s for writing: %s\n",
-					to,
-					strerror(errno));
-			goto cleanup;
-		}
-		if ( !(tst=fdopen(fd, "w")) ) {
-			fprintf(stderr,
-					"Opening output stream [fdopen()] failed: %s\n",
-					strerror(errno));
-			goto cleanup;
-		}
-		/* at this point we have a stream and don't need 'fd' anymore */
-		fd = -1;
-	} else {
-		tst = stdout;
-	}
-
-	/* clear old errors */
-	clearerr(fst);
-	clearerr(tst);
-
-	/* use macro versions on register vars; stdio is already buffered,
-	 * there's nothing to be gained by reading/writing blocks into
-	 * a secondary buffer...
-	 */
-	{
-	register int ch;
-	register FILE *f = fst;
-	register FILE *t = tst;
-		while ( EOF != (ch = getc(f)) && EOF != putc(ch, t) )
-			/* nothing else */;
-	}
-
-	if ( ferror(fst) ) {
-		fprintf(stderr,"Read error: %s\n",strerror(errno));
-		goto cleanup;
-	}
-	if ( ferror(tst) ) {
-		fprintf(stderr,"Write error: %s\n",strerror(errno));
-		goto cleanup;
-	}
-
-	rval = 0;
-
-cleanup:
-
-	if ( fd >= 0 )
-		close(fd);
-
-	if ( fst ) {
-		if ( from )
-			fclose(fst);
-		else
-			clearerr(fst);
-	}
-	if ( tst ) {
-		if ( to )
-			fclose(tst);
-		else {
-			/* flush stdout */
-			fflush(tst);
-			clearerr(tst);
-		}
-	}
-
-	return rval;
-}
-
-int
-ln(char *to, char *name, char *opts)
-{
-	if (!to) {
-		fprintf(stderr,"ln: need 'to' argument\n");
-		return -1;
-	}
-	if (!name) {
-		if ( !(name = strrchr(to,'/')) ) {
-			fprintf(stderr,
-					"ln: 'unable to link %s to %s\n",
-					to,to);
-			return -1;
-		}
-		name++;
-	}
-	if (opts || strchr(opts,'s')) {
-		if (symlink(name,to)) {
-			fprintf(stderr,"symlink: %s\n",strerror(errno));
-			return -1;
-		}
-	} else {
-		if (link(name,to)) {
-			fprintf(stderr,"hardlink: %s\n",strerror(errno));
-			return -1;
-		}
-	}
-	return 0;
-}
-
-int
-rm(char *path)
-{
-	return unlink(path);
-}
-
-int
-cd(char *path)
-{
-	return chdir(path);
-}
-
-#ifdef HAVE_CEXP
-static CexpHelpTabRec _cexpHelpTabDirutils[] __attribute__((unused)) = {
-	HELP(
-"copy a file: cp(""from"",[""to""[,""-f""]])\n\
-                 from = NULL <-- stdin\n\
-                 to   = NULL --> stdout\n\
-                 option -f: overwrite existing file\n",
-		int,
-		cp, (char *from, char *to, char *options)
-		),
-	HELP(
-"list a directory: ls([""dir""])\n",
-		int,
-		ls, (char *dir)
-		),
-	HELP(
-"remove a file\n",
-		int,
-		rm, (char *path)
-		),
-	HELP(
-"change the working directory\n",
-		int,
-		cd, (char *path)
-		),
-	HELP(
-"create a link: ln(""to"",""name"",""[-s]""\n\
-                   -s creates a symlink\n",
-		int,
-		ln, (char *to, char *name, char *options)
-		),
-	HELP("",,0,)
-};
-#endif
Index: rvices/nfsclient/include/librtemsNfs.h
===================================================================
--- services/nfsclient/include/librtemsNfs.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,179 +1,0 @@
-#ifndef LIB_RTEMS_NFS_CLIENT_H
-#define LIB_RTEMS_NFS_CLIENT_H
-
-/* public interface to the NFS client library for RTEMS */
-
-/* Author: Till Straumann <strauman@slac.stanford.edu> 2002-2003 */
-
-/*
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
- * 	   Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-
-#ifdef	HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <rtems.h>
-#include <rtems/libio.h>
-#include <rtems/libio_.h>
-#include <rtems/seterr.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* RPCIO driver interface.
- * If you need RPCIO for other purposes than NFS
- * you may want to include <rpcio.h>
-#include "rpcio.h"
- */
-
-/* Priority of daemon; may be setup prior to calling rpcUdpInit();
- * otherwise the network task priority from the rtems_bsdnet_config
- * is used...
- */
-extern rtems_task_priority rpciodPriority;
-
-/* Initialize the driver.
- *
- * Note, called in nfsfs initialise when mount is called.
- *
- * RETURNS: 0 on success, -1 on failure
- */
-int
-rpcUdpInit(void);
-
-/* Cleanup/Stop
- *
- * RETURNS: 0 on success, nonzero if still in use
- */
-int
-rpcUdpCleanup(void);
-
-/* NFS driver interface */
-
-/* Initialize the NFS driver.
- *
- * NOTE: The RPCIO driver must have been initialized prior to
- *       calling this.
- *
- * Note, called in nfsfs initialise when mount is called with defaults.
- *
- * ARGS:	depth of the small and big
- * 			transaction pools, i.e. how
- * 			many transactions (buffers)
- * 			should always be kept around.
- *
- * 			(If more transactions are needed,
- * 			they are created and destroyed
- * 			on the fly).
- *
- * 			Supply zero values to have the
- * 			driver chose reasonable defaults.
- */
-void
-nfsInit(int smallPoolDepth, int bigPoolDepth);
-
-/* Driver cleanup code
- *
- * RETURNS: 0 on success, nonzero if still in use
- */
-int
-nfsCleanup(void);
-
-/* Dump a list of the currently mounted NFS to a file
- * (stdout is used in case f==NULL)
- */
-int
-nfsMountsShow(FILE *f);
-
-/*
- * Filesystem mount table mount handler. Do not call, use the mount call.
- */
-int 
-rtems_nfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry,
-                     const void                           *data);
-
-/* A utility routine to find the path leading to a
- * rtems_filesystem_location_info_t node.
- *
- * This should really be present in libcsupport...
- *
- * INPUT: 'loc' and a buffer 'buf' (length 'len') to hold the
- *        path.
- * OUTPUT: path copied into 'buf'
- *
- * RETURNS: 0 on success, RTEMS error code on error.
- */
-rtems_status_code
-rtems_filesystem_resolve_location(char *buf, int len, rtems_filesystem_location_info_t *loc);
-
-/* Set the timeout (initial default: 10s) for NFS and mount calls.
- *
- * RETURNS 0 on success, nonzero if the requested timeout is less than
- * a clock tick or if the system clock rate cannot be determined.
- */
-
-int
-nfsSetTimeout(uint32_t timeout_ms);
-
-/* Read current timeout (in milliseconds) */
-uint32_t
-nfsGetTimeout(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
Index: rvices/nfsclient/include/rpcio.h
===================================================================
--- services/nfsclient/include/rpcio.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,208 +1,0 @@
-#ifndef RPCIO_H
-#define RPCIO_H
-
-/* A multihreaded RPC/UDP multiplexor */
-
-/* Author: Till Straumann, <strauman@slac.stanford.edu>, 2002 */
-
-/*
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
- * 	   Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-
-#ifdef __rtems
-#include <rtems.h>
-#endif
-
-#include <rpc/rpc.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/param.h>
-#include <stdarg.h>
-
-typedef struct RpcUdpServerRec_ 	*RpcUdpServer;
-typedef struct RpcUdpXactRec_		*RpcUdpXact;
-
-typedef RpcUdpXact					RpcUdpClnt;
-
-#define RPCIOD_DEFAULT_ID	0xdef10000
-
-int
-rpcUdpInit(void);
-
-enum clnt_stat
-rpcUdpServerCreate(
-	struct sockaddr_in	*paddr,
-	rpcprog_t		prog,
-	rpcvers_t		vers,
-	u_long			uid,		/* RPCIO_DEFAULT_ID picks default */
-	u_long			gid,		/* RPCIO_DEFAULT_ID picks default */
-	RpcUdpServer		*pclnt		/* new server is returned here    */
-	);
-
-
-void
-rpcUdpServerDestroy(RpcUdpServer s);
-
-/* Dump statistics to a file (stdout if NULL);
- * returns 0 for convenience
- */
-int
-rpcUdpStats(FILE *f);
-
-enum clnt_stat
-rpcUdpClntCreate(
-	struct sockaddr_in	*psaddr,
-	rpcprog_t		prog,
-	rpcvers_t		vers,
-	u_long			uid,		/* RPCIO_DEFAULT_ID picks default */
-	u_long			gid,		/* RPCIO_DEFAULT_ID picks default */
-	RpcUdpClnt		*pclnt		/* new client is returned here    */
-	);
-
-void
-RpcUdpClntDestroy(RpcUdpClnt clnt);
-
-/* mute compiler warnings */
-typedef void *XdrProcT;
-typedef void *CaddrT;
-
-enum clnt_stat
-rpcUdpClntCall(
-	RpcUdpClnt		clnt,
-	u_long			proc,
-	XdrProcT		xargs,
-	CaddrT			pargs,
-	XdrProcT		xres,
-	CaddrT			pres,
-	struct timeval	*timeout	/* optional timeout; maybe NULL to pick default */
-	);
-
-RpcUdpXact
-rpcUdpXactCreate(
-	u_long	program,
-	u_long	version,
-	u_long	size
-	);
-
-void
-rpcUdpXactDestroy(
-	RpcUdpXact xact
-	);
-
-/* send a transaction */
-enum clnt_stat
-rpcUdpSend(
-	RpcUdpXact		xact,
-	RpcUdpServer	srvr,
-	struct timeval	*timeout,	/* maybe NULL to pick default */
-	u_long			proc,
-	xdrproc_t		xres,
-	caddr_t			pres,
-	xdrproc_t		xargs,
-	caddr_t			pargs,
-	...				/* 0 terminated xdrproc/pobj additional argument list */
-	);
-
-/* wait for a transaction to complete */
-enum clnt_stat
-rpcUdpRcv(RpcUdpXact xact);
-
-/* a yet simpler interface */
-enum clnt_stat
-rpcUdpCallRp(
-	struct sockaddr_in	*pserver_addr,
-	u_long				prog,
-	u_long				vers,
-	u_long				proc,
-	XdrProcT			xargs,
-	CaddrT				pargs,
-	XdrProcT			xres,
-	CaddrT				pres,
-	u_long				uid,		/* RPCIO_DEFAULT_ID picks default */
-	u_long				gid,		/* RPCIO_DEFAULT_ID picks default */
-	struct timeval		*timeout	/* NULL picks default		*/
-);
-
-
-/* manage pools of transactions */
-
-/* A pool of transactions. The idea is not to malloc/free them
- * all the time but keep a limited number around in a 'pool'.
- * Users who need a XACT may get it from the pool and put it back
- * when done.
- * The pool is implemented by RTEMS message queues who manage
- * the required task synchronization.
- * A requestor has different options if the pool is empty:
- *  - it can wait (block) for a XACT to become available
- *  - it can get an error status
- *  - or it can malloc an extra XACT from the heap which
- *    will eventually be released.
- */
-
-typedef struct RpcUdpXactPoolRec_  *RpcUdpXactPool;
-
-/* NOTE: the pool is empty initially, must get messages (in
- *       GetCreate mode
- */
-RpcUdpXactPool
-rpcUdpXactPoolCreate(
-	rpcprog_t prog, rpcvers_t version,
-	int xactsize,	int poolsize);
-
-void
-rpcUdpXactPoolDestroy(RpcUdpXactPool pool);
-
-typedef enum {
-	XactGetFail,	/* call fails if no transaction available */
-	XactGetWait,	/* call blocks until transaction available */
-	XactGetCreate	/* a new transaction is allocated (and freed when put back to the pool */
-} XactPoolGetMode;
-
-RpcUdpXact
-rpcUdpXactPoolGet(RpcUdpXactPool pool, XactPoolGetMode mode);
-
-void
-rpcUdpXactPoolPut(RpcUdpXact xact);
-
-#endif
Index: rvices/nfsclient/nfs.c
===================================================================
--- services/nfsclient/nfs.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,3051 +1,0 @@
-/* NFS client implementation for RTEMS; hooks into the RTEMS filesystem */
-
-/* Author: Till Straumann <strauman@slac.stanford.edu> 2002 */
-
-/*
- * Hacked on by others.
- *
- * Modifications to support reference counting in the file system are
- * Copyright (c) 2012 embedded brains GmbH.
- */
-
-/*
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
- * 	   Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-
-#ifdef	HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <rtems.h>
-#include <rtems/libio.h>
-#include <rtems/libio_.h>
-#include <rtems/seterr.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <nfs_prot.h>
-#include <mount_prot.h>
-
-#include "rpcio.h"
-#include "librtemsNfs.h"
-
-/* Configurable parameters */
-
-/* Estimated average length of a filename (including terminating 0).
- * This was calculated by doing
- *
- * 	find <some root> -print -exec basename '{}' \; > feil
- * 	wc feil
- *
- * AVG_NAMLEN = (num_chars + num_lines)/num_lines
- */
-#define CONFIG_AVG_NAMLEN				10
-
-#define CONFIG_NFS_SMALL_XACT_SIZE		800			/* size of RPC arguments for non-write ops */
-/* lifetime of NFS attributes in a NfsNode;
- * the time is in seconds and the lifetime is
- * infinite if the symbol is #undef
- */
-#define CONFIG_ATTR_LIFETIME			10/*secs*/
-
-/*
- * The 'st_blksize' (stat(2)) value this nfs
- * client should report. If set to zero then the server's fattr data
- * is passed throught which is not necessary optimal.
- * Newlib's stdio uses 'st_blksize' (if built with HAVE_BLKSIZE defined)
- * to size the default buffer.
- * Due to the overhead of NFS it is probably better to use the maximum
- * size of an NFS read request (8k) rather than the optimal block
- * size on the server.
- * This value can be overridden at run-time by setting the global
- * variable 'nfsStBlksize'.
- * Thanks to Steven Johnson <sjohnson@sakuraindustries.com> for helping
- * working on this issue.
- */
-#define DEFAULT_NFS_ST_BLKSIZE			NFS_MAXDATA
-
-/* dont change this without changing the maximal write size */
-#define CONFIG_NFS_BIG_XACT_SIZE		UDPMSGSIZE	/* dont change this */
-
-/* The real values for these are specified further down */
-#define NFSCALL_TIMEOUT					(&_nfscalltimeout)
-#define MNTCALL_TIMEOUT					(&_nfscalltimeout)
-static struct timeval _nfscalltimeout = { 10, 0 };	/* {secs, us } */
-
-/* More or less fixed constants; in particular, NFS3 is not supported */
-#define DELIM							'/'
-#define HOSTDELIM						':'
-#define UPDIR							".."
-#define UIDSEP							'@'
-#define NFS_VERSION_2					NFS_VERSION
-
-/* we use a dynamically assigned major number */
-#define NFS_MAJOR						(nfsGlob.nfs_major)
-
-
-/* NOTE: RTEMS (ss-20020301) uses a 'short st_ino' type :-( but the
- * NFS fileid is 32 bit. [Later versions of RTEMS have fixed this;
- * nfsInit() issues a warning if you run a version with 'short st_ino'.]
- *
- * As a workarount, we merge the upper 16bits of the fileid into the
- * minor device no. Hence, it is still possible to uniquely identify
- * a file by looking at its device number (major = nfs, minor = part
- * of the fileid + our 'nfs-id' identifier).
- *
- * This has an impact on performance, as e.g. getcwd() stats() all
- * directory entries when it believes it has crossed a mount point
- * (a.st_dev != b.st_dev).
- *
- * OTOH, it also might cause node comparison failure! E.g. 'getcwd()'
- * assumes that two nodes residing in the same directory must be located
- * on the same device and hence compares 'st_ino' only.
- * If two files in the same directory have the same inode number
- * modulo 2^16, they will be considered equal (although their device
- * number doesn't match - getcwd doesn't look at it).
- *
- * Other software might or might not be affected.
- *
- * The only clean solution to this problem is bumping up the size of
- * 'ino_t' at least to 'long'.
- * Note that this requires _all_ software (libraries etc.) to be
- * recompiled.
- */
-
-#define	NFS_MAKE_DEV_T_INO_HACK(node) \
-		rtems_filesystem_make_dev_t( NFS_MAJOR, \
-			(((rtems_device_minor_number)((node)->nfs->id))<<16) | (((rtems_device_minor_number)SERP_ATTR((node)).fileid) >> 16) )
-
-/* use our 'nfs id' and the server's fsid for the minor device number
- * this should be fairly unique
- */
-#define	NFS_MAKE_DEV_T(node) \
-		rtems_filesystem_make_dev_t( NFS_MAJOR, \
-			(((rtems_device_minor_number)((node)->nfs->id))<<16) | (SERP_ATTR((node)).fsid & (((rtems_device_minor_number)1<<16)-1)) )
-
-#define  DIRENT_HEADER_SIZE ( sizeof(struct dirent) - \
-			sizeof( ((struct dirent *)0)->d_name ) )
-
-
-/* debugging flags */
-#define DEBUG_COUNT_NODES	(1<<0)
-#define DEBUG_TRACK_NODES	(1<<1)
-#define DEBUG_EVALPATH		(1<<2)
-#define DEBUG_READDIR		(1<<3)
-#define DEBUG_SYSCALLS		(1<<4)
-
-/* #define DEBUG	( DEBUG_SYSCALLS | DEBUG_COUNT_NODES ) */
-
-#ifdef DEBUG
-#define STATIC
-#else
-#define STATIC static
-#endif
-
-#define MUTEX_ATTRIBUTES    (RTEMS_LOCAL           |   \
-                            RTEMS_PRIORITY         |   \
-                            RTEMS_INHERIT_PRIORITY |   \
-                            RTEMS_BINARY_SEMAPHORE)
-
-#define LOCK(s)		do {                               \
-						rtems_semaphore_obtain((s),    \
-									RTEMS_WAIT,        \
-									RTEMS_NO_TIMEOUT); \
-					} while (0)
-
-#define UNLOCK(s)	do { rtems_semaphore_release((s)); \
-					} while (0)
-
-static inline char *
-nfs_dupname(const char *name, size_t namelen)
-{
-	char *dupname = malloc(namelen + 1);
-
-	if (dupname != NULL) {
-		memcpy(dupname, name, namelen);
-		dupname [namelen] = '\0';
-	} else {
-		errno = ENOMEM;
-	}
-
-	return dupname;
-}
-
-/*****************************************
-	Types with Associated XDR Routines
- *****************************************/
-
-/* a string buffer with a maximal length.
- * If the buffer pointer is NULL, it is updated
- * with an appropriately allocated area.
- */
-typedef struct strbuf {
-	char	*buf;
-	u_int	max;
-} strbuf;
-
-/* Read 'readlink' results into a 'strbuf'.
- * This is convenient as it avoids
- * one extra step of copying / lenght
- * checking.
- */
-typedef struct readlinkres_strbuf {
-	nfsstat	status;
-	strbuf	strbuf;
-} readlinkres_strbuf;
-
-static bool_t
-xdr_readlinkres_strbuf(XDR *xdrs, readlinkres_strbuf *objp)
-{
-	if ( !xdr_nfsstat(xdrs, &objp->status) )
-		return FALSE;
-
-	if ( NFS_OK == objp->status ) {
-		if ( !xdr_string(xdrs, &objp->strbuf.buf, objp->strbuf.max) )
-			return FALSE;
-	}
-	return TRUE;
-}
-
-
-/* DirInfoRec is used instead of dirresargs
- * to convert recursion into iteration. The
- * 'rpcgen'erated xdr_dirresargs ends up
- * doing nested calls when unpacking the
- * 'next' pointers.
- */
-
-typedef struct DirInfoRec_ {
-	readdirargs	readdirargs;
-	/* clone of the 'readdirres' fields;
-	 * the cookie is put into the readdirargs above
-	 */
-	nfsstat		status;
-	char		*buf, *ptr;
-	int			len;
-	bool_t		eofreached;
-} DirInfoRec, *DirInfo;
-
-/* this deals with one entry / record */
-static bool_t
-xdr_dir_info_entry(XDR *xdrs, DirInfo di)
-{
-union	{
-	char			nambuf[NFS_MAXNAMLEN+1];
-	nfscookie		cookie;
-}				dummy;
-struct dirent	*pde = (struct dirent *)di->ptr;
-u_int			fileid;
-char			*name;
-register int	nlen = 0,len,naligned = 0;
-nfscookie		*pcookie;
-
-	len = di->len;
-
-	if ( !xdr_u_int(xdrs, &fileid) )
-		return FALSE;
-
-	/* we must pass the address of a char* */
-	name = (len > NFS_MAXNAMLEN) ? pde->d_name : dummy.nambuf;
-
-	if ( !xdr_filename(xdrs, &name) ) {
-		return FALSE;
-	}
-
-	if (len >= 0) {
-		nlen      = strlen(name);
-		naligned  = nlen + 1 /* string delimiter */ + 3 /* alignment */;
-		naligned &= ~3;
-		len      -= naligned;
-	}
-
-	/* if the cookie goes into the DirInfo, we hope this doesn't fail
-	 * - the caller ends up with an invalid readdirargs cookie otherwise...
-	 */
-	pcookie = (len >= 0) ? &di->readdirargs.cookie : &dummy.cookie;
-	if ( !xdr_nfscookie(xdrs, pcookie) ) {
-		return FALSE;
-	}
-
-	di->len = len;
-	/* adjust the buffer pointer */
-	if (len >= 0) {
-		pde->d_ino    = fileid;
-		pde->d_namlen = nlen;
-		pde->d_off	  = di->ptr - di->buf;
-		if (name == dummy.nambuf) {
-			memcpy(pde->d_name, dummy.nambuf, nlen + 1);
-		}
-		pde->d_reclen = DIRENT_HEADER_SIZE + naligned;
-		di->ptr      += pde->d_reclen;
-	}
-
-	return TRUE;
-}
-
-/* this routine loops over all entries */
-static bool_t
-xdr_dir_info(XDR *xdrs, DirInfo di)
-{
-DirInfo	dip;
-
-	if ( !xdr_nfsstat(xdrs, &di->status) )
-		return FALSE;
-
-	if ( NFS_OK != di->status )
-		return TRUE;
-
-	dip = di;
-
-	while (dip) {
-		/* reserve space for the dirent 'header' - we assume it's word aligned! */
-#ifdef DEBUG
-		assert( DIRENT_HEADER_SIZE % 4 == 0 );
-#endif
-		dip->len -= DIRENT_HEADER_SIZE;
-
-		/* we pass a 0 size - size is unused since
-		 * we always pass a non-NULL pointer
-		 */
-		if ( !xdr_pointer(xdrs, (void*)&dip, 0 /* size */, (xdrproc_t)xdr_dir_info_entry) )
-			return FALSE;
-	}
-
-	if ( ! xdr_bool(xdrs, &di->eofreached) )
-		return FALSE;
-
-	/* if everything fits into the XDR buffer but not the user's buffer,
-	 * they must resume reading from where xdr_dir_info_entry() started
-	 * skipping and 'eofreached' needs to be adjusted
-	 */
-	if ( di->len < 0 && di->eofreached )
-		di->eofreached = FALSE;
-
-	return TRUE;
-}
-
-
-/* a type better suited for node operations
- * than diropres.
- * fattr and fhs are swapped so parts of this
- * structure may be used as a diroparg which
- * is practical when looking up paths.
- */
-
-/* Macro for accessing serporid fields
- */
-#define SERP_ARGS(node) ((node)->serporid.serporid_u.serporid.arg_u)
-#define SERP_ATTR(node) ((node)->serporid.serporid_u.serporid.attributes)
-#define SERP_FILE(node) ((node)->serporid.serporid_u.serporid.file)
-
-
-typedef struct serporidok {
-	fattr					attributes;
-	nfs_fh					file;
-	union	{
-		struct {
-			filename	name;
-		}					diroparg;
-		struct {
-			sattr		attributes;
-		}					sattrarg;
-		struct {
-			uint32_t	offset;
-			uint32_t	count;
-			uint32_t	totalcount;
-		}					readarg;
-		struct {
-			uint32_t	beginoffset;
-			uint32_t	offset;
-			uint32_t	totalcount;
-			struct {
-				uint32_t data_len;
-				char* data_val;
-			}			data;
-		}					writearg;
-		struct {
-			filename	name;
-			sattr		attributes;
-		}					createarg;
-		struct {
-			filename	name;
-			diropargs	to;
-		}					renamearg;
-		struct {
-			diropargs	to;
-		}					linkarg;
-		struct {
-			filename	name;
-			nfspath		to;
-			sattr		attributes;
-		}					symlinkarg;
-		struct {
-			nfscookie	cookie;
-			uint32_t	count;
-		}					readdirarg;
-	}							arg_u;
-} serporidok;
-
-typedef struct serporid {
-	nfsstat			status;
-	union	{
-		serporidok	serporid;
-	}				serporid_u;
-} serporid;
-
-/* an XDR routine to encode/decode the inverted diropres
- * into an nfsnodestat;
- *
- * NOTE: this routine only acts on
- *   - 'serporid.status'
- *   - 'serporid.file'
- *   - 'serporid.attributes'
- * and leaves the 'arg_u' alone.
- *
- * The idea is that a 'diropres' is read into 'serporid'
- * which can then be used as an argument to subsequent
- * NFS-RPCs (after filling in the node's arg_u).
- */
-static bool_t
-xdr_serporidok(XDR *xdrs, serporidok *objp)
-{
-     if (!xdr_nfs_fh (xdrs, &objp->file))
-         return FALSE;
-     if (!xdr_fattr (xdrs, &objp->attributes))
-         return FALSE;
-    return TRUE;
-}
-
-static bool_t
-xdr_serporid(XDR *xdrs, serporid *objp)
-{
-     if (!xdr_nfsstat (xdrs, &objp->status))
-         return FALSE;
-    switch (objp->status) {
-    case NFS_OK:
-         if (!xdr_serporidok(xdrs, &objp->serporid_u.serporid))
-             return FALSE;
-        break;
-    default:
-        break;
-    }
-    return TRUE;
-}
-
-/*****************************************
-	Data Structures and Types
- *****************************************/
-
-/* 'time()' hack with less overhead; */
-
-/* assume reading a long word is atomic */
-#define READ_LONG_IS_ATOMIC
-
-typedef uint32_t	TimeStamp;
-
-static inline TimeStamp
-nowSeconds(void)
-{
-  rtems_interval rval;
-  rtems_clock_get_seconds_since_epoch( &rval );
-  return rval;
-}
-
-
-/* Per mounted FS structure */
-typedef struct NfsRec_ {
-		/* the NFS server we're talking to.
-		 */
-	RpcUdpServer						 server;
-		/* statistics; how many NfsNodes are
-		 * currently alive.
-		 */
-	volatile int						 nodesInUse;
-#if DEBUG & DEBUG_COUNT_NODES
-		/* statistics; how many 'NfsNode.str'
-		 * strings are currently allocated.
-		 */
-	volatile int						 stringsInUse;
-#endif
-		/* A small number who uniquely
-		 * identifies a mounted NFS within
-		 * this driver (i.e. this NfsRec).
-		 * Each time a NFS is mounted, the
-		 * global ID counter is incremented
-		 * and its value is assigned to the
-		 * newly created NfsRec.
-		 */
-	u_short								 id;
-		/* Our RTEMS filesystem mt_entry
-		 */
-	rtems_filesystem_mount_table_entry_t *mt_entry;
-		/* Next NfsRec on a linked list who
-		 * is anchored at nfsGlob
-		 */
-	struct NfsRec_						 *next;
-		/* Who we pretend we are
-		 */
-	u_long								 uid,gid;
-} NfsRec, *Nfs;
-
-typedef struct NfsNodeRec_ {
-		/* This holds this node's attributes
-		 * (stats) and its nfs filehandle.
-		 * It also contains room for nfs rpc
-		 * arguments.
-		 */
-	serporid	serporid;
-		/* The arguments we used when doing
-		 * the 'lookup' call for this node.
-		 * We need this information (especially
-		 * the directory FH) for performing
-		 * certain operations on this
-		 * node (in particular: for unlinking
-		 * it from a parent directory)
-		 */
-	diropargs		args;
-		/* FS this node belongs to
-		 */
-	Nfs				nfs;
-		/* A buffer for the string the
-		 * args.name points to.
-		 * We need this because args.name might
-		 * temporarily point to strings on the
-		 * stack. Duplicates are allocated from
-		 * the heap and attached to 'str' so
-		 * they can be released as appropriate.
-		 */
-	char		   *str;
-		/* A timestamp for the stats
-		 */
-	TimeStamp		age;
-} NfsNodeRec, *NfsNode;
-
-/*****************************************
-	Forward Declarations
- *****************************************/
-
-static ssize_t nfs_readlink_with_node(
-	NfsNode node,
-	char *buf,
-	size_t len
-);
-
-static int updateAttr(NfsNode node, int force);
-
-/* Mask bits when setting attributes.
- * Only the 'arg' fields with their
- * corresponding bit set in the mask
- * will be used. The others are left
- * unchanged.
- * The 'TOUCH' bits instruct nfs_sattr()
- * to update the respective time
- * fields to the current time
- */
-#define	SATTR_MODE		(1<<0)
-#define	SATTR_UID		(1<<1)
-#define	SATTR_GID		(1<<2)
-#define	SATTR_SIZE		(1<<3)
-#define	SATTR_ATIME		(1<<4)
-#define	SATTR_TOUCHA	(1<<5)
-#define	SATTR_MTIME		(1<<6)
-#define	SATTR_TOUCHM	(1<<7)
-#define SATTR_TOUCH		(SATTR_TOUCHM | SATTR_TOUCHA)
-
-static int
-nfs_sattr(NfsNode node, sattr *arg, u_long mask);
-
-extern const struct _rtems_filesystem_operations_table nfs_fs_ops;
-static const struct _rtems_filesystem_file_handlers_r nfs_file_file_handlers;
-static const struct _rtems_filesystem_file_handlers_r nfs_dir_file_handlers;
-static const struct _rtems_filesystem_file_handlers_r nfs_link_file_handlers;
-static		   rtems_driver_address_table		 drvNfs;
-
-int
-nfsMountsShow(FILE*);
-
-rtems_status_code
-rtems_filesystem_resolve_location(char *buf, int len, rtems_filesystem_location_info_t *loc);
-
-/*****************************************
-	Global Variables
- *****************************************/
-
-/* These are (except for MAXNAMLEN/MAXPATHLEN) copied from IMFS */
-
-static const rtems_filesystem_limits_and_options_t
-nfs_limits_and_options = {
-   5, 				/* link_max */
-   6, 				/* max_canon */
-   7, 				/* max_input */
-   NFS_MAXNAMLEN,	/* name_max */
-   NFS_MAXPATHLEN,	/* path_max */
-   2,				/* pipe_buf */
-   1,				/* posix_async_io */
-   2,				/* posix_chown_restrictions */
-   3,				/* posix_no_trunc */
-   4,				/* posix_prio_io */
-   5,				/* posix_sync_io */
-   6				/* posix_vdisable */
-};
-
-/* size of an encoded 'entry' object */
-static int dirres_entry_size;
-
-/* Global stuff and statistics */
-static struct nfsstats {
-		/* A lock for protecting the
-		 * linked ist of mounted NFS
-		 * and the num_mounted_fs field
-		 */
-	rtems_id					llock;
-		/* A lock for protecting misc
-		 * stuff  within the driver.
-		 * The lock must only be held
-		 * for short periods of time.
-		 */
-	rtems_id					lock;
-		/* Our major number as assigned
-		 * by RTEMS
-		 */
-	rtems_device_major_number	nfs_major;
-		/* The number of currently
-		 * mounted NFS
-		 */
-	int							num_mounted_fs;
-		/* A list of the currently
-		 * mounted NFS
-		 */
-	struct NfsRec_				*mounted_fs;
-		/* A counter for allocating
-		 * unique IDs to each mounted
-		 * NFS.
-		 * Assume we are not going to
-		 * do more than 16k mounts
-		 * during the system lifetime
-		 */
-	u_short						fs_ids;
-} nfsGlob = {0, 0,  0, 0, 0, 0};
-
-/*
- * Global variable to tune the 'st_blksize' (stat(2)) value this nfs
- * client should report.
- * size on the server.
- */
-#ifndef DEFAULT_NFS_ST_BLKSIZE
-#define DEFAULT_NFS_ST_BLKSIZE	NFS_MAXDATA
-#endif
-int nfsStBlksize = DEFAULT_NFS_ST_BLKSIZE;
-
-/* Two pools of RPC transactions;
- * One with small send buffers
- * the other with a big one.
- * The actual size of the small
- * buffer is configurable (see top).
- *
- * Note: The RX buffers are always
- * big
- */
-static RpcUdpXactPool smallPool = 0;
-static RpcUdpXactPool bigPool   = 0;
-
-
-/*****************************************
-	Implementation
- *****************************************/
-
-/* Create a Nfs object. This is
- * per-mounted NFS information.
- *
- * ARGS:	The Nfs server handle.
- *
- * RETURNS:	Nfs on success,
- * 			NULL on failure with
- * 			errno set
- *
- * NOTE:	The submitted server
- * 			object is 'owned' by
- * 			this Nfs and will be
- * 			destroyed by nfsDestroy()
- */
-static Nfs
-nfsCreate(RpcUdpServer server)
-{
-Nfs rval = calloc(1,sizeof(*rval));
-
-	if (rval) {
-		rval->server     = server;
-		LOCK(nfsGlob.llock);
-			rval->next 		   = nfsGlob.mounted_fs;
-			nfsGlob.mounted_fs = rval;
-		UNLOCK(nfsGlob.llock);
-	} else {
-		errno = ENOMEM;
-	}
-		return rval;
-}
-
-/* Destroy an Nfs object and
- * its associated server
- */
-static void
-nfsDestroy(Nfs nfs)
-{
-register Nfs prev;
-	if (!nfs)
-		return;
-
-	LOCK(nfsGlob.llock);
-		if (nfs == nfsGlob.mounted_fs)
-			nfsGlob.mounted_fs = nfs->next;
-		else {
-			for (prev = nfsGlob.mounted_fs;
-				 prev && prev->next != nfs;
-				 prev = prev->next)
-					/* nothing else to do */;
-			assert( prev );
-			prev->next = nfs->next;
-		}
-	UNLOCK(nfsGlob.llock);
-
-	nfs->next = 0; /* paranoia */
-	rpcUdpServerDestroy(nfs->server);
-	free(nfs);
-}
-
-/*
- * Create a Node. The node will
- * be associated with a particular
- * mounted NFS identified by 'nfs'
- * Optionally, a NFS file handle
- * may be copied into this node.
- *
- * ARGS:	nfs of the NFS this node
- * 			belongs to.
- * 			NFS file handle identifying
- * 			this node.
- * RETURNS:	node on success,
- * 			NULL on failure with errno
- * 			set.
- *
- * NOTE:	The caller of this routine
- * 			is responsible for copying
- * 			a NFS file handle if she
- * 			choses to pass a NULL fh.
- *
- * 			The driver code assumes the
- * 			a node always has a valid
- * 			NFS filehandle and file
- * 			attributes (unless the latter
- * 			are aged).
- */
-static NfsNode
-nfsNodeCreate(Nfs nfs, fhandle *fh)
-{
-NfsNode	rval = malloc(sizeof(*rval));
-unsigned long flags;
-
-#if DEBUG & DEBUG_TRACK_NODES
-	fprintf(stderr,"NFS: creating a node\n");
-#endif
-
-	if (rval) {
-		if (fh)
-			memcpy( &SERP_FILE(rval), fh, sizeof(*fh) );
-		rtems_interrupt_disable(flags);
-			nfs->nodesInUse++;
-		rtems_interrupt_enable(flags);
-		rval->nfs       = nfs;
-		rval->str		= 0;
-	} else {
-		errno = ENOMEM;
-	}
-
-	return rval;
-}
-
-/* destroy a node */
-static void
-nfsNodeDestroy(NfsNode node)
-{
-unsigned long flags;
-
-#if DEBUG & DEBUG_TRACK_NODES
-	fprintf(stderr,"NFS: destroying a node\n");
-#endif
-#if 0
-	if (!node)
-		return;
-	/* this probably does nothing... */
-  	xdr_free(xdr_serporid, &node->serporid);
-#endif
-
-	rtems_interrupt_disable(flags);
-		node->nfs->nodesInUse--;
-#if DEBUG & DEBUG_COUNT_NODES
-		if (node->str)
-			node->nfs->stringsInUse--;
-#endif
-	rtems_interrupt_enable(flags);
-
-	if (node->str)
-		free(node->str);
-
-	free(node);
-}
-
-/* Clone a given node (AKA copy constructor),
- * i.e. create an exact copy.
- *
- * ARGS:	node to clone
- * RETURNS:	new node on success
- * 			NULL on failure with errno set.
- *
- * NOTE:	a string attached to 'str'
- * 			is cloned as well. Outdated
- * 			attributes (of the new copy
- * 			only) will be refreshed
- * 			(if unsuccessful, this could
- * 			be a reason for failure to
- * 			clone a node).
- */
-static NfsNode
-nfsNodeClone(NfsNode node)
-{
-NfsNode rval = nfsNodeCreate(node->nfs, 0);
-
-	if (rval) {
-		*rval = *node;
-
-		/* must clone the string also */
-		if (node->str) {
-			rval->args.name = rval->str = strdup(node->str);
-			if (!rval->str) {
-				errno = ENOMEM;
-				nfsNodeDestroy(rval);
-				return 0;
-			}
-#if DEBUG & DEBUG_COUNT_NODES
-			{ unsigned long flags;
-			rtems_interrupt_disable(flags);
-				node->nfs->stringsInUse++;
-			rtems_interrupt_enable(flags);
-			}
-#endif
-		}
-
-		/* possibly update the stats */
-		if (updateAttr(rval, 0 /* only if necessary */)) {
-			nfsNodeDestroy(rval);
-			return 0;
-		}
-	}
-	return rval;
-}
-
-/* Initialize the driver.
- *
- * ARGS:	depth of the small and big
- * 			transaction pools, i.e. how
- * 			many transactions (buffers)
- * 			should always be kept around.
- *
- * 			(If more transactions are needed,
- * 			they are created and destroyed
- * 			on the fly).
- */
-void
-nfsInit(int smallPoolDepth, int bigPoolDepth)
-{
-static int initialised = 0;
-entry	dummy;
-rtems_status_code status;
-
-	if (initialised)
-		return;
-
-	initialised = 1;
-
-	fprintf(stderr,
-          "RTEMS-NFS $Release$, "                       \
-          "Till Straumann, Stanford/SLAC/SSRL 2002, " \
-          "See LICENSE file for licensing info.\n");
-
-	/* Get a major number */
-
-	if (RTEMS_SUCCESSFUL != rtems_io_register_driver(0, &drvNfs, &nfsGlob.nfs_major)) {
-		fprintf(stderr,"Registering NFS driver failed - %s\n", strerror(errno));
-		return;
-	}
-
-	if (0==smallPoolDepth)
-		smallPoolDepth = 20;
-	if (0==bigPoolDepth)
-		bigPoolDepth   = 10;
-
-	/* it's crucial to zero out the 'next' pointer
-	 * because it terminates the xdr_entry recursion
-	 *
-	 * we also must make the filename some non-zero
-	 * char pointer!
-	 */
-
-	memset(&dummy, 0, sizeof(dummy));
-
-	dummy.nextentry   = 0;
-	dummy.name        = "somename"; /* guess average length of a filename */
-	dirres_entry_size = xdr_sizeof((xdrproc_t)xdr_entry, &dummy);
-
-	smallPool = rpcUdpXactPoolCreate(
-		NFS_PROGRAM,
-		NFS_VERSION_2,
-		CONFIG_NFS_SMALL_XACT_SIZE,
-		smallPoolDepth);
-	assert( smallPool );
-
-	bigPool = rpcUdpXactPoolCreate(
-		NFS_PROGRAM,
-		NFS_VERSION_2,
-		CONFIG_NFS_BIG_XACT_SIZE,
-		bigPoolDepth);
-	assert( bigPool );
-
-	status = rtems_semaphore_create(
-		rtems_build_name('N','F','S','l'),
-		1,
-		MUTEX_ATTRIBUTES,
-		0,
-		&nfsGlob.llock);
-	assert( status == RTEMS_SUCCESSFUL );
-	status = rtems_semaphore_create(
-		rtems_build_name('N','F','S','m'),
-		1,
-		MUTEX_ATTRIBUTES,
-		0,
-		&nfsGlob.lock);
-	assert( status == RTEMS_SUCCESSFUL );
-
-	if (sizeof(ino_t) < sizeof(u_int)) {
-		fprintf(stderr,
-			"WARNING: Using 'short st_ino' hits performance and may fail to access/find correct files\n");
-		fprintf(stderr,
-			"you should fix newlib's sys/stat.h - for now I'll enable a hack...\n");
-
-	}
-}
-
-/* Driver cleanup code
- */
-int
-nfsCleanup(void)
-{
-rtems_id	l;
-int			refuse;
-
-	if (!nfsGlob.llock) {
-		/* registering the driver failed - let them still cleanup */
-		return 0;
-	}
-
-	LOCK(nfsGlob.llock);
-	if ( (refuse = nfsGlob.num_mounted_fs) ) {
-		fprintf(stderr,"Refuse to unload NFS; %i filesystems still mounted.\n",
-						refuse);
-		nfsMountsShow(stderr);
-		/* yes, printing is slow - but since you try to unload the driver,
-		 * you assume nobody is using NFS, so what if they have to wait?
-		 */
-		UNLOCK(nfsGlob.llock);
-		return -1;
-	}
-
-	rtems_semaphore_delete(nfsGlob.lock);
-	nfsGlob.lock = 0;
-
-	/* hold the lock while cleaning up... */
-
-	rpcUdpXactPoolDestroy(smallPool);
-	rpcUdpXactPoolDestroy(bigPool);
-	l = nfsGlob.llock;
-	rtems_io_unregister_driver(nfsGlob.nfs_major);
-
-	rtems_semaphore_delete(l);
-	nfsGlob.llock = 0;
-	return 0;
-}
-
-/* NFS RPC wrapper.
- *
- * ARGS:	srvr	the NFS server we want to call
- * 			proc	the NFSPROC_xx we want to invoke
- * 			xargs   xdr routine to wrap the arguments
- * 			pargs   pointer to the argument object
- * 			xres	xdr routine to unwrap the results
- * 			pres	pointer to the result object
- *
- * RETURNS:	0 on success, -1 on error with errno set.
- *
- * NOTE:	the caller assumes that errno is set to
- *			a nonzero value if this routine returns
- *			an error (nonzero return value).
- *
- *			This routine prints RPC error messages to
- *			stderr.
- */
-STATIC int
-nfscall(
-	RpcUdpServer	srvr,
-	int				proc,
-	xdrproc_t		xargs,
-	void *			pargs,
-	xdrproc_t		xres,
-	void *			pres)
-{
-RpcUdpXact		xact;
-enum clnt_stat	stat;
-RpcUdpXactPool	pool;
-int				rval = -1;
-
-
-	switch (proc) {
-		case NFSPROC_SYMLINK:
-		case NFSPROC_WRITE:
-					pool = bigPool;		break;
-		default:	pool = smallPool;	break;
-	}
-
-	xact = rpcUdpXactPoolGet(pool, XactGetCreate);
-
-	if ( !xact ) {
-		errno = ENOMEM;
-		return -1;
-	}
-
-	if ( RPC_SUCCESS != (stat=rpcUdpSend(
-								xact,
-								srvr,
-								NFSCALL_TIMEOUT,
-								proc,
-								xres,
-								pres,
-								xargs,
-								pargs,
-								0)) ||
-	     RPC_SUCCESS != (stat=rpcUdpRcv(xact)) ) {
-
-		fprintf(stderr,
-				"NFS (proc %i) - %s\n",
-				proc,
-				clnt_sperrno(stat));
-
-		switch (stat) {
-			/* TODO: this is probably not complete and/or fully accurate */
-			case RPC_CANTENCODEARGS : errno = EINVAL;	break;
-			case RPC_AUTHERROR  	: errno = EPERM;	break;
-
-			case RPC_CANTSEND		:
-			case RPC_CANTRECV		: /* hope they have errno set */
-			case RPC_SYSTEMERROR	: break;
-
-			default             	: errno = EIO;		break;
-		}
-	} else {
-		rval = 0;
-	}
-
-	/* release the transaction back into the pool */
-	rpcUdpXactPoolPut(xact);
-
-	if (rval && !errno)
-		errno = EIO;
-
-	return rval;
-}
-
-/* Check the 'age' of a node's stats
- * and read the attributes from the server
- * if necessary.
- *
- * ARGS:	node	node to update
- * 			force	enforce updating ignoring
- * 					the timestamp/age
- *
- * RETURNS:	0 on success,
- * 			-1 on failure with errno set
- */
-
-static int
-updateAttr(NfsNode node, int force)
-{
-
-	if (force
-#ifdef CONFIG_ATTR_LIFETIME
-		|| (nowSeconds() - node->age > CONFIG_ATTR_LIFETIME)
-#endif
-		) {
-		if ( nfscall(node->nfs->server,
-					  NFSPROC_GETATTR,
-					  (xdrproc_t)xdr_nfs_fh,	&SERP_FILE(node),
-					  (xdrproc_t)xdr_attrstat, &node->serporid) )
-		return -1;
-
-		if ( NFS_OK != node->serporid.status ) {
-			errno = node->serporid.status;
-			return -1;
-		}
-
-		node->age = nowSeconds();
-	}
-
-	return 0;
-}
-
-/*
- * IP address helper.
- *
- * initialize a sockaddr_in from a
- * [<uid>'.'<gid>'@']<host>':'<path>" string and let
- * pPath point to the <path> part; retrieve the optional
- * uid/gids
- *
- * ARGS:	see description above
- *
- * RETURNS:	0 on success,
- * 			-1 on failure with errno set
- */
-static int
-buildIpAddr(u_long *puid, u_long *pgid,
-			char **pHost, struct sockaddr_in *psa,
-			char **pPath)
-{
-struct hostent *h;
-char	host[64];
-char	*chpt = *pPath;
-char	*path;
-int		len;
-
-	if ( !chpt ) {
-		errno = EINVAL;
-		return -1;
-	}
-
-	/* look for the optional uid/gid */
-	if ( (chpt = strchr(chpt, UIDSEP)) ) {
-		if ( 2 != sscanf(*pPath,"%li.%li",puid,pgid) ) {
-			errno = EINVAL;
-			return -1;
-		}
-		chpt++;
-	} else {
-		*puid = geteuid();
-		*pgid = getegid();
-		chpt  = *pPath;
-	}
-	if ( pHost )
-		*pHost = chpt;
-
-	/* split the device name which is in the form
-	 *
-	 * <host> ':' <path>
-	 *
-	 * into its components using a local buffer
-	 */
-
-	if ( !(path = strchr(chpt, HOSTDELIM)) ||
-	      (len  = path - chpt) >= sizeof(host) - 1 ) {
-		errno = EINVAL;
-		return -1;
-	}
-	/* point to path beyond ':' */
-	path++;
-
-	strncpy(host, chpt, len);
-	host[len]=0;
-
-  /* BEGIN OF NON-THREAD SAFE REGION */
-
-	h = gethostbyname(host);
-
-	if ( !h ) {
-		errno = EINVAL;
-		return -1;
-	}
-
-	memcpy(&psa->sin_addr, h->h_addr, sizeof (struct in_addr));
-  
-  /* END OF NON-THREAD SAFE REGION */
-
-	psa->sin_family = AF_INET;
-	psa->sin_port   = 0;
-	*pPath          = path;
-	return 0;
-}
-
-/* wrapper similar to nfscall.
- * However, since it is not used
- * very often, the simpler and less
- * efficient rpcUdpCallRp API is used.
- *
- * ARGS:	see 'nfscall()' above
- *
- * RETURNS:	RPC status
- */
-static enum clnt_stat
-mntcall(
-	struct sockaddr_in	*psrvr,
-	int					proc,
-	xdrproc_t			xargs,
-	void *				pargs,
-	xdrproc_t			xres,
-	void *				pres,
-	u_long				uid,
-	u_long				gid)
-{
-#ifdef MOUNT_V1_PORT
-int					retry;
-#endif
-enum clnt_stat		stat = RPC_FAILED;
-
-#ifdef MOUNT_V1_PORT
-	/* if the portmapper fails, retry a fixed port */
-	for (retry = 1, psrvr->sin_port = 0, stat = RPC_FAILED;
-		 retry >= 0 && stat;
-		 stat && (psrvr->sin_port = htons(MOUNT_V1_PORT)), retry-- )
-#endif
-		stat  = rpcUdpCallRp(
-						psrvr,
-						MOUNTPROG,
-						MOUNTVERS,
-						proc,
-						xargs,
-						pargs,
-						xres,
-						pres,
-						uid,
-						gid,
-						MNTCALL_TIMEOUT
-				);
-	return stat;
-}
-
-/*****************************************
-	RTEMS File System Operations for NFS
- *****************************************/
-
-static bool nfs_is_directory(
-	rtems_filesystem_eval_path_context_t *ctx,
-	void *arg
-)
-{
-	bool is_dir = false;
-	rtems_filesystem_location_info_t *currentloc =
-		rtems_filesystem_eval_path_get_currentloc(ctx);
-	NfsNode node = currentloc->node_access;
-	int force_update = 0;
-
-	if (updateAttr(node, force_update) == 0) {
-		is_dir = SERP_ATTR(node).type == NFDIR;
-	}
-
-	return is_dir;
-}
-
-static int nfs_search_in_directory(
-	Nfs nfs,
-	const NfsNode dir,
-	char *part,
-	NfsNode entry
-)
-{
-	int rv;
-
-	entry->nfs = nfs;
-
-	/* lookup one element */
-	SERP_ATTR(entry) = SERP_ATTR(dir);
-	SERP_FILE(entry) = SERP_FILE(dir);
-	SERP_ARGS(entry).diroparg.name = part;
-
-	/* remember args / directory fh */
-	memcpy(&entry->args, &SERP_FILE(dir), sizeof(dir->args));
-
-#if DEBUG & DEBUG_EVALPATH
-	fprintf(stderr,"Looking up '%s'\n",part);
-#endif
-
-	rv = nfscall(
-		nfs->server,
-		NFSPROC_LOOKUP,
-		(xdrproc_t) xdr_diropargs, &SERP_FILE(entry),
-		(xdrproc_t) xdr_serporid,  &entry->serporid
-	);
-
-	if (rv == 0 && entry->serporid.status == NFS_OK) {
-		int force_update = 1;
-
-		rv = updateAttr(entry, force_update);
-	} else {
-		rv = -1;
-	}
-
-	return rv;
-}
-
-static void nfs_eval_follow_link(
-	rtems_filesystem_eval_path_context_t *ctx,
-	NfsNode link
-)
-{
-	const size_t len = NFS_MAXPATHLEN + 1;
-	char *buf = malloc(len);
-
-	if (buf != NULL) {
-		ssize_t rv = nfs_readlink_with_node(link, buf, len);
-
-		if (rv >= 0) {
-			rtems_filesystem_eval_path_recursive(ctx, buf, (size_t) rv);
-		} else {
-			rtems_filesystem_eval_path_error(ctx, 0);
-		}
-
-		free(buf);
-	} else {
-		rtems_filesystem_eval_path_error(ctx, ENOMEM);
-	}
-}
-
-static void nfs_eval_set_handlers(
-	rtems_filesystem_eval_path_context_t *ctx,
-	ftype type
-)
-{
-	rtems_filesystem_location_info_t *currentloc =
-		rtems_filesystem_eval_path_get_currentloc(ctx);
-
-	switch (type) {
-		case NFDIR:
-			currentloc->handlers = &nfs_dir_file_handlers;
-			break;
-		case NFREG:
-			currentloc->handlers = &nfs_file_file_handlers;
-			break;
-		case NFLNK:
-			currentloc->handlers = &nfs_link_file_handlers;
-			break;
-		default:
-			currentloc->handlers = &rtems_filesystem_handlers_default;
-			break;
-	}
-}
-
-static int nfs_move_node(NfsNode dst, const NfsNode src)
-{
-	int rv = 0;
-
-	if (dst->str != NULL) {
-#if DEBUG & DEBUG_COUNT_NODES
-		rtems_interrupt_level flags;
-		rtems_interrupt_disable(flags);
-			dst->nfs->stringsInUse--;
-		rtems_interrupt_enable(flags);
-#endif
-		free(dst->str);
-	}
-
-	*dst = *src;
-	dst->str = NULL;
-
-	if (src->args.name != NULL) {
-		dst->str = dst->args.name = strdup(src->args.name);
-		if (dst->str != NULL) {
-#if DEBUG & DEBUG_COUNT_NODES
-			rtems_interrupt_level flags;
-			rtems_interrupt_disable(flags);
-				dst->nfs->stringsInUse++;
-			rtems_interrupt_enable(flags);
-#endif
-		} else {
-			rv = -1;
-		}
-	}
-
-	return rv;
-}
-
-static rtems_filesystem_eval_path_generic_status nfs_eval_part(
-	rtems_filesystem_eval_path_context_t *ctx,
-	char *part
-)
-{
-	rtems_filesystem_eval_path_generic_status status =
-		RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE;
-	rtems_filesystem_location_info_t *currentloc =
-		rtems_filesystem_eval_path_get_currentloc(ctx);
-	Nfs nfs = currentloc->mt_entry->fs_info;
-	NfsNode dir = currentloc->node_access;
-	NfsNodeRec entry;
-	int rv = nfs_search_in_directory(nfs, dir, part, &entry);
-
-	if (rv == 0) {
-		bool terminal = !rtems_filesystem_eval_path_has_path(ctx);
-		int eval_flags = rtems_filesystem_eval_path_get_flags(ctx);
-		bool follow_sym_link = (eval_flags & RTEMS_FS_FOLLOW_SYM_LINK) != 0;
-		ftype type = SERP_ATTR(&entry).type;
-
-		rtems_filesystem_eval_path_clear_token(ctx);
-
-		if (type == NFLNK && (follow_sym_link || !terminal)) {
-			nfs_eval_follow_link(ctx, &entry);
-		} else {
-			rv = nfs_move_node(dir, &entry);
-			if (rv == 0) {
-				nfs_eval_set_handlers(ctx, type);
-				if (!terminal) {
-					status = RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE;
-				}
-			} else {
-				rtems_filesystem_eval_path_error(ctx, ENOMEM);
-			}
-		}
-	} else {
-		status = RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_NO_ENTRY;
-	}
-
-	return status;
-}
-
-static rtems_filesystem_eval_path_generic_status nfs_eval_token(
-	rtems_filesystem_eval_path_context_t *ctx,
-	void *arg,
-	const char *token,
-	size_t tokenlen
-)
-{
-	rtems_filesystem_eval_path_generic_status status =
-		RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE;
-
-	if (rtems_filesystem_is_current_directory(token, tokenlen)) {
-		rtems_filesystem_eval_path_clear_token(ctx);
-		if (rtems_filesystem_eval_path_has_path(ctx)) {
-			status = RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE;
-		}
-	} else {
-		char *part = nfs_dupname(token, tokenlen);
-
-		if (part != NULL) {
-			status = nfs_eval_part(ctx, part);
-			free(part);
-		} else {
-			rtems_filesystem_eval_path_error(ctx, ENOMEM);
-		}
-	}
-
-	return status;
-}
-
-static const rtems_filesystem_eval_path_generic_config nfs_eval_config = {
-	.is_directory = nfs_is_directory,
-	.eval_token = nfs_eval_token
-};
-
-static void nfs_eval_path(rtems_filesystem_eval_path_context_t *ctx)
-{
-	rtems_filesystem_eval_path_generic(ctx, NULL, &nfs_eval_config);
-}
-
-/* create a hard link */
-
-static int nfs_link(
-	const rtems_filesystem_location_info_t *parentloc,
-	const rtems_filesystem_location_info_t *targetloc,
-	const char *name,
-	size_t namelen
-)
-{
-int rv = 0;
-NfsNode pNode = parentloc->node_access;
-nfsstat status;
-NfsNode tNode = targetloc->node_access;
-char *dupname;
-
-	dupname = nfs_dupname(name, namelen);
-	if (dupname == NULL)
-		return -1;
-
-#if DEBUG & DEBUG_SYSCALLS
-	fprintf(stderr,"Creating link '%s'\n",dupname);
-#endif
-
-	memcpy(&SERP_ARGS(tNode).linkarg.to.dir,
-		   &SERP_FILE(pNode),
-		   sizeof(SERP_FILE(pNode)));
-
-	SERP_ARGS(tNode).linkarg.to.name = dupname;
-
-	if ( nfscall(tNode->nfs->server,
-					  NFSPROC_LINK,
-					  (xdrproc_t)xdr_linkargs,	&SERP_FILE(tNode),
-					  (xdrproc_t)xdr_nfsstat,	&status)
-	     || (NFS_OK != (errno = status))
-	   ) {
-#if DEBUG & DEBUG_SYSCALLS
-		perror("nfs_link");
-#endif
-		rv = -1;
-	}
-
-	free(dupname);
-
-	return rv;
-
-}
-
-static int nfs_do_unlink(
-	const rtems_filesystem_location_info_t *parentloc,
-	const rtems_filesystem_location_info_t *loc,
-	int								  proc
-)
-{
-nfsstat			status;
-NfsNode			node  = loc->node_access;
-Nfs				nfs   = node->nfs;
-#if DEBUG & DEBUG_SYSCALLS
-char			*name = NFSPROC_REMOVE == proc ?
-							"nfs_unlink" : "nfs_rmdir";
-#endif
-
-	/* The FS generics have determined that pathloc is _not_
-	 * a directory. Hence we may assume that the parent
-	 * is in our NFS.
-	 */
-
-#if DEBUG & DEBUG_SYSCALLS
-	assert( node->args.name == node->str && node->str );
-
-	fprintf(stderr,"%s '%s'\n", name, node->args.name);
-#endif
-
-	if ( nfscall(nfs->server,
-				 proc,
-				 (xdrproc_t)xdr_diropargs,	&node->args,
-				 (xdrproc_t)xdr_nfsstat,	&status)
-	     || (NFS_OK != (errno = status))
-	    ) {
-#if DEBUG & DEBUG_SYSCALLS
-		perror(name);
-#endif
-		return -1;
-	}
-
-	return 0;
-}
-
-static int nfs_chown(
-	const rtems_filesystem_location_info_t  *pathloc,       /* IN */
-	uid_t                                    owner,         /* IN */
-	gid_t                                    group          /* IN */
-)
-{
-sattr	arg;
-
-	arg.uid = owner;
-	arg.gid = group;
-
-	return nfs_sattr(pathloc->node_access, &arg, SATTR_UID | SATTR_GID);
-
-}
-
-static int nfs_clonenode(rtems_filesystem_location_info_t *loc)
-{
-	NfsNode	node = loc->node_access;
-
-	LOCK(nfsGlob.lock);
-	node = nfsNodeClone(node);
-	UNLOCK(nfsGlob.lock);
-
-	loc->node_access = node;
-
-	return node != NULL ? 0 : -1;
-}
-
-/* Cleanup the FS private info attached to pathloc->node_access */
-static void nfs_freenode(
-	const rtems_filesystem_location_info_t      *pathloc       /* IN */
-)
-{
-#if DEBUG & DEBUG_COUNT_NODES
-Nfs	nfs    = ((NfsNode)pathloc->node_access)->nfs;
-
-	/* print counts at entry where they are > 0 so 'nfs' is safe from being destroyed
-	 * and there's no race condition
-	 */
-	fprintf(stderr,
-			"entering freenode, in use count is %i nodes, %i strings\n",
-			nfs->nodesInUse,
-			nfs->stringsInUse);
-#endif
-
-	nfsNodeDestroy(pathloc->node_access);
-}
-
-/* NOTE/TODO: mounting on top of NFS is not currently supported
- *
- * Challenge: stateless protocol. It would be possible to
- * delete mount points on the server. We would need some sort
- * of a 'garbage collector' looking for dead/unreachable
- * mount points and unmounting them.
- * Also, the path evaluation routine would have to check
- * for crossing mount points. Crossing over from one NFS
- * into another NFS could probably handled iteratively
- * rather than by recursion.
- */
-
-int rtems_nfs_initialize(
-  rtems_filesystem_mount_table_entry_t *mt_entry,
-  const void                           *data
-)
-{
-char				*host;
-struct sockaddr_in	saddr;
-enum clnt_stat		stat;
-fhstatus			fhstat;
-u_long				uid,gid;
-#ifdef NFS_V2_PORT
-int					retry;
-#endif
-Nfs					nfs       = 0;
-NfsNode				rootNode  = 0;
-RpcUdpServer		nfsServer = 0;
-int					e         = -1;
-char				*path     = mt_entry->dev;
-
-  if (rpcUdpInit () < 0) {
-    fprintf (stderr, "error: initialising RPC\n");
-    return -1;
-  }
-  
-	nfsInit(0, 0);
-
-#if 0
-	printf("Trying to mount %s on %s\n",path,mntpoint);
-#endif
-  
-	if ( buildIpAddr(&uid, &gid, &host, &saddr, &path) )
-		return -1;
-
-#ifdef NFS_V2_PORT
-	/* if the portmapper fails, retry a fixed port */
-	for (retry = 1, saddr.sin_port = 0, stat = RPC_FAILED;
-		 retry >= 0 && stat;
-		 stat && (saddr.sin_port = htons(NFS_V2_PORT)), retry-- )
-#endif
-		stat = rpcUdpServerCreate(
-					&saddr,
-					NFS_PROGRAM,
-					NFS_VERSION_2,
-					uid,
-					gid,
-					&nfsServer
-					);
-
-	if ( RPC_SUCCESS != stat ) {
-		fprintf(stderr,
-				"Unable to contact NFS server - invalid port? (%s)\n",
-				clnt_sperrno(stat));
-		e = EPROTONOSUPPORT;
-		goto cleanup;
-	}
-
-
-	/* first, try to ping the NFS server by
-	 * calling the NULL proc.
-	 */
-	if ( nfscall(nfsServer,
-					 NFSPROC_NULL,
-					 (xdrproc_t)xdr_void, 0,
-					 (xdrproc_t)xdr_void, 0) ) {
-
-		fputs("NFS Ping ",stderr);
-		fwrite(host, 1, path-host-1, stderr);
-		fprintf(stderr," failed: %s\n", strerror(errno));
-
-		e = errno ? errno : EIO;
-		goto cleanup;
-	}
-
-	/* that seemed to work - we now try the
-	 * actual mount
-	 */
-
-	/* reuse server address but let the mntcall()
-	 * search for the mountd's port
-	 */
-	saddr.sin_port = 0;
-
-	stat = mntcall( &saddr,
-					MOUNTPROC_MNT,
-					(xdrproc_t)xdr_dirpath,
-					&path,
-					(xdrproc_t)xdr_fhstatus,
-					&fhstat,
-				 	uid,
-				 	gid );
-
-	if (stat) {
-		fprintf(stderr,"MOUNT -- %s\n",clnt_sperrno(stat));
-		if ( e<=0 )
-			e = EIO;
-		goto cleanup;
-	} else if (NFS_OK != (e=fhstat.fhs_status)) {
-		fprintf(stderr,"MOUNT: %s\n",strerror(e));
-		goto cleanup;
-	}
-
-	nfs = nfsCreate(nfsServer);
-	assert( nfs );
-	nfsServer = 0;
-
-	nfs->uid  = uid;
-	nfs->gid  = gid;
-
-	/* that seemed to work - we now create the root node
-	 * and we also must obtain the root node attributes
-	 */
-	rootNode = nfsNodeCreate(nfs, &fhstat.fhstatus_u.fhs_fhandle);
-	assert( rootNode );
-
-	if ( updateAttr(rootNode, 1 /* force */) ) {
-		e = errno;
-		goto cleanup;
-	}
-
-	/* looks good so far */
-
-	mt_entry->mt_fs_root->location.node_access = rootNode;
-
-	rootNode = 0;
-
-	mt_entry->ops = &nfs_fs_ops;
-	mt_entry->mt_fs_root->location.handlers	 = &nfs_dir_file_handlers;
-	mt_entry->pathconf_limits_and_options = &nfs_limits_and_options;
-
-	LOCK(nfsGlob.llock);
-		nfsGlob.num_mounted_fs++;
-		/* allocate a new ID for this FS */
-		nfs->id = nfsGlob.fs_ids++;
-	UNLOCK(nfsGlob.llock);
-
-	mt_entry->fs_info				 = nfs;
-	nfs->mt_entry					 = mt_entry;
-	nfs = 0;
-
-	e = 0;
-
-cleanup:
-	if (nfs)
-		nfsDestroy(nfs);
-	if (nfsServer)
-		rpcUdpServerDestroy(nfsServer);
-	if (rootNode)
-		nfsNodeDestroy(rootNode);
-	if (e)
-		rtems_set_errno_and_return_minus_one(e);
-	else
-		return 0;
-}
-
-/* This op is called when they try to unmount THIS fs */
-STATIC void nfs_fsunmount_me(
-	rtems_filesystem_mount_table_entry_t *mt_entry    /* in */
-)
-{
-enum clnt_stat		stat;
-struct sockaddr_in	saddr;
-char			*path = mt_entry->dev;
-int			nodesInUse;
-u_long			uid,gid;
-int			status;
-
-LOCK(nfsGlob.llock);
-	nodesInUse = ((Nfs)mt_entry->fs_info)->nodesInUse;
-
-	if (nodesInUse > 1 /* one ref to the root node used by us */) {
-		UNLOCK(nfsGlob.llock);
-		fprintf(stderr,
-				"Refuse to unmount; there are still %i nodes in use (1 used by us)\n",
-				nodesInUse);
-                rtems_fatal_error_occurred(0xdeadbeef);
-                return;
-	}
-
-	status = buildIpAddr(&uid, &gid, 0, &saddr, &path);
-	assert( !status );
-
-	stat = mntcall( &saddr,
-					MOUNTPROC_UMNT,
-					(xdrproc_t)xdr_dirpath, &path,
-					(xdrproc_t)xdr_void,	 0,
-				    uid,
-				    gid
-				  );
-
-	if (stat) {
-		UNLOCK(nfsGlob.llock);
-		fprintf(stderr,"NFS UMOUNT -- %s\n", clnt_sperrno(stat));
-		return;
-	}
-
-	nfsNodeDestroy(mt_entry->mt_fs_root->location.node_access);
-	mt_entry->mt_fs_root->location.node_access = 0;
-
-	nfsDestroy(mt_entry->fs_info);
-	mt_entry->fs_info = 0;
-
-	nfsGlob.num_mounted_fs--;
-UNLOCK(nfsGlob.llock);
-}
-
-/* OPTIONAL; may be NULL - BUT: CAUTION; mount() doesn't check
- * for this handler to be present - a fs bug
- * //NOTE: (10/25/2002) patch submitted and probably applied
- */
-static rtems_filesystem_node_types_t nfs_node_type(
-  const rtems_filesystem_location_info_t *loc
-)
-{
-NfsNode node = loc->node_access;
-
-	if (updateAttr(node, 0 /* only if old */))
-		return -1;
-
-	switch( SERP_ATTR(node).type ) {
-		default:
-			/* rtems has no value for 'unknown';
-			 */
-		case NFNON:
-		case NFSOCK:
-		case NFBAD:
-		case NFFIFO:
-				break;
-
-
-		case NFREG: return RTEMS_FILESYSTEM_MEMORY_FILE;
-		case NFDIR:	return RTEMS_FILESYSTEM_DIRECTORY;
-
-		case NFBLK:
-		case NFCHR:	return RTEMS_FILESYSTEM_DEVICE;
-
-		case NFLNK: return RTEMS_FILESYSTEM_SYM_LINK;
-	}
-	return -1;
-}
-
-static int nfs_mknod(
-	const rtems_filesystem_location_info_t *parentloc,
-	const char *name,
-	size_t namelen,
-	mode_t mode,
-	dev_t dev
-)
-{
-
-int					rv = 0;
-struct timeval				now;
-diropres				res;
-NfsNode					node = parentloc->node_access;
-Nfs					nfs  = node->nfs;
-mode_t					type = S_IFMT & mode;
-char					*dupname;
-
-	if (type != S_IFDIR && type != S_IFREG)
-		rtems_set_errno_and_return_minus_one(ENOTSUP);
-
-	dupname = nfs_dupname(name, namelen);
-	if (dupname == NULL)
-		return -1;
-
-#if DEBUG & DEBUG_SYSCALLS
-	fprintf(stderr,"nfs_mknod: creating %s\n", dupname);
-#endif
-
-        rtems_clock_get_tod_timeval(&now);
-
-	SERP_ARGS(node).createarg.name       		= dupname;
-	SERP_ARGS(node).createarg.attributes.mode	= mode;
-	SERP_ARGS(node).createarg.attributes.uid	= nfs->uid;
-	SERP_ARGS(node).createarg.attributes.gid	= nfs->gid;
-	SERP_ARGS(node).createarg.attributes.size	= 0;
-	SERP_ARGS(node).createarg.attributes.atime.seconds	= now.tv_sec;
-	SERP_ARGS(node).createarg.attributes.atime.useconds	= now.tv_usec;
-	SERP_ARGS(node).createarg.attributes.mtime.seconds	= now.tv_sec;
-	SERP_ARGS(node).createarg.attributes.mtime.useconds	= now.tv_usec;
-
-	if ( nfscall( nfs->server,
-						(type == S_IFDIR) ? NFSPROC_MKDIR : NFSPROC_CREATE,
-						(xdrproc_t)xdr_createargs,	&SERP_FILE(node),
-						(xdrproc_t)xdr_diropres,	&res)
-		|| (NFS_OK != (errno = res.status)) ) {
-#if DEBUG & DEBUG_SYSCALLS
-		perror("nfs_mknod");
-#endif
-                rv = -1;
-	}
-
-	free(dupname);
-
-	return rv;
-}
-
-static int nfs_rmnod(
-	const rtems_filesystem_location_info_t *parentloc,
-	const rtems_filesystem_location_info_t *loc
-)
-{
-	int rv = 0;
-	NfsNode	node  = loc->node_access;
-	int force_update = 0;
-
-	if (updateAttr(node, force_update) == 0) {
-		int proc = SERP_ATTR(node).type == NFDIR
-			? NFSPROC_RMDIR
-				: NFSPROC_REMOVE;
-
-		rv = nfs_do_unlink(parentloc, loc, proc);
-	} else {
-		rv = -1;
-	}
-
-	return rv;
-}
-
-static int nfs_utime(
-	const rtems_filesystem_location_info_t  *pathloc, /* IN */
-	time_t                                   actime,  /* IN */
-	time_t                                   modtime  /* IN */
-)
-{
-sattr	arg;
-
-	/* TODO: add rtems EPOCH - UNIX EPOCH seconds */
-	arg.atime.seconds  = actime;
-	arg.atime.useconds = 0;
-	arg.mtime.seconds  = modtime;
-	arg.mtime.useconds = 0;
-
-	return nfs_sattr(pathloc->node_access, &arg, SATTR_ATIME | SATTR_MTIME);
-}
-
-static int nfs_symlink(
-	const rtems_filesystem_location_info_t *parentloc,
-	const char *name,
-	size_t namelen,
-	const char *target
-)
-{
-int					rv = 0;
-struct timeval				now;
-nfsstat					status;
-NfsNode					node = parentloc->node_access;
-Nfs					nfs  = node->nfs;
-char					*dupname;
-
-	dupname = nfs_dupname(name, namelen);
-	if (dupname == NULL)
-		return -1;
-
-#if DEBUG & DEBUG_SYSCALLS
-	fprintf(stderr,"nfs_symlink: creating %s -> %s\n", dupname, target);
-#endif
-
-	rtems_clock_get_tod_timeval(&now);
-
-	SERP_ARGS(node).symlinkarg.name       		= dupname;
-	SERP_ARGS(node).symlinkarg.to				= (nfspath) target;
-
-	SERP_ARGS(node).symlinkarg.attributes.mode	= S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
-	SERP_ARGS(node).symlinkarg.attributes.uid	= nfs->uid;
-	SERP_ARGS(node).symlinkarg.attributes.gid	= nfs->gid;
-	SERP_ARGS(node).symlinkarg.attributes.size	= 0;
-	SERP_ARGS(node).symlinkarg.attributes.atime.seconds  = now.tv_sec;
-	SERP_ARGS(node).symlinkarg.attributes.atime.useconds = now.tv_usec;
-	SERP_ARGS(node).symlinkarg.attributes.mtime.seconds  = now.tv_sec;
-	SERP_ARGS(node).symlinkarg.attributes.mtime.useconds = now.tv_usec;
-
-	if ( nfscall( nfs->server,
-						NFSPROC_SYMLINK,
-						(xdrproc_t)xdr_symlinkargs,	&SERP_FILE(node),
-						(xdrproc_t)xdr_nfsstat,		&status)
-		|| (NFS_OK != (errno = status)) ) {
-#if DEBUG & DEBUG_SYSCALLS
-		perror("nfs_symlink");
-#endif
-                rv = -1;
-	}
-
-	free(dupname);
-
-	return rv;
-}
-
-static ssize_t nfs_readlink_with_node(
-	NfsNode node,
-	char *buf,
-	size_t len
-)
-{
-	Nfs nfs = node->nfs;
-	readlinkres_strbuf rr;
-
-	rr.strbuf.buf = buf;
-	rr.strbuf.max = len - 1;
-
-	if ( nfscall(nfs->server,
-							NFSPROC_READLINK,
-							(xdrproc_t)xdr_nfs_fh,      		&SERP_FILE(node),
-							(xdrproc_t)xdr_readlinkres_strbuf, &rr)
-		|| (NFS_OK != (errno = rr.status)) ) {
-#if DEBUG & DEBUG_SYSCALLS
-		perror("nfs_readlink_with_node");
-#endif
-		return -1;
-	}
-
-	return (ssize_t) strlen(rr.strbuf.buf);
-}
-
-static ssize_t nfs_readlink(
-	const rtems_filesystem_location_info_t *loc,
-	char *buf,
-	size_t len
-)
-{
-	NfsNode	node = loc->node_access;
-
-	return nfs_readlink_with_node(node, buf, len);
-}
-
-static int nfs_rename(
-	const rtems_filesystem_location_info_t *oldparentloc,
-	const rtems_filesystem_location_info_t *oldloc,
-	const rtems_filesystem_location_info_t *newparentloc,
-	const char *name,
-	size_t namelen
-)
-{
-	int rv = 0;
-	char *dupname = nfs_dupname(name, namelen);
-
-	if (dupname != NULL) {
-		NfsNode oldParentNode = oldparentloc->node_access;
-		NfsNode oldNode = oldloc->node_access;
-		NfsNode newParentNode = newparentloc->node_access;
-		Nfs nfs = oldParentNode->nfs;
-		const nfs_fh *toDirSrc = &SERP_FILE(newParentNode);
-		nfs_fh *toDirDst = &SERP_ARGS(oldParentNode).renamearg.to.dir;
-		nfsstat	status;
-
-		SERP_ARGS(oldParentNode).renamearg.name = oldNode->str;
-		SERP_ARGS(oldParentNode).renamearg.to.name = dupname;
-		memcpy(toDirDst, toDirSrc, sizeof(*toDirDst));
-
-		rv = nfscall(
-			nfs->server,
-			NFSPROC_RENAME,
-			(xdrproc_t) xdr_renameargs,
-			&SERP_FILE(oldParentNode),
-			(xdrproc_t) xdr_nfsstat,
-			&status
-		);
-		if (rv == 0 && (errno = status) != NFS_OK) {
-			rv = -1;
-		}
-
-		free(dupname);
-	} else {
-		rv = -1;
-	}
-
-	return rv;
-}
-
-static void nfs_lock(const rtems_filesystem_mount_table_entry_t *mt_entry)
-{
-}
-
-static void nfs_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry)
-{
-}
-
-static bool nfs_are_nodes_equal(
-	const rtems_filesystem_location_info_t *a,
-	const rtems_filesystem_location_info_t *b
-)
-{
-	bool equal = false;
-	NfsNode na = a->node_access;
-
-	if (updateAttr(na, 0) == 0) {
-		NfsNode nb = b->node_access;
-
-		if (updateAttr(nb, 0) == 0) {
-			equal = SERP_ATTR(na).fileid == SERP_ATTR(nb).fileid
-				&& SERP_ATTR(na).fsid == SERP_ATTR(nb).fsid;
-		}
-	}
-
-	return equal;
-}
-
-static int nfs_fchmod(
-	const rtems_filesystem_location_info_t *loc,
-	mode_t mode
-)
-{
-sattr	arg;
-
-	arg.mode = mode;
-	return nfs_sattr(loc->node_access, &arg, SATTR_MODE);
-
-}
-
-const struct _rtems_filesystem_operations_table nfs_fs_ops = {
-	.lock_h         = nfs_lock,
-	.unlock_h       = nfs_unlock,
-	.eval_path_h    = nfs_eval_path,
-	.link_h         = nfs_link,
-	.are_nodes_equal_h = nfs_are_nodes_equal,
-	.node_type_h    = nfs_node_type,
-	.mknod_h        = nfs_mknod,
-	.rmnod_h        = nfs_rmnod,
-	.fchmod_h       = nfs_fchmod,
-	.chown_h        = nfs_chown,
-	.clonenod_h     = nfs_clonenode,
-	.freenod_h      = nfs_freenode,
-	.mount_h        = rtems_filesystem_default_mount,
-	.fsmount_me_h   = rtems_nfs_initialize,
-	.unmount_h      = rtems_filesystem_default_unmount,
-	.fsunmount_me_h = nfs_fsunmount_me,
-	.utime_h        = nfs_utime,
-	.symlink_h      = nfs_symlink,
-	.readlink_h     = nfs_readlink,
-	.rename_h       = nfs_rename,
-	.statvfs_h      = rtems_filesystem_default_statvfs
-};
-
-/*****************************************
-	File Handlers
-
-	NOTE: the FS generics expect a FS'
-	      evalpath_h() to switch the
-		  pathloc->handlers according
-		  to the pathloc/node's file
-		  type.
-		  We currently have 'file' and
-		  'directory' handlers and very
-		  few 'symlink' handlers.
-
-		  The handlers for each type are
-		  implemented or #defined ZERO
-		  in a 'nfs_file_xxx',
-		  'nfs_dir_xxx', 'nfs_link_xxx'
-		  sequence below this point.
-
-		  In some cases, a common handler,
-		  can be used for all file types.
-		  It is then simply called
-		  'nfs_xxx'.
- *****************************************/
-
-/* stateless NFS protocol makes this trivial */
-static int nfs_file_open(
-	rtems_libio_t *iop,
-	const char    *pathname,
-	int           oflag,
-	mode_t        mode
-)
-{
-	return 0;
-}
-
-/* reading directories is not stateless; we must
- * remember the last 'read' position, i.e.
- * the server 'cookie'. We do manage this information
- * attached to the pathinfo.node_access_2.
- */
-static int nfs_dir_open(
-	rtems_libio_t *iop,
-	const char    *pathname,
-	int           oflag,
-	mode_t        mode
-)
-{
-NfsNode		node = iop->pathinfo.node_access;
-DirInfo		di;
-
-	/* create a readdirargs object and copy the file handle;
-	 * attach to the pathinfo.node_access_2
-	 */
-
-	di = (DirInfo) malloc(sizeof(*di));
-	iop->pathinfo.node_access_2 = di;
-
-	if ( !di  ) {
-		errno = ENOMEM;
-		return -1;
-	}
-
-	memcpy( &di->readdirargs.dir,
-			&SERP_FILE(node),
-			sizeof(di->readdirargs.dir) );
-
-	/* rewind cookie */
-	memset( &di->readdirargs.cookie,
-	        0,
-	        sizeof(di->readdirargs.cookie) );
-
-	di->eofreached = FALSE;
-
-	return 0;
-}
-
-static int nfs_file_close(
-	rtems_libio_t *iop
-)
-{
-	return 0;
-}
-
-static int nfs_dir_close(
-	rtems_libio_t *iop
-)
-{
-	free(iop->pathinfo.node_access_2);
-	iop->pathinfo.node_access_2 = 0;
-	return 0;
-}
-
-static ssize_t nfs_file_read_chunk(
-	NfsNode node,
-	uint32_t offset,
-	void *buffer,
-	size_t count
-)
-{
-readres	rr;
-Nfs		nfs  = node->nfs;
-
-	SERP_ARGS(node).readarg.offset		= offset;
-	SERP_ARGS(node).readarg.count	  	= count;
-	SERP_ARGS(node).readarg.totalcount	= UINT32_C(0xdeadbeef);
-
-	rr.readres_u.reply.data.data_val	= buffer;
-
-	if ( nfscall(	nfs->server,
-						NFSPROC_READ,
-						(xdrproc_t)xdr_readargs,	&SERP_FILE(node),
-						(xdrproc_t)xdr_readres,	&rr) ) {
-		return -1;
-	}
-
-
-	if (NFS_OK != rr.status) {
-		rtems_set_errno_and_return_minus_one(rr.status);
-	}
-
-#if DEBUG & DEBUG_SYSCALLS
-	fprintf(stderr,
-			"Read %i (asked for %i) bytes from offset %i to 0x%08x\n",
-			rr.readres_u.reply.data.data_len,
-			count,
-			iop->offset,
-			rr.readres_u.reply.data.data_val);
-#endif
-
-
-	return rr.readres_u.reply.data.data_len;
-}
-
-static ssize_t nfs_file_read(
-	rtems_libio_t *iop,
-	void *buffer,
-	size_t count
-)
-{
-	ssize_t rv = 0;
-	NfsNode node = iop->pathinfo.node_access;
-	uint32_t offset = iop->offset;
-	char *in = buffer;
-
-	do {
-		size_t chunk = count <= NFS_MAXDATA ? count : NFS_MAXDATA;
-		ssize_t done = nfs_file_read_chunk(node, offset, in, chunk);
-
-		if (done > 0) {
-			offset += (uint32_t) done;
-			in += done;
-			count -= (size_t) done;
-			rv += done;
-		} else {
-			count = 0;
-			if (done < 0) {
-				rv = -1;
-			}
-		}
-	} while (count > 0);
-
-	if (rv > 0) {
-		iop->offset = offset;
-	}
-
-	return rv;
-}
-
-/* this is called by readdir() / getdents() */
-static ssize_t nfs_dir_read(
-	rtems_libio_t *iop,
-	void          *buffer,
-	size_t        count
-)
-{
-DirInfo			di     = iop->pathinfo.node_access_2;
-RpcUdpServer	server = ((Nfs)iop->pathinfo.mt_entry->fs_info)->server;
-
-	if ( di->eofreached )
-		return 0;
-
-	di->ptr = di->buf = buffer;
-
-	/* align + round down the buffer */
-	count &= ~ (DIRENT_HEADER_SIZE - 1);
-	di->len = count;
-
-#if 0
-	/* now estimate the number of entries we should ask for */
-	count /= DIRENT_HEADER_SIZE + CONFIG_AVG_NAMLEN;
-
-	/* estimate the encoded size that might take up */
-	count *= dirres_entry_size + CONFIG_AVG_NAMLEN;
-#else
-	/* integer arithmetics are better done the other way round */
-	count *= dirres_entry_size + CONFIG_AVG_NAMLEN;
-	count /= DIRENT_HEADER_SIZE + CONFIG_AVG_NAMLEN;
-#endif
-
-	if (count > NFS_MAXDATA)
-		count = NFS_MAXDATA;
-
-	di->readdirargs.count = count;
-
-#if DEBUG & DEBUG_READDIR
-	fprintf(stderr,
-			"Readdir: asking for %i XDR bytes, buffer is %i\n",
-			count, di->len);
-#endif
-
-	if ( nfscall(
-					server,
-					NFSPROC_READDIR,
-					(xdrproc_t)xdr_readdirargs, &di->readdirargs,
-					(xdrproc_t)xdr_dir_info,    di) ) {
-		return -1;
-	}
-
-
-	if (NFS_OK != di->status) {
-		rtems_set_errno_and_return_minus_one(di->status);
-	}
-
-	return (char*)di->ptr - (char*)buffer;
-}
-
-static ssize_t nfs_file_write(
-	rtems_libio_t *iop,
-	const void    *buffer,
-	size_t        count
-)
-{
-NfsNode 	node = iop->pathinfo.node_access;
-Nfs			nfs  = node->nfs;
-int			e;
-
-	if (count > NFS_MAXDATA)
-		count = NFS_MAXDATA;
-
-
-	SERP_ARGS(node).writearg.beginoffset   = UINT32_C(0xdeadbeef);
-	if ( LIBIO_FLAGS_APPEND & iop->flags ) {
-		if ( updateAttr(node, 0) ) {
-			return -1;
-		}
-		SERP_ARGS(node).writearg.offset	  	   = SERP_ATTR(node).size;
-	} else {
-		SERP_ARGS(node).writearg.offset	  	   = iop->offset;
-	}
-	SERP_ARGS(node).writearg.totalcount	   = UINT32_C(0xdeadbeef);
-	SERP_ARGS(node).writearg.data.data_len = count;
-	SERP_ARGS(node).writearg.data.data_val = (void*)buffer;
-
-	/* write XDR buffer size will be chosen by nfscall based
-	 * on the PROC specifier
-	 */
-
-	if ( nfscall(	nfs->server,
-						NFSPROC_WRITE,
-						(xdrproc_t)xdr_writeargs,	&SERP_FILE(node),
-						(xdrproc_t)xdr_attrstat,	&node->serporid) ) {
-		return -1;
-	}
-
-
-	if (NFS_OK != (e=node->serporid.status) ) {
-		/* try at least to recover the current attributes */
-		updateAttr(node, 1 /* force */);
-		rtems_set_errno_and_return_minus_one(e);
-	}
-
-	node->age = nowSeconds();
-
-	iop->offset += count;
-
-	return count;
-}
-
-static off_t nfs_dir_lseek(
-	rtems_libio_t *iop,
-	off_t          length,
-	int            whence
-)
-{
-	off_t rv = rtems_filesystem_default_lseek_directory(iop, length, whence);
-
-	if (rv == 0) {
-		DirInfo di = iop->pathinfo.node_access_2;
-		nfscookie *cookie = &di->readdirargs.cookie;
-
-		di->eofreached = FALSE;
-
-		/* rewind cookie */
-		memset(cookie, 0, sizeof(*cookie));
-	}
-
-	return rv;
-}
-
-#if 0	/* structure types for reference */
-struct fattr {
-		ftype type;
-		u_int mode;
-		u_int nlink;
-		u_int uid;
-		u_int gid;
-		u_int size;
-		u_int blocksize;
-		u_int rdev;
-		u_int blocks;
-		u_int fsid;
-		u_int fileid;
-		nfstime atime;
-		nfstime mtime;
-		nfstime ctime;
-};
-
-struct  stat
-{
-		dev_t         st_dev;
-		ino_t         st_ino;
-		mode_t        st_mode;
-		nlink_t       st_nlink;
-		uid_t         st_uid;
-		gid_t         st_gid;
-		dev_t         st_rdev;
-		off_t         st_size;
-		/* SysV/sco doesn't have the rest... But Solaris, eabi does.  */
-#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
-		time_t        st_atime;
-		time_t        st_mtime;
-		time_t        st_ctime;
-#else
-		time_t        st_atime;
-		long          st_spare1;
-		time_t        st_mtime;
-		long          st_spare2;
-		time_t        st_ctime;
-		long          st_spare3;
-		long          st_blksize;
-		long          st_blocks;
-		long      st_spare4[2];
-#endif
-};
-#endif
-
-/* common for file/dir/link */
-static int nfs_fstat(
-	const rtems_filesystem_location_info_t *loc,
-	struct stat *buf
-)
-{
-NfsNode	node = loc->node_access;
-fattr	*fa  = &SERP_ATTR(node);
-
-	if (updateAttr(node, 0 /* only if old */)) {
-		return -1;
-	}
-
-/* done by caller
-	memset(buf, 0, sizeof(*buf));
- */
-
-	/* translate */
-
-	/* one of the branches hopefully is optimized away */
-	if (sizeof(ino_t) < sizeof(u_int)) {
-	buf->st_dev		= NFS_MAKE_DEV_T_INO_HACK((NfsNode)loc->node_access);
-	} else {
-	buf->st_dev		= NFS_MAKE_DEV_T((NfsNode)loc->node_access);
-	}
-	buf->st_mode	= fa->mode;
-	buf->st_nlink	= fa->nlink;
-	buf->st_uid		= fa->uid;
-	buf->st_gid		= fa->gid;
-	buf->st_size	= fa->size;
-	/* Set to "preferred size" of this NFS client implementation */
-	buf->st_blksize	= nfsStBlksize ? nfsStBlksize : fa->blocksize;
-	buf->st_rdev	= fa->rdev;
-	buf->st_blocks	= fa->blocks;
-	buf->st_ino     = fa->fileid;
-	buf->st_atime	= fa->atime.seconds;
-	buf->st_mtime	= fa->mtime.seconds;
-	buf->st_ctime	= fa->ctime.seconds;
-
-#if 0 /* NFS should return the modes */
-	switch(fa->type) {
-		default:
-		case NFNON:
-		case NFBAD:
-				break;
-
-		case NFSOCK: buf->st_mode |= S_IFSOCK; break;
-		case NFFIFO: buf->st_mode |= S_IFIFO;  break;
-		case NFREG : buf->st_mode |= S_IFREG;  break;
-		case NFDIR : buf->st_mode |= S_IFDIR;  break;
-		case NFBLK : buf->st_mode |= S_IFBLK;  break;
-		case NFCHR : buf->st_mode |= S_IFCHR;  break;
-		case NFLNK : buf->st_mode |= S_IFLNK;  break;
-	}
-#endif
-
-	return 0;
-}
-
-/* a helper which does the real work for
- * a couple of handlers (such as chmod,
- * ftruncate or utime)
- */
-static int
-nfs_sattr(NfsNode node, sattr *arg, u_long mask)
-{
-
-struct timeval				now;
-nfstime					nfsnow, t;
-int						e;
-u_int					mode;
-
-	if (updateAttr(node, 0 /* only if old */))
-		return -1;
-
-        rtems_clock_get_tod_timeval(&now);
-
-	/* TODO: add rtems EPOCH - UNIX EPOCH seconds */
-	nfsnow.seconds  = now.tv_sec;
-	nfsnow.useconds = now.tv_usec;
-
-	/* merge permission bits into existing type bits */
-	mode = SERP_ATTR(node).mode;
-	if (mask & SATTR_MODE) {
-		mode &= S_IFMT;
-		mode |= arg->mode & ~S_IFMT;
-	} else {
-		mode = -1;
-	}
-	SERP_ARGS(node).sattrarg.attributes.mode  = mode;
-
-	SERP_ARGS(node).sattrarg.attributes.uid	  =
-		(mask & SATTR_UID)  ? arg->uid : -1;
-
-	SERP_ARGS(node).sattrarg.attributes.gid	  =
-		(mask & SATTR_GID)  ? arg->gid : -1;
-
-	SERP_ARGS(node).sattrarg.attributes.size  =
-		(mask & SATTR_SIZE) ? arg->size : -1;
-
-	if (mask & SATTR_ATIME)
-		t = arg->atime;
-	else if (mask & SATTR_TOUCHA)
-		t = nfsnow;
-	else
-		t.seconds = t.useconds = -1;
-	SERP_ARGS(node).sattrarg.attributes.atime = t;
-
-	if (mask & SATTR_ATIME)
-		t = arg->mtime;
-	else if (mask & SATTR_TOUCHA)
-		t = nfsnow;
-	else
-		t.seconds = t.useconds = -1;
-	SERP_ARGS(node).sattrarg.attributes.mtime = t;
-
-	node->serporid.status = NFS_OK;
-
-	if ( nfscall( node->nfs->server,
-						NFSPROC_SETATTR,
-						(xdrproc_t)xdr_sattrargs,	&SERP_FILE(node),
-						(xdrproc_t)xdr_attrstat,	&node->serporid) ) {
-#if DEBUG & DEBUG_SYSCALLS
-		fprintf(stderr,
-				"nfs_sattr (mask 0x%08x): %s",
-				mask,
-				strerror(errno));
-#endif
-		return -1;
-	}
-
-	if (NFS_OK != (e=node->serporid.status) ) {
-#if DEBUG & DEBUG_SYSCALLS
-		fprintf(stderr,"nfs_sattr: %s\n",strerror(e));
-#endif
-		/* try at least to recover the current attributes */
-		updateAttr(node, 1 /* force */);
-		rtems_set_errno_and_return_minus_one(e);
-	}
-
-	node->age = nowSeconds();
-
-	return 0;
-}
-
-/* just set the size attribute to 'length'
- * the server will take care of the rest :-)
- */
-static int nfs_file_ftruncate(
-	rtems_libio_t *iop,
-	off_t          length
-)
-{
-sattr					arg;
-
-	arg.size = length;
-	/* must not modify any other attribute; if we are not the owner
-	 * of the file or directory but only have write access changing
-	 * any attribute besides 'size' will fail...
-	 */
-	return nfs_sattr(iop->pathinfo.node_access,
-					 &arg,
-					 SATTR_SIZE);
-}
-
-/* the file handlers table */
-static const
-struct _rtems_filesystem_file_handlers_r nfs_file_file_handlers = {
-	.open_h      = nfs_file_open,
-	.close_h     = nfs_file_close,
-	.read_h      = nfs_file_read,
-	.write_h     = nfs_file_write,
-	.ioctl_h     = rtems_filesystem_default_ioctl,
-	.lseek_h     = rtems_filesystem_default_lseek_file,
-	.fstat_h     = nfs_fstat,
-	.ftruncate_h = nfs_file_ftruncate,
-	.fsync_h     = rtems_filesystem_default_fsync_or_fdatasync,
-	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fcntl_h     = rtems_filesystem_default_fcntl
-};
-
-/* the directory handlers table */
-static const
-struct _rtems_filesystem_file_handlers_r nfs_dir_file_handlers = {
-	.open_h      = nfs_dir_open,
-	.close_h     = nfs_dir_close,
-	.read_h      = nfs_dir_read,
-	.write_h     = rtems_filesystem_default_write,
-	.ioctl_h     = rtems_filesystem_default_ioctl,
-	.lseek_h     = nfs_dir_lseek,
-	.fstat_h     = nfs_fstat,
-	.ftruncate_h = rtems_filesystem_default_ftruncate_directory,
-	.fsync_h     = rtems_filesystem_default_fsync_or_fdatasync,
-	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fcntl_h     = rtems_filesystem_default_fcntl
-};
-
-/* the link handlers table */
-static const
-struct _rtems_filesystem_file_handlers_r nfs_link_file_handlers = {
-	.open_h      = rtems_filesystem_default_open,
-	.close_h     = rtems_filesystem_default_close,
-	.read_h      = rtems_filesystem_default_read,
-	.write_h     = rtems_filesystem_default_write,
-	.ioctl_h     = rtems_filesystem_default_ioctl,
-	.lseek_h     = rtems_filesystem_default_lseek,
-	.fstat_h     = nfs_fstat,
-	.ftruncate_h = rtems_filesystem_default_ftruncate,
-	.fsync_h     = rtems_filesystem_default_fsync_or_fdatasync,
-	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fcntl_h     = rtems_filesystem_default_fcntl
-};
-
-/* we need a dummy driver entry table to get a
- * major number from the system
- */
-static
-rtems_device_driver nfs_initialize(
-		rtems_device_major_number	major,
-		rtems_device_minor_number	minor,
-		void						*arg
-)
-{
-	/* we don't really use this routine because
-     * we cannot supply an argument (contrary
-     * to what the 'arg' parameter suggests - it
-     * is always set to 0 by the generics :-()
-     * and because we don't want the user to
-     * have to deal with the major number (which
-     * OTOH is something WE are interested in. The
-     * only reason for using this API was getting
-     * a major number, after all).
-     *
-	 * Something must be present, however, to
-	 * reserve a slot in the driver table.
-	 */
-	return RTEMS_SUCCESSFUL;
-}
-
-static rtems_driver_address_table	drvNfs = {
-		nfs_initialize,
-		0,					/* open    */
-		0,					/* close   */
-		0,					/* read    */
-		0,					/* write   */
-		0					/* control */
-};
-
-/* Dump a list of the currently mounted NFS to a  file */
-int
-nfsMountsShow(FILE *f)
-{
-char	*mntpt = 0;
-Nfs		nfs;
-
-	if (!f)
-		f = stdout;
-
-	if ( !(mntpt=malloc(MAXPATHLEN)) ) {
-		fprintf(stderr,"nfsMountsShow(): no memory\n");
-		return -1;
-	}
-
-	fprintf(f,"Currently Mounted NFS:\n");
-
-	LOCK(nfsGlob.llock);
-
-	for (nfs = nfsGlob.mounted_fs; nfs; nfs=nfs->next) {
-		fprintf(f,"%s on ", nfs->mt_entry->dev);
-		if (rtems_filesystem_resolve_location(mntpt, MAXPATHLEN, &nfs->mt_entry->mt_fs_root->location))
-			fprintf(f,"<UNABLE TO LOOKUP MOUNTPOINT>\n");
-		else
-			fprintf(f,"%s\n",mntpt);
-	}
-
-	UNLOCK(nfsGlob.llock);
-
-	free(mntpt);
-	return 0;
-}
-
-#if 0
-CCJ_REMOVE_MOUNT
-/* convenience wrapper
- *
- * NOTE: this routine calls NON-REENTRANT
- *       gethostbyname() if the host is
- *       not in 'dot' notation.
- */
-int
-nfsMount(char *uidhost, char *path, char *mntpoint)
-{
-struct stat								st;
-int										devl;
-char									*host;
-int										rval = -1;
-char									*dev =  0;
-
-	if (!uidhost || !path || !mntpoint) {
-		fprintf(stderr,"usage: nfsMount(""[uid.gid@]host"",""path"",""mountpoint"")\n");
-		nfsMountsShow(stderr);
-		return -1;
-	}
-
-	if ( !(dev = malloc((devl=strlen(uidhost) + 20 + strlen(path)+1))) ) {
-		fprintf(stderr,"nfsMount: out of memory\n");
-		return -1;
-	}
-
-	/* Try to create the mount point if nonexistent */
-	if (stat(mntpoint, &st)) {
-		if (ENOENT != errno) {
-			perror("nfsMount trying to create mount point - stat failed");
-			goto cleanup;
-		} else if (mkdir(mntpoint,0777)) {
-			perror("nfsMount trying to create mount point");
-			goto cleanup;
-		}
-	}
-
-	if ( !(host=strchr(uidhost,UIDSEP)) ) {
-		host = uidhost;
-	} else {
-		host++;
-	}
-
-	if (isdigit((unsigned char)*host)) {
-		/* avoid using gethostbyname */
-		sprintf(dev,"%s:%s",uidhost,path);
-	} else {
-		struct hostent *h;
-
-		/* copy the uid part (hostname will be
-		 * overwritten)
-		 */
-		strcpy(dev, uidhost);
-
-		/* NOTE NOTE NOTE: gethostbyname is NOT
-		 * thread safe. This is UGLY
-		 */
-
-/* BEGIN OF NON-THREAD SAFE REGION */
-
-		h = gethostbyname(host);
-
-		if ( !h ||
-			 !inet_ntop( AF_INET,
-					     (struct in_addr*)h->h_addr_list[0],
-						 dev  + (host - uidhost),
-						 devl - (host - uidhost) )
-			) {
-			fprintf(stderr,"nfsMount: host '%s' not found\n",host);
-			goto cleanup;
-		}
-
-/* END OF NON-THREAD SAFE REGION */
-
-		/* append ':<path>' */
-		strcat(dev,":");
-		strcat(dev,path);
-	}
-
-	printf("Trying to mount %s on %s\n",dev,mntpoint);
-
-	if (mount(dev,
-			  mntpoint,
-			  "nfs",
- 			  RTEMS_FILESYSTEM_READ_WRITE,
- 			  NULL)) {
-		perror("nfsMount - mount");
-		goto cleanup;
-	}
-
-	rval = 0;
-
-cleanup:
-	free(dev);
-	return rval;
-}
-#endif
-
-/* HERE COMES A REALLY UGLY HACK */
-
-/* This is stupid; it is _very_ hard to find the path
- * leading to a rtems_filesystem_location_info_t node :-(
- * The only easy way is making the location the current
- * directory and issue a getcwd().
- * However, since we don't want to tamper with the
- * current directory, we must create a separate
- * task to do the job for us - sigh.
- */
-
-typedef struct ResolvePathArgRec_ {
-	rtems_filesystem_location_info_t	*loc;	/* IN: location to resolve	*/
-	char								*buf;	/* IN/OUT: buffer where to put the path */
-	int									len;	/* IN: buffer length		*/
-	rtems_id							sync;	/* IN: synchronization		*/
-	rtems_status_code					status; /* OUT: result				*/
-} ResolvePathArgRec, *ResolvePathArg;
-
-static void
-resolve_path(rtems_task_argument arg)
-{
-ResolvePathArg						rpa = (ResolvePathArg)arg;
-rtems_filesystem_location_info_t	old;
-
-	/* IMPORTANT: let the helper task have its own libio environment (i.e. cwd) */
-	if (RTEMS_SUCCESSFUL == (rpa->status = rtems_libio_set_private_env())) {
-
-		old = rtems_filesystem_current->location;
-
-		rtems_filesystem_current->location = *(rpa->loc);
-
-		if ( !getcwd(rpa->buf, rpa->len) )
-			rpa->status = RTEMS_UNSATISFIED;
-
-		/* must restore the cwd because 'freenode' will be called on it */
-		rtems_filesystem_current->location = old;
-	}
-	rtems_semaphore_release(rpa->sync);
-	rtems_task_delete(RTEMS_SELF);
-}
-
-
-/* a utility routine to find the path leading to a
- * rtems_filesystem_location_info_t node
- *
- * INPUT: 'loc' and a buffer 'buf' (length 'len') to hold the
- *        path.
- * OUTPUT: path copied into 'buf'
- *
- * RETURNS: 0 on success, RTEMS error code on error.
- */
-rtems_status_code
-rtems_filesystem_resolve_location(char *buf, int len, rtems_filesystem_location_info_t *loc)
-{
-ResolvePathArgRec	arg;
-rtems_id			tid = 0;
-rtems_task_priority	pri;
-rtems_status_code	status;
-
-	arg.loc  = loc;
-	arg.buf  = buf;
-	arg.len  = len;
-	arg.sync = 0;
-
-	status = rtems_semaphore_create(
-					rtems_build_name('r','e','s','s'),
-					0,
-					RTEMS_SIMPLE_BINARY_SEMAPHORE,
-					0,
-					&arg.sync);
-
-	if (RTEMS_SUCCESSFUL != status)
-		goto cleanup;
-
-	rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &pri);
-
-	status = rtems_task_create(
-					rtems_build_name('r','e','s','s'),
-					pri,
-					RTEMS_MINIMUM_STACK_SIZE + 50000,
-					RTEMS_DEFAULT_MODES,
-					RTEMS_DEFAULT_ATTRIBUTES,
-					&tid);
-
-	if (RTEMS_SUCCESSFUL != status)
-		goto cleanup;
-
-	status = rtems_task_start(tid, resolve_path, (rtems_task_argument)&arg);
-
-	if (RTEMS_SUCCESSFUL != status) {
-		rtems_task_delete(tid);
-		goto cleanup;
-	}
-
-
-	/* synchronize with the helper task */
-	rtems_semaphore_obtain(arg.sync, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
-
-	status = arg.status;
-
-cleanup:
-	if (arg.sync)
-		rtems_semaphore_delete(arg.sync);
-
-	return status;
-}
-
-int
-nfsSetTimeout(uint32_t timeout_ms)
-{
-rtems_interrupt_level k;
-uint32_t	          s,us;
-
-	if ( timeout_ms > 100000 ) {
-		/* out of range */
-		return -1;
-	}
-
-	s  = timeout_ms/1000;
-	us = (timeout_ms % 1000) * 1000;
-
-	rtems_interrupt_disable(k);
-	_nfscalltimeout.tv_sec  = s;
-	_nfscalltimeout.tv_usec = us;
-	rtems_interrupt_enable(k);
-
-	return 0;
-}
-
-uint32_t
-nfsGetTimeout( void )
-{
-rtems_interrupt_level k;
-uint32_t              s,us;
-	rtems_interrupt_disable(k);
-	s  = _nfscalltimeout.tv_sec;
-	us = _nfscalltimeout.tv_usec;
-	rtems_interrupt_enable(k);
-	return s*1000 + us/1000;
-}
Index: rvices/nfsclient/nfs.modini.c
===================================================================
--- services/nfsclient/nfs.modini.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,31 +1,0 @@
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "librtemsNfs.h"
-
-/* CEXP dynamic loader support */
-
-void
-_cexpModuleInitialize(void *mod)
-{
-#if defined(DEBUG)
-	/* print load address (in case we crash while initializing) */
-unsigned lr;
-	__asm__ __volatile__(
-			"	    bl     thisis_loaded_at \n"
-			"thisis_loaded_at:              \n"
-			"       mflr   %0               \n"
-			: "=r"(lr) ::"lr");
-	printf("thisis_loaded_at: 0x%08x\n",lr);
-#endif
-	nfsInit(0,0);
-}
-
-int
-_cexpModuleFinalize(void *mod)
-{
-	return nfsCleanup();
-}
-
-
Index: rvices/nfsclient/nfsTest.c
===================================================================
--- services/nfsclient/nfsTest.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,379 +1,0 @@
-/* Test program for evaluating NFS read throughput */
-
-/* Author: Till Straumann <strauman@slac.stanford.edu>, 2006 */
-
-/* This test code allows for evaluating NFS read performance
- * under various scenarios:
- *  - synchronous reads with various buffer sizes (select
- *    'num_readers' == 0, see below).
- *  - pseudo 'read-ahead' using multiple threads that issue
- *    NFS reads from the same file (but from different offsets)
- *    in parallel.
- *    Rationale: each NFS read request is synchronous, i.e., the
- *    caller sends a request to the server and waits for the
- *    reply to come back. Performance enhancement can be expected
- *    by requesting multiple blocks in parallel rather than
- *    sequentially.
- *
- * rtems_interval
- * nfsTestRead(char *file_name, int chunk_size, int num_readers);
- *
- * 1) creates 'num_readers' threads, each opening 'file_name' for
- *    reading on a separate file descriptor.
- * 2) creates message queues for communicating with reader threads
- *
- * 3) read file using nfsTestReadBigbuf() until EOF is reached
- *
- * 4) releases resources.
- *
- * RETURNS: Time elapsed during step 3 in ms. This is measured
- *          using the system clock so make sure the test file
- *          is big enough.
- *
- * nfsTestReadBigbuf() synchronously reads a block of
- * 'num_readers * chunk_size' (which may be bigger than
- * the UDP limit of 8k) using 'num_reader' threads to
- * retrieve the various pieces of the big block in parallel.
- * This speeds up things since several RPC calls can
- * be in the works at once.
- *
- * NOTES:
- *  - if 'num_readers' == 0 this corresponds to an 'ordinary'
- *    NFS read. 'num_readers' == 1 schedules a single reader
- *    thread (== ordinary NFS read + message passing overhead).
- *  - no actual processing on the data is done; they are simply
- *    thrown away. A real, performance-critical application could
- *    pipeline 'reader' and 'cruncher' threads.
- *  - read is not completely asynchronous; synchronization is still
- *    performed at 'big block' boundaries (num_readers * chunk_size).
- */
-
-/*
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
- * 	   Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems.h>
-#include <rtems/error.h>
-
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-unsigned nfsTestReaderPri = 80;
-
-struct nfsTestReq_ {
-	unsigned offset;	/* file offset */
-	int      size;		/* IN: block size to read (must be < 8192), OUT: bytes actually read */
-	void	 *buf;		/* data buffer address */
-};
-
-/* Queue for sending requests to parallel reader tasks */
-rtems_id nfsTestRQ = 0;
-/* Queue to pickup replies from parallel reader tasks  */
-rtems_id nfsTestAQ = 0;
-
-
-/* Reader task; opens its own file descriptor
- * and works on requests:
- *    - obtain request from request queue.
- *    - lseek to the requested file offset
- *    - NFS read into buffer
- *    - queue reply.
- *
- * Note that this implementation is very simple
- *  - no full error checking.
- *  - file is opened/closed by thread
- * it's main purpose is running quick tests.
- */
-static rtems_task
-nfsTestReader(rtems_task_argument arg)
-{
-int                fd = open((char*)arg,O_RDONLY);
-unsigned long      s;
-struct nfsTestReq_ r;
-rtems_status_code  sc;
-
-	if ( fd < 0 ) {
-		perror("nfsReader: opening file");
-		goto cleanup;
-	}
-	do {
-		s  = sizeof(r);
-		sc = rtems_message_queue_receive(nfsTestRQ, &r, &s, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
-		if ( RTEMS_SUCCESSFUL != sc ) {
-			rtems_error(sc, "(Error) reading from message queue");
-			goto cleanup;
-		}
-		if ( !r.buf ) {
-			/* They send a NULL buffer as a shutdown request */
-			break;
-		}
-#ifdef DEBUG
-		printf("Reader: reading offset %u, size %i to %p ... ",
-			r.offset, r.size, r.buf);
-#endif
-		/* seek to requested offset */
-		lseek(fd, r.offset, SEEK_SET);
-		r.size = read(fd, r.buf, r.size);
-#ifdef DEBUG
-		printf("got %i\n",r.size);
-#endif
-		rtems_message_queue_send(nfsTestAQ, &r, sizeof(r));
-	} while (1) ;
-
-cleanup:
-	if ( fd >= 0 )
-		close(fd);
-	rtems_task_delete(RTEMS_SELF);
-}
-
-
-/* helper to create and start a reader task */
-static rtems_id
-taskSpawn(char *filenm, int inst)
-{
-rtems_status_code sc;
-rtems_id          tid;
-
-	sc = rtems_task_create(
-			rtems_build_name('n','t','t','0'+inst),
-			nfsTestReaderPri,
-			1400,
-			RTEMS_DEFAULT_MODES,
-			RTEMS_DEFAULT_ATTRIBUTES,
-			&tid);
-	if ( RTEMS_SUCCESSFUL != sc ) {
-		rtems_error(sc,"(Error) Creating nfs reader task %i",inst);
-		return 0;
-	}
-
-	sc = rtems_task_start(tid, nfsTestReader, (rtems_task_argument)filenm);
-	if ( RTEMS_SUCCESSFUL != sc ) {
-		rtems_error(sc,"(Error) Staritng nfs reader task %i",inst);
-		rtems_task_delete(tid);
-		return 0;
-	}
-
-	return tid;
-}
-
-/*
- * Read nrd*sz bytes into 'buf' from file offset 'off'
- * using 'nrd' parallel reader tasks to do the job.
- * This helper routine schedules 'nrd' requests to
- * the reader tasks and waits for all requests to
- * finish.
- *
- * RETURNS: number of bytes read or -1 (error).
- *
- * CAVEATS:
- *	- assumes read requests always return 'sz' bytes
- *    unless the end of file is reached.
- *    THIS ASSUMPTION SHOULD NOT BE MADE WHEN WRITING
- *    ANY 'REAL' CODE.
- */
-static int
-nfsTestReadBigbuf(char *buf, int off, int sz, int nrd)
-{
-int i,rval=0;
-struct nfsTestReq_ r;
-	r.buf    = buf;
-	r.size   = sz;
-	r.offset = off;
-	/* send out parallel requests */
-	for (i=0; i<nrd; i++) {
-		rtems_message_queue_send(nfsTestRQ, &r, sizeof(r));
-		r.offset += sz;
-		r.buf    += sz;
-	}
-	/* wait for answers */
-	for (i=0; i<nrd; i++) {
-		unsigned long s = sizeof(r);
-		rtems_message_queue_receive(nfsTestAQ, &r, &s, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
-		if ( r.size < 0 ) {
-			fprintf(stderr,"A reader failed\n");
-			rval = -1;
-		} else {
-			/* FIXME sanity checks:
-			 *   - catch case where any-but-last read returns < sz
-			 */
-			if ( rval >= 0 ) {
-				rval += r.size;
-			}
-		}
-	}
-	return rval;
-}
-
-/* Main test routine
- *
- * Read file 'fname' usint 'nrd' parallel reader tasks,
- * each operating on chunks of 'sz' bytes.
- *
- * RETURNS: time elapsed in milliseconds. This is measured
- *          using the system clock. Hence, for the result
- *          to be meaningful, the file must be big enough.
- *
- */
-rtems_interval
-nfsTestRead(char *fnam, int sz, int nrd)
-{
-int               i;
-unsigned          off;
-rtems_interval    now=-1, then, tickspsec;
-rtems_status_code sc;
-int		          fd=-1;
-char	          *buf=0;
-
-	if ( nrd < 0 )
-		nrd = 0;
-
-	if ( sz < 0 || sz > 8192 ) {
-		fprintf(stderr,"\n");
-		return -1;
-	}
-
-	nfsTestRQ = nfsTestAQ = 0;
-
-	/* Allocate buffer */
-	if ( ! (buf=malloc(sz*(nrd ? nrd : 1))) ) {
-		perror("allocating buffer");
-		goto cleanup;
-	}
-
-	/* Don't bother proceeding if we can't open the file for reading */
-	if ( (fd=open(fnam,O_RDONLY)) < 0 ) {
-		perror("opening file");
-		goto cleanup;
-	}
-	if ( nrd ) {
-		close(fd); fd = -1;
-	}
-
-	/* Create request queue */
-	if ( nrd ) {
-		sc = rtems_message_queue_create(
-				rtems_build_name('n','t','r','q'),
-				nrd,
-				sizeof(struct nfsTestReq_),
-				RTEMS_DEFAULT_ATTRIBUTES,
-				& nfsTestRQ );
-
-		if ( RTEMS_SUCCESSFUL != sc ) {
-			rtems_error(sc, "(Error) creating request queue");
-			nfsTestRQ = 0;
-			goto cleanup;
-		}
-
-		/* Spawn reader tasks */
-		for ( i=0; i<nrd; i++ ) {
-			if ( ! taskSpawn(fnam, i) )
-				goto cleanup;
-		}
-
-		/* Create reply queue */
-		sc = rtems_message_queue_create(
-				rtems_build_name('n','t','a','q'),
-				nrd,
-				sizeof(struct nfsTestReq_),
-				RTEMS_DEFAULT_ATTRIBUTES,
-				& nfsTestAQ );
-
-		if ( RTEMS_SUCCESSFUL != sc ) {
-			rtems_error(sc, "(Error) creating reply queue");
-			nfsTestAQ = 0;
-			goto cleanup;
-		}
-	}
-
-	/* Timed main loop */
-        then = rtems_clock_get_ticks_since_boot();
-
-	if ( nrd ) {
-		off = 0;
-		while  ((i = nfsTestReadBigbuf(buf, off, sz, nrd)) > 0 ) {
-#ifdef DEBUG
-			printf("bigbuf got %i\n", i);
-#endif
-			off += i;
-		}
-	} else {
-		while ( (i = read(fd, buf, sz)) > 0 )
-			/* nothing else to do */;
-		if ( i < 0 ) {
-			perror("reading");
-			goto cleanup;
-		}
-	}
-
-        now = rtems_clock_get_ticks_since_boot();
-	now = (now-then)*1000;
-	ticksspec = rtems_clock_get_ticks_per_second();
-	now /= tickspsec; /* time in ms */
-
-cleanup:
-	if ( fd >= 0 )
-		close(fd);
-
-	if ( nfsTestRQ ) {
-		/* request tasks to shutdown by sending NULL buf request  */
-		struct nfsTestReq_ r;
-		r.buf = 0;
-		for ( i=0; i<nrd; i++ ) {
-			rtems_message_queue_send( nfsTestRQ, &r, sizeof(r) );
-		}
-		/* cheat: instead of proper synchronization with shutdown we simply
-		 * delay for a second...
-		 */
-		rtems_task_wake_after( tickspsec );
-		rtems_message_queue_delete( nfsTestRQ );
-	}
-	if ( nfsTestAQ )
-		rtems_message_queue_delete( nfsTestAQ );
-	free(buf);
-	return now;
-}
Index: rvices/nfsclient/proto/mount_prot.h
===================================================================
--- services/nfsclient/proto/mount_prot.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,144 +1,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#ifndef _MOUNT_PROT_H_RPCGEN
-#define _MOUNT_PROT_H_RPCGEN
-
-#include <rpc/rpc.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MNTPATHLEN 1024
-#define MNTNAMLEN 255
-#define FHSIZE 32
-
-typedef char fhandle[FHSIZE];
-
-struct fhstatus {
-	u_int fhs_status;
-	union {
-		fhandle fhs_fhandle;
-	} fhstatus_u;
-};
-typedef struct fhstatus fhstatus;
-
-typedef char *dirpath;
-
-typedef char *name;
-
-typedef struct mountbody *mountlist;
-
-struct mountbody {
-	name ml_hostname;
-	dirpath ml_directory;
-	mountlist ml_next;
-};
-typedef struct mountbody mountbody;
-
-typedef struct groupnode *groups;
-
-struct groupnode {
-	name gr_name;
-	groups gr_next;
-};
-typedef struct groupnode groupnode;
-
-typedef struct exportnode *exports;
-
-struct exportnode {
-	dirpath ex_dir;
-	groups ex_groups;
-	exports ex_next;
-};
-typedef struct exportnode exportnode;
-
-#define MOUNTPROG 100005
-#define MOUNTVERS 1
-
-#if defined(__STDC__) || defined(__cplusplus)
-#define MOUNTPROC_NULL 0
-extern  void * mountproc_null_1(void *, CLIENT *);
-extern  void * mountproc_null_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_MNT 1
-extern  fhstatus * mountproc_mnt_1(dirpath *, CLIENT *);
-extern  fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC_DUMP 2
-extern  mountlist * mountproc_dump_1(void *, CLIENT *);
-extern  mountlist * mountproc_dump_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_UMNT 3
-extern  void * mountproc_umnt_1(dirpath *, CLIENT *);
-extern  void * mountproc_umnt_1_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC_UMNTALL 4
-extern  void * mountproc_umntall_1(void *, CLIENT *);
-extern  void * mountproc_umntall_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_EXPORT 5
-extern  exports * mountproc_export_1(void *, CLIENT *);
-extern  exports * mountproc_export_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_EXPORTALL 6
-extern  exports * mountproc_exportall_1(void *, CLIENT *);
-extern  exports * mountproc_exportall_1_svc(void *, struct svc_req *);
-extern int mountprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
-
-#else /* K&R C */
-#define MOUNTPROC_NULL 0
-extern  void * mountproc_null_1();
-extern  void * mountproc_null_1_svc();
-#define MOUNTPROC_MNT 1
-extern  fhstatus * mountproc_mnt_1();
-extern  fhstatus * mountproc_mnt_1_svc();
-#define MOUNTPROC_DUMP 2
-extern  mountlist * mountproc_dump_1();
-extern  mountlist * mountproc_dump_1_svc();
-#define MOUNTPROC_UMNT 3
-extern  void * mountproc_umnt_1();
-extern  void * mountproc_umnt_1_svc();
-#define MOUNTPROC_UMNTALL 4
-extern  void * mountproc_umntall_1();
-extern  void * mountproc_umntall_1_svc();
-#define MOUNTPROC_EXPORT 5
-extern  exports * mountproc_export_1();
-extern  exports * mountproc_export_1_svc();
-#define MOUNTPROC_EXPORTALL 6
-extern  exports * mountproc_exportall_1();
-extern  exports * mountproc_exportall_1_svc();
-extern int mountprog_1_freeresult ();
-#endif /* K&R C */
-
-/* the xdr functions */
-
-#if defined(__STDC__) || defined(__cplusplus)
-extern  bool_t xdr_fhandle (XDR *, fhandle);
-extern  bool_t xdr_fhstatus (XDR *, fhstatus*);
-extern  bool_t xdr_dirpath (XDR *, dirpath*);
-extern  bool_t xdr_name (XDR *, name*);
-extern  bool_t xdr_mountlist (XDR *, mountlist*);
-extern  bool_t xdr_mountbody (XDR *, mountbody*);
-extern  bool_t xdr_groups (XDR *, groups*);
-extern  bool_t xdr_groupnode (XDR *, groupnode*);
-extern  bool_t xdr_exports (XDR *, exports*);
-extern  bool_t xdr_exportnode (XDR *, exportnode*);
-
-#else /* K&R C */
-extern bool_t xdr_fhandle ();
-extern bool_t xdr_fhstatus ();
-extern bool_t xdr_dirpath ();
-extern bool_t xdr_name ();
-extern bool_t xdr_mountlist ();
-extern bool_t xdr_mountbody ();
-extern bool_t xdr_groups ();
-extern bool_t xdr_groupnode ();
-extern bool_t xdr_exports ();
-extern bool_t xdr_exportnode ();
-
-#endif /* K&R C */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !_MOUNT_PROT_H_RPCGEN */
Index: rvices/nfsclient/proto/mount_prot.x
===================================================================
--- services/nfsclient/proto/mount_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,161 +1,0 @@
-/* @(#)mount.x	2.1 88/08/01 4.0 RPCSRC */
-/* @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro */
-
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-/*
- * Protocol description for the mount program
- */
-
-
-const MNTPATHLEN = 1024;	/* maximum bytes in a pathname argument */
-const MNTNAMLEN = 255;		/* maximum bytes in a name argument */
-const FHSIZE = 32;		/* size in bytes of a file handle */
-
-/*
- * The fhandle is the file handle that the server passes to the client.
- * All file operations are done using the file handles to refer to a file
- * or a directory. The file handle can contain whatever information the
- * server needs to distinguish an individual file.
- */
-typedef opaque fhandle[FHSIZE];	
-
-/*
- * If a status of zero is returned, the call completed successfully, and 
- * a file handle for the directory follows. A non-zero status indicates
- * some sort of error. The status corresponds with UNIX error numbers.
- */
-union fhstatus switch (unsigned fhs_status) {
-case 0:
-	fhandle fhs_fhandle;
-default:
-	void;
-};
-
-/*
- * The type dirpath is the pathname of a directory
- */
-typedef string dirpath<MNTPATHLEN>;
-
-/*
- * The type name is used for arbitrary names (hostnames, groupnames)
- */
-typedef string name<MNTNAMLEN>;
-
-/*
- * A list of who has what mounted
- */
-typedef struct mountbody *mountlist;
-struct mountbody {
-	name ml_hostname;
-	dirpath ml_directory;
-	mountlist ml_next;
-};
-
-/*
- * A list of netgroups
- */
-typedef struct groupnode *groups;
-struct groupnode {
-	name gr_name;
-	groups gr_next;
-};
-
-/*
- * A list of what is exported and to whom
- */
-typedef struct exportnode *exports;
-struct exportnode {
-	dirpath ex_dir;
-	groups ex_groups;
-	exports ex_next;
-};
-
-program MOUNTPROG {
-	/*
-	 * Version one of the mount protocol communicates with version two
-	 * of the NFS protocol. The only connecting point is the fhandle 
-	 * structure, which is the same for both protocols.
-	 */
-	version MOUNTVERS {
-		/*
-		 * Does no work. It is made available in all RPC services
-		 * to allow server reponse testing and timing
-		 */
-		void
-		MOUNTPROC_NULL(void) = 0;
-
-		/*	
-		 * If fhs_status is 0, then fhs_fhandle contains the
-	 	 * file handle for the directory. This file handle may
-		 * be used in the NFS protocol. This procedure also adds
-		 * a new entry to the mount list for this client mounting
-		 * the directory.
-		 * Unix authentication required.
-		 */
-		fhstatus 
-		MOUNTPROC_MNT(dirpath) = 1;
-
-		/*
-		 * Returns the list of remotely mounted filesystems. The 
-		 * mountlist contains one entry for each hostname and 
-		 * directory pair.
-		 */
-		mountlist
-		MOUNTPROC_DUMP(void) = 2;
-
-		/*
-		 * Removes the mount list entry for the directory
-		 * Unix authentication required.
-		 */
-		void
-		MOUNTPROC_UMNT(dirpath) = 3;
-
-		/*
-		 * Removes all of the mount list entries for this client
-		 * Unix authentication required.
-		 */
-		void
-		MOUNTPROC_UMNTALL(void) = 4;
-
-		/*
-		 * Returns a list of all the exported filesystems, and which
-		 * machines are allowed to import it.
-		 */
-		exports
-		MOUNTPROC_EXPORT(void)  = 5;
-
-		/*
-		 * Identical to MOUNTPROC_EXPORT above
-		 */
-		exports
-		MOUNTPROC_EXPORTALL(void) = 6;
-	} = 1;
-} = 100005;
Index: rvices/nfsclient/proto/mount_prot_xdr.c
===================================================================
--- services/nfsclient/proto/mount_prot_xdr.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#include "mount_prot.h"
-
-bool_t
-xdr_fhandle (XDR *xdrs, fhandle objp)
-{
-	 if (!xdr_opaque (xdrs, objp, FHSIZE))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_fhstatus (XDR *xdrs, fhstatus *objp)
-{
-	 if (!xdr_u_int (xdrs, &objp->fhs_status))
-		 return FALSE;
-	switch (objp->fhs_status) {
-	case 0:
-		 if (!xdr_fhandle (xdrs, objp->fhstatus_u.fhs_fhandle))
-			 return FALSE;
-		break;
-	default:
-		break;
-	}
-	return TRUE;
-}
-
-bool_t
-xdr_dirpath (XDR *xdrs, dirpath *objp)
-{
-	 if (!xdr_string (xdrs, objp, MNTPATHLEN))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_name (XDR *xdrs, name *objp)
-{
-	 if (!xdr_string (xdrs, objp, MNTNAMLEN))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_mountlist (XDR *xdrs, mountlist *objp)
-{
-	 if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_mountbody (XDR *xdrs, mountbody *objp)
-{
-	 if (!xdr_name (xdrs, &objp->ml_hostname))
-		 return FALSE;
-	 if (!xdr_dirpath (xdrs, &objp->ml_directory))
-		 return FALSE;
-	 if (!xdr_mountlist (xdrs, &objp->ml_next))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_groups (XDR *xdrs, groups *objp)
-{
-	 if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_groupnode (XDR *xdrs, groupnode *objp)
-{
-	 if (!xdr_name (xdrs, &objp->gr_name))
-		 return FALSE;
-	 if (!xdr_groups (xdrs, &objp->gr_next))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_exports (XDR *xdrs, exports *objp)
-{
-	 if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_exportnode (XDR *xdrs, exportnode *objp)
-{
-	 if (!xdr_dirpath (xdrs, &objp->ex_dir))
-		 return FALSE;
-	 if (!xdr_groups (xdrs, &objp->ex_groups))
-		 return FALSE;
-	 if (!xdr_exports (xdrs, &objp->ex_next))
-		 return FALSE;
-	return TRUE;
-}
Index: rvices/nfsclient/proto/nfs_prot.h
===================================================================
--- services/nfsclient/proto/nfs_prot.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,453 +1,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#ifndef _NFS_PROT_H_RPCGEN
-#define _NFS_PROT_H_RPCGEN
-
-#include <rpc/rpc.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NFS_PORT 2049
-#define NFS_MAXDATA 8192
-#define NFS_MAXPATHLEN 1024
-#define NFS_MAXNAMLEN 255
-#define NFS_FHSIZE 32
-#define NFS_COOKIESIZE 4
-#define NFS_FIFO_DEV -1
-#define NFSMODE_FMT 0170000
-#define NFSMODE_DIR 0040000
-#define NFSMODE_CHR 0020000
-#define NFSMODE_BLK 0060000
-#define NFSMODE_REG 0100000
-#define NFSMODE_LNK 0120000
-#define NFSMODE_SOCK 0140000
-#define NFSMODE_FIFO 0010000
-
-enum nfsstat {
-	NFS_OK = 0,
-	NFSERR_PERM = 1,
-	NFSERR_NOENT = 2,
-	NFSERR_IO = 5,
-	NFSERR_NXIO = 6,
-	NFSERR_ACCES = 13,
-	NFSERR_EXIST = 17,
-	NFSERR_NODEV = 19,
-	NFSERR_NOTDIR = 20,
-	NFSERR_ISDIR = 21,
-	NFSERR_FBIG = 27,
-	NFSERR_NOSPC = 28,
-	NFSERR_ROFS = 30,
-	NFSERR_NAMETOOLONG = 63,
-	NFSERR_NOTEMPTY = 66,
-	NFSERR_DQUOT = 69,
-	NFSERR_STALE = 70,
-	NFSERR_WFLUSH = 99,
-};
-typedef enum nfsstat nfsstat;
-
-enum ftype {
-	NFNON = 0,
-	NFREG = 1,
-	NFDIR = 2,
-	NFBLK = 3,
-	NFCHR = 4,
-	NFLNK = 5,
-	NFSOCK = 6,
-	NFBAD = 7,
-	NFFIFO = 8,
-};
-typedef enum ftype ftype;
-
-struct nfs_fh {
-	char data[NFS_FHSIZE];
-};
-typedef struct nfs_fh nfs_fh;
-
-struct nfstime {
-	u_int seconds;
-	u_int useconds;
-};
-typedef struct nfstime nfstime;
-
-struct fattr {
-	ftype type;
-	u_int mode;
-	u_int nlink;
-	u_int uid;
-	u_int gid;
-	u_int size;
-	u_int blocksize;
-	u_int rdev;
-	u_int blocks;
-	u_int fsid;
-	u_int fileid;
-	nfstime atime;
-	nfstime mtime;
-	nfstime ctime;
-};
-typedef struct fattr fattr;
-
-struct sattr {
-	u_int mode;
-	u_int uid;
-	u_int gid;
-	u_int size;
-	nfstime atime;
-	nfstime mtime;
-};
-typedef struct sattr sattr;
-
-typedef char *filename;
-
-typedef char *nfspath;
-
-struct attrstat {
-	nfsstat status;
-	union {
-		fattr attributes;
-	} attrstat_u;
-};
-typedef struct attrstat attrstat;
-
-struct sattrargs {
-	nfs_fh file;
-	sattr attributes;
-};
-typedef struct sattrargs sattrargs;
-
-struct diropargs {
-	nfs_fh dir;
-	filename name;
-};
-typedef struct diropargs diropargs;
-
-struct diropokres {
-	nfs_fh file;
-	fattr attributes;
-};
-typedef struct diropokres diropokres;
-
-struct diropres {
-	nfsstat status;
-	union {
-		diropokres diropres;
-	} diropres_u;
-};
-typedef struct diropres diropres;
-
-struct readlinkres {
-	nfsstat status;
-	union {
-		nfspath data;
-	} readlinkres_u;
-};
-typedef struct readlinkres readlinkres;
-
-struct readargs {
-	nfs_fh file;
-	u_int offset;
-	u_int count;
-	u_int totalcount;
-};
-typedef struct readargs readargs;
-
-struct readokres {
-	fattr attributes;
-	struct {
-		u_int data_len;
-		char *data_val;
-	} data;
-};
-typedef struct readokres readokres;
-
-struct readres {
-	nfsstat status;
-	union {
-		readokres reply;
-	} readres_u;
-};
-typedef struct readres readres;
-
-struct writeargs {
-	nfs_fh file;
-	u_int beginoffset;
-	u_int offset;
-	u_int totalcount;
-	struct {
-		u_int data_len;
-		char *data_val;
-	} data;
-};
-typedef struct writeargs writeargs;
-
-struct createargs {
-	diropargs where;
-	sattr attributes;
-};
-typedef struct createargs createargs;
-
-struct renameargs {
-	diropargs from;
-	diropargs to;
-};
-typedef struct renameargs renameargs;
-
-struct linkargs {
-	nfs_fh from;
-	diropargs to;
-};
-typedef struct linkargs linkargs;
-
-struct symlinkargs {
-	diropargs from;
-	nfspath to;
-	sattr attributes;
-};
-typedef struct symlinkargs symlinkargs;
-
-struct nfscookie {
-	char data[NFS_COOKIESIZE];
-};
-typedef struct nfscookie nfscookie;
-
-struct readdirargs {
-	nfs_fh dir;
-	nfscookie cookie;
-	u_int count;
-};
-typedef struct readdirargs readdirargs;
-
-struct entry {
-	u_int fileid;
-	filename name;
-	nfscookie cookie;
-	struct entry *nextentry;
-};
-typedef struct entry entry;
-
-struct dirlist {
-	entry *entries;
-	bool_t eof;
-};
-typedef struct dirlist dirlist;
-
-struct readdirres {
-	nfsstat status;
-	union {
-		dirlist reply;
-	} readdirres_u;
-};
-typedef struct readdirres readdirres;
-
-struct statfsokres {
-	u_int tsize;
-	u_int bsize;
-	u_int blocks;
-	u_int bfree;
-	u_int bavail;
-};
-typedef struct statfsokres statfsokres;
-
-struct statfsres {
-	nfsstat status;
-	union {
-		statfsokres reply;
-	} statfsres_u;
-};
-typedef struct statfsres statfsres;
-
-#define NFS_PROGRAM 100003
-#define NFS_VERSION 2
-
-#if defined(__STDC__) || defined(__cplusplus)
-#define NFSPROC_NULL 0
-extern  void * nfsproc_null_2(void *, CLIENT *);
-extern  void * nfsproc_null_2_svc(void *, struct svc_req *);
-#define NFSPROC_GETATTR 1
-extern  attrstat * nfsproc_getattr_2(nfs_fh *, CLIENT *);
-extern  attrstat * nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
-#define NFSPROC_SETATTR 2
-extern  attrstat * nfsproc_setattr_2(sattrargs *, CLIENT *);
-extern  attrstat * nfsproc_setattr_2_svc(sattrargs *, struct svc_req *);
-#define NFSPROC_ROOT 3
-extern  void * nfsproc_root_2(void *, CLIENT *);
-extern  void * nfsproc_root_2_svc(void *, struct svc_req *);
-#define NFSPROC_LOOKUP 4
-extern  diropres * nfsproc_lookup_2(diropargs *, CLIENT *);
-extern  diropres * nfsproc_lookup_2_svc(diropargs *, struct svc_req *);
-#define NFSPROC_READLINK 5
-extern  readlinkres * nfsproc_readlink_2(nfs_fh *, CLIENT *);
-extern  readlinkres * nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
-#define NFSPROC_READ 6
-extern  readres * nfsproc_read_2(readargs *, CLIENT *);
-extern  readres * nfsproc_read_2_svc(readargs *, struct svc_req *);
-#define NFSPROC_WRITECACHE 7
-extern  void * nfsproc_writecache_2(void *, CLIENT *);
-extern  void * nfsproc_writecache_2_svc(void *, struct svc_req *);
-#define NFSPROC_WRITE 8
-extern  attrstat * nfsproc_write_2(writeargs *, CLIENT *);
-extern  attrstat * nfsproc_write_2_svc(writeargs *, struct svc_req *);
-#define NFSPROC_CREATE 9
-extern  diropres * nfsproc_create_2(createargs *, CLIENT *);
-extern  diropres * nfsproc_create_2_svc(createargs *, struct svc_req *);
-#define NFSPROC_REMOVE 10
-extern  nfsstat * nfsproc_remove_2(diropargs *, CLIENT *);
-extern  nfsstat * nfsproc_remove_2_svc(diropargs *, struct svc_req *);
-#define NFSPROC_RENAME 11
-extern  nfsstat * nfsproc_rename_2(renameargs *, CLIENT *);
-extern  nfsstat * nfsproc_rename_2_svc(renameargs *, struct svc_req *);
-#define NFSPROC_LINK 12
-extern  nfsstat * nfsproc_link_2(linkargs *, CLIENT *);
-extern  nfsstat * nfsproc_link_2_svc(linkargs *, struct svc_req *);
-#define NFSPROC_SYMLINK 13
-extern  nfsstat * nfsproc_symlink_2(symlinkargs *, CLIENT *);
-extern  nfsstat * nfsproc_symlink_2_svc(symlinkargs *, struct svc_req *);
-#define NFSPROC_MKDIR 14
-extern  diropres * nfsproc_mkdir_2(createargs *, CLIENT *);
-extern  diropres * nfsproc_mkdir_2_svc(createargs *, struct svc_req *);
-#define NFSPROC_RMDIR 15
-extern  nfsstat * nfsproc_rmdir_2(diropargs *, CLIENT *);
-extern  nfsstat * nfsproc_rmdir_2_svc(diropargs *, struct svc_req *);
-#define NFSPROC_READDIR 16
-extern  readdirres * nfsproc_readdir_2(readdirargs *, CLIENT *);
-extern  readdirres * nfsproc_readdir_2_svc(readdirargs *, struct svc_req *);
-#define NFSPROC_STATFS 17
-extern  statfsres * nfsproc_statfs_2(nfs_fh *, CLIENT *);
-extern  statfsres * nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
-extern int nfs_program_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
-
-#else /* K&R C */
-#define NFSPROC_NULL 0
-extern  void * nfsproc_null_2();
-extern  void * nfsproc_null_2_svc();
-#define NFSPROC_GETATTR 1
-extern  attrstat * nfsproc_getattr_2();
-extern  attrstat * nfsproc_getattr_2_svc();
-#define NFSPROC_SETATTR 2
-extern  attrstat * nfsproc_setattr_2();
-extern  attrstat * nfsproc_setattr_2_svc();
-#define NFSPROC_ROOT 3
-extern  void * nfsproc_root_2();
-extern  void * nfsproc_root_2_svc();
-#define NFSPROC_LOOKUP 4
-extern  diropres * nfsproc_lookup_2();
-extern  diropres * nfsproc_lookup_2_svc();
-#define NFSPROC_READLINK 5
-extern  readlinkres * nfsproc_readlink_2();
-extern  readlinkres * nfsproc_readlink_2_svc();
-#define NFSPROC_READ 6
-extern  readres * nfsproc_read_2();
-extern  readres * nfsproc_read_2_svc();
-#define NFSPROC_WRITECACHE 7
-extern  void * nfsproc_writecache_2();
-extern  void * nfsproc_writecache_2_svc();
-#define NFSPROC_WRITE 8
-extern  attrstat * nfsproc_write_2();
-extern  attrstat * nfsproc_write_2_svc();
-#define NFSPROC_CREATE 9
-extern  diropres * nfsproc_create_2();
-extern  diropres * nfsproc_create_2_svc();
-#define NFSPROC_REMOVE 10
-extern  nfsstat * nfsproc_remove_2();
-extern  nfsstat * nfsproc_remove_2_svc();
-#define NFSPROC_RENAME 11
-extern  nfsstat * nfsproc_rename_2();
-extern  nfsstat * nfsproc_rename_2_svc();
-#define NFSPROC_LINK 12
-extern  nfsstat * nfsproc_link_2();
-extern  nfsstat * nfsproc_link_2_svc();
-#define NFSPROC_SYMLINK 13
-extern  nfsstat * nfsproc_symlink_2();
-extern  nfsstat * nfsproc_symlink_2_svc();
-#define NFSPROC_MKDIR 14
-extern  diropres * nfsproc_mkdir_2();
-extern  diropres * nfsproc_mkdir_2_svc();
-#define NFSPROC_RMDIR 15
-extern  nfsstat * nfsproc_rmdir_2();
-extern  nfsstat * nfsproc_rmdir_2_svc();
-#define NFSPROC_READDIR 16
-extern  readdirres * nfsproc_readdir_2();
-extern  readdirres * nfsproc_readdir_2_svc();
-#define NFSPROC_STATFS 17
-extern  statfsres * nfsproc_statfs_2();
-extern  statfsres * nfsproc_statfs_2_svc();
-extern int nfs_program_2_freeresult ();
-#endif /* K&R C */
-
-/* the xdr functions */
-
-#if defined(__STDC__) || defined(__cplusplus)
-extern  bool_t xdr_nfsstat (XDR *, nfsstat*);
-extern  bool_t xdr_ftype (XDR *, ftype*);
-extern  bool_t xdr_nfs_fh (XDR *, nfs_fh*);
-extern  bool_t xdr_nfstime (XDR *, nfstime*);
-extern  bool_t xdr_fattr (XDR *, fattr*);
-extern  bool_t xdr_sattr (XDR *, sattr*);
-extern  bool_t xdr_filename (XDR *, filename*);
-extern  bool_t xdr_nfspath (XDR *, nfspath*);
-extern  bool_t xdr_attrstat (XDR *, attrstat*);
-extern  bool_t xdr_sattrargs (XDR *, sattrargs*);
-extern  bool_t xdr_diropargs (XDR *, diropargs*);
-extern  bool_t xdr_diropokres (XDR *, diropokres*);
-extern  bool_t xdr_diropres (XDR *, diropres*);
-extern  bool_t xdr_readlinkres (XDR *, readlinkres*);
-extern  bool_t xdr_readargs (XDR *, readargs*);
-extern  bool_t xdr_readokres (XDR *, readokres*);
-extern  bool_t xdr_readres (XDR *, readres*);
-extern  bool_t xdr_writeargs (XDR *, writeargs*);
-extern  bool_t xdr_createargs (XDR *, createargs*);
-extern  bool_t xdr_renameargs (XDR *, renameargs*);
-extern  bool_t xdr_linkargs (XDR *, linkargs*);
-extern  bool_t xdr_symlinkargs (XDR *, symlinkargs*);
-extern  bool_t xdr_nfscookie (XDR *, nfscookie*);
-extern  bool_t xdr_readdirargs (XDR *, readdirargs*);
-extern  bool_t xdr_entry (XDR *, entry*);
-extern  bool_t xdr_dirlist (XDR *, dirlist*);
-extern  bool_t xdr_readdirres (XDR *, readdirres*);
-extern  bool_t xdr_statfsokres (XDR *, statfsokres*);
-extern  bool_t xdr_statfsres (XDR *, statfsres*);
-
-#else /* K&R C */
-extern bool_t xdr_nfsstat ();
-extern bool_t xdr_ftype ();
-extern bool_t xdr_nfs_fh ();
-extern bool_t xdr_nfstime ();
-extern bool_t xdr_fattr ();
-extern bool_t xdr_sattr ();
-extern bool_t xdr_filename ();
-extern bool_t xdr_nfspath ();
-extern bool_t xdr_attrstat ();
-extern bool_t xdr_sattrargs ();
-extern bool_t xdr_diropargs ();
-extern bool_t xdr_diropokres ();
-extern bool_t xdr_diropres ();
-extern bool_t xdr_readlinkres ();
-extern bool_t xdr_readargs ();
-extern bool_t xdr_readokres ();
-extern bool_t xdr_readres ();
-extern bool_t xdr_writeargs ();
-extern bool_t xdr_createargs ();
-extern bool_t xdr_renameargs ();
-extern bool_t xdr_linkargs ();
-extern bool_t xdr_symlinkargs ();
-extern bool_t xdr_nfscookie ();
-extern bool_t xdr_readdirargs ();
-extern bool_t xdr_entry ();
-extern bool_t xdr_dirlist ();
-extern bool_t xdr_readdirres ();
-extern bool_t xdr_statfsokres ();
-extern bool_t xdr_statfsres ();
-
-#endif /* K&R C */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !_NFS_PROT_H_RPCGEN */
Index: rvices/nfsclient/proto/nfs_prot.x
===================================================================
--- services/nfsclient/proto/nfs_prot.x	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,1268 +1,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- * 
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- * 
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- * 
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- * 
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#ifndef RPC_HDR
-%#ifndef lint
-%/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
-%/*static char sccsid[] = "from: @(#)nfs_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
-%static char rcsid[] = "$Id$";
-%#endif /* not lint */
-#endif
-
-const NFS_PORT          = 2049;
-const NFS_MAXDATA       = 8192;
-const NFS_MAXPATHLEN    = 1024;
-const NFS_MAXNAMLEN	= 255;
-const NFS_FHSIZE	= 32;
-const NFS_COOKIESIZE	= 4;
-const NFS_FIFO_DEV	= -1;	/* size kludge for named pipes */
-
-/*
- * File types
- */
-const NFSMODE_FMT  = 0170000;	/* type of file */
-const NFSMODE_DIR  = 0040000;	/* directory */
-const NFSMODE_CHR  = 0020000;	/* character special */
-const NFSMODE_BLK  = 0060000;	/* block special */
-const NFSMODE_REG  = 0100000;	/* regular */
-const NFSMODE_LNK  = 0120000;	/* symbolic link */
-const NFSMODE_SOCK = 0140000;	/* socket */
-const NFSMODE_FIFO = 0010000;	/* fifo */
-
-/*
- * Error status
- */
-enum nfsstat {
-	NFS_OK= 0,		/* no error */
-	NFSERR_PERM=1,		/* Not owner */
-	NFSERR_NOENT=2,		/* No such file or directory */
-	NFSERR_IO=5,		/* I/O error */
-	NFSERR_NXIO=6,		/* No such device or address */
-	NFSERR_ACCES=13,	/* Permission denied */
-	NFSERR_EXIST=17,	/* File exists */
-	NFSERR_NODEV=19,	/* No such device */
-	NFSERR_NOTDIR=20,	/* Not a directory*/
-	NFSERR_ISDIR=21,	/* Is a directory */
-	NFSERR_FBIG=27,		/* File too large */
-	NFSERR_NOSPC=28,	/* No space left on device */
-	NFSERR_ROFS=30,		/* Read-only file system */
-	NFSERR_NAMETOOLONG=63,	/* File name too long */
-	NFSERR_NOTEMPTY=66,	/* Directory not empty */
-	NFSERR_DQUOT=69,	/* Disc quota exceeded */
-	NFSERR_STALE=70,	/* Stale NFS file handle */
-	NFSERR_WFLUSH=99	/* write cache flushed */
-};
-
-/*
- * File types
- */
-enum ftype {
-	NFNON = 0,	/* non-file */
-	NFREG = 1,	/* regular file */
-	NFDIR = 2,	/* directory */
-	NFBLK = 3,	/* block special */
-	NFCHR = 4,	/* character special */
-	NFLNK = 5,	/* symbolic link */
-	NFSOCK = 6,	/* unix domain sockets */
-	NFBAD = 7,	/* unused */
-	NFFIFO = 8 	/* named pipe */
-};
-
-/*
- * File access handle
- */
-struct nfs_fh {
-	opaque data[NFS_FHSIZE];
-};
-
-/* 
- * Timeval
- */
-struct nfstime {
-	unsigned seconds;
-	unsigned useconds;
-};
-
-
-/*
- * File attributes
- */
-struct fattr {
-	ftype type;		/* file type */
-	unsigned mode;		/* protection mode bits */
-	unsigned nlink;		/* # hard links */
-	unsigned uid;		/* owner user id */
-	unsigned gid;		/* owner group id */
-	unsigned size;		/* file size in bytes */
-	unsigned blocksize;	/* prefered block size */
-	unsigned rdev;		/* special device # */
-	unsigned blocks;	/* Kb of disk used by file */
-	unsigned fsid;		/* device # */
-	unsigned fileid;	/* inode # */
-	nfstime	atime;		/* time of last access */
-	nfstime	mtime;		/* time of last modification */
-	nfstime	ctime;		/* time of last change */
-};
-
-/*
- * File attributes which can be set
- */
-struct sattr {
-	unsigned mode;	/* protection mode bits */
-	unsigned uid;	/* owner user id */
-	unsigned gid;	/* owner group id */
-	unsigned size;	/* file size in bytes */
-	nfstime	atime;	/* time of last access */
-	nfstime	mtime;	/* time of last modification */
-};
-
-
-typedef string filename<NFS_MAXNAMLEN>; 
-typedef string nfspath<NFS_MAXPATHLEN>;
-
-/*
- * Reply status with file attributes
- */
-union attrstat switch (nfsstat status) {
-case NFS_OK:
-	fattr attributes;
-default:
-	void;
-};
-
-struct sattrargs {
-	nfs_fh file;
-	sattr attributes;
-};
-
-/*
- * Arguments for directory operations
- */
-struct diropargs {
-	nfs_fh	dir;	/* directory file handle */
-	filename name;		/* name (up to NFS_MAXNAMLEN bytes) */
-};
-
-struct diropokres {
-	nfs_fh file;
-	fattr attributes;
-};
-
-/*
- * Results from directory operation
- */
-union diropres switch (nfsstat status) {
-case NFS_OK:
-	diropokres diropres;
-default:
-	void;
-};
-
-union readlinkres switch (nfsstat status) {
-case NFS_OK:
-	nfspath data;
-default:
-	void;
-};
-
-/*
- * Arguments to remote read
- */
-struct readargs {
-	nfs_fh file;		/* handle for file */
-	unsigned offset;	/* byte offset in file */
-	unsigned count;		/* immediate read count */
-	unsigned totalcount;	/* total read count (from this offset)*/
-};
-
-/*
- * Status OK portion of remote read reply
- */
-struct readokres {
-	fattr	attributes;	/* attributes, need for pagin*/
-	opaque data<NFS_MAXDATA>;
-};
-
-union readres switch (nfsstat status) {
-case NFS_OK:
-	readokres reply;
-default:
-	void;
-};
-
-/*
- * Arguments to remote write 
- */
-struct writeargs {
-	nfs_fh	file;		/* handle for file */
-	unsigned beginoffset;	/* beginning byte offset in file */
-	unsigned offset;	/* current byte offset in file */
-	unsigned totalcount;	/* total write count (to this offset)*/
-	opaque data<NFS_MAXDATA>;
-};
-
-struct createargs {
-	diropargs where;
-	sattr attributes;
-};
-
-struct renameargs {
-	diropargs from;
-	diropargs to;
-};
-
-struct linkargs {
-	nfs_fh from;
-	diropargs to;
-};
-
-struct symlinkargs {
-	diropargs from;
-	nfspath to;
-	sattr attributes;
-};
-
-
-/* TS, 10/21/2002; converted cookie to struct */
-struct nfscookie {
- 	opaque data[NFS_COOKIESIZE];
-};
-
-/*
- * Arguments to readdir
- */
-struct readdirargs {
-	nfs_fh dir;		/* directory handle */
-	nfscookie cookie;
-	unsigned count;		/* number of directory bytes to read */
-};
-
-struct entry {
-	unsigned fileid;
-	filename name;
-	nfscookie cookie;
-	entry *nextentry;
-};
-
-struct dirlist {
-	entry *entries;
-	bool eof;
-};
-
-union readdirres switch (nfsstat status) {
-case NFS_OK:
-	dirlist reply;
-default:
-	void;
-};
-
-struct statfsokres {
-	unsigned tsize;	/* preferred transfer size in bytes */
-	unsigned bsize;	/* fundamental file system block size */
-	unsigned blocks;	/* total blocks in file system */
-	unsigned bfree;	/* free blocks in fs */
-	unsigned bavail;	/* free blocks avail to non-superuser */
-};
-
-union statfsres switch (nfsstat status) {
-case NFS_OK:
-	statfsokres reply;
-default:
-	void;
-};
-
-#ifdef WANT_NFS3
-
-/*
- * NFSv3 constants and types
- */
-const NFS3_FHSIZE	= 64;	/* maximum size in bytes of a file handle */
-const NFS3_COOKIEVERFSIZE = 8;	/* size of a cookie verifier for READDIR */
-const NFS3_CREATEVERFSIZE = 8;	/* size of the verifier used for CREATE */
-const NFS3_WRITEVERFSIZE = 8;	/* size of the verifier used for WRITE */
-
-typedef unsigned hyper uint64;
-typedef hyper int64;
-typedef unsigned long uint32;
-typedef long int32;
-typedef string filename3<>;
-typedef string nfspath3<>;
-typedef uint64 fileid3;
-typedef uint64 cookie3;
-typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
-typedef opaque createverf3[NFS3_CREATEVERFSIZE];
-typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
-typedef uint32 uid3;
-typedef uint32 gid3;
-typedef uint64 size3;
-typedef uint64 offset3;
-typedef uint32 mode3;
-typedef uint32 count3;
-
-/*
- * Error status (v3)
- */
-enum nfsstat3 {
-	NFS3_OK	= 0,
-	NFS3ERR_PERM		= 1,
-	NFS3ERR_NOENT		= 2,
-	NFS3ERR_IO		= 5,
-	NFS3ERR_NXIO		= 6,
-	NFS3ERR_ACCES		= 13,
-	NFS3ERR_EXIST		= 17,
-	NFS3ERR_XDEV		= 18,
-	NFS3ERR_NODEV		= 19,
-	NFS3ERR_NOTDIR		= 20,
-	NFS3ERR_ISDIR		= 21,
-	NFS3ERR_INVAL		= 22,
-	NFS3ERR_FBIG		= 27,
-	NFS3ERR_NOSPC		= 28,
-	NFS3ERR_ROFS		= 30,
-	NFS3ERR_MLINK		= 31,
-	NFS3ERR_NAMETOOLONG	= 63,
-	NFS3ERR_NOTEMPTY	= 66,
-	NFS3ERR_DQUOT		= 69,
-	NFS3ERR_STALE		= 70,
-	NFS3ERR_REMOTE		= 71,
-	NFS3ERR_BADHANDLE	= 10001,
-	NFS3ERR_NOT_SYNC	= 10002,
-	NFS3ERR_BAD_COOKIE	= 10003,
-	NFS3ERR_NOTSUPP		= 10004,
-	NFS3ERR_TOOSMALL	= 10005,
-	NFS3ERR_SERVERFAULT	= 10006,
-	NFS3ERR_BADTYPE		= 10007,
-	NFS3ERR_JUKEBOX		= 10008
-};
-
-/*
- * File types (v3)
- */
-enum ftype3 {
-	NF3REG	= 1,		/* regular file */
-	NF3DIR	= 2,		/* directory */
-	NF3BLK	= 3,		/* block special */
-	NF3CHR	= 4,		/* character special */
-	NF3LNK	= 5,		/* symbolic link */
-	NF3SOCK	= 6,		/* unix domain sockets */
-	NF3FIFO	= 7		/* named pipe */
-};
-
-struct specdata3 {
-	uint32	specdata1;
-	uint32	specdata2;
-};
-
-/*
- * File access handle (v3)
- */
-struct nfs_fh3 {
-	opaque data<NFS3_FHSIZE>;
-};
-
-/* 
- * Timeval (v3)
- */
-struct nfstime3 {
-	uint32	seconds;
-	uint32	nseconds;
-};
-
-
-/*
- * File attributes (v3)
- */
-struct fattr3 {
-	ftype3	type;		/* file type */
-	mode3	mode;		/* protection mode bits */
-	uint32	nlink;		/* # hard links */
-	uid3	uid;		/* owner user id */
-	gid3	gid;		/* owner group id */
-	size3	size;		/* file size in bytes */
-	size3	used;		/* prefered block size */
-	specdata3 rdev;		/* special device # */
-	uint64 fsid;		/* device # */
-	fileid3	fileid;		/* inode # */
-	nfstime3 atime;		/* time of last access */
-	nfstime3 mtime;		/* time of last modification */
-	nfstime3 ctime;		/* time of last change */
-};
-
-union post_op_attr switch (bool attributes_follow) {
-case TRUE:
-	fattr3	attributes;
-case FALSE:
-	void;
-};
-
-struct wcc_attr {
-	size3	size;
-	nfstime3 mtime;
-	nfstime3 ctime;
-};
-
-union pre_op_attr switch (bool attributes_follow) {
-case TRUE:
-	wcc_attr attributes;
-case FALSE:
-	void;
-};
-
-struct wcc_data {
-	pre_op_attr before;
-	post_op_attr after;
-};
-
-union post_op_fh3 switch (bool handle_follows) {
-case TRUE:
-	nfs_fh3	handle;
-case FALSE:
-	void;
-};
-
-/*
- * File attributes which can be set (v3)
- */
-enum time_how {
-	DONT_CHANGE		= 0,
-	SET_TO_SERVER_TIME	= 1,
-	SET_TO_CLIENT_TIME	= 2
-};
-
-union set_mode3 switch (bool set_it) {
-case TRUE:
-	mode3	mode;
-default:
-	void;
-};
-
-union set_uid3 switch (bool set_it) {
-case TRUE:
-	uid3	uid;
-default:
-	void;
-};
-
-union set_gid3 switch (bool set_it) {
-case TRUE:
-	gid3	gid;
-default:
-	void;
-};
-
-union set_size3 switch (bool set_it) {
-case TRUE:
-	size3	size;
-default:
-	void;
-};
-
-union set_atime switch (time_how set_it) {
-case SET_TO_CLIENT_TIME:
-	nfstime3	atime;
-default:
-	void;
-};
-
-union set_mtime switch (time_how set_it) {
-case SET_TO_CLIENT_TIME:
-	nfstime3	mtime;
-default:
-	void;
-};
-
-struct sattr3 {
-	set_mode3	mode;
-	set_uid3	uid;
-	set_gid3	gid;
-	set_size3	size;
-	set_atime	atime;
-	set_mtime	mtime;
-};
-
-/*
- * Arguments for directory operations (v3)
- */
-struct diropargs3 {
-	nfs_fh3	dir;		/* directory file handle */
-	filename3 name;		/* name (up to NFS_MAXNAMLEN bytes) */
-};
-
-/*
- * Arguments to getattr (v3).
- */
-struct GETATTR3args {
-	nfs_fh3		object;
-};
-
-struct GETATTR3resok {
-	fattr3		obj_attributes;
-};
-
-union GETATTR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	GETATTR3resok	resok;
-default:
-	void;
-};
-
-/*
- * Arguments to setattr (v3).
- */
-union sattrguard3 switch (bool check) {
-case TRUE:
-	nfstime3	obj_ctime;
-case FALSE:
-	void;
-};
-
-struct SETATTR3args {
-	nfs_fh3		object;
-	sattr3		new_attributes;
-	sattrguard3	guard;
-};
-
-struct SETATTR3resok {
-	wcc_data	obj_wcc;
-};
-
-struct SETATTR3resfail {
-	wcc_data	obj_wcc;
-};
-
-union SETATTR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	SETATTR3resok	resok;
-default:
-	SETATTR3resfail	resfail;
-};
-
-/*
- * Arguments to lookup (v3).
- */
-struct LOOKUP3args {
-	diropargs3	what;
-};
-
-struct LOOKUP3resok {
-	nfs_fh3		object;
-	post_op_attr	obj_attributes;
-	post_op_attr	dir_attributes;
-};
-
-struct LOOKUP3resfail {
-	post_op_attr	dir_attributes;
-};
-
-union LOOKUP3res switch (nfsstat3 status) {
-case NFS3_OK:
-	LOOKUP3resok	resok;
-default:
-	LOOKUP3resfail	resfail;
-};
-
-/*
- * Arguments to access (v3).
- */
-const ACCESS3_READ	= 0x0001;
-const ACCESS3_LOOKUP	= 0x0002;
-const ACCESS3_MODIFY	= 0x0004;
-const ACCESS3_EXTEND	= 0x0008;
-const ACCESS3_DELETE	= 0x0010;
-const ACCESS3_EXECUTE	= 0x0020;
-
-struct ACCESS3args {
-	nfs_fh3		object;
-	uint32		access;
-};
-
-struct ACCESS3resok {
-	post_op_attr	obj_attributes;
-	uint32		access;
-};
-
-struct ACCESS3resfail {
-	post_op_attr	obj_attributes;
-};
-
-union ACCESS3res switch (nfsstat3 status) {
-case NFS3_OK:
-	ACCESS3resok	resok;
-default:
-	ACCESS3resfail	resfail;
-};
-
-/*
- * Arguments to readlink (v3).
- */
-struct READLINK3args {
-	nfs_fh3		symlink;
-};
-
-struct READLINK3resok {
-	post_op_attr	symlink_attributes;
-	nfspath3	data;
-};
-
-struct READLINK3resfail {
-	post_op_attr	symlink_attributes;
-};
-
-union READLINK3res switch (nfsstat3 status) {
-case NFS3_OK:
-	READLINK3resok	resok;
-default:
-	READLINK3resfail resfail;
-};
-
-/*
- * Arguments to read (v3).
- */
-struct READ3args {
-	nfs_fh3		file;
-	offset3		offset;
-	count3		count;
-};
-
-struct READ3resok {
-	post_op_attr	file_attributes;
-	count3		count;
-	bool		eof;
-	opaque		data<>;
-};
-
-struct READ3resfail {
-	post_op_attr	file_attributes;
-};
-
-/* XXX: solaris 2.6 uses ``nfsstat'' here */
-union READ3res switch (nfsstat3 status) {
-case NFS3_OK:
-	READ3resok	resok;
-default:
-	READ3resfail	resfail;
-};
-
-/*
- * Arguments to write (v3).
- */
-enum stable_how {
-	UNSTABLE	= 0,
-	DATA_SYNC	= 1,
-	FILE_SYNC	= 2
-};
-
-struct WRITE3args {
-	nfs_fh3		file;
-	offset3		offset;
-	count3		count;
-	stable_how	stable;
-	opaque		data<>;
-};
-
-struct WRITE3resok {
-	wcc_data	file_wcc;
-	count3		count;
-	stable_how	committed;
-	writeverf3	verf;
-};
-
-struct WRITE3resfail {
-	wcc_data	file_wcc;
-};
-
-union WRITE3res switch (nfsstat3 status) {
-case NFS3_OK:
-	WRITE3resok	resok;
-default:
-	WRITE3resfail	resfail;
-};
-
-/*
- * Arguments to create (v3).
- */
-enum createmode3 {
-	UNCHECKED	= 0,
-	GUARDED		= 1,
-	EXCLUSIVE	= 2
-};
-
-union createhow3 switch (createmode3 mode) {
-case UNCHECKED:
-case GUARDED:
-	sattr3		obj_attributes;
-case EXCLUSIVE:
-	createverf3	verf;
-};
-
-struct CREATE3args {
-	diropargs3	where;
-	createhow3	how;
-};
-
-struct CREATE3resok {
-	post_op_fh3	obj;
-	post_op_attr	obj_attributes;
-	wcc_data	dir_wcc;
-};
-
-struct CREATE3resfail {
-	wcc_data	dir_wcc;
-};
-
-union CREATE3res switch (nfsstat3 status) {
-case NFS3_OK:
-	CREATE3resok	resok;
-default:
-	CREATE3resfail	resfail;
-};
-
-/*
- * Arguments to mkdir (v3).
- */
-struct MKDIR3args {
-	diropargs3	where;
-	sattr3		attributes;
-};
-
-struct MKDIR3resok {
-	post_op_fh3	obj;
-	post_op_attr	obj_attributes;
-	wcc_data	dir_wcc;
-};
-
-struct MKDIR3resfail {
-	wcc_data	dir_wcc;
-};
-
-union MKDIR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	MKDIR3resok	resok;
-default:
-	MKDIR3resfail	resfail;
-};
-
-/*
- * Arguments to symlink (v3).
- */
-struct symlinkdata3 {
-	sattr3		symlink_attributes;
-	nfspath3	symlink_data;
-};
-
-struct SYMLINK3args {
-	diropargs3	where;
-	symlinkdata3	symlink;
-};
-
-struct SYMLINK3resok {
-	post_op_fh3	obj;
-	post_op_attr	obj_attributes;
-	wcc_data	dir_wcc;
-};
-
-struct SYMLINK3resfail {
-	wcc_data	dir_wcc;
-};
-
-union SYMLINK3res switch (nfsstat3 status) {
-case NFS3_OK:
-	SYMLINK3resok	resok;
-default:
-	SYMLINK3resfail	resfail;
-};
-
-/*
- * Arguments to mknod (v3).
- */
-struct devicedata3 {
-	sattr3		dev_attributes;
-	specdata3	spec;
-};
-
-union mknoddata3 switch (ftype3 type) {
-case NF3CHR:
-case NF3BLK:
-	devicedata3	device;
-case NF3SOCK:
-case NF3FIFO:
-	sattr3		pipe_attributes;
-default:
-	void;
-};
-
-struct MKNOD3args {
-	diropargs3	where;
-	mknoddata3	what;
-};
-
-struct MKNOD3resok {
-	post_op_fh3	obj;
-	post_op_attr	obj_attributes;
-	wcc_data	dir_wcc;
-};
-
-struct MKNOD3resfail {
-	wcc_data	dir_wcc;
-};
-
-union MKNOD3res switch (nfsstat3 status) {
-case NFS3_OK:
-	MKNOD3resok	resok;
-default:
-	MKNOD3resfail	resfail;
-};
-
-/*
- * Arguments to remove (v3).
- */
-struct REMOVE3args {
-	diropargs3	object;
-};
-
-struct REMOVE3resok {
-	wcc_data	dir_wcc;
-};
-
-struct REMOVE3resfail {
-	wcc_data	dir_wcc;
-};
-
-union REMOVE3res switch (nfsstat3 status) {
-case NFS3_OK:
-	REMOVE3resok	resok;
-default:
-	REMOVE3resfail	resfail;
-};
-
-/*
- * Arguments to rmdir (v3).
- */
-struct RMDIR3args {
-	diropargs3	object;
-};
-
-struct RMDIR3resok {
-	wcc_data	dir_wcc;
-};
-
-struct RMDIR3resfail {
-	wcc_data	dir_wcc;
-};
-
-union RMDIR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	RMDIR3resok	resok;
-default:
-	RMDIR3resfail	resfail;
-};
-
-/*
- * Arguments to rename (v3).
- */
-struct RENAME3args {
-	diropargs3	from;
-	diropargs3	to;
-};
-
-struct RENAME3resok {
-	wcc_data	fromdir_wcc;
-	wcc_data	todir_wcc;
-};
-
-struct RENAME3resfail {
-	wcc_data	fromdir_wcc;
-	wcc_data	todir_wcc;
-};
-
-union RENAME3res switch (nfsstat3 status) {
-case NFS3_OK:
-	RENAME3resok	resok;
-default:
-	RENAME3resfail	resfail;
-};
-
-/*
- * Arguments to link (v3).
- */
-struct LINK3args {
-	nfs_fh3		file;
-	diropargs3	link;
-};
-
-struct LINK3resok {
-	post_op_attr	file_attributes;
-	wcc_data	linkdir_wcc;
-};
-
-struct LINK3resfail {
-	post_op_attr	file_attributes;
-	wcc_data	linkdir_wcc;
-};
-
-union LINK3res switch (nfsstat3 status) {
-case NFS3_OK:
-	LINK3resok	resok;
-default:
-	LINK3resfail	resfail;
-};
-
-/*
- * Arguments to readdir (v3).
- */
-struct READDIR3args {
-	nfs_fh3		dir;
-	cookie3		cookie;
-	cookieverf3	cookieverf;
-	count3		count;
-};
-
-struct entry3 {
-	fileid3		fileid;
-	filename3	name;
-	cookie3		cookie;
-	entry3		*nextentry;
-};
-
-struct dirlist3 {
-	entry3		*entries;
-	bool		eof;
-};
-
-struct READDIR3resok {
-	post_op_attr	dir_attributes;
-	cookieverf3	cookieverf;
-	dirlist3	reply;
-};
-
-struct READDIR3resfail {
-	post_op_attr	dir_attributes;
-};
-
-union READDIR3res switch (nfsstat3 status) {
-case NFS3_OK:
-	READDIR3resok	resok;
-default:
-	READDIR3resfail	resfail;
-};
-
-/*
- * Arguments to readdirplus (v3).
- */
-struct READDIRPLUS3args {
-	nfs_fh3		dir;
-	cookie3		cookie;
-	cookieverf3	cookieverf;
-	count3		dircount;
-	count3		maxcount;
-};
-
-struct entryplus3 {
-	fileid3		fileid;
-	filename3	name;
-	cookie3		cookie;
-	post_op_attr	name_attributes;
-	post_op_fh3	name_handle;
-	entryplus3	*nextentry;
-};
-
-struct dirlistplus3 {
-	entryplus3	*entries;
-	bool		eof;
-};
-
-struct READDIRPLUS3resok {
-	post_op_attr	dir_attributes;
-	cookieverf3	cookieverf;
-	dirlistplus3	reply;
-};
-
-struct READDIRPLUS3resfail {
-	post_op_attr	dir_attributes;
-};
-
-union READDIRPLUS3res switch (nfsstat3 status) {
-case NFS3_OK:
-	READDIRPLUS3resok	resok;
-default:
-	READDIRPLUS3resfail	resfail;
-};
-
-/*
- * Arguments to fsstat (v3).
- */
-struct FSSTAT3args {
-	nfs_fh3		fsroot;
-};
-
-struct FSSTAT3resok {
-	post_op_attr	obj_attributes;
-	size3		tbytes;
-	size3		fbytes;
-	size3		abytes;
-	size3		tfiles;
-	size3		ffiles;
-	size3		afiles;
-	uint32		invarsec;
-};
-
-struct FSSTAT3resfail {
-	post_op_attr	obj_attributes;
-};
-
-union FSSTAT3res switch (nfsstat3 status) {
-case NFS3_OK:
-	FSSTAT3resok	resok;
-default:
-	FSSTAT3resfail	resfail;
-};
-
-/*
- * Arguments to fsinfo (v3).
- */
-const FSF3_LINK		= 0x0001;
-const FSF3_SYMLINK	= 0x0002;
-const FSF3_HOMOGENEOUS	= 0x0008;
-const FSF3_CANSETTIME	= 0x0010;
-
-struct FSINFO3args {
-	nfs_fh3		fsroot;
-};
-
-struct FSINFO3resok {
-	post_op_attr	obj_attributes;
-	uint32		rtmax;
-	uint32		rtpref;
-	uint32		rtmult;
-	uint32		wtmax;
-	uint32		wtpref;
-	uint32		wtmult;
-	uint32		dtpref;
-	size3		maxfilesize;
-	nfstime3	time_delta;
-	uint32		properties;
-};
-
-struct FSINFO3resfail {
-	post_op_attr	obj_attributes;
-};
-
-union FSINFO3res switch (nfsstat3 status) {
-case NFS3_OK:
-	FSINFO3resok	resok;
-default:
-	FSINFO3resfail	resfail;
-};
-
-/*
- * Arguments to pathconf (v3).
- */
-struct PATHCONF3args {
-	nfs_fh3		object;
-};
-
-struct PATHCONF3resok {
-	post_op_attr	obj_attributes;
-	uint32		linkmax;
-	uint32		name_max;
-	bool		no_trunc;
-	bool		chown_restricted;
-	bool		case_insensitive;
-	bool		case_preserving;
-};
-
-struct PATHCONF3resfail {
-	post_op_attr	obj_attributes;
-};
-
-union PATHCONF3res switch (nfsstat3 status) {
-case NFS3_OK:
-	PATHCONF3resok	resok;
-default:
-	PATHCONF3resfail	resfail;
-};
-
-/*
- * Arguments to commit (v3).
- */
-struct COMMIT3args {
-	nfs_fh3		file;
-	offset3		offset;
-	count3		count;
-};
-
-struct COMMIT3resok {
-	wcc_data	file_wcc;
-	writeverf3	verf;
-};
-
-struct COMMIT3resfail {
-	wcc_data	file_wcc;
-};
-
-union COMMIT3res switch (nfsstat3 status) {
-case NFS3_OK:
-	COMMIT3resok	resok;
-default:
-	COMMIT3resfail	resfail;
-};
-
-#endif /* WANT_NFS3 */
-
-/*
- * Remote file service routines
- */
-program NFS_PROGRAM {
-	version NFS_VERSION {
-		void 
-		NFSPROC_NULL(void) = 0;
-
-		attrstat 
-		NFSPROC_GETATTR(nfs_fh) =	1;
-
-		attrstat 
-		NFSPROC_SETATTR(sattrargs) = 2;
-
-		void 
-		NFSPROC_ROOT(void) = 3;
-
-		diropres 
-		NFSPROC_LOOKUP(diropargs) = 4;
-
-		readlinkres 
-		NFSPROC_READLINK(nfs_fh) = 5;
-
-		readres 
-		NFSPROC_READ(readargs) = 6;
-
-		void 
-		NFSPROC_WRITECACHE(void) = 7;
-
-		attrstat
-		NFSPROC_WRITE(writeargs) = 8;
-
-		diropres
-		NFSPROC_CREATE(createargs) = 9;
-
-		nfsstat
-		NFSPROC_REMOVE(diropargs) = 10;
-
-		nfsstat
-		NFSPROC_RENAME(renameargs) = 11;
-
-		nfsstat
-		NFSPROC_LINK(linkargs) = 12;
-
-		nfsstat
-		NFSPROC_SYMLINK(symlinkargs) = 13;
-
-		diropres
-		NFSPROC_MKDIR(createargs) = 14;
-
-		nfsstat
-		NFSPROC_RMDIR(diropargs) = 15;
-
-		readdirres
-		NFSPROC_READDIR(readdirargs) = 16;
-
-		statfsres
-		NFSPROC_STATFS(nfs_fh) = 17;
-	} = 2;
-} = 100003;
-#ifdef WANT_NFS3
-program NFS3_PROGRAM {
-	version NFS_V3 {
-		void
-		NFSPROC3_NULL(void)			= 0;
-
-		GETATTR3res
-		NFSPROC3_GETATTR(GETATTR3args)		= 1;
-
-		SETATTR3res
-		NFSPROC3_SETATTR(SETATTR3args)		= 2;
-
-		LOOKUP3res
-		NFSPROC3_LOOKUP(LOOKUP3args)		= 3;
-
-		ACCESS3res
-		NFSPROC3_ACCESS(ACCESS3args)		= 4;
-
-		READLINK3res
-		NFSPROC3_READLINK(READLINK3args)	= 5;
-
-		READ3res
-		NFSPROC3_READ(READ3args)		= 6;
-
-		WRITE3res
-		NFSPROC3_WRITE(WRITE3args)		= 7;
-
-		CREATE3res
-		NFSPROC3_CREATE(CREATE3args)		= 8;
-
-		MKDIR3res
-		NFSPROC3_MKDIR(MKDIR3args)		= 9;
-
-		SYMLINK3res
-		NFSPROC3_SYMLINK(SYMLINK3args)		= 10;
-
-		MKNOD3res
-		NFSPROC3_MKNOD(MKNOD3args)		= 11;
-
-		REMOVE3res
-		NFSPROC3_REMOVE(REMOVE3args)		= 12;
-
-		RMDIR3res
-		NFSPROC3_RMDIR(RMDIR3args)		= 13;
-
-		RENAME3res
-		NFSPROC3_RENAME(RENAME3args)		= 14;
-
-		LINK3res
-		NFSPROC3_LINK(LINK3args)		= 15;
-
-		READDIR3res
-		NFSPROC3_READDIR(READDIR3args)		= 16;
-
-		READDIRPLUS3res
-		NFSPROC3_READDIRPLUS(READDIRPLUS3args)	= 17;
-
-		FSSTAT3res
-		NFSPROC3_FSSTAT(FSSTAT3args)		= 18;
-
-		FSINFO3res
-		NFSPROC3_FSINFO(FSINFO3args)		= 19;
-
-		PATHCONF3res
-		NFSPROC3_PATHCONF(PATHCONF3args)	= 20;
-
-		COMMIT3res
-		NFSPROC3_COMMIT(COMMIT3args)		= 21;
-	} = 3;
-} = 100003;
-#endif
-
Index: rvices/nfsclient/proto/nfs_prot_xdr.c
===================================================================
--- services/nfsclient/proto/nfs_prot_xdr.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,621 +1,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#include "nfs_prot.h"
-#ifndef lint
-/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
-/*static char sccsid[] = "from: @(#)nfs_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
-  #if !defined(__rtems__)
-    static char rcsid[] = "$Id$";
-  #endif
-#endif /* not lint */
-
-bool_t
-xdr_nfsstat (XDR *xdrs, nfsstat *objp)
-{
-	 if (!xdr_enum (xdrs, (enum_t *) objp))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_ftype (XDR *xdrs, ftype *objp)
-{
-	 if (!xdr_enum (xdrs, (enum_t *) objp))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_nfs_fh (XDR *xdrs, nfs_fh *objp)
-{
-	 if (!xdr_opaque (xdrs, objp->data, NFS_FHSIZE))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_nfstime (XDR *xdrs, nfstime *objp)
-{
-	 if (!xdr_u_int (xdrs, &objp->seconds))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->useconds))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_fattr (XDR *xdrs, fattr *objp)
-{
-	register int32_t *buf;
-
-
-	if (xdrs->x_op == XDR_ENCODE) {
-		 if (!xdr_ftype (xdrs, &objp->type))
-			 return FALSE;
-		buf = XDR_INLINE (xdrs, 10 * BYTES_PER_XDR_UNIT);
-		if (buf == NULL) {
-			 if (!xdr_u_int (xdrs, &objp->mode))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->nlink))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->uid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->gid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->size))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->blocksize))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->rdev))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->blocks))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->fsid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->fileid))
-				 return FALSE;
-
-		} else {
-		IXDR_PUT_U_LONG(buf, objp->mode);
-		IXDR_PUT_U_LONG(buf, objp->nlink);
-		IXDR_PUT_U_LONG(buf, objp->uid);
-		IXDR_PUT_U_LONG(buf, objp->gid);
-		IXDR_PUT_U_LONG(buf, objp->size);
-		IXDR_PUT_U_LONG(buf, objp->blocksize);
-		IXDR_PUT_U_LONG(buf, objp->rdev);
-		IXDR_PUT_U_LONG(buf, objp->blocks);
-		IXDR_PUT_U_LONG(buf, objp->fsid);
-		IXDR_PUT_U_LONG(buf, objp->fileid);
-		}
-		 if (!xdr_nfstime (xdrs, &objp->atime))
-			 return FALSE;
-		 if (!xdr_nfstime (xdrs, &objp->mtime))
-			 return FALSE;
-		 if (!xdr_nfstime (xdrs, &objp->ctime))
-			 return FALSE;
-		return TRUE;
-	} else if (xdrs->x_op == XDR_DECODE) {
-		 if (!xdr_ftype (xdrs, &objp->type))
-			 return FALSE;
-		buf = XDR_INLINE (xdrs, 10 * BYTES_PER_XDR_UNIT);
-		if (buf == NULL) {
-			 if (!xdr_u_int (xdrs, &objp->mode))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->nlink))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->uid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->gid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->size))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->blocksize))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->rdev))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->blocks))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->fsid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->fileid))
-				 return FALSE;
-
-		} else {
-		objp->mode = IXDR_GET_U_LONG(buf);
-		objp->nlink = IXDR_GET_U_LONG(buf);
-		objp->uid = IXDR_GET_U_LONG(buf);
-		objp->gid = IXDR_GET_U_LONG(buf);
-		objp->size = IXDR_GET_U_LONG(buf);
-		objp->blocksize = IXDR_GET_U_LONG(buf);
-		objp->rdev = IXDR_GET_U_LONG(buf);
-		objp->blocks = IXDR_GET_U_LONG(buf);
-		objp->fsid = IXDR_GET_U_LONG(buf);
-		objp->fileid = IXDR_GET_U_LONG(buf);
-		}
-		 if (!xdr_nfstime (xdrs, &objp->atime))
-			 return FALSE;
-		 if (!xdr_nfstime (xdrs, &objp->mtime))
-			 return FALSE;
-		 if (!xdr_nfstime (xdrs, &objp->ctime))
-			 return FALSE;
-	 return TRUE;
-	}
-
-	 if (!xdr_ftype (xdrs, &objp->type))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->mode))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->nlink))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->uid))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->gid))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->size))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->blocksize))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->rdev))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->blocks))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->fsid))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->fileid))
-		 return FALSE;
-	 if (!xdr_nfstime (xdrs, &objp->atime))
-		 return FALSE;
-	 if (!xdr_nfstime (xdrs, &objp->mtime))
-		 return FALSE;
-	 if (!xdr_nfstime (xdrs, &objp->ctime))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_sattr (XDR *xdrs, sattr *objp)
-{
-	register int32_t *buf;
-
-
-	if (xdrs->x_op == XDR_ENCODE) {
-		buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
-		if (buf == NULL) {
-			 if (!xdr_u_int (xdrs, &objp->mode))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->uid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->gid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->size))
-				 return FALSE;
-
-		} else {
-		IXDR_PUT_U_LONG(buf, objp->mode);
-		IXDR_PUT_U_LONG(buf, objp->uid);
-		IXDR_PUT_U_LONG(buf, objp->gid);
-		IXDR_PUT_U_LONG(buf, objp->size);
-		}
-		 if (!xdr_nfstime (xdrs, &objp->atime))
-			 return FALSE;
-		 if (!xdr_nfstime (xdrs, &objp->mtime))
-			 return FALSE;
-		return TRUE;
-	} else if (xdrs->x_op == XDR_DECODE) {
-		buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
-		if (buf == NULL) {
-			 if (!xdr_u_int (xdrs, &objp->mode))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->uid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->gid))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->size))
-				 return FALSE;
-
-		} else {
-		objp->mode = IXDR_GET_U_LONG(buf);
-		objp->uid = IXDR_GET_U_LONG(buf);
-		objp->gid = IXDR_GET_U_LONG(buf);
-		objp->size = IXDR_GET_U_LONG(buf);
-		}
-		 if (!xdr_nfstime (xdrs, &objp->atime))
-			 return FALSE;
-		 if (!xdr_nfstime (xdrs, &objp->mtime))
-			 return FALSE;
-	 return TRUE;
-	}
-
-	 if (!xdr_u_int (xdrs, &objp->mode))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->uid))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->gid))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->size))
-		 return FALSE;
-	 if (!xdr_nfstime (xdrs, &objp->atime))
-		 return FALSE;
-	 if (!xdr_nfstime (xdrs, &objp->mtime))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_filename (XDR *xdrs, filename *objp)
-{
-	 if (!xdr_string (xdrs, objp, NFS_MAXNAMLEN))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_nfspath (XDR *xdrs, nfspath *objp)
-{
-	 if (!xdr_string (xdrs, objp, NFS_MAXPATHLEN))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_attrstat (XDR *xdrs, attrstat *objp)
-{
-	 if (!xdr_nfsstat (xdrs, &objp->status))
-		 return FALSE;
-	switch (objp->status) {
-	case NFS_OK:
-		 if (!xdr_fattr (xdrs, &objp->attrstat_u.attributes))
-			 return FALSE;
-		break;
-	default:
-		break;
-	}
-	return TRUE;
-}
-
-bool_t
-xdr_sattrargs (XDR *xdrs, sattrargs *objp)
-{
-	 if (!xdr_nfs_fh (xdrs, &objp->file))
-		 return FALSE;
-	 if (!xdr_sattr (xdrs, &objp->attributes))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_diropargs (XDR *xdrs, diropargs *objp)
-{
-	 if (!xdr_nfs_fh (xdrs, &objp->dir))
-		 return FALSE;
-	 if (!xdr_filename (xdrs, &objp->name))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_diropokres (XDR *xdrs, diropokres *objp)
-{
-	 if (!xdr_nfs_fh (xdrs, &objp->file))
-		 return FALSE;
-	 if (!xdr_fattr (xdrs, &objp->attributes))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_diropres (XDR *xdrs, diropres *objp)
-{
-	 if (!xdr_nfsstat (xdrs, &objp->status))
-		 return FALSE;
-	switch (objp->status) {
-	case NFS_OK:
-		 if (!xdr_diropokres (xdrs, &objp->diropres_u.diropres))
-			 return FALSE;
-		break;
-	default:
-		break;
-	}
-	return TRUE;
-}
-
-bool_t
-xdr_readlinkres (XDR *xdrs, readlinkres *objp)
-{
-	 if (!xdr_nfsstat (xdrs, &objp->status))
-		 return FALSE;
-	switch (objp->status) {
-	case NFS_OK:
-		 if (!xdr_nfspath (xdrs, &objp->readlinkres_u.data))
-			 return FALSE;
-		break;
-	default:
-		break;
-	}
-	return TRUE;
-}
-
-bool_t
-xdr_readargs (XDR *xdrs, readargs *objp)
-{
-	 if (!xdr_nfs_fh (xdrs, &objp->file))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->offset))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->count))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->totalcount))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_readokres (XDR *xdrs, readokres *objp)
-{
-	 if (!xdr_fattr (xdrs, &objp->attributes))
-		 return FALSE;
-	 if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_readres (XDR *xdrs, readres *objp)
-{
-	 if (!xdr_nfsstat (xdrs, &objp->status))
-		 return FALSE;
-	switch (objp->status) {
-	case NFS_OK:
-		 if (!xdr_readokres (xdrs, &objp->readres_u.reply))
-			 return FALSE;
-		break;
-	default:
-		break;
-	}
-	return TRUE;
-}
-
-bool_t
-xdr_writeargs (XDR *xdrs, writeargs *objp)
-{
-	register int32_t *buf;
-
-
-	if (xdrs->x_op == XDR_ENCODE) {
-		 if (!xdr_nfs_fh (xdrs, &objp->file))
-			 return FALSE;
-		buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
-		if (buf == NULL) {
-			 if (!xdr_u_int (xdrs, &objp->beginoffset))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->offset))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->totalcount))
-				 return FALSE;
-
-		} else {
-		IXDR_PUT_U_LONG(buf, objp->beginoffset);
-		IXDR_PUT_U_LONG(buf, objp->offset);
-		IXDR_PUT_U_LONG(buf, objp->totalcount);
-		}
-		 if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA))
-			 return FALSE;
-		return TRUE;
-	} else if (xdrs->x_op == XDR_DECODE) {
-		 if (!xdr_nfs_fh (xdrs, &objp->file))
-			 return FALSE;
-		buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
-		if (buf == NULL) {
-			 if (!xdr_u_int (xdrs, &objp->beginoffset))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->offset))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->totalcount))
-				 return FALSE;
-
-		} else {
-		objp->beginoffset = IXDR_GET_U_LONG(buf);
-		objp->offset = IXDR_GET_U_LONG(buf);
-		objp->totalcount = IXDR_GET_U_LONG(buf);
-		}
-		 if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA))
-			 return FALSE;
-	 return TRUE;
-	}
-
-	 if (!xdr_nfs_fh (xdrs, &objp->file))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->beginoffset))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->offset))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->totalcount))
-		 return FALSE;
-	 if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_createargs (XDR *xdrs, createargs *objp)
-{
-	 if (!xdr_diropargs (xdrs, &objp->where))
-		 return FALSE;
-	 if (!xdr_sattr (xdrs, &objp->attributes))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_renameargs (XDR *xdrs, renameargs *objp)
-{
-	 if (!xdr_diropargs (xdrs, &objp->from))
-		 return FALSE;
-	 if (!xdr_diropargs (xdrs, &objp->to))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_linkargs (XDR *xdrs, linkargs *objp)
-{
-	 if (!xdr_nfs_fh (xdrs, &objp->from))
-		 return FALSE;
-	 if (!xdr_diropargs (xdrs, &objp->to))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_symlinkargs (XDR *xdrs, symlinkargs *objp)
-{
-	 if (!xdr_diropargs (xdrs, &objp->from))
-		 return FALSE;
-	 if (!xdr_nfspath (xdrs, &objp->to))
-		 return FALSE;
-	 if (!xdr_sattr (xdrs, &objp->attributes))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_nfscookie (XDR *xdrs, nfscookie *objp)
-{
-	 if (!xdr_opaque (xdrs, objp->data, NFS_COOKIESIZE))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_readdirargs (XDR *xdrs, readdirargs *objp)
-{
-	 if (!xdr_nfs_fh (xdrs, &objp->dir))
-		 return FALSE;
-	 if (!xdr_nfscookie (xdrs, &objp->cookie))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->count))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_entry (XDR *xdrs, entry *objp)
-{
-	 if (!xdr_u_int (xdrs, &objp->fileid))
-		 return FALSE;
-	 if (!xdr_filename (xdrs, &objp->name))
-		 return FALSE;
-	 if (!xdr_nfscookie (xdrs, &objp->cookie))
-		 return FALSE;
-	 if (!xdr_pointer (xdrs, (char **)&objp->nextentry, sizeof (entry), (xdrproc_t) xdr_entry))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_dirlist (XDR *xdrs, dirlist *objp)
-{
-	 if (!xdr_pointer (xdrs, (char **)&objp->entries, sizeof (entry), (xdrproc_t) xdr_entry))
-		 return FALSE;
-	 if (!xdr_bool (xdrs, &objp->eof))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_readdirres (XDR *xdrs, readdirres *objp)
-{
-	 if (!xdr_nfsstat (xdrs, &objp->status))
-		 return FALSE;
-	switch (objp->status) {
-	case NFS_OK:
-		 if (!xdr_dirlist (xdrs, &objp->readdirres_u.reply))
-			 return FALSE;
-		break;
-	default:
-		break;
-	}
-	return TRUE;
-}
-
-bool_t
-xdr_statfsokres (XDR *xdrs, statfsokres *objp)
-{
-	register int32_t *buf;
-
-
-	if (xdrs->x_op == XDR_ENCODE) {
-		buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT);
-		if (buf == NULL) {
-			 if (!xdr_u_int (xdrs, &objp->tsize))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->bsize))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->blocks))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->bfree))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->bavail))
-				 return FALSE;
-		} else {
-			IXDR_PUT_U_LONG(buf, objp->tsize);
-			IXDR_PUT_U_LONG(buf, objp->bsize);
-			IXDR_PUT_U_LONG(buf, objp->blocks);
-			IXDR_PUT_U_LONG(buf, objp->bfree);
-			IXDR_PUT_U_LONG(buf, objp->bavail);
-		}
-		return TRUE;
-	} else if (xdrs->x_op == XDR_DECODE) {
-		buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT);
-		if (buf == NULL) {
-			 if (!xdr_u_int (xdrs, &objp->tsize))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->bsize))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->blocks))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->bfree))
-				 return FALSE;
-			 if (!xdr_u_int (xdrs, &objp->bavail))
-				 return FALSE;
-		} else {
-			objp->tsize = IXDR_GET_U_LONG(buf);
-			objp->bsize = IXDR_GET_U_LONG(buf);
-			objp->blocks = IXDR_GET_U_LONG(buf);
-			objp->bfree = IXDR_GET_U_LONG(buf);
-			objp->bavail = IXDR_GET_U_LONG(buf);
-		}
-	 return TRUE;
-	}
-
-	 if (!xdr_u_int (xdrs, &objp->tsize))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->bsize))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->blocks))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->bfree))
-		 return FALSE;
-	 if (!xdr_u_int (xdrs, &objp->bavail))
-		 return FALSE;
-	return TRUE;
-}
-
-bool_t
-xdr_statfsres (XDR *xdrs, statfsres *objp)
-{
-	 if (!xdr_nfsstat (xdrs, &objp->status))
-		 return FALSE;
-	switch (objp->status) {
-	case NFS_OK:
-		 if (!xdr_statfsokres (xdrs, &objp->statfsres_u.reply))
-			 return FALSE;
-		break;
-	default:
-		break;
-	}
-	return TRUE;
-}
Index: rvices/nfsclient/rfc1094.txt
===================================================================
--- services/nfsclient/rfc1094.txt	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,1258 +1,0 @@
-
-  RFC 1094 (RFC1094)
-
-Internet RFC/STD/FYI/BCP Archives
-
-
-      RFC 1094 - NFS: Network File System Protocol specification
-
-------------------------------------------------------------------------
-
-
-Network Working Group                             Sun Microsystems, Inc.
-Request for Comments: 1094                                    March 1989
-
-            NFS: Network File System Protocol Specification
-
-STATUS OF THIS MEMO
-
-   This RFC describes a protocol that Sun Microsystems, Inc., and others
-   are using.  A new version of the protocol is under development, but
-   others may benefit from the descriptions of the current protocol, and
-   discussion of some of the design issues.  Distribution of this memo
-   is unlimited.
-
-1. INTRODUCTION
-
-   The Sun Network Filesystem (NFS) protocol provides transparent remote
-   access to shared files across networks.  The NFS protocol is designed
-   to be portable across different machines, operating systems, network
-   architectures, and transport protocols.  This portability is achieved
-   through the use of Remote Procedure Call (RPC) primitives built on
-   top of an eXternal Data Representation (XDR).  Implementations
-   already exist for a variety of machines, from personal computers to
-   supercomputers.
-
-   The supporting mount protocol allows the server to hand out remote
-   access privileges to a restricted set of clients.  It performs the
-   operating system-specific functions that allow, for example, to
-   attach remote directory trees to some local file system.
-
-1.1.  Remote Procedure Call
-
-   Sun's Remote Procedure Call specification provides a procedure-
-   oriented interface to remote services.  Each server supplies a
-   "program" that is a set of procedures.  NFS is one such program.  The
-   combination of host address, program number, and procedure number
-   specifies one remote procedure.  A goal of NFS was to not require any
-   specific level of reliability from its lower levels, so it could
-   potentially be used on many underlying transport protocols, or even
-   another remote procedure call implementation.  For ease of
-   discussion, the rest of this document will assume NFS is implemented
-   on top of Sun RPC, described in  RFC 1057 </rfcs/rfc1057.html>, "RPC: Remote Procedure
-   Call Protocol Specification".
-
-1.2.  External Data Representation
-
-   The eXternal Data Representation (XDR) standard provides a common way
-   of representing a set of data types over a network.  The NFS Protocol
-
-   Specification is written using the RPC data description language.
-   For more information, see RFC 1014 </rfcs/rfc1014.html>, "XDR: External Data
-   Representation Standard".  Although automated RPC/XDR compilers exist
-   to generate server and client "stubs", NFS does not require their
-   use.  Any software that provides equivalent functionality can be
-   used, and if the encoding is exactly the same it can interoperate
-   with other implementations of NFS.
-
-1.3.  Stateless Servers
-
-   The NFS protocol was intended to be as stateless as possible.  That
-   is, a server should not need to maintain any protocol state
-   information about any of its clients in order to function correctly.
-   Stateless servers have a distinct advantage over stateful servers in
-   the event of a failure.  With stateless servers, a client need only
-   retry a request until the server responds; it does not even need to
-   know that the server has crashed, or the network temporarily went
-   down.  The client of a stateful server, on the other hand, needs to
-   either detect a server failure and rebuild the server's state when it
-   comes back up, or cause client operations to fail.
-
-   This may not sound like an important issue, but it affects the
-   protocol in some unexpected ways.  We feel that it may be worth a bit
-   of extra complexity in the protocol to be able to write very simple
-   servers that do not require fancy crash recovery.  Note that even if
-   a so-called "reliable" transport protocol such as TCP is used, the
-   client must still be able to handle interruptions of service by re-
-   opening connections when they time out.  Thus, a stateless protocol
-   may actually simplify the  implementation.
-
-   On the other hand, NFS deals with objects such as files and
-   directories that inherently have state -- what good would a file be
-   if it did not keep its contents intact?  The goal was to not
-   introduce any extra state in the protocol itself.  Inherently
-   stateful operations such as file or record locking, and remote
-   execution,  were implemented as separate services, not described in
-   this document.
-
-   The basic way to simplify recovery was to make operations as
-   "idempotent" as possible (so that they can potentially be repeated).
-   Some operations in this version of the protocol did not attain this
-   goal; luckily most of the operations (such as Read and Write) are
-   idempotent.  Also, most server failures occur between operations, not
-   between the receipt of an operation and the response.  Finally,
-   although actual server failures may be rare, in complex networks,
-   failures of any network, router, or bridge may be indistinguishable
-   from a server failure.
-
-2. NFS PROTOCOL DEFINITION
-
-   Servers change over time, and so can the protocol that they use.  RPC
-   provides a version number with each RPC request.  This RFC describes
-   version two of the NFS protocol.  Even in the second version, there
-   are a few obsolete procedures and parameters, which will be removed
-   in later versions.  An RFC for version three of the NFS protocol is
-   currently under preparation.
-
-2.1.  File System Model
-
-   NFS assumes a file system that is hierarchical, with directories as
-   all but the bottom level of files.  Each entry in a directory (file,
-   directory, device, etc.) has a string name.  Different operating
-   systems may have restrictions on the depth of the tree or the names
-   used, as well as using different syntax to represent the "pathname",
-   which is the concatenation of all the "components" (directory and
-   file names) in the name.  A "file system" is a tree on a single
-   server (usually a single disk or physical partition) with a specified
-   "root".  Some operating systems provide a "mount" operation to make
-   all file systems appear as a single tree, while others maintain a
-   "forest" of file systems.  Files are unstructured streams of
-   uninterpreted bytes.  Version 3 of NFS uses slightly more general
-   file system model.
-
-   NFS looks up one component of a pathname at a time.  It may not be
-   obvious why it does not just take the whole pathname, traipse down
-   the directories, and return a file handle when it is done.  There are
-   several good reasons not to do this.  First, pathnames need
-   separators between the directory components, and different operating
-   systems use different separators.  We could define a Network Standard
-   Pathname Representation, but then every pathname would have to be
-   parsed and converted at each end.  Other issues are discussed in
-   section 3, NFS Implementation Issues.
-
-   Although files and directories are similar objects in many ways,
-   different procedures are used to read directories and files.  This
-   provides a network standard format for representing directories.  The
-   same argument as above could have been used to justify a procedure
-   that returns only one directory entry per call.  The problem is
-   efficiency.  Directories can contain many entries, and a remote call
-   to return each would be just too slow.
-
-2.2.  Server Procedures
-
-   The protocol definition is given as a set of procedures with
-   arguments and results defined using the RPC language (XDR language
-   extended with program, version, and procedure declarations).  A brief
-
-   description of the function of each procedure should provide enough
-   information to allow implementation.  Section 2.3 describes the basic
-   data types in more detail.
-
-   All of the procedures in the NFS protocol are assumed to be
-   synchronous.  When a procedure returns to the client, the client can
-   assume that the operation has completed and any data associated with
-   the request is now on stable storage.  For example, a client WRITE
-   request may cause the server to update data blocks, filesystem
-   information blocks (such as indirect blocks), and file attribute
-   information (size and modify times).  When the WRITE returns to the
-   client, it can assume that the write is safe, even in case of a
-   server crash, and it can discard the data written.  This is a very
-   important part of the statelessness of the server.  If the server
-   waited to flush data from remote requests, the client would have to
-   save those requests so that it could resend them in case of a server
-   crash.
-
-           /*
-            * Remote file service routines
-            */
-           program NFS_PROGRAM {
-                   version NFS_VERSION {
-                           void
-                           NFSPROC_NULL(void)              = 0;
-
-                           attrstat
-                           NFSPROC_GETATTR(fhandle)        = 1;
-
-                           attrstat
-                           NFSPROC_SETATTR(sattrargs)      = 2;
-
-                           void
-                           NFSPROC_ROOT(void)              = 3;
-
-                           diropres
-                           NFSPROC_LOOKUP(diropargs)       = 4;
-
-                           readlinkres
-                           NFSPROC_READLINK(fhandle)       = 5;
-
-                           readres
-                           NFSPROC_READ(readargs)          = 6;
-
-                           void
-                           NFSPROC_WRITECACHE(void)        = 7;
-
-                           attrstat
-                           NFSPROC_WRITE(writeargs)        = 8;
-
-                           diropres
-                           NFSPROC_CREATE(createargs)      = 9;
-
-                           stat
-                           NFSPROC_REMOVE(diropargs)       = 10;
-
-                           stat
-                           NFSPROC_RENAME(renameargs)      = 11;
-
-                           stat
-                           NFSPROC_LINK(linkargs)          = 12;
-
-                           stat
-                           NFSPROC_SYMLINK(symlinkargs)    = 13;
-
-                           diropres
-                           NFSPROC_MKDIR(createargs)       = 14;
-
-                           stat
-                           NFSPROC_RMDIR(diropargs)        = 15;
-
-                           readdirres
-                           NFSPROC_READDIR(readdirargs)    = 16;
-
-                           statfsres
-                           NFSPROC_STATFS(fhandle)         = 17;
-                   } = 2;
-           } = 100003;
-
-2.2.1.  Do Nothing
-
-           void
-           NFSPROC_NULL(void) = 0;
-
-   This procedure does no work.  It is made available in all RPC
-   services to allow server response testing and timing.
-
-2.2.2.  Get File Attributes
-
-           attrstat
-           NFSPROC_GETATTR (fhandle) = 1;
-
-   If the reply status is NFS_OK, then the reply attributes contains the
-   attributes for the file given by the input fhandle.
-
-2.2.3.  Set File Attributes
-
-           struct sattrargs {
-                   fhandle file;
-                   sattr attributes;
-           };
-
-           attrstat
-           NFSPROC_SETATTR (sattrargs) = 2;
-
-   The "attributes" argument contains fields which are either -1 or are
-   the new value for the attributes of "file".  If the reply status is
-   NFS_OK, then the reply attributes have the attributes of the file
-   after the "SETATTR" operation has completed.
-
-   Notes:  The use of -1 to indicate an unused field in "attributes" is
-   changed in the next version of the protocol.
-
-2.2.4.  Get Filesystem Root
-
-           void
-           NFSPROC_ROOT(void) = 3;
-
-   Obsolete.  This procedure is no longer used because finding the root
-   file handle of a filesystem requires moving pathnames between client
-   and server.  To do this right, we would have to define a network
-   standard representation of pathnames.  Instead, the function of
-   looking up the root file handle is done by the MNTPROC_MNT procedure.
-   (See Appendix A, "Mount Protocol Definition", for details).
-
-2.2.5.  Look Up File Name
-
-           diropres
-           NFSPROC_LOOKUP(diropargs) = 4;
-
-   If the reply "status" is NFS_OK, then the reply "file" and reply
-   "attributes" are the file handle and attributes for the file "name"
-   in the directory given by "dir" in the argument.
-
-2.2.6.  Read From Symbolic Link
-
-           union readlinkres switch (stat status) {
-           case NFS_OK:
-               path data;
-           default:
-               void;
-           };
-
-           readlinkres
-           NFSPROC_READLINK(fhandle) = 5;
-
-   If "status" has the value NFS_OK, then the reply "data" is the data
-   in the symbolic link given by the file referred to by the fhandle
-   argument.
-
-   Notes:  Since NFS always parses pathnames on the client, the pathname
-   in a symbolic link may mean something different (or be meaningless)
-   on a different client or on the server if a different pathname syntax
-   is used.
-
-2.2.7.  Read From File
-
-           struct readargs {
-                   fhandle file;
-                   unsigned offset;
-                   unsigned count;
-                   unsigned totalcount;
-           };
-
-           union readres switch (stat status) {
-           case NFS_OK:
-                   fattr attributes;
-                   nfsdata data;
-           default:
-                   void;
-           };
-
-           readres
-           NFSPROC_READ(readargs) = 6;
-
-   Returns up to "count" bytes of "data" from the file given by "file",
-   starting at "offset" bytes from the beginning of the file.  The first
-   byte of the file is at offset zero.  The file attributes after the
-   read takes place are returned in "attributes".
-
-   Notes:  The argument "totalcount" is unused, and is removed in the
-   next protocol revision.
-
-2.2.8.  Write to Cache
-
-           void
-           NFSPROC_WRITECACHE(void) = 7;
-
-   To be used in the next protocol revision.
-
-2.2.9.  Write to File
-
-           struct writeargs {
-                   fhandle file;
-                   unsigned beginoffset;
-                   unsigned offset;
-                   unsigned totalcount;
-                   nfsdata data;
-           };
-
-           attrstat
-           NFSPROC_WRITE(writeargs) = 8;
-
-   Writes "data" beginning "offset" bytes from the beginning of "file".
-   The first byte of the file is at offset zero.  If the reply "status"
-   is NFS_OK, then the reply "attributes" contains the attributes of the
-   file after the write has completed.  The write operation is atomic.
-   Data from this "WRITE" will not be mixed with data from another
-   client's "WRITE".
-
-   Notes:  The arguments "beginoffset" and "totalcount" are ignored and
-   are removed in the next protocol revision.
-
-2.2.10.  Create File
-
-           struct createargs {
-                   diropargs where;
-                   sattr attributes;
-           };
-
-           diropres
-           NFSPROC_CREATE(createargs) = 9;
-
-   The file "name" is created in the directory given by "dir".  The
-   initial attributes of the new file are given by "attributes".  A
-   reply "status" of NFS_OK indicates that the file was created, and
-   reply "file" and reply "attributes" are its file handle and
-   attributes.  Any other reply "status" means that the operation failed
-   and no file was created.
-
-   Notes:  This routine should pass an exclusive create flag, meaning
-   "create the file only if it is not already there".
-
-2.2.11.  Remove File
-
-           stat
-           NFSPROC_REMOVE(diropargs) = 10;
-
-   The file "name" is removed from the directory given by "dir".  A
-   reply of NFS_OK means the directory entry was removed.
-
-   Notes:  possibly non-idempotent operation.
-
-2.2.12.  Rename File
-
-           struct renameargs {
-                   diropargs from;
-                   diropargs to;
-           };
-
-           stat
-           NFSPROC_RENAME(renameargs) = 11;
-
-   The existing file "from.name" in the directory given by "from.dir" is
-   renamed to "to.name" in the directory given by "to.dir".  If the
-   reply is NFS_OK, the file was renamed.  The RENAME operation is
-   atomic on the server; it cannot be interrupted in the middle.
-
-   Notes:  possibly non-idempotent operation.
-
-2.2.13.  Create Link to File
-
-   Procedure 12, Version 2.
-
-           struct linkargs {
-                   fhandle from;
-                   diropargs to;
-           };
-
-           stat
-           NFSPROC_LINK(linkargs) = 12;
-
-   Creates the file "to.name" in the directory given by "to.dir", which
-   is a hard link to the existing file given by "from".  If the return
-   value is NFS_OK, a link was created.  Any other return value
-   indicates an error, and the link was not created.
-
-   A hard link should have the property that changes to either of the
-   linked files are reflected in both files.  When a hard link is made
-   to a file, the attributes for the file should have a value for
-   "nlink" that is one greater than the value before the link.
-
-   Notes:  possibly non-idempotent operation.
-
-2.2.14.  Create Symbolic Link
-
-           struct symlinkargs {
-                   diropargs from;
-                   path to;
-                   sattr attributes;
-           };
-
-           stat
-           NFSPROC_SYMLINK(symlinkargs) = 13;
-
-   Creates the file "from.name" with ftype NFLNK in the directory given
-   by "from.dir".  The new file contains the pathname "to" and has
-   initial attributes given by "attributes".  If the return value is
-   NFS_OK, a link was created.  Any other return value indicates an
-   error, and the link was not created.
-
-   A symbolic link is a pointer to another file.  The name given in "to"
-   is not interpreted by the server, only stored in the newly created
-   file.  When the client references a file that is a symbolic link, the
-   contents of the symbolic link are normally transparently
-   reinterpreted as a pathname to substitute.  A READLINK operation
-   returns the data to the client for interpretation.
-
-   Notes:  On UNIX servers the attributes are never used, since symbolic
-   links always have mode 0777.
-
-2.2.15.  Create Directory
-
-           diropres
-           NFSPROC_MKDIR (createargs) = 14;
-
-   The new directory "where.name" is created in the directory given by
-   "where.dir".  The initial attributes of the new directory are given
-   by "attributes".  A reply "status" of NFS_OK indicates that the new
-   directory was created, and reply "file" and reply "attributes" are
-   its file handle and attributes.  Any other reply "status" means that
-   the operation failed and no directory was created.
-
-   Notes:  possibly non-idempotent operation.
-
-2.2.16.  Remove Directory
-
-           stat
-           NFSPROC_RMDIR(diropargs) = 15;
-
-   The existing empty directory "name" in the directory given by "dir"
-   is removed.  If the reply is NFS_OK, the directory was removed.
-
-   Notes:  possibly non-idempotent operation.
-
-2.2.17.  Read From Directory
-
-           struct readdirargs {
-                   fhandle dir;
-                   nfscookie cookie;
-                   unsigned count;
-           };
-
-           struct entry {
-                   unsigned fileid;
-                   filename name;
-                   nfscookie cookie;
-                   entry *nextentry;
-           };
-
-           union readdirres switch (stat status) {
-           case NFS_OK:
-                   struct {
-                           entry *entries;
-                           bool eof;
-                   } readdirok;
-           default:
-                   void;
-           };
-
-           readdirres
-           NFSPROC_READDIR (readdirargs) = 16;
-
-   Returns a variable number of directory entries, with a total size of
-   up to "count" bytes, from the directory given by "dir".  If the
-   returned value of "status" is NFS_OK, then it is followed by a
-   variable number of "entry"s.  Each "entry" contains a "fileid" which
-   consists of a unique number to identify the file within a filesystem,
-   the "name" of the file, and a "cookie" which is an opaque pointer to
-   the next entry in the directory.  The cookie is used in the next
-   READDIR call to get more entries starting at a given point in the
-   directory.  The special cookie zero (all bits zero) can be used to
-   get the entries starting at the beginning of the directory.  The
-   "fileid" field should be the same number as the "fileid" in the the
-   attributes of the file.  (See section "2.3.5. fattr" under "Basic
-   Data Types".)  The "eof" flag has a value of TRUE if there are no
-   more entries in the directory.
-
-2.2.18.  Get Filesystem Attributes
-
-           union statfsres (stat status) {
-           case NFS_OK:
-               struct {
-                   unsigned tsize;
-                   unsigned bsize;
-                   unsigned blocks;
-                   unsigned bfree;
-                   unsigned bavail;
-               } info;
-           default:
-                   void;
-           };
-
-           statfsres
-           NFSPROC_STATFS(fhandle) = 17;
-
-   If the reply "status" is NFS_OK, then the reply "info" gives the
-   attributes for the filesystem that contains file referred to by the
-   input fhandle.  The attribute fields contain the following values:
-
-      tsize   The optimum transfer size of the server in bytes.  This is
-              the number of bytes the server would like to have in the
-              data part of READ and WRITE requests.
-
-      bsize   The block size in bytes of the filesystem.
-
-      blocks  The total number of "bsize" blocks on the filesystem.
-
-      bfree   The number of free "bsize" blocks on the filesystem.
-
-      bavail  The number of "bsize" blocks available to non-privileged
-              users.
-
-   Notes:  This call does not work well if a filesystem has variable
-   size blocks.
-
-2.3.  Basic Data Types
-
-   The following XDR definitions are basic structures and types used in
-   other structures described further on.
-
-2.3.1.  stat
-
-       enum stat {
-           NFS_OK = 0,
-           NFSERR_PERM=1,
-
-           NFSERR_NOENT=2,
-           NFSERR_IO=5,
-           NFSERR_NXIO=6,
-           NFSERR_ACCES=13,
-           NFSERR_EXIST=17,
-           NFSERR_NODEV=19,
-           NFSERR_NOTDIR=20,
-           NFSERR_ISDIR=21,
-           NFSERR_FBIG=27,
-           NFSERR_NOSPC=28,
-           NFSERR_ROFS=30,
-           NFSERR_NAMETOOLONG=63,
-           NFSERR_NOTEMPTY=66,
-           NFSERR_DQUOT=69,
-           NFSERR_STALE=70,
-           NFSERR_WFLUSH=99
-       };
-
-   The "stat" type is returned with every procedure's results.  A value
-   of NFS_OK indicates that the call completed successfully and the
-   results are valid.  The other values indicate some kind of error
-   occurred on the server side during the servicing of the procedure.
-   The error values are derived from UNIX error numbers.
-
-   NFSERR_PERM
-      Not owner.  The caller does not have correct ownership to perform
-      the requested operation.
-
-   NFSERR_NOENT
-      No such file or directory.  The file or directory specified does
-      not exist.
-
-   NFSERR_IO
-      Some sort of hard error occurred when the operation was in
-      progress.  This could be a disk error, for example.
-
-   NFSERR_NXIO
-      No such device or address.
-
-   NFSERR_ACCES
-      Permission denied.  The caller does not have the correct
-      permission to perform the requested operation.
-
-   NFSERR_EXIST
-      File exists.  The file specified already exists.
-
-   NFSERR_NODEV
-      No such device.
-
-   NFSERR_NOTDIR
-      Not a directory.  The caller specified a non-directory in a
-      directory operation.
-
-   NFSERR_ISDIR
-      Is a directory.  The caller specified a directory in a non-
-      directory operation.
-
-   NFSERR_FBIG
-      File too large.  The operation caused a file to grow beyond the
-      server's limit.
-
-   NFSERR_NOSPC
-      No space left on device.  The operation caused the server's
-      filesystem to reach its limit.
-
-   NFSERR_ROFS
-      Read-only filesystem.  Write attempted on a read-only filesystem.
-
-   NFSERR_NAMETOOLONG
-      File name too long.  The file name in an operation was too long.
-
-   NFSERR_NOTEMPTY
-      Directory not empty.  Attempted to remove a directory that was not
-      empty.
-
-   NFSERR_DQUOT
-      Disk quota exceeded.  The client's disk quota on the server has
-      been exceeded.
-
-   NFSERR_STALE
-      The "fhandle" given in the arguments was invalid.  That is, the
-      file referred to by that file handle no longer exists, or access
-      to it has been revoked.
-
-   NFSERR_WFLUSH
-      The server's write cache used in the "WRITECACHE" call got flushed
-      to disk.
-
-2.3.2.  ftype
-
-          enum ftype {
-              NFNON = 0,
-              NFREG = 1,
-              NFDIR = 2,
-              NFBLK = 3,
-              NFCHR = 4,
-              NFLNK = 5
-          };
-
-      The enumeration "ftype" gives the type of a file.  The type NFNON
-      indicates a non-file, NFREG is a regular file, NFDIR is a
-      directory, NFBLK is a block-special device, NFCHR is a character-
-      special device, and NFLNK is a symbolic link.
-
-2.3.3.  fhandle
-
-          typedef opaque fhandle[FHSIZE];
-
-      The "fhandle" is the file handle passed between the server and the
-      client.  All file operations are done using file handles to refer
-      to a file or directory.  The file handle can contain whatever
-      information the server needs to distinguish an individual file.
-
-2.3.4.  timeval
-
-          struct timeval {
-              unsigned int seconds;
-              unsigned int useconds;
-          };
-
-      The "timeval" structure is the number of seconds and microseconds
-      since midnight January 1, 1970, Greenwich Mean Time.  It is used
-      to pass time and date information.
-
-2.3.5.  fattr
-
-          struct fattr {
-              ftype        type;
-              unsigned int mode;
-              unsigned int nlink;
-              unsigned int uid;
-              unsigned int gid;
-              unsigned int size;
-              unsigned int blocksize;
-              unsigned int rdev;
-              unsigned int blocks;
-
-              unsigned int fsid;
-              unsigned int fileid;
-              timeval      atime;
-              timeval      mtime;
-              timeval      ctime;
-          };
-
-      The "fattr" structure contains the attributes of a file; "type" is
-      the type of the file; "nlink" is the number of hard links to the
-      file (the number of different names for the same file); "uid" is
-      the user identification number of the owner of the file; "gid" is
-      the group identification number of the group of the file; "size"
-      is the size in bytes of the file; "blocksize" is the size in bytes
-      of a block of the file; "rdev" is the device number of the file if
-      it is type NFCHR or NFBLK; "blocks" is the number of blocks the
-      file takes up on disk; "fsid" is the file system identifier for
-      the filesystem containing the file; "fileid" is a number that
-      uniquely identifies the file within its filesystem; "atime" is the
-      time when the file was last accessed for either read or write;
-      "mtime" is the time when the file data was last modified
-      (written); and "ctime" is the time when the status of the file was
-      last changed.  Writing to the file also changes "ctime" if the
-      size of the file changes.
-
-      "Mode" is the access mode encoded as a set of bits.  Notice that
-      the file type is specified both in the mode bits and in the file
-      type.  This is really a bug in the protocol and will be fixed in
-      future versions.  The descriptions given below specify the bit
-      positions using octal numbers.
-
-      0040000 This is a directory; "type" field should be NFDIR.
-      0020000 This is a character special file; "type" field should
-              be NFCHR.
-      0060000 This is a block special file; "type" field should be
-              NFBLK.
-      0100000 This is a regular file; "type" field should be NFREG.
-      0120000 This is a symbolic link file;  "type" field should be
-              NFLNK.
-      0140000 This is a named socket; "type" field should be NFNON.
-      0004000 Set user id on execution.
-      0002000 Set group id on execution.
-      0001000 Save swapped text even after use.
-      0000400 Read permission for owner.
-      0000200 Write permission for owner.
-      0000100 Execute and search permission for owner.
-      0000040 Read permission for group.
-      0000020 Write permission for group.
-      0000010 Execute and search permission for group.
-
-      0000004 Read permission for others.
-      0000002 Write permission for others.
-      0000001 Execute and search permission for others.
-
-      Notes:  The bits are the same as the mode bits returned by the
-      stat(2) system call in UNIX.  The file type is specified both in
-      the mode bits and in the file type.  This is fixed in future
-      versions.
-
-      The "rdev" field in the attributes structure is an operating
-      system specific device specifier.  It will be removed and
-      generalized in the next revision of the protocol.
-
-2.3.6.  sattr
-
-          struct sattr {
-              unsigned int mode;
-              unsigned int uid;
-              unsigned int gid;
-              unsigned int size;
-              timeval      atime;
-              timeval      mtime;
-          };
-
-      The "sattr" structure contains the file attributes which can be
-      set from the client.  The fields are the same as for "fattr"
-      above.  A "size" of zero means the file should be truncated.  A
-      value of -1 indicates a field that should be ignored.
-
-2.3.7.  filename
-
-          typedef string filename<MAXNAMLEN>;
-
-      The type "filename" is used for passing file names or pathname
-      components.
-
-2.3.8.  path
-
-          typedef string path<MAXPATHLEN>;
-
-      The type "path" is a pathname.  The server considers it as a
-      string with no internal structure, but to the client it is the
-      name of a node in a filesystem tree.
-
-2.3.9.  attrstat
-
-          union attrstat switch (stat status) {
-          case NFS_OK:
-
-              fattr attributes;
-          default:
-              void;
-          };
-
-      The "attrstat" structure is a common procedure result.  It
-      contains a "status" and, if the call succeeded, it also contains
-      the attributes of the file on which the operation was done.
-
-2.3.10.  diropargs
-
-          struct diropargs {
-              fhandle  dir;
-              filename name;
-          };
-
-      The "diropargs" structure is used in directory operations.  The
-      "fhandle" "dir" is the directory in which to find the file "name".
-      A directory operation is one in which the directory is affected.
-
-2.3.11.  diropres
-
-          union diropres switch (stat status) {
-          case NFS_OK:
-              struct {
-                  fhandle file;
-                  fattr   attributes;
-              } diropok;
-          default:
-              void;
-          };
-
-      The results of a directory operation are returned in a "diropres"
-      structure.  If the call succeeded, a new file handle "file" and
-      the "attributes" associated with that file are returned along with
-      the "status".
-
-3. NFS IMPLEMENTATION ISSUES
-
-   The NFS protocol was designed to allow different operating systems to
-   share files.  However, since it was designed in a UNIX environment,
-   many operations have semantics similar to the operations of the UNIX
-   file system.  This section discusses some of the implementation-
-   specific details and semantic issues.
-
-3.1.  Server/Client Relationship
-
-   The NFS protocol is designed to allow servers to be as simple and
-
-   general as possible.  Sometimes the simplicity of the server can be a
-   problem, if the client wants to implement complicated filesystem
-   semantics.
-
-   For example, some operating systems allow removal of open files.  A
-   process can open a file and, while it is open, remove it from the
-   directory.  The file can be read and written as long as the process
-   keeps it open, even though the file has no name in the filesystem.
-   It is impossible for a stateless server to implement these semantics.
-   The client can do some tricks such as renaming the file on remove,
-   and only removing it on close.  We believe that the server provides
-   enough functionality to implement most file system semantics on the
-   client.
-
-   Every NFS client can also potentially be a server, and remote and
-   local mounted filesystems can be freely intermixed.  This leads to
-   some interesting problems when a client travels down the directory
-   tree of a remote filesystem and reaches the mount point on the server
-   for another remote filesystem.  Allowing the server to follow the
-   second remote mount would require loop detection, server lookup, and
-   user revalidation.  Instead, we decided not to let clients cross a
-   server's mount point.  When a client does a LOOKUP on a directory on
-   which the server has mounted a filesystem, the client sees the
-   underlying directory instead of the mounted directory.
-
-   For example, if a server has a file system called "/usr" and mounts
-   another file system on  "/usr/src", if a client mounts "/usr", it
-   does NOT see the mounted version of "/usr/src".  A client could do
-   remote mounts that match the server's mount points to maintain the
-   server's view.  In this example, the client would also have to mount
-   "/usr/src" in addition to "/usr", even if they are from the same
-   server.
-
-3.2. Pathname Interpretation
-
-   There are a few complications to the rule that pathnames are always
-   parsed on the client.  For example, symbolic links could have
-   different interpretations on different clients.  Another common
-   problem for non-UNIX implementations is the special interpretation of
-   the pathname ".." to mean the parent of a given directory.  The next
-   revision of the protocol uses an explicit flag to indicate the parent
-   instead.
-
-3.3.  Permission Issues
-
-   The NFS protocol, strictly speaking, does not define the permission
-   checking used by servers.  However, it is expected that a server will
-   do normal operating system permission checking using AUTH_UNIX style
-
-   authentication as the basis of its protection mechanism.  The server
-   gets the client's effective "uid", effective "gid", and groups on
-   each call and uses them to check permission.  There are various
-   problems with this method that can been resolved in interesting ways.
-
-   Using "uid" and "gid" implies that the client and server share the
-   same "uid" list.  Every server and client pair must have the same
-   mapping from user to "uid" and from group to "gid".  Since every
-   client can also be a server, this tends to imply that the whole
-   network shares the same "uid/gid" space.  AUTH_DES (and the next
-   revision of the NFS protocol) uses string names instead of numbers,
-   but there are still complex problems to be solved.
-
-   Another problem arises due to the usually stateful open operation.
-   Most operating systems check permission at open time, and then check
-   that the file is open on each read and write request.  With stateless
-   servers, the server has no idea that the file is open and must do
-   permission checking on each read and write call.  On a local
-   filesystem, a user can open a file and then change the permissions so
-   that no one is allowed to touch it, but will still be able to write
-   to the file because it is open.  On a remote filesystem, by contrast,
-   the write would fail.  To get around this problem, the server's
-   permission checking algorithm should allow the owner of a file to
-   access it regardless of the permission setting.
-
-   A similar problem has to do with paging in from a file over the
-   network.  The operating system usually checks for execute permission
-   before opening a file for demand paging, and then reads blocks from
-   the open file.  The file may not have read permission, but after it
-   is opened it does not matter.  An NFS server can not tell the
-   difference between a normal file read and a demand page-in read.  To
-   make this work, the server allows reading of files if the "uid" given
-   in the call has either execute or read permission on the file.
-
-   In most operating systems, a particular user (on UNIX, the user ID
-   zero) has access to all files no matter what permission and ownership
-   they have.  This "super-user" permission may not be allowed on the
-   server, since anyone who can become super-user on their workstation
-   could gain access to all remote files.  The UNIX server by default
-   maps user id 0 to -2 before doing its access checking.  This works
-   except for NFS root filesystems, where super-user access cannot be
-   avoided.
-
-3.4.  RPC Information
-
-   Authentication
-      The NFS service uses AUTH_UNIX,  AUTH_DES, or AUTH_SHORT style
-      authentication, except in the NULL procedure where AUTH_NONE is
-
-      also allowed.
-
-   Transport Protocols
-      NFS is supported normally on UDP.
-
-   Port Number
-      The NFS protocol currently uses the UDP port number 2049.  This is
-      not an officially assigned port, so later versions of the protocol
-      use the "Portmapping" facility of RPC.
-
-3.5.  Sizes of XDR Structures
-
-   These are the sizes, given in decimal bytes, of various XDR
-   structures used in the protocol:
-
-   /*
-    * The maximum number of bytes of data in a READ or WRITE
-    * request.
-    */
-   const MAXDATA = 8192;
-
-   /* The maximum number of bytes in a pathname argument. */
-   const MAXPATHLEN = 1024;
-
-   /* The maximum number of bytes in a file name argument. */
-   const MAXNAMLEN = 255;
-
-   /* The size in bytes of the opaque "cookie" passed by READDIR. */
-   const COOKIESIZE  = 4;
-
-   /* The size in bytes of the opaque file handle. */
-   const FHSIZE = 32;
-
-3.6. Setting RPC Parameters
-
-   Various file system parameters and options should be set at mount
-   time.  The mount protocol is described in the appendix below.  For
-   example, "Soft" mounts as well as "Hard" mounts are usually both
-   provided.  Soft mounted file systems return errors when RPC
-   operations fail (after a given number of optional retransmissions),
-   while hard mounted file systems continue to retransmit forever.  The
-   maximum transfer sizes are implementation dependent.  For efficient
-   operation over a local network, 8192 bytes of data are normally used.
-   This may result in lower-level fragmentation (such as at the IP
-   level).  Since some network interfaces may not allow such packets,
-   for operation over slower-speed networks or hosts, or through
-   gateways, transfer sizes of 512 or 1024 bytes often provide better
-   results.
-
-   Clients and servers may need to keep caches of recent operations to
-   help avoid problems with non-idempotent operations.  For example, if
-   the transport protocol drops the response for a Remove File
-   operation, upon retransmission the server may return an error code of
-   NFSERR_NOENT instead of NFS_OK.  But if the server keeps around the
-   last operation requested and its result, it could return the proper
-   success code.  Of course, the server could be crashed and rebooted
-   between retransmissions, but a small cache (even a single entry)
-   would solve most problems.
-
-                   Appendix A. MOUNT PROTOCOL DEFINITION
-
-A.1.  Introduction
-
-   The mount protocol is separate from, but related to, the NFS
-   protocol.  It provides operating system specific services to get the
-   NFS off the ground -- looking up server path names, validating user
-   identity, and checking access permissions.  Clients use the mount
-   protocol to get the first file handle, which allows them entry into a
-   remote filesystem.
-
-   The mount protocol is kept separate from the NFS protocol to make it
-   easy to plug in new access checking and validation methods without
-   changing the NFS server protocol.
-
-   Notice that the protocol definition implies stateful servers because
-   the server maintains a list of client's mount requests.  The mount
-   list information is not critical for the correct functioning of
-   either the client or the server.  It is intended for advisory use
-   only, for example, to warn possible clients when a server is going
-   down.
-
-   Version one of the mount protocol is used with version two of the NFS
-   protocol.  The only information communicated between these two
-   protocols is the "fhandle" structure.
-
-A.2.  RPC Information
-
-   Authentication
-      The mount service uses AUTH_UNIX and AUTH_NONE style
-      authentication only.
-
-   Transport Protocols
-      The mount service is supported on both UDP and TCP.
-
-   Port Number
-      Consult the server's portmapper, described in RFC 1057 </rfcs/rfc1057.html>, "RPC:
-      Remote Procedure Call Protocol Specification", to find the port
-      number on which the mount service is registered.
-
-A.3.  Sizes of XDR Structures
-
-   These are the sizes, given in decimal bytes, of various XDR
-   structures used in the protocol:
-
-           /* The maximum number of bytes in a pathname argument. */
-           const MNTPATHLEN = 1024;
-
-           /* The maximum number of bytes in a name argument. */
-           const MNTNAMLEN = 255;
-
-           /* The size in bytes of the opaque file handle. */
-           const FHSIZE = 32;
-
-A.4.  Basic Data Types
-
-   This section presents the data types used by the mount protocol.  In
-   many cases they are similar to the types used in NFS.
-
-A.4.1.  fhandle
-
-       typedef opaque fhandle[FHSIZE];
-
-   The type "fhandle" is the file handle that the server passes to the
-   client.  All file operations are done using file handles to refer to
-   a file or directory.  The file handle can contain whatever
-   information the server needs to distinguish an individual file.
-
-   This is the same as the "fhandle" XDR definition in version 2 of the
-   NFS protocol; see section "2.3.3. fhandle" under "Basic Data Types".
-
-A.4.2.  fhstatus
-
-       union fhstatus switch (unsigned status) {
-       case 0:
-           fhandle directory;
-       default:
-           void;
-       }
-
-   The type "fhstatus" is a union.  If a "status" of zero is returned,
-   the call completed successfully, and a file handle for the
-   "directory" follows.  A non-zero status indicates some sort of error.
-   In this case, the status is a UNIX error number.
-
-A.4.3.  dirpath
-
-       typedef string dirpath<MNTPATHLEN>;
-
-   The type "dirpath" is a server pathname of a directory.
-
-A.4.4.  name
-
-       typedef string name<MNTNAMLEN>;
-
-   The type "name" is an arbitrary string used for various names.
-
-A.5.  Server Procedures
-
-   The following sections define the RPC procedures supplied by a mount
-   server.
-
-           /*
-            * Protocol description for the mount program
-            */
-           program MOUNTPROG {
-                   /*
-                    * Version 1 of the mount protocol used with
-                    * version 2 of the NFS protocol.
-                    */
-                   version MOUNTVERS {
-
-                           void
-                           MOUNTPROC_NULL(void) = 0;
-
-                           fhstatus
-                           MOUNTPROC_MNT(dirpath) = 1;
-
-                           mountlist
-                           MOUNTPROC_DUMP(void) = 2;
-
-                           void
-                           MOUNTPROC_UMNT(dirpath) = 3;
-
-                           void
-                           MOUNTPROC_UMNTALL(void) = 4;
-
-                           exportlist
-                           MOUNTPROC_EXPORT(void)  = 5;
-                   } = 1;
-           } = 100005;
-
-A.5.1.  Do Nothing
-
-           void
-           MNTPROC_NULL(void) = 0;
-
-   This procedure does no work.  It is made available in all RPC
-   services to allow server response testing and timing.
-
-A.5.2.  Add Mount Entry
-
-           fhstatus
-           MNTPROC_MNT(dirpath) = 1;
-
-   If the reply "status" is 0, then the reply "directory" contains the
-   file handle for the directory "dirname".  This file handle may be
-   used in the NFS protocol.  This procedure also adds a new entry to
-   the mount list for this client mounting "dirname".
-
-A.5.3.  Return Mount Entries
-
-           struct *mountlist {
-                   name      hostname;
-                   dirpath   directory;
-                   mountlist nextentry;
-           };
-
-           mountlist
-           MNTPROC_DUMP(void) = 2;
-
-   Returns the list of remote mounted filesystems.  The "mountlist"
-   contains one entry for each "hostname" and "directory" pair.
-
-A.5.4.  Remove Mount Entry
-
-           void
-           MNTPROC_UMNT(dirpath) = 3;
-
-   Removes the mount list entry for the input "dirpath".
-
-A.5.5.  Remove All Mount Entries
-
-           void
-           MNTPROC_UMNTALL(void) = 4;
-
-   Removes all of the mount list entries for this client.
-
-A.5.6.  Return Export List
-
-           struct *groups {
-                   name grname;
-                   groups grnext;
-           };
-
-           struct *exportlist {
-                   dirpath filesys;
-                   groups groups;
-                   exportlist next;
-           };
-
-           exportlist
-           MNTPROC_EXPORT(void) = 5;
-
-   Returns a variable number of export list entries.  Each entry
-   contains a filesystem name and a list of groups that are allowed to
-   import it.  The filesystem name is in "filesys", and the group name
-   is in the list "groups".
-
-   Notes:  The exportlist should contain more information about the
-   status of the filesystem, such as a read-only flag.
-
-Author's Address:
-
-   Bill Nowicki
-   Sun Microsystems, Inc.
-   Mail Stop 1-40
-   2550 Garcia Avenue
-   Mountain View, CA 94043
-
-   Phone: (415) 336-7278
-
-   Email: nowicki@SUN.COM <mailto:nowicki@SUN.COM>
-
-Comment on RFC 1094 </rfccomment.php?rfcnum=1094>
-
- 
-
-Comments about this RFC:
-
-    * RFC 1094: I am preparing for doing a project in File System in
-      Network. can you specify... </qa/rfcc-377.html> by Ravik (12/4/2003)
-
-
-Previous: RFC 1093 - NSFNET routing architecture </rfcs/rfc1093.html>
-
-	 	
-
-Next: RFC 1095 - Common Management Information Services and Protocol
-over TCP/IP (CMOT) </rfcs/rfc1095.html>
-
- 
-
-------------------------------------------------------------------------
Index: rvices/nfsclient/rpcio.c
===================================================================
--- services/nfsclient/rpcio.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,1790 +1,0 @@
-/* RPC multiplexor for a multitasking environment */
-
-/* Author: Till Straumann <strauman@slac.stanford.edu>, 2002 */
-
-/* This code funnels arbitrary task's UDP/RPC requests
- * through one socket to arbitrary servers.
- * The replies are gathered and dispatched to the
- * requestors.
- * One task handles all the sending and receiving
- * work including retries.
- * It is up to the requestor, however, to do
- * the XDR encoding of the arguments / decoding
- * of the results (except for the RPC header which
- * is handled by the daemon).
- */
-
-/*
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
- * 	   Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <inttypes.h>
-
-#include <rtems.h>
-#include <rtems/error.h>
-#include <rtems/rtems_bsdnet.h>
-#include <stdlib.h>
-#include <time.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_prot.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <assert.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "rpcio.h"
-
-/****************************************************************/
-/* CONFIGURABLE PARAMETERS                                      */
-/****************************************************************/
-
-#define MBUF_RX			/* If defined: use mbuf XDR stream for
-						 *  decoding directly out of mbufs
-						 *  Otherwise, the regular 'recvfrom()'
-						 *  interface will be used involving an
-						 *  extra buffer allocation + copy step.
-						 */
-
-#define MBUF_TX			/* If defined: avoid copying data when
-						 *  sending. Instead, use a wrapper to
-						 *  'sosend()' which will point an MBUF
-						 *  directly to our buffer space.
-						 *  Note that the BSD stack does not copy
-						 *  data when fragmenting packets - it
-						 *  merely uses an mbuf chain pointing
-						 *  into different areas of the data.
-						 *
-						 * If undefined, the regular 'sendto()'
-						 *  interface is used.
-						 */
-
-#undef REJECT_SERVERIP_MISMATCH
-						/* If defined, RPC replies must come from the server
-						 * that was queried. Eric Norum has reported problems
-						 * with clustered NFS servers. So we disable this
-						 * reducing paranoia...
-						 */
-
-/* daemon task parameters */
-#define RPCIOD_STACK		10000
-#define RPCIOD_PRIO			100	/* *fallback* priority */
-
-/* depth of the message queue for sending
- * RPC requests to the daemon
- */
-#define RPCIOD_QDEPTH		20
-
-/* Maximum retry limit for retransmission */
-#define RPCIOD_RETX_CAP_S	3 /* seconds */
-
-/* Default timeout for RPC calls */
-#define RPCIOD_DEFAULT_TIMEOUT	(&_rpc_default_timeout)
-static struct timeval _rpc_default_timeout = { 10 /* secs */, 0 /* usecs */ };
-
-/* how many times should we try to resend a failed
- * transaction with refreshed AUTHs
- */
-#define RPCIOD_REFRESH		2
-
-/* Events we are using; the RPC_EVENT
- * MUST NOT be used by any application
- * thread doing RPC IO (e.g. NFS)
- */
-#define RTEMS_RPC_EVENT		RTEMS_EVENT_30	/* THE event used by RPCIO. Every task doing
-											 * RPC IO will receive this - hence it is
-											 * RESERVED
-											 */
-#define RPCIOD_RX_EVENT		RTEMS_EVENT_1	/* Events the RPCIOD is using/waiting for */
-#define RPCIOD_TX_EVENT		RTEMS_EVENT_2
-#define RPCIOD_KILL_EVENT	RTEMS_EVENT_3	/* send to the daemon to kill it          */
-
-#define LD_XACT_HASH		8				/* ld of the size of the transaction hash table  */
-
-
-/* Debugging Flags                                              */
-
-/* NOTE: defining DEBUG 0 leaves some 'assert()' paranoia checks
- *       but produces no output
- */
-
-#define	DEBUG_TRACE_XACT	(1<<0)
-#define DEBUG_EVENTS		(1<<1)
-#define DEBUG_MALLOC		(1<<2)
-#define DEBUG_TIMEOUT		(1<<3)
-#define DEBUG_PACKLOSS		(1<<4)	/* This introduces random, artificial packet losses to test retransmission */
-
-#define DEBUG_PACKLOSS_FRACT (0xffffffff/10)
-
-/* USE PARENTHESIS WHEN 'or'ing MULTIPLE FLAGS: (DEBUG_XX | DEBUG_YY) */
-#define DEBUG				(0)
-
-/****************************************************************/
-/* END OF CONFIGURABLE SECTION                                  */
-/****************************************************************/
-
-/* prevent rollover of our timers by readjusting the epoch on the fly */
-#if	(DEBUG) & DEBUG_TIMEOUT
-#define RPCIOD_EPOCH_SECS	10
-#else
-#define RPCIOD_EPOCH_SECS	10000
-#endif
-
-#ifdef	DEBUG
-#define ASSERT(arg)			assert(arg)
-#else
-#define ASSERT(arg)			if (arg)
-#endif
-
-/****************************************************************/
-/* MACROS                                                       */
-/****************************************************************/
-
-
-#define XACT_HASHS		(1<<(LD_XACT_HASH))	/* the hash table size derived from the ld       */
-#define XACT_HASH_MSK	((XACT_HASHS)-1)	/* mask to extract the hash index from a RPC-XID */
-
-
-#define MU_LOCK(mutex)		do { 							\
-							assert(							\
-								RTEMS_SUCCESSFUL ==			\
-								rtems_semaphore_obtain(		\
-										(mutex),			\
-										RTEMS_WAIT,			\
-										RTEMS_NO_TIMEOUT	\
-										) );				\
-							} while(0)
-
-#define MU_UNLOCK(mutex)	do {							\
-							assert(							\
-								RTEMS_SUCCESSFUL ==			\
-								rtems_semaphore_release(	\
-										(mutex)				\
-										) );				\
-							} while(0)
-
-#define MU_CREAT(pmutex)	do {							\
-							assert(							\
-								RTEMS_SUCCESSFUL ==			\
-								rtems_semaphore_create(		\
-										rtems_build_name(	\
-											'R','P','C','l'	\
-											),				\
-										1,					\
-										MUTEX_ATTRIBUTES,	\
-										0,					\
-										(pmutex)) );		\
-							} while (0)
-
-
-#define MU_DESTROY(mutex)	do {							\
-							assert(							\
-								RTEMS_SUCCESSFUL ==			\
-								rtems_semaphore_delete(		\
-										mutex				\
-										) );				\
-							} while (0)
-
-#define MUTEX_ATTRIBUTES	(RTEMS_LOCAL           | 		\
-			   				RTEMS_PRIORITY         | 		\
-			   				RTEMS_INHERIT_PRIORITY | 		\
-						   	RTEMS_BINARY_SEMAPHORE)
-
-#define FIRST_ATTEMPT		0x88888888 /* some time that is never reached */
-
-/****************************************************************/
-/* TYPE DEFINITIONS                                             */
-/****************************************************************/
-
-typedef	rtems_interval		TimeoutT;
-
-/* 100000th implementation of a doubly linked list;
- * since only one thread is looking at these,
- * we need no locking
- */
-typedef struct ListNodeRec_ {
-	struct ListNodeRec_ *next, *prev;
-} ListNodeRec, *ListNode;
-
-
-/* Structure representing an RPC server */
-typedef struct RpcUdpServerRec_ {
-		RpcUdpServer		next;			/* linked list of all servers; protected by hlock */
-		union {
-		struct sockaddr_in	sin;
-		struct sockaddr     sa;
-		}					addr;
-		AUTH				*auth;
-		rtems_id			authlock;		/* must MUTEX the auth object - it's not clear
-											 *  what is better:
-											 *   1 having one (MUTEXed) auth per server
-											 *	   who is shared among all transactions
-											 *	   using that server
-											 *	 2 maintaining an AUTH per transaction
-											 *	   (there are then other options: manage
-											 *	   XACT pools on a per-server basis instead
-											 *	   of associating a server with a XACT when
-											 *   sending)
-											 * experience will show if the current (1)
-											 * approach has to be changed.
-											 */
-		TimeoutT			retry_period;	/* dynamically adjusted retry period
-											 * (based on packet roundtrip time)
-											 */
-		/* STATISTICS */
-		unsigned long		retrans;		/* how many retries were issued by this server         */
-		unsigned long		requests;		/* how many requests have been sent                    */
-		unsigned long       timeouts;		/* how many requests have timed out                    */
-		unsigned long       errors;         /* how many errors have occurred (other than timeouts) */
-		char				name[20];		/* server's address in IP 'dot' notation               */
-} RpcUdpServerRec;
-
-typedef union  RpcBufU_ {
-		uint32_t			xid;
-		char				buf[1];
-} RpcBufU, *RpcBuf;
-
-/* RX Buffer implementation; this is either
- * an MBUF chain (MBUF_RX configuration)
- * or a buffer allocated from the heap
- * where recvfrom copies the (encoded) reply
- * to. The XDR routines the copy/decode
- * it into the user's data structures.
- */
-#ifdef MBUF_RX
-typedef	struct mbuf *		RxBuf;	/* an MBUF chain */
-static  void   				bufFree(struct mbuf **m);
-#define XID(ibuf) 			(*(mtod((ibuf), u_long *)))
-extern void 				xdrmbuf_create(XDR *, struct mbuf *, enum xdr_op);
-#else
-typedef RpcBuf				RxBuf;
-#define	bufFree(b)			do { MY_FREE(*(b)); *(b)=0; } while(0)
-#define XID(ibuf) 			((ibuf)->xid)
-#endif
-
-/* A RPC 'transaction' consisting
- * of server and requestor information,
- * buffer space and an XDR object
- * (for encoding arguments).
- */
-typedef struct RpcUdpXactRec_ {
-		ListNodeRec			node;		/* so we can put XACTs on a list                */
-		RpcUdpServer		server;		/* server this XACT goes to                     */
-		long				lifetime;	/* during the lifetime, retry attempts are made */
-		long				tolive;		/* lifetime timer                               */
-		struct rpc_err		status;		/* RPC reply error status                       */
-		long				age;		/* age info; needed to manage retransmission    */
-		long				trip;		/* record round trip time in ticks              */
-		rtems_id			requestor;	/* the task waiting for this XACT to complete   */
-		RpcUdpXactPool		pool;		/* if this XACT belong to a pool, this is it    */
-		XDR					xdrs;		/* argument encoder stream                      */
-		int					xdrpos;     /* stream position after the (permanent) header */
-		xdrproc_t			xres;		/* reply decoder proc - TODO needn't be here    */
-		caddr_t				pres;		/* reply decoded obj  - TODO needn't be here    */
-#ifndef MBUF_RX
-		int					ibufsize;	/* size of the ibuf (bytes)                     */
-#endif
-#ifdef  MBUF_TX
-		int					refcnt;		/* mbuf external storage reference count        */
-#endif
-		int					obufsize;	/* size of the obuf (bytes)                     */
-		RxBuf				ibuf;		/* pointer to input buffer assigned by daemon   */
-		RpcBufU				obuf;       /* output buffer (encoded args) APPENDED HERE   */
-} RpcUdpXactRec;
-
-typedef struct RpcUdpXactPoolRec_ {
-	rtems_id	box;
-	int			prog;
-	int			version;
-	int			xactSize;
-} RpcUdpXactPoolRec;
-
-/* a global hash table where all 'living' transaction
- * objects are registered.
- * A number of bits in a transaction's XID maps 1:1 to
- * an index in this table. Hence, the XACT matching
- * an RPC/UDP reply packet can quickly be found
- * The size of this table imposes a hard limit on the
- * number of all created transactions in the system.
- */
-static RpcUdpXact xactHashTbl[XACT_HASHS]={0};
-static u_long     xidUpper   [XACT_HASHS]={0};
-static unsigned   xidHashSeed            = 0 ;
-
-/* forward declarations */
-static RpcUdpXact
-sockRcv(void);
-
-static void
-rpcio_daemon(rtems_task_argument);
-
-#ifdef MBUF_TX
-ssize_t
-sendto_nocpy (
-		int s,
-		const void *buf, size_t buflen,
-		int flags,
-		const struct sockaddr *toaddr, int tolen,
-		void *closure,
-		void (*freeproc)(caddr_t, u_int),
-		void (*refproc)(caddr_t, u_int)
-);
-static void paranoia_free(caddr_t closure, u_int size);
-static void paranoia_ref (caddr_t closure, u_int size);
-#define SENDTO	sendto_nocpy
-#else
-#define SENDTO	sendto
-#endif
-
-static RpcUdpServer		rpcUdpServers = 0;	/* linked list of all servers; protected by llock */
-
-static int				ourSock = -1;		/* the socket we are using for communication */
-static rtems_id			rpciod  = 0;		/* task id of the RPC daemon                 */
-static rtems_id			msgQ    = 0;		/* message queue where the daemon picks up
-											 * requests
-											 */
-#ifndef NDEBUG
-static rtems_id			llock	= 0;		/* MUTEX protecting the server list */
-static rtems_id			hlock	= 0;		/* MUTEX protecting the hash table and the list of servers */
-#endif
-static rtems_id			fini	= 0;		/* a synchronization semaphore we use during
-											 * module cleanup / driver unloading
-											 */
-static rtems_interval	ticksPerSec;		/* cached system clock rate (WHO IS ASSUMED NOT
-											 * TO CHANGE)
-											 */
-
-rtems_task_priority		rpciodPriority = 0;
-
-#if (DEBUG) & DEBUG_MALLOC
-/* malloc wrappers for debugging */
-static int nibufs = 0;
-
-static inline void *MY_MALLOC(int s)
-{
-	if (s) {
-		void *rval;
-		MU_LOCK(hlock);
-		assert(nibufs++ < 2000);
-		MU_UNLOCK(hlock);
-		assert((rval = malloc(s)) != 0);
-		return rval;
-	}
-	return 0;
-}
-
-static inline void *MY_CALLOC(int n, int s)
-{
-	if (s) {
-		void *rval;
-		MU_LOCK(hlock);
-		assert(nibufs++ < 2000);
-		MU_UNLOCK(hlock);
-		assert((rval = calloc(n,s)) != 0);
-		return rval;
-	}
-	return 0;
-}
-
-
-static inline void MY_FREE(void *p)
-{
-	if (p) {
-		MU_LOCK(hlock);
-		nibufs--;
-		MU_UNLOCK(hlock);
-		free(p);
-	}
-}
-#else
-#define MY_MALLOC	malloc
-#define MY_CALLOC	calloc
-#define MY_FREE		free
-#endif
-
-static inline bool_t
-locked_marshal(RpcUdpServer s, XDR *xdrs)
-{
-bool_t rval;
-	MU_LOCK(s->authlock);
-	rval = AUTH_MARSHALL(s->auth, xdrs);
-	MU_UNLOCK(s->authlock);
-	return rval;
-}
-
-/* Locked operations on a server's auth object */
-static inline bool_t
-locked_validate(RpcUdpServer s, struct opaque_auth *v)
-{
-bool_t rval;
-	MU_LOCK(s->authlock);
-	rval = AUTH_VALIDATE(s->auth, v);
-	MU_UNLOCK(s->authlock);
-	return rval;
-}
-
-static inline bool_t
-locked_refresh(RpcUdpServer s)
-{
-bool_t rval;
-	MU_LOCK(s->authlock);
-	rval = AUTH_REFRESH(s->auth);
-	MU_UNLOCK(s->authlock);
-	return rval;
-}
-
-/* Create a server object
- *
- */
-enum clnt_stat
-rpcUdpServerCreate(
-	struct sockaddr_in	*paddr,
-	rpcprog_t		prog,
-	rpcvers_t		vers,
-	u_long			uid,
-	u_long			gid,
-	RpcUdpServer		*psrv
-	)
-{
-RpcUdpServer	rval;
-u_short			port;
-char			hname[MAX_MACHINE_NAME + 1];
-int				theuid, thegid;
-int				thegids[NGRPS];
-gid_t			gids[NGROUPS];
-int				len,i;
-AUTH			*auth;
-enum clnt_stat	pmap_err;
-struct pmap		pmaparg;
-
-	if ( gethostname(hname, MAX_MACHINE_NAME) ) {
-		fprintf(stderr,
-				"RPCIO - error: I have no hostname ?? (%s)\n",
-				strerror(errno));
-		return RPC_UNKNOWNHOST;
-	}
-
-	if ( (len = getgroups(NGROUPS, gids) < 0 ) ) {
-		fprintf(stderr,
-				"RPCIO - error: I unable to get group ids (%s)\n",
-				strerror(errno));
-		return RPC_FAILED;
-	}
-
-	if ( len > NGRPS )
-		len = NGRPS;
-
-	for (i=0; i<len; i++)
-		thegids[i] = (int)gids[i];
-
-	theuid = (int) ((RPCIOD_DEFAULT_ID == uid) ? geteuid() : uid);
-	thegid = (int) ((RPCIOD_DEFAULT_ID == gid) ? getegid() : gid);
-
-	if ( !(auth = authunix_create(hname, theuid, thegid, len, thegids)) ) {
-		fprintf(stderr,
-				"RPCIO - error: unable to create RPC AUTH\n");
-		return RPC_FAILED;
-	}
-
-	/* if they specified no port try to ask the portmapper */
-	if (!paddr->sin_port) {
-
-		paddr->sin_port = htons(PMAPPORT);
-
-        pmaparg.pm_prog = prog;
-        pmaparg.pm_vers = vers;
-        pmaparg.pm_prot = IPPROTO_UDP;
-        pmaparg.pm_port = 0;  /* not needed or used */
-
-
-		/* dont use non-reentrant pmap_getport ! */
-
-		pmap_err = rpcUdpCallRp(
-						paddr,
-						PMAPPROG,
-						PMAPVERS,
-						PMAPPROC_GETPORT,
-						xdr_pmap,
-						&pmaparg,
-						xdr_u_short,
-						&port,
-						uid,
-						gid,
-						0);
-
-		if ( RPC_SUCCESS != pmap_err ) {
-			paddr->sin_port = 0;
-			return pmap_err;
-		}
-
-		paddr->sin_port = htons(port);
-	}
-
-	if (0==paddr->sin_port) {
-			return RPC_PROGNOTREGISTERED;
-	}
-
-	rval       			= (RpcUdpServer)MY_MALLOC(sizeof(*rval));
-	memset(rval, 0, sizeof(*rval));
-
-	if (!inet_ntop(AF_INET, &paddr->sin_addr, rval->name, sizeof(rval->name)))
-		sprintf(rval->name,"?.?.?.?");
-	rval->addr.sin		= *paddr;
-
-	/* start with a long retransmission interval - it
-	 * will be adapted dynamically
-	 */
-	rval->retry_period  = RPCIOD_RETX_CAP_S * ticksPerSec;
-
-	rval->auth 			= auth;
-
-	MU_CREAT( &rval->authlock );
-
-	/* link into list */
-	MU_LOCK( llock );
-	rval->next = rpcUdpServers;
-	rpcUdpServers = rval;
-	MU_UNLOCK( llock );
-
-	*psrv				= rval;
-	return RPC_SUCCESS;
-}
-
-void
-rpcUdpServerDestroy(RpcUdpServer s)
-{
-RpcUdpServer prev;
-	if (!s)
-		return;
-	/* we should probably verify (but how?) that nobody
-	 * (at least: no outstanding XACTs) is using this
-	 * server;
-	 */
-
-	/* remove from server list */
-	MU_LOCK(llock);
-	prev = rpcUdpServers;
-	if ( s == prev ) {
-		rpcUdpServers = s->next;
-	} else {
-		for ( ; prev ; prev = prev->next) {
-			if (prev->next == s) {
-				prev->next = s->next;
-				break;
-			}
-		}
-	}
-	MU_UNLOCK(llock);
-
-	/* MUST have found it */
-	assert(prev);
-
-	auth_destroy(s->auth);
-
-	MU_DESTROY(s->authlock);
-	MY_FREE(s);
-}
-
-int
-rpcUdpStats(FILE *f)
-{
-RpcUdpServer s;
-
-	if (!f) f = stdout;
-
-	fprintf(f,"RPCIOD statistics:\n");
-
-	MU_LOCK(llock);
-	for (s = rpcUdpServers; s; s=s->next) {
-		fprintf(f,"\nServer -- %s:\n", s->name);
-		fprintf(f,"  requests    sent: %10ld, retransmitted: %10ld\n",
-						s->requests, s->retrans);
-		fprintf(f,"         timed out: %10ld,   send errors: %10ld\n",
-						s->timeouts, s->errors);
-		fprintf(f,"  current retransmission interval: %dms\n",
-						(unsigned)(s->retry_period * 1000 / ticksPerSec) );
-	}
-	MU_UNLOCK(llock);
-
-	return 0;
-}
-
-RpcUdpXact
-rpcUdpXactCreate(
-	u_long	program,
-	u_long	version,
-	u_long	size
-	)
-{
-RpcUdpXact		rval=0;
-struct rpc_msg	header;
-register int	i,j;
-
-	if (!size)
-		size = UDPMSGSIZE;
-	/* word align */
-	size = (size + 3) & ~3;
-
-	rval = (RpcUdpXact)MY_CALLOC(1,sizeof(*rval) - sizeof(rval->obuf) + size);
-
-	if (rval) {
-
-		header.rm_xid             = 0;
-		header.rm_direction       = CALL;
-		header.rm_call.cb_rpcvers = RPC_MSG_VERSION;
-		header.rm_call.cb_prog    = program;
-		header.rm_call.cb_vers    = version;
-		xdrmem_create(&(rval->xdrs), rval->obuf.buf, size, XDR_ENCODE);
-
-		if (!xdr_callhdr(&(rval->xdrs), &header)) {
-			MY_FREE(rval);
-			return 0;
-		}
-		/* pick a free table slot and initialize the XID */
-		rval->obuf.xid = time(0) ^ (uintptr_t)rval;
-		MU_LOCK(hlock);
-		rval->obuf.xid = (xidHashSeed++ ^ ((uintptr_t)rval>>10)) & XACT_HASH_MSK;
-		i=j=(rval->obuf.xid & XACT_HASH_MSK);
-		if (msgQ) {
-			/* if there's no message queue, refuse to
-			 * give them transactions; we might be in the process to
-			 * go away...
-			 */
-			do {
-				i=(i+1) & XACT_HASH_MSK; /* cheap modulo */
-				if (!xactHashTbl[i]) {
-#if (DEBUG) & DEBUG_TRACE_XACT
-					fprintf(stderr,"RPCIO: entering index %i, val %x\n",i,rval);
-#endif
-					xactHashTbl[i]=rval;
-					j=-1;
-					break;
-				}
-			} while (i!=j);
-		}
-		MU_UNLOCK(hlock);
-		if (i==j) {
-			XDR_DESTROY(&rval->xdrs);
-			MY_FREE(rval);
-			return 0;
-		}
-		rval->obuf.xid  = xidUpper[i] | i;
-		rval->xdrpos    = XDR_GETPOS(&(rval->xdrs));
-		rval->obufsize  = size;
-	}
-	return rval;
-}
-
-void
-rpcUdpXactDestroy(RpcUdpXact xact)
-{
-int i = xact->obuf.xid & XACT_HASH_MSK;
-
-#if (DEBUG) & DEBUG_TRACE_XACT
-		fprintf(stderr,"RPCIO: removing index %i, val %x\n",i,xact);
-#endif
-
-		ASSERT( xactHashTbl[i]==xact );
-
-		MU_LOCK(hlock);
-		xactHashTbl[i]=0;
-		/* remember XID we used last time so we can avoid
-		 * reusing the same one (incremented by rpcUdpSend routine)
-		 */
-		xidUpper[i]   = xact->obuf.xid & ~XACT_HASH_MSK;
-		MU_UNLOCK(hlock);
-
-		bufFree(&xact->ibuf);
-
-		XDR_DESTROY(&xact->xdrs);
-		MY_FREE(xact);
-}
-
-
-
-/* Send a transaction, i.e. enqueue it to the
- * RPC daemon who will actually send it.
- */
-enum clnt_stat
-rpcUdpSend(
-	RpcUdpXact		xact,
-	RpcUdpServer	srvr,
-	struct timeval	*timeout,
-	u_long			proc,
-	xdrproc_t		xres, caddr_t pres,
-	xdrproc_t		xargs, caddr_t pargs,
-	...
-   )
-{
-register XDR	*xdrs;
-unsigned long	ms;
-va_list			ap;
-
-	va_start(ap,pargs);
-
-	if (!timeout)
-		timeout = RPCIOD_DEFAULT_TIMEOUT;
-
-	ms = 1000 * timeout->tv_sec + timeout->tv_usec/1000;
-
-	/* round lifetime to closest # of ticks */
-	xact->lifetime  = (ms * ticksPerSec + 500) / 1000;
-	if ( 0 == xact->lifetime )
-		xact->lifetime = 1;
-
-#if (DEBUG) & DEBUG_TIMEOUT
-	{
-	static int once=0;
-	if (!once++) {
-		fprintf(stderr,
-				"Initial lifetime: %i (ticks)\n",
-				xact->lifetime);
-	}
-	}
-#endif
-
-	xact->tolive    = xact->lifetime;
-
-	xact->xres      = xres;
-	xact->pres      = pres;
-	xact->server    = srvr;
-
-	xdrs            = &xact->xdrs;
-	xdrs->x_op      = XDR_ENCODE;
-	/* increment transaction ID */
-	xact->obuf.xid += XACT_HASHS;
-	XDR_SETPOS(xdrs, xact->xdrpos);
-	if ( !XDR_PUTLONG(xdrs,(long*)&proc) || !locked_marshal(srvr, xdrs) ||
-		 !xargs(xdrs, pargs) ) {
-		va_end(ap);
-		return(xact->status.re_status=RPC_CANTENCODEARGS);
-	}
-	while ((xargs=va_arg(ap,xdrproc_t))) {
-		if (!xargs(xdrs, va_arg(ap,caddr_t)))
-		va_end(ap);
-		return(xact->status.re_status=RPC_CANTENCODEARGS);
-	}
-
-	va_end(ap);
-
-	rtems_task_ident(RTEMS_SELF, RTEMS_WHO_AM_I, &xact->requestor);
-	if ( rtems_message_queue_send( msgQ, &xact, sizeof(xact)) ) {
-		return RPC_CANTSEND;
-	}
-	/* wakeup the rpciod */
-	ASSERT( RTEMS_SUCCESSFUL==rtems_event_send(rpciod, RPCIOD_TX_EVENT) );
-
-	return RPC_SUCCESS;
-}
-
-/* Block for the RPC reply to an outstanding
- * transaction.
- * The caller is woken by the RPC daemon either
- * upon reception of the reply or on timeout.
- */
-enum clnt_stat
-rpcUdpRcv(RpcUdpXact xact)
-{
-int					refresh;
-XDR			reply_xdrs;
-struct rpc_msg		reply_msg;
-rtems_status_code	status;
-rtems_event_set		gotEvents;
-
-	refresh = 0;
-
-	do {
-
-	/* block for the reply */
-	status = rtems_event_receive(
-		RTEMS_RPC_EVENT,
-		RTEMS_WAIT | RTEMS_EVENT_ANY,
-		RTEMS_NO_TIMEOUT,
-		&gotEvents);
-	ASSERT( status == RTEMS_SUCCESSFUL );
-
-	if (xact->status.re_status) {
-#ifdef MBUF_RX
-		/* add paranoia */
-		ASSERT( !xact->ibuf );
-#endif
-		return xact->status.re_status;
-	}
-
-#ifdef MBUF_RX
-	xdrmbuf_create(&reply_xdrs, xact->ibuf, XDR_DECODE);
-#else
-	xdrmem_create(&reply_xdrs, xact->ibuf->buf, xact->ibufsize, XDR_DECODE);
-#endif
-
-	reply_msg.acpted_rply.ar_verf          = _null_auth;
-	reply_msg.acpted_rply.ar_results.where = xact->pres;
-	reply_msg.acpted_rply.ar_results.proc  = xact->xres;
-
-	if (xdr_replymsg(&reply_xdrs, &reply_msg)) {
-		/* OK */
-		_seterr_reply(&reply_msg, &xact->status);
-		if (RPC_SUCCESS == xact->status.re_status) {
-			if ( !locked_validate(xact->server,
-								&reply_msg.acpted_rply.ar_verf) ) {
-				xact->status.re_status = RPC_AUTHERROR;
-				xact->status.re_why    = AUTH_INVALIDRESP;
-			}
-			if (reply_msg.acpted_rply.ar_verf.oa_base) {
-				reply_xdrs.x_op = XDR_FREE;
-				xdr_opaque_auth(&reply_xdrs, &reply_msg.acpted_rply.ar_verf);
-			}
-			refresh = 0;
-		} else {
-			/* should we try to refresh our credentials ? */
-			if ( !refresh ) {
-				/* had never tried before */
-				refresh = RPCIOD_REFRESH;
-			}
-		}
-	} else {
-		reply_xdrs.x_op        = XDR_FREE;
-		xdr_replymsg(&reply_xdrs, &reply_msg);
-		xact->status.re_status = RPC_CANTDECODERES;
-	}
-	XDR_DESTROY(&reply_xdrs);
-
-	bufFree(&xact->ibuf);
-
-#ifndef MBUF_RX
-	xact->ibufsize = 0;
-#endif
-
-	if (refresh && locked_refresh(xact->server)) {
-		rtems_task_ident(RTEMS_SELF, RTEMS_WHO_AM_I, &xact->requestor);
-		if ( rtems_message_queue_send(msgQ, &xact, sizeof(xact)) ) {
-			return RPC_CANTSEND;
-		}
-		/* wakeup the rpciod */
-		fprintf(stderr,"RPCIO INFO: refreshing my AUTH\n");
-		ASSERT( RTEMS_SUCCESSFUL==rtems_event_send(rpciod, RPCIOD_TX_EVENT) );
-	}
-
-	} while ( 0 &&  refresh-- > 0 );
-
-	return xact->status.re_status;
-}
-
-
-/* On RTEMS, I'm told to avoid select(); this seems to
- * be more efficient
- */
-static void
-rxWakeupCB(struct socket *sock, void *arg)
-{
-  rtems_id *rpciod = (rtems_id*) arg;
-  rtems_event_send(*rpciod, RPCIOD_RX_EVENT);
-}
-
-int
-rpcUdpInit(void)
-{
-int			s;
-rtems_status_code	status;
-int			noblock = 1;
-struct sockwakeup	wkup;
-
-	if (ourSock < 0) {
-    fprintf(stderr,"RTEMS-RPCIOD $Release$, " \
-            "Till Straumann, Stanford/SLAC/SSRL 2002, " \
-            "See LICENSE file for licensing info.\n");
-
-		ourSock=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-		if (ourSock>=0) {
-			bindresvport(ourSock,(struct sockaddr_in*)0);
-			s = ioctl(ourSock, FIONBIO, (char*)&noblock);
-			assert( s == 0 );
-			/* assume nobody tampers with the clock !! */
-			ticksPerSec = rtems_clock_get_ticks_per_second();
-			MU_CREAT( &hlock );
-			MU_CREAT( &llock );
-
-			if ( !rpciodPriority ) {
-				/* use configured networking priority */
-				if ( ! (rpciodPriority = rtems_bsdnet_config.network_task_priority) )
-					rpciodPriority = RPCIOD_PRIO;	/* fallback value */
-			}
-
-			status = rtems_task_create(
-											rtems_build_name('R','P','C','d'),
-											rpciodPriority,
-											RPCIOD_STACK,
-											RTEMS_DEFAULT_MODES,
-											/* fprintf saves/restores FP registers on PPC :-( */
-											RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT,
-											&rpciod);
-			assert( status == RTEMS_SUCCESSFUL );
-
-			wkup.sw_pfn = rxWakeupCB;
-			wkup.sw_arg = &rpciod;
-			assert( 0==setsockopt(ourSock, SOL_SOCKET, SO_RCVWAKEUP, &wkup, sizeof(wkup)) );
-			status = rtems_message_queue_create(
-											rtems_build_name('R','P','C','q'),
-											RPCIOD_QDEPTH,
-											sizeof(RpcUdpXact),
-											RTEMS_DEFAULT_ATTRIBUTES,
-											&msgQ);
-			assert( status == RTEMS_SUCCESSFUL );
-			status = rtems_task_start( rpciod, rpcio_daemon, 0 );
-			assert( status == RTEMS_SUCCESSFUL );
-
-		} else {
-			return -1;
-		}
-	}
-	return 0;
-}
-
-int
-rpcUdpCleanup(void)
-{
-	rtems_semaphore_create(
-			rtems_build_name('R','P','C','f'),
-			0,
-			RTEMS_DEFAULT_ATTRIBUTES,
-			0,
-			&fini);
-	rtems_event_send(rpciod, RPCIOD_KILL_EVENT);
-	/* synchronize with daemon */
-	rtems_semaphore_obtain(fini, RTEMS_WAIT, 5*ticksPerSec);
-	/* if the message queue is still there, something went wrong */
-	if (!msgQ) {
-		rtems_task_delete(rpciod);
-	}
-	rtems_semaphore_delete(fini);
-	return (msgQ !=0);
-}
-
-/* Another API - simpler but less efficient.
- * For each RPCall, a server and a Xact
- * are created and destroyed on the fly.
- *
- * This should be used for infrequent calls
- * (e.g. a NFS mount request).
- *
- * This is roughly compatible with the original
- * clnt_call() etc. API - but it uses our
- * daemon and is fully reentrant.
- */
-enum clnt_stat
-rpcUdpClntCreate(
-		struct sockaddr_in	*psaddr,
-		rpcprog_t		prog,
-		rpcvers_t		vers,
-		u_long			uid,
-		u_long			gid,
-		RpcUdpClnt		*pclnt
-)
-{
-RpcUdpXact		x;
-RpcUdpServer	s;
-enum clnt_stat	err;
-
-	if ( RPC_SUCCESS != (err=rpcUdpServerCreate(psaddr, prog, vers, uid, gid, &s)) )
-		return err;
-
-	if ( !(x=rpcUdpXactCreate(prog, vers, UDPMSGSIZE)) ) {
-		rpcUdpServerDestroy(s);
-		return RPC_FAILED;
-	}
-	/* TODO: could maintain a server cache */
-
-	x->server = s;
-
-	*pclnt = x;
-
-	return RPC_SUCCESS;
-}
-
-void
-rpcUdpClntDestroy(RpcUdpClnt xact)
-{
-	rpcUdpServerDestroy(xact->server);
-	rpcUdpXactDestroy(xact);
-}
-
-enum clnt_stat
-rpcUdpClntCall(
-	RpcUdpClnt		xact,
-	u_long			proc,
-	XdrProcT		xargs,
-	CaddrT			pargs,
-	XdrProcT		xres,
-	CaddrT			pres,
-	struct timeval	*timeout
-	)
-{
-enum clnt_stat	stat;
-
-		if ( (stat = rpcUdpSend(xact, xact->server, timeout, proc,
-								xres, pres,
-								xargs, pargs,
-								0)) ) {
-			fprintf(stderr,"RPCIO Send failed: %i\n",stat);
-			return stat;
-		}
-		return rpcUdpRcv(xact);
-}
-
-/* a yet simpler interface */
-enum clnt_stat
-rpcUdpCallRp(
-	struct sockaddr_in	*psrvr,
-	u_long				prog,
-	u_long				vers,
-	u_long				proc,
-	XdrProcT			xargs,
-	CaddrT				pargs,
-	XdrProcT			xres,
-	CaddrT				pres,
-	u_long				uid,		/* RPCIO_DEFAULT_ID picks default */
-	u_long				gid,		/* RPCIO_DEFAULT_ID picks default */
-	struct timeval		*timeout	/* NULL picks default		*/
-)
-{
-RpcUdpClnt			clp;
-enum clnt_stat		stat;
-
-	stat = rpcUdpClntCreate(
-				psrvr,
-				prog,
-				vers,
-				uid,
-				gid,
-				&clp);
-
-	if ( RPC_SUCCESS != stat )
-		return stat;
-
-	stat = rpcUdpClntCall(
-				clp,
-				proc,
-				xargs, pargs,
-				xres,  pres,
-				timeout);
-
-	rpcUdpClntDestroy(clp);
-
-	return stat;
-}
-
-/* linked list primitives */
-static void
-nodeXtract(ListNode n)
-{
-	if (n->prev)
-		n->prev->next = n->next;
-	if (n->next)
-		n->next->prev = n->prev;
-	n->next = n->prev = 0;
-}
-
-static void
-nodeAppend(ListNode l, ListNode n)
-{
-	if ( (n->next = l->next) )
-		n->next->prev = n;
-	l->next = n;
-	n->prev = l;
-
-}
-
-/* this code does the work */
-static void
-rpcio_daemon(rtems_task_argument arg)
-{
-rtems_status_code stat;
-RpcUdpXact        xact;
-RpcUdpServer      srv;
-rtems_interval    next_retrans, then, unow;
-long			  			now;	/* need to do signed comparison with age! */
-rtems_event_set   events;
-ListNode          newList;
-size_t            size;
-rtems_id          q          =  0;
-ListNodeRec       listHead   = {0, 0};
-unsigned long     epoch      = RPCIOD_EPOCH_SECS * ticksPerSec;
-unsigned long			max_period = RPCIOD_RETX_CAP_S * ticksPerSec;
-rtems_status_code	status;
-
-
-        then = rtems_clock_get_ticks_since_boot();
-
-	for (next_retrans = epoch;;) {
-
-		if ( RTEMS_SUCCESSFUL !=
-			 (stat = rtems_event_receive(
-						RPCIOD_RX_EVENT | RPCIOD_TX_EVENT | RPCIOD_KILL_EVENT,
-						RTEMS_WAIT | RTEMS_EVENT_ANY,
-						next_retrans,
-						&events)) ) {
-			ASSERT( RTEMS_TIMEOUT == stat );
-			events = 0;
-		}
-
-		if (events & RPCIOD_KILL_EVENT) {
-			int i;
-
-#if (DEBUG) & DEBUG_EVENTS
-			fprintf(stderr,"RPCIO: got KILL event\n");
-#endif
-
-			MU_LOCK(hlock);
-			for (i=XACT_HASHS-1; i>=0; i--) {
-				if (xactHashTbl[i]) {
-					break;
-				}
-			}
-			if (i<0) {
-				/* prevent them from creating and enqueueing more messages */
-				q=msgQ;
-				/* messages queued after we executed this assignment will fail */
-				msgQ=0;
-			}
-			MU_UNLOCK(hlock);
-			if (i>=0) {
-				fprintf(stderr,"RPCIO There are still transactions circulating; I refuse to go away\n");
-				fprintf(stderr,"(1st in slot %i)\n",i);
-				rtems_semaphore_release(fini);
-			} else {
-				break;
-			}
-		}
-
-        	unow = rtems_clock_get_ticks_since_boot();
-
-		/* measure everything relative to then to protect against
-		 * rollover
-		 */
-		now = unow - then;
-
-		/* NOTE: we don't lock the hash table while we are operating
-		 * on transactions; the paradigm is that we 'own' a particular
-		 * transaction (and hence it's hash table slot) from the
-		 * time the xact was put into the message queue until we
-		 * wake up the requestor.
-		 */
-
-		if (RPCIOD_RX_EVENT & events) {
-
-#if (DEBUG) & DEBUG_EVENTS
-			fprintf(stderr,"RPCIO: got RX event\n");
-#endif
-
-			while ((xact=sockRcv())) {
-
-				/* extract from the retransmission list */
-				nodeXtract(&xact->node);
-
-				/* change the ID - there might already be
-				 * a retransmission on the way. When it's
-				 * reply arrives we must not find it's ID
-				 * in the hashtable
-				 */
-				xact->obuf.xid        += XACT_HASHS;
-
-				xact->status.re_status = RPC_SUCCESS;
-
-				/* calculate roundtrip ticks */
-				xact->trip             = now - xact->trip;
-
-				srv                    = xact->server;
-
-				/* adjust the server's retry period */
-				{
-					register TimeoutT rtry = srv->retry_period;
-					register TimeoutT trip = xact->trip;
-
-					ASSERT( trip >= 0 );
-
-					if ( 0==trip )
-						trip = 1;
-
-					/* retry_new = 0.75*retry_old + 0.25 * 8 * roundrip */
-					rtry   = (3*rtry + (trip << 3)) >> 2;
-
-					if ( rtry > max_period )
-						rtry = max_period;
-
-					srv->retry_period = rtry;
-				}
-
-				/* wakeup requestor */
-				rtems_event_send(xact->requestor, RTEMS_RPC_EVENT);
-			}
-		}
-
-		if (RPCIOD_TX_EVENT & events) {
-
-#if (DEBUG) & DEBUG_EVENTS
-			fprintf(stderr,"RPCIO: got TX event\n");
-#endif
-
-			while (RTEMS_SUCCESSFUL == rtems_message_queue_receive(
-											msgQ,
-											&xact,
-											&size,
-											RTEMS_NO_WAIT,
-											RTEMS_NO_TIMEOUT)) {
-				/* put to the head of timeout q */
-				nodeAppend(&listHead, &xact->node);
-
-				xact->age  = now;
-				xact->trip = FIRST_ATTEMPT;
-			}
-		}
-
-
-		/* work the timeout q */
-		newList = 0;
-		for ( xact=(RpcUdpXact)listHead.next;
-			  xact && xact->age <= now;
-			  xact=(RpcUdpXact)listHead.next ) {
-
-				/* extract from the list */
-				nodeXtract(&xact->node);
-
-				srv = xact->server;
-
-				if (xact->tolive < 0) {
-					/* this one timed out */
-					xact->status.re_errno  = ETIMEDOUT;
-					xact->status.re_status = RPC_TIMEDOUT;
-
-					srv->timeouts++;
-
-					/* Change the ID - there might still be
-					 * a reply on the way. When it arrives we
-					 * must not find it's ID in the hash table
-					 *
-					 * Thanks to Steven Johnson for hunting this
-					 * one down.
-					 */
-					xact->obuf.xid        += XACT_HASHS;
-
-#if (DEBUG) & DEBUG_TIMEOUT
-					fprintf(stderr,"RPCIO XACT timed out; waking up requestor\n");
-#endif
-					if ( rtems_event_send(xact->requestor, RTEMS_RPC_EVENT) ) {
-						rtems_panic("RPCIO PANIC file %s line: %i, requestor id was 0x%08x",
-									__FILE__,
-									__LINE__,
-									xact->requestor);
-					}
-
-				} else {
-					int len;
-
-					len = (int)XDR_GETPOS(&xact->xdrs);
-
-#ifdef MBUF_TX
-					xact->refcnt = 1;	/* sendto itself */
-#endif
-					if ( len != SENDTO( ourSock,
-										xact->obuf.buf,
-										len,
-										0,
-										&srv->addr.sa,
-										sizeof(srv->addr.sin)
-#ifdef MBUF_TX
-										, xact,
-										paranoia_free,
-										paranoia_ref
-#endif
-										) ) {
-
-						xact->status.re_errno  = errno;
-						xact->status.re_status = RPC_CANTSEND;
-						srv->errors++;
-
-						/* wakeup requestor */
-						fprintf(stderr,"RPCIO: SEND failure\n");
-						status = rtems_event_send(xact->requestor, RTEMS_RPC_EVENT);
-						assert( status == RTEMS_SUCCESSFUL );
-
-					} else {
-						/* send successful; calculate retransmission time
-						 * and enqueue to temporary list
-						 */
-						if (FIRST_ATTEMPT != xact->trip) {
-#if (DEBUG) & DEBUG_TIMEOUT
-							fprintf(stderr,
-								"timed out; tolive is %i (ticks), retry period is %i (ticks)\n",
-									xact->tolive,
-									srv->retry_period);
-#endif
-							/* this is a real retry; we backup
-							 * the server's retry interval
-							 */
-							if ( srv->retry_period < max_period ) {
-
-								/* If multiple transactions for this server
-								 * fail (e.g. because it died) this will
-								 * back-off very agressively (doubling
-								 * the retransmission period for every
-								 * timed out transaction up to the CAP limit)
-								 * which is desirable - single packet failure
-								 * is treated more gracefully by this algorithm.
-								 */
-
-								srv->retry_period<<=1;
-#if (DEBUG) & DEBUG_TIMEOUT
-								fprintf(stderr,
-										"adjusted to; retry period %i\n",
-										srv->retry_period);
-#endif
-							} else {
-								/* never wait longer than RPCIOD_RETX_CAP_S seconds */
-								fprintf(stderr,
-										"RPCIO: server '%s' not responding - still trying\n",
-										srv->name);
-							}
-							if ( 0 == ++srv->retrans % 1000) {
-								fprintf(stderr,
-										"RPCIO - statistics: already %li retries to server %s\n",
-										srv->retrans,
-										srv->name);
-							}
-						} else {
-							srv->requests++;
-						}
-						xact->trip      = now;
-						{
-						long capped_period = srv->retry_period;
-							if ( xact->lifetime < capped_period )
-								capped_period = xact->lifetime;
-						xact->age       = now + capped_period;
-						xact->tolive   -= capped_period;
-						}
-						/* enqueue to the list of newly sent transactions */
-						xact->node.next = newList;
-						newList         = &xact->node;
-#if (DEBUG) & DEBUG_TIMEOUT
-						fprintf(stderr,
-								"XACT (0x%08x) age is 0x%x, now: 0x%x\n",
-								xact,
-								xact->age,
-								now);
-#endif
-					}
-				}
-	    }
-
-		/* insert the newly sent transactions into the
-		 * sorted retransmission list
-		 */
-		for (; (xact = (RpcUdpXact)newList); ) {
-			register ListNode p,n;
-			newList = newList->next;
-			for ( p=&listHead; (n=p->next) && xact->age > ((RpcUdpXact)n)->age; p=n )
-				/* nothing else to do */;
-			nodeAppend(p, &xact->node);
-		}
-
-		if (now > epoch) {
-			/* every now and then, readjust the epoch */
-			register ListNode n;
-			then += now;
-			for (n=listHead.next; n; n=n->next) {
-				/* readjust outstanding time intervals subject to the
-				 * condition that the 'absolute' time must remain
-				 * the same. 'age' and 'trip' are measured with
-				 * respect to 'then' - hence:
-				 *
-				 * abs_age == old_age + old_then == new_age + new_then
-				 *
-				 * ==> new_age = old_age + old_then - new_then == old_age - 'now'
-				 */
-				((RpcUdpXact)n)->age  -= now;
-				((RpcUdpXact)n)->trip -= now;
-#if (DEBUG) & DEBUG_TIMEOUT
-				fprintf(stderr,
-						"readjusted XACT (0x%08x); age is 0x%x, trip: 0x%x now: 0x%x\n",
-						(RpcUdpXact)n,
-						((RpcUdpXact)n)->trip,
-						((RpcUdpXact)n)->age,
-						now);
-#endif
-			}
-			now = 0;
-		}
-
-		next_retrans = listHead.next ?
-							((RpcUdpXact)listHead.next)->age - now :
-							epoch;	/* make sure we don't miss updating the epoch */
-#if (DEBUG) & DEBUG_TIMEOUT
-		fprintf(stderr,"RPCIO: next timeout is %x\n",next_retrans);
-#endif
-	}
-	/* close our socket; shut down the receiver */
-	close(ourSock);
-
-#if 0 /* if we get here, no transactions exist, hence there can be none
-	   * in the queue whatsoever
-	   */
-	/* flush the message queue */
-	while (RTEMS_SUCCESSFUL == rtems_message_queue_receive(
-										q,
-										&xact,
-										&size,
-										RTEMS_NO_WAIT,
-										RTEMS_NO_TIMEOUT)) {
-			/* TODO enque xact */
-	}
-
-	/* flush all outstanding transactions */
-
-	for (xact=((RpcUdpXact)listHead.next); xact; xact=((RpcUdpXact)xact->node.next)) {
-			xact->status.re_status = RPC_TIMEDOUT;
-			rtems_event_send(xact->requestor, RTEMS_RPC_EVENT);
-	}
-#endif
-
-	rtems_message_queue_delete(q);
-
-	MU_DESTROY(hlock);
-
-	fprintf(stderr,"RPC daemon exited...\n");
-
-	rtems_semaphore_release(fini);
-	rtems_task_suspend(RTEMS_SELF);
-}
-
-
-/* support for transaction 'pools'. A number of XACT objects
- * is always kept around. The initial number is 0 but it
- * is allowed to grow up to a maximum.
- * If the need grows beyond the maximum, behavior depends:
- * Users can either block until a transaction becomes available,
- * they can create a new XACT on the fly or get an error
- * if no free XACT is available from the pool.
- */
-
-RpcUdpXactPool
-rpcUdpXactPoolCreate(
-	rpcprog_t prog, 		rpcvers_t version,
-	int xactsize,	int poolsize)
-{
-RpcUdpXactPool	rval = MY_MALLOC(sizeof(*rval));
-rtems_status_code	status;
-
-	ASSERT( rval );
-	status = rtems_message_queue_create(
-					rtems_build_name('R','P','C','p'),
-					poolsize,
-					sizeof(RpcUdpXact),
-					RTEMS_DEFAULT_ATTRIBUTES,
-					&rval->box);
-	assert( status == RTEMS_SUCCESSFUL );
-
-	rval->prog     = prog;
-	rval->version  = version;
-	rval->xactSize = xactsize;
-	return rval;
-}
-
-void
-rpcUdpXactPoolDestroy(RpcUdpXactPool pool)
-{
-RpcUdpXact xact;
-
-	while ((xact = rpcUdpXactPoolGet(pool, XactGetFail))) {
-		rpcUdpXactDestroy(xact);
-	}
-	rtems_message_queue_delete(pool->box);
-	MY_FREE(pool);
-}
-
-RpcUdpXact
-rpcUdpXactPoolGet(RpcUdpXactPool pool, XactPoolGetMode mode)
-{
-RpcUdpXact	 xact = 0;
-size_t           size;
-
-	if (RTEMS_SUCCESSFUL != rtems_message_queue_receive(
-								pool->box,
-								&xact,
-								&size,
-								XactGetWait == mode ?
-									RTEMS_WAIT : RTEMS_NO_WAIT,
-								RTEMS_NO_TIMEOUT)) {
-
-		/* nothing found in box; should we create a new one ? */
-
-		xact = (XactGetCreate == mode) ?
-					rpcUdpXactCreate(
-							pool->prog,
-							pool->version,
-							pool->xactSize) : 0 ;
-		if (xact)
-				xact->pool = pool;
-
-	}
-	return xact;
-}
-
-void
-rpcUdpXactPoolPut(RpcUdpXact xact)
-{
-RpcUdpXactPool pool;
-
-	pool = xact->pool;
-	ASSERT( pool );
-
-	if (RTEMS_SUCCESSFUL != rtems_message_queue_send(
-								pool->box,
-								&xact,
-								sizeof(xact)))
-		rpcUdpXactDestroy(xact);
-}
-
-#ifdef MBUF_RX
-
-/* WORKAROUND: include sys/mbuf.h (or other bsdnet headers) only
- *             _after_ using malloc()/free() & friends because
- *             the RTEMS/BSDNET headers redefine those :-(
- */
-
-#define _KERNEL
-#include <sys/mbuf.h>
-
-ssize_t
-recv_mbuf_from(int s, struct mbuf **ppm, long len, struct sockaddr *fromaddr, int *fromlen);
-
-static void
-bufFree(struct mbuf **m)
-{
-	if (*m) {
-		rtems_bsdnet_semaphore_obtain();
-		m_freem(*m);
-		rtems_bsdnet_semaphore_release();
-		*m = 0;
-	}
-}
-#endif
-
-#ifdef MBUF_TX
-static void
-paranoia_free(caddr_t closure, u_int size)
-{
-#if (DEBUG)
-RpcUdpXact xact = (RpcUdpXact)closure;
-int        len  = (int)XDR_GETPOS(&xact->xdrs);
-
-	ASSERT( --xact->refcnt >= 0 && size == len );
-#endif
-}
-
-static void
-paranoia_ref (caddr_t closure, u_int size)
-{
-#if (DEBUG)
-RpcUdpXact xact = (RpcUdpXact)closure;
-int        len  = (int)XDR_GETPOS(&xact->xdrs);
-	ASSERT( size == len );
-	xact->refcnt++;
-#endif
-}
-#endif
-
-/* receive from a socket and find
- * the transaction corresponding to the
- * transaction ID received in the server
- * reply.
- *
- * The semantics of the 'pibuf' pointer are
- * as follows:
- *
- * MBUF_RX:
- *
- */
-
-#define RPCIOD_RXBUFSZ	UDPMSGSIZE
-
-static RpcUdpXact
-sockRcv(void)
-{
-int					len,i;
-uint32_t				xid;
-union {
-	struct sockaddr_in	sin;
-	struct sockaddr     sa;
-}					fromAddr;
-int					fromLen  = sizeof(fromAddr.sin);
-RxBuf				ibuf     = 0;
-RpcUdpXact			xact     = 0;
-
-	do {
-
-	/* rcv_mbuf() and recvfrom() differ in that the
-	 * former allocates buffers and passes them back
-	 * to us whereas the latter requires us to provide
-	 * buffer space.
-	 * Hence, in the first case whe have to make sure
-	 * no old buffer is leaked - in the second case,
-	 * we might well re-use an old buffer but must
-	 * make sure we have one allocated
-	 */
-#ifdef MBUF_RX
-	if (ibuf)
-		bufFree(&ibuf);
-
-	len  = recv_mbuf_from(
-					ourSock,
-					&ibuf,
-					RPCIOD_RXBUFSZ,
-				    &fromAddr.sa,
-				    &fromLen);
-#else
-	if ( !ibuf )
-		ibuf = (RpcBuf)MY_MALLOC(RPCIOD_RXBUFSZ);
-	if ( !ibuf )
-		goto cleanup; /* no memory - drop this message */
-
-	len  = recvfrom(ourSock,
-				    ibuf->buf,
-				    RPCIOD_RXBUFSZ,
-				    0,
-				    &fromAddr.sa,
-					&fromLen);
-#endif
-
-	if (len <= 0) {
-		if (EAGAIN != errno)
-			fprintf(stderr,"RECV failed: %s\n",strerror(errno));
-		goto cleanup;
-	}
-
-#if (DEBUG) & DEBUG_PACKLOSS
-	if ( (unsigned)rand() < DEBUG_PACKLOSS_FRACT ) {
-		/* lose packets once in a while */
-		static int xxx = 0;
-		if ( ++xxx % 16 == 0 )
-			fprintf(stderr,"DEBUG: dropped %i packets, so far...\n",xxx);
-		if ( ibuf )
-			bufFree( &ibuf );
-		continue;
-	}
-#endif
-
-	i = (xid=XID(ibuf)) & XACT_HASH_MSK;
-
-	if ( !(xact=xactHashTbl[i])                                             ||
-		   xact->obuf.xid                     != xid                        ||
-#ifdef REJECT_SERVERIP_MISMATCH
-		   xact->server->addr.sin.sin_addr.s_addr != fromAddr.sin.sin_addr.s_addr	||
-#endif
-		   xact->server->addr.sin.sin_port        != fromAddr.sin.sin_port ) {
-
-		if (xact) {
-			if (
-#ifdef REJECT_SERVERIP_MISMATCH
-			    xact->server->addr.sin.sin_addr.s_addr == fromAddr.sin.sin_addr.s_addr &&
-#endif
-		        xact->server->addr.sin.sin_port        == fromAddr.sin.sin_port        &&
-			    ( xact->obuf.xid                   == xid + XACT_HASHS   ||
-				  xact->obuf.xid                   == xid + 2*XACT_HASHS    )
-				) {
-#ifndef DEBUG /* don't complain if it's just a late arrival of a retry */
-			fprintf(stderr,"RPCIO - FYI sockRcv(): dropping late/redundant retry answer\n");
-#endif
-			} else {
-			fprintf(stderr,"RPCIO WARNING sockRcv(): transaction mismatch\n");
-			fprintf(stderr,"xact: xid  0x%08" PRIx32 "  -- got 0x%08" PRIx32 "\n",
-							xact->obuf.xid, xid);
-			fprintf(stderr,"xact: addr 0x%08" PRIx32 "  -- got 0x%08" PRIx32 "\n",
-							xact->server->addr.sin.sin_addr.s_addr,
-							fromAddr.sin.sin_addr.s_addr);
-			fprintf(stderr,"xact: port 0x%08x  -- got 0x%08x\n",
-							xact->server->addr.sin.sin_port,
-							fromAddr.sin.sin_port);
-			}
-		} else {
-			fprintf(stderr,
-					"RPCIO WARNING sockRcv(): got xid 0x%08" PRIx32 " but its slot is empty\n",
-					xid);
-		}
-		/* forget about this one and try again */
-		xact = 0;
-	}
-
-	} while ( !xact );
-
-	xact->ibuf     = ibuf;
-#ifndef MBUF_RX
-	xact->ibufsize = RPCIOD_RXBUFSZ;
-#endif
-
-	return xact;
-
-cleanup:
-
-	bufFree(&ibuf);
-
-	return 0;
-}
-
-
-#include <rtems/rtems_bsdnet_internal.h>
-/* double check the event configuration; should probably globally
- * manage system events!!
- * We do this at the end of the file for the same reason we had
- * included mbuf.h only a couple of lines above - see comment up
- * there...
- */
-#if RTEMS_RPC_EVENT & SOSLEEP_EVENT & SBWAIT_EVENT & NETISR_EVENTS
-#error ILLEGAL EVENT CONFIGURATION
-#endif
Index: rvices/nfsclient/rpcio.modini.c
===================================================================
--- services/nfsclient/rpcio.modini.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,19 +1,0 @@
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "librtemsNfs.h"
-/* CEXP module support (magic init) */
-void
-_cexpModuleInitialize(void *mod)
-{
-	rpcUdpInit();
-}
-
-int
-_cexpModuleFinalize(void *mod)
-{
-	return rpcUdpCleanup();
-}
-
-
Index: rvices/nfsclient/sock_mbuf.c
===================================================================
--- services/nfsclient/sock_mbuf.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,281 +1,0 @@
-/*
- *  NOTE:
- *    This is derived from libnetworking/rtems/rtems_syscall.c
- *
- *    RTEMS/libnetworking LICENSING restrictions may apply
- *
- *    Author (modifications only):
- *    Copyright: 2002, Stanford University and
- *    		 Till Straumann, <strauman@slac.stanford.edu>
- *    Licensing: 'LICENSE.NET' file in the RTEMS top source directory
- *               for more information.
- */
-
-/*
-The RTEMS TCP/IP stack is a port of the FreeBSD TCP/IP stack.  The following
-copyright and licensing information applies to this code.
-
-This code is found under the c/src/libnetworking directory but does not
-constitute the entire contents of that subdirectory.
-
-=============================================================================
-
-Copyright (c) 1980, 1983, 1988, 1993
-	The Regents of the University of California.  All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgment:
-	This product includes software developed by the University of
-	California, Berkeley and its contributors.
-4. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--
-Portions Copyright (c) 1993 by Digital Equipment Corporation.
-
-Permission to use, copy, modify, and distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies, and that
-the name of Digital Equipment Corporation not be used in advertising or
-publicity pertaining to distribution of the document or software without
-specific, written prior permission.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
-WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
-CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-=============================================================================
-*/
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-#include <rtems.h>
-#include <rtems/libio.h>
-#include <rtems/error.h>
-
-#define _KERNEL
-#define __BSD_VISIBLE	1
-#include <rtems/rtems_bsdnet.h>
-
-#include <sys/errno.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/protosw.h>
-#include <sys/proc.h>
-#include <sys/fcntl.h>
-#include <sys/filio.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-struct socket *rtems_bsdnet_fdToSocket(int fd);
-
-/*
- * Package system call argument into mbuf.
- *
- * (unfortunately, the original is not public)
- */
-static int
-sockaddrtombuf (struct mbuf **mp, const struct sockaddr *buf, int buflen)
-{
-struct mbuf *m;
-struct sockaddr *sa;
-
-	if ((u_int)buflen > MLEN)
-		return (EINVAL);
-
-	rtems_bsdnet_semaphore_obtain();
-	m = m_get(M_WAIT, MT_SONAME);
-	rtems_bsdnet_semaphore_release();
-
-	if (m == NULL)
-		return (ENOBUFS);
-	m->m_len = buflen;
-	memcpy (mtod(m, caddr_t), buf, buflen);
-	*mp = m;
-	sa = mtod(m, struct sockaddr *);
-	sa->sa_len = buflen;
-
-	return 0;
-}
-
-static void
-dummyproc(caddr_t ext_buf, u_int ext_size)
-{
-}
-
-/*
- * send data by simply allocating an MBUF packet
- * header and pointing it to our data region.
- *
- * Optionally, the caller may supply 'reference'
- * and 'free' procs. (The latter may call the
- * user back once the networking stack has
- * released the buffer).
- *
- * The callbacks are provided with the 'closure'
- * pointer and the 'buflen' argument.
- */
-ssize_t
-sendto_nocpy (
-		int s,
-		const void *buf, size_t buflen,
-		int flags,
-		const struct sockaddr *toaddr, int tolen,
-		void *closure,
-		void (*freeproc)(caddr_t, u_int),
-		void (*refproc)(caddr_t, u_int)
-)
-{
-	int           error;
-	struct socket *so;
-	struct mbuf   *to, *m;
-	int           ret = -1;
-
-	rtems_bsdnet_semaphore_obtain ();
-	if ((so = rtems_bsdnet_fdToSocket (s)) == NULL) {
-		rtems_bsdnet_semaphore_release ();
-		return -1;
-	}
-
-	error = sockaddrtombuf (&to, toaddr, tolen);
-	if (error) {
-		errno = error;
-		rtems_bsdnet_semaphore_release ();
-		return -1;
-	}
-
-	MGETHDR(m, M_WAIT, MT_DATA);
-	m->m_pkthdr.len   = 0;
-	m->m_pkthdr.rcvif =  (struct ifnet *) 0;
-
-	m->m_flags       |= M_EXT;
-	m->m_ext.ext_buf  = closure ? closure : (void*)buf;
-	m->m_ext.ext_size = buflen;
-	/* we _must_ supply non-null procs; otherwise,
-	 * the kernel code assumes it's a mbuf cluster
-	 */
-	m->m_ext.ext_free = freeproc ? freeproc : dummyproc;
-	m->m_ext.ext_ref  = refproc  ? refproc  : dummyproc;
-	m->m_pkthdr.len  += buflen;
-	m->m_len          = buflen;
-	m->m_data		  = (void*)buf;
-
-	error = sosend (so, to, NULL, m, NULL, flags);
-	if (error) {
-		if (/*auio.uio_resid != len &&*/ (error == EINTR || error == EWOULDBLOCK))
-			error = 0;
-	}
-	if (error)
-		errno = error;
-	else
-		ret = buflen;
-	if (to)
-		m_freem(to);
-	rtems_bsdnet_semaphore_release ();
-	return (ret);
-}
-
-
-/*
- * receive data in an 'mbuf chain'.
- * The chain must be released once the
- * data has been extracted:
- *
- *   rtems_bsdnet_semaphore_obtain();
- *   	m_freem(chain);
- *   rtems_bsdnet_semaphore_release();
- */
-ssize_t
-recv_mbuf_from(int s, struct mbuf **ppm, long len, struct sockaddr *fromaddr, int *fromlen)
-{
-	int ret = -1;
-	int error;
-	struct uio auio;
-	struct socket *so;
-	struct mbuf *from = NULL;
-
-	memset(&auio, 0, sizeof(auio));
-	*ppm = 0;
-
-	rtems_bsdnet_semaphore_obtain ();
-	if ((so = rtems_bsdnet_fdToSocket (s)) == NULL) {
-		rtems_bsdnet_semaphore_release ();
-		return -1;
-	}
-/*	auio.uio_iov = mp->msg_iov;
-	auio.uio_iovcnt = mp->msg_iovlen;
-	auio.uio_segflg = UIO_USERSPACE;
-	auio.uio_rw = UIO_READ;
-	auio.uio_offset = 0;
-*/
-	auio.uio_resid = len;
-	error = soreceive (so, &from, &auio, (struct mbuf **) ppm,
-			(struct mbuf **)NULL,
-			NULL);
-	if (error) {
-		if (auio.uio_resid != len && (error == EINTR || error == EWOULDBLOCK))
-			error = 0;
-	}
-	if (error) {
-		errno = error;
-	}
-	else {
-		ret = len - auio.uio_resid;
-		if (fromaddr) {
-			len = *fromlen;
-			if ((len <= 0) || (from == NULL)) {
-				len = 0;
-			}
-			else {
-				if (len > from->m_len)
-					len = from->m_len;
-				memcpy (fromaddr, mtod(from, caddr_t), len);
-			}
-			*fromlen = len;
-		}
-	}
-	if (from)
-		m_freem (from);
-	if (error && *ppm) {
-		m_freem(*ppm);
-		*ppm = 0;
-	}
-	rtems_bsdnet_semaphore_release ();
-	return (ret);
-}
Index: rvices/nfsclient/xdr_mbuf.c
===================================================================
--- services/nfsclient/xdr_mbuf.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,537 +1,0 @@
-/* xdr_mbuf is derived from xdr_mem */
-
-/* Author (mbuf specifica): Till Straumann <strauman@slac.stanford.edu>, 10/2002 */
-
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/
-/*static char *sccsid = "from: @(#)xdr_mem.c	2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_mem.c,v 1.8 1999/08/28 00:02:56 peter Exp $";
-#endif
-
-/*
- * xdr_mbuf,  XDR implementation using mbuf buffers
- *
- * derived from:
- *
- * xdr_mem.h, XDR implementation using memory buffers.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * The MBUF stream is useful for BSDNET kernel (or RTEMS for that matter)
- * use.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <netinet/in.h>
-
-#include <stdlib.h>
-
-#define TODO
-
-/* TODO remove: a hack because malloc is redefined */
-#ifdef TODO
-static inline void *
-my_malloc(size_t i)
-{
-	return malloc(i);
-}
-
-static inline void
-my_free(void *p)
-{
-	return free(p);
-}
-#endif
-
-#define DEBUG_ASSERT	(1<<0)
-#define DEBUG_VERB		(1<<1)
-
-#define DEBUG			DEBUG_ASSERT
-
-#define _KERNEL
-#include <sys/mbuf.h>
-
-#include <assert.h>
-
-#if DEBUG & DEBUG_VERB || defined(TODO)
-#include <stdio.h>
-#endif
-
-static bool_t	xdrmbuf_getlong_aligned(XDR *xdrs, long *lp);
-static bool_t	xdrmbuf_putlong_aligned(XDR *xdrs, const long *lp);
-static bool_t	xdrmbuf_getlong_unaligned(XDR *xdrs, long *lp);
-static bool_t	xdrmbuf_putlong_unaligned(XDR *xdrs, const long *lp);
-static bool_t	xdrmbuf_getbytes(XDR *xdrs, caddr_t addr, u_int len);
-static bool_t	xdrmbuf_putbytes(XDR *xdrs, const char *addr, u_int len);
-static u_int	xdrmbuf_getpos(XDR *xdrs); /* XXX w/64-bit pointers, u_int not enough! */
-static bool_t	xdrmbuf_setpos(XDR *xdrs, u_int pos);
-static int32_t *xdrmbuf_inline_aligned(XDR *xdrs, u_int len);
-static int32_t *xdrmbuf_inline_unaligned(XDR *xdrs, u_int len);
-static void	xdrmbuf_destroy(XDR *);
-
-static struct	xdr_ops xdrmbuf_ops_aligned = {
-	xdrmbuf_getlong_aligned,
-	xdrmbuf_putlong_aligned,
-	xdrmbuf_getbytes,
-	xdrmbuf_putbytes,
-	xdrmbuf_getpos,
-	xdrmbuf_setpos,
-	xdrmbuf_inline_aligned,
-	xdrmbuf_destroy
-};
-
-static struct	xdr_ops xdrmbuf_ops_unaligned = {
-	xdrmbuf_getlong_unaligned,
-	xdrmbuf_putlong_unaligned,
-	xdrmbuf_getbytes,
-	xdrmbuf_putbytes,
-	xdrmbuf_getpos,
-	xdrmbuf_setpos,
-	xdrmbuf_inline_unaligned,
-	xdrmbuf_destroy
-};
-
-typedef struct MBPrivateRec_ {
-	struct mbuf		*mchain;
-	struct mbuf		*mcurrent;
-	u_int			pos;		/* number of bytes contained in all MUBFS ahead
-								 * of mcurrent
-								 */
-} MBPrivateRec, *MBPrivate;
-
-/* NOTE: the stream position helper 'pos'
- *       must be managed by the caller!
- */
-static inline void
-xdrmbuf_setup(XDR *xdrs, struct mbuf *m)
-{
-MBPrivate	mbp = (MBPrivate)xdrs->x_base;
-
-		mbp->mcurrent    = m;
-		xdrs->x_private  = mtod(m,caddr_t);
-		xdrs->x_handy    = m->m_len;
-		xdrs->x_ops      = ((uintptr_t)xdrs->x_private & (sizeof(int32_t) - 1))
-								? &xdrmbuf_ops_unaligned : &xdrmbuf_ops_aligned;
-}
-
-static struct mbuf *
-xdrmbuf_next(XDR *xdrs)
-{
-struct mbuf		*rval;
-MBPrivate		mbp = (MBPrivate)xdrs->x_base;
-
-	if (mbp->mcurrent) {
-		mbp->pos += mbp->mcurrent->m_len;
-		rval      = mbp->mcurrent->m_next;
-	} else {
-		rval      = 0;
-	}
-
-	if (rval) {
-		xdrmbuf_setup(xdrs, rval);
-	}
-#if DEBUG & DEBUG_VERB
-	else {
-		fprintf(stderr,"xdrmbuf: end of chain\n");
-	}
-#endif
-
-	return rval;
-}
-
-/*
- * The procedure xdrmbuf_create initializes a stream descriptor for a
- * memory buffer.
- */
-void
-xdrmbuf_create(XDR *xdrs, struct mbuf *mbuf, enum xdr_op op)
-{
-MBPrivate mbp;
-
-	xdrs->x_op = op;
-	mbp = (MBPrivate)my_malloc(sizeof(*mbp));
-	assert( mbp );
-	xdrs->x_base  = (caddr_t) mbp;
-
-	mbp->mchain   = mbuf;
-	mbp->pos      = 0;
-
-#if DEBUG & DEBUG_VERB
-	{
-	struct mbuf *mbf;
-	fprintf(stderr,"Dumping chain:\n");
-	for (mbf = mbuf; mbf; mbf=mbf->m_next) {
-		int ii;
-		fprintf(stderr,"MBUF------------");
-		for (ii=0; ii<mbf->m_len; ii++) {
-			fprintf(stderr,"%02x ",mtod(mbf,char*)[ii]);
-			if (ii%16==0)
-				fputc('\n',stderr);
-		}
-		fputc('\n',stderr);
-	}
-	}
-#endif
-
-	xdrmbuf_setup(xdrs, mbuf);
-}
-
-static void
-xdrmbuf_destroy(XDR *xdrs)
-{
-MBPrivate	mbp = (MBPrivate)xdrs->x_base;
-#if 0 /* leave destroying the chain to the user */
-struct mbuf *m = mbp->mchain;
-
-	rtems_bsdnet_semaphore_obtain();
-		m_freem(m);
-	rtems_bsdnet_semaphore_release();
-#endif
-
-	my_free(mbp);
-}
-
-static bool_t
-xdrmbuf_getlong_aligned(register XDR *xdrs, register long *lp)
-{
-	while ( (signed int)(xdrs->x_handy -= sizeof(int32_t)) < 0) {
-		if ((xdrs->x_handy += sizeof(int32_t)) == 0) {
-			/* handy was 0 on entry; request a new buffer.
-			 * Coded this way, so the most frequently executed
-			 * path needs only one comparison...
-			 */
-			if (!xdrmbuf_next(xdrs))
-				return FALSE;
-		} else {
-			/* uh-oh an aligned long spread over two MBUFS ??
-			 * let the unaligned handler deal with this rare
-			 * situation.
-			 */
-			return xdrmbuf_getlong_unaligned(xdrs,lp);
-		}
-	}
-	*lp = ntohl(*(int32_t *)(xdrs->x_private));
-	xdrs->x_private += sizeof(int32_t);
-#if DEBUG & DEBUG_VERB
-	fprintf(stderr,"Got aligned long %x\n",*lp);
-#endif
-	return (TRUE);
-}
-
-static bool_t
-xdrmbuf_putlong_aligned(
-	XDR *xdrs,
-	const long *lp)
-{
-fprintf(stderr,"TODO: xdrmbuf_putlong_aligned() is unimplemented\n");
-	return FALSE;
-#if 0
-	if ((xdrs->x_handy -= sizeof(int32_t)) < 0)
-		return (FALSE);
-	*(int32_t *)xdrs->x_private = htonl(*lp);
-	xdrs->x_private += sizeof(int32_t);
-	return (TRUE);
-#endif
-}
-
-static bool_t
-xdrmbuf_getlong_unaligned(
-	XDR *xdrs,
-	long *lp)
-{
-union {
-	int32_t l;
-	char	c[sizeof(int32_t)];
-}	u;
-
-register int  i,j;
-register char *cp,*sp;
-
-	i = xdrs->x_handy - sizeof(int32_t);
-
-	/* handle the most common case first */
-	if ( i >= 0 ) {
-
-		xdrs->x_handy   = i;
-		sp			    = (char*)xdrs->x_private;
-		xdrs->x_private = sp + sizeof(int32_t);
-
-#ifdef CANDO_UNALIGNED
-		{
-			*lp              = ntohl(*(int32_t *)sp);
-#        if DEBUG & DEBUG_VERB
-			fprintf(stderr,"Got unaligned long %x (%i remaining)\n",*lp, xdrs->x_handy);
-#        endif
-			return TRUE;
-		}
-#else   /* machine can't do unaligned access */
-		{
-			u.c[0]          = *sp;
-			u.c[1]          = *++sp;
-			u.c[2]          = *++sp;
-			u.c[3]          = *++sp;
-
-			goto done;
-		}
-#endif /* CANDO_UNALIGNED */
-	}
-
-	/* here the messy 'crossing buffers' business starts */
-
-
-	j  = sizeof(int32_t);
-
-	cp = u.c-1;
-
-	/* NOTE: on entry to this section,  handy < j holds */
-	do {
-		sp = ((char*)xdrs->x_private)-1;
-
-		if ( (i=xdrs->x_handy) >= j ) {
-			/* more data in the buffer than we need:
-			 * copy everything we need and goto 'done'
-			 */
-			xdrs->x_handy    = i-j;
-			do {
-				*++cp = *++sp;
-			} while (--j > 0);
-			xdrs->x_private  = (caddr_t)++sp;
-
-			goto done;
-
-		} else {
-			/* not enough data - copy as much as possible
-			 * then get retrieve the next MBUF and start
-			 * over
-			 */
-			j-=i;
-			while (i--)
-				*++cp = *++sp;
-			if (!xdrmbuf_next(xdrs))
-				return FALSE;
-#if DEBUG & DEBUG_VERB
-			fprintf(stderr,"getlong_unaligned: crossed mbuf boundary\n");
-#endif
-		}
-	} while (j > 0);
-
-done:
-
-	*lp = ntohl(u.l);
-
-#if DEBUG & DEBUG_VERB
-	fprintf(stderr,"Got unaligned long %x (%i remaining)\n",*lp, xdrs->x_handy);
-#endif
-	return (TRUE);
-}
-
-static bool_t
-xdrmbuf_putlong_unaligned(
-	XDR *xdrs,
-	const long *lp )
-{
-
-	fprintf(stderr,"TODO: xdrmbuf_putlong_unaligned() is unimplemented\n");
-	return FALSE;
-#if 0
-	{
-	int32_t l;
-
-	if ((xdrs->x_handy -= sizeof(int32_t)) < 0)
-		return (FALSE);
-	l = htonl(*lp);
-	memcpy(xdrs->x_private, &l, sizeof(int32_t));
-	xdrs->x_private += sizeof(int32_t);
-	return (TRUE);
-	}
-#endif
-}
-
-static bool_t
-xdrmbuf_getbytes(
-	XDR *xdrs,
-	caddr_t addr,
-	u_int len)
-{
-#if DEBUG & DEBUG_VERB
-int	olen=len,bufs=0;
-#endif
-
-#if DEBUG & DEBUG_VERB
-	fprintf(stderr,"wanting %i bytes (have %i)\n",olen,xdrs->x_handy);
-#endif
-
-	while (len>0) {
-		if (xdrs->x_handy >= len) {
-			memcpy(addr, xdrs->x_private, len);
-			xdrs->x_private += len;
-			xdrs->x_handy   -= len;
-#if 0 /* save a couple of instructions */
-			len = 0;
-#else
-			goto done;
-#endif
-		} else {
-			if (xdrs->x_handy > 0) {
-				memcpy(addr, xdrs->x_private, xdrs->x_handy);
-				len  -= xdrs->x_handy;
-				addr += xdrs->x_handy;
-			}
-			if (!xdrmbuf_next(xdrs))
-				return FALSE;
-#if DEBUG & DEBUG_VERB
-			bufs++;
-#endif
-		}
-	}
-done:
-#if DEBUG & DEBUG_VERB
-	fprintf(stderr,"Got %i bytes (out of %i mbufs)\n",olen,bufs);
-#endif
-	return (TRUE);
-}
-
-static bool_t
-xdrmbuf_putbytes(
-	XDR *xdrs,
-	const char *addr,
-	u_int len )
-{
-
-	fprintf(stderr,"TODO: xdrmbuf_putbytes() is unimplemented\n");
-	return FALSE;
-#if 0
-	if ((xdrs->x_handy -= len) < 0)
-		return (FALSE);
-	memcpy(xdrs->x_private, addr, len);
-	xdrs->x_private += len;
-	return (TRUE);
-#endif
-}
-
-static u_int
-xdrmbuf_getpos(
-	XDR *xdrs)
-{
-#if 1
-MBPrivate	mbp  = (MBPrivate)xdrs->x_base;
-struct mbuf *m   = mbp->mcurrent;
-u_int       rval = mbp->pos;
-
-	if (m) {
-		rval += xdrs->x_private - mtod(m, void*);
-	}
-#else
-struct mbuf *m;
-u_int 		rval = 0;
-MBPrivate	mbp  = (MBPrivate)xdrs->x_base;
-
-	for ( m = mbp->mchain; m && m != mbp->mcurrent; m = m->m_next )
-		rval += m->m_len;
-	if (m) {
-		rval += (u_long)xdrs->x_private - mtod(m, u_long);
-	}
-
-#endif
-	return rval;
-}
-
-static bool_t
-xdrmbuf_setpos(
-	XDR *xdrs,
-	u_int pos)
-{
-struct		mbuf *m;
-MBPrivate	mbp   = (MBPrivate)xdrs->x_base;
-
-	if (pos >= mbp->pos) {
-		pos      -= mbp->pos;
-		m         = mbp->mcurrent;
-	} else {
-		m         = mbp->mchain;
-		mbp->pos  = 0;
-	}
-
-	while ( m && pos >= m->m_len ) {
-		pos      -= m->m_len;
-		mbp->pos += m->m_len;
-		m         = m->m_next;
-	}
-
-	if (m) {
-		xdrmbuf_setup(xdrs, m);
-		xdrs->x_private += pos;
-		return TRUE;
-	}
-
-	return 0 == pos ? TRUE : FALSE;
-}
-
-static int32_t *
-xdrmbuf_inline_aligned(
-	XDR *xdrs,
-	u_int len)
-{
-int32_t	*buf = 0;
-
-	if (xdrs->x_handy == 0 && !xdrmbuf_next(xdrs))
-		return 0;
-
-	if (xdrs->x_handy >= len) {
-		xdrs->x_handy -= len;
-		buf = (int32_t *) xdrs->x_private;
-		xdrs->x_private += len;
-#if DEBUG & DEBUG_VERB
-		fprintf(stderr,"Got %i aligned inline bytes at %x\n", len, buf);
-#endif
-	}
-#if DEBUG & DEBUG_VERB
-	else {
-		fprintf(stderr,"Skipped %i aligned inline bytes\n",len);
-	}
-#endif
-	return (buf);
-}
-
-static int32_t *
-xdrmbuf_inline_unaligned(
-	XDR *xdrs,
-	u_int len )
-{
-	return (0);
-}
Index: rvices/telnetd/Makefile
===================================================================
--- services/telnetd/Makefile	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,44 +1,0 @@
-include ../../config.inc
-
-include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
-include $(RTEMS_CUSTOM)
-include $(PROJECT_ROOT)/make/leaf.cfg
-
-CFLAGS += -I $(INSTALL_BASE)/include
-
-CFLAGS += -w 
-CFLAGS += -I include 
-CFLAGS += -std=gnu99
-CFLAGS += -MT $@ -MD -MP -MF $(basename $@).d
-
-C_FILES =
-C_FILES += check_passwd.c
-C_FILES += des.c
-C_FILES += pty.c
-C_FILES += telnetd.c
-# genpw.c is native
-
-C_O_FILES = $(C_FILES:%.c=%.o)
-C_D_FILES = $(C_FILES:%.c=%.d)
-
-LIB = libtelnetd.a
-
-all: $(LIB)
-
-$(LIB): $(C_O_FILES)
-	$(AR) rcu $@ $^
-
-install: $(LIB)
-	install -d $(INSTALL_BASE)/include/rtems
-	install -c -m 644 include/rtems/pty.h $(INSTALL_BASE)/rtems
-	install -c -m 644 include/rtems/telnetd.h $(INSTALL_BASE)/rtems
-	install -c -m 644 include/passwd.h $(INSTALL_BASE)/rtems
-	install -c -m 644 $(LIB) $(INSTALL_BASE)
-
-clean:
-	rm -f $(LIB) $(C_O_FILES) $(C_D_FILES) $(GEN_FILES)
-
--include $(C_D_FILES)
-
-doc: 
-
Index: rvices/telnetd/README
===================================================================
--- services/telnetd/README	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,23 +1,0 @@
-Author: fernando.ruiz@ctv.es (correo@fernando-ruiz.com)
-
-This directory contains a telnetd server
-primary features:
-
-   + create a user shell pseudo-terminal task.
-
-This code has not been extensively tested.  It is provided as a tool
-for RTEMS users to open more shell tcp/ip pseudo-terminal.
-Suggestions and comments are appreciated.
-
-Read libmisc/shell for more information.
-
-NOTES:
-
-1.  OOB not yet implemented. Only a reduced negotiation is implemented.
-    
-2.  If you have tcp/ip initialied you can start telnetd daemon.
-    You need register pseudo-terminals driver into device drivers table.
-
-Enjoy it.
-
-FUTURE:
Index: rvices/telnetd/check_passwd.c
===================================================================
--- services/telnetd/check_passwd.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,107 +1,0 @@
-/*
- * Authorship
- * ----------
- * This software was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2003-2007
- * 	   Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * This software was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- *
- * Copyright (c) 2009 embedded brains GmbH and others.
- *
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <termios.h>
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-
-#include <rtems/telnetd.h>
-
-#include "passwd.h"
-
-char *__des_crypt_r( const char *, const char *, char *, int);
-
-/**
- * @brief Standard Telnet login check that uses DES to encrypt the passphrase.
- *
- * Takes a @a passphrase, encrypts it and compares it to the encrypted
- * passphrase in the @c TELNETD_PASSWD environment variable.  No password is
- * required if @c TELNETD_PASSWD is unset.  The argument @a user is ignored.
- */
-bool rtems_telnetd_login_check(
-  const char *user,
-  const char *passphrase
-)
-{
-  char *pw = getenv( "TELNETD_PASSWD");
-  char cryptbuf [21];
-  char salt [3];
-
-  if (pw == NULL || strlen( pw) == 0) {
-    #ifdef TELNETD_DEFAULT_PASSWD
-      pw = TELNETD_DEFAULT_PASSWD;
-    #else
-      return true;
-    #endif
-  }
-
-  strncpy( salt, pw, 2);
-  salt [2] = '\0';
-
-  return strcmp(
-    __des_crypt_r( passphrase, salt, cryptbuf, sizeof( cryptbuf)),
-    pw
-  ) == 0;
-}
Index: rvices/telnetd/des.c
===================================================================
--- services/telnetd/des.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,879 +1,0 @@
-/*
- * FreeSec: libcrypt for NetBSD
- *
- * Copyright (c) 1994 David Burren
- * All rights reserved.
- *
- * Ported to RTEMS and made reentrant by Till Straumann, 9/2003
- *
- * Adapted for FreeBSD-2.0 by Geoffrey M. Rehmet
- *	this file should now *only* export crypt(), in order to make
- *	binaries of libcrypt exportable from the USA
- *
- * Adapted for FreeBSD-4.0 by Mark R V Murray
- *	this file should now *only* export crypt_des(), in order to make
- *	a module that can be optionally included in libcrypt.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of other contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This is an original implementation of the DES and the crypt(3) interfaces
- * by David Burren <davidb@werj.com.au>.
- *
- * An excellent reference on the underlying algorithm (and related
- * algorithms) is:
- *
- *	B. Schneier, Applied Cryptography: protocols, algorithms,
- *	and source code in C, John Wiley & Sons, 1994.
- *
- * Note that in that book's description of DES the lookups for the initial,
- * pbox, and final permutations are inverted (this has been brought to the
- * attention of the author).  A list of errata for this book has been
- * posted to the sci.crypt newsgroup by the author and is available for FTP.
- *
- * ARCHITECTURE ASSUMPTIONS:
- *	It is assumed that the 8-byte arrays passed by reference can be
- *	addressed as arrays of u_int32_t's (ie. the CPU is not picky about
- *	alignment).
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define __FORCE_GLIBC
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#ifndef __rtems__
-#include <pwd.h>
-#include <string.h>
-#include <crypt.h>
-#endif
-#include <stdlib.h>
-
-#define REENTRANT
-/* Re-entrantify me -- all this junk needs to be in
- * struct crypt_data to make this really reentrant... */
-
-/* TS; not really - only the stuff in Des_Context */
-static struct fixed1 {
-u_char	inv_key_perm[64];
-u_char	inv_comp_perm[56];
-u_char	u_sbox[8][64];
-u_char	un_pbox[32];
-} des1_f;
-static struct fixed2 {
-u_int32_t ip_maskl[8][256], ip_maskr[8][256];
-} des2_f;
-static struct fixed3 {
-u_int32_t fp_maskl[8][256], fp_maskr[8][256];
-} des3_f;
-static struct fixed4 {
-u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
-u_int32_t comp_maskl[8][128], comp_maskr[8][128];
-} des4_f;
-
-#define	inv_key_perm des1_f.inv_key_perm
-#define	inv_comp_perm des1_f.inv_comp_perm
-#define	u_sbox des1_f.u_sbox
-#define	un_pbox des1_f.un_pbox
-#define ip_maskl des2_f.ip_maskl
-#define ip_maskr des2_f.ip_maskr
-#define fp_maskl des3_f.fp_maskl
-#define fp_maskr des3_f.fp_maskr
-#define key_perm_maskl des4_f.key_perm_maskl
-#define key_perm_maskr des4_f.key_perm_maskr
-#define comp_maskl des4_f.comp_maskl
-#define comp_maskr des4_f.comp_maskr
-
-/* These need to be maintained per-process */
-struct Des_Context {
-u_int32_t en_keysl[16], en_keysr[16];
-u_int32_t de_keysl[16], de_keysr[16];
-u_int32_t saltbits;
-u_int32_t old_salt;
-u_int32_t old_rawkey0, old_rawkey1;
-};
-
-#ifndef REENTRANT
-static struct Des_Context single;
-#endif
-
-#define en_keysl des_ctx->en_keysl
-#define en_keysr des_ctx->en_keysr
-#define de_keysl des_ctx->de_keysl
-#define de_keysr des_ctx->de_keysr
-#define saltbits des_ctx->saltbits
-#define old_salt des_ctx->old_salt
-#define old_rawkey0 des_ctx->old_rawkey0
-#define old_rawkey1 des_ctx->old_rawkey1
-
-/* Static stuff that stays resident and doesn't change after
- * being initialized, and therefore doesn't need to be made
- * reentrant. */
-static u_char	init_perm[64], final_perm[64];
-static u_char	m_sbox[4][4096];
-static u_int32_t psbox[4][256];
-
-
-
-
-/* A pile of data */
-static const u_char	ascii64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
-static const u_char	IP[64] = {
-  58, 50, 42, 34, 26, 18, 10,  2, 60, 52, 44, 36, 28, 20, 12,  4,
-  62, 54, 46, 38, 30, 22, 14,  6, 64, 56, 48, 40, 32, 24, 16,  8,
-  57, 49, 41, 33, 25, 17,  9,  1, 59, 51, 43, 35, 27, 19, 11,  3,
-  61, 53, 45, 37, 29, 21, 13,  5, 63, 55, 47, 39, 31, 23, 15,  7
-};
-
-static const u_char	key_perm[56] = {
-  57, 49, 41, 33, 25, 17,  9,  1, 58, 50, 42, 34, 26, 18,
-  10,  2, 59, 51, 43, 35, 27, 19, 11,  3, 60, 52, 44, 36,
-  63, 55, 47, 39, 31, 23, 15,  7, 62, 54, 46, 38, 30, 22,
-  14,  6, 61, 53, 45, 37, 29, 21, 13,  5, 28, 20, 12,  4
-};
-
-static const u_char	key_shifts[16] = {
-  1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
-};
-
-static const u_char	comp_perm[48] = {
-  14, 17, 11, 24,  1,  5,  3, 28, 15,  6, 21, 10,
-  23, 19, 12,  4, 26,  8, 16,  7, 27, 20, 13,  2,
-  41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
-  44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
-};
-
-/*
- *	No E box is used, as it's replaced by some ANDs, shifts, and ORs.
- */
-
-static const u_char	sbox[8][64] = {
-  {
-    14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7,
-     0, 15,  7,  4, 14,  2, 13,  1, 10,  6, 12, 11,  9,  5,  3,  8,
-     4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0,
-    15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13
-  },
-  {
-    15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10,
-     3, 13,  4,  7, 15,  2,  8, 14, 12,  0,  1, 10,  6,  9, 11,  5,
-     0, 14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15,
-    13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5, 14,  9
-  },
-  {
-    10,  0,  9, 14,  6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8,
-    13,  7,  0,  9,  3,  4,  6, 10,  2,  8,  5, 14, 12, 11, 15,  1,
-    13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7,
-     1, 10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12
-  },
-  {
-     7, 13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4, 15,
-    13,  8, 11,  5,  6, 15,  0,  3,  4,  7,  2, 12,  1, 10, 14,  9,
-    10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,  4,
-     3, 15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2, 14
-  },
-  {
-     2, 12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9,
-    14, 11,  2, 12,  4,  7, 13,  1,  5,  0, 15, 10,  3,  9,  8,  6,
-     4,  2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14,
-    11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3
-  },
-  {
-    12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11,
-    10, 15,  4,  2,  7, 12,  9,  5,  6,  1, 13, 14,  0, 11,  3,  8,
-     9, 14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6,
-     4,  3,  2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13
-  },
-  {
-     4, 11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1,
-    13,  0, 11,  7,  4,  9,  1, 10, 14,  3,  5, 12,  2, 15,  8,  6,
-     1,  4, 11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2,
-     6, 11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12
-  },
-  {
-    13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7,
-     1, 15, 13,  8, 10,  3,  7,  4, 12,  5,  6, 11,  0, 14,  9,  2,
-     7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8,
-     2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11
-  }
-};
-
-static const u_char	pbox[32] = {
-  16,  7, 20, 21, 29, 12, 28, 17,  1, 15, 23, 26,  5, 18, 31, 10,
-   2,  8, 24, 14, 32, 27,  3,  9, 19, 13, 30,  6, 22, 11,  4, 25
-};
-
-static const u_int32_t bits32[32] =
-{
-  0x80000000, 0x40000000, 0x20000000, 0x10000000,
-  0x08000000, 0x04000000, 0x02000000, 0x01000000,
-  0x00800000, 0x00400000, 0x00200000, 0x00100000,
-  0x00080000, 0x00040000, 0x00020000, 0x00010000,
-  0x00008000, 0x00004000, 0x00002000, 0x00001000,
-  0x00000800, 0x00000400, 0x00000200, 0x00000100,
-  0x00000080, 0x00000040, 0x00000020, 0x00000010,
-  0x00000008, 0x00000004, 0x00000002, 0x00000001
-};
-
-static const u_char	bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
-static const u_int32_t *bits28, *bits24;
-
-
-static int
-ascii_to_bin(char ch)
-{
-  if (ch > 'z')
-    return(0);
-  if (ch >= 'a')
-    return(ch - 'a' + 38);
-  if (ch > 'Z')
-    return(0);
-  if (ch >= 'A')
-    return(ch - 'A' + 12);
-  if (ch > '9')
-    return(0);
-  if (ch >= '.')
-    return(ch - '.');
-  return(0);
-}
-
-struct Des_Context *
-des_ctx_init(void)
-{
-struct Des_Context *des_ctx;
-#ifdef REENTRANT
-  des_ctx = malloc(sizeof(*des_ctx));
-#else
-  des_ctx = &single;
-#endif
-  old_rawkey0 = old_rawkey1 = 0L;
-  saltbits = 0L;
-  old_salt = 0L;
-
-  return des_ctx;
-}
-
-static void
-des_init(void)
-{
-  int	i, j, b, k, inbit, obit;
-  u_int32_t	*p, *il, *ir, *fl, *fr;
-  static int des_initialised = 0;
-
-  if (des_initialised==1)
-      return;
-
-#ifndef REENTRANT
-  des_ctx_init();
-#endif
-
-  bits24 = (bits28 = bits32 + 4) + 4;
-
-  /*
-   * Invert the S-boxes, reordering the input bits.
-   */
-  for (i = 0; i < 8; i++)
-    for (j = 0; j < 64; j++) {
-      b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf);
-      u_sbox[i][j] = sbox[i][b];
-    }
-
-  /*
-   * Convert the inverted S-boxes into 4 arrays of 8 bits.
-   * Each will handle 12 bits of the S-box input.
-   */
-  for (b = 0; b < 4; b++)
-    for (i = 0; i < 64; i++)
-      for (j = 0; j < 64; j++)
-        m_sbox[b][(i << 6) | j] =
-          (u_char)((u_sbox[(b << 1)][i] << 4) |
-          u_sbox[(b << 1) + 1][j]);
-
-  /*
-   * Set up the initial & final permutations into a useful form, and
-   * initialise the inverted key permutation.
-   */
-  for (i = 0; i < 64; i++) {
-    init_perm[final_perm[i] = IP[i] - 1] = (u_char)i;
-    inv_key_perm[i] = 255;
-  }
-
-  /*
-   * Invert the key permutation and initialise the inverted key
-   * compression permutation.
-   */
-  for (i = 0; i < 56; i++) {
-    inv_key_perm[key_perm[i] - 1] = (u_char)i;
-    inv_comp_perm[i] = 255;
-  }
-
-  /*
-   * Invert the key compression permutation.
-   */
-  for (i = 0; i < 48; i++) {
-    inv_comp_perm[comp_perm[i] - 1] = (u_char)i;
-  }
-
-  /*
-   * Set up the OR-mask arrays for the initial and final permutations,
-   * and for the key initial and compression permutations.
-   */
-  for (k = 0; k < 8; k++) {
-    for (i = 0; i < 256; i++) {
-      *(il = &ip_maskl[k][i]) = 0L;
-      *(ir = &ip_maskr[k][i]) = 0L;
-      *(fl = &fp_maskl[k][i]) = 0L;
-      *(fr = &fp_maskr[k][i]) = 0L;
-      for (j = 0; j < 8; j++) {
-        inbit = 8 * k + j;
-        if (i & bits8[j]) {
-          if ((obit = init_perm[inbit]) < 32)
-            *il |= bits32[obit];
-          else
-            *ir |= bits32[obit-32];
-          if ((obit = final_perm[inbit]) < 32)
-            *fl |= bits32[obit];
-          else
-            *fr |= bits32[obit - 32];
-        }
-      }
-    }
-    for (i = 0; i < 128; i++) {
-      *(il = &key_perm_maskl[k][i]) = 0L;
-      *(ir = &key_perm_maskr[k][i]) = 0L;
-      for (j = 0; j < 7; j++) {
-        inbit = 8 * k + j;
-        if (i & bits8[j + 1]) {
-          if ((obit = inv_key_perm[inbit]) == 255)
-            continue;
-          if (obit < 28)
-            *il |= bits28[obit];
-          else
-            *ir |= bits28[obit - 28];
-        }
-      }
-      *(il = &comp_maskl[k][i]) = 0L;
-      *(ir = &comp_maskr[k][i]) = 0L;
-      for (j = 0; j < 7; j++) {
-        inbit = 7 * k + j;
-        if (i & bits8[j + 1]) {
-          if ((obit=inv_comp_perm[inbit]) == 255)
-            continue;
-          if (obit < 24)
-            *il |= bits24[obit];
-          else
-            *ir |= bits24[obit - 24];
-        }
-      }
-    }
-  }
-
-  /*
-   * Invert the P-box permutation, and convert into OR-masks for
-   * handling the output of the S-box arrays setup above.
-   */
-  for (i = 0; i < 32; i++)
-    un_pbox[pbox[i] - 1] = (u_char)i;
-
-  for (b = 0; b < 4; b++)
-    for (i = 0; i < 256; i++) {
-      *(p = &psbox[b][i]) = 0L;
-      for (j = 0; j < 8; j++) {
-        if (i & bits8[j])
-          *p |= bits32[un_pbox[8 * b + j]];
-      }
-    }
-
-  des_initialised = 1;
-}
-
-
-static void
-setup_salt(long salt, struct Des_Context *des_ctx)
-{
-  u_int32_t	obit, saltbit;
-  int	i;
-
-  if (salt == old_salt)
-    return;
-  old_salt = salt;
-
-  saltbits = 0L;
-  saltbit = 1;
-  obit = 0x800000;
-  for (i = 0; i < 24; i++) {
-    if (salt & saltbit)
-      saltbits |= obit;
-    saltbit <<= 1;
-    obit >>= 1;
-  }
-}
-
-
-static int
-des_setkey(const char *key, struct Des_Context *des_ctx)
-{
-  u_int32_t	k0, k1, rawkey0, rawkey1;
-  int		shifts, round;
-
-  des_init();
-
-  rawkey0 = ntohl(*(const u_int32_t *) key);
-  rawkey1 = ntohl(*(const u_int32_t *) (key + 4));
-
-  if ((rawkey0 | rawkey1)
-      && rawkey0 == old_rawkey0
-      && rawkey1 == old_rawkey1) {
-    /*
-     * Already setup for this key.
-     * This optimisation fails on a zero key (which is weak and
-     * has bad parity anyway) in order to simplify the starting
-     * conditions.
-     */
-    return(0);
-  }
-  old_rawkey0 = rawkey0;
-  old_rawkey1 = rawkey1;
-
-  /*
-   *	Do key permutation and split into two 28-bit subkeys.
-   */
-  k0 = key_perm_maskl[0][rawkey0 >> 25]
-     | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f]
-     | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f]
-     | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f]
-     | key_perm_maskl[4][rawkey1 >> 25]
-     | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f]
-     | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f]
-     | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f];
-  k1 = key_perm_maskr[0][rawkey0 >> 25]
-     | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f]
-     | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f]
-     | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f]
-     | key_perm_maskr[4][rawkey1 >> 25]
-     | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f]
-     | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f]
-     | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f];
-  /*
-   *	Rotate subkeys and do compression permutation.
-   */
-  shifts = 0;
-  for (round = 0; round < 16; round++) {
-    u_int32_t	t0, t1;
-
-    shifts += key_shifts[round];
-
-    t0 = (k0 << shifts) | (k0 >> (28 - shifts));
-    t1 = (k1 << shifts) | (k1 >> (28 - shifts));
-
-    de_keysl[15 - round] =
-    en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f]
-        | comp_maskl[1][(t0 >> 14) & 0x7f]
-        | comp_maskl[2][(t0 >> 7) & 0x7f]
-        | comp_maskl[3][t0 & 0x7f]
-        | comp_maskl[4][(t1 >> 21) & 0x7f]
-        | comp_maskl[5][(t1 >> 14) & 0x7f]
-        | comp_maskl[6][(t1 >> 7) & 0x7f]
-        | comp_maskl[7][t1 & 0x7f];
-
-    de_keysr[15 - round] =
-    en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f]
-        | comp_maskr[1][(t0 >> 14) & 0x7f]
-        | comp_maskr[2][(t0 >> 7) & 0x7f]
-        | comp_maskr[3][t0 & 0x7f]
-        | comp_maskr[4][(t1 >> 21) & 0x7f]
-        | comp_maskr[5][(t1 >> 14) & 0x7f]
-        | comp_maskr[6][(t1 >> 7) & 0x7f]
-        | comp_maskr[7][t1 & 0x7f];
-  }
-  return(0);
-}
-
-
-static int
-do_des(	u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out, int count, struct Des_Context *des_ctx)
-{
-  /*
-   *	l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
-   */
-  u_int32_t	l, r, *kl, *kr, *kl1, *kr1;
-  u_int32_t	f, r48l, r48r;
-  int		round;
-
-  if (count == 0) {
-    return(1);
-  } else if (count > 0) {
-    /*
-     * Encrypting
-     */
-    kl1 = en_keysl;
-    kr1 = en_keysr;
-  } else {
-    /*
-     * Decrypting
-     */
-    count = -count;
-    kl1 = de_keysl;
-    kr1 = de_keysr;
-  }
-
-  /*
-   *	Do initial permutation (IP).
-   */
-  l = ip_maskl[0][l_in >> 24]
-    | ip_maskl[1][(l_in >> 16) & 0xff]
-    | ip_maskl[2][(l_in >> 8) & 0xff]
-    | ip_maskl[3][l_in & 0xff]
-    | ip_maskl[4][r_in >> 24]
-    | ip_maskl[5][(r_in >> 16) & 0xff]
-    | ip_maskl[6][(r_in >> 8) & 0xff]
-    | ip_maskl[7][r_in & 0xff];
-  r = ip_maskr[0][l_in >> 24]
-    | ip_maskr[1][(l_in >> 16) & 0xff]
-    | ip_maskr[2][(l_in >> 8) & 0xff]
-    | ip_maskr[3][l_in & 0xff]
-    | ip_maskr[4][r_in >> 24]
-    | ip_maskr[5][(r_in >> 16) & 0xff]
-    | ip_maskr[6][(r_in >> 8) & 0xff]
-    | ip_maskr[7][r_in & 0xff];
-
-  while (count--) {
-    /*
-     * Do each round.
-     */
-    kl = kl1;
-    kr = kr1;
-    round = 16;
-    while (round--) {
-      /*
-       * Expand R to 48 bits (simulate the E-box).
-       */
-      r48l	= ((r & 0x00000001) << 23)
-        | ((r & 0xf8000000) >> 9)
-        | ((r & 0x1f800000) >> 11)
-        | ((r & 0x01f80000) >> 13)
-        | ((r & 0x001f8000) >> 15);
-
-      r48r	= ((r & 0x0001f800) << 7)
-        | ((r & 0x00001f80) << 5)
-        | ((r & 0x000001f8) << 3)
-        | ((r & 0x0000001f) << 1)
-        | ((r & 0x80000000) >> 31);
-      /*
-       * Do salting for crypt() and friends, and
-       * XOR with the permuted key.
-       */
-      f = (r48l ^ r48r) & saltbits;
-      r48l ^= f ^ *kl++;
-      r48r ^= f ^ *kr++;
-      /*
-       * Do sbox lookups (which shrink it back to 32 bits)
-       * and do the pbox permutation at the same time.
-       */
-      f = psbox[0][m_sbox[0][r48l >> 12]]
-        | psbox[1][m_sbox[1][r48l & 0xfff]]
-        | psbox[2][m_sbox[2][r48r >> 12]]
-        | psbox[3][m_sbox[3][r48r & 0xfff]];
-      /*
-       * Now that we've permuted things, complete f().
-       */
-      f ^= l;
-      l = r;
-      r = f;
-    }
-    r = l;
-    l = f;
-  }
-  /*
-   * Do final permutation (inverse of IP).
-   */
-  *l_out	= fp_maskl[0][l >> 24]
-    | fp_maskl[1][(l >> 16) & 0xff]
-    | fp_maskl[2][(l >> 8) & 0xff]
-    | fp_maskl[3][l & 0xff]
-    | fp_maskl[4][r >> 24]
-    | fp_maskl[5][(r >> 16) & 0xff]
-    | fp_maskl[6][(r >> 8) & 0xff]
-    | fp_maskl[7][r & 0xff];
-  *r_out	= fp_maskr[0][l >> 24]
-    | fp_maskr[1][(l >> 16) & 0xff]
-    | fp_maskr[2][(l >> 8) & 0xff]
-    | fp_maskr[3][l & 0xff]
-    | fp_maskr[4][r >> 24]
-    | fp_maskr[5][(r >> 16) & 0xff]
-    | fp_maskr[6][(r >> 8) & 0xff]
-    | fp_maskr[7][r & 0xff];
-  return(0);
-}
-
-
-#if 0
-static int
-des_cipher(const char *in, char *out, u_int32_t salt, int count)
-{
-  u_int32_t	l_out, r_out, rawl, rawr;
-  int		retval;
-  union {
-    u_int32_t	*ui32;
-    const char	*c;
-  } trans;
-
-  des_init();
-
-  setup_salt(salt);
-
-  trans.c = in;
-  rawl = ntohl(*trans.ui32++);
-  rawr = ntohl(*trans.ui32);
-
-  retval = do_des(rawl, rawr, &l_out, &r_out, count);
-
-  trans.c = out;
-  *trans.ui32++ = htonl(l_out);
-  *trans.ui32 = htonl(r_out);
-  return(retval);
-}
-#endif
-
-
-#ifndef REENTRANT
-void
-setkey(const char *key)
-{
-  int	i, j;
-  u_int32_t	packed_keys[2];
-  u_char	*p;
-
-  p = (u_char *) packed_keys;
-
-  for (i = 0; i < 8; i++) {
-    p[i] = 0;
-    for (j = 0; j < 8; j++)
-      if (*key++ & 1)
-        p[i] |= bits8[j];
-  }
-  des_setkey(p, &single);
-}
-#endif
-
-
-#ifndef REENTRANT
-void
-encrypt(char *block, int flag)
-{
-  u_int32_t	io[2];
-  u_char	*p;
-  int	i, j;
-
-  des_init();
-
-  setup_salt(0L, &single);
-  p = block;
-  for (i = 0; i < 2; i++) {
-    io[i] = 0L;
-    for (j = 0; j < 32; j++)
-      if (*p++ & 1)
-        io[i] |= bits32[j];
-  }
-  do_des(io[0], io[1], io, io + 1, flag ? -1 : 1, &single);
-  for (i = 0; i < 2; i++)
-    for (j = 0; j < 32; j++)
-      block[(i << 5) | j] = (io[i] & bits32[j]) ? 1 : 0;
-}
-
-#endif
-
-char *
-__des_crypt_r(const char *key, const char *setting, char *output, int sz)
-{
-  char *rval = 0;
-  struct Des_Context *des_ctx;
-  u_int32_t	count, salt, l, r0, r1, keybuf[2];
-  u_char		*p, *q;
-
-  if (sz < 21)
-    return NULL;
-
-  des_init();
-  des_ctx = des_ctx_init();
-
-  /*
-   * Copy the key, shifting each character up by one bit
-   * and padding with zeros.
-   */
-  q = (u_char *)keybuf;
-  while (q - (u_char *)keybuf - 8) {
-    *q++ = *key << 1;
-    if (*(q - 1))
-      key++;
-  }
-  if (des_setkey((char *)keybuf, des_ctx))
-    goto bailout;
-
-#if 0
-  if (*setting == _PASSWORD_EFMT1) {
-    int		i;
-    /*
-     * "new"-style:
-     *	setting - underscore, 4 bytes of count, 4 bytes of salt
-     *	key - unlimited characters
-     */
-    for (i = 1, count = 0L; i < 5; i++)
-      count |= ascii_to_bin(setting[i]) << ((i - 1) * 6);
-
-    for (i = 5, salt = 0L; i < 9; i++)
-      salt |= ascii_to_bin(setting[i]) << ((i - 5) * 6);
-
-    while (*key) {
-      /*
-       * Encrypt the key with itself.
-       */
-      if (des_cipher((char *)keybuf, (char *)keybuf, 0L, 1))
-        goto bailout;
-      /*
-       * And XOR with the next 8 characters of the key.
-       */
-      q = (u_char *)keybuf;
-      while (q - (u_char *)keybuf - 8 && *key)
-        *q++ ^= *key++ << 1;
-
-      if (des_setkey((char *)keybuf))
-        goto bailout;
-    }
-    strncpy(output, setting, 9);
-
-    /*
-     * Double check that we weren't given a short setting.
-     * If we were, the above code will probably have created
-     * wierd values for count and salt, but we don't really care.
-     * Just make sure the output string doesn't have an extra
-     * NUL in it.
-     */
-    output[9] = '\0';
-    p = (u_char *)output + strlen(output);
-  } else
-#endif
-  {
-    /*
-     * "old"-style:
-     *	setting - 2 bytes of salt
-     *	key - up to 8 characters
-     */
-    count = 25;
-
-    salt = (ascii_to_bin(setting[1]) << 6)
-         |  ascii_to_bin(setting[0]);
-
-    output[0] = setting[0];
-    /*
-     * If the encrypted password that the salt was extracted from
-     * is only 1 character long, the salt will be corrupted.  We
-     * need to ensure that the output string doesn't have an extra
-     * NUL in it!
-     */
-    output[1] = setting[1] ? setting[1] : output[0];
-
-    p = (u_char *)output + 2;
-  }
-  setup_salt(salt, des_ctx);
-  /*
-   * Do it.
-   */
-  if (do_des(0L, 0L, &r0, &r1, (int)count, des_ctx))
-    goto bailout;
-  /*
-   * Now encode the result...
-   */
-  l = (r0 >> 8);
-  *p++ = ascii64[(l >> 18) & 0x3f];
-  *p++ = ascii64[(l >> 12) & 0x3f];
-  *p++ = ascii64[(l >> 6) & 0x3f];
-  *p++ = ascii64[l & 0x3f];
-
-  l = (r0 << 16) | ((r1 >> 16) & 0xffff);
-  *p++ = ascii64[(l >> 18) & 0x3f];
-  *p++ = ascii64[(l >> 12) & 0x3f];
-  *p++ = ascii64[(l >> 6) & 0x3f];
-  *p++ = ascii64[l & 0x3f];
-
-  l = r1 << 2;
-  *p++ = ascii64[(l >> 12) & 0x3f];
-  *p++ = ascii64[(l >> 6) & 0x3f];
-  *p++ = ascii64[l & 0x3f];
-  *p = 0;
-
-  rval = output;
-bailout:
-  free(des_ctx);
-  return rval;
-}
-
-char *
-__des_crypt(const char *key, const char *setting)
-{
-  static char	output[21];
-  return __des_crypt_r(key, setting, output, sizeof(output));
-}
-
-
-#ifdef DEBUG
-
-void
-des_snap(void **pf, void **pd)
-{
-  uint8* pfc;
-  *pf = malloc(sizeof(struct fixed1) + sizeof(struct fixed2) + sizeof(struct fixed3) + sizeof(struct fixed4));
-  pfc = *pf;
-  memcpy(pfc, &des1_f, sizeof(des1_f));
-  pfc += sizeof(des1_f);
-  memcpy(pfc, &des2_f, sizeof(des2_f));
-  pfc += sizeof(des2_f);
-  memcpy(pfc, &des3_f, sizeof(des3_f));
-  pfc += sizeof(des3_f);
-  memcpy(pfc, &des4_f, sizeof(des4_f));
-//	*pd = malloc(sizeof(struct Des_Context));
-//	memcpy(*pd, &des_ctx, sizeof(des_ctx));
-}
-
-void
-des_check(void *pf, void *pd)
-{
-  uint8* pfc1, pfc2, pfc3, pfc4;
-  pfc1 = pf;
-  pfc2 = pfc1 + sizeof(des1_f);
-  pfc3 = pfc2 + sizeof(des2_f);
-  pfc4 = pfc3 + sizeof(des3_f);
-  printf("Fixed: do%s differ"/*", Context: do%s differ"*/"\n",
-         (memcmp(pfc1, &des1_f, sizeof(des1_f)) ||
-          memcmp(pfc2, &des2_f, sizeof(des2_f)) ||
-          memcmp(pfc3, &des4_f, sizeof(des3_f)) ||
-          memcmp(pfc4, &des4_f, sizeof(des4_f))) ? "" : "nt");
-}
-
-#endif
Index: rvices/telnetd/genpw.c
===================================================================
--- services/telnetd/genpw.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,79 +1,0 @@
-/*
- * Authorship
- * ----------
- * This software was created by
- *     Till Straumann <strauman@slac.stanford.edu>, 2003-2007
- * 	   Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * This software was produced by
- *     the Stanford Linear Accelerator Center, Stanford University,
- * 	   under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software.  Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <crypt.h>
-#include <stdio.h>
-#include <unistd.h>
-
-static void
-usage(char *nm)
-{
-  fprintf(stderr,"Usage: %s [-h] [-s salt] cleartext_password\n", nm);
-}
-
-int
-main(int argc, char **argv)
-{
-int ch;
-char *salt="td";
-  while ( (ch=getopt(argc, argv, "hs:")) >=0 ) {
-    switch (ch) {
-      default:  fprintf(stderr,"Unknown Option '%c'\n",ch);
-      case 'h': usage(argv[0]);
-      return 0;
-      case 's': salt=optarg;
-      break;
-    }
-  }
-  if ( optind >= argc ) {
-    usage(argv[0]);
-    return 1;
-  }
-  printf("#define TELNETD_DEFAULT_PASSWD \"%s\"\n",crypt(argv[optind],salt));
-}
Index: rvices/telnetd/include/passwd.h
===================================================================
--- services/telnetd/include/passwd.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,25 +1,0 @@
-/* Define a default password for telnetd here.
- * NOTES:
- *  - this can be overridden at run-time by setting
- *    the "TELNETD_PASSWD" environment variable.
- *    As soon as that variable is set, the new password
- *    is effective - no need to restart telnetd.
- *  - this must be set to an _encrypted_ password, NOT
- *    the cleartext. Use the 'genpw' utility to generate
- *    a password string:
- *
- *    1) Compile 'genpw.c' for the HOST, i.e.
- *         cc -o genpw genpw.c -lcrypt
- *    1) delete an old password definition from this file.
- *    2) run './genpw >> passwd.h'. This will append
- *       a new definition to this file.
- *
- *  - if no password is defined here, no authentication
- *    is needed, i.e. telnet is open to the world.
- *
- *    T. Straumann <strauman@slac.stanford.edu>
- */
-
-/* #undef TELNETD_DEFAULT_PASSWD */
-/* Default password: 'rtems' */
-#define TELNETD_DEFAULT_PASSWD "tduDcyLX12owo"
Index: rvices/telnetd/include/rtems/pty.h
===================================================================
--- services/telnetd/include/rtems/pty.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * /dev/ptyXX  (A first version for pseudo-terminals)
- *
- *  Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es)
- *  May 2001
- *
- *  This program 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.
- */
-
-#ifndef _RTEMS_PTY_H
-#define _RTEMS_PTY_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif	
-
-#include <rtems.h>	
-
-/* Number of ptys to setup */
-extern size_t rtems_pty_maximum_ptys;
-
-/* Return the devname for a free pty slot.
- * If no slot available (socket>=0)
- * then the socket argument is closed
- */
-char * rtems_pty_get(int socket);
-
-
-/* OBSOLETE */
-#define get_pty		rtems_pty_get
-
-rtems_device_driver pty_initialize(
-  rtems_device_major_number  major,
-  rtems_device_minor_number  minor,
-  void                      *arg);
-rtems_device_driver pty_open(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg);
-rtems_device_driver pty_close(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg);
-rtems_device_driver pty_read(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg);
-rtems_device_driver pty_write(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg);
-rtems_device_driver pty_control(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg);
-
-
-#define PTY_DRIVER_TABLE_ENTRY \
-       { pty_initialize , pty_open , pty_close , \
-   pty_read , pty_write , pty_control }
-
-#ifdef __cplusplus
-}
-#endif	
-
-#endif
Index: rvices/telnetd/include/rtems/telnetd.h
===================================================================
--- services/telnetd/include/rtems/telnetd.h	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,110 +1,0 @@
-/*
- *  Original Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es)
- *  May 2001
- *  Reworked by Till Straumann and .h overhauled by Joel Sherrill.
- *
- * Copyright (c) 2009 embedded brains GmbH and others.
- *
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifndef _RTEMS_TELNETD_H
-#define _RTEMS_TELNETD_H
-
-#include <rtems.h>
-#include <rtems/shell.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-bool rtems_telnetd_login_check(
-  const char *user,
-  const char *passphrase
-);
-
-/**
- * @brief Telnet command type.
- */
-typedef void (*rtems_telnetd_command)(
-  char * /* device name */,
-  void * /* arg */
-);
-
-/**
- * @brief Telnet configuration structure.
- */
-typedef struct {
-  /**
-   * @brief Function invoked for each Telnet connection.
-   *
-   * The first parameter contains the device name.  The second parameter
-   * contains the argument pointer of this configuration table.
-   */
-  rtems_telnetd_command command;
-
-  /**
-   * @brief Argument for command function.
-   */
-  void *arg;
-
-  /**
-   * @brief Task priority.
-   *
-   * If this parameter is equal to zero, then the priority of network task is
-   * used or 100 if this priority is less than two.
-   */
-  rtems_task_priority priority;
-
-  /**
-   * @brief Task stack size.
-   */
-  size_t stack_size;
-
-  /**
-   * @brief Login check function.
-   *
-   * Method used for login checks.  Use @c NULL to disable a login check.
-   */
-  rtems_shell_login_check_t login_check;
-
-  /**
-   * @brief Keep standard IO of the caller.
-   *
-   * Telnet takes over the standard input, output and error associated with
-   * task, if this parameter is set to @c true.  In this case, it will @b not
-   * listen on any sockets.  When this parameter is @c false, Telnet will
-   * create other tasks for the shell which listen on sockets.
-   */
-  bool keep_stdio;
-} rtems_telnetd_config_table;
-
-/**
- * @brief Telnet configuration.
- *
- * The application must provide this configuration table.  It is used by
- * rtems_telnetd_initialize() to configure the Telnet subsystem.  Do not modify
- * the entries after the intialization since it is used internally.
- */
-extern rtems_telnetd_config_table rtems_telnetd_config;
-
-/**
- * @brief Initializes the Telnet subsystem.
- *
- * Uses the application provided @ref rtems_telnetd_config configuration table.
- */
-rtems_status_code rtems_telnetd_initialize(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
Index: rvices/telnetd/pty.c
===================================================================
--- services/telnetd/pty.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,652 +1,0 @@
-/*
- * /dev/ptyXX  (Support for pseudo-terminals)
- *
- *  Original Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es)
- *  May 2001
- *
- *  This program 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.
- *
- *  Till Straumann <strauman@slac.stanford.edu>
- *
- *   - converted into a loadable module
- *   - NAWS support / ioctls for querying/setting the window
- *     size added.
- *   - don't delete the running task when the connection
- *     is closed. Rather let 'read()' return a 0 count so
- *     they may cleanup. Some magic hack works around termios
- *     limitation.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define DEBUG_WH    (1<<0)
-#define DEBUG_DETAIL  (1<<1)
-
-/* #define DEBUG DEBUG_WH */
-
-/*-----------------------------------------*/
-#include <termios.h>
-#include <rtems/termiostypes.h>
-#include <sys/ttycom.h>
-#include <rtems.h>
-#include <rtems/libio.h>
-#include <rtems/bspIo.h>
-#include <errno.h>
-#include <sys/socket.h>
-/*-----------------------------------------*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-/*-----------------------------------------*/
-#define IAC_ESC    255
-#define IAC_DONT   254
-#define IAC_DO     253
-#define IAC_WONT   252
-#define IAC_WILL   251
-#define IAC_SB     250
-#define IAC_GA     249
-#define IAC_EL     248
-#define IAC_EC     247
-#define IAC_AYT    246
-#define IAC_AO     245
-#define IAC_IP     244
-#define IAC_BRK    243
-#define IAC_DMARK  242
-#define IAC_NOP    241
-#define IAC_SE     240
-#define IAC_EOR    239
-
-#define SB_MAX    16
-
-extern int rtems_telnetd_maximum_ptys;
-
-struct pty_tt;
-typedef struct pty_tt pty_t;
-
-struct pty_tt {
- char                     *devname;
- struct rtems_termios_tty *ttyp;
- tcflag_t                  c_cflag;
- int                       opened;
- int                       socket;
- int                       last_cr;
- unsigned                  iac_mode;
- unsigned char             sb_buf[SB_MAX];
- int                       sb_ind;
- int                       width;
- int                       height;
-};
-
-
-static int    telnet_pty_inited=FALSE;
-static pty_t *telnet_ptys;
-
-static rtems_device_major_number pty_major;
-
-
-/* This procedure returns the devname for a pty slot free.
- * If not slot availiable (field socket>=0)
- *  then the socket argument is closed
- */
-
-char *  telnet_get_pty(int socket)
-{
-  int ndx;
-
-  if (telnet_pty_inited) {
-#if 0
-    if ( rtems_telnetd_maximum_ptys < 5 )
-      rtems_telnetd_maximum_ptys = 5;
-
-    telnet_ptys = malloc( rtems_telnetd_maximum_ptys * sizeof (pty_t) );
-#endif
-    if ( !telnet_ptys ) {
-      return NULL;
-    }
-
-    for (ndx=0;ndx<rtems_telnetd_maximum_ptys;ndx++) {
-
-      if (telnet_ptys[ndx].socket<0) {
-        struct timeval t;
-        /* set a long polling interval to save CPU time */
-        t.tv_sec=2;
-        t.tv_usec=00000;
-        setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &t, sizeof(t));
-        telnet_ptys[ndx].socket=socket;
-        return telnet_ptys[ndx].devname;
-      };
-    };
-  }
-  close(socket);
-  return NULL;
-}
-
-
-/*-----------------------------------------------------------*/
-/*
- * The NVT terminal is negociated in PollRead and PollWrite
- * with every BYTE sendded or received.
- * A litle status machine in the pty_read_byte(int minor)
- *
- */
-static const char IAC_AYT_RSP[]="\r\nAYT? Yes, RTEMS-SHELL is here\r\n";
-static const char IAC_BRK_RSP[]="<*Break*>";
-static const char IAC_IP_RSP []="<*Interrupt*>";
-
-static
-int send_iac(int minor,unsigned char mode,unsigned char option)
-{
-  unsigned char buf[3];
-
-  buf[0]=IAC_ESC;
-  buf[1]=mode;
-  buf[2]=option;
-  return write(telnet_ptys[minor].socket,buf,sizeof(buf));
-}
-
-static int
-handleSB(pty_t *pty)
-{
-  switch (pty->sb_buf[0]) {
-    case 31:  /* NAWS */
-      pty->width  = (pty->sb_buf[1]<<8) + pty->sb_buf[2];
-      pty->height = (pty->sb_buf[3]<<8) + pty->sb_buf[4];
-#if DEBUG & DEBUG_WH
-      fprintf(stderr,
-          "Setting width/height to %ix%i\n",
-          pty->width,
-          pty->height);
-#endif
-      break;
-    default:
-      break;
-  }
-  return 0;
-}
-
-static int read_pty(int minor)
-{ /* Characters written to the client side*/
-   unsigned char  value;
-   unsigned int  omod;
-   int      count;
-   int      result;
-   pty_t      *pty=telnet_ptys+minor;
-
-   count=read(pty->socket,&value,sizeof(value));
-   if (count<0)
-    return -1;
-
-   if (count<1) {
-      /* Unfortunately, there is no way of passing an EOF
-       * condition through the termios driver. Hence, we
-       * resort to an ugly hack. Setting cindex>ccount
-       * causes the termios driver to return a read count
-       * of '0' which is what we want here. We leave
-       * 'errno' untouched.
-       */
-      pty->ttyp->cindex=pty->ttyp->ccount+1;
-      return pty->ttyp->termios.c_cc[VEOF];
-   };
-
-   omod=pty->iac_mode;
-   pty->iac_mode=0;
-   switch(omod & 0xff) {
-       case IAC_ESC:
-           switch(value) {
-               case IAC_ESC :
-                   /* in case this is an ESC ESC sequence in SB mode */
-                   pty->iac_mode = omod>>8;
-                   return IAC_ESC;
-               case IAC_DONT:
-               case IAC_DO  :
-               case IAC_WONT:
-               case IAC_WILL:
-                   pty->iac_mode=value;
-                   return -1;
-               case IAC_SB  :
-#if DEBUG & DEBUG_DETAIL
-                   printk("SB\n");
-#endif
-                   pty->iac_mode=value;
-                   pty->sb_ind=0;
-                   return -100;
-               case IAC_GA  :
-                   return -1;
-               case IAC_EL  :
-                   return 0x03; /* Ctrl-C*/
-               case IAC_EC  :
-                   return '\b';
-               case IAC_AYT :
-                   write(pty->socket,IAC_AYT_RSP,strlen(IAC_AYT_RSP));
-                   return -1;
-               case IAC_AO  :
-                   return -1;
-               case IAC_IP  :
-                   write(pty->socket,IAC_IP_RSP,strlen(IAC_IP_RSP));
-                   return -1;
-               case IAC_BRK :
-                   write(pty->socket,IAC_BRK_RSP,strlen(IAC_BRK_RSP));
-                   return -1;
-               case IAC_DMARK:
-                   return -2;
-               case IAC_NOP :
-                   return -1;
-               case IAC_SE  :
-#if DEBUG & DEBUG_DETAIL
-                  {
-                  int i;
-                  printk("SE");
-                  for (i=0; i<pty->sb_ind; i++)
-                    printk(" %02x",pty->sb_buf[i]);
-                  printk("\n");
-                  }
-#endif
-                  handleSB(pty);
-               return -101;
-               case IAC_EOR :
-                   return -102;
-               default      :
-                   return -1;
-           };
-           break;
-
-       case IAC_SB:
-           pty->iac_mode=omod;
-           if (IAC_ESC==value) {
-             pty->iac_mode=(omod<<8)|value;
-           } else {
-             if (pty->sb_ind < SB_MAX)
-               pty->sb_buf[pty->sb_ind++]=value;
-           }
-           return -1;
-
-       case IAC_WILL:
-           if (value==34){
-              send_iac(minor,IAC_DONT,   34);  /*LINEMODE*/
-              send_iac(minor,IAC_DO  ,    1);  /*ECHO    */
-           } else if (value==31) {
-              send_iac(minor,IAC_DO  ,   31);  /*NAWS    */
-#if DEBUG & DEBUG_DETAIL
-              printk("replied DO NAWS\n");
-#endif
-           } else {
-              send_iac(minor,IAC_DONT,value);
-           }
-           return -1;
-       case IAC_DONT:
-           return -1;
-       case IAC_DO  :
-           if (value==3) {
-              send_iac(minor,IAC_WILL,    3);  /* GO AHEAD*/
-           } else  if (value==1) {
-              /* ECHO */
-           } else {
-              send_iac(minor,IAC_WONT,value);
-           };
-           return -1;
-       case IAC_WONT:
-           if (value==1) {
-             send_iac(minor,IAC_WILL,    1);
-           } else { /* ECHO */
-             send_iac(minor,IAC_WONT,value);
-           }
-           return -1;
-       default:
-           if (value==IAC_ESC) {
-              pty->iac_mode=value;
-              return -1;
-           } else {
-              result=value;
-              if ( 0
-#if 0               /* pass CRLF through - they should use termios to handle it */
-                 ||  ((value=='\n') && (pty->last_cr))
-#endif
-                /* but map telnet CRNUL to CR down here */
-                 || ((value==0) && pty->last_cr)
-                ) result=-1;
-               pty->last_cr=(value=='\r');
-               return result;
-           };
-   };
-  /* should never get here but keep compiler happy */
-  return -1;
-}
-
-/*-----------------------------------------------------------*/
-static int ptySetAttributes(int minor,const struct termios *t);
-static int ptyPollInitialize(int major,int minor,void * arg) ;
-static int ptyShutdown(int major,int minor,void * arg) ;
-static ssize_t ptyPollWrite(int minor, const char * buf, size_t len) ;
-static int ptyPollRead(int minor) ;
-static const rtems_termios_callbacks * pty_get_termios_handlers(int polled) ;
-/*-----------------------------------------------------------*/
-/* Set the 'Hardware'                                        */
-/*-----------------------------------------------------------*/
-static int
-ptySetAttributes(int minor,const struct termios *t) {
-  if (minor<rtems_telnetd_maximum_ptys) {
-   telnet_ptys[minor].c_cflag=t->c_cflag;
-  } else {
-   return -1;
-  };
-  return 0;
-}
-/*-----------------------------------------------------------*/
-static int
-ptyPollInitialize(int major,int minor,void * arg) {
-  rtems_libio_open_close_args_t * args = (rtems_libio_open_close_args_t*)arg;
-  struct termios t;
-        if (minor<rtems_telnetd_maximum_ptys) {
-         if (telnet_ptys[minor].socket<0) return -1;
-   telnet_ptys[minor].opened=TRUE;
-   telnet_ptys[minor].ttyp= (struct rtems_termios_tty *) args->iop->data1;
-   telnet_ptys[minor].iac_mode=0;
-   telnet_ptys[minor].sb_ind=0;
-   telnet_ptys[minor].width=0;
-   telnet_ptys[minor].height=0;
-   t.c_cflag=B9600|CS8;/* termios default */
-   return ptySetAttributes(minor,&t);
-  } else {
-   return -1;
-  }
-}
-/*-----------------------------------------------------------*/
-static int
-ptyShutdown(int major,int minor,void * arg) {
-  if (minor<rtems_telnetd_maximum_ptys) {
-    telnet_ptys[minor].opened=FALSE;
-    if (telnet_ptys[minor].socket>=0) close(telnet_ptys[minor].socket);
-      telnet_ptys[minor].socket=-1;
-    chown(telnet_ptys[minor].devname,2,0);
-  } else {
-    return -1;
-  }
-  return 0;
-}
-/*-----------------------------------------------------------*/
-/* Write Characters into pty device                          */
-/*-----------------------------------------------------------*/
-static ssize_t
-ptyPollWrite(int minor, const char * buf, size_t len) {
-  size_t count;
-  if (minor<rtems_telnetd_maximum_ptys) {
-    if (telnet_ptys[minor].socket<0)
-      return -1;
-    count=write(telnet_ptys[minor].socket,buf,len);
-  } else {
-   count=-1;
-  }
-  return count;
-}
-/*-----------------------------------------------------------*/
-static int
-ptyPollRead(int minor) {
-  int result;
-
-  if (minor<rtems_telnetd_maximum_ptys) {
-    if (telnet_ptys[minor].socket<0)
-      return -1;
-    result=read_pty(minor);
-    return result;
-  }
-  return -1;
-}
-/*-----------------------------------------------------------*/
-/*  pty_initialize
- *
- *  This routine initializes the pty IO driver.
- *
- *  Input parameters: NONE
- *
- *  Output parameters:  NONE
- *
- *  Return values:
- */
-/*-----------------------------------------------------------*/
-static
-rtems_device_driver my_pty_initialize(
-  rtems_device_major_number  major,
-  rtems_device_minor_number  minor,
-  void                      *arg
-)
-{
-  int ndx;
-  rtems_status_code status;
-
-  if ( rtems_telnetd_maximum_ptys < 5 )
-    rtems_telnetd_maximum_ptys = 5;
-
-  telnet_ptys = malloc( rtems_telnetd_maximum_ptys * sizeof (pty_t) );
-
-  /*
-   * Set up ptys
-   */
-
-  for (ndx=0;ndx<rtems_telnetd_maximum_ptys;ndx++) {
-    telnet_ptys[ndx].devname = (char*)malloc(strlen("/dev/ptyXX")+1);
-    sprintf(telnet_ptys[ndx].devname,"/dev/pty%X",ndx);
-    telnet_ptys[ndx].ttyp    =  NULL;
-    telnet_ptys[ndx].c_cflag = CS8|B9600;
-    telnet_ptys[ndx].socket  = -1;
-    telnet_ptys[ndx].opened  = FALSE;
-    telnet_ptys[ndx].sb_ind  = 0;
-    telnet_ptys[ndx].width   = 0;
-    telnet_ptys[ndx].height  = 0;
-
-  }
-
-  /*
-   * Register the devices
-   */
-  for (ndx=0;ndx<rtems_telnetd_maximum_ptys;ndx++) {
-    status = rtems_io_register_name(telnet_ptys[ndx].devname, major, ndx);
-    if (status != RTEMS_SUCCESSFUL)
-        rtems_fatal_error_occurred(status);
-    chmod(telnet_ptys[ndx].devname,0660);
-    chown(telnet_ptys[ndx].devname,2,0); /* tty,root*/
-  };
-  printk("Device: /dev/pty%X../dev/pty%X (%d)pseudo-terminals registered.\n",
-          0,rtems_telnetd_maximum_ptys-1,rtems_telnetd_maximum_ptys);
-
-  return RTEMS_SUCCESSFUL;
-}
-
-static int pty_do_finalize(void)
-{
-    int ndx;
-    rtems_status_code status;
-
-    if ( !telnet_pty_inited )
-      return 0;
-
-    for (ndx=0;ndx<rtems_telnetd_maximum_ptys;ndx++) {
-      if (telnet_ptys[ndx].opened) {
-          fprintf(stderr,
-            "There are still opened PTY devices, unable to proceed\n");
-          return -1;
-      }
-    }
-    if (RTEMS_SUCCESSFUL != rtems_io_unregister_driver(pty_major)) {
-        fprintf(stderr,"Unable to remove this driver\n");
-        return -1;
-    }
-    for (ndx=0;ndx<rtems_telnetd_maximum_ptys;ndx++) {
-        /* rtems_io_register_name() actually creates a node in the filesystem
-         * (mknod())
-         */
-        status = (rtems_status_code)unlink(telnet_ptys[ndx].devname);
-        if (status != RTEMS_SUCCESSFUL)
-          perror("removing pty device node from file system");
-        else
-          free(telnet_ptys[ndx].devname);
-    };
-
-    free ( telnet_ptys );
-
-    fprintf(stderr,"PTY driver unloaded successfully\n");
-    telnet_pty_inited=FALSE;
-    return 0;
-}
-
-/*
- *  Open entry point
- */
-
-static
-rtems_device_driver my_pty_open(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg
-)
-{
-  rtems_status_code sc;
-  sc = rtems_termios_open(major,minor,arg,pty_get_termios_handlers(FALSE));
-  return sc;
-}
-
-/*
- *  Close entry point
- */
-
-static
-rtems_device_driver my_pty_close(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg
-)
-{
-  return rtems_termios_close(arg);
-}
-
-/*
- * read bytes from the pty
- */
-
-static
-rtems_device_driver my_pty_read(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg
-)
-{
-  return rtems_termios_read(arg);
-}
-
-/*
- * write bytes to the pty
- */
-
-static
-rtems_device_driver my_pty_write(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg
-)
-{
-  return rtems_termios_write(arg);
-}
-
-/*
- *  IO Control entry point
- */
-
-static
-rtems_device_driver my_pty_control(
-  rtems_device_major_number major,
-  rtems_device_minor_number minor,
-  void                    * arg
-)
-{
-  rtems_libio_ioctl_args_t *args = (rtems_libio_ioctl_args_t*)arg;
-  struct winsize           *wp = (struct winsize*)args->buffer;
-  pty_t                    *p = &telnet_ptys[minor];
-
-  switch (args->command) {
-
-    case TIOCGWINSZ:
-
-      wp->ws_row = p->height;
-      wp->ws_col = p->width;
-      args->ioctl_return=0;
-#if DEBUG & DEBUG_WH
-      fprintf(stderr,
-          "ioctl(TIOCGWINSZ), returning %ix%i\n",
-          wp->ws_col,
-          wp->ws_row);
-#endif
-
-      return RTEMS_SUCCESSFUL;
-
-    case TIOCSWINSZ:
-#if DEBUG & DEBUG_WH
-      fprintf(stderr,
-          "ioctl(TIOCGWINSZ), setting %ix%i\n",
-          wp->ws_col,
-          wp->ws_row);
-#endif
-
-      p->height = wp->ws_row;
-      p->width  = wp->ws_col;
-      args->ioctl_return=0;
-
-      return RTEMS_SUCCESSFUL;
-
-    default:
-
-     break;
-  }
-
-  return rtems_termios_ioctl(arg);
-}
-
-static rtems_driver_address_table drvPty = {
-    my_pty_initialize,
-    my_pty_open,
-    my_pty_close,
-    my_pty_read,
-    my_pty_write,
-    my_pty_control
-};
-
-/*-----------------------------------------------------------*/
-static const rtems_termios_callbacks pty_poll_callbacks = {
-  ptyPollInitialize,  /* FirstOpen */
-  ptyShutdown,        /* LastClose */
-  ptyPollRead,        /* PollRead  */
-  ptyPollWrite,       /* Write */
-  ptySetAttributes,   /* setAttributes */
-  NULL,               /* stopRemoteTX */
-  NULL,               /* StartRemoteTX */
-  0                   /* outputUsesInterrupts */
-};
-/*-----------------------------------------------------------*/
-static const rtems_termios_callbacks * pty_get_termios_handlers(int polled) {
-  return &pty_poll_callbacks;
-}
-/*-----------------------------------------------------------*/
-
-static int pty_do_initialize(void)
-{
-  if ( !telnet_pty_inited ) {
-    if (RTEMS_SUCCESSFUL==rtems_io_register_driver(0, &drvPty, &pty_major))
-      telnet_pty_inited=TRUE;
-    else
-      fprintf(stderr,"WARNING: registering the PTY driver FAILED\n");
-  }
-  return telnet_pty_inited;
-}
-
-int telnet_pty_initialize(void)
-{
-  return pty_do_initialize();
-}
-
-int telnet_pty_finalize(void)
-{
-  return pty_do_finalize();
-}
Index: rvices/telnetd/telnetd.c
===================================================================
--- services/telnetd/telnetd.c	(revision 23c7ab408be5130ee161d35cedc862d00628afd0)
+++ 	(revision )
@@ -1,510 +1,0 @@
-/***********************************************************/
-/*
- *
- *  The telnet DAEMON
- *
- *  Author: 17,may 2001
- *
- *   WORK: fernando.ruiz@ctv.es
- *   HOME: correo@fernando-ruiz.com
- *
- * After start the net you can start this daemon.
- * It uses the previously inited pseudo-terminales (pty.c)
- * getting a new terminal with getpty(). This function
- * gives a terminal name passing a opened socket like parameter.
- *
- * With register_telnetd() you add a new command in the shell to start
- * this daemon interactively. (Login in /dev/console of course)
- *
- * Sorry but OOB is not still implemented. (This is the first version)
- *
- * Till Straumann <strauman@slac.stanford.edu>
- *  - made the 'shell' interface more generic, i.e. it is now
- *    possible to have 'telnetd' run an arbitrary 'shell'
- *    program.
- *
- * Copyright (c) 2009 embedded brains GmbH and others.
- *
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems.h>
-#include <rtems/error.h>
-#include <rtems/pty.h>
-#include <rtems/shell.h>
-#include <rtems/telnetd.h>
-#include <rtems/bspIo.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <syslog.h>
-
-#include <rtems/userenv.h>
-#include <rtems/error.h>
-#include <rtems/rtems_bsdnet.h>
-
-#define PARANOIA
-
-extern char *telnet_get_pty(int socket);
-extern int   telnet_pty_initialize(void);
-
-struct shell_args {
-  char *devname;
-  void *arg;
-  char  peername[16];
-  char  delete_myself;
-};
-
-typedef union uni_sa {
-  struct sockaddr_in sin;
-  struct sockaddr     sa;
-} uni_sa;
-
-static int sockpeername(int sock, char *buf, int bufsz);
-
-rtems_id telnetd_dflt_spawn(
-  const char *name,
-  unsigned priority,
-  unsigned stackSize,
-  void (*fn)(void*),
-  void *fnarg
-);
-
-/***********************************************************/
-static rtems_id telnetd_task_id = RTEMS_ID_NONE;
-
-rtems_id (*telnetd_spawn_task)(
-  const char *,
-  unsigned,
-  unsigned,
-  void (*)(void*),
-  void *
-) = telnetd_dflt_spawn;
-
-static char *grab_a_Connection(
-  int des_socket,
-  uni_sa *srv,
-  char *peername,
-  int sz
-)
-{
-  char *rval = 0;
-#if 0
-  socklen_t size_adr = sizeof(srv->sin);
-#else
-  /* 4.6 doesn't have socklen_t */
-  uint32_t size_adr = sizeof(srv->sin);
-#endif
-  int acp_sock;
-
-  acp_sock = accept(des_socket,&srv->sa,&size_adr);
-
-  if (acp_sock<0) {
-    perror("telnetd:accept");
-    goto bailout;
-  };
-
-  if ( !(rval=telnet_get_pty(acp_sock)) ) {
-    syslog( LOG_DAEMON | LOG_ERR, "telnetd: unable to obtain PTY");
-    /* NOTE: failing 'do_get_pty()' closed the socket */
-    goto bailout;
-  }
-
-  if (sockpeername(acp_sock, peername, sz))
-    strncpy(peername, "<UNKNOWN>", sz);
-
-#ifdef PARANOIA
-  syslog(LOG_DAEMON | LOG_INFO,
-      "telnetd: accepted connection from %s on %s",
-      peername,
-      rval);
-#endif
-
-bailout:
-
-  return rval;
-}
-
-
-static void release_a_Connection(char *devname, char *peername, FILE **pstd, int n)
-{
-
-#ifdef PARANOIA
-  syslog( LOG_DAEMON | LOG_INFO,
-      "telnetd: releasing connection from %s on %s",
-      peername,
-      devname );
-#endif
-
-  while (--n>=0)
-    if (pstd[n]) fclose(pstd[n]);
-
-}
-
-static int sockpeername(int sock, char *buf, int bufsz)
-{
-  uni_sa peer;
-  int    rval = sock < 0;
-#if 0
-  socklen_t len  = sizeof(peer.sin);
-#else
-  /* 4.6 doesn't have socklen_t */
-  uint32_t len  = sizeof(peer.sin);
-#endif
-
-  if ( !rval )
-    rval = getpeername(sock, &peer.sa, &len);
-
-  if ( !rval )
-    rval = !inet_ntop( AF_INET, &peer.sin.sin_addr, buf, bufsz );
-
-  return rval;
-}
-
-static void
-spawned_shell(void *arg);
-
-/***********************************************************/
-static void
-rtems_task_telnetd(void *task_argument)
-{
-  int                des_socket;
-  uni_sa             srv;
-  char              *devname;
-  char               peername[16];
-  int                i=1;
-  int                size_adr;
-  struct shell_args *arg = NULL;
-
-  if ((des_socket=socket(PF_INET,SOCK_STREAM,0))<0) {
-    perror("telnetd:socket");
-    telnetd_task_id = RTEMS_ID_NONE;
-    rtems_task_delete(RTEMS_SELF);
-  };
-  setsockopt(des_socket,SOL_SOCKET,SO_KEEPALIVE,&i,sizeof(i));
-
-  memset(&srv,0,sizeof(srv));
-  srv.sin.sin_family=AF_INET;
-  srv.sin.sin_port=htons(23);
-  size_adr=sizeof(srv.sin);
-  if ((bind(des_socket,&srv.sa,size_adr))<0) {
-    perror("telnetd:bind");
-    close(des_socket);
-    telnetd_task_id = RTEMS_ID_NONE;
-    rtems_task_delete(RTEMS_SELF);
-  };
-  if ((listen(des_socket,5))<0) {
-    perror("telnetd:listen");
-          close(des_socket);
-    telnetd_task_id = RTEMS_ID_NONE;
-    rtems_task_delete(RTEMS_SELF);
-  };
-
-  /* we don't redirect stdio as this probably
-   * was started from the console anyways..
-   */
-  do {
-    if (rtems_telnetd_config.keep_stdio) {
-      bool start = true;
-      char device_name [32];
-
-      ttyname_r( 1, device_name, sizeof( device_name));
-      if (rtems_telnetd_config.login_check != NULL) {
-        start = rtems_shell_login_prompt(
-          stdin,
-          stderr,
-          device_name,
-          rtems_telnetd_config.login_check
-        );
-      }
-      if (start) {
-        rtems_telnetd_config.command( device_name, arg->arg);
-      } else {
-        syslog(
-          LOG_AUTHPRIV | LOG_WARNING,
-          "telnetd: to many wrong passwords entered from %s",
-          device_name
-        );
-      }
-    } else {
-      devname = grab_a_Connection(des_socket, &srv, peername, sizeof(peername));
-
-      if ( !devname ) {
-        /* if something went wrong, sleep for some time */
-        sleep(10);
-        continue;
-      }
-
-      arg = malloc( sizeof(*arg) );
-
-      arg->devname = devname;
-      arg->arg = rtems_telnetd_config.arg;
-      strncpy(arg->peername, peername, sizeof(arg->peername));
-
-      telnetd_task_id = telnetd_spawn_task(
-        devname,
-        rtems_telnetd_config.priority,
-        rtems_telnetd_config.stack_size,
-        spawned_shell,
-        arg
-      );
-      if (telnetd_task_id == RTEMS_ID_NONE) {
-        FILE *dummy;
-
-        if ( telnetd_spawn_task != telnetd_dflt_spawn ) {
-          fprintf(stderr,"Telnetd: Unable to spawn child task\n");
-        }
-
-        /* hmm - the pty driver slot can only be
-         * released by opening and subsequently
-         * closing the PTY - this also closes
-         * the underlying socket. So we mock up
-         * a stream...
-         */
-
-        if ( !(dummy=fopen(devname,"r+")) )
-          perror("Unable to dummy open the pty, losing a slot :-(");
-        release_a_Connection(devname, peername, &dummy, 1);
-        free(arg);
-        sleep(2); /* don't accept connections too fast */
-      }
-    }
-  } while(1);
-
-  /* TODO: how to free the connection semaphore? But then -
-   *       stopping the daemon is probably only needed during
-   *       development/debugging.
-   *       Finalizer code should collect all the connection semaphore
-   *       counts and eventually clean up...
-   */
-  close(des_socket);
-  telnetd_task_id = RTEMS_ID_NONE;
-}
-
-rtems_status_code rtems_telnetd_initialize( void)
-{
-  if (telnetd_task_id != RTEMS_ID_NONE) {
-    fprintf(stderr, "telnetd already started\n");
-    return RTEMS_RESOURCE_IN_USE;
-  }
-
-  if (rtems_telnetd_config.command == NULL) {
-    fprintf(stderr, "telnetd setup with invalid command\n");
-    return RTEMS_IO_ERROR;
-  }
-
-  if ( !telnet_pty_initialize() ) {
-    fprintf(stderr, "telnetd cannot initialize PTY driver\n");
-    return RTEMS_IO_ERROR;
-  }
-
-  /* Check priority */
-  if (rtems_telnetd_config.priority <= 0) {
-    rtems_telnetd_config.priority = rtems_bsdnet_config.network_task_priority;
-  }
-  if (rtems_telnetd_config.priority < 2) {
-    rtems_telnetd_config.priority = 100;
-  }
-
-  /* Check stack size */
-  if (rtems_telnetd_config.stack_size <= 0) {
-    rtems_telnetd_config.stack_size = (size_t)32 * 1024;
-  }
-
-  /* Spawn task */
-  telnetd_task_id = telnetd_spawn_task(
-    "TNTD",
-    rtems_telnetd_config.priority,
-    rtems_telnetd_config.stack_size,
-    rtems_task_telnetd,
-    0
-  );
-  if (telnetd_task_id == RTEMS_ID_NONE) {
-    return RTEMS_IO_ERROR;
-  }
-
-  /* Print status */
-  if (!rtems_telnetd_config.keep_stdio) {
-    fprintf(
-      stderr,
-      "telnetd started with stacksize = %u and priority = %d\n",
-      (unsigned) rtems_telnetd_config.stack_size,
-      (unsigned) rtems_telnetd_config.priority
-    );
-  }
-
-  return RTEMS_SUCCESSFUL;
-}
-
-/* utility wrapper */
-static void
-spawned_shell(void *targ)
-{
-  rtems_status_code    sc;
-  FILE                *nstd[3]={0};
-  FILE                *ostd[3]={ stdin, stdout, stderr };
-  int                  i=0;
-  struct shell_args  *arg = targ;
-  bool login_failed = false;
-  bool start = true;
-
-  sc=rtems_libio_set_private_env();
-
-  /* newlib hack/workaround. Before we change stdin/out/err we must make
-         * sure the internal data are initialized (fileno(stdout) has this sideeffect).
-   * This should probably be done from RTEMS' libc support layer...
-   * (T.S., newlibc-1.13; 2005/10)
-         */
-
-  fileno(stdout);
-
-  if (RTEMS_SUCCESSFUL != sc) {
-    rtems_error(sc,"rtems_libio_set_private_env");
-    goto cleanup;
-  }
-
-  /* redirect stdio */
-  for (i=0; i<3; i++) {
-    if ( !(nstd[i]=fopen(arg->devname,"r+")) ) {
-      perror("unable to open stdio");
-      goto cleanup;
-    }
-  }
-
-  stdin  = nstd[0];
-  stdout = nstd[1];
-  stderr = nstd[2];
-
-  #if 0
-    printk("STDOUT is now %x (%x) (FD %i/%i)\n",
-           stdout,nstd[1],fileno(stdout),fileno(nstd[1]));
-    printf("hello\n");
-    write(fileno(stdout),"hellofd\n",8);
-  #endif
-
-  /* call their routine */
-  if (rtems_telnetd_config.login_check != NULL) {
-    start = rtems_shell_login_prompt(
-      stdin,
-      stderr,
-      arg->devname,
-      rtems_telnetd_config.login_check
-    );
-    login_failed = !start;
-  }
-  if (start) {
-    rtems_telnetd_config.command( arg->devname, arg->arg);
-  }
-
-  stdin  = ostd[0];
-  stdout = ostd[1];
-  stderr = ostd[2];
-
-  if (login_failed) {
-    syslog(
-      LOG_AUTHPRIV | LOG_WARNING,
-      "telnetd: to many wrong passwords entered from %s",
-      arg->peername
-    );
-  }
-
-cleanup:
-  release_a_Connection(arg->devname, arg->peername, nstd, i);
-  free(arg);
-}
-
-struct wrap_delete_args {
-  void (*t)(void *);
-  void           *a;
-};
-
-static rtems_task
-wrap_delete(rtems_task_argument arg)
-{
-  struct wrap_delete_args     *pwa = (struct wrap_delete_args *)arg;
-  register void              (*t)(void *) = pwa->t;
-  register void               *a   = pwa->a;
-
-  /* free argument before calling function (which may never return if
-   * they choose to delete themselves)
-   */
-  free(pwa);
-  t(a);
-  rtems_task_delete(RTEMS_SELF);
-}
-
-rtems_id
-telnetd_dflt_spawn(const char *name, unsigned int priority, unsigned int stackSize, void (*fn)(void *), void* fnarg)
-{
-  rtems_status_code        sc;
-  rtems_id                 task_id = RTEMS_ID_NONE;
-  char                     nm[4] = {'X','X','X','X' };
-  struct wrap_delete_args *pwa = malloc(sizeof(*pwa));
-
-  strncpy(nm, name, 4);
-
-  if ( !pwa ) {
-    perror("Telnetd: no memory\n");
-    return RTEMS_ID_NONE;
-  }
-
-  pwa->t = fn;
-  pwa->a = fnarg;
-
-  if ((sc=rtems_task_create(
-    rtems_build_name(nm[0], nm[1], nm[2], nm[3]),
-      (rtems_task_priority)priority,
-      stackSize,
-      RTEMS_DEFAULT_MODES,
-      RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT,
-      &task_id)) ||
-    (sc=rtems_task_start(
-      task_id,
-      wrap_delete,
-      (rtems_task_argument)pwa))) {
-        free(pwa);
-        rtems_error(sc,"Telnetd: spawning task failed");
-        return RTEMS_ID_NONE;
-  }
-  return task_id;
-}
-
-/* convenience routines for CEXP (retrieve stdio descriptors
- * from reent structure)
- */
-#ifdef stdin
-static __inline__ FILE *
-_stdin(void)  { return stdin; }
-#undef stdin
-FILE *stdin(void)  { return _stdin(); }
-#endif
-#ifdef stdout
-static __inline__ FILE *
-_stdout(void) { return stdout; }
-#undef stdout
-FILE *stdout(void) { return _stdout(); }
-#endif
-#ifdef stderr
-static __inline__ FILE *
-_stderr(void) { return stderr; }
-#undef stderr
-FILE *stderr(void) { return _stderr(); }
-#endif
-
-/* MUST NOT USE stdin & friends below here !!!!!!!!!!!!! */
