/**********************************************************************
 * ti library's routine to get complete node info from node id
 *
 * $Author: brlewis $
 * $Source: /afs/net.mit.edu/dev/project/techinfodev/src/libti/RCS/nodeinfo.c,v $
 * $Header: /afs/net.mit.edu/dev/project/techinfodev/src/libti/RCS/nodeinfo.c,v 4.1 94/06/03 16:23:33 brlewis Exp $
 *
 * Copyright 1993 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_nodeinfo_c[] = "$Header: /afs/net.mit.edu/dev/project/techinfodev/src/libti/RCS/nodeinfo.c,v 4.1 94/06/03 16:23:33 brlewis Exp $";
#endif /* lint */

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

/**********************************************************************
 * ti_nodeinfo(TI *tp, long id, ti_node *nd)
 *
 * - puts info in nd
 * - returns error code
 **********************************************************************/

#define TI_NODEINFO_MAX_SIZE (10240)

long
ti_nodeinfo(tp, id, nd)
     TI *tp;
     long id;
     ti_node *nd;
{
  long code=0L;
  char tosend[16], torecv[TI_NODEINFO_MAX_SIZE];

  /* construct techinfo command */
  sprintf(tosend, "s:%ld\n", id);

  /* fill in level info (for _ti_str2nd) */
  strcpy(torecv, "0:");

  /* send command and receive reply */
  if (code = _ti_talk(tp, tosend, strlen(tosend),
		      torecv+2, TI_NODEINFO_MAX_SIZE-3)) return(code);

  return(_ti_str2nd(tp, torecv, nd));
}
