⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libmng_error.c

📁 一款最完整的工业组态软源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    {MNG_TOOMUCHJDAT,      "Too much data in JDAT chunk(s)"},
    {MNG_JPEGPARMSERR,     "JHDR parameters & JFIF-data do not match"},
#endif
    {MNG_INVFILLMETHOD,    "The fill_method is invalid"},
#ifndef MNG_NO_DELTA_PNG
    {MNG_OBJNOTCONCRETE,   "Target object for DHDR must be concrete"},
#endif
    {MNG_TARGETNOALPHA,    "Target object must have alpha-channel"},
    {MNG_MNGTOOCOMPLEX,    "MHDR simplicity indicates unsupported feature(s)"},
    {MNG_UNKNOWNCRITICAL,  "Unknown critical chunk encountered"},
#ifndef MNG_SKIPCHUNK_nEED
    {MNG_UNSUPPORTEDNEED,  "Requested nEED resources are not supported"},
#endif
    {MNG_INVALIDDELTA,     "The delta operation is invalid (mismatched color_types?)"},
    {MNG_INVALIDMETHOD,    "Method is invalid"},
    {MNG_IMPROBABLELENGTH, "Chunklength is incredibly large"},
    {MNG_INVALIDBLOCK,     "Delta block width and or height invalid"},
    {MNG_INVALIDEVENT,     "Event type is invalid"},
    {MNG_INVALIDMASK,      "Mask type is invalid"},
    {MNG_NOMATCHINGLOOP,   "ENDL without matching LOOP"},
#ifndef MNG_SKIPCHUNK_evNT
    {MNG_SEEKNOTFOUND,     "evNT points to unknown SEEK"},
#endif
#ifndef MNG_SKIPCHUNK_PAST
    {MNG_OBJNOTABSTRACT,   "Destination object for PAST must be abstract"},
#endif
    {MNG_TERMSEQERROR,     "TERM misplaced during creation of MNG stream"},

    {MNG_INVALIDCNVSTYLE,  "Canvas_style is invalid"},
    {MNG_WRONGCHUNK,       "Attempt to access the wrong chunk"},
    {MNG_INVALIDENTRYIX,   "Attempt to access an non-existing entry"},
    {MNG_NOHEADER,         "No valid header-chunk"},
    {MNG_NOCORRCHUNK,      "Parent chunk not found"},
    {MNG_NOMHDR,           "No MNG header (MHDR) found"},

    {MNG_IMAGETOOLARGE,    "Image is larger than defined maximum"},
    {MNG_NOTANANIMATION,   "Image is not an animation"},
    {MNG_FRAMENRTOOHIGH,   "Framenr out of bounds"},
    {MNG_LAYERNRTOOHIGH,   "Layernr out of bounds"},
    {MNG_PLAYTIMETOOHIGH,  "Playtime out of bounds"},
    {MNG_FNNOTIMPLEMENTED, "Function not yet implemented"},
    {MNG_IMAGEFROZEN,      "Image is frozen"},

    {MNG_LCMS_NOHANDLE,    "Handle could not be initialized"},
    {MNG_LCMS_NOMEM,       "No memory for gamma-table(s)"},
    {MNG_LCMS_NOTRANS,     "Transformation could not be initialized"}
  };
#endif /* MNG_INCLUDE_ERROR_STRINGS */

/* ************************************************************************** */

mng_bool mng_store_error (mng_datap   pData,
                          mng_retcode iError,
                          mng_retcode iExtra1,
                          mng_retcode iExtra2)
{
#ifdef MNG_SUPPORT_TRACE
  MNG_TRACEB (pData, MNG_FN_STORE_ERROR, MNG_LC_START)
#endif

  if (pData != 0)
  {
    pData->iErrorcode = iError;        /* save also for getlasterror */
    pData->iErrorx1   = iExtra1;
    pData->iErrorx2   = iExtra2;

#ifdef MNG_INCLUDE_ERROR_STRINGS
    {                                  /* binary search variables */
      mng_int32        iTop, iLower, iUpper, iMiddle;
      mng_error_entryp pEntry;         /* pointer to found entry */
                                       /* determine max index of table */
      iTop = (sizeof (error_table) / sizeof (error_table [0])) - 1;

      iLower  = 0;                     /* initialize binary search */
      iMiddle = iTop >> 1;             /* start in the middle */
      iUpper  = iTop;
      pEntry  = 0;                     /* no goods yet! */

      do                               /* the binary search itself */
        {
          if (error_table [iMiddle].iError < iError)
            iLower = iMiddle + 1;
          else if (error_table [iMiddle].iError > iError)
            iUpper = iMiddle - 1;
          else
          {
            pEntry = &error_table [iMiddle];
            break;
          }

          iMiddle = (iLower + iUpper) >> 1;
        }
      while (iLower <= iUpper);

      if (pEntry)                      /* found it ? */
        pData->zErrortext = pEntry->zErrortext;
      else
        pData->zErrortext = "Unknown error";
      }
#else /* MNG_INCLUDE_ERROR_STRINGS */
    pData->zErrortext = 0;
#endif /* MNG_INCLUDE_ERROR_STRINGS */

    if (iError == 0)                   /* no error is not severe ! */
    {
      pData->iSeverity = 0;
    }
    else
    {
      switch (iError&0x3C00)           /* determine the severity */
      {
        case 0x0800 : { pData->iSeverity = 5; break; }
        case 0x1000 : { pData->iSeverity = 2; break; }
        case 0x2000 : { pData->iSeverity = 1; break; }
        default     : { pData->iSeverity = 9; }
      }
    }
  }

#ifdef MNG_SUPPORT_TRACE
  MNG_TRACEB (pData, MNG_FN_STORE_ERROR, MNG_LC_END)
#endif

  return MNG_TRUE;
}

/* ************************************************************************** */

mng_bool mng_process_error (mng_datap   pData,
                            mng_retcode iError,
                            mng_retcode iExtra1,
                            mng_retcode iExtra2)
{
#ifdef MNG_SUPPORT_TRACE
  MNG_TRACEB (pData, MNG_FN_PROCESS_ERROR, MNG_LC_START)
#endif

  mng_store_error (pData, iError, iExtra1, iExtra2);

  if ((pData != MNG_NULL) && (pData->iMagic == MNG_MAGIC))
  {
    if (pData->fErrorproc)             /* callback defined ? */
      return pData->fErrorproc (((mng_handle)pData), iError, pData->iSeverity,
                                pData->iChunkname, pData->iChunkseq,
                                pData->iErrorx1, pData->iErrorx2, pData->zErrortext);
  }

#ifdef MNG_SUPPORT_TRACE
  MNG_TRACEB (pData, MNG_FN_PROCESS_ERROR, MNG_LC_END)
#endif

  return MNG_TRUE;                     /* warnings are ignored by default ! */
}

/* ************************************************************************** */
/* * end of file                                                            * */
/* ************************************************************************** */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -