#include <fcntl.h>
#include <stdio.h>
#include <proto/dlg.h>
#include <proto/dos.h>
#include <dlg/menu.h>

#include <link/io.h>

#include <pragmas/dlg.h>

extern struct Library  *DLGBase;
extern char           **SA;
extern struct USER_DATA UserDat;

SHORT ListMenuSets(int level)

{int            fp;
 SHORT          count = 0;
 struct MenuSet set;

 if ((fp=open("DLGCONFIG:Misc/MenuSets.bbs",O_RDONLY))==EOF)
    {
     AFPrintf(&UserDat,Output(),SA[3486]);
     return(-1);
    }

 AFPrintf(&UserDat,Output(),SA[3487]);
 Draw_Line(75);
 while(read(fp,&set,sizeof(set))==sizeof(set))
       if (set.level<=level)
          {
           AFPrintf(&UserDat,Output(),SA[3488],set.number,set.name);
           if (set.number>count) count = set.number;
          }

 Draw_Line(75);
 AFPrintf(&UserDat,Output(),"\n");

 close(fp);
 return(count);
}


BOOL CheckMenuSet(int number,int level)

{int            fp;
 struct MenuSet set;

 if (!number)  return(FALSE);

 if ((fp=open("DLGCONFIG:Misc/MenuSets.bbs",O_RDONLY))==EOF)
      return(FALSE);

 while(read(fp,&set,sizeof(set))==sizeof(set))
      {if (set.number == number)
          {close(fp);
           if (set.level > level)
               return(FALSE);
             else
               return(TRUE);
          }
      }

close(fp);
return(FALSE);
}
