/**********************************************************************
 * ti library's routine for setting source info
 *
 * $Author: brlewis $
 * $Source: /afs/net.mit.edu/dev/project/techinfodev/src/libti/RCS/setsrc.c,v $
 * $Header: /afs/net.mit.edu/dev/project/techinfodev/src/libti/RCS/setsrc.c,v 2.2 93/02/25 10:06:53 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_setsrc_c[] = "$Header: /afs/net.mit.edu/dev/project/techinfodev/src/libti/RCS/setsrc.c,v 2.2 93/02/25 10:06:53 brlewis Exp $";
#endif /* lint */

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

/**********************************************************************
 * ti_setsrc(TI *tp, ti_sourceinfo *info)
 *
 * - fills in source info
 * - returns error code
 **********************************************************************/

long
ti_setsrc(tp, info)
     TI *tp;
     ti_sourceinfo *info;
{
  long code;
  char tosend[1024];

  /* send command and receive reply */
  sprintf(tosend, "A:%s:%s:%s:%s:%s\n",
	  info->ssource,
	  info->lsource,
	  info->name,
	  info->phone,
	  info->email);
  if (code = _ti_talk(tp, tosend, strlen(tosend), info->buf, 255))
    return(code);

  /* failure? */
  if (isdigit(info->buf[0]))
    {
      strncpy(ti_context, tosend, 126);
      ti_context[127] = '\0';
      return(_ti_srverr(info->buf));
    }

  return(0L);
}
