-/* Copy service info so we don't have to free it only sometimes. */
-static void
-copy_svc(struct service_info *to, const struct service_info *from)
-{
- to->display_name = from->display_name;
-#define copy(_field_) to->_field_ = getcpy(from->_field_)
- copy(name);
- copy(scope);
- copy(client_id);
- copy(client_secret);
- copy(auth_endpoint);
- copy(token_endpoint);
- copy(redirect_uri);
-#undef copy
-}
-
-/* Return profile component node name for a service parameter. */
-static char *
-node_name_for_svc(const char *base_name, const char *svc)
-{
- char *result = mh_xmalloc(sizeof "oauth-" - 1
- + strlen(svc)
- + 1 /* '-' */
- + strlen(base_name)
- + 1 /* '\0' */);
- sprintf(result, "oauth-%s-%s", svc, base_name);
- /* TODO: s/_/-/g ? */
- return result;
-}
-
-/* Update one service_info field if overridden in profile. */
-static void
-update_svc_field(char **field, const char *base_name, const char *svc)
-{
- char *name = node_name_for_svc(base_name, svc);
- const char *value = context_find(name);
- if (value != NULL) {
- free(*field);
- *field = getcpy(value);
- }
- free(name);
-}
-
-/* Update all service_info fields that are overridden in profile. */
-static boolean
-update_svc(struct service_info *svc, const char *svc_name, mh_oauth_ctx *ctx)
-{
-#define update(name) \
- update_svc_field(&svc->name, #name, svc_name); \
- if (svc->name == NULL) { \
- set_err_details(ctx, MH_OAUTH_BAD_PROFILE, #name " is missing"); \
- return FALSE; \
- }
- update(scope);
- update(client_id);
- update(client_secret);
- update(auth_endpoint);
- update(token_endpoint);
- update(redirect_uri);
-#undef update
-
- if (svc->name == NULL) {
- svc->name = getcpy(svc_name);
- }
-
- if (svc->display_name == NULL) {
- svc->display_name = svc->name;
- }
-
- return TRUE;
-}
-