/* 
* Copyright (C) 2001-2009, CompHEP Collaboration
* Copyright (C) 1997, Alexander Pukhov 
* ------------------------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>

#include "chep_limits.h"
#include "unix_utils.h"
#include "tptcmac.h"
#include "syst.h"
#include "s_files.h"

FILE *menup   = 0x0;
FILE *menuq   = 0x0;
FILE *diagrp  = 0x0;			/* file of Adiagram; */
FILE *diagrq  = 0x0;			/* file of CSdiagram; */
FILE *catalog = 0x0;

char mdFls[5][10] =
{"vars", "func", "prtcls", "lgrng", "cpart"};
shortstr pathtouser = "";
shortstr _pathtouser = "";

void 
wrt_menu (FILE * men, int menutype, int k, char *txt, int ndel, int ncalc, int nrest,
	  long recpos)
{
  if (menutype == 1)
    {
      fseek (men, (k - 1) * 54 + 2, SEEK_SET);
      fprintf (men, "%4d| %-27.27s|%5d|%5d|%-8d", k, txt, ndel, nrest, (int) recpos);
      fflush(men);
    }
  else
    {
      fseek (men, (k - 1) * 60 + 2, SEEK_SET);
      fprintf (men, "%4d| %-27.27s|%5d|%5d|%5d|%-8d", k, txt, ndel, ncalc, nrest,
              (int) recpos);
      fflush(men);
    }
}


int 
rd_menu (FILE * men, int menutype, int k, char *txt, int *ndel, int *ncalc, int *nrest, long *recpos)
{
  if (menutype == 1)
    {
      fseek (men, (k - 1) * 54 + 2, SEEK_SET);
      if (5 != fscanf (men, "%d| %[^|]%*c%d|%d|%ld", &k, txt, ndel, nrest, recpos))
	return 0;
      *ncalc = 0;
    }
  else
    {
      fseek (men, (k - 1) * (60) + 2, SEEK_SET);
      if (6 != fscanf (men, "%4d| %[^|]%*c%d|%d|%d|%ld", &k, txt, ndel, ncalc, nrest, recpos))
	return 0;
    }
  return 1;
}
