summaryrefslogtreecommitdiff
path: root/exceptions.c
diff options
context:
space:
mode:
authorPixel <Pixel>2001-04-28 21:40:25 +0000
committerPixel <Pixel>2001-04-28 21:40:25 +0000
commit3b37a00a4be251f87e543d269489cb7a989425d5 (patch)
tree51aedcb4d1627743d6e240266c58a67cf6ae0d67 /exceptions.c
parentab778d7f896b16f3e6f2b068c2b34d219723002b (diff)
Hop, gros bordel, plein de fichiers ajoutes et supprimes :)
Diffstat (limited to 'exceptions.c')
-rw-r--r--exceptions.c84
1 files changed, 0 insertions, 84 deletions
diff --git a/exceptions.c b/exceptions.c
deleted file mode 100644
index cd8bf81..0000000
--- a/exceptions.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *
- * Gestionnaire d'exceptions
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#else
-#define _(x) x
-#endif
-#include "exceptions.h"
-
-char *contexts[128];
-int clevel = 0;
-
-char *Estrdup(char *o)
-{
- char *r;
-
- if (o) {
- if (!(r = strdup(o))) {
- exception(1, _("Out of memory."));
- }
- } else {
- return NULL;
- }
- return r;
-}
-
-void *Emalloc(size_t s)
-{
- void *r;
-
- if (s) {
- if (!(r = malloc(s))) {
- exception(1, _("Out of memory."));
- }
- } else {
- return NULL;
- }
- return r;
-}
-
-void pushcontext(char *c)
-{
- if (clevel == 128) {
- exception(1, _("Too much error contexts during pushcontext()."));
- }
- contexts[clevel++] = Estrdup(c);
-#ifdef DEBUG
- fprintf(stderr,"%s\n",c);
-#endif
-}
-
-void popcontext(void)
-{
- if (clevel == 0) {
- exception(1, _("Error context empty, but popcontext() called."));
- }
- free(contexts[--clevel]);
-}
-
-void flushcontext(void)
-{
- while (clevel) {
- popcontext();
- }
-}
-
-void exception(int level, char *msg)
-{
- int i;
-
- fprintf(stderr, "Error detected. Showing context.\n");
- for (i = 0; i < clevel; i++) {
- fprintf(stderr, " (%i) - %s\n", i, contexts[i]);
- }
- fprintf(stderr, " Error description: %s\n", msg);
- exit(level);
-}