/* 
   * Copyright (C) 1997, Alexander Pukhov 
   * Copyright (C) 2001-2003, CompHEP Collaboration
   *------------------------------------------------------
   * $Id: s_files.c,v 1.4 2003/06/25 18:46:42 kryukov Exp $
   *
   * $Log: s_files.c,v $
   * Revision 1.4  2003/06/25 18:46:42  kryukov
   * *** empty log message ***
   *
   * Revision 1.3  2003/04/22 09:01:20  kryukov
   * Apply indent to improve readability of files
   *
   * Revision 1.2  2003/04/20 17:55:02  kryukov
   * Clean up warnings during make
   *
 */
#include "service2/include/os.h"
#include "service2/include/tptcmac.h"
#include "chep_crt/include/syst.h"

#include "syst2.h"
#include "s_files.h"

FILE *menup;
FILE *menuq;
FILE *diagrp;			/* file of Adiagram; */
FILE *diagrq;			/* file of CSdiagram; */
FILE *catalog;
FILE *archiv;

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

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


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