/*
 * Copyright 1990 by Baylor College of Medicine ALL RIGHTS RESERVED. 
 *
 * This program is subject to a license agreement between 
 * Baylor College of Medicine and MIT. Any use inconsistent with
 * said license and any use by persons other than the faculty, 
 * students and staff at MIT or any use on a computer not operated 
 * as part of the Athena Computing Environment (ACE) is expressly 
 * prohibited.
 */
/*******************************************************************************
* SYSTEM...: Virtual Notebook System
*
* MODULE...: printer.c
*
* PURPOSE..:
*   Provide means for loading site printer file 
*
* TAG: PRN
*
* REVISIONS:
*   Ross Dargahi                December 1990
*
*******************************************************************************/

#define PRINTER_C    /*define source name for includes*/

/*******************************************************************************
Include Files
*******************************************************************************/

#include <stdio.h>
#include "printer.h"

/*******************************************************************************
Private Defines
*******************************************************************************/



/*******************************************************************************
Private Global Declarations
*******************************************************************************/



/*******************************************************************************
Private Function Prototypes
*******************************************************************************/

/*******************************************************************************
****************************    PUBLIC FUNCTIONS    ****************************
*******************************************************************************/

int PRNloadPrinters(noPrinters, maxPrinters, printers, printerFile)

int       *noPrinters;  /*no of printers loaded into the printer array*/
int       maxPrinters;  /*maximum number of printers to load*/
PRINTER_S *printers;    /*pointer to an aray of printers*/
char      *printerFile;  /*printer file name*/

/*loads in site printer definitions*/

{
  FILE *printerFp;

  *noPrinters = 0;
  
  if (!(printerFp = fopen(printerFile, "r")))
     return(-1); 
  else
     while (!feof(printerFp) && *noPrinters < maxPrinters)
      {
        fscanf(printerFp, "%s %f %f %f %f %d", printers[*noPrinters].pname,
                                               &printers[*noPrinters].tMargin,
                                               &printers[*noPrinters].bMargin,
                                               &printers[*noPrinters].lMargin,
                                               &printers[*noPrinters].rMargin,
                                               &printers[*noPrinters].colour);
        
       (*noPrinters)++;
      }

    fclose(printerFp);
    (*noPrinters)--;
    return(0);

} /*PRNloadPrinters*/

/*******************************************************************************
****************************    PRIVATE FUNCTIONS    ***************************
*******************************************************************************/


/*******************************************************************************
Private undefines
*******************************************************************************/
#undef PRINTER_C
