home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / OLS / Os2 / LHA2P205 / LHA2P205.LZH / lha2-2.05pre / source.lzh / src / error.c < prev    next >
C/C++ Source or Header  |  1995-10-15  |  1KB  |  86 lines

  1. /*
  2.  * error.c --- error processing
  3.  *   Copyright (C) 1988-1992, Haruyasu YOSHIZAKI
  4.  *
  5.  * $Log$
  6.  */
  7.  
  8.  
  9. #include <sys/types.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <signal.h>
  13. #include <time.h>
  14. #include "typedef.h"
  15. #include "port2.h"
  16. #include "lh.h"
  17. #include "header.h"
  18. #include "errmes.h"
  19.  
  20.  
  21. /* process for error */
  22. void
  23. error(char *errmes, const char *p)
  24. {
  25.   if(file1 != NULL)
  26.     {
  27.       fclose(file1);
  28.       if(cmdupdate)        /* during updating */
  29.     rename(filename1, arcname); /* recover old archive */
  30.     }
  31.   if(errmes == COPYERR)        /* error during copying temporary? */
  32.     {
  33.       fclose(file2);
  34.       eprintf(COPYERR, filename2);
  35.       exit(3);
  36.     }
  37.   if(file3 != NULL)
  38.     {
  39.       fclose(file3);
  40.       if(cmd == 'E')        /* during extracting */
  41.     remove(filename3);    /* delete the file */
  42.     }
  43.   if(file2 != NULL)
  44.     {
  45.       fclose(file2);
  46.       remove(filename2);    /* delete temporary */
  47.     }
  48.   eprintf("\n%s", errmes);
  49.   if(p)
  50.     eprintf(" : '%s'", p);
  51.   eprintf("\n");
  52.   exit(2);
  53. }
  54.  
  55.  
  56. void
  57. fileerror(char *errmes, FILE *file)
  58. {
  59.   char *name;
  60.  
  61.   name = NULL;
  62.   if(file == file1)
  63.     name = filename1;
  64.   if(file == file2)
  65.     name = filename2;
  66.   if(file == file3)
  67.     name = hpb.pathname;
  68.  
  69.   error(errmes, name);
  70. }
  71.  
  72.  
  73. /* handle user break */
  74. void
  75. userbreak(int code)
  76. {
  77.   error(CTRLBRK, NULL);
  78. }
  79.  
  80.  
  81. void
  82. initbreak(void)
  83. {
  84.   signal(SIGINT, userbreak);
  85. }
  86.