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

📄 flwterr.c

📁 大师写的二代小波经典之作
💻 C
字号:
/* *  -*- Mode: ANSI C -*- *  $Id: flwterr.c,v 1.3 1996/11/20 20:53:14 fernande Exp $ *  $Source: /sgi.acct/sweldens/cvs/liftpack/Util/flwterr.c,v $ *  Author: Gabriel Fernandez * *  The error handling function uses the error codes defined in the *  flwterr.h file to print the corresponding message. *//* do not edit anything above this line *//* System header files */#include <stdio.h>#include <stdlib.h>   /* for exit() *//* FLWT header files */#include <flwtdef.h>#include <flwterr.h>#include <memchk.h>/* * Error function: prints a customized error message using an internal *                 set of codes for standard error messages. Each type *                 of error message will require a number of arguments *                 used in the display of the error. There is a custom *                 type of error used for uncommon errors. */voidError ( const char *functionName, const ErrorCode errCode,        const RetType retType, ... ){    va_list  args;                    /* variable argument list */    Flt      fvar1, fvar2;            /* f.p. paramemters */    int      ivar1, ivar2;            /* integer paramemters */    char     *buf1, *buf2;            /* char/string paramemters */    char     function_name[BUFSIZ];   /* function that called error */    /* PrintLeaks();   print list of memory allocations yet not deallocated */    /* Check for function name */    va_start (args, retType);    sprintf (function_name, "%s()", functionName);    fprintf (stderr, "\n%s: ", function_name);    switch ( errCode ) {    /* check error code */        /* General Errors */        case MISSING_PARAMETER:            fprintf (stderr, "Parameter is missing from command line.\n");            break;        case INVALID_ANSWER:            fprintf (stderr, "Invalid answer. Try again!");            break;        case INVALID_RELATIONAL_INT:            buf1 = va_arg(args, char *);   /* name of variable */            buf2 = va_arg(args, char *);   /* relational operator */            ivar1 = va_arg(args, int);     /* bound */            fprintf (stderr, "%s should be %s than %d.\n", buf1, buf2, ivar1);            break;        case INVALID_RELATIONAL_FLT:            buf1 = va_arg(args, char *);   /* name of variable */            buf2 = va_arg(args, char *);   /* relational operator */            fvar1 = va_arg(args, Flt);     /* bound */            fprintf (stderr, "%s should be %s than %g.\n", buf1, buf2, fvar1);            break;        case INVALID_VALUE_INT:            buf1 = va_arg(args, char *);   /* name of variable */            ivar1 = va_arg(args, int);     /* lower bound */            ivar2 = va_arg(args, int);     /* upper bound */            fprintf (stderr, "%s should be between %d and %d.\n",                     buf1, ivar1, ivar2);            break;        case INVALID_VALUE_FLT:            buf1 = va_arg(args, char *);   /* name of variable */            fvar1 = va_arg(args, Flt);     /* lower bound */            fvar2 = va_arg(args, Flt);     /* upper bound */            fprintf (stderr, "%s should be between %g and %g.\n",                     buf1, fvar1, fvar2);            break;        case NOT_EVEN:            buf1 = va_arg(args, char *);            fprintf (stderr, "%s is not an even number.\n", buf1);            break;        case IGNORE:            buf1 = va_arg(args, char *);            fprintf (stderr, "Ignoring command line argument %s\n", buf1);            fprintf (stderr, "Use '-h' option to get help.\n");            break;        case DENOM_NEAR_ZERO:            fprintf (stderr, "Denominator near zero. Expect garbage.\n");            break;        case SINGULAR_MATRIX:            fprintf (stderr, "Singular matrix found.\n");            break;        case NO_LIFTING_MATRIX:            fprintf (stderr, "Lifting matrix hasn't yet been created.\n");            fprintf (stderr, "Run GetDual() to initialize it.");            break;        case NO_FILTER_VECTOR:            fprintf (stderr, "Filter vector hasn't yet been created.\n");            fprintf (stderr, "Run GetDual() to initialize it.");            break;        case FATAL_ERROR:            fprintf (stderr, "Fatal error. Cannot recover from this.\n");            break;        /* Memory Errors */        case MALLOC_FAIL:            fprintf (stderr, "malloc failure.\n");            perror (function_name);            break;        case CALLOC_FAIL:            fprintf (stderr, "calloc failure.\n");            perror (function_name);            break;        case REALLOC_FAIL:            fprintf (stderr, "realloc failure.\n");            perror (function_name);            break;        case MEMORY_VECTOR:            fprintf (stderr, "Error allocating memory for vector.\n");            perror (function_name);            break;        case MEMORY_MATRIX:            fprintf (stderr, "Error allocating memory for matrix.\n");            perror (function_name);            break;        case MEMORY_IMAGE:            fprintf (stderr, "Error allocating memory for image.\n");            perror (function_name);            break;        /* File Errors */        case NO_FILE:            buf1 = va_arg(args, char *);            fprintf (stderr, "Error opening file '%s'.\n", buf1);            perror (function_name);            break;        case NO_DIR:            buf1 = va_arg(args, char *);            fprintf (stderr, "\"%s\" directory does not exist.\n", buf1);            perror (function_name);            fprintf (stderr, "Execute 'mkdir %s' in current directory\n", buf1);            fprintf (stderr, "and put all your data files in there.\n");            break;        case READ_ERROR:            fprintf (stderr, "Error reading data file.\n");            perror (function_name);            break;        case WRITE_ERROR:            fprintf (stderr, "Error writing data file.\n");            perror (function_name);            break;        case INVALID_FILE_FORMAT:            buf1 = va_arg(args, char *);            fprintf (stderr, "File '%s' is not in recognized format.\n", buf1);            break;        case NO_READABLE_FORMAT:            buf1 = va_arg(args, char *);            fprintf (stderr, "File '%s' is not in a readable format.\n", buf1);            break;        case NO_FORMAT:            fprintf (stderr, "Invalid format or type not read yet.\n");            break;        /* Custom error message */        case CUSTOM:            buf1 = va_arg(args, char *);            vfprintf (stderr, buf1, args);            perror (function_name);            break;        /* Invalid Error Code */        default:            fprintf (stderr, "Invalid error code!\n");            exit (GENERAL_ERROR);            break;    }    va_end (args);    fflush (stderr);    /* Exit or return */    if ( retType == ABORT ) {        FreeLeaks();   /* free memory allocations */        exit ( (int)errCode );    } else if ( retType == RETURN ) {        return;    } else {        fprintf (stderr, "Invalid return type!");        Error ("Error", FATAL_ERROR, ABORT);        /* NOTREACHED */    }}

⌨️ 快捷键说明

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