/*   ---------------------------------      -------     
 *   |\  | | | | |  |.| |   \|  |/ /|\      |||||||     
 *   | | | |/  | |\ |/  |/|  |\ |/  |    ?  ---+---  =< 
 *   | | | |   | |  |     |  |  |   |     \qqqqqqqqq/   
 *   ---------------------------------  ~~~~~~~~~~~~~~~~
 *  printErrorMsg() - handles the printing of DOS error messages.
 *  Copyright (C) 1993 Torsten Poulin
 *
 *  This file is part of "Torsten's AmigaDOS Shell Commands" package.
 *  The package 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.
 *
 *  The package 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: printErrorMsg.c,v 1.2 93/03/01 13:01:12 Torsten Rel $
 * $Log:	printErrorMsg.c,v $
 * Revision 1.2  93/03/01  13:01:12  Torsten
 * Changed all occurrences of "struct DosBase *" to "struct DosLibrary *"
 * 
 * Revision 1.1  93/03/01  11:03:13  Torsten
 * Initial revision
 * 
 */

#include <exec/types.h>
#include <dos/dos.h>
#include <dos/dosasl.h>
#include <clib/dos_protos.h>
#ifdef __SASC
#include <pragmas/dos_pragmas.h>
#endif

LONG printErrorMsg(LONG rc, UBYTE *text, struct DosLibrary *DOSBase)
{
  if (rc == ERROR_BREAK)
  {
    PrintFault(ERROR_BREAK, NULL);
    rc = RETURN_WARN;
  }
  else if (rc == ERROR_NO_FREE_STORE)
  {
    PrintFault(ERROR_NO_FREE_STORE, text);
    rc = RETURN_FAIL;
  }
  else if (rc != RETURN_OK)
    PrintFault(IoErr(), text);

  return rc;
}
