Rename map functions to be consistent with tmpl functions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 3 Oct 2014 00:30:46 +0000 (01:30 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 3 Oct 2014 00:30:46 +0000 (01:30 +0100)
src/include/map.h
src/main/map.c
src/main/modcall.c
src/modules/rlm_cache/rlm_cache.c
src/modules/rlm_ldap/attrmap.c

index f2737b1..f7baf63 100644 (file)
@@ -66,20 +66,20 @@ typedef struct value_pair_map {
 
 typedef int (*radius_map_getvalue_t)(VALUE_PAIR **out, REQUEST *request, value_pair_map_t const *map, void *ctx);
 
-value_pair_map_t *map_from_cp(TALLOC_CTX *ctx, CONF_PAIR *cp,
-                             request_refs_t dst_request_def, pair_lists_t dst_list_def,
-                             request_refs_t src_request_def, pair_lists_t src_list_def);
+value_pair_map_t *map_afrom_cp(TALLOC_CTX *ctx, CONF_PAIR *cp,
+                              request_refs_t dst_request_def, pair_lists_t dst_list_def,
+                              request_refs_t src_request_def, pair_lists_t src_list_def);
 
-value_pair_map_t *map_from_fields(TALLOC_CTX *ctx, char const *lhs, FR_TOKEN lhs_type,
-                                 FR_TOKEN op, char const *rhs, FR_TOKEN rhs_type,
-                                 request_refs_t dst_request_def, pair_lists_t dst_list_def,
-                                 request_refs_t src_request_def, pair_lists_t src_list_def);
+value_pair_map_t *map_afrom_fields(TALLOC_CTX *ctx, char const *lhs, FR_TOKEN lhs_type,
+                                  FR_TOKEN op, char const *rhs, FR_TOKEN rhs_type,
+                                  request_refs_t dst_request_def, pair_lists_t dst_list_def,
+                                  request_refs_t src_request_def, pair_lists_t src_list_def);
 
-int            map_from_cs(CONF_SECTION *cs, value_pair_map_t **head,
-                           pair_lists_t dst_list_def, pair_lists_t src_list_def,
-                           unsigned int max);
+int            map_afrom_cs(value_pair_map_t **out, CONF_SECTION *cs,
+                            pair_lists_t dst_list_def, pair_lists_t src_list_def,
+                            unsigned int max);
 
-int            map_from_vp_str(value_pair_map_t **out, REQUEST *request, char const *raw,
+int            map_afrom_vp_str(value_pair_map_t **out, REQUEST *request, char const *raw,
                                 request_refs_t dst_request_def, pair_lists_t dst_list_def,
                                 request_refs_t src_request_def, pair_lists_t src_list_def);
 
index 2c7aa61..cb562f8 100644 (file)
@@ -160,7 +160,7 @@ bool map_cast_from_hex(value_pair_map_t *map, FR_TOKEN rhs_type, char const *rhs
  *     in.
  * @return value_pair_map_t if successful or NULL on error.
  */
-value_pair_map_t *map_from_cp(TALLOC_CTX *ctx, CONF_PAIR *cp,
+value_pair_map_t *map_afrom_cp(TALLOC_CTX *ctx, CONF_PAIR *cp,
                              request_refs_t dst_request_def, pair_lists_t dst_list_def,
                              request_refs_t src_request_def, pair_lists_t src_list_def)
 {
@@ -411,7 +411,7 @@ error:
  * Uses 'name2' of section to set default request and lists.
  *
  * @param[in] cs the update section
- * @param[out] head Where to store the head of the map.
+ * @param[out] out Where to store the head of the map.
  * @param[in] dst_list_def The default destination list, usually dictated by
  *     the section the module is being called in.
  * @param[in] src_list_def The default source list, usually dictated by the
@@ -419,9 +419,8 @@ error:
  * @param[in] max number of mappings to process.
  * @return -1 on error, else 0.
  */
-int map_from_cs(CONF_SECTION *cs, value_pair_map_t **head,
-               pair_lists_t dst_list_def, pair_lists_t src_list_def,
-               unsigned int max)
+int map_afrom_cs(value_pair_map_t **out, CONF_SECTION *cs, pair_lists_t dst_list_def, pair_lists_t src_list_def,
+                unsigned int max)
 {
        char const *cs_list, *p;
 
@@ -434,8 +433,8 @@ int map_from_cs(CONF_SECTION *cs, value_pair_map_t **head,
        value_pair_map_t **tail, *map;
        TALLOC_CTX *ctx;
 
-       *head = NULL;
-       tail = head;
+       *out = NULL;
+       tail = out;
 
        if (!cs) return 0;
 
@@ -478,7 +477,7 @@ int map_from_cs(CONF_SECTION *cs, value_pair_map_t **head,
                }
 
                cp = cf_itemtopair(ci);
-               map = map_from_cp(ctx, cp, request_def, dst_list_def, REQUEST_CURRENT, src_list_def);
+               map = map_afrom_cp(ctx, cp, request_def, dst_list_def, REQUEST_CURRENT, src_list_def);
                if (!map) {
                        goto error;
                }
@@ -490,7 +489,7 @@ int map_from_cs(CONF_SECTION *cs, value_pair_map_t **head,
 
        return 0;
 error:
-       TALLOC_FREE(*head);
+       TALLOC_FREE(*out);
        return -1;
 }
 
@@ -520,12 +519,12 @@ error:
  *     in.
  * @return value_pair_map_t if successful or NULL on error.
  */
-value_pair_map_t *map_from_fields(TALLOC_CTX *ctx, char const *lhs, FR_TOKEN lhs_type,
-                                 FR_TOKEN op, char const *rhs, FR_TOKEN rhs_type,
-                                 request_refs_t dst_request_def,
-                                 pair_lists_t dst_list_def,
-                                 request_refs_t src_request_def,
-                                 pair_lists_t src_list_def)
+value_pair_map_t *map_afrom_fields(TALLOC_CTX *ctx, char const *lhs, FR_TOKEN lhs_type,
+                                  FR_TOKEN op, char const *rhs, FR_TOKEN rhs_type,
+                                  request_refs_t dst_request_def,
+                                  pair_lists_t dst_list_def,
+                                  request_refs_t src_request_def,
+                                  pair_lists_t src_list_def)
 {
        ssize_t slen;
        value_pair_map_t *map;
@@ -569,9 +568,9 @@ value_pair_map_t *map_from_fields(TALLOC_CTX *ctx, char const *lhs, FR_TOKEN lhs
  * @param src_list_def to use if attribute isn't qualified.
  * @return 0 on success, < 0 on error.
  */
-int map_from_vp_str(value_pair_map_t **out, REQUEST *request, char const *vp_str,
-                   request_refs_t dst_request_def, pair_lists_t dst_list_def,
-                   request_refs_t src_request_def, pair_lists_t src_list_def)
+int map_afrom_vp_str(value_pair_map_t **out, REQUEST *request, char const *vp_str,
+                    request_refs_t dst_request_def, pair_lists_t dst_list_def,
+                    request_refs_t src_request_def, pair_lists_t src_list_def)
 {
        char const *p = vp_str;
        FR_TOKEN quote;
@@ -604,8 +603,8 @@ int map_from_vp_str(value_pair_map_t **out, REQUEST *request, char const *vp_str
                return -1;
        }
 
-       map = map_from_fields(request, raw.l_opand, T_BARE_WORD, raw.op, raw.r_opand, raw.quote,
-                             dst_request_def, dst_list_def, src_request_def, src_list_def);
+       map = map_afrom_fields(request, raw.l_opand, T_BARE_WORD, raw.op, raw.r_opand, raw.quote,
+                              dst_request_def, dst_list_def, src_request_def, src_list_def);
        if (!map) {
                REDEBUG("Failed parsing attribute string: %s", fr_strerror());
                return -1;
index 88f9771..e986906 100644 (file)
@@ -1598,7 +1598,7 @@ static modcallable *do_compile_modupdate(modcallable *parent, UNUSED rlm_compone
        /*
         *      This looks at cs->name2 to determine which list to update
         */
-       rcode = map_from_cs(cs, &head, PAIR_LIST_REQUEST, PAIR_LIST_REQUEST, 128);
+       rcode = map_afrom_cs(&head, cs, PAIR_LIST_REQUEST, PAIR_LIST_REQUEST, 128);
        if (rcode < 0) return NULL; /* message already printed */
 
        if (!head) {
index 4c62e0f..8e27d90 100644 (file)
@@ -435,9 +435,8 @@ static int cache_verify(rlm_cache_t *inst, value_pair_map_t **head)
 {
        value_pair_map_t *map;
 
-       if (map_from_cs(cf_section_sub_find(inst->cs, "update"),
-                          head, PAIR_LIST_REQUEST,
-                          PAIR_LIST_REQUEST, MAX_ATTRMAP) < 0) {
+       if (map_afrom_cs(head, cf_section_sub_find(inst->cs, "update"),
+                        PAIR_LIST_REQUEST, PAIR_LIST_REQUEST, MAX_ATTRMAP) < 0) {
                return -1;
        }
 
index ddb4b00..62ad2d3 100644 (file)
@@ -58,9 +58,9 @@ static int rlm_ldap_map_getvalue(VALUE_PAIR **out, REQUEST *request, value_pair_
                        value_pair_map_t *attr = NULL;
 
                        RDEBUG3("Parsing valuepair string \"%s\"", self->values[i]->bv_val);
-                       if (map_from_vp_str(&attr, request, self->values[i]->bv_val,
-                                           map->lhs->tmpl_request, map->lhs->tmpl_list,
-                                           REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
+                       if (map_afrom_vp_str(&attr, request, self->values[i]->bv_val,
+                                            map->lhs->tmpl_request, map->lhs->tmpl_list,
+                                            REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
                                RWDEBUG("Failed parsing \"%s\" as valuepair, skipping...", self->values[i]->bv_val);
                                continue;
                        }
@@ -130,9 +130,9 @@ int rlm_ldap_map_verify(ldap_instance_t *inst, value_pair_map_t **head)
 {
        value_pair_map_t *map;
 
-       if (map_from_cs(cf_section_sub_find(inst->cs, "update"),
-                          head, PAIR_LIST_REPLY,
-                          PAIR_LIST_REQUEST, LDAP_MAX_ATTRMAP) < 0) {
+       if (map_afrom_cs(head, cf_section_sub_find(inst->cs, "update"),
+                        PAIR_LIST_REPLY,
+                        PAIR_LIST_REQUEST, LDAP_MAX_ATTRMAP) < 0) {
                return -1;
        }
        /*
@@ -401,9 +401,9 @@ void rlm_ldap_map_do(UNUSED const ldap_instance_t *inst, REQUEST *request, LDAP
                        value_pair_map_t *attr;
 
                        RDEBUG3("Parsing attribute string '%s'", values[i]);
-                       if (map_from_vp_str(&attr, request, values[i],
-                                           REQUEST_CURRENT, PAIR_LIST_REPLY,
-                                           REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
+                       if (map_afrom_vp_str(&attr, request, values[i],
+                                            REQUEST_CURRENT, PAIR_LIST_REPLY,
+                                            REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
                                RWDEBUG("Failed parsing '%s' value \"%s\" as valuepair, skipping...",
                                        inst->valuepair_attr, values[i]);
                                continue;