/****************************************************************************/
/*                                                                          */
/*                      Chaine de CAO & VLSI   Alliance                     */
/*                                                                          */
/*    Produit :  Synthetiseur Logique                                       */
/*    Fichier :  gestionLst.c                                               */
/*                                                                          */
/*    (c) copyright 1991 Laboratoire MASI equipe CAO & VLSI                 */
/*    Tous droits reserves                                                  */
/*    Support : e-mail cao-vlsi@masi.ibp.fr                                 */
/*                                                                          */
/*    Auteur(s) :  L. Burgun                            le : 10/06/1992     */
/*                                                                          */
/*    Modifie par :                                     le : ../../....     */
/*    Modifie par :                                     le : ../../....     */
/*    Modifie par :                                     le : ../../....     */
/*                                                                          */
/****************************************************************************/

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include MUT_H
#include "../compil/lax_param.h"


/*---------------------------------------------------------------------------

---------------------------------------------------------------------------*/
int intGestion(message)
char *message;
{
char *value = (char *) mbkalloc( 100 );
int val;

system("clear");
printf("%s\n",message);
printf("\n\n");
gets(value);
printf("value : "); 
gets(value);
val = atoi(value);
mbkfree(value);
return(val);
}

/*---------------------------------------------------------------------------

---------------------------------------------------------------------------*/

ptype_list *lstGestion (lst, message)
ptype_list *lst;
char *message;
{
ptype_list *lstCur;
char *name = (char *) mbkalloc( 100 );
char *value = (char *) mbkalloc( 100 );
int val;
char choix;

do
   {
   system("clear");
   printf("%s\n\n",message);
   lstCur = lst;
   while (lstCur)
      {
      printf("%s : %d\n", driveName(lstCur->DATA), lstCur->TYPE);
      lstCur = lstCur->NEXT;
      }
   printf("\n\n");
   printf("                 [A]dd, [D]elete or [R]eturn\n");
   printf("\n\n");

   do {
      choix = tolower(AuVol());
      }
   while( strchr( "adr", choix ) == NULL);
   gets(name);

   lstCur = lst;
   if (choix == 'a')
      {
      printf("name : ");
      gets(name);
      printf("value : "); 
      gets(value);
      val = atoi(value);
      name = parseName(name);
      while (lstCur)
         {
         if (!strcmp(name,lstCur->DATA))
            {
            lstCur->TYPE = val;
            break; 
            }
         lstCur = lstCur->NEXT;
         }
      if (!lstCur)
         {
         lst = addptype(lst,val,namealloc(name)); 
         }
      }
   if (choix == 'd')
      {
      printf("name : ");
      gets(name);
      name = parseName(name);
      while (lstCur)
         {
         if (!strcmp(name,lstCur->DATA))
            {
            lstCur->TYPE = 0;
            }
         lstCur = lstCur->NEXT;
         }
      }
   }
while (choix != 'r');
mbkfree(name);
mbkfree(value);
return(lst);
}
