Rename fr_print_string to fr_prints
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 7 Dec 2014 22:37:12 +0000 (17:37 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 8 Dec 2014 19:35:46 +0000 (14:35 -0500)
src/include/libradius.h
src/lib/dict.c
src/lib/print.c
src/main/auth.c
src/main/collectd.c
src/main/radwho.c
src/main/tmpl.c
src/main/xlat.c
src/modules/rlm_rest/rest.c

index 8359a37..a3a0e40 100644 (file)
@@ -425,9 +425,8 @@ int         fr_check_lib_magic(uint64_t magic);
  */
 int            fr_utf8_char(uint8_t const *str);
 char const             *fr_utf8_strchr(int *chr_len, char const *str, char const *chr);
-size_t         fr_print_string(char const *in, ssize_t inlen,
-                               char *out, size_t outlen, char quote);
-size_t         fr_print_string_len(char const *in, ssize_t inlen, char quote);
+size_t         fr_prints(char const *in, ssize_t inlen, char *out, size_t outlen, char quote);
+size_t         fr_prints_len(char const *in, ssize_t inlen, char quote);
 char           *fr_aprints(TALLOC_CTX *ctx, char const *in, ssize_t inlen, char quote);
 
 #define                is_truncated(_ret, _max) ((_ret) >= (_max))
index d021837..40bf1e3 100644 (file)
@@ -625,7 +625,7 @@ int dict_valid_name(char const *name)
                if (!dict_attr_allowed_chars[*p]) {
                        char buff[5];
 
-                       fr_print_string((char const *)p, 1, buff, sizeof(buff), '\'');
+                       fr_prints((char const *)p, 1, buff, sizeof(buff), '\'');
                        fr_strerror_printf("Invalid character '%s' in attribute", buff);
 
                        return -(p - (uint8_t const *)name);
index 07d71a3..3819467 100644 (file)
@@ -165,7 +165,7 @@ char const *fr_utf8_strchr(int *chr_len, char const *str, char const *chr)
  * @param[in] quote the quotation character
  * @return the number of bytes written to the out buffer, or a number >= outlen if truncation has occurred.
  */
-size_t fr_print_string(char const *in, ssize_t inlen, char *out, size_t outlen, char quote)
+size_t fr_prints(char const *in, ssize_t inlen, char *out, size_t outlen, char quote)
 {
        uint8_t const   *p = (uint8_t const *) in;
        int             utf8 = 0;
@@ -173,7 +173,7 @@ size_t fr_print_string(char const *in, ssize_t inlen, char *out, size_t outlen,
 
        /*
         *      IF YOU MODIFY THIS FUNCTION, YOU MUST MAKE
-        *      EQUIVALENT MODIFICATIONS TO fr_print_string_len
+        *      EQUIVALENT MODIFICATIONS TO fr_prints_len
         */
 
        /* Can't '\0' terminate */
@@ -302,7 +302,7 @@ finish:
        return outlen - freespace;
 }
 
-/** Find the length of the buffer required to fully escape a string with fr_print_string
+/** Find the length of the buffer required to fully escape a string with fr_prints
  *
  * Were assuming here that's it's cheaper to figure out the length and do one
  * alloc than repeatedly expand the buffer when we find extra chars which need
@@ -313,7 +313,7 @@ finish:
  * @param[in] quote the quotation character.
  * @return the size of buffer required to hold the escaped string including the NULL byte.
  */
-size_t fr_print_string_len(char const *in, ssize_t inlen, char quote)
+size_t fr_prints_len(char const *in, ssize_t inlen, char quote)
 {
        uint8_t const   *p = (uint8_t const *) in;
        size_t          outlen = 1;     /* Need one byte for \0 */
@@ -424,15 +424,15 @@ char *fr_aprints(TALLOC_CTX *ctx, char const *in, ssize_t inlen, char quote)
        size_t len, ret;
        char *out;
 
-       len = fr_print_string_len(in, inlen, quote);
+       len = fr_prints_len(in, inlen, quote);
 
        out = talloc_array(ctx, char, len);
-       ret = fr_print_string(in, inlen, out, len, quote);
+       ret = fr_prints(in, inlen, out, len, quote);
        /*
         *      This is a fatal error, but fr_assert is the strongest
         *      assert we're allowed to use in library functions.
         */
-       if (!fr_assert(ret == len)) {
+       if (!fr_assert(ret == (len - 1))) {
                talloc_free(out);
                return NULL;
        }
@@ -482,7 +482,7 @@ size_t vp_data_prints_value(char *out, size_t outlen,
                        *out++ = quote;
                        freespace--;
 
-                       len = fr_print_string(data->strvalue, inlen, out, freespace, quote);
+                       len = fr_prints(data->strvalue, inlen, out, freespace, quote);
                        /* always terminate the quoted string with another quote */
                        if (len >= (freespace - 1)) {
                                out[outlen - 2] = (char) quote;
@@ -499,7 +499,7 @@ size_t vp_data_prints_value(char *out, size_t outlen,
                        return len + 2;
                }
 
-               return fr_print_string(data->strvalue, inlen, out, outlen, quote);
+               return fr_prints(data->strvalue, inlen, out, outlen, quote);
 
        case PW_TYPE_INTEGER:
                i = data->integer;
@@ -710,12 +710,12 @@ char *vp_data_aprints_value(TALLOC_CTX *ctx,
                }
 
                /* Gets us the size of the buffer we need to alloc */
-               len = fr_print_string_len(data->strvalue, inlen, quote);
+               len = fr_prints_len(data->strvalue, inlen, quote);
                p = talloc_array(ctx, char, len);
                if (!p) return NULL;
 
-               ret = fr_print_string(data->strvalue, inlen, p, len, quote);
-               if (!fr_assert(ret == len)) {
+               ret = fr_prints(data->strvalue, inlen, p, len, quote);
+               if (!fr_assert(ret == (len - 1))) {
                        talloc_free(p);
                        return NULL;
                }
index 37c68d3..f3c3f5a 100644 (file)
@@ -101,9 +101,7 @@ static int rad_authlog(char const *msg, REQUEST *request, int goodpass)
        if (username == NULL) {
                strcpy(clean_username, "<no User-Name attribute>");
        } else {
-               fr_print_string(username->vp_strvalue,
-                               username->vp_length,
-                               clean_username, sizeof(clean_username), '\0');
+               fr_prints(username->vp_strvalue, username->vp_length, clean_username, sizeof(clean_username), '\0');
        }
 
        /*
@@ -125,9 +123,8 @@ static int rad_authlog(char const *msg, REQUEST *request, int goodpass)
                } else if (pairfind(request->packet->vps, PW_CHAP_PASSWORD, 0, TAG_ANY)) {
                        strcpy(clean_password, "<CHAP-Password>");
                } else {
-                       fr_print_string(request->password->vp_strvalue,
-                                        request->password->vp_length,
-                                       clean_password, sizeof(clean_password), '\0');
+                       fr_prints(request->password->vp_strvalue, request->password->vp_length,
+                                 clean_password, sizeof(clean_password), '\0');
                }
        }
 
index 9a9c5f8..ee1db96 100644 (file)
@@ -191,8 +191,8 @@ static rs_stats_tmpl_t *rs_stats_collectd_init(TALLOC_CTX *ctx, rs_t *conf,
        /*
         *      Plugin is ASCII only and no '/'
         */
-       fr_print_string(conf->stats.prefix, strlen(conf->stats.prefix),
-                       value->identifier.plugin, sizeof(value->identifier.plugin), '\0');
+       fr_prints(conf->stats.prefix, strlen(conf->stats.prefix),
+                 value->identifier.plugin, sizeof(value->identifier.plugin), '\0');
        for (p = value->identifier.plugin; *p; ++p) {
                if ((*p == '-') || (*p == '/'))*p = '_';
        }
@@ -200,8 +200,8 @@ static rs_stats_tmpl_t *rs_stats_collectd_init(TALLOC_CTX *ctx, rs_t *conf,
        /*
         *      Plugin instance is ASCII only (assuming printable only) and no '/'
         */
-       fr_print_string(plugin_instance, strlen(plugin_instance),
-                       value->identifier.plugin_instance, sizeof(value->identifier.plugin_instance), '\0');
+       fr_prints(plugin_instance, strlen(plugin_instance), value->identifier.plugin_instance,
+                 sizeof(value->identifier.plugin_instance), '\0');
        for (p = value->identifier.plugin_instance; *p; ++p) {
                if ((*p == '-') || (*p == '/')) *p = '_';
        }
@@ -209,14 +209,14 @@ static rs_stats_tmpl_t *rs_stats_collectd_init(TALLOC_CTX *ctx, rs_t *conf,
        /*
         *      Type is ASCII only (assuming printable only) and no '/' or '-'
         */
-       fr_print_string(type, strlen(type),
-                       value->identifier.type, sizeof(value->identifier.type), '\0');
+       fr_prints(type, strlen(type), value->identifier.type,
+                 sizeof(value->identifier.type), '\0');
        for (p = value->identifier.type; *p; ++p) {
                if ((*p == '-') || (*p == '/')) *p = '_';
        }
 
-       fr_print_string(type_instance, strlen(type_instance),
-                       value->identifier.type_instance, sizeof(value->identifier.type_instance), '\0');
+       fr_prints(type_instance, strlen(type_instance), value->identifier.type_instance,
+                 sizeof(value->identifier.type_instance), '\0');
        for (p = value->identifier.type_instance; *p; ++p) {
                if ((*p == '-') || (*p == '/')) *p = '_';
        }
index 665a558..94ee1e5 100644 (file)
@@ -429,10 +429,10 @@ int main(int argc, char **argv)
                        memcpy(nasname, rt.login, sizeof(rt.login));
                        nasname[sizeof(rt.login)] = '\0';
 
-                       fr_print_string(nasname, -1, buffer, sizeof(buffer), '"');
+                       fr_prints(nasname, -1, buffer, sizeof(buffer), '"');
                        printf("User-Name = \"%s\"\n", buffer);
 
-                       fr_print_string(session_id, -1, buffer, sizeof(buffer), '"');
+                       fr_prints(session_id, -1, buffer, sizeof(buffer), '"');
                        printf("Acct-Session-Id = \"%s\"\n", buffer);
 
                        if (zap) printf("Acct-Status-Type = Stop\n");
@@ -476,7 +476,7 @@ int main(int argc, char **argv)
                                       sizeof(rt.caller_id));
                                nasname[sizeof(rt.caller_id)] = '\0';
 
-                               fr_print_string(nasname, -1, buffer, sizeof(buffer), '"');
+                               fr_prints(nasname, -1, buffer, sizeof(buffer), '"');
                                printf("Calling-Station-Id = \"%s\"\n", buffer);
                        }
 
index d7326d6..4d81512 100644 (file)
@@ -1179,7 +1179,7 @@ size_t tmpl_prints(char *buffer, size_t bufsize, value_pair_tmpl_t const *vpt, D
        /*
         *      Print it with appropriate escaping
         */
-       len = fr_print_string(vpt->name, -1, q, bufsize - 3, c);
+       len = fr_prints(vpt->name, -1, q, bufsize - 3, c);
 
        q += len;
        *(q++) = c;
index 17b01bf..8f03c44 100644 (file)
@@ -490,7 +490,7 @@ static ssize_t xlat_string(UNUSED void *instance, REQUEST *request,
 
        switch (vp->da->type) {
        case PW_TYPE_OCTETS:
-               len = fr_print_string((char const *) p, vp->vp_length, out, outlen, '"');
+               len = fr_prints((char const *) p, vp->vp_length, out, outlen, '"');
                break;
 
        case PW_TYPE_STRING:
@@ -498,7 +498,7 @@ static ssize_t xlat_string(UNUSED void *instance, REQUEST *request,
                break;
 
        default:
-               len = fr_print_string((char const *) p, ret, out, outlen, '\0');
+               len = fr_prints((char const *) p, ret, out, outlen, '\0');
                break;
        }
 
@@ -2074,7 +2074,7 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
                 *
                 *      The OUTPUT of xlat is a printable string.  The INPUT might not be...
                 *
-                *      This is really the reverse of fr_print_string().
+                *      This is really the reverse of fr_prints().
                 */
                if (cf_new_escape && *child) {
                        ssize_t slen;
index 484100e..4e13d68 100644 (file)
@@ -1693,7 +1693,7 @@ malformed:
        {
                char escaped[1024];
 
-               fr_print_string((char *) in, t, escaped, sizeof(escaped), '\0');
+               fr_prints((char *) in, t, escaped, sizeof(escaped), '\0');
 
                REDEBUG("Received %zu bytes of response data: %s", t, escaped);
                ctx->code = -1;