summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-07-06 16:57:28 +0300
committerLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-07-06 17:01:13 +0300
commitffeecc715ad86e4f8a9c914c1fd4d86cd3e31263 (patch)
tree28bcf1d84d9783566cb8f2bd12d349e3d1f45834
parent438d3c7c15bdbacff31e4437adf40fbcd5a7edcc (diff)
downloadobexd-ffeecc715ad86e4f8a9c914c1fd4d86cd3e31263.tar.gz
log: fix use of log_ prefix
-rw-r--r--src/log.c148
-rw-r--r--src/log.h17
-rw-r--r--src/obex.c140
3 files changed, 152 insertions, 153 deletions
diff --git a/src/log.c b/src/log.c
index 02c06fb..8c5d769 100644
--- a/src/log.c
+++ b/src/log.c
@@ -57,7 +57,7 @@ void error(const char *format, ...)
va_end(ap);
}
-void log_debug(const char *format, ...)
+void obex_debug(const char *format, ...)
{
va_list ap;
@@ -68,146 +68,14 @@ void log_debug(const char *format, ...)
va_end(ap);
}
-static struct {
- int evt;
- const char *name;
-} obex_event[] = {
- /* Progress has been made */
- { OBEX_EV_PROGRESS, "PROGRESS" },
- /* An incoming request is about to come */
- { OBEX_EV_REQHINT, "REQHINT" },
- /* An incoming request has arrived */
- { OBEX_EV_REQ, "REQ" },
- /* Request has finished */
- { OBEX_EV_REQDONE, "REQDONE" },
- /* Link has been disconnected */
- { OBEX_EV_LINKERR, "LINKERR" },
- /* Malformed data encountered */
- { OBEX_EV_PARSEERR, "PARSEERR" },
- /* Connection accepted */
- { OBEX_EV_ACCEPTHINT, "ACCEPTHINT" },
- /* Request was aborted */
- { OBEX_EV_ABORT, "ABORT" },
- /* Need to feed more data when sending a stream */
- { OBEX_EV_STREAMEMPTY, "STREAMEMPTY" },
- /* Time to pick up data when receiving a stream */
- { OBEX_EV_STREAMAVAIL, "STREAMAVAIL" },
- /* Unexpected data, not fatal */
- { OBEX_EV_UNEXPECTED, "UNEXPECTED" },
- /* First packet of an incoming request has been parsed */
- { OBEX_EV_REQCHECK, "REQCHECK" },
- { 0xFF, NULL },
-};
-
-/* Possible commands */
-static struct {
- int cmd;
- const char *name;
-} obex_command[] = {
- { OBEX_CMD_CONNECT, "CONNECT" },
- { OBEX_CMD_DISCONNECT, "DISCONNECT" },
- { OBEX_CMD_PUT, "PUT" },
- { OBEX_CMD_GET, "GET" },
- { OBEX_CMD_SETPATH, "SETPATH" },
- { OBEX_CMD_SESSION, "SESSION" },
- { OBEX_CMD_ABORT, "ABORT" },
- { OBEX_FINAL, "FINAL" },
- { 0xFF, NULL },
-};
-
-/* Possible Response */
-static struct {
- int rsp;
- const char *name;
-} obex_response[] = {
- { OBEX_RSP_CONTINUE, "CONTINUE" },
- { OBEX_RSP_SWITCH_PRO, "SWITCH_PRO" },
- { OBEX_RSP_SUCCESS, "SUCCESS" },
- { OBEX_RSP_CREATED, "CREATED" },
- { OBEX_RSP_ACCEPTED, "ACCEPTED" },
- { OBEX_RSP_NON_AUTHORITATIVE, "NON_AUTHORITATIVE" },
- { OBEX_RSP_NO_CONTENT, "NO_CONTENT" },
- { OBEX_RSP_RESET_CONTENT, "RESET_CONTENT" },
- { OBEX_RSP_PARTIAL_CONTENT, "PARTIAL_CONTENT" },
- { OBEX_RSP_MULTIPLE_CHOICES, "MULTIPLE_CHOICES" },
- { OBEX_RSP_MOVED_PERMANENTLY, "MOVED_PERMANENTLY" },
- { OBEX_RSP_MOVED_TEMPORARILY, "MOVED_TEMPORARILY" },
- { OBEX_RSP_SEE_OTHER, "SEE_OTHER" },
- { OBEX_RSP_NOT_MODIFIED, "NOT_MODIFIED" },
- { OBEX_RSP_USE_PROXY, "USE_PROXY" },
- { OBEX_RSP_BAD_REQUEST, "BAD_REQUEST" },
- { OBEX_RSP_UNAUTHORIZED, "UNAUTHORIZED" },
- { OBEX_RSP_PAYMENT_REQUIRED, "PAYMENT_REQUIRED" },
- { OBEX_RSP_FORBIDDEN, "FORBIDDEN" },
- { OBEX_RSP_NOT_FOUND, "NOT_FOUND" },
- { OBEX_RSP_METHOD_NOT_ALLOWED, "METHOD_NOT_ALLOWED" },
- { OBEX_RSP_NOT_ACCEPTABLE, "NOT_ACCEPTABLE" },
- { OBEX_RSP_PROXY_AUTH_REQUIRED, "PROXY_AUTH_REQUIRED" },
- { OBEX_RSP_REQUEST_TIME_OUT, "REQUEST_TIME_OUT" },
- { OBEX_RSP_CONFLICT, "CONFLICT" },
- { OBEX_RSP_GONE, "GONE" },
- { OBEX_RSP_LENGTH_REQUIRED, "LENGTH_REQUIRED" },
- { OBEX_RSP_PRECONDITION_FAILED, "PRECONDITION_FAILED" },
- { OBEX_RSP_REQ_ENTITY_TOO_LARGE, "REQ_ENTITY_TOO_LARGE" },
- { OBEX_RSP_REQ_URL_TOO_LARGE, "REQ_URL_TOO_LARGE" },
- { OBEX_RSP_UNSUPPORTED_MEDIA_TYPE, "UNSUPPORTED_MEDIA_TYPE"},
- { OBEX_RSP_INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR" },
- { OBEX_RSP_NOT_IMPLEMENTED, "NOT_IMPLEMENTED" },
- { OBEX_RSP_BAD_GATEWAY, "BAD_GATEWAY" },
- { OBEX_RSP_SERVICE_UNAVAILABLE, "SERVICE_UNAVAILABLE" },
- { OBEX_RSP_GATEWAY_TIMEOUT, "GATEWAY_TIMEOUT" },
- { OBEX_RSP_VERSION_NOT_SUPPORTED, "VERSION_NOT_SUPPORTED" },
- { OBEX_RSP_DATABASE_FULL, "DATABASE_FULL" },
- { OBEX_RSP_DATABASE_LOCKED, "DATABASE_LOCKED" },
- { 0xFF, NULL },
-};
-
-void obex_debug(int evt, int cmd, int rsp)
-{
- const char *evtstr = NULL, *cmdstr = NULL, *rspstr = NULL;
- int i;
- static int lastevt, lastcmd;
-
- if (evt < 0)
- evt = lastevt;
- else
- lastevt = evt;
-
- if (cmd < 0)
- cmd = lastcmd;
- else
- lastcmd = cmd;
-
- for (i = 0; obex_event[i].evt != 0xFF; i++) {
- if (obex_event[i].evt != evt)
- continue;
- evtstr = obex_event[i].name;
- }
-
- for (i = 0; obex_command[i].cmd != 0xFF; i++) {
- if (obex_command[i].cmd != cmd)
- continue;
- cmdstr = obex_command[i].name;
- }
-
- for (i = 0; obex_response[i].rsp != 0xFF; i++) {
- if (obex_response[i].rsp != rsp)
- continue;
- rspstr = obex_response[i].name;
- }
-
- log_debug("%s(0x%x), %s(0x%x), %s(0x%x)", evtstr, evt, cmdstr, cmd,
- rspstr, rsp);
-}
-
-extern struct log_debug_desc __start___debug[];
-extern struct log_debug_desc __stop___debug[];
+extern struct obex_debug_desc __start___debug[];
+extern struct obex_debug_desc __stop___debug[];
static gchar **enabled = NULL;
int debug_enabled = FALSE;
-static gboolean is_enabled(struct log_debug_desc *desc)
+static gboolean is_enabled(struct obex_debug_desc *desc)
{
int i;
@@ -228,16 +96,16 @@ static gboolean is_enabled(struct log_debug_desc *desc)
void log_enable_debug()
{
- struct log_debug_desc *desc;
+ struct obex_debug_desc *desc;
for (desc = __start___debug; desc < __stop___debug; desc++)
- desc->flags |= LOG_DEBUG_FLAG_PRINT;
+ desc->flags |= OBEX_DEBUG_FLAG_PRINT;
}
void log_init(const char *ident, const char *debug, int log_option)
{
int option = log_option | LOG_NDELAY | LOG_PID;
- struct log_debug_desc *desc;
+ struct obex_debug_desc *desc;
const char *name = NULL, *file = NULL;
if (debug != NULL)
@@ -253,7 +121,7 @@ void log_init(const char *ident, const char *debug, int log_option)
}
if (is_enabled(desc))
- desc->flags |= LOG_DEBUG_FLAG_PRINT;
+ desc->flags |= OBEX_DEBUG_FLAG_PRINT;
}
openlog(ident, option, LOG_DAEMON);
diff --git a/src/log.h b/src/log.h
index 12dc513..93d8dde 100644
--- a/src/log.h
+++ b/src/log.h
@@ -23,18 +23,17 @@
void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void log_debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void obex_debug(int evt, int cmd, int rsp);
+void obex_debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
void log_init(const char *ident, const char *debug, int log_option);
void log_cleanup(void);
void log_enable_debug(void);
-struct log_debug_desc {
+struct obex_debug_desc {
const char *name;
const char *file;
-#define LOG_DEBUG_FLAG_DEFAULT (0)
-#define LOG_DEBUG_FLAG_PRINT (1 << 0)
+#define OBEX_DEBUG_FLAG_DEFAULT (0)
+#define OBEX_DEBUG_FLAG_PRINT (1 << 0)
unsigned int flags;
} __attribute__((aligned(8)));
@@ -47,10 +46,10 @@ struct log_debug_desc {
* name it is called in.
*/
#define DBG(fmt, arg...) do { \
- static struct log_debug_desc __log_debug_desc \
+ static struct obex_debug_desc __obex_debug_desc \
__attribute__((used, section("__debug"), aligned(8))) = { \
- .file = __FILE__, .flags = LOG_DEBUG_FLAG_DEFAULT, \
+ .file = __FILE__, .flags = OBEX_DEBUG_FLAG_DEFAULT, \
}; \
- if (__log_debug_desc.flags & LOG_DEBUG_FLAG_PRINT) \
- log_debug("%s:%s() " fmt, __FILE__, __FUNCTION__ , ## arg); \
+ if (__obex_debug_desc.flags & OBEX_DEBUG_FLAG_PRINT) \
+ obex_debug("%s:%s() " fmt, __FILE__, __FUNCTION__ , ## arg); \
} while (0)
diff --git a/src/obex.c b/src/obex.c
index 53474ec..9d001dd 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -85,6 +85,138 @@ struct auth_header {
uint8_t val[0];
} __attribute__ ((packed));
+static struct {
+ int evt;
+ const char *name;
+} obex_event[] = {
+ /* Progress has been made */
+ { OBEX_EV_PROGRESS, "PROGRESS" },
+ /* An incoming request is about to come */
+ { OBEX_EV_REQHINT, "REQHINT" },
+ /* An incoming request has arrived */
+ { OBEX_EV_REQ, "REQ" },
+ /* Request has finished */
+ { OBEX_EV_REQDONE, "REQDONE" },
+ /* Link has been disconnected */
+ { OBEX_EV_LINKERR, "LINKERR" },
+ /* Malformed data encountered */
+ { OBEX_EV_PARSEERR, "PARSEERR" },
+ /* Connection accepted */
+ { OBEX_EV_ACCEPTHINT, "ACCEPTHINT" },
+ /* Request was aborted */
+ { OBEX_EV_ABORT, "ABORT" },
+ /* Need to feed more data when sending a stream */
+ { OBEX_EV_STREAMEMPTY, "STREAMEMPTY" },
+ /* Time to pick up data when receiving a stream */
+ { OBEX_EV_STREAMAVAIL, "STREAMAVAIL" },
+ /* Unexpected data, not fatal */
+ { OBEX_EV_UNEXPECTED, "UNEXPECTED" },
+ /* First packet of an incoming request has been parsed */
+ { OBEX_EV_REQCHECK, "REQCHECK" },
+ { 0xFF, NULL },
+};
+
+/* Possible commands */
+static struct {
+ int cmd;
+ const char *name;
+} obex_command[] = {
+ { OBEX_CMD_CONNECT, "CONNECT" },
+ { OBEX_CMD_DISCONNECT, "DISCONNECT" },
+ { OBEX_CMD_PUT, "PUT" },
+ { OBEX_CMD_GET, "GET" },
+ { OBEX_CMD_SETPATH, "SETPATH" },
+ { OBEX_CMD_SESSION, "SESSION" },
+ { OBEX_CMD_ABORT, "ABORT" },
+ { OBEX_FINAL, "FINAL" },
+ { 0xFF, NULL },
+};
+
+/* Possible Response */
+static struct {
+ int rsp;
+ const char *name;
+} obex_response[] = {
+ { OBEX_RSP_CONTINUE, "CONTINUE" },
+ { OBEX_RSP_SWITCH_PRO, "SWITCH_PRO" },
+ { OBEX_RSP_SUCCESS, "SUCCESS" },
+ { OBEX_RSP_CREATED, "CREATED" },
+ { OBEX_RSP_ACCEPTED, "ACCEPTED" },
+ { OBEX_RSP_NON_AUTHORITATIVE, "NON_AUTHORITATIVE" },
+ { OBEX_RSP_NO_CONTENT, "NO_CONTENT" },
+ { OBEX_RSP_RESET_CONTENT, "RESET_CONTENT" },
+ { OBEX_RSP_PARTIAL_CONTENT, "PARTIAL_CONTENT" },
+ { OBEX_RSP_MULTIPLE_CHOICES, "MULTIPLE_CHOICES" },
+ { OBEX_RSP_MOVED_PERMANENTLY, "MOVED_PERMANENTLY" },
+ { OBEX_RSP_MOVED_TEMPORARILY, "MOVED_TEMPORARILY" },
+ { OBEX_RSP_SEE_OTHER, "SEE_OTHER" },
+ { OBEX_RSP_NOT_MODIFIED, "NOT_MODIFIED" },
+ { OBEX_RSP_USE_PROXY, "USE_PROXY" },
+ { OBEX_RSP_BAD_REQUEST, "BAD_REQUEST" },
+ { OBEX_RSP_UNAUTHORIZED, "UNAUTHORIZED" },
+ { OBEX_RSP_PAYMENT_REQUIRED, "PAYMENT_REQUIRED" },
+ { OBEX_RSP_FORBIDDEN, "FORBIDDEN" },
+ { OBEX_RSP_NOT_FOUND, "NOT_FOUND" },
+ { OBEX_RSP_METHOD_NOT_ALLOWED, "METHOD_NOT_ALLOWED" },
+ { OBEX_RSP_NOT_ACCEPTABLE, "NOT_ACCEPTABLE" },
+ { OBEX_RSP_PROXY_AUTH_REQUIRED, "PROXY_AUTH_REQUIRED" },
+ { OBEX_RSP_REQUEST_TIME_OUT, "REQUEST_TIME_OUT" },
+ { OBEX_RSP_CONFLICT, "CONFLICT" },
+ { OBEX_RSP_GONE, "GONE" },
+ { OBEX_RSP_LENGTH_REQUIRED, "LENGTH_REQUIRED" },
+ { OBEX_RSP_PRECONDITION_FAILED, "PRECONDITION_FAILED" },
+ { OBEX_RSP_REQ_ENTITY_TOO_LARGE, "REQ_ENTITY_TOO_LARGE" },
+ { OBEX_RSP_REQ_URL_TOO_LARGE, "REQ_URL_TOO_LARGE" },
+ { OBEX_RSP_UNSUPPORTED_MEDIA_TYPE, "UNSUPPORTED_MEDIA_TYPE"},
+ { OBEX_RSP_INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR" },
+ { OBEX_RSP_NOT_IMPLEMENTED, "NOT_IMPLEMENTED" },
+ { OBEX_RSP_BAD_GATEWAY, "BAD_GATEWAY" },
+ { OBEX_RSP_SERVICE_UNAVAILABLE, "SERVICE_UNAVAILABLE" },
+ { OBEX_RSP_GATEWAY_TIMEOUT, "GATEWAY_TIMEOUT" },
+ { OBEX_RSP_VERSION_NOT_SUPPORTED, "VERSION_NOT_SUPPORTED" },
+ { OBEX_RSP_DATABASE_FULL, "DATABASE_FULL" },
+ { OBEX_RSP_DATABASE_LOCKED, "DATABASE_LOCKED" },
+ { 0xFF, NULL },
+};
+
+static void print_event(int evt, int cmd, int rsp)
+{
+ const char *evtstr = NULL, *cmdstr = NULL, *rspstr = NULL;
+ int i;
+ static int lastevt, lastcmd;
+
+ if (evt < 0)
+ evt = lastevt;
+ else
+ lastevt = evt;
+
+ if (cmd < 0)
+ cmd = lastcmd;
+ else
+ lastcmd = cmd;
+
+ for (i = 0; obex_event[i].evt != 0xFF; i++) {
+ if (obex_event[i].evt != evt)
+ continue;
+ evtstr = obex_event[i].name;
+ }
+
+ for (i = 0; obex_command[i].cmd != 0xFF; i++) {
+ if (obex_command[i].cmd != cmd)
+ continue;
+ cmdstr = obex_command[i].name;
+ }
+
+ for (i = 0; obex_response[i].rsp != 0xFF; i++) {
+ if (obex_response[i].rsp != rsp)
+ continue;
+ rspstr = obex_response[i].name;
+ }
+
+ obex_debug("%s(0x%x), %s(0x%x), %s(0x%x)", evtstr, evt, cmdstr, cmd,
+ rspstr, rsp);
+}
+
static void os_set_response(obex_object_t *obj, int err)
{
uint8_t rsp;
@@ -126,7 +258,7 @@ static void os_set_response(obex_object_t *obj, int err)
lastrsp = OBEX_RSP_INTERNAL_SERVER_ERROR;
}
- obex_debug(-1, -1, rsp);
+ print_event(-1, -1, rsp);
OBEX_ObjectSetRsp(obj, rsp, lastrsp);
}
@@ -937,13 +1069,13 @@ static void cmd_put(struct obex_session *os, obex_t *obex, obex_object_t *obj)
os_set_response(obj, err);
}
-static void obex_event(obex_t *obex, obex_object_t *obj, int mode,
+static void obex_event_cb(obex_t *obex, obex_object_t *obj, int mode,
int evt, int cmd, int rsp)
{
struct obex_session *os;
int err;
- obex_debug(evt, cmd, rsp);
+ print_event(evt, cmd, rsp);
os = OBEX_GetUserData(obex);
@@ -1118,7 +1250,7 @@ int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
os->tx_mtu = tx_mtu != 0 ? tx_mtu : DEFAULT_TX_MTU;
os->size = OBJECT_SIZE_DELETE;
- obex = OBEX_Init(OBEX_TRANS_FD, obex_event, 0);
+ obex = OBEX_Init(OBEX_TRANS_FD, obex_event_cb, 0);
if (!obex) {
obex_session_free(os);
return -EIO;