home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / dosutils / ext2tool / src / e2err.c < prev    next >
C/C++ Source or Header  |  1995-05-14  |  1KB  |  48 lines

  1. /***************************************************************************
  2.  * error code routine
  3.  *
  4.  * Copyright (C) 1995 Claus Tondering, ct@login.dknet.dk
  5.  * This file may be redistributed under the terms of the GNU Public License.
  6.  ***************************************************************************/
  7.  
  8. #include <stdio.h>
  9. #include <errno.h>
  10. #include "e2err.h"
  11.  
  12.  
  13. struct errlist {
  14.     int value;
  15.     char *text;
  16. } errors[] = {
  17.     ENOENT,        "No such file or directory",
  18.     ENOTDIR,    "Not a directory",
  19.     0x07,        "Illegal disk number",
  20.     0x80,        "Disk not ready",
  21.     0xaa,        "Disk not ready",
  22.     E2E_NOCWD,    "E2CWD environment not specified",
  23.     E2E_BADCWD,    "E2CWD environment has bad format",
  24.     E2E_BADFS,    "Disk does not contain an ext2 file system",
  25.     E2E_BADPART,"Disk partitioning is corrupted",
  26.     E2E_BADMEM,    "Not enough memory",
  27. };
  28.  
  29. #define ERRCOUNT (sizeof(errors)/sizeof(errors[0]))
  30.  
  31.  
  32.  
  33. void
  34. e2_err(char * text, int err)
  35. {
  36.     int i;
  37.  
  38.     for (i=0; i<ERRCOUNT; i++) {
  39.         if (errors[i].value == err) {
  40.             fprintf(stderr,"%s: %s\n",text,errors[i].text);
  41.             exit(1);
  42.         }
  43.     }
  44.  
  45.     fprintf(stderr,"%s: Error number %d\n",text,err);
  46.     exit(1);
  47. }
  48.