/*
 * Auxilliary routines for BibTeX in C.
 *
 * Tim Morgan 2/15/88
 * Eduardo Krell 4/21/88
 */

/*
 * JBibTeX Version by Shouichi Matsui
 *  matsui@denken.or.jp (matsui%denken.or.jp@uunet.uu.net)
 *  1989-05-02
 *  Last updated: 1990-12-29
 *  many codes are from ../cjtex/extra.c by T. Sakurai 
 */
/*
 * Modified for pTeX 2.1 by Kazunori Aasayama
 *  asayama@kuis.kyoto-u.ac.jp  Sep. 4, 1995
 * Modified for pTeX 2.1.5 by Kazunori Aasayama
 *  asayama@vsp.cpg.sony.co.jp March. 14, 1997
 */

#include "kanji.h"
#include "jbibextra.h"
#include "jbibd.h"
#include <kpathsea/variable.h>

#ifdef WIN32
#ifdef HAVE_SYS_PARAM_H
#  include <sys/param.h>
#else
#  include <limits.h>
#endif
#ifndef NOFILE
#  define NOFILE 512
#endif
#endif

/*
   const_string based_prog_name="BibTeX";
   const_string based_prog_version="0.99c";
   */

boolean inputline(FILE *f)
{
  int i;

  last = 0;

#ifdef KANJI
  last = input_line2(f, buffer, last, bufsize, &i);
#else /* KANJI */
  while ( last < bufsize && ((i = getc(f)) != EOF) && i != '\n' && i != '\r') {
#ifdef	NONASCII
    buffer[last++] = i;
#else /* NONASCII */
    buffer[last++] = (i > 127 || i < 0)?' ':i;
#endif /* NONASCII */
  }
#endif /* KANJI */

  if (i == EOF && last == 0)
    return false;
  if (i != EOF && i != '\n' && i != '\r')
    return false;

  /* Don't bother using xord if we don't need to.  */
#ifdef NONASCII
  /*
     for (i = 0; i <= last; i++)
     buffer[i] = xord[buffer[i]];
     */
#endif

  return true;
}

void initkanji(void)
{
  set_enc_string("utf8", "uptex");
}
