+ auth->refcount--;
+ if (auth->refcount == 0)
+ auth_client_free(auth);
+}
+
+/* Get a provider by name */
+static inline struct auth_provider *
+find_provider(const char *name)
+{
+ rb_dlink_node *ptr;
+
+ RB_DLINK_FOREACH(ptr, auth_providers.head)
+ {
+ struct auth_provider *provider = ptr->data;
+
+ if(strcasecmp(provider->name, name) == 0)
+ return provider;
+ }
+
+ return NULL;
+}
+
+/* Get a provider's id by name */
+static inline bool
+get_provider_id(const char *name, uint32_t *id)
+{
+ struct auth_provider *provider = find_provider(name);
+
+ if(provider != NULL)
+ {
+ *id = provider->id;
+ return true;
+ }
+ else
+ return false;
+}
+
+/* Get a provider's raw status */
+static inline provider_status_t
+get_provider_status(struct auth_client *auth, uint32_t provider)
+{
+ return auth->data[provider].status;
+}
+
+/* Set a provider's raw status */
+static inline void
+set_provider_status(struct auth_client *auth, uint32_t provider, provider_status_t status)
+{
+ auth->data[provider].status = status;
+}
+
+/* Set the provider as running
+ * If you're doing asynchronous work call this */
+static inline void
+set_provider_running(struct auth_client *auth, uint32_t provider)
+{
+ auth->providers_active++;
+ set_provider_status(auth, provider, PROVIDER_STATUS_RUNNING);
+}
+
+/* Provider is no longer operating on this auth client
+ * You should use provider_done and not this */
+static inline void
+set_provider_done(struct auth_client *auth, uint32_t provider)
+{
+ set_provider_status(auth, provider, PROVIDER_STATUS_DONE);
+ auth->providers_active--;