/* comptype.c */
/* gets the list of computers */
#include <dos/dos.h>
#include <dos/dosextens.h>
#include "bbs.h"
#include <exec/types.h>
#include <libraries/dos.h>
#include <workbench/workbench.h>
#include <clib/icon_protos.h>
#include <workbench/startup.h>
extern int ComputerEntries;
extern char *ComputerTypes[255],NodeStr[];

BOOL ReadComputerTypes(void)
{
 int loop;
 char str[300],*lbuffer;     // ,s[10];
 FILE *fh;

 sprintf(str,"%sComputerList",NodeStr);
 if(fh=fopen(str,"r")) {
	    if(fgets(str,79,fh)) {
 		str[80]='\0';
	    	ComputerEntries=atol(str);
		    if(lbuffer=AllocMem(ComputerEntries*90,MEMF_ANY)) {
 			for(loop=0; loop<ComputerEntries; loop++) {
 				ComputerTypes[loop]=(UBYTE *)((90*loop)+(ULONG)lbuffer);
	    			if(fgets(ComputerTypes[loop],79,fh))
 					ComputerTypes[loop][strlen(ComputerTypes[loop])-1]='\0';
 				else {           
 					printf("Not enough entries in ComputerTypes\n");
                     fclose(fh);
                     return(FALSE);
                 }
				}
			} else {
 			printf("%c %s %d\n",str[0],str,ComputerEntries);
		    	printf("Not enough memory to read in ComputerTypes\n");
		    	fclose(fh);
     	    return(FALSE);       // CloseDisplay();
			}
		} else {
	    	if(fh) fclose(fh);
 		printf("No entries in ComputerTypes\n");
  	    return(FALSE);            //  CloseDisplay();
		}
 	if(fh) fclose(fh);            //(RTS)
	} else {
 	printf("Missing file %s\n",str);
	    return(FALSE);                 // CloseDisplay();
	}
 return(TRUE);
}

