From df9dd7403d159ffd963995f64b7037eb4b22173b Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 13 May 2010 19:26:42 -0300 Subject: [PATCH] obexd: Coding style fixes --- obexd/plugins/filesystem.c | 72 ++++----- obexd/plugins/filesystem.h | 4 +- obexd/plugins/ftp.c | 195 +++++++++++++------------ obexd/plugins/opp.c | 116 +++++++-------- obexd/plugins/pbap.c | 235 +++++++++++++++--------------- obexd/plugins/phonebook-dummy.c | 30 ++-- obexd/plugins/phonebook-ebook.c | 53 +++---- obexd/plugins/phonebook-tracker.c | 5 +- obexd/plugins/phonebook.h | 46 +++--- obexd/plugins/syncevolution.c | 43 +++--- obexd/plugins/vcard.c | 1 - obexd/src/bluetooth.c | 18 +-- obexd/src/bluetooth.h | 4 +- obexd/src/btio.c | 24 +-- obexd/src/btio.h | 10 +- obexd/src/dbus.h | 4 +- obexd/src/logging.c | 51 ++++--- obexd/src/main.c | 18 +-- obexd/src/manager.c | 106 +++++++------- obexd/src/mimetype.c | 19 +-- obexd/src/mimetype.h | 31 ++-- obexd/src/obex-priv.h | 70 ++++----- obexd/src/obex.c | 132 ++++++++--------- obexd/src/obex.h | 24 +-- obexd/src/plugin.c | 4 +- obexd/src/service.c | 11 +- obexd/src/service.h | 37 ++--- 27 files changed, 691 insertions(+), 672 deletions(-) diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index cd09af298..633036b13 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -58,7 +58,7 @@ #define FL_TYPE "" EOL_CHARS #define FL_TYPE_PCSUITE " ]>" EOL_CHARS + " [ ]>" EOL_CHARS #define FL_BODY_BEGIN "" EOL_CHARS @@ -77,22 +77,22 @@ " modified=\"%s\" mem-type=\"DEV\"" \ " created=\"%s\"/>" EOL_CHARS -static const guint8 FTP_TARGET[TARGET_SIZE] = { +static const uint8_t FTP_TARGET[TARGET_SIZE] = { 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 }; #define PCSUITE_WHO_SIZE 8 -static const guint8 PCSUITE_WHO[PCSUITE_WHO_SIZE] = { +static const uint8_t PCSUITE_WHO[PCSUITE_WHO_SIZE] = { 'P','C',' ','S','u','i','t','e' }; -static gchar *file_stat_line(gchar *filename, struct stat *fstat, - struct stat *dstat, gboolean root, - gboolean pcsuite) +static char *file_stat_line(char *filename, struct stat *fstat, + struct stat *dstat, gboolean root, + gboolean pcsuite) { - gchar perm[51], atime[18], ctime[18], mtime[18]; - gchar *escaped, *ret = NULL; + char perm[51], atime[18], ctime[18], mtime[18]; + char *escaped, *ret = NULL; snprintf(perm, 50, "user-perm=\"%s%s%s\" group-perm=\"%s%s%s\" " "other-perm=\"%s%s%s\"", @@ -119,18 +119,18 @@ static gchar *file_stat_line(gchar *filename, struct stat *fstat, mtime, ctime); else ret = g_strdup_printf(FL_FOLDER_ELEMENT, escaped, perm, - atime, mtime, ctime); + atime, mtime, ctime); } else if (S_ISREG(fstat->st_mode)) ret = g_strdup_printf(FL_FILE_ELEMENT, escaped, fstat->st_size, - perm, atime, mtime, ctime); + perm, atime, mtime, ctime); g_free(escaped); return ret; } -static gpointer filesystem_open(const char *name, int oflag, mode_t mode, - gpointer context, size_t *size, int *err) +static void *filesystem_open(const char *name, int oflag, mode_t mode, + void *context, size_t *size, int *err) { struct stat stats; struct statvfs buf; @@ -198,7 +198,7 @@ failed: return NULL; } -static int filesystem_close(gpointer object) +static int filesystem_close(void *object) { if (close(GPOINTER_TO_INT(object)) < 0) return -errno; @@ -206,8 +206,8 @@ static int filesystem_close(gpointer object) return 0; } -static ssize_t filesystem_read(gpointer object, void *buf, size_t count, - guint8 *hi) +static ssize_t filesystem_read(void *object, void *buf, size_t count, + uint8_t *hi) { ssize_t ret; @@ -220,7 +220,7 @@ static ssize_t filesystem_read(gpointer object, void *buf, size_t count, return ret; } -static ssize_t filesystem_write(gpointer object, const void *buf, size_t count) +static ssize_t filesystem_write(void *object, const void *buf, size_t count) { ssize_t ret; @@ -235,11 +235,11 @@ struct capability_object { int pid; int output; int err; - guint watch; + unsigned int watch; GString *buffer; }; -static void script_exited(GPid pid, gint status, gpointer data) +static void script_exited(GPid pid, int status, void *data) { struct capability_object *object = data; char buf[128]; @@ -273,11 +273,11 @@ static int capability_exec(const char **argv, int *output, int *err) return pid; } -static gpointer capability_open(const char *name, int oflag, mode_t mode, - gpointer context, size_t *size, int *err) +static void *capability_open(const char *name, int oflag, mode_t mode, + void *context, size_t *size, int *err) { struct capability_object *object = NULL; - gchar *buf; + char *buf; const char *argv[2]; if (oflag != O_RDONLY) @@ -344,13 +344,13 @@ static GString *append_folder_preamble(GString *object) } static GString *append_listing(GString *object, const char *name, - gboolean pcsuite, size_t *size, int *err) + gboolean pcsuite, size_t *size, int *err) { struct stat fstat, dstat; struct dirent *ep; DIR *dp; gboolean root, symlinks; - gint ret; + int ret; root = g_str_equal(name, obex_option_root_folder()); @@ -376,9 +376,9 @@ static GString *append_listing(GString *object, const char *name, } while ((ep = readdir(dp))) { - gchar *filename; - gchar *fullname; - gchar *line; + char *filename; + char *fullname; + char *line; if (ep->d_name[0] == '.') continue; @@ -437,8 +437,8 @@ failed: return NULL; } -static gpointer folder_open(const char *name, int oflag, mode_t mode, - gpointer context, size_t *size, int *err) +static void *folder_open(const char *name, int oflag, mode_t mode, + void *context, size_t *size, int *err) { GString *object; @@ -449,8 +449,8 @@ static gpointer folder_open(const char *name, int oflag, mode_t mode, return append_listing(object, name, FALSE, size, err); } -static gpointer pcsuite_open(const char *name, int oflag, mode_t mode, - gpointer context, size_t *size, int *err) +static void *pcsuite_open(const char *name, int oflag, mode_t mode, + void *context, size_t *size, int *err) { GString *object; @@ -461,7 +461,7 @@ static gpointer pcsuite_open(const char *name, int oflag, mode_t mode, return append_listing(object, name, TRUE, size, err); } -int string_free(gpointer object) +int string_free(void *object) { GString *string = object; @@ -470,7 +470,7 @@ int string_free(gpointer object) return 0; } -ssize_t string_read(gpointer object, void *buf, size_t count) +ssize_t string_read(void *object, void *buf, size_t count) { GString *string = object; ssize_t len; @@ -485,14 +485,14 @@ ssize_t string_read(gpointer object, void *buf, size_t count) return len; } -static ssize_t folder_read(gpointer object, void *buf, size_t count, guint8 *hi) +static ssize_t folder_read(void *object, void *buf, size_t count, uint8_t *hi) { *hi = OBEX_HDR_BODY; return string_read(object, buf, count); } -static ssize_t capability_read(gpointer object, void *buf, size_t count, - guint8 *hi) +static ssize_t capability_read(void *object, void *buf, size_t count, + uint8_t *hi) { struct capability_object *obj = object; @@ -507,7 +507,7 @@ static ssize_t capability_read(gpointer object, void *buf, size_t count, return read(obj->output, buf, count); } -static int capability_close(gpointer object) +static int capability_close(void *object) { struct capability_object *obj = object; diff --git a/obexd/plugins/filesystem.h b/obexd/plugins/filesystem.h index 636ddb27a..712653f79 100644 --- a/obexd/plugins/filesystem.h +++ b/obexd/plugins/filesystem.h @@ -21,5 +21,5 @@ * */ -int string_free(gpointer object); -ssize_t string_read(gpointer object, void *buf, size_t count); +int string_free(void *object); +ssize_t string_read(void *object, void *buf, size_t count); diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index ffb00fff5..945cfca20 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -54,99 +54,100 @@ #define LST_TYPE "x-obex/folder-listing" #define CAP_TYPE "x-obex/capability" -#define FTP_CHANNEL 10 -#define FTP_RECORD " \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ +#define FTP_CHANNEL 10 +#define FTP_RECORD " \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ " -#define PCSUITE_CHANNEL 24 +#define PCSUITE_CHANNEL 24 #define PCSUITE_WHO_SIZE 8 -#define PCSUITE_RECORD " \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ + +#define PCSUITE_RECORD " \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ " -static const guint8 FTP_TARGET[TARGET_SIZE] = { - 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, - 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 }; +static const uint8_t FTP_TARGET[TARGET_SIZE] = { + 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, + 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 }; -static const guint8 PCSUITE_WHO[PCSUITE_WHO_SIZE] = { +static const uint8_t PCSUITE_WHO[PCSUITE_WHO_SIZE] = { 'P','C',' ','S','u','i','t','e' }; struct ftp_session { struct obex_session *os; - gchar *folder; + char *folder; }; static void set_folder(struct ftp_session *ftp, const char *new_folder) @@ -156,7 +157,7 @@ static void set_folder(struct ftp_session *ftp, const char *new_folder) ftp->folder = new_folder ? g_strdup(new_folder) : NULL; } -static gint get_by_type(struct ftp_session *ftp, const gchar *type) +static int get_by_type(struct ftp_session *ftp, const char *type) { struct obex_session *os = ftp->os; const char *capability = obex_get_capability_path(os); @@ -173,7 +174,7 @@ static gint get_by_type(struct ftp_session *ftp, const gchar *type) return -ENOENT; } -static gpointer ftp_connect(struct obex_session *os, int *err) +static void *ftp_connect(struct obex_session *os, int *err) { struct ftp_session *ftp; const char *root_folder; @@ -193,7 +194,7 @@ static gpointer ftp_connect(struct obex_session *os, int *err) } static int ftp_get(struct obex_session *os, obex_object_t *obj, - gboolean *stream, gpointer user_data) + gboolean *stream, void *user_data) { struct ftp_session *ftp = user_data; const char *type = obex_get_type(os); @@ -212,9 +213,9 @@ static int ftp_get(struct obex_session *os, obex_object_t *obj, return 0; } -static gint ftp_delete(struct ftp_session *ftp, const char *name) +static int ftp_delete(struct ftp_session *ftp, const char *name) { - gchar *path; + char *path; int ret = 0; if (!(ftp->folder && name)) @@ -230,11 +231,11 @@ static gint ftp_delete(struct ftp_session *ftp, const char *name) return ret; } -static gint ftp_chkput(struct obex_session *os, gpointer user_data) +static int ftp_chkput(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; - const gchar *name = obex_get_name(os); - gchar *path; + const char *name = obex_get_name(os); + char *path; int ret; if (name == NULL) @@ -252,7 +253,7 @@ static gint ftp_chkput(struct obex_session *os, gpointer user_data) return ret; } -static int ftp_put(struct obex_session *os, gpointer user_data) +static int ftp_put(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; const char *name = obex_get_name(os); @@ -271,12 +272,12 @@ static int ftp_put(struct obex_session *os, gpointer user_data) } static int ftp_setpath(struct obex_session *os, obex_object_t *obj, - gpointer user_data) + void *user_data) { struct ftp_session *ftp = user_data; - const gchar *root_folder, *name; - guint8 *nonhdr; - gchar *fullname; + const char *root_folder, *name; + uint8_t *nonhdr; + char *fullname; struct stat dstat; gboolean root; int err; @@ -373,7 +374,7 @@ done: return err; } -static void ftp_disconnect(struct obex_session *os, gpointer user_data) +static void ftp_disconnect(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c index 729c2ef16..01afe76d9 100644 --- a/obexd/plugins/opp.c +++ b/obexd/plugins/opp.c @@ -45,56 +45,56 @@ #define OPP_CHANNEL 9 #define OPP_RECORD " \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ " -static gpointer opp_connect(struct obex_session *os, int *err) +static void *opp_connect(struct obex_session *os, int *err) { manager_register_transfer(os); @@ -104,17 +104,17 @@ static gpointer opp_connect(struct obex_session *os, int *err) return NULL; } -static void opp_progress(struct obex_session *os, gpointer user_data) +static void opp_progress(struct obex_session *os, void *user_data) { manager_emit_transfer_progress(os); } -static gint opp_chkput(struct obex_session *os, gpointer user_data) +static int opp_chkput(struct obex_session *os, void *user_data) { - gchar *folder, *name; - gchar *path; - gint32 time; - gint ret; + char *folder, *name; + char *path; + int32_t time; + int ret; if (obex_get_size(os) == OBJECT_SIZE_DELETE) return -EINVAL; @@ -153,7 +153,7 @@ skip_auth: return ret; } -static int opp_put(struct obex_session *os, gpointer user_data) +static int opp_put(struct obex_session *os, void *user_data) { const char *name = obex_get_name(os); const char *folder = obex_get_root_folder(os); @@ -168,7 +168,7 @@ static int opp_put(struct obex_session *os, gpointer user_data) } static int opp_get(struct obex_session *os, obex_object_t *obj, - gboolean *stream, gpointer user_data) + gboolean *stream, void *user_data) { const char *type; @@ -193,12 +193,12 @@ static int opp_get(struct obex_session *os, obex_object_t *obj, return 0; } -static void opp_disconnect(struct obex_session *os, gpointer user_data) +static void opp_disconnect(struct obex_session *os, void *user_data) { manager_unregister_transfer(os); } -static void opp_reset(struct obex_session *os, gpointer user_data) +static void opp_reset(struct obex_session *os, void *user_data) { manager_emit_transfer_completed(os); } diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index 36e520684..efa244534 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -76,81 +76,81 @@ #define PBAP_CHANNEL 15 #define PBAP_RECORD " \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ " struct aparam_header { - uint8_t tag; - uint8_t len; - uint8_t val[0]; + uint8_t tag; + uint8_t len; + uint8_t val[0]; } __attribute__ ((packed)); struct cache { gboolean valid; - guint32 index; - gchar *folder; + uint32_t index; + char *folder; GSList *entries; }; struct cache_entry { - guint32 handle; - gchar *id; - gchar *name; - gchar *sound; - gchar *tel; + uint32_t handle; + char *id; + char *name; + char *sound; + char *tel; }; struct pbap_session { struct apparam_field *params; - gchar *folder; + char *folder; uint32_t find_handle; GString *buffer; struct cache cache; }; -static const guint8 PBAP_TARGET[TARGET_SIZE] = { +static const uint8_t PBAP_TARGET[TARGET_SIZE] = { 0x79, 0x61, 0x35, 0xF0, 0xF0, 0xC5, 0x11, 0xD8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0C, 0x9A, 0x66 }; typedef int (*cache_entry_find_f) (const struct cache_entry *entry, - const gchar *value); + const char *value); static void cache_entry_free(struct cache_entry *entry) { @@ -162,9 +162,9 @@ static void cache_entry_free(struct cache_entry *entry) } static gboolean entry_name_find(const struct cache_entry *entry, - const gchar *value) + const char *value) { - gchar *name; + char *name; gboolean ret; if (!entry->name) @@ -181,7 +181,7 @@ static gboolean entry_name_find(const struct cache_entry *entry, } static gboolean entry_sound_find(const struct cache_entry *entry, - const gchar *value) + const char *value) { if (!entry->sound) return FALSE; @@ -190,7 +190,7 @@ static gboolean entry_sound_find(const struct cache_entry *entry, } static gboolean entry_tel_find(const struct cache_entry *entry, - const gchar *value) + const char *value) { if (!entry->tel) return FALSE; @@ -198,7 +198,7 @@ static gboolean entry_tel_find(const struct cache_entry *entry, return (g_strstr_len(entry->tel, -1, value) ? TRUE : FALSE); } -static const gchar *cache_find(struct cache *cache, guint32 handle) +static const char *cache_find(struct cache *cache, uint32_t handle) { GSList *l; @@ -220,13 +220,13 @@ static void cache_clear(struct cache *cache) cache->entries = NULL; } -static void phonebook_size_result(const gchar *buffer, size_t bufsize, - gint vcards, gint missed, gpointer user_data) +static void phonebook_size_result(const char *buffer, size_t bufsize, + int vcards, int missed, void *user_data) { struct pbap_session *pbap = user_data; - gchar aparam[4]; + char aparam[4]; struct aparam_header *hdr = (struct aparam_header *) aparam; - guint16 phonebooksize; + uint16_t phonebooksize; phonebooksize = htons(vcards); @@ -239,8 +239,8 @@ static void phonebook_size_result(const gchar *buffer, size_t bufsize, obex_object_set_io_flags(pbap, G_IO_IN, 0); } -static void query_result(const gchar *buffer, size_t bufsize, gint vcards, - gint missed, gpointer user_data) +static void query_result(const char *buffer, size_t bufsize, int vcards, + int missed, void *user_data) { struct pbap_session *pbap = user_data; @@ -253,9 +253,9 @@ static void query_result(const gchar *buffer, size_t bufsize, gint vcards, obex_object_set_io_flags(pbap, G_IO_IN, 0); } -static void cache_entry_notify(const gchar *id, guint32 handle, - const gchar *name, const gchar *sound, - const gchar *tel, gpointer user_data) +static void cache_entry_notify(const char *id, uint32_t handle, + const char *name, const char *sound, + const char *tel, void *user_data) { struct pbap_session *pbap = user_data; struct cache_entry *entry = g_new0(struct cache_entry, 1); @@ -338,11 +338,11 @@ static GSList *sort_entries(GSList *l, uint8_t order, uint8_t search_attrib, * when the attribute is not provided. */ switch (search_attrib) { + /* Number */ case 1: - /* Number */ find = entry_tel_find; break; - /* Sound */ + /* Sound */ case 2: find = entry_sound_find; break; @@ -355,7 +355,7 @@ static GSList *sort_entries(GSList *l, uint8_t order, uint8_t search_attrib, for (; l; l = l->next) { struct cache_entry *entry = l->data; - if (searchval && !find(entry, (const gchar *) searchval)) + if (searchval && !find(entry, (const char *) searchval)) continue; sorted = g_slist_insert_sorted(sorted, entry, sort); @@ -408,6 +408,7 @@ static void cache_ready_notify(void *user_data) pbap->buffer = g_string_append(pbap->buffer, VCARD_LISTING_END); g_slist_free(sorted); + done: if (!pbap->cache.valid) { pbap->cache.valid = TRUE; @@ -425,19 +426,19 @@ static void cache_entry_done(void *user_data) id = cache_find(&pbap->cache, pbap->find_handle); - ret = phonebook_get_entry(pbap->folder, id, pbap->params, query_result, - pbap); + ret = phonebook_get_entry(pbap->folder, id, pbap->params, + query_result, pbap); if (ret < 0) obex_object_set_io_flags(pbap, G_IO_ERR, ret); } -static struct apparam_field *parse_aparam(const guint8 *buffer, guint32 hlen) +static struct apparam_field *parse_aparam(const uint8_t *buffer, uint32_t hlen) { struct apparam_field *param; struct aparam_header *hdr; - guint64 val64; - guint32 len = 0; - guint16 val16; + uint64_t val64; + uint32_t len = 0; + uint16_t val16; param = g_new0(struct apparam_field, 1); @@ -509,7 +510,7 @@ failed: return NULL; } -static gpointer pbap_connect(struct obex_session *os, int *err) +static void *pbap_connect(struct obex_session *os, int *err) { struct pbap_session *pbap; @@ -526,16 +527,16 @@ static gpointer pbap_connect(struct obex_session *os, int *err) } static int pbap_get(struct obex_session *os, obex_object_t *obj, - gboolean *stream, gpointer user_data) + gboolean *stream, void *user_data) { struct pbap_session *pbap = user_data; - const gchar *type = obex_get_type(os); - const gchar *name = obex_get_name(os); + const char *type = obex_get_type(os); + const char *name = obex_get_name(os); struct apparam_field *params; - const guint8 *buffer; - gchar *path; + const uint8_t *buffer; + char *path; ssize_t rsize; - gint ret; + int ret; if (type == NULL) return -EBADR; @@ -585,12 +586,12 @@ static int pbap_get(struct obex_session *os, obex_object_t *obj, } static int pbap_setpath(struct obex_session *os, obex_object_t *obj, - gpointer user_data) + void *user_data) { struct pbap_session *pbap = user_data; - const gchar *name; - guint8 *nonhdr; - gchar *fullname; + const char *name; + uint8_t *nonhdr; + char *fullname; int err; if (OBEX_ObjectGetNonHdrData(obj, &nonhdr) != 2) { @@ -617,7 +618,7 @@ static int pbap_setpath(struct obex_session *os, obex_object_t *obj, return 0; } -static void pbap_disconnect(struct obex_session *os, gpointer user_data) +static void pbap_disconnect(struct obex_session *os, void *user_data) { struct pbap_session *pbap = user_data; @@ -633,7 +634,7 @@ static void pbap_disconnect(struct obex_session *os, gpointer user_data) g_free(pbap); } -static gint pbap_chkput(struct obex_session *os, gpointer user_data) +static int pbap_chkput(struct obex_session *os, void *user_data) { /* Rejects all PUTs */ return -EINVAL; @@ -653,8 +654,8 @@ static struct obex_service_driver pbap = { .chkput = pbap_chkput }; -static gpointer vobject_pull_open(const char *name, int oflag, mode_t mode, - gpointer context, size_t *size, int *err) +static void *vobject_pull_open(const char *name, int oflag, mode_t mode, + void *context, size_t *size, int *err) { struct pbap_session *pbap = context; phonebook_cb cb; @@ -686,8 +687,8 @@ fail: return NULL; } -static gpointer vobject_list_open(const char *name, int oflag, mode_t mode, - gpointer context, size_t *size, int *err) +static void *vobject_list_open(const char *name, int oflag, mode_t mode, + void *context, size_t *size, int *err) { struct pbap_session *pbap = context; int ret; @@ -723,12 +724,12 @@ fail: return NULL; } -static gpointer vobject_vcard_open(const char *name, int oflag, mode_t mode, - gpointer context, size_t *size, int *err) +static void *vobject_vcard_open(const char *name, int oflag, mode_t mode, + void *context, size_t *size, int *err) { struct pbap_session *pbap = context; - const gchar *id; - guint32 handle; + const char *id; + uint32_t handle; int ret; if (oflag != O_RDONLY) { @@ -773,8 +774,8 @@ fail: return NULL; } -static ssize_t vobject_pull_read(gpointer object, void *buf, size_t count, - guint8 *hi) +static ssize_t vobject_pull_read(void *object, void *buf, size_t count, + uint8_t *hi) { struct pbap_session *pbap = object; @@ -791,8 +792,8 @@ static ssize_t vobject_pull_read(gpointer object, void *buf, size_t count, return string_read(pbap->buffer, buf, count); } -static ssize_t vobject_list_read(gpointer object, void *buf, size_t count, - guint8 *hi) +static ssize_t vobject_list_read(void *object, void *buf, size_t count, + uint8_t *hi) { struct pbap_session *pbap = object; @@ -808,8 +809,8 @@ static ssize_t vobject_list_read(gpointer object, void *buf, size_t count, return string_read(pbap->buffer, buf, count); } -static ssize_t vobject_vcard_read(gpointer object, void *buf, size_t count, - guint8 *hi) +static ssize_t vobject_vcard_read(void *object, void *buf, size_t count, + uint8_t *hi) { struct pbap_session *pbap = object; @@ -820,7 +821,7 @@ static ssize_t vobject_vcard_read(gpointer object, void *buf, size_t count, return string_read(pbap->buffer, buf, count); } -static int vobject_close(gpointer object) +static int vobject_close(void *object) { struct pbap_session *pbap = object; @@ -833,27 +834,27 @@ static int vobject_close(gpointer object) } static struct obex_mime_type_driver mime_pull = { - .target = PBAP_TARGET, - .mimetype = "x-bt/phonebook", - .open = vobject_pull_open, - .close = vobject_close, - .read = vobject_pull_read, + .target = PBAP_TARGET, + .mimetype = "x-bt/phonebook", + .open = vobject_pull_open, + .close = vobject_close, + .read = vobject_pull_read, }; static struct obex_mime_type_driver mime_list = { - .target = PBAP_TARGET, - .mimetype = "x-bt/vcard-listing", - .open = vobject_list_open, - .close = vobject_close, - .read = vobject_list_read, + .target = PBAP_TARGET, + .mimetype = "x-bt/vcard-listing", + .open = vobject_list_open, + .close = vobject_close, + .read = vobject_list_read, }; static struct obex_mime_type_driver mime_vcard = { - .target = PBAP_TARGET, - .mimetype = "x-bt/vcard", - .open = vobject_vcard_open, - .close = vobject_close, - .read = vobject_vcard_read, + .target = PBAP_TARGET, + .mimetype = "x-bt/vcard", + .open = vobject_vcard_open, + .close = vobject_close, + .read = vobject_vcard_read, }; static int pbap_init(void) diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c index 9765b3e24..019b797ef 100644 --- a/obexd/plugins/phonebook-dummy.c +++ b/obexd/plugins/phonebook-dummy.c @@ -47,8 +47,8 @@ typedef void (*vcard_func_t) (const char *file, VObject *vo, void *user_data); struct dummy_data { - phonebook_cb cb; - gpointer user_data; + phonebook_cb cb; + void *user_data; const struct apparam_field *apparams; char *folder; int fd; @@ -61,9 +61,9 @@ struct cache_query { DIR *dp; }; -static gchar *root_folder = NULL; +static char *root_folder = NULL; -static void dummy_free(gpointer user_data) +static void dummy_free(void *user_data) { struct dummy_data *dummy = user_data; @@ -161,7 +161,7 @@ static int foreach_vcard(DIR *dp, vcard_func_t func, uint16_t offset, */ for (l = g_slist_nth(sorted, offset); l && n < maxlistcount; l = l->next) { - const gchar *filename = l->data; + const char *filename = l->data; fd = openat(folderfd, filename, O_RDONLY); if (fd < 0) { @@ -324,7 +324,7 @@ static gboolean create_cache(void *user_data) return FALSE; } -static gboolean read_entry(gpointer user_data) +static gboolean read_entry(void *user_data) { struct dummy_data *dummy = user_data; char buffer[1024]; @@ -359,11 +359,11 @@ static gboolean is_dir(const char *dir) return S_ISDIR(st.st_mode); } -gchar *phonebook_set_folder(const gchar *current_folder, - const gchar *new_folder, guint8 flags, int *err) +char *phonebook_set_folder(const char *current_folder, + const char *new_folder, uint8_t flags, int *err) { gboolean root, child; - gchar *tmp1, *tmp2, *base, *absolute, *relative = NULL; + char *tmp1, *tmp2, *base, *absolute, *relative = NULL; int ret, len; root = (g_strcmp0("/", current_folder) == 0); @@ -442,8 +442,8 @@ done: return relative; } -int phonebook_pull(const gchar *name, const struct apparam_field *params, - phonebook_cb cb, gpointer user_data) +int phonebook_pull(const char *name, const struct apparam_field *params, + phonebook_cb cb, void *user_data) { struct dummy_data *dummy; char *filename, *folder; @@ -480,9 +480,9 @@ int phonebook_pull(const gchar *name, const struct apparam_field *params, return 0; } -int phonebook_get_entry(const gchar *folder, const gchar *id, +int phonebook_get_entry(const char *folder, const char *id, const struct apparam_field *params, - phonebook_cb cb, gpointer user_data) + phonebook_cb cb, void *user_data) { struct dummy_data *dummy; char *filename; @@ -508,8 +508,8 @@ int phonebook_get_entry(const gchar *folder, const gchar *id, return 0; } -int phonebook_create_cache(const gchar *name, phonebook_entry_cb entry_cb, - phonebook_cache_ready_cb ready_cb, gpointer user_data) +int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb, + phonebook_cache_ready_cb ready_cb, void *user_data) { struct cache_query *query; char *foldername; diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c index 21278bef3..c3c22a2cc 100644 --- a/obexd/plugins/phonebook-ebook.c +++ b/obexd/plugins/phonebook-ebook.c @@ -48,18 +48,18 @@ struct contacts_query { const struct apparam_field *params; phonebook_cb cb; - gpointer user_data; + void *user_data; }; struct cache_query { phonebook_entry_cb entry_cb; phonebook_cache_ready_cb ready_cb; - gpointer user_data; + void *user_data; }; static EBook *ebook = NULL; -static gchar *attribute_mask[] = { +static char *attribute_mask[] = { /* 0 */ "VERSION", "FN", "N", @@ -93,11 +93,12 @@ static gchar *attribute_mask[] = { }; -static gchar *evcard_to_string(EVCard *evcard, guint format, guint64 filter) +static char *evcard_to_string(EVCard *evcard, unsigned int format, + uint64_t filter) { EVCard *evcard2; - gchar *vcard; - guint i; + char *vcard; + unsigned int i; if (!filter) return e_vcard_to_string(evcard, format); @@ -106,7 +107,7 @@ static gchar *evcard_to_string(EVCard *evcard, guint format, guint64 filter) * Mandatory attributes for vCard 2.1 are VERSION ,N and TEL. * Mandatory attributes for vCard 3.0 are VERSION, N, FN and TEL */ - filter = (format == EVC_FORMAT_VCARD_30 ? filter | 0x85: filter | 0x87); + filter = format == EVC_FORMAT_VCARD_30 ? filter | 0x85: filter | 0x87; evcard2 = e_vcard_new(); for (i = 0; i < 29; i++) { @@ -129,11 +130,11 @@ static gchar *evcard_to_string(EVCard *evcard, guint format, guint64 filter) } static void ebookpull_cb(EBook *book, EBookStatus estatus, GList *contacts, - gpointer user_data) + void *user_data) { struct contacts_query *data = user_data; GString *string = g_string_new(""); - guint count = 0, maxcount; + unsigned int count = 0, maxcount; GList *l; if (estatus != E_BOOK_ERROR_OK) { @@ -159,7 +160,7 @@ static void ebookpull_cb(EBook *book, EBookStatus estatus, GList *contacts, for (; l && count < maxcount; l = g_list_next(l), count++) { EContact *contact = E_CONTACT(l->data); EVCard *evcard = E_VCARD(contact); - gchar *vcard; + char *vcard; vcard = evcard_to_string(evcard, data->params->format, data->params->filter); @@ -176,11 +177,11 @@ done: } static void ebook_entry_cb(EBook *book, EBookStatus estatus, - EContact *contact, gpointer user_data) + EContact *contact, void *user_data) { struct contacts_query *data = user_data; EVCard *evcard; - gchar *vcard; + char *vcard; size_t len; if (estatus != E_BOOK_ERROR_OK) { @@ -203,7 +204,7 @@ static void ebook_entry_cb(EBook *book, EBookStatus estatus, g_free(data); } -static gchar *evcard_name_attribute_to_string(EVCard *evcard) +static char *evcard_name_attribute_to_string(EVCard *evcard) { EVCardAttribute *attrib; GList *l; @@ -214,7 +215,7 @@ static gchar *evcard_name_attribute_to_string(EVCard *evcard) return NULL; for (l = e_vcard_attribute_get_values(attrib); l; l = l->next) { - const gchar *value = l->data; + const char *value = l->data; if (!strlen(value)) continue; @@ -234,7 +235,7 @@ static gchar *evcard_name_attribute_to_string(EVCard *evcard) } static void cache_cb(EBook *book, EBookStatus estatus, GList *contacts, - gpointer user_data) + void *user_data) { struct cache_query *data = user_data; GList *l; @@ -248,7 +249,7 @@ static void cache_cb(EBook *book, EBookStatus estatus, GList *contacts, EContact *contact = E_CONTACT(l->data); EVCard *evcard = E_VCARD(contact); EVCardAttribute *attrib; - gchar *uid, *tel, *name; + char *uid, *tel, *name; name = evcard_name_attribute_to_string(evcard); if (!name) @@ -307,11 +308,11 @@ void phonebook_exit(void) g_object_unref(ebook); } -gchar *phonebook_set_folder(const gchar *current_folder, - const gchar *new_folder, guint8 flags, int *err) +char *phonebook_set_folder(const char *current_folder, + const char *new_folder, uint8_t flags, int *err) { gboolean root, child; - gchar *fullname = NULL, *tmp1, *tmp2, *base; + char *fullname = NULL, *tmp1, *tmp2, *base; int ret = 0, len; root = (g_strcmp0("/", current_folder) == 0); @@ -391,8 +392,8 @@ done: return fullname; } -gint phonebook_pull(const gchar *name, const struct apparam_field *params, - phonebook_cb cb, gpointer user_data) +int phonebook_pull(const char *name, const struct apparam_field *params, + phonebook_cb cb, void *user_data) { struct contacts_query *data; EBookQuery *query; @@ -411,9 +412,9 @@ gint phonebook_pull(const gchar *name, const struct apparam_field *params, return 0; } -int phonebook_get_entry(const gchar *folder, const gchar *id, +int phonebook_get_entry(const char *folder, const char *id, const struct apparam_field *params, - phonebook_cb cb, gpointer user_data) + phonebook_cb cb, void *user_data) { struct contacts_query *data; @@ -430,8 +431,8 @@ int phonebook_get_entry(const gchar *folder, const gchar *id, return 0; } -int phonebook_create_cache(const gchar *name, phonebook_entry_cb entry_cb, - phonebook_cache_ready_cb ready_cb, gpointer user_data) +int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb, + phonebook_cache_ready_cb ready_cb, void *user_data) { struct cache_query *data; EBookQuery *query; @@ -448,5 +449,5 @@ int phonebook_create_cache(const gchar *name, phonebook_entry_cb entry_cb, e_book_query_unref(query); - return (ret == FALSE ? 0 : -EBADR); + return ret == FALSE ? 0 : -EBADR; } diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index a8cbb4542..c8ae03b5c 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -503,7 +503,8 @@ static void pull_contacts(char **reply, int num_fields, void *user_data) done: if (num_fields == 0) - data->cb(vcards->str, vcards->len, data->index, 0, data->user_data); + data->cb(vcards->str, vcards->len, data->index, 0, + data->user_data); g_string_free(vcards, TRUE); } @@ -657,7 +658,7 @@ int phonebook_get_entry(const char *folder, const char *id, data->cb = cb; query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, - id, id, id, id, id, id, id, id); + id, id, id, id, id, id, id, id); ret = query_tracker(query, 8, pull_contacts, data);; diff --git a/obexd/plugins/phonebook.h b/obexd/plugins/phonebook.h index 85f69a38b..d7cfa46bd 100644 --- a/obexd/plugins/phonebook.h +++ b/obexd/plugins/phonebook.h @@ -23,25 +23,25 @@ #define EOL "\r\n" #define VCARD_LISTING_BEGIN \ - "" EOL\ + "" EOL\ "" EOL\ - "" EOL -#define VCARD_LISTING_ELEMENT "" EOL -#define VCARD_LISTING_END "" + "" EOL +#define VCARD_LISTING_ELEMENT "" EOL +#define VCARD_LISTING_END "" struct apparam_field { /* list and pull attributes */ - guint16 maxlistcount; - guint16 liststartoffset; + uint16_t maxlistcount; + uint16_t liststartoffset; /* pull and vcard attributes */ - guint64 filter; - guint8 format; + uint64_t filter; + uint8_t format; /* list attributes only */ - guint8 order; - guint8 searchattrib; - guint8 *searchval; + uint8_t order; + uint8_t searchattrib; + uint8_t *searchval; }; /* @@ -49,14 +49,14 @@ struct apparam_field { * all contacts that match the application parameters rules. * Contacts will be returned in the vcard format. */ -typedef void (*phonebook_cb) (const gchar *buffer, size_t bufsize, - gint vcards, gint missed, gpointer user_data); +typedef void (*phonebook_cb) (const char *buffer, size_t bufsize, + int vcards, int missed, void *user_data); /* * Interface between the PBAP core and backends to * append a new entry in the PBAP folder cache. */ -#define PHONEBOOK_INVALID_HANDLE 0xffffffff +#define PHONEBOOK_INVALID_HANDLE 0xffffffff typedef void (*phonebook_entry_cb) (const char *id, uint32_t handle, const char *name, const char *sound, const char *tel, void *user_data); @@ -65,7 +65,7 @@ typedef void (*phonebook_entry_cb) (const char *id, uint32_t handle, * After notify all entries to PBAP core, the backend * needs to notify that the operation has finished. */ -typedef void (*phonebook_cache_ready_cb) (gpointer user_data); +typedef void (*phonebook_cache_ready_cb) (void *user_data); int phonebook_init(void); @@ -78,16 +78,16 @@ void phonebook_exit(void); * the PBAP virtual folder architecture. Validate the folder's name * is responsibility of the back-ends. */ -gchar *phonebook_set_folder(const gchar *current_folder, - const gchar *new_folder, guint8 flags, int *err); +char *phonebook_set_folder(const char *current_folder, + const char *new_folder, uint8_t flags, int *err); /* * PullPhoneBook never use cached entries. PCE use this function to get all * entries of a given folder. The back-end MUST return only the content based * on the application parameters requested by the client. */ -int phonebook_pull(const gchar *name, const struct apparam_field *params, - phonebook_cb cb, gpointer user_data); +int phonebook_pull(const char *name, const struct apparam_field *params, + phonebook_cb cb, void *user_data); /* * Function used to retrieve a contact from the backend. Only contacts @@ -95,9 +95,9 @@ int phonebook_pull(const gchar *name, const struct apparam_field *params, * return only the content based on the application parameters requested * by the client. */ -int phonebook_get_entry(const gchar *folder, const gchar *id, +int phonebook_get_entry(const char *folder, const char *id, const struct apparam_field *params, - phonebook_cb cb, gpointer user_data); + phonebook_cb cb, void *user_data); /* * PBAP core will keep the contacts cache per folder. SetPhoneBook or @@ -105,5 +105,5 @@ int phonebook_get_entry(const gchar *folder, const gchar *id, * Cache will store only the necessary information required to reply to * PullvCardListing request and verify if a given contact belongs to the source. */ -int phonebook_create_cache(const gchar *name, phonebook_entry_cb entry_cb, - phonebook_cache_ready_cb ready_cb, gpointer user_data); +int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb, + phonebook_cache_ready_cb ready_cb, void *user_data); diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c index a40497c44..87deb17c7 100644 --- a/obexd/plugins/syncevolution.c +++ b/obexd/plugins/syncevolution.c @@ -50,7 +50,7 @@ #define SYNCML_TARGET_SIZE 11 -static const guint8 SYNCML_TARGET[SYNCML_TARGET_SIZE] = { +static const uint8_t SYNCML_TARGET[SYNCML_TARGET_SIZE] = { 0x53, 0x59, 0x4E, 0x43, 0x4D, 0x4C, 0x2D, 0x53, 0x59, 0x4E, 0x43 }; @@ -92,12 +92,12 @@ static const guint8 SYNCML_TARGET[SYNCML_TARGET_SIZE] = { struct synce_context { struct obex_session *os; DBusConnection *dbus_conn; - gchar *conn_obj; - guint reply_watch; - guint abort_watch; + char *conn_obj; + unsigned int reply_watch; + unsigned int abort_watch; GString *buffer; int lasterr; - gchar *id; + char *id; }; static void append_dict_entry(DBusMessageIter *dict, const char *key, @@ -113,13 +113,13 @@ static void append_dict_entry(DBusMessageIter *dict, const char *key, } static gboolean reply_signal(DBusConnection *conn, DBusMessage *msg, - void *data) + void *data) { struct synce_context *context = data; const char *path = dbus_message_get_path(msg); DBusMessageIter iter, array_iter; - gchar *value; - gint length; + char *value; + int length; if (strcmp(context->conn_obj, path) != 0) { obex_object_set_io_flags(context, G_IO_ERR, -EPERM); @@ -140,12 +140,13 @@ static gboolean reply_signal(DBusConnection *conn, DBusMessage *msg, } static gboolean abort_signal(DBusConnection *conn, DBusMessage *msg, - void *data) + void *data) { struct synce_context *context = data; obex_object_set_io_flags(context, G_IO_ERR, -EPERM); context->lasterr = -EPERM; + return TRUE; } @@ -155,7 +156,7 @@ static void connect_cb(DBusPendingCall *call, void *user_data) DBusConnection *conn; DBusMessage *reply; DBusError err; - gchar *path; + char *path; conn = context->dbus_conn; @@ -214,7 +215,7 @@ done: dbus_message_unref(reply); } -static gpointer synce_connect(struct obex_session *os, int *err) +static void *synce_connect(struct obex_session *os, int *err) { DBusConnection *conn; struct synce_context *context; @@ -242,13 +243,13 @@ failed: return NULL; } -static int synce_put(struct obex_session *os, gpointer user_data) +static int synce_put(struct obex_session *os, void *user_data) { return 0; } static int synce_get(struct obex_session *os, obex_object_t *obj, - gboolean *stream, gpointer user_data) + gboolean *stream, void *user_data) { if (stream) *stream = TRUE; @@ -272,15 +273,15 @@ static void close_cb(DBusPendingCall *call, void *user_data) dbus_message_unref(reply); } -static void synce_disconnect(struct obex_session *os, gpointer user_data) +static void synce_disconnect(struct obex_session *os, void *user_data) { struct synce_context *context = user_data; g_free(context); } -static gpointer synce_open(const char *name, int oflag, mode_t mode, - gpointer user_data, size_t *size, int *err) +static void *synce_open(const char *name, int oflag, mode_t mode, + void *user_data, size_t *size, int *err) { if (err) *err = 0; @@ -288,11 +289,11 @@ static gpointer synce_open(const char *name, int oflag, mode_t mode, return user_data; } -static int synce_close(gpointer object) +static int synce_close(void *object) { struct synce_context *context = object; DBusMessage *msg; - const gchar *error; + const char *error; gboolean normal; DBusPendingCall *call; @@ -329,11 +330,11 @@ done: return 0; } -static ssize_t synce_read(gpointer object, void *buf, size_t count, guint8 *hi) +static ssize_t synce_read(void *object, void *buf, size_t count, uint8_t *hi) { struct synce_context *context = object; DBusConnection *conn; - gchar transport[36], transport_description[24]; + char transport[36], transport_description[24]; const char *session; DBusMessage *msg; DBusMessageIter iter, dict; @@ -395,7 +396,7 @@ failed: return -EPERM; } -static ssize_t synce_write(gpointer object, const void *buf, size_t count) +static ssize_t synce_write(void *object, const void *buf, size_t count) { struct synce_context *context = object; DBusMessage *msg; diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c index c0a5f85bc..4afa12f36 100644 --- a/obexd/plugins/vcard.c +++ b/obexd/plugins/vcard.c @@ -254,5 +254,4 @@ void phonebook_contact_free(struct phonebook_contact *contact) g_free(contact->prefix); g_free(contact->suffix); g_free(contact); - } diff --git a/obexd/src/bluetooth.c b/obexd/src/bluetooth.c index d3f72ba81..368747338 100644 --- a/obexd/src/bluetooth.c +++ b/obexd/src/bluetooth.c @@ -49,13 +49,13 @@ static GSList *servers = NULL; -static void confirm_event(GIOChannel *io, gpointer user_data) +static void confirm_event(GIOChannel *io, void *user_data) { struct server *server = user_data; struct obex_service_driver *driver; GError *err = NULL; char address[18]; - guint8 channel; + uint8_t channel; bt_io_get(io, BT_IO_RFCOMM, &err, BT_IO_OPT_DEST, address, @@ -90,7 +90,7 @@ drop: g_io_channel_shutdown(io, TRUE, NULL); } -static gint server_start(struct server *server) +static int server_start(struct server *server) { GError *err = NULL; struct obex_service_driver *driver; @@ -120,7 +120,7 @@ failed: return -EINVAL; } -static gint server_stop(struct server *server) +static int server_stop(struct server *server) { if (!server->io) return -EINVAL; @@ -137,9 +137,9 @@ static gint server_stop(struct server *server) return 0; } -static gint server_register(guint16 service, const gchar *folder, +static int server_register(uint16_t service, const char *folder, gboolean secure, gboolean auto_accept, - gboolean symlinks, const gchar *capability) + gboolean symlinks, const char *capability) { struct server *server; GSList *drivers; @@ -163,12 +163,12 @@ static gint server_register(guint16 service, const gchar *folder, return 0; } -gint bluetooth_init(guint service, const gchar *folder, gboolean secure, +int bluetooth_init(unsigned int service, const char *folder, gboolean secure, gboolean auto_accept, gboolean symlinks, - const gchar *capability) + const char *capability) { return server_register(service, folder, secure, auto_accept, symlinks, - capability); + capability); } void bluetooth_exit(void) diff --git a/obexd/src/bluetooth.h b/obexd/src/bluetooth.h index 4f191a43b..1a4e1d89d 100644 --- a/obexd/src/bluetooth.h +++ b/obexd/src/bluetooth.h @@ -26,9 +26,9 @@ #include #endif -gint bluetooth_init(guint service, const gchar *folder, gboolean secure, +int bluetooth_init(unsigned int service, const char *folder, gboolean secure, gboolean auto_accept, gboolean symlinks, - const gchar *capability); + const char *capability); void bluetooth_exit(void); void bluetooth_start(void); void bluetooth_stop(void); diff --git a/obexd/src/btio.c b/obexd/src/btio.c index cf91de7a7..0adbceec1 100644 --- a/obexd/src/btio.c +++ b/obexd/src/btio.c @@ -61,20 +61,20 @@ struct set_opts { struct connect { BtIOConnect connect; - gpointer user_data; + void *user_data; GDestroyNotify destroy; }; struct accept { BtIOConnect connect; - gpointer user_data; + void *user_data; GDestroyNotify destroy; }; struct server { BtIOConnect connect; BtIOConfirm confirm; - gpointer user_data; + void *user_data; GDestroyNotify destroy; }; @@ -114,7 +114,7 @@ static gboolean check_nval(GIOChannel *io) } static gboolean accept_cb(GIOChannel *io, GIOCondition cond, - gpointer user_data) + void *user_data) { struct accept *accept = user_data; GError *err = NULL; @@ -135,7 +135,7 @@ static gboolean accept_cb(GIOChannel *io, GIOCondition cond, } static gboolean connect_cb(GIOChannel *io, GIOCondition cond, - gpointer user_data) + void *user_data) { struct connect *conn = user_data; GError *gerr = NULL; @@ -168,7 +168,7 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond, } static gboolean server_cb(GIOChannel *io, GIOCondition cond, - gpointer user_data) + void *user_data) { struct server *server = user_data; int srv_sock, cli_sock; @@ -200,7 +200,7 @@ static gboolean server_cb(GIOChannel *io, GIOCondition cond, } static void server_add(GIOChannel *io, BtIOConnect connect, - BtIOConfirm confirm, gpointer user_data, + BtIOConfirm confirm, void *user_data, GDestroyNotify destroy) { struct server *server; @@ -218,7 +218,7 @@ static void server_add(GIOChannel *io, BtIOConnect connect, } static void connect_add(GIOChannel *io, BtIOConnect connect, - gpointer user_data, GDestroyNotify destroy) + void *user_data, GDestroyNotify destroy) { struct connect *conn; GIOCondition cond; @@ -233,7 +233,7 @@ static void connect_add(GIOChannel *io, BtIOConnect connect, (GDestroyNotify) connect_remove); } -static void accept_add(GIOChannel *io, BtIOConnect connect, gpointer user_data, +static void accept_add(GIOChannel *io, BtIOConnect connect, void *user_data, GDestroyNotify destroy) { struct accept *accept; @@ -1039,7 +1039,7 @@ static gboolean get_valist(GIOChannel *io, BtIOType type, GError **err, return FALSE; } -gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer user_data, +gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, void *user_data, GDestroyNotify destroy, GError **err) { int sock; @@ -1188,7 +1188,7 @@ failed: } GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect, - gpointer user_data, GDestroyNotify destroy, + void *user_data, GDestroyNotify destroy, GError **gerr, BtIOOption opt1, ...) { GIOChannel *io; @@ -1242,7 +1242,7 @@ GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect, } GIOChannel *bt_io_listen(BtIOType type, BtIOConnect connect, - BtIOConfirm confirm, gpointer user_data, + BtIOConfirm confirm, void *user_data, GDestroyNotify destroy, GError **err, BtIOOption opt1, ...) { diff --git a/obexd/src/btio.h b/obexd/src/btio.h index 00d743e08..7df597291 100644 --- a/obexd/src/btio.h +++ b/obexd/src/btio.h @@ -71,11 +71,11 @@ typedef enum { BT_IO_SEC_HIGH, } BtIOSecLevel; -typedef void (*BtIOConfirm)(GIOChannel *io, gpointer user_data); +typedef void (*BtIOConfirm)(GIOChannel *io, void *user_data); -typedef void (*BtIOConnect)(GIOChannel *io, GError *err, gpointer user_data); +typedef void (*BtIOConnect)(GIOChannel *io, GError *err, void *user_data); -gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer user_data, +gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, void *user_data, GDestroyNotify destroy, GError **err); gboolean bt_io_set(GIOChannel *io, BtIOType type, GError **err, @@ -85,11 +85,11 @@ gboolean bt_io_get(GIOChannel *io, BtIOType type, GError **err, BtIOOption opt1, ...); GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect, - gpointer user_data, GDestroyNotify destroy, + void *user_data, GDestroyNotify destroy, GError **err, BtIOOption opt1, ...); GIOChannel *bt_io_listen(BtIOType type, BtIOConnect connect, - BtIOConfirm confirm, gpointer user_data, + BtIOConfirm confirm, void *user_data, GDestroyNotify destroy, GError **err, BtIOOption opt1, ...); diff --git a/obexd/src/dbus.h b/obexd/src/dbus.h index ccafc1e38..fe736ca23 100644 --- a/obexd/src/dbus.h +++ b/obexd/src/dbus.h @@ -32,7 +32,7 @@ void manager_unregister_transfer(struct obex_session *os); void manager_emit_transfer_started(struct obex_session *os); void manager_emit_transfer_progress(struct obex_session *os); void manager_emit_transfer_completed(struct obex_session *os); -int manager_request_authorization(struct obex_session *os, gint32 time, - gchar **new_folder, gchar **new_name); +int manager_request_authorization(struct obex_session *os, int32_t time, + char **new_folder, char **new_name); DBusConnection *obex_dbus_get_connection(void); diff --git a/obexd/src/logging.c b/obexd/src/logging.c index f0a25cb3d..f42770ef2 100644 --- a/obexd/src/logging.c +++ b/obexd/src/logging.c @@ -110,28 +110,40 @@ void stop_logging(void) } static struct { - int evt; - const char *name; + int evt; + const char *name; } obex_event[] = { - { OBEX_EV_PROGRESS, "PROGRESS" }, /* Progress has been made */ - { OBEX_EV_REQHINT, "REQHINT" }, /* An incoming request is about to come */ - { OBEX_EV_REQ, "REQ" }, /* An incoming request has arrived */ - { OBEX_EV_REQDONE, "REQDONE" }, /* Request has finished */ - { OBEX_EV_LINKERR, "LINKERR" }, /* Link has been disconnected */ - { OBEX_EV_PARSEERR, "PARSEERR" }, /* Malformed data encountered */ - { OBEX_EV_ACCEPTHINT, "ACCEPTHINT" }, /* Connection accepted */ - { OBEX_EV_ABORT, "ABORT" }, /* Request was aborted */ - { OBEX_EV_STREAMEMPTY, "STREAMEMPTY" }, /* Need to feed more data when sending a stream */ - { OBEX_EV_STREAMAVAIL, "STREAMAVAIL" }, /* Time to pick up data when receiving a stream */ - { OBEX_EV_UNEXPECTED, "UNEXPECTED" }, /* Unexpected data, not fatal */ - { OBEX_EV_REQCHECK, "REQCHECK" }, /* First packet of an incoming request has been parsed */ + /* 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; + int cmd; + const char *name; } obex_command[] = { { OBEX_CMD_CONNECT, "CONNECT" }, { OBEX_CMD_DISCONNECT, "DISCONNECT" }, @@ -146,8 +158,8 @@ static struct { /* Possible Response */ static struct { - int rsp; - const char *name; + int rsp; + const char *name; } obex_response[] = { { OBEX_RSP_CONTINUE, "CONTINUE" }, { OBEX_RSP_SWITCH_PRO, "SWITCH_PRO" }, @@ -217,5 +229,6 @@ void obex_debug(int evt, int cmd, int rsp) rspstr = obex_response[i].name; } - debug("%s(0x%x), %s(0x%x), %s(0x%x)", evtstr, evt, cmdstr, cmd, rspstr, rsp); + debug("%s(0x%x), %s(0x%x), %s(0x%x)", evtstr, evt, cmdstr, cmd, + rspstr, rsp); } diff --git a/obexd/src/main.c b/obexd/src/main.c index def0ad3c8..3408c726d 100644 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -66,9 +66,9 @@ static int signal_pipe[2]; #define TTY_RX_MTU 65535 #define TTY_TX_MTU 65535 -int tty_init(int services, const gchar *root_path, - const gchar *capability, gboolean symlinks, - const gchar *devnode) +int tty_init(int services, const char *root_path, + const char *capability, gboolean symlinks, + const char *devnode) { struct server *server; struct termios options; @@ -158,10 +158,10 @@ static void sig_debug(int sig) static gboolean option_detach = TRUE; static gboolean option_debug = FALSE; -static gchar *option_root = NULL; -static gchar *option_root_setup = NULL; -static gchar *option_capability = NULL; -static gchar *option_devnode = NULL; +static char *option_root = NULL; +static char *option_root_setup = NULL; +static char *option_capability = NULL; +static char *option_devnode = NULL; static gboolean option_autoaccept = FALSE; static gboolean option_opp = FALSE; @@ -202,7 +202,7 @@ static GOptionEntry options[] = { { NULL }, }; -const gchar *obex_option_root_folder(void) +const char *obex_option_root_folder(void) { return option_root; } @@ -286,7 +286,7 @@ static gboolean is_dir(const char *dir) { static gboolean root_folder_setup(char *root, char *root_setup) { - gint status; + int status; char *argv[3] = { root_setup, root, NULL }; if (is_dir(root)) diff --git a/obexd/src/manager.c b/obexd/src/manager.c index 8fef605d9..4eb518c67 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -46,21 +46,21 @@ #include "btio.h" #include "service.h" -#define OPENOBEX_MANAGER_PATH "/" -#define OPENOBEX_MANAGER_INTERFACE OPENOBEX_SERVICE ".Manager" -#define ERROR_INTERFACE OPENOBEX_SERVICE ".Error" -#define TRANSFER_INTERFACE OPENOBEX_SERVICE ".Transfer" -#define SESSION_INTERFACE OPENOBEX_SERVICE ".Session" +#define OPENOBEX_MANAGER_PATH "/" +#define OPENOBEX_MANAGER_INTERFACE OPENOBEX_SERVICE ".Manager" +#define ERROR_INTERFACE OPENOBEX_SERVICE ".Error" +#define TRANSFER_INTERFACE OPENOBEX_SERVICE ".Transfer" +#define SESSION_INTERFACE OPENOBEX_SERVICE ".Session" #define TIMEOUT 60*1000 /* Timeout for user response (miliseconds) */ struct agent { - gchar *bus_name; - gchar *path; - gboolean auth_pending; - gchar *new_name; - gchar *new_folder; - guint watch_id; + char *bus_name; + char *path; + gboolean auth_pending; + char *new_name; + char *new_folder; + unsigned int watch_id; }; static struct agent *agent = NULL; @@ -68,9 +68,9 @@ static struct agent *agent = NULL; struct pending_request { DBusPendingCall *call; struct server *server; - gchar *adapter_path; + char *adapter_path; char address[18]; - guint watch; + unsigned int watch; GIOChannel *io; }; @@ -82,7 +82,7 @@ struct adapter_any { static DBusConnection *connection = NULL; static DBusConnection *system_conn = NULL; static struct adapter_any *any = NULL; -static guint listener_id = 0; +static unsigned int listener_id = 0; static void agent_free(struct agent *agent) { @@ -209,7 +209,7 @@ static void agent_disconnected(DBusConnection *conn, void *user_data) static DBusMessage *register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { - const gchar *path, *sender; + const char *path, *sender; if (agent) return agent_already_exists(msg); @@ -235,7 +235,7 @@ static DBusMessage *register_agent(DBusConnection *conn, static DBusMessage *unregister_agent(DBusConnection *conn, DBusMessage *msg, void *data) { - const gchar *path, *sender; + const char *path, *sender; if (!agent) return agent_does_not_exist(msg); @@ -280,7 +280,7 @@ static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *reply; DBusMessageIter iter; DBusMessageIter dict; - gchar *uuid; + char *uuid; reply = dbus_message_new_method_return(msg); if (!reply) @@ -313,7 +313,7 @@ static DBusMessage *transfer_cancel(DBusConnection *connection, DBusMessage *msg, void *user_data) { struct obex_session *os = user_data; - const gchar *sender; + const char *sender; if (!os) return invalid_args(msg); @@ -356,7 +356,7 @@ static GDBusMethodTable session_methods[] = { { } }; -static void add_record_reply(DBusPendingCall *call, gpointer user_data) +static void add_record_reply(DBusPendingCall *call, void *user_data) { struct server *server = user_data; DBusMessage *reply = dbus_pending_call_steal_reply(call); @@ -386,12 +386,12 @@ static void add_record_reply(DBusPendingCall *call, gpointer user_data) dbus_message_unref(reply); } -static gint add_record(const gchar *path, - const gchar *xml, struct server *server) +static int add_record(const char *path, + const char *xml, struct server *server) { DBusMessage *msg; DBusPendingCall *call; - gint ret = 0; + int ret = 0; msg = dbus_message_new_method_call("org.bluez", path, "org.bluez.Service", "AddRecord"); @@ -416,8 +416,8 @@ failed: void register_record(struct server *server) { struct obex_service_driver *driver; - gchar *xml; - gint ret; + char *xml; + int ret; if (system_conn == NULL) return; @@ -435,11 +435,11 @@ void register_record(struct server *server) g_free(xml); } -static void find_adapter_any_reply(DBusPendingCall *call, gpointer user_data) +static void find_adapter_any_reply(DBusPendingCall *call, void *user_data) { DBusMessage *reply = dbus_pending_call_steal_reply(call); const char *path; - gchar *xml; + char *xml; GSList *l; DBusError derr; @@ -477,7 +477,7 @@ done: static DBusPendingCall *find_adapter(const char *pattern, DBusPendingCallNotifyFunction function, - gpointer user_data) + void *user_data) { DBusMessage *msg; DBusPendingCall *call; @@ -586,7 +586,7 @@ void manager_cleanup(void) void manager_emit_transfer_started(struct obex_session *os) { - gchar *path = g_strdup_printf("/transfer%u", os->cid); + char *path = g_strdup_printf("/transfer%u", os->cid); g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE, "TransferStarted", @@ -596,9 +596,9 @@ void manager_emit_transfer_started(struct obex_session *os) g_free(path); } -static void emit_transfer_completed(guint32 id, gboolean success) +static void emit_transfer_completed(uint32_t id, gboolean success) { - gchar *path = g_strdup_printf("/transfer%u", id); + char *path = g_strdup_printf("/transfer%u", id); g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE, "TransferCompleted", @@ -609,9 +609,10 @@ static void emit_transfer_completed(guint32 id, gboolean success) g_free(path); } -static void emit_transfer_progress(guint32 id, guint32 total, guint32 transfered) +static void emit_transfer_progress(uint32_t id, uint32_t total, + uint32_t transfered) { - gchar *path = g_strdup_printf("/transfer%u", id); + char *path = g_strdup_printf("/transfer%u", id); g_dbus_emit_signal(connection, path, TRANSFER_INTERFACE, "Progress", @@ -624,7 +625,7 @@ static void emit_transfer_progress(guint32 id, guint32 total, guint32 transfered void manager_register_transfer(struct obex_session *os) { - gchar *path = g_strdup_printf("/transfer%u", os->cid); + char *path = g_strdup_printf("/transfer%u", os->cid); if (!g_dbus_register_interface(connection, path, TRANSFER_INTERFACE, @@ -640,7 +641,7 @@ void manager_register_transfer(struct obex_session *os) void manager_unregister_transfer(struct obex_session *os) { - gchar *path = g_strdup_printf("/transfer%u", os->cid); + char *path = g_strdup_printf("/transfer%u", os->cid); /* Got an error during a transfer. */ if (os->object) @@ -662,10 +663,10 @@ static void agent_cancel() g_dbus_send_message(connection, msg); } -static void agent_reply(DBusPendingCall *call, gpointer user_data) +static void agent_reply(DBusPendingCall *call, void *user_data) { DBusMessage *reply = dbus_pending_call_steal_reply(call); - const gchar *name; + const char *name; DBusError derr; gboolean *got_reply = user_data; @@ -694,7 +695,7 @@ static void agent_reply(DBusPendingCall *call, gpointer user_data) DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { /* Splits folder and name */ - const gchar *slash = strrchr(name, '/'); + const char *slash = strrchr(name, '/'); debug("Agent replied with %s", name); if (!slash) { agent->new_name = g_strdup(name); @@ -708,28 +709,27 @@ static void agent_reply(DBusPendingCall *call, gpointer user_data) dbus_message_unref(reply); } -static gboolean auth_error(GIOChannel *io, GIOCondition cond, - gpointer user_data) +static gboolean auth_error(GIOChannel *io, GIOCondition cond, void *user_data) { agent->auth_pending = FALSE; return FALSE; } -int manager_request_authorization(struct obex_session *os, gint32 time, - gchar **new_folder, gchar **new_name) +int manager_request_authorization(struct obex_session *os, int32_t time, + char **new_folder, char **new_name) { DBusMessage *msg; DBusPendingCall *call; GIOChannel *io; struct sockaddr_rc addr; socklen_t addrlen; - gchar address[18]; - const gchar *bda = address; - const gchar *filename = (os->name ? os->name : ""); - const gchar *type = (os->type ? os->type : ""); - gchar *path; - guint watch, fd; + char address[18]; + const char *bda = address; + const char *filename = os->name ? os->name : ""; + const char *type = os->type ? os->type : ""; + char *path; + unsigned int watch, fd; gboolean got_reply; if (!agent) @@ -831,7 +831,7 @@ static void pending_request_free(struct pending_request *pending) g_free(pending); } -static void service_reply(DBusPendingCall *call, gpointer user_data) +static void service_reply(DBusPendingCall *call, void *user_data) { struct pending_request *pending = user_data; GIOChannel *io = pending->io; @@ -868,7 +868,7 @@ done: } static gboolean service_error(GIOChannel *io, GIOCondition cond, - gpointer user_data) + void *user_data) { struct pending_request *pending = user_data; @@ -881,7 +881,7 @@ static gboolean service_error(GIOChannel *io, GIOCondition cond, return FALSE; } -static void find_adapter_reply(DBusPendingCall *call, gpointer user_data) +static void find_adapter_reply(DBusPendingCall *call, void *user_data) { struct pending_request *pending = user_data; DBusMessage *reply = dbus_pending_call_steal_reply(call); @@ -944,7 +944,7 @@ failed: pending_request_free(pending); } -gint request_service_authorization(struct server *server, GIOChannel *io, +int request_service_authorization(struct server *server, GIOChannel *io, const char *address) { struct pending_request *pending; @@ -980,7 +980,7 @@ gint request_service_authorization(struct server *server, GIOChannel *io, void manager_register_session(struct obex_session *os) { - gchar *path = g_strdup_printf("/session%u", os->cid); + char *path = g_strdup_printf("/session%u", os->cid); if (!g_dbus_register_interface(connection, path, SESSION_INTERFACE, @@ -1001,7 +1001,7 @@ void manager_register_session(struct obex_session *os) void manager_unregister_session(struct obex_session *os) { - gchar *path = g_strdup_printf("/session%u", os->cid); + char *path = g_strdup_printf("/session%u", os->cid); g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE, "SessionRemoved", diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c index 4ec7665db..0f638a07e 100644 --- a/obexd/src/mimetype.c +++ b/obexd/src/mimetype.c @@ -41,12 +41,12 @@ static GSList *drivers = NULL; static GSList *watches = NULL; struct io_watch { - gpointer object; + void *object; obex_object_io_func func; - gpointer user_data; + void *user_data; }; -void obex_object_set_io_flags(gpointer object, int flags, int err) +void obex_object_set_io_flags(void *object, int flags, int err) { GSList *l; @@ -67,7 +67,7 @@ void obex_object_set_io_flags(gpointer object, int flags, int err) } } -static struct io_watch *find_io_watch(gpointer object) +static struct io_watch *find_io_watch(void *object) { GSList *l; @@ -81,7 +81,7 @@ static struct io_watch *find_io_watch(gpointer object) return NULL; } -static void reset_io_watch(gpointer object) +static void reset_io_watch(void *object) { struct io_watch *watch; @@ -93,8 +93,8 @@ static void reset_io_watch(gpointer object) g_free(watch); } -static int set_io_watch(gpointer object, obex_object_io_func func, - gpointer user_data) +static int set_io_watch(void *object, obex_object_io_func func, + void *user_data) { struct io_watch *watch; @@ -117,8 +117,9 @@ static int set_io_watch(gpointer object, obex_object_io_func func, return 0; } -struct obex_mime_type_driver *obex_mime_type_driver_find(const guint8 *target, - const char *mimetype, const guint8 *who, guint who_size) +struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, + const char *mimetype, const uint8_t *who, + unsigned int who_size) { GSList *l; diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h index 39ad51e2e..4cb3156d9 100644 --- a/obexd/src/mimetype.h +++ b/obexd/src/mimetype.h @@ -21,27 +21,28 @@ * */ -typedef gboolean (*obex_object_io_func) (gpointer object, int flags, int err, - gpointer user_data); +typedef gboolean (*obex_object_io_func) (void *object, int flags, int err, + void *user_data); struct obex_mime_type_driver { - const guint8 *target; + const uint8_t *target; const char *mimetype; - const guint8 *who; - guint who_size; - gpointer (*open) (const char *name, int oflag, mode_t mode, - gpointer driver_data, size_t *size, int *err); - int (*close) (gpointer object); - ssize_t (*read) (gpointer object, void *buf, size_t count, guint8 *hi); - ssize_t (*write) (gpointer object, const void *buf, size_t count); + const uint8_t *who; + unsigned int who_size; + void *(*open) (const char *name, int oflag, mode_t mode, + void *driver_data, size_t *size, int *err); + int (*close) (void *object); + ssize_t (*read) (void *object, void *buf, size_t count, uint8_t *hi); + ssize_t (*write) (void *object, const void *buf, size_t count); int (*remove) (const char *name); - int (*set_io_watch) (gpointer object, obex_object_io_func func, - gpointer user_data); + int (*set_io_watch) (void *object, obex_object_io_func func, + void *user_data); }; int obex_mime_type_driver_register(struct obex_mime_type_driver *driver); void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver); -struct obex_mime_type_driver *obex_mime_type_driver_find(const guint8 *target, - const char *mimetype, const guint8 *who, guint who_size); +struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, + const char *mimetype, const uint8_t *who, + unsigned int who_size); -void obex_object_set_io_flags(gpointer object, int flags, int err); +void obex_object_set_io_flags(void *object, int flags, int err); diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h index 11d524f17..0f167ce61 100644 --- a/obexd/src/obex-priv.h +++ b/obexd/src/obex-priv.h @@ -23,49 +23,49 @@ */ struct server { - gboolean auto_accept; - gchar *folder; - gboolean symlinks; - gchar *capability; - guint32 handle; - gchar *devnode; - gboolean secure; - GIOChannel *io; - guint watch; - guint16 tx_mtu; - guint16 rx_mtu; - GSList *drivers; + gboolean auto_accept; + char *folder; + gboolean symlinks; + char *capability; + uint32_t handle; + char *devnode; + gboolean secure; + GIOChannel *io; + unsigned int watch; + uint16_t tx_mtu; + uint16_t rx_mtu; + GSList *drivers; }; struct obex_session { - GIOChannel *io; - guint32 cid; - guint16 tx_mtu; - guint16 rx_mtu; - guint8 cmd; - gchar *name; - gchar *type; - const gchar *path; - time_t time; - guint8 *buf; - gint32 pending; - gint32 offset; - gint32 size; - gpointer object; - gboolean aborted; + GIOChannel *io; + uint32_t cid; + uint16_t tx_mtu; + uint16_t rx_mtu; + uint8_t cmd; + char *name; + char *type; + const char *path; + time_t time; + uint8_t *buf; + int32_t pending; + int32_t offset; + int32_t size; + void *object; + gboolean aborted; struct obex_service_driver *service; - gpointer service_data; + void *service_data; struct server *server; - gboolean checked; - obex_t *obex; - obex_object_t *obj; + gboolean checked; + obex_t *obex; + obex_object_t *obj; struct obex_mime_type_driver *driver; - gboolean finished; + gboolean finished; }; -gint obex_session_start(GIOChannel *io, struct server *server); +int obex_session_start(GIOChannel *io, struct server *server); void server_free(struct server *server); void register_record(struct server *server); -gint request_service_authorization(struct server *server, GIOChannel *io, - const char *address); +int request_service_authorization(struct server *server, GIOChannel *io, + const char *address); diff --git a/obexd/src/obex.c b/obexd/src/obex.c index e4872c1d5..f781ce668 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -55,20 +55,20 @@ #define DEFAULT_TX_MTU 32767 /* Connection ID */ -static guint32 cid = 0x0000; +static uint32_t cid = 0x0000; static GSList *sessions = NULL; typedef struct { - guint8 version; - guint8 flags; - guint16 mtu; + uint8_t version; + uint8_t flags; + uint16_t mtu; } __attribute__ ((packed)) obex_connect_hdr_t; static void os_set_response(obex_object_t *obj, int err) { - guint8 rsp; - guint8 lastrsp; + uint8_t rsp; + uint8_t lastrsp; switch (err) { case 0: @@ -163,12 +163,12 @@ static void obex_session_free(struct obex_session *os) } /* From Imendio's GnomeVFS OBEX module (om-utils.c) */ -static time_t parse_iso8610(const gchar *val, int size) +static time_t parse_iso8610(const char *val, int size) { time_t time, tz_offset = 0; struct tm tm; - gchar *date; - gchar tz; + char *date; + char tz; int nr; memset(&tm, 0, sizeof(tm)); @@ -215,11 +215,11 @@ static void cmd_connect(struct obex_session *os, obex_connect_hdr_t *nonhdr; obex_headerdata_t hd; uint8_t *buffer; - guint hlen, newsize; - guint16 mtu; - guint8 hi; - const guint8 *target = NULL, *who = NULL; - guint target_size = 0, who_size = 0; + unsigned int hlen, newsize; + uint16_t mtu; + uint8_t hi; + const uint8_t *target = NULL, *who = NULL; + unsigned int target_size = 0, who_size = 0; int err; if (OBEX_ObjectGetNonHdrData(obj, &buffer) != sizeof(*nonhdr)) { @@ -287,12 +287,12 @@ static void cmd_connect(struct obex_session *os, os_set_response(obj, err); } -static gboolean chk_cid(obex_t *obex, obex_object_t *obj, guint32 cid) +static gboolean chk_cid(obex_t *obex, obex_object_t *obj, uint32_t cid) { struct obex_session *os; obex_headerdata_t hd; - guint hlen; - guint8 hi; + unsigned int hlen; + uint8_t hi; gboolean ret = FALSE; os = OBEX_GetUserData(obex); @@ -317,12 +317,12 @@ static gboolean chk_cid(obex_t *obex, obex_object_t *obj, guint32 cid) return ret; } -static gint obex_read_stream(struct obex_session *os, obex_t *obex, +static int obex_read_stream(struct obex_session *os, obex_t *obex, obex_object_t *obj) { - gint size; - gint32 len = 0; - const guint8 *buffer; + int size; + int32_t len = 0; + const uint8_t *buffer; if (os->aborted) return -EPERM; @@ -355,7 +355,7 @@ static gint obex_read_stream(struct obex_session *os, obex_t *obex, write: while (os->pending > 0) { - gint w; + int w; w = os->driver->write(os->object, os->buf + len, os->pending); @@ -376,14 +376,14 @@ write: return 0; } -static gint obex_write_stream(struct obex_session *os, +static int obex_write_stream(struct obex_session *os, obex_t *obex, obex_object_t *obj) { obex_headerdata_t hd; - guint8 *ptr; - gint32 len; - guint flags; - guint8 hi; + uint8_t *ptr; + int32_t len; + unsigned int flags; + uint8_t hi; debug("obex_write_stream: name=%s type=%s tx_mtu=%d file=%p", os->name ? os->name : "", os->type ? os->type : "", @@ -422,7 +422,7 @@ add_header: switch (hi) { case OBEX_HDR_BODY: - flags = (len ? OBEX_FL_STREAM_DATA : OBEX_FL_STREAM_DATAEND); + flags = len ? OBEX_FL_STREAM_DATA : OBEX_FL_STREAM_DATAEND; break; case OBEX_HDR_APPARAM: flags = 0; @@ -442,8 +442,8 @@ add_header: return len; } -static gboolean handle_async_io(gpointer object, int flags, int err, - gpointer user_data) +static gboolean handle_async_io(void *object, int flags, int err, + void *user_data) { struct obex_session *os = user_data; int ret = 0; @@ -484,8 +484,8 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj) { obex_headerdata_t hd; gboolean stream; - guint hlen; - guint8 hi; + unsigned int hlen; + uint8_t hi; int err; if (!os->service) { @@ -510,7 +510,7 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj) if (hlen == 0) continue; - os->name = g_convert((const gchar *) hd.bs, hlen, + os->name = g_convert((const char *) hd.bs, hlen, "UTF8", "UTF16BE", NULL, NULL, NULL); debug("OBEX_HDR_NAME: %s", os->name); break; @@ -527,14 +527,14 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj) if (hd.bs[hlen - 1] != '\0') break; - if (!g_utf8_validate((const gchar *) hd.bs, -1, NULL)) { + if (!g_utf8_validate((const char *) hd.bs, -1, NULL)) { debug("Invalid type header: %s", hd.bs); break; } /* FIXME: x-obex/folder-listing - type is mandatory */ - os->type = g_strndup((const gchar *) hd.bs, hlen); + os->type = g_strndup((const char *) hd.bs, hlen); debug("OBEX_HDR_TYPE: %s", os->type); os->driver = obex_mime_type_driver_find( os->service->target, os->type, @@ -597,9 +597,9 @@ static void cmd_setpath(struct obex_session *os, obex_t *obex, obex_object_t *obj) { obex_headerdata_t hd; - guint32 hlen; + uint32_t hlen; int err; - guint8 hi; + uint8_t hi; if (!os->service) { OBEX_ObjectSetRsp(obj, OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN); @@ -633,7 +633,7 @@ static void cmd_setpath(struct obex_session *os, break; } - os->name = g_convert((const gchar *) hd.bs, hlen, + os->name = g_convert((const char *) hd.bs, hlen, "UTF8", "UTF16BE", NULL, NULL, NULL); debug("Set path name: %s", os->name); @@ -644,10 +644,10 @@ static void cmd_setpath(struct obex_session *os, os_set_response(obj, err); } -int obex_get_stream_start(struct obex_session *os, const gchar *filename) +int obex_get_stream_start(struct obex_session *os, const char *filename) { - gint err; - gpointer object; + int err; + void *object; size_t size; object = os->driver->open(filename, O_RDONLY, 0, os->service_data, @@ -673,7 +673,7 @@ fail: return err; } -gint obex_put_stream_start(struct obex_session *os, const gchar *filename) +int obex_put_stream_start(struct obex_session *os, const char *filename) { int err; @@ -703,9 +703,9 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj) { struct obex_session *os; obex_headerdata_t hd; - guint hlen; - guint8 hi; - gint ret; + unsigned int hlen; + uint8_t hi; + int ret; os = OBEX_GetUserData(obex); @@ -730,7 +730,7 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj) if (hlen == 0) continue; - os->name = g_convert((const gchar *) hd.bs, hlen, + os->name = g_convert((const char *) hd.bs, hlen, "UTF8", "UTF16BE", NULL, NULL, NULL); debug("OBEX_HDR_NAME: %s", os->name); break; @@ -748,12 +748,12 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj) if (hd.bs[hlen - 1] != '\0') break; - if (!g_utf8_validate((const gchar *) hd.bs, -1, NULL)) { + if (!g_utf8_validate((const char *) hd.bs, -1, NULL)) { debug("Invalid type header: %s", hd.bs); break; } - os->type = g_strndup((const gchar *) hd.bs, hlen); + os->type = g_strndup((const char *) hd.bs, hlen); debug("OBEX_HDR_TYPE: %s", os->type); os->driver = obex_mime_type_driver_find( os->service->target, os->type, @@ -771,7 +771,7 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj) debug("OBEX_HDR_LENGTH: %d", os->size); break; case OBEX_HDR_TIME: - os->time = parse_iso8610((const gchar *) hd.bs, hlen); + os->time = parse_iso8610((const char *) hd.bs, hlen); break; } } @@ -859,8 +859,8 @@ 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, gint mode, - gint evt, gint cmd, gint rsp) +static void obex_event(obex_t *obex, obex_object_t *obj, int mode, + int evt, int cmd, int rsp) { struct obex_session *os; @@ -1010,7 +1010,7 @@ void server_free(struct server *server) g_free(server); } -static void obex_handle_destroy(gpointer user_data) +static void obex_handle_destroy(void *user_data) { struct obex_session *os; obex_t *obex = user_data; @@ -1025,11 +1025,11 @@ static void obex_handle_destroy(gpointer user_data) OBEX_Cleanup(obex); } -static gboolean tty_reinit(gpointer data) +static gboolean tty_reinit(void *data) { struct server *server = data; GSList *l; - guint services = 0; + unsigned int services = 0; for (l = server->drivers; l; l = l->next) { struct obex_service_driver *driver = l->data; @@ -1046,7 +1046,7 @@ static gboolean tty_reinit(gpointer data) } static gboolean obex_handle_input(GIOChannel *io, - GIOCondition cond, gpointer user_data) + GIOCondition cond, void *user_data) { obex_t *obex = user_data; struct obex_session *os = OBEX_GetUserData(obex); @@ -1077,7 +1077,7 @@ failed: return FALSE; } -void obex_connect_cb(GIOChannel *io, GError *err, gpointer user_data) +void obex_connect_cb(GIOChannel *io, GError *err, void *user_data) { struct server *server = user_data; @@ -1091,11 +1091,11 @@ void obex_connect_cb(GIOChannel *io, GError *err, gpointer user_data) g_io_channel_shutdown(io, TRUE, NULL); } -gint obex_session_start(GIOChannel *io, struct server *server) +int obex_session_start(GIOChannel *io, struct server *server) { struct obex_session *os; obex_t *obex; - gint ret, fd; + int ret, fd; os = g_new0(struct obex_session, 1); @@ -1136,7 +1136,7 @@ gint obex_session_start(GIOChannel *io, struct server *server) return 0; } -gint obex_tty_session_stop(void) +int obex_tty_session_stop(void) { GSList *l; @@ -1170,7 +1170,7 @@ const char *obex_get_root_folder(struct obex_session *os) return os->server->folder; } -guint16 obex_get_service(struct obex_session *os) +uint16_t obex_get_service(struct obex_session *os) { return os->service->service; } @@ -1202,8 +1202,8 @@ int obex_remove(struct obex_session *os, const char *path) char *obex_get_id(struct obex_session *os) { GError *gerr = NULL; - gchar address[18]; - guint8 channel; + char address[18]; + uint8_t channel; bt_io_get(os->io, BT_IO_RFCOMM, &gerr, BT_IO_OPT_DEST, address, @@ -1216,11 +1216,11 @@ char *obex_get_id(struct obex_session *os) } ssize_t obex_aparam_read(struct obex_session *os, - obex_object_t *obj, const guint8 **buffer) + obex_object_t *obj, const uint8_t **buffer) { obex_headerdata_t hd; - guint8 hi; - guint32 hlen; + uint8_t hi; + uint32_t hlen; OBEX_ObjectReParseHeaders(os->obex, obj); @@ -1235,7 +1235,7 @@ ssize_t obex_aparam_read(struct obex_session *os, } int obex_aparam_write(struct obex_session *os, - obex_object_t *obj, const guint8 *data, guint size) + obex_object_t *obj, const uint8_t *data, unsigned int size) { obex_headerdata_t hd; diff --git a/obexd/src/obex.h b/obexd/src/obex.h index 5b92808ce..1d568098c 100644 --- a/obexd/src/obex.h +++ b/obexd/src/obex.h @@ -40,31 +40,31 @@ struct obex_session; -void obex_connect_cb(GIOChannel *io, GError *err, gpointer user_data); +void obex_connect_cb(GIOChannel *io, GError *err, void *user_data); -int obex_get_stream_start(struct obex_session *os, const gchar *filename); -int obex_put_stream_start(struct obex_session *os, const gchar *filename); +int obex_get_stream_start(struct obex_session *os, const char *filename); +int obex_put_stream_start(struct obex_session *os, const char *filename); const char *obex_get_name(struct obex_session *os); ssize_t obex_get_size(struct obex_session *os); const char *obex_get_type(struct obex_session *os); const char *obex_get_root_folder(struct obex_session *os); -guint16 obex_get_service(struct obex_session *os); +uint16_t obex_get_service(struct obex_session *os); gboolean obex_get_symlinks(struct obex_session *os); const char *obex_get_capability_path(struct obex_session *os); gboolean obex_get_auto_accept(struct obex_session *os); int obex_remove(struct obex_session *os, const char *path); char *obex_get_id(struct obex_session *os); -ssize_t obex_aparam_read(struct obex_session *os, - obex_object_t *obj, const guint8 **buffer); -int obex_aparam_write(struct obex_session *os, - obex_object_t *obj, const guint8 *buffer, guint size); +ssize_t obex_aparam_read(struct obex_session *os, obex_object_t *obj, + const uint8_t **buffer); +int obex_aparam_write(struct obex_session *os, obex_object_t *obj, + const uint8_t *buffer, unsigned int size); -const gchar *obex_option_root_folder(void); +const char *obex_option_root_folder(void); gboolean obex_option_symlinks(void); -int tty_init(gint service, const gchar *folder, const gchar *capability, - gboolean symlinks, const gchar *devnode); -gint obex_tty_session_stop(void); +int tty_init(int service, const char *folder, const char *capability, + gboolean symlinks, const char *devnode); +int obex_tty_session_stop(void); void tty_closed(void); /* Just a thin wrapper around memcmp to deal with NULL values */ diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c index 301f64e72..2e12ac3b7 100644 --- a/obexd/src/plugin.c +++ b/obexd/src/plugin.c @@ -84,7 +84,7 @@ static gboolean add_plugin(void *handle, struct obex_plugin_desc *desc) gboolean plugin_init(void) { GDir *dir; - const gchar *file; + const char *file; unsigned int i; if (strlen(PLUGINDIR) == 0) @@ -104,7 +104,7 @@ gboolean plugin_init(void) while ((file = g_dir_read_name(dir)) != NULL) { struct obex_plugin_desc *desc; void *handle; - gchar *filename; + char *filename; if (g_str_has_prefix(file, "lib") == TRUE || g_str_has_suffix(file, ".so") == FALSE) diff --git a/obexd/src/service.c b/obexd/src/service.c index ad0889d85..befea9ca0 100644 --- a/obexd/src/service.c +++ b/obexd/src/service.c @@ -37,14 +37,13 @@ static GSList *drivers = NULL; -struct obex_service_driver *obex_service_driver_find(GSList *list, - const guint8 *target, guint target_size, - const guint8 *who, guint who_size) - +struct obex_service_driver *obex_service_driver_find(GSList *drivers, + const uint8_t *target, unsigned int target_size, + const uint8_t *who, unsigned int who_size) { GSList *l; - for (l = list; l; l = l->next) { + for (l = drivers; l; l = l->next) { struct obex_service_driver *driver = l->data; if (memcmp0(who, driver->who, who_size)) @@ -57,7 +56,7 @@ struct obex_service_driver *obex_service_driver_find(GSList *list, return NULL; } -GSList *obex_service_driver_list(guint16 services) +GSList *obex_service_driver_list(uint16_t services) { GSList *l; GSList *list = NULL; diff --git a/obexd/src/service.h b/obexd/src/service.h index 81185d9ff..1726c432d 100644 --- a/obexd/src/service.h +++ b/obexd/src/service.h @@ -23,27 +23,28 @@ struct obex_service_driver { const char *name; - guint16 service; - guint8 channel; - const guint8 *target; - guint target_size; - const guint8 *who; - guint who_size; - const gchar *record; - gpointer (*connect) (struct obex_session *os, int *err); - void (*progress) (struct obex_session *os, gpointer user_data); + uint16_t service; + uint8_t channel; + const uint8_t *target; + unsigned int target_size; + const uint8_t *who; + unsigned int who_size; + const char *record; + void *(*connect) (struct obex_session *os, int *err); + void (*progress) (struct obex_session *os, void *user_data); int (*get) (struct obex_session *os, obex_object_t *obj, - gboolean *stream, gpointer user_data); - int (*put) (struct obex_session *os, gpointer user_data); - gint (*chkput) (struct obex_session *os, gpointer user_data); - int (*setpath) (struct obex_session *os, obex_object_t *obj, gpointer user_data); - void (*disconnect) (struct obex_session *os, gpointer user_data); - void (*reset) (struct obex_session *os, gpointer user_data); + gboolean *stream, void *user_data); + int (*put) (struct obex_session *os, void *user_data); + int (*chkput) (struct obex_session *os, void *user_data); + int (*setpath) (struct obex_session *os, obex_object_t *obj, + void *user_data); + void (*disconnect) (struct obex_session *os, void *user_data); + void (*reset) (struct obex_session *os, void *user_data); }; int obex_service_driver_register(struct obex_service_driver *driver); void obex_service_driver_unregister(struct obex_service_driver *driver); -GSList *obex_service_driver_list(guint16 services); +GSList *obex_service_driver_list(uint16_t services); struct obex_service_driver *obex_service_driver_find(GSList *drivers, - const guint8 *target, guint target_size, - const guint8 *who, guint who_size); + const uint8_t *target, unsigned int target_size, + const uint8_t *who, unsigned int who_size); -- 2.47.3