OpenOCD
error.c
Go to the documentation of this file.
1 /*
2  * This file is part of the libjaylink project.
3  *
4  * Copyright (C) 2014-2015 Marc Schink <jaylink-dev@marcschink.de>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "libjaylink.h"
21 
40 JAYLINK_API const char *jaylink_strerror(int error_code)
41 {
42  switch (error_code) {
43  case JAYLINK_OK:
44  return "no error";
45  case JAYLINK_ERR:
46  return "unspecified error";
47  case JAYLINK_ERR_ARG:
48  return "invalid argument";
49  case JAYLINK_ERR_MALLOC:
50  return "memory allocation error";
52  return "timeout occurred";
53  case JAYLINK_ERR_PROTO:
54  return "protocol violation";
56  return "entity not available";
58  return "operation not supported";
59  case JAYLINK_ERR_IO:
60  return "input/output error";
61  case JAYLINK_ERR_DEV:
62  return "device: unspecified error";
64  return "device: operation not supported";
66  return "device: entity not available";
68  return "device: not enough memory to perform operation";
69  default:
70  return "unknown error";
71  }
72 }
73 
86 JAYLINK_API const char *jaylink_strerror_name(int error_code)
87 {
88  switch (error_code) {
89  case JAYLINK_OK:
90  return "JAYLINK_OK";
91  case JAYLINK_ERR:
92  return "JAYLINK_ERR";
93  case JAYLINK_ERR_ARG:
94  return "JAYLINK_ERR_ARG";
95  case JAYLINK_ERR_MALLOC:
96  return "JAYLINK_ERR_MALLOC";
98  return "JAYLINK_ERR_TIMEOUT";
99  case JAYLINK_ERR_PROTO:
100  return "JAYLINK_ERR_PROTO";
102  return "JAYLINK_ERR_NOT_AVAILABLE";
104  return "JAYLINK_ERR_NOT_SUPPORTED";
105  case JAYLINK_ERR_IO:
106  return "JAYLINK_ERR_IO";
107  case JAYLINK_ERR_DEV:
108  return "JAYLINK_ERR_DEV";
110  return "JAYLINK_ERR_DEV_NOT_SUPPORTED";
112  return "JAYLINK_ERR_DEV_NOT_AVAILABLE";
114  return "JAYLINK_ERR_DEV_NO_MEMORY";
115  default:
116  return "unknown error code";
117  }
118 }
JAYLINK_API const char * jaylink_strerror_name(int error_code)
Return the name of a libjaylink error code.
Definition: error.c:86
JAYLINK_API const char * jaylink_strerror(int error_code)
Return a human-readable description of a libjaylink error code.
Definition: error.c:40