/**********************************************************************
 * ti library's routine for removing nodes
 *
 * $Author: brlewis $
 * $Source: /afs/net.mit.edu/project/net_dev/brlewis/src/lib/RCS/remove.c,v $
 * $Header: /afs/net.mit.edu/project/net_dev/brlewis/src/lib/RCS/remove.c,v 0.2 92/04/01 16:19:05 brlewis Exp $
 *
 * Copyright 1991 by the Massachusetts Institute of Technology.
 *
 * For copying and distribution information, please see the file
 * <mit-copyright.h>.
 **********************************************************************/

#include <mit-copyright.h>

#ifndef lint
static char rcsid_ti_remove_c[] = "$Header: /afs/net.mit.edu/project/net_dev/brlewis/src/lib/RCS/remove.c,v 0.2 92/04/01 16:19:05 brlewis Exp $";
#endif /* lint */

#include <stdio.h>
#include <string.h>
#include <ti/ti.h>

/**********************************************************************
 * ti_remove(TI *tp, long nid)
 *	caller supplies node id of node to remove.
 *
 * - returns error code
 **********************************************************************/

long
ti_remove(tp, nid)
     TI *tp;
     long nid;
{
  long code;
  char inbuf[BUFSIZ], outbuf[32];

  /* construct techinfo command */
  sprintf(outbuf, "x:%ld\n", nid);

  /* send command and receive reply */
  if (code = _ti_talk(tp, outbuf, strlen(outbuf),
		      inbuf, BUFSIZ-1)) return(code);

  /* success? */
  if (!atoi(inbuf)) return(0L);

  /* failure */
  sprintf(ti_context, "%ld", nid);
  return(_ti_srverr(inbuf));
}
