zl5011xprinterror.c

来自「Zalink50114----TDMoIP芯片驱动源码」· C语言 代码 · 共 132 行

C
132
字号
/*******************************************************************************
*
*  File name:              zl5011xPrintError.c
*
*  Version:                7
*
*  Author:                 MRC
*
*  Date created:           03/05/2002
*
*  Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
*  All rights reserved.
*
*  Module Description:
*
*  This is the header file for the error code handling functions.
*  It contains the function prototypes and any definitions.
*
*  Revision History:
*
*  Rev:  Date:       Author:  Comments:
*  1     03/05/2002  MRC      Creation
*  2     07/05/2002  MRC      Updated
*  3     13/06/2002  MRC      Added prefix to error code in print fn
*  4     19/12/2002  MRC      Tidied up.
*  5     13/01/2003  MRC      PrintError fn now uses TRACE
*  6     21/01/2003  MRC      Added include for PrintError header
*  7     20/01/2005  APL      Added alternative version of GetErrString
*
*******************************************************************************/

#include "zl5011x.h"
#include "zl5011xErrorString.h"
#include "zl5011xPrintError.h"

const char zl5011xStrErrorUnknown[] = "*** Unknown error code ***";

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

 Function:
    zl5011xGetErrString2

 Description:
   Takes an error code enum in and returns a string for that code.

 Inputs:
   status   Error code to use

 Outputs:

 Returns:
  pointer to an error string

 Remarks:
   None

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

const char * zl5011xGetErrString2(zlStatusE status)
{
   Uint32T  loop;

   for (loop = 0; loop < (sizeof(zlError) / sizeof(zlErrorStringsS)); loop++)
   {
      if (zlError[loop].code == status)
      {
         return zlError[loop].text;
      }
   }
   return zl5011xStrErrorUnknown;
}

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

 Function:
    zl5011xGetErrString

 Description:
   Takes an error code enum in and returns a string for that code.

 Inputs:
   status   Error code to use

 Outputs:
   buf      pointer to a buffer to copy the error string into

 Returns:
   Nothing

 Remarks:
   None

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

void zl5011xGetErrString(zlStatusE status, char *buf)
{
   strcpy(buf, zl5011xGetErrString2(status));
}

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

 Function:
    zl5011xPrintErr

 Description:
   Takes an error code and prints the string representation to the standard
   output

 Inputs:
   status   Error code to use

 Outputs:
   None

 Returns:
  zlStatusE

 Remarks:
   None

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

void zl5011xPrintErr(zlStatusE status)
{
   if (status != ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_ERR_FN_ID, "ERROR-API = %s (%d)",
            (Uint32T)zl5011xGetErrString2(status), status, 0, 0, 0, 0);
   }
}

⌨️ 快捷键说明

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