/**********************************************************************
 * ti library's routine for linking nodes
 *
 * $Author: brlewis $
 * $Source: /afs/net.mit.edu/project/net_dev/brlewis/src/lib/RCS/link.c,v $
 * $Header: /afs/net.mit.edu/project/net_dev/brlewis/src/lib/RCS/link.c,v 0.2 92/04/01 16:18:55 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_link_c[] = "$Header: /afs/net.mit.edu/project/net_dev/brlewis/src/lib/RCS/link.c,v 0.2 92/04/01 16:18:55 brlewis Exp $";
#endif /* lint */

#include <stdio.h>
#include <string.h>
#include <ti/ti.h>

/**********************************************************************
 * ti_link(TI_H hti, long pnid, long cnid)
 *	caller supplies parent and child node id's.
 *
 * - returns error code
 **********************************************************************/

/* jms 7/9/92 -- windows-izing completed pending approval. */

long
ti_link(hti, pnid, cnid)
     TI_H hti;
     long pnid, cnid;
{
  long code;
  static char inbuf[BUFSIZ];

  /* send command and receive reply */
  if (code = _ti_talkf(hti, inbuf, BUFSIZ-1, "l:%ld:%ld\n", pnid, cnid))
    return(code);

  /* success? */
  if (!atoi(inbuf)) return(0L);

  /* failure */
  sprintf(ti_context, "%ld, %ld", pnid, cnid);
  return(_ti_srverr(inbuf));
}
