-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdberror.c
45 lines (37 loc) · 815 Bytes
/
dberror.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
40
41
42
43
44
45
//
// dberror.c
// testcode_2_0920
//
// Created by Pingyu Xue on 9/21/16.
// Copyright © 2016 Pingyu Xue. All rights reserved.
//
#include "dberror.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
char *RC_message;
/* print a message to standard out describing the error */
void
printError (RC error)
{
if (RC_message != NULL)
printf("EC (%i), \"%s\"\n", error, RC_message);
else
printf("EC (%i)\n", error);
}
char *
errorMessage (RC error)
{
char *message;
if (RC_message != NULL)
{
message = (char *) malloc(strlen(RC_message) + 30);
sprintf(message, "EC (%i), \"%s\"\n", error, RC_message);
}
else
{
message = (char *) malloc(30);
sprintf(message, "EC (%i)\n", error);
}
return message;
}