More formatting fixes in rlm_perl
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 21 Apr 2015 13:55:59 +0000 (14:55 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 21 Apr 2015 14:42:47 +0000 (15:42 +0100)
src/modules/rlm_perl/rlm_perl.c

index 181e510..9e845c3 100644 (file)
@@ -29,7 +29,7 @@ RCSID("$Id$")
 #include <freeradius-devel/rad_assert.h>
 
 #ifdef INADDR_ANY
-#undef INADDR_ANY
+#  undef INADDR_ANY
 #endif
 #include <EXTERN.h>
 #include <perl.h>
@@ -74,7 +74,7 @@ typedef struct rlm_perl_t {
        char const      *xlat_name;
        char const      *perl_flags;
        PerlInterpreter *perl;
-       bool             perl_parsed;
+       bool            perl_parsed;
        pthread_key_t   *thread_key;
 
 #ifdef USE_ITHREADS
@@ -126,8 +126,8 @@ static const CONF_PARSER module_config[] = {
 EXTERN_C void boot_DynaLoader(pTHX_ CV* cv);
 
 #ifdef USE_ITHREADS
-#define dl_librefs "DynaLoader::dl_librefs"
-#define dl_modules "DynaLoader::dl_modules"
+#  define dl_librefs "DynaLoader::dl_librefs"
+#  define dl_modules "DynaLoader::dl_modules"
 static void rlm_perl_clear_handles(pTHX)
 {
        AV *librefs = get_av(dl_librefs, false);
@@ -151,20 +151,16 @@ static void **rlm_perl_get_handles(pTHX)
 
        handles = (void **)rad_malloc(sizeof(void *) * (AvFILL(librefs)+2));
 
-       for (i=0; i<=AvFILL(librefs); i++) {
+       for (i = 0; i <= AvFILL(librefs); i++) {
                void *handle;
                SV *handle_sv = *av_fetch(librefs, i, false);
-
-               if(!handle_sv) {
-                       ERROR("Could not fetch $%s[%d]!\n",
-                              dl_librefs, (int)i);
+               if (!handle_sv) {
+                       ERROR("Could not fetch $%s[%d]!", dl_librefs, (int)i);
                        continue;
                }
                handle = (void *)SvIV(handle_sv);
 
-               if (handle) {
-                       handles[i] = handle;
-               }
+               if (handle) handles[i] = handle;
        }
 
        av_clear(modules);
@@ -183,8 +179,8 @@ static void rlm_perl_close_handles(void **handles)
                return;
        }
 
-       for (i=0; handles[i]; i++) {
-               DEBUG("close %p\n", handles[i]);
+       for (i = 0; handles[i]; i++) {
+               DEBUG("Close %p", handles[i]);
                dlclose(handles[i]);
        }
 
@@ -210,7 +206,7 @@ static void rlm_perl_destruct(PerlInterpreter *perl)
         * FIXME: This shouldn't happen
         *
         */
-       while (PL_scopestack_ix > 1 ){
+       while (PL_scopestack_ix > 1{
                LEAVE;
        }
 
@@ -253,9 +249,9 @@ static PerlInterpreter *rlm_perl_clone(PerlInterpreter *perl, pthread_key_t *key
        {
                dTHXa(interp);
        }
-#if PERL_REVISION >= 5 && PERL_VERSION <8
+#  if PERL_REVISION >= 5 && PERL_VERSION <8
        call_pv("CLONE",0);
-#endif
+#  endif
        ptr_table_free(PL_ptr_table);
        PL_ptr_table = NULL;
 
@@ -275,9 +271,9 @@ static PerlInterpreter *rlm_perl_clone(PerlInterpreter *perl, pthread_key_t *key
 #endif
 
 /*
- * This is wrapper for radlog
- * Now users can call radiusd::radlog(level,msg) wich is the same
- * calling radlog from C code.
+ *     This is wrapper for radlog
+ *     Now users can call radiusd::radlog(level,msg) wich is the same
+ *     calling radlog from C code.
  */
 static XS(XS_radiusd_radlog)
 {
@@ -311,7 +307,7 @@ static void xs_init(pTHX)
 }
 
 /*
- * The xlat function
+ *     The xlat function
  */
 static ssize_t perl_xlat(void *instance, REQUEST *request, char const *fmt, char *out, size_t freespace)
 {
@@ -480,7 +476,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
        char const      **embed_c;      /* Stupid Perl and lack of const consistency */
        char            **embed;
        char            **envp = NULL;
-       char const      xlat_name;
+       char const      *xlat_name;
        int             exitstatus = 0, argc=0;
 
        CONF_SECTION *cs;
@@ -537,11 +533,8 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
 #endif
 
        xlat_name = cf_section_name2(conf);
-       if (!xlat_name)
-               xlat_name = cf_section_name1(conf);
-       if (xlat_name) {
-               xlat_register(xlat_name, perl_xlat, NULL, inst);
-       }
+       if (!xlat_name) xlat_name = cf_section_name1(conf);
+       if (xlat_name) xlat_register(xlat_name, perl_xlat, NULL, inst);
 
        exitstatus = perl_parse(inst->perl, xs_init, argc, embed, NULL);
 
@@ -838,9 +831,8 @@ static int do_perl(void *instance, REQUEST *request, char const *function_name)
                SPAGAIN;
 
                if (SvTRUE(ERRSV)) {
-                       ERROR("rlm_perl: perl_embed:: module = %s , func = %s exit status= %s\n",
-                              inst->module,
-                              function_name, SvPV(ERRSV,n_a));
+                       RDEBUG("perl_embed:: module = %s , func = %s exit status= %s\n",
+                              inst->module, function_name, SvPV(ERRSV,n_a));
                        (void)POPs;
                }
 
@@ -940,7 +932,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_accounting(void *instance, REQUEST *requ
        if ((pair = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE, 0, TAG_ANY)) != NULL) {
                acctstatustype = pair->vp_integer;
        } else {
-               ERROR("Invalid Accounting Packet");
+               RDEBUG("Invalid Accounting Packet");
                return RLM_MODULE_INVALID;
        }
 
@@ -979,9 +971,7 @@ static int mod_detach(void *instance)
        rlm_perl_t      *inst = (rlm_perl_t *) instance;
        int             exitstatus = 0, count = 0;
 
-       if (inst->rad_perlconf_hv != NULL) {
-               hv_undef(inst->rad_perlconf_hv);
-       }
+       if (inst->rad_perlconf_hv != NULL) hv_undef(inst->rad_perlconf_hv);
 
        if (inst->perl_parsed && inst->func_detach) {
                dTHXa(inst->perl);
@@ -1044,11 +1034,11 @@ module_t rlm_perl = {
                mod_authenticate,       /* authenticate */
                mod_authorize,          /* authorize */
                mod_preacct,            /* preacct */
-               mod_accounting, /* accounting */
+               mod_accounting,         /* accounting */
                mod_checksimul,         /* check simul */
 #ifdef WITH_PROXY
                mod_pre_proxy,          /* pre-proxy */
-               mod_post_proxy, /* post-proxy */
+               mod_post_proxy,         /* post-proxy */
 #else
                NULL, NULL,
 #endif