From: Christian Zimmermann <zimmermach@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Christian Zimmermann <zimmermach@gmail.com>
Subject: [PATCH BlueZ 2/2] Removed obsolete conversion functions, since the conversion is now done once during install
Date: Mon, 26 Nov 2018 17:49:07 +0100 [thread overview]
Message-ID: <20181126164907.15659-2-zimmermach@gmail.com> (raw)
In-Reply-To: <20181126164907.15659-1-zimmermach@gmail.com>
---
src/adapter.c | 51 ---------------------------
src/storage.c | 110 ----------------------------------------------------------
src/storage.h | 4 ---
3 files changed, 165 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index c24432125..ff8f64300 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -423,18 +423,6 @@ void btd_adapter_set_class(struct btd_adapter *adapter, uint8_t major,
set_dev_class(adapter);
}
-static uint8_t get_mode(const char *mode)
-{
- if (strcasecmp("off", mode) == 0)
- return MODE_OFF;
- else if (strcasecmp("connectable", mode) == 0)
- return MODE_CONNECTABLE;
- else if (strcasecmp("discoverable", mode) == 0)
- return MODE_DISCOVERABLE;
- else
- return MODE_UNKNOWN;
-}
-
const char *btd_adapter_get_storage_dir(struct btd_adapter *adapter)
{
static char dir[25];
@@ -5639,44 +5627,6 @@ static void convert_device_storage(struct btd_adapter *adapter)
textfile_foreach(filename, convert_proximity_entry, address);
}
-static void convert_config(struct btd_adapter *adapter, const char *filename,
- GKeyFile *key_file)
-{
- char address[18];
- char str[MAX_NAME_LENGTH + 1];
- char config_path[PATH_MAX];
- int timeout;
- uint8_t mode;
- char *data;
- gsize length = 0;
-
- ba2str(&adapter->bdaddr, address);
- snprintf(config_path, PATH_MAX, STORAGEDIR "/%s/config", address);
-
- if (read_pairable_timeout(address, &timeout) == 0)
- g_key_file_set_integer(key_file, "General",
- "PairableTimeout", timeout);
-
- if (read_discoverable_timeout(address, &timeout) == 0)
- g_key_file_set_integer(key_file, "General",
- "DiscoverableTimeout", timeout);
-
- if (read_on_mode(address, str, sizeof(str)) == 0) {
- mode = get_mode(str);
- g_key_file_set_boolean(key_file, "General", "Discoverable",
- mode == MODE_DISCOVERABLE);
- }
-
- if (read_local_name(&adapter->bdaddr, str) == 0)
- g_key_file_set_string(key_file, "General", "Alias", str);
-
- create_file(filename, S_IRUSR | S_IWUSR);
-
- data = g_key_file_to_data(key_file, &length, NULL);
- g_file_set_contents(filename, data, length, NULL);
- g_free(data);
-}
-
static void fix_storage(struct btd_adapter *adapter)
{
char filename[PATH_MAX];
@@ -5753,7 +5703,6 @@ static void load_config(struct btd_adapter *adapter)
btd_adapter_get_storage_dir(adapter));
if (stat(filename, &st) < 0) {
- convert_config(adapter, filename, key_file);
convert_device_storage(adapter);
}
diff --git a/src/storage.c b/src/storage.c
index 734a9e08e..6317d7cf5 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -22,128 +22,18 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <unistd.h>
#include <stdlib.h>
-#include <time.h>
-#include <sys/file.h>
-#include <sys/stat.h>
#include <glib.h>
#include "lib/bluetooth.h"
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
-#include "lib/uuid.h"
#include "textfile.h"
#include "uuid-helper.h"
#include "storage.h"
-/* When all services should trust a remote device */
-#define GLOBAL_TRUST "[all]"
-
-struct match {
- GSList *keys;
- char *pattern;
-};
-
-static inline int create_filename(char *buf, size_t size,
- const bdaddr_t *bdaddr, const char *name)
-{
- char addr[18];
-
- ba2str(bdaddr, addr);
-
- return create_name(buf, size, STORAGEDIR, addr, name);
-}
-
-int read_discoverable_timeout(const char *src, int *timeout)
-{
- char filename[PATH_MAX], *str;
-
- create_name(filename, PATH_MAX, STORAGEDIR, src, "config");
-
- str = textfile_get(filename, "discovto");
- if (!str)
- return -ENOENT;
-
- if (sscanf(str, "%d", timeout) != 1) {
- free(str);
- return -ENOENT;
- }
-
- free(str);
-
- return 0;
-}
-
-int read_pairable_timeout(const char *src, int *timeout)
-{
- char filename[PATH_MAX], *str;
-
- create_name(filename, PATH_MAX, STORAGEDIR, src, "config");
-
- str = textfile_get(filename, "pairto");
- if (!str)
- return -ENOENT;
-
- if (sscanf(str, "%d", timeout) != 1) {
- free(str);
- return -ENOENT;
- }
-
- free(str);
-
- return 0;
-}
-
-int read_on_mode(const char *src, char *mode, int length)
-{
- char filename[PATH_MAX], *str;
-
- create_name(filename, PATH_MAX, STORAGEDIR, src, "config");
-
- str = textfile_get(filename, "onmode");
- if (!str)
- return -ENOENT;
-
- strncpy(mode, str, length);
- mode[length - 1] = '\0';
-
- free(str);
-
- return 0;
-}
-
-int read_local_name(const bdaddr_t *bdaddr, char *name)
-{
- char filename[PATH_MAX], *str;
- int len;
-
- create_filename(filename, PATH_MAX, bdaddr, "config");
-
- str = textfile_get(filename, "name");
- if (!str)
- return -ENOENT;
-
- len = strlen(str);
- if (len > HCI_MAX_NAME_LENGTH)
- str[HCI_MAX_NAME_LENGTH] = '\0';
- strcpy(name, str);
-
- free(str);
-
- return 0;
-}
-
sdp_record_t *record_from_string(const char *str)
{
sdp_record_t *rec;
diff --git a/src/storage.h b/src/storage.h
index 1c0ad57ec..8b7d9aa30 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -21,9 +21,5 @@
*
*/
-int read_discoverable_timeout(const char *src, int *timeout);
-int read_pairable_timeout(const char *src, int *timeout);
-int read_on_mode(const char *src, char *mode, int length);
-int read_local_name(const bdaddr_t *bdaddr, char *name);
sdp_record_t *record_from_string(const char *str);
sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid);
--
2.11.0
next prev parent reply other threads:[~2018-11-26 16:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-26 16:49 [PATCH BlueZ 1/2] Added config conversion for Bluez4 as shell script during install Christian Zimmermann
2018-11-26 16:49 ` Christian Zimmermann [this message]
2018-11-27 11:50 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181126164907.15659-2-zimmermach@gmail.com \
--to=zimmermach@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).