#include <stdio.h>
#include <stdlib.h>

#ifdef USE_NLLIBC
#include <nllibc.h>
#endif

#include "lib.h"

/*****************************************************************
 * library
 */

static int errline = 0;

void saveline(int line)
{
  errline = line;
}

int loadline(void)
{
  return errline;
}

void error_exit(int line, int code, char *filename, int fileline)
{
  if (line == 0)
    line = errline;
  fflush(stdout);
  fprintf(stderr, "\nLINE:%d - Syntax error (%s:%d)\n",
	  line, filename, fileline);
  exit(code);
}

void indent_print(int num)
{
  int i;
  for (i = 0; i < num * 2; i++)
    printf(" ");
}
