linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH obexd 1/6] gobex: Add translating error codes to strings
@ 2011-12-08 13:07 Bartosz Szatkowski
  2011-12-08 13:07 ` [PATCH obexd 2/6] Add basic support for MAP client in obex-client Bartosz Szatkowski
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Bartosz Szatkowski @ 2011-12-08 13:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bartosz Szatkowski

---
 gobex/gobex.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gobex/gobex.h |    2 ++
 2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index b374b06..38d6812 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -114,6 +114,62 @@ struct setpath_data {
 	guint8 constants;
 } __attribute__ ((packed));
 
+struct error_code {
+	guint8 code;
+	const char *name;
+} obex_errors[] = {
+	{ G_OBEX_RSP_CONTINUE,			"Continue" },
+	{ G_OBEX_RSP_SUCCESS,			"Success" },
+	{ G_OBEX_RSP_CREATED,			"Created" },
+	{ G_OBEX_RSP_ACCEPTED,			"Accepted" },
+	{ G_OBEX_RSP_NON_AUTHORITATIVE,		"Non Authoritative" },
+	{ G_OBEX_RSP_NO_CONTENT,		"No Content" },
+	{ G_OBEX_RSP_RESET_CONTENT,		"Reset Content" },
+	{ G_OBEX_RSP_PARTIAL_CONTENT,		"Partial Content" },
+	{ G_OBEX_RSP_MULTIPLE_CHOICES,		"Multiple Choices" },
+	{ G_OBEX_RSP_MOVED_PERMANENTLY,		"Moved Permanently" },
+	{ G_OBEX_RSP_MOVED_TEMPORARILY,		"Moved Temporarily" },
+	{ G_OBEX_RSP_SEE_OTHER,			"See Other" },
+	{ G_OBEX_RSP_NOT_MODIFIED,		"Not Modified" },
+	{ G_OBEX_RSP_USE_PROXY,			"Use Proxy" },
+	{ G_OBEX_RSP_BAD_REQUEST,		"Bad Request" },
+	{ G_OBEX_RSP_UNAUTHORIZED,		"Unauthorized" },
+	{ G_OBEX_RSP_PAYMENT_REQUIRED,		"Payment Required" },
+	{ G_OBEX_RSP_FORBIDDEN,			"Forbidden" },
+	{ G_OBEX_RSP_NOT_FOUND,			"Not Found" },
+	{ G_OBEX_RSP_METHOD_NOT_ALLOWED,	"Method Not Allowed" },
+	{ G_OBEX_RSP_NOT_ACCEPTABLE,		"Not Acceptable" },
+	{ G_OBEX_RSP_PROXY_AUTH_REQUIRED,	"Proxy Authentication Required" },
+	{ G_OBEX_RSP_REQUEST_TIME_OUT,		"Request Time Out" },
+	{ G_OBEX_RSP_CONFLICT,			"Conflict" },
+	{ G_OBEX_RSP_GONE,			"Gone" },
+	{ G_OBEX_RSP_LENGTH_REQUIRED,		"Length Required" },
+	{ G_OBEX_RSP_PRECONDITION_FAILED,	"Precondition Failed" },
+	{ G_OBEX_RSP_REQ_ENTITY_TOO_LARGE,	"Request Entity Too Large" },
+	{ G_OBEX_RSP_REQ_URL_TOO_LARGE,		"Request URL Too Large" },
+	{ G_OBEX_RSP_UNSUPPORTED_MEDIA_TYPE,	"Unsupported Media Type" },
+	{ G_OBEX_RSP_INTERNAL_SERVER_ERROR,	"Internal Server Error" },
+	{ G_OBEX_RSP_NOT_IMPLEMENTED,		"Not Implemented" },
+	{ G_OBEX_RSP_BAD_GATEWAY,		"Bad Gateway" },
+	{ G_OBEX_RSP_SERVICE_UNAVAILABLE,	"Service Unavailable" },
+	{ G_OBEX_RSP_GATEWAY_TIMEOUT,		"Gateway Timeout" },
+	{ G_OBEX_RSP_VERSION_NOT_SUPPORTED,	"Version Not Supported" },
+	{ G_OBEX_RSP_DATABASE_FULL,		"Database Full" },
+	{ G_OBEX_RSP_DATABASE_LOCKED,		"Database Locked" },
+	{ 0x00,					NULL }
+};
+
+const char *g_obex_strerror(guint8 err_code)
+{
+	struct error_code *error;
+
+	for (error = obex_errors; error->name != NULL; error++)
+		if (error->code == err_code)
+			return error->name;
+
+	return "<unknown>";
+}
+
 static ssize_t req_header_offset(guint8 opcode)
 {
 	switch (opcode) {
diff --git a/gobex/gobex.h b/gobex/gobex.h
index 1b20333..81981ea 100644
--- a/gobex/gobex.h
+++ b/gobex/gobex.h
@@ -119,4 +119,6 @@ guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
 
 gboolean g_obex_cancel_transfer(guint id);
 
+const char *g_obex_strerror(guint8 err_code);
+
 #endif /* __GOBEX_H */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [PATCH obexd 1/6] gobex: Add translating error codes to strings
@ 2011-12-05 11:41 Bartosz Szatkowski
  2011-12-05 11:41 ` [PATCH obexd 3/6] Add support for SetFolder in MAP client Bartosz Szatkowski
  0 siblings, 1 reply; 9+ messages in thread
