/*
 *  Asterisk - Enable or disable asterisk as a wildcard.
 *  Copyright (C) 1992 Torsten Poulin
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  The author can be contacted by s-mail at
 *    Torsten Poulin
 *    Banebrinken 99, 2, 77
 *    DK-2400 Copenhagen NV
 *    DENMARK
 *
 * $Id: Asterisk.c,v 1.1 92/04/05 10:22:41 Torsten Exp $
 * $Log:	Asterisk.c,v $
 * Revision 1.1  92/04/05  10:22:41  Torsten
 * Initial revision
 *  
 */

#include <exec/types.h>
#include <dos/dosextens.h>
#include <dos/rdargs.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#ifdef __SASC
#include <pragmas/exec_pragmas.h>
#include <pragmas/dos_pragmas.h>
#endif
#include "tastlib.h"
#include "asterisk_rev.h"

#define PROGNAME "Asterisk"
#define TEMPLATE "ON/S,OFF/S"
#define OPT_ON  0
#define OPT_OFF 1

char const versionID[] = VERSTAG;
char const copyright[] = "$COPYRIGHT:©1992 Torsten Poulin$";

LONG entrypoint(VOID)
{
  struct DosLibrary *DOSBase;
  struct RDArgs *args;
  LONG   arg[2];
  LONG   rc = RETURN_OK;  

  if (!(DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 37L)))
    return RETURN_FAIL;

  arg[OPT_ON] = arg[OPT_OFF] = 0L;

  if (!(args = ReadArgs(TEMPLATE, arg, NULL))) {
    PrintFault(IoErr(), PROGNAME);
    rc = RETURN_FAIL;
  }
  else {
    if ((BOOL) arg[OPT_ON] == (BOOL) arg[OPT_OFF]) {
      PutStr("Asterisk wildcard is ");
      PutStr((DOSBase->dl_Root->rn_Flags & RNF_WILDSTAR)
	     ? "ON\n"
	     : "OFF\n");
    }
    else {
      if ((BOOL) arg[OPT_ON]) DOSBase->dl_Root->rn_Flags |= RNF_WILDSTAR;
      else DOSBase->dl_Root->rn_Flags &= ~RNF_WILDSTAR;
    }
    FreeArgs(args);
  }
  CloseLibrary((struct Library *) DOSBase);
  return rc;
}
