Rev | Line | |
---|
[13] | 1 | /* |
---|
| 2 | * $Id: error.c,v 1.4 2002/09/09 23:55:44 fabio Exp $ |
---|
| 3 | * |
---|
| 4 | */ |
---|
| 5 | #include "util.h" |
---|
| 6 | #include "error.h" |
---|
| 7 | |
---|
| 8 | static char *error_str = 0; |
---|
| 9 | static int error_str_len, error_str_maxlen; |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | void |
---|
| 13 | error_init(void) |
---|
| 14 | { |
---|
| 15 | if (error_str != 0) { |
---|
| 16 | FREE(error_str); |
---|
| 17 | } |
---|
| 18 | error_str_len = 0; |
---|
| 19 | error_str_maxlen = 100; |
---|
| 20 | error_str = ALLOC(char, error_str_maxlen); |
---|
| 21 | *error_str = '\0'; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | void |
---|
| 26 | error_append(char *s) |
---|
| 27 | { |
---|
| 28 | int slen; |
---|
| 29 | |
---|
| 30 | slen = strlen(s); |
---|
| 31 | if (error_str_len + slen + 1 > error_str_maxlen) { |
---|
| 32 | error_str_maxlen = (error_str_len + slen) * 2; /* cstevens@ic */ |
---|
| 33 | error_str = REALLOC(char, error_str, error_str_maxlen); |
---|
| 34 | } |
---|
| 35 | (void) strcpy(error_str + error_str_len, s); |
---|
| 36 | error_str_len += slen; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | char * |
---|
| 41 | error_string(void) |
---|
| 42 | { |
---|
| 43 | return error_str; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | void |
---|
| 48 | error_cleanup(void) |
---|
| 49 | { |
---|
| 50 | FREE(error_str); |
---|
| 51 | error_str_len = 0; |
---|
| 52 | error_str_maxlen = 0; |
---|
| 53 | error_str = 0; |
---|
| 54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.