]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DBus: Move wpas_dbus_new_decompose_object_path()
authorFabien Marotte <fabienx.marotte@linux.intel.com>
Sun, 12 Jun 2011 21:41:41 +0000 (14:41 -0700)
committerJouni Malinen <j@w1.fi>
Sun, 12 Jun 2011 21:41:41 +0000 (14:41 -0700)
Moved wpas_dbus_new_decompose_object_path from dbus_new_handlers.c
to dbus_new_helpers.c.

Signed-off-by: Fabien Marotte <fabienx.marotte@linux.intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/dbus/dbus_new_helpers.c
wpa_supplicant/dbus/dbus_new_helpers.h

index 68e5465db7a917e2b958f4877b261756d9c13662..08d0f15c6245cc2f8c67a4e8248f4fc8fbbe8bf9 100644 (file)
@@ -42,70 +42,6 @@ static const char *debug_strings[] = {
 };
 
 
-/**
- * wpas_dbus_new_decompose_object_path - Decompose an interface object path into parts
- * @path: The dbus object path
- * @network: (out) the configured network this object path refers to, if any
- * @bssid: (out) the scanned bssid this object path refers to, if any
- * Returns: The object path of the network interface this path refers to
- *
- * For a given object path, decomposes the object path into object id, network,
- * and BSSID parts, if those parts exist.
- */
-static char * wpas_dbus_new_decompose_object_path(const char *path,
-                                                 char **network,
-                                                 char **bssid)
-{
-       const unsigned int dev_path_prefix_len =
-               strlen(WPAS_DBUS_NEW_PATH_INTERFACES "/");
-       char *obj_path_only;
-       char *next_sep;
-
-       /* Be a bit paranoid about path */
-       if (!path || os_strncmp(path, WPAS_DBUS_NEW_PATH_INTERFACES "/",
-                               dev_path_prefix_len))
-               return NULL;
-
-       /* Ensure there's something at the end of the path */
-       if ((path + dev_path_prefix_len)[0] == '\0')
-               return NULL;
-
-       obj_path_only = os_strdup(path);
-       if (obj_path_only == NULL)
-               return NULL;
-
-       next_sep = os_strchr(obj_path_only + dev_path_prefix_len, '/');
-       if (next_sep != NULL) {
-               const char *net_part = os_strstr(
-                       next_sep, WPAS_DBUS_NEW_NETWORKS_PART "/");
-               const char *bssid_part = os_strstr(
-                       next_sep, WPAS_DBUS_NEW_BSSIDS_PART "/");
-
-               if (network && net_part) {
-                       /* Deal with a request for a configured network */
-                       const char *net_name = net_part +
-                               os_strlen(WPAS_DBUS_NEW_NETWORKS_PART "/");
-                       *network = NULL;
-                       if (os_strlen(net_name))
-                               *network = os_strdup(net_name);
-               } else if (bssid && bssid_part) {
-                       /* Deal with a request for a scanned BSSID */
-                       const char *bssid_name = bssid_part +
-                               os_strlen(WPAS_DBUS_NEW_BSSIDS_PART "/");
-                       if (strlen(bssid_name))
-                               *bssid = os_strdup(bssid_name);
-                       else
-                               *bssid = NULL;
-               }
-
-               /* Cut off interface object path before "/" */
-               *next_sep = '\0';
-       }
-
-       return obj_path_only;
-}
-
-
 /**
  * wpas_dbus_error_unknown_error - Return a new InvalidArgs error message
  * @message: Pointer to incoming dbus message this error refers to
index 6e6e842c8fdb88cb91e8e0bf044569853452b9ab..9675e658688c7038fddce87cf048f68227b50735 100644 (file)
@@ -884,3 +884,66 @@ void wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface,
        fill_dict_with_properties(dict_iter, obj_desc->properties,
                                  interface, obj_desc->user_data);
 }
+
+/**
+ * wpas_dbus_new_decompose_object_path - Decompose an interface object path into parts
+ * @path: The dbus object path
+ * @network: (out) the configured network this object path refers to, if any
+ * @bssid: (out) the scanned bssid this object path refers to, if any
+ * Returns: The object path of the network interface this path refers to
+ *
+ * For a given object path, decomposes the object path into object id, network,
+ * and BSSID parts, if those parts exist.
+ */
+char *wpas_dbus_new_decompose_object_path(const char *path,
+                                          char **network,
+                                          char **bssid)
+{
+       const unsigned int dev_path_prefix_len =
+               os_strlen(WPAS_DBUS_NEW_PATH_INTERFACES "/");
+       char *obj_path_only;
+       char *next_sep;
+
+       /* Be a bit paranoid about path */
+       if (!path || os_strncmp(path, WPAS_DBUS_NEW_PATH_INTERFACES "/",
+                               dev_path_prefix_len))
+               return NULL;
+
+       /* Ensure there's something at the end of the path */
+       if ((path + dev_path_prefix_len)[0] == '\0')
+               return NULL;
+
+       obj_path_only = os_strdup(path);
+       if (obj_path_only == NULL)
+               return NULL;
+
+       next_sep = os_strchr(obj_path_only + dev_path_prefix_len, '/');
+       if (next_sep != NULL) {
+               const char *net_part = os_strstr(
+                       next_sep, WPAS_DBUS_NEW_NETWORKS_PART "/");
+               const char *bssid_part = os_strstr(
+                       next_sep, WPAS_DBUS_NEW_BSSIDS_PART "/");
+
+               if (network && net_part) {
+                       /* Deal with a request for a configured network */
+                       const char *net_name = net_part +
+                               os_strlen(WPAS_DBUS_NEW_NETWORKS_PART "/");
+                       *network = NULL;
+                       if (os_strlen(net_name))
+                               *network = os_strdup(net_name);
+               } else if (bssid && bssid_part) {
+                       /* Deal with a request for a scanned BSSID */
+                       const char *bssid_name = bssid_part +
+                               os_strlen(WPAS_DBUS_NEW_BSSIDS_PART "/");
+                       if (os_strlen(bssid_name))
+                               *bssid = os_strdup(bssid_name);
+                       else
+                               *bssid = NULL;
+               }
+
+               /* Cut off interface object path before "/" */
+               *next_sep = '\0';
+       }
+
+       return obj_path_only;
+}
index 7038b634335ed570ea9748de05e9fc163794821d..9476d156439939e6381d10f9e4cecc4d0583a4a2 100644 (file)
@@ -145,4 +145,8 @@ void wpa_dbus_mark_property_changed(struct wpas_dbus_priv *iface,
 DBusMessage * wpa_dbus_introspect(DBusMessage *message,
                                  struct wpa_dbus_object_desc *obj_dsc);
 
+char *wpas_dbus_new_decompose_object_path(const char *path,
+                                          char **network,
+                                          char **bssid);
+
 #endif /* WPA_DBUS_CTRL_H */