PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/fm/error.c

https://github.com/darth/fm_lib_with_gmp
C | 65 lines | 36 code | 9 blank | 20 comment | 2 complexity | dd97991586be398c0e696e00632880ef MD5 | raw file
Possible License(s): LGPL-3.0
  1. /*
  2. * error.c: this file is part of the FM project.
  3. *
  4. * FM, a fast and optimized C implementation of Fourier-Motzkin
  5. * projection algorithm.
  6. *
  7. * Copyright (C) 2006-2008 Louis-Noel Pouchet
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public License
  11. * as published by the Free Software Foundation; either version 3
  12. * of the License, or (at your option) any later version.
  13. *
  14. * The complete GNU Lesser General Public Licence Notice can be found
  15. * as the `COPYING.LESSER' file in the root directory.
  16. *
  17. * Author:
  18. * Louis-Noel Pouchet <Louis-Noel.Pouchet@inria.fr>
  19. *
  20. */
  21. #if HAVE_CONFIG_H
  22. # include <fm/config.h>
  23. #endif
  24. #include <fm/common.h>
  25. #include <fm/error.h>
  26. static void error (int exit_status, const char *mode,
  27. const char *message);
  28. const char *program_name = NULL;
  29. void
  30. set_program_name (const char *path)
  31. {
  32. if (! program_name)
  33. program_name = xstrdup (basename (path));
  34. }
  35. static void
  36. error (int exit_status, const char *mode, const char *message)
  37. {
  38. fprintf (stderr, "%s: %s: %s.\n", program_name, mode, message);
  39. if (exit_status >= 0)
  40. exit (exit_status);
  41. }
  42. void
  43. fm_warning (const char *message)
  44. {
  45. error (-1, "warning", message);
  46. }
  47. void
  48. fm_error (const char *message)
  49. {
  50. error (-1, "ERROR", message);
  51. }
  52. void
  53. fm_fatal (const char *message)
  54. {
  55. error (EXIT_FAILURE, "FATAL", message);
  56. }