home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / packery / xpk_source / xpkmaster / geterror.c < prev    next >
C/C++ Source or Header  |  1996-10-19  |  949b  |  46 lines

  1. #ifndef XPKMASTER_GETERROR_C
  2. #define XPKMASTER_GETERROR_C
  3.  
  4. /* Routinesheader
  5.  
  6.     Name:        geterror.c
  7.     Main:        xpkmaster
  8.     Versionstring:    $VER: geterror.c 1.0 (05.10.96)
  9.     Author:        SDI
  10.     Distribution:    PD
  11.     Description:    Error message generator
  12.  
  13.  1.0   05.10.96 : first real version
  14. */
  15.  
  16. #include "xpkmaster.h"
  17. #include "xpk_strings.h"
  18. #include <exec/types.h>
  19.  
  20. #define MINERROR -32
  21.  
  22. void geterror(struct XpkBuffer *xbuf)
  23. {
  24.   STRPTR res;
  25.   STRPTR buf = xbuf->xb_ErrBuf;
  26.  
  27.   if(!buf)
  28.     return;
  29.  
  30.   if(*xbuf->xb_ErrMsg)
  31.     res = xbuf->xb_ErrMsg;
  32.   else if (xbuf->xb_Result > 0 || xbuf->xb_Result < MINERROR)
  33.     res = strings[TXT_UNKNOWN_ERROR];
  34.   else
  35.     res = XpkErrs[-xbuf->xb_Result];
  36.  
  37.   if(xbuf->xb_Flags & XMF_SHORTERR)
  38.     sprintf(buf, "%.50s", res);
  39.   else
  40.     sprintf(buf, strings[FMT_LONG_ERROR],
  41.     xbuf->xb_Flags & XMF_PACKING ? strings[TXT_PACKING] :
  42.     strings[TXT_UNPACKING], xbuf->xb_Prog.xp_FileName, res);
  43. }
  44.  
  45. #endif /* XPKMASTER_GETERROR_C */
  46.