/* 
* Copyright (C) 2001-2008, CompHEP Collaboration
* Copyright (C) 1997, Alexander Pukhov 
* ------------------------------------------------------
* $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 <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;
FILE *menuq;
FILE *diagrp;			/* file of Adiagram; */
FILE *diagrq;			/* file of CSdiagram; */
FILE *catalog;

char mdFls[5][10] =
{"vars", "func", "prtcls", "lgrng", "cpart"};
shortstr pathtouser, _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;
}