From: Bartosz Szatkowski @ 2011-12-05 11:41 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bartosz Szatkowski

---
 gobex/gobex.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gobex/gobex.h |    2 ++
 2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index b374b06..9fe7a1a 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -114,6 +114,62 @@ struct setpath_data {
 	guint8 constants;
 } __attribute__ ((packed));
 
+struct error_code {
+	guint8 code;
+	const char *name;
+} obex_errors[] = {
+	{ G_OBEX_RSP_CONTINUE, "Continue" },
+	{ G_OBEX_RSP_SUCCESS, "Success" },
+	{ G_OBEX_RSP_CREATED, "Created" },
+	{ G_OBEX_RSP_ACCEPTED, "Accepted" },
+	{ G_OBEX_RSP_NON_AUTHORITATIVE, "Non Authoritative" },
+	{ G_OBEX_RSP_NO_CONTENT, "No Content" },
+	{ G_OBEX_RSP_RESET_CONTENT, "Reset Content" },
+	{ G_OBEX_RSP_PARTIAL_CONTENT, "Partial Content" },
+	{ G_OBEX_RSP_MULTIPLE_CHOICES, "Multiple Choices" },
+	{ G_OBEX_RSP_MOVED_PERMANENTLY, "Moved Permanently" },
+	{ G_OBEX_RSP_MOVED_TEMPORARILY, "Moved Temporarily" },
+	{ G_OBEX_RSP_SEE_OTHER, "See Other" },
+	{ G_OBEX_RSP_NOT_MODIFIED, "Not Modified" },
+	{ G_OBEX_RSP_USE_PROXY, "Use Proxy" },
+	{ G_OBEX_RSP_BAD_REQUEST, "Bad Request" },
+	{ G_OBEX_RSP_UNAUTHORIZED, "Unauthorized" },
+	{ G_OBEX_RSP_PAYMENT_REQUIRED, "Payment Required" },
+	{ G_OBEX_RSP_FORBIDDEN, "Forbidden" },
+	{ G_OBEX_RSP_NOT_FOUND, "Not Found" },
+	{ G_OBEX_RSP_METHOD_NOT_ALLOWED, "Method Not Allowed" },
+	{ G_OBEX_RSP_NOT_ACCEPTABLE, "Not Acceptable" },
+	{ G_OBEX_RSP_PROXY_AUTH_REQUIRED, "Proxy Auth Required" },
+	{ G_OBEX_RSP_REQUEST_TIME_OUT, "Request Time Out" },
+	{ G_OBEX_RSP_CONFLICT, "Conflict" },
+	{ G_OBEX_RSP_GONE, "Gone" },
+	{ G_OBEX_RSP_LENGTH_REQUIRED, "Length Required" },
+	{ G_OBEX_RSP_PRECONDITION_FAILED, "Precondition Failed" },
+	{ G_OBEX_RSP_REQ_ENTITY_TOO_LARGE, "Req Entity Too Large" },
+	{ G_OBEX_RSP_REQ_URL_TOO_LARGE, "Req Url Too Large" },
+	{ G_OBEX_RSP_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type" },
+	{ G_OBEX_RSP_INTERNAL_SERVER_ERROR, "Internal Server Error" },
+	{ G_OBEX_RSP_NOT_IMPLEMENTED, "Not Implemented" },
+	{ G_OBEX_RSP_BAD_GATEWAY, "Bad Gateway" },
+	{ G_OBEX_RSP_SERVICE_UNAVAILABLE, "Service Unavailable" },
+	{ G_OBEX_RSP_GATEWAY_TIMEOUT, "Gateway Timeout" },
+	{ G_OBEX_RSP_VERSION_NOT_SUPPORTED, "Version Not Supported" },
+	{ G_OBEX_RSP_DATABASE_FULL, "Database Full" },
+	{ G_OBEX_RSP_DATABASE_LOCKED, "Database Locked" },
+	{ }
+};
+
+const char *g_obex_strerror(guint8 err_code)
+{
+	struct error_code *error;
+
+	for (error = obex_errors; error != NULL; error++)
+		if (error->code == err_code)
+			return error->name;
+
+	return "<unknown>";
+}
+
 static ssize_t req_header_offset(guint8 opcode)
 {
 	switch (opcode) {
diff --git a/gobex/gobex.h b/gobex/gobex.h
index 1b20333..81981ea 100644
--- a/gobex/gobex.h
+++ b/gobex/gobex.h
@@ -119,4 +119,6 @@ guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
 
 gboolean g_obex_cancel_transfer(guint id);
 
+const char *g_obex_strerror(guint8 err_code);
+
 #endif /* __GOBEX_H */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-12-09 13:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-08 13:07 [PATCH obexd 1/6] gobex: Add translating error codes to strings Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 2/6] Add basic support for MAP client in obex-client Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 3/6] Add support for SetFolder in MAP client Bartosz Szatkowski
2011-12-09 13:22   ` Johan Hedberg
2011-12-09 13:58     ` Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 4/6] Add simple helper for " Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 5/6] Add basic support for MAP folder listing Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 6/6] Add support for PullMessagesListing in MAP client Bartosz Szatkowski
  -- strict thread matches above, loose matches on Subject: below --
2011-12-05 11:41 [PATCH obexd 1/6] gobex: Add translating error codes to strings Bartosz Szatkowski
2011-12-05 11:41 ` [PATCH obexd 3/6] Add support for SetFolder in MAP client Bartosz Szatkowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).