/*
 * CheckBridgeboard.c :
 * --------------------
 * Auteur        : Xavier Mertens
 * Version   $VER: 1.00 
 * Création      : 18 Jun 1993 - 8:36
 * Modification  : -
 * Langage       : SAS/C V6.2
 * Compatibilité : 1.x - 2.x - 3.x
 * Description   : Teste la présence et l'activité de la carte passerelle
 *                 et renvoie un code utile pour les scripts.
 * Remarque(s)   : -
 * Historique    : V1.00 : Création.
 */

#include <exec/types.h>
#include <exec/interrupts.h>
#include <string.h>
#include <janus/janus.h>
#include <clib/exec_protos.h>

#define NUMBUF    24
#define DATA_LEN  129+1+1
#define OK        0
#define WARN      5
#define ERROR      10
#define PRINT(x)  Write(Output(),x,strlen(x))

struct Library *JanusBase;

main(int argc,char *argv[]){
  APTR base = NULL;
  BOOL mode = FALSE;
  if((argc > 2) || (!strcmp(argv[1],"?"))){
    PRINT("CheckBridgeboard v1.00 © Xavier Mertens (18.06.93)\nSyntaxe : CheckBridgeboard [QUIET]\n");
    exit(ERROR);
  }
  if(!strcmp(strupr(argv[1]),"QUIET"))
    mode = TRUE;
  if(!(JanusBase = OpenLibrary("janus.library",NULL)))
    if(mode)
      exit(WARN);
    else{
      PRINT("Pas de carte passerelle trouvée!\n");
      exit(WARN);
    }
  if(!(base = AllocJanusMem(DATA_LEN * NUMBUF,MEMF_PARAMETER | MEM_BYTEACCESS)))
    if(mode)
      exit(WARN);
    else{
      PRINT("Carte passerelle non active!\n");
      exit(WARN);
    }  
  CloseLibrary(JanusBase);
  if(!mode)
    PRINT("Ok,carte passerelle trouvée!\n");
  exit(OK);
}

/* Eof */
