Massively cleaned up #include's, so they're in a consistent
[freeradius.git] / src / modules / rlm_sql_log / rlm_sql_log.c
index 8705845..4628dc0 100644 (file)
@@ -7,6 +7,7 @@
  *  Author:     Nicolas Baradakis <nicolas.baradakis@cegetel.net>
  *
  *  Copyright (C) 2005 Cegetel
+ *  Copyright 2006 The FreeRADIUS server project
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "autoconf.h"
+#include <freeradius-devel/ident.h>
+RCSID("$Id$")
+
+#include <freeradius-devel/radiusd.h>
+#include <freeradius-devel/modules.h>
 
 #include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <sys/stat.h>
 
-#include "libradius.h"
-#include "radiusd.h"
-#include "modules.h"
-#include "conffile.h"
-
-static const char rcsid[] = "$Id$";
-
 static int sql_log_instantiate(CONF_SECTION *conf, void **instance);
 static int sql_log_detach(void *instance);
 static int sql_log_accounting(void *instance, REQUEST *request);
@@ -230,7 +226,7 @@ static int sql_set_user(rlm_sql_log_t *inst, REQUEST *request, char *sqlusername
        pairdelete(&request->packet->vps, PW_SQL_USER_NAME);
 
        if (username != NULL) {
-               strNcpy(tmpuser, username, MAX_STRING_LEN);
+               strlcpy(tmpuser, username, MAX_STRING_LEN);
        } else if (inst->sql_user_name[0] != '\0') {
                radius_xlat(tmpuser, sizeof(tmpuser), inst->sql_user_name,
                            request, NULL);
@@ -239,7 +235,7 @@ static int sql_set_user(rlm_sql_log_t *inst, REQUEST *request, char *sqlusername
        }
 
        if (tmpuser[0] != '\0') {
-               strNcpy(sqlusername, tmpuser, sizeof(tmpuser));
+               strlcpy(sqlusername, tmpuser, sizeof(tmpuser));
                DEBUG2("rlm_sql_log (%s): sql_set_user escaped user --> '%s'",
                       inst->name, sqlusername);
                vp = pairmake("SQL-User-Name", sqlusername, 0);
@@ -428,10 +424,11 @@ static int sql_log_postauth(void *instance, REQUEST *request)
  *     is single-threaded.
  */
 module_t rlm_sql_log = {
+       RLM_MODULE_INIT,
        "sql_log",
        RLM_TYPE_THREAD_SAFE,           /* type */
-       NULL,                           /* initialization */
        sql_log_instantiate,            /* instantiation */
+       sql_log_detach,                 /* detach */
        {
                NULL,                   /* authentication */
                NULL,                   /* authorization */
@@ -442,6 +439,4 @@ module_t rlm_sql_log = {
                NULL,                   /* post-proxy */
                sql_log_postauth        /* post-auth */
        },
-       sql_log_detach,                 /* detach */
-       NULL,                           /* destroy */
 };