The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
rlm_sql_null.c
Go to the documentation of this file.
1 /*
2  * sql_null.c SQL Module
3  *
4  * Version: $Id: 48964db6eb017f519418e4fd6f5e316a3dcc5598 $
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  * @copyright 2012 Alan DeKok (aland@freeradius.org)
21  */
22 
23 RCSID("$Id: 48964db6eb017f519418e4fd6f5e316a3dcc5598 $")
24 
25 #include <freeradius-devel/server/base.h>
26 
27 #include "rlm_sql.h"
28 
29 
30 static const void *fake = "fake";
31 
34 {
35  memcpy(&handle->conn, &fake, sizeof(handle->conn));
36  return 0;
37 }
38 
39 static unlang_action_t sql_query(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
40 {
41  fr_sql_query_t *query_ctx = talloc_get_type_abort(uctx, fr_sql_query_t);
42  query_ctx->rcode = RLM_SQL_OK;
44 }
45 
47 {
48  return 0;
49 }
50 
51 static unlang_action_t sql_fetch_row(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
52 {
53  fr_sql_query_t *query_ctx = talloc_get_type_abort(uctx, fr_sql_query_t);
54  query_ctx->row = NULL;
55  query_ctx->rcode = RLM_SQL_NO_MORE_ROWS;
57 }
58 
60 {
61  return 0;
62 }
63 
64 /** Stub function for retrieving errors, should not be called
65  *
66  */
67 static size_t sql_error(UNUSED TALLOC_CTX *ctx, UNUSED sql_log_entry_t out[], UNUSED size_t outlen,
69 {
70  return 0;
71 }
72 
74 {
75  return 0;
76 }
77 
79 {
80  return 1;
81 }
82 
83 /* Exported to rlm_sql */
86  .common = {
87  .magic = MODULE_MAGIC_INIT,
88  .name = "sql_null"
89  },
90  .sql_socket_init = sql_socket_init,
91  .sql_query = sql_query,
92  .sql_select_query = sql_query,
93  .sql_num_rows = sql_num_rows,
94  .sql_fetch_row = sql_fetch_row,
95  .sql_free_result = sql_free_result,
96  .sql_error = sql_error,
97  .sql_finish_query = sql_finish_query,
98  .sql_finish_select_query = sql_finish_query,
99  .sql_affected_rows = sql_affected_rows
100 };
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition: action.h:35
#define RCSID(id)
Definition: build.h:446
#define UNUSED
Definition: build.h:313
static fr_time_delta_t timeout
Definition: dhcpclient.c:54
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static const conf_parser_t config[]
Definition: base.c:188
#define RETURN_MODULE_OK
Definition: rcode.h:57
rlm_rcode_t
Return codes indicating the result of the module call.
Definition: rcode.h:40
Prototypes and functions for the SQL module.
void * conn
Database specific connection handle.
Definition: rlm_sql.h:114
sql_rcode_t
Action to take at end of an SQL query.
Definition: rlm_sql.h:44
@ RLM_SQL_OK
Success.
Definition: rlm_sql.h:47
@ RLM_SQL_NO_MORE_ROWS
No more rows available.
Definition: rlm_sql.h:50
rlm_sql_row_t row
Row data from the last query.
Definition: rlm_sql.h:147
sql_rcode_t rcode
Result code.
Definition: rlm_sql.h:146
Definition: rlm_sql.h:61
static const void * fake
Definition: rlm_sql_null.c:30
static size_t sql_error(UNUSED TALLOC_CTX *ctx, UNUSED sql_log_entry_t out[], UNUSED size_t outlen, UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
Stub function for retrieving errors, should not be called.
Definition: rlm_sql_null.c:67
rlm_sql_driver_t rlm_sql_null
Definition: rlm_sql_null.c:85
static sql_rcode_t sql_socket_init(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config, UNUSED fr_time_delta_t timeout)
Definition: rlm_sql_null.c:32
static unlang_action_t sql_fetch_row(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
Definition: rlm_sql_null.c:51
static int sql_affected_rows(UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
Definition: rlm_sql_null.c:78
static int sql_num_rows(UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
Definition: rlm_sql_null.c:46
static sql_rcode_t sql_finish_query(UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
Definition: rlm_sql_null.c:73
static sql_rcode_t sql_free_result(UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
Definition: rlm_sql_null.c:59
static unlang_action_t sql_query(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
Definition: rlm_sql_null.c:39
module_t common
Common fields for all loadable modules.
Definition: rlm_sql.h:202
A time delta, a difference in time measured in nanoseconds.
Definition: time.h:80
static size_t char ** out
Definition: value.h:984