-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.c
executable file
·39 lines (37 loc) · 1.12 KB
/
error.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* $Id: error.c,v 1.2 2012/07/03 17:35:44 ferber Exp $ */
#include "iban.h"
#include <string.h>
#include <stdio.h>
char *iban_error(char *etx, int ecd) {
int subcode= ecd % 100;
if(ecd == IBAN_ERR_OK) {
strcpy(etx, "No error");
}
else if(ecd == IBAN_ERR_BADARGS) {
strcpy(etx, "Bad arguments / null pointer");
}
else if(ecd == IBAN_ERR_NOMEM) {
strcpy(etx, "Not enough memory");
}
else if(ecd == IBAN_ERR_COUNTRY) {
strcpy(etx, "Unknown country code");
}
else if(ecd-subcode == IBAN_ERR_LENGTH) {
sprintf(etx, "Expected number of characters: %d", subcode);
}
else if(ecd-subcode == IBAN_ERR_CHECKSUM) {
sprintf(etx, "Checksum error; calculated: %02d", subcode);
}
else if(ecd-subcode == IBAN_ERR_DIGIT) {
sprintf(etx, "Expected a digit [0-9] at position %d", subcode);
}
else if(ecd-subcode == IBAN_ERR_ALPHA) {
sprintf(etx, "Expected a letter [A-Z] at position %d", subcode);
}
else if(ecd-subcode == IBAN_ERR_ALNUM) {
sprintf(etx, "Expected a letter [A-Z] or a digit [0-9]"
" at position %d", subcode);
}
else strcpy(etx, "Unknown error");
return etx;
}