本文整理汇总了C++中rad_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ rad_malloc函数的具体用法?C++ rad_malloc怎么用?C++ rad_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rad_malloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sql_fetch_row
/*************************************************************************
*
* Function: sql_fetch_row
*
* Purpose: database specific fetch_row. Returns a SQL_ROW struct
* with all the data for the query in 'sqlsocket->row'. Returns
* 0 on success, -1 on failure, SQL_DOWN if 'database is down'
*
*************************************************************************/
static int sql_fetch_row(SQLSOCK * sqlsocket, SQL_CONFIG *config)
{
int c, i;
SQLINTEGER len, slen;
SQL_ROW retval;
rlm_sql_db2_sock *sock;
sock = sqlsocket->conn;
c = sql_num_fields(sqlsocket, config);
retval = (SQL_ROW)rad_malloc(c*sizeof(char*)+1);
/* advance cursor */
if(SQLFetch(sock->stmt) == SQL_NO_DATA_FOUND) {
sqlsocket->row = NULL;
return 0;
}
for(i = 0; i < c; i++) {
/* get column length */
SQLColAttribute(sock->stmt,
i+1, SQL_DESC_DISPLAY_SIZE,
NULL, 0, NULL, &len);
retval[i] = (char*)rad_malloc(len+1);
/* get the actual column */
SQLGetData(sock->stmt,
i+1, SQL_C_CHAR, retval[i], len+1, &slen);
if(slen == SQL_NULL_DATA)
retval[i][0] = '\0';
}
sqlsocket->row = retval;
return 0;
}
开发者ID:TheMysteriousX,项目名称:freeradius-abfab,代码行数:42,代码来源:sql_db2.c
示例2: sql_select_query
/*************************************************************************
*
* Function: sql_select_query
*
* Purpose: Issue a select query to the database
*
*************************************************************************/
static int sql_select_query(rlm_sql_handle_t *handle, rlm_sql_config_t *config, char *querystr) {
rlm_sql_unixodbc_conn_t *conn = handle->conn;
SQLINTEGER column;
SQLLEN len;
int numfields;
int state;
/* Only state = 0 means success */
if ((state = sql_query(handle, config, querystr))) {
return state;
}
numfields=sql_num_fields(handle, config);
if (numfields < 0) {
return -1;
}
/* Reserving memory for result */
conn->row = (char **) rad_malloc((numfields+1)*sizeof(char *));
conn->row[numfields] = NULL;
for(column = 1; column <= numfields; column++) {
SQLColAttributes(conn->statement,((SQLUSMALLINT) column),SQL_COLUMN_LENGTH,NULL,0,NULL,&len);
conn->row[column-1] = (char*)rad_malloc((int)++len);
SQLBindCol(conn->statement, column, SQL_C_CHAR, (SQLCHAR *)conn->row[column-1], len, NULL);
}
return 0;
}
开发者ID:Gejove,项目名称:freeradius-server,代码行数:35,代码来源:rlm_sql_unixodbc.c
示例3: sql_fetch_row
/*************************************************************************
*
* Function: sql_fetch_row
*
* Purpose: database specific fetch_row. Returns a rlm_sql_row_t struct
* with all the data for the query in 'handle->row'. Returns
* 0 on success, -1 on failure, RLM_SQL_RECONNECT if 'database is down'.
*
*************************************************************************/
static sql_rcode_t sql_fetch_row(rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config) {
int records, i, len;
rlm_sql_postgres_conn_t *conn = handle->conn;
handle->row = NULL;
if (conn->cur_row >= PQntuples(conn->result))
return 0;
free_result_row(conn);
records = PQnfields(conn->result);
conn->num_fields = records;
if ((PQntuples(conn->result) > 0) && (records > 0)) {
conn->row = (char **)rad_malloc((records+1)*sizeof(char *));
memset(conn->row, '\0', (records+1)*sizeof(char *));
for (i = 0; i < records; i++) {
len = PQgetlength(conn->result, conn->cur_row, i);
conn->row[i] = (char *)rad_malloc(len+1);
memset(conn->row[i], '\0', len+1);
strlcpy(conn->row[i], PQgetvalue(conn->result, conn->cur_row,i),len + 1);
}
conn->cur_row++;
handle->row = conn->row;
}
return 0;
}
开发者ID:Distrotech,项目名称:freeradius-server,代码行数:40,代码来源:rlm_sql_postgresql.c
示例4: krb5_instantiate
static int krb5_instantiate(CONF_SECTION *conf, void **instance)
{
int ret;
rlm_krb5_t *data;
krb5_context *context;
data = rad_malloc(sizeof(*data));
memset(data, 0, sizeof(*data));
if (cf_section_parse(conf, data, module_config) < 0) {
free(data);
return -1;
}
context = data->context = rad_malloc(sizeof(*context));
ret = krb5_init_context(context);
if (ret) {
radlog(L_AUTH, "rlm_krb5: krb5_init failed: %s",
error_message(ret));
free(data);
return -1;
} else {
radlog(L_AUTH, "rlm_krb5: krb5_init ok");
}
*instance = data;
return 0;
}
开发者ID:rssh,项目名称:freeradius-server,代码行数:32,代码来源:rlm_krb5.c
示例5: redisn_get_grouplist
static int redisn_get_grouplist (REDIS_INST *inst, REDISSOCK *redis_socket, REQUEST *request, REDISN_GROUPLIST **group_list)
{
char querystr[MAX_QUERY_LEN];
int num_groups = 0;
REDIS_ROW row;
REDISN_GROUPLIST *group_list_tmp;
/* NOTE: redisn_set_user should have been run before calling this function */
group_list_tmp = *group_list = NULL;
if (!inst->groupmemb_query ||
(inst->groupmemb_query[0] == 0))
return 0;
if (!radius_xlat(querystr, sizeof(querystr), inst->groupmemb_query, request, redisn_escape_func, inst)) {
radlog_request(L_ERR, 0, request, "xlat \"%s\" failed.",
inst->groupmemb_query);
return -1;
}
if (rlm_redisn_query(inst, redis_socket, querystr) < 0) {
radlog_request(L_ERR, 0, request,
"database query error, %s",
querystr);
return -1;
}
while (rlm_redisn_fetch_row(inst, redis_socket) == 0) {
row = redis_socket->row;
if (row == NULL)
break;
if (row[0] == NULL){
RDEBUG("row[0] returned NULL");
(inst->redisn_finish_query)(inst, redis_socket);
redisn_grouplist_free(group_list);
return -1;
}
if (*group_list == NULL) {
*group_list = rad_malloc(sizeof(REDISN_GROUPLIST));
group_list_tmp = *group_list;
} else {
rad_assert(group_list_tmp != NULL);
group_list_tmp->next = rad_malloc(sizeof(REDISN_GROUPLIST));
group_list_tmp = group_list_tmp->next;
}
group_list_tmp->next = NULL;
DEBUG("redisn: redisn_get_grouplist: got groupname: %s\n",row[0]);
strlcpy(group_list_tmp->groupname, row[0], MAX_STRING_LEN);
}
(inst->redisn_finish_query)(inst, redis_socket);
return num_groups;
}
开发者ID:mguesdon,项目名称:freeradius-server,代码行数:54,代码来源:rlm_redisn.c
示例6: sql_get_grouplist
static int sql_get_grouplist (SQL_INST *inst, SQLSOCK *sqlsocket, REQUEST *request, SQL_GROUPLIST **group_list)
{
char querystr[MAX_QUERY_LEN];
int num_groups = 0;
SQL_ROW row;
SQL_GROUPLIST *group_list_tmp;
/* NOTE: sql_set_user should have been run before calling this function */
group_list_tmp = *group_list = NULL;
if (!inst->config->groupmemb_query ||
(inst->config->groupmemb_query[0] == 0))
return 0;
if (!radius_xlat(querystr, sizeof(querystr), inst->config->groupmemb_query, request, sql_escape_func)) {
radlog_request(L_ERR, 0, request, "xlat \"%s\" failed.",
inst->config->groupmemb_query);
return -1;
}
if (rlm_sql_select_query(sqlsocket, inst, querystr) < 0) {
radlog_request(L_ERR, 0, request,
"database query error, %s: %s",
querystr,
(inst->module->sql_error)(sqlsocket,inst->config));
return -1;
}
while (rlm_sql_fetch_row(sqlsocket, inst) == 0) {
row = sqlsocket->row;
if (row == NULL)
break;
if (row[0] == NULL){
RDEBUG("row[0] returned NULL");
(inst->module->sql_finish_select_query)(sqlsocket, inst->config);
sql_grouplist_free(group_list);
return -1;
}
if (*group_list == NULL) {
*group_list = rad_malloc(sizeof(SQL_GROUPLIST));
group_list_tmp = *group_list;
} else {
rad_assert(group_list_tmp != NULL);
group_list_tmp->next = rad_malloc(sizeof(SQL_GROUPLIST));
group_list_tmp = group_list_tmp->next;
}
group_list_tmp->next = NULL;
strlcpy(group_list_tmp->groupname, row[0], MAX_STRING_LEN);
}
(inst->module->sql_finish_select_query)(sqlsocket, inst->config);
return num_groups;
}
开发者ID:gprocopciuc,项目名称:freeradius-server,代码行数:54,代码来源:rlm_sql.c
示例7: sql_get_grouplist
static int sql_get_grouplist (rlm_sql_t *inst, rlm_sql_handle_t *handle, REQUEST *request, rlm_sql_grouplist_t **group_list)
{
char querystr[MAX_QUERY_LEN];
int num_groups = 0;
rlm_sql_row_t row;
rlm_sql_grouplist_t *group_list_tmp;
/* NOTE: sql_set_user should have been run before calling this function */
group_list_tmp = *group_list = NULL;
if (!inst->config->groupmemb_query ||
(inst->config->groupmemb_query[0] == 0))
return 0;
if (!radius_xlat(querystr, sizeof(querystr), inst->config->groupmemb_query, request, sql_escape_func, inst)) {
radlog_request(L_ERR, 0, request, "xlat \"%s\" failed.",
inst->config->groupmemb_query);
return -1;
}
if (rlm_sql_select_query(&handle, inst, querystr) < 0) {
return -1;
}
while (rlm_sql_fetch_row(&handle, inst) == 0) {
row = handle->row;
if (row == NULL)
break;
if (row[0] == NULL){
RDEBUG("row[0] returned NULL");
(inst->module->sql_finish_select_query)(handle, inst->config);
sql_grouplist_free(group_list);
return -1;
}
if (*group_list == NULL) {
*group_list = rad_malloc(sizeof(rlm_sql_grouplist_t));
group_list_tmp = *group_list;
} else {
rad_assert(group_list_tmp != NULL);
group_list_tmp->next = rad_malloc(sizeof(rlm_sql_grouplist_t));
group_list_tmp = group_list_tmp->next;
}
group_list_tmp->next = NULL;
strlcpy(group_list_tmp->groupname, row[0], MAX_STRING_LEN);
}
(inst->module->sql_finish_select_query)(handle, inst->config);
return num_groups;
}
开发者ID:Gejove,项目名称:freeradius-server,代码行数:50,代码来源:rlm_sql.c
示例8: lookup_by_index
/*
* Create a new sublist.
*/
static indexed_modcallable *new_sublist(rbtree_t *components, int comp, int idx)
{
indexed_modcallable *c;
c = lookup_by_index(components, comp, idx);
/* It is an error to try to create a sublist that already
* exists. It would almost certainly be caused by accidental
* duplication in the config file.
*
* index 0 is the exception, because it is used when we want
* to collect _all_ listed modules under a single index by
* default, which is currently the case in all components
* except authenticate. */
if (c) {
if (idx == 0) {
return c;
}
return NULL;
}
c = rad_malloc(sizeof(*c));
c->modulelist = NULL;
c->comp = comp;
c->idx = idx;
if (!rbtree_insert(components, c)) {
free(c);
return NULL;
}
return c;
}
开发者ID:candlerb,项目名称:freeradius-server,代码行数:36,代码来源:modules.c
示例9: realm_instantiate
static int realm_instantiate(CONF_SECTION *conf, void **instance)
{
struct realm_config_t *inst;
/* setup a storage area for instance data */
inst = rad_malloc(sizeof(*inst));
if (!inst) {
return -1;
}
memset(inst, 0, sizeof(*inst));
if(cf_section_parse(conf, inst, module_config) < 0) {
free(inst);
return -1;
}
if(strcasecmp(inst->formatstring, "suffix") == 0) {
inst->format = REALM_FORMAT_SUFFIX;
} else if(strcasecmp(inst->formatstring, "prefix") == 0) {
inst->format = REALM_FORMAT_PREFIX;
} else {
radlog(L_ERR, "Bad value \"%s\" for realm format value", inst->formatstring);
free(inst);
return -1;
}
if(strlen(inst->delim) != 1) {
radlog(L_ERR, "Bad value \"%s\" for realm delimiter value", inst->delim);
free(inst);
return -1;
}
*instance = inst;
return 0;
}
开发者ID:Antti,项目名称:freeradius-server,代码行数:35,代码来源:rlm_realm.c
示例10: rad_malloc
/*
* Create a new REQUEST data structure.
*/
REQUEST *request_alloc(void)
{
REQUEST *request;
request = rad_malloc(sizeof(REQUEST));
memset(request, 0, sizeof(REQUEST));
#ifndef NDEBUG
request->magic = REQUEST_MAGIC;
#endif
#ifdef WITH_PROXY
request->proxy = NULL;
#endif
request->reply = NULL;
#ifdef WITH_PROXY
request->proxy_reply = NULL;
#endif
request->config_items = NULL;
request->username = NULL;
request->password = NULL;
request->timestamp = time(NULL);
request->options = RAD_REQUEST_OPTION_NONE;
request->module = "";
request->component = "<core>";
if (debug_flag) request->radlog = radlog_request;
return request;
}
开发者ID:dragon9k,项目名称:freeradius-server,代码行数:31,代码来源:util.c
示例11: smsotp_instantiate
/*
* Do any per-module initialization that is separate to each
* configured instance of the module. e.g. set up connections
* to external databases, read configuration files, set up
* dictionary entries, etc.
*
* If configuration information is given in the config section
* that must be referenced in later calls, store a handle to it
* in *instance otherwise put a null pointer there.
*/
static int smsotp_instantiate(CONF_SECTION *conf, void **instance)
{
rlm_smsotp_t *data;
/*
* Set up a storage area for instance data
*/
data = rad_malloc(sizeof(*data));
if (!data) {
return -1;
}
memset(data, 0, sizeof(*data));
/*
* If the configuration parameters can't be parsed, then
* fail.
*/
if (cf_section_parse(conf, data, module_config) < 0) {
free(data);
return -1;
}
*instance = data;
return 0;
}
开发者ID:binjetztauchimnetz,项目名称:freeradius-server,代码行数:36,代码来源:rlm_smsotp.c
示例12: sql_init_socket
/*************************************************************************
*
* Function: sql_create_socket
*
* Purpose: Establish connection to the db
*
*************************************************************************/
static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
{
LOGINREC *login;
rlm_sql_freetds_sock *freetds_sock;
if (!sqlsocket->conn) {
sqlsocket->conn = (rlm_sql_freetds_sock *)rad_malloc(sizeof(struct rlm_sql_freetds_sock));
if (!sqlsocket->conn) {
return -1;
}
}
if (dbinit() == FAIL) {
radlog(L_ERR, "rlm_sql_freetds: Unable to init FreeTDS");
return -1;
}
dbsetversion(DBVERSION_80);
dberrhandle(err_handler);
// Timeout so that FreeTDS doesn't wait for ever.
dbsetlogintime((unsigned long)config->query_timeout);
dbsettime((unsigned long)config->query_timeout);
freetds_sock = sqlsocket->conn;
memset(freetds_sock, 0, sizeof(*freetds_sock));
DEBUG("rlm_sql_freetds (%s): Starting connect to FreeTDS/MSSQL server", config->xlat_name);
if (!(login = dblogin())) {
radlog(L_ERR, "rlm_sql_freetds (%s): Unable to allocate login record", config->xlat_name);
return -1;
}
DBSETLUSER(login, config->sql_login);
DBSETLPWD(login, config->sql_password);
if ((freetds_sock->dbproc = dbopen(login, config->sql_server)) == FAIL) {
radlog(L_ERR, "rlm_sql_freetds (%s): Unable to connect to FreeTDS/MSSQL server %[email protected]%s",
config->xlat_name, config->sql_login, config->sql_server);
dbloginfree(login);
return -1;
}
dbloginfree(login);
if ((dbuse(freetds_sock->dbproc, config->sql_db)) == FAIL) {
radlog(L_ERR, "rlm_sql_freetds (%s): Unable to select database on FreeTDS/MSSQL server %[email protected]%s:%s",
config->xlat_name, config->sql_login, config->sql_server, config->sql_db);
return -1;
}
/* I know this may look strange, but it sets a pointer to
the freetds_sock struct so that it can be used within the
query_timeout_handler function to be able to timeout properly */
dbsetinterrupt(freetds_sock->dbproc, query_timeout_handler, query_timeout_handler);
dbsetuserdata(freetds_sock->dbproc, (BYTE *)freetds_sock);
return 0;
}
开发者ID:FabioPedretti,项目名称:freeradius-server,代码行数:67,代码来源:rlm_sql_freetds.c
示例13: dhcp_instantiate
/*
* Instantiate the module.
*/
static int dhcp_instantiate(CONF_SECTION *conf, void **instance)
{
rlm_dhcp_t *inst;
inst = rad_malloc(sizeof(*inst));
if (!inst) {
return -1;
}
memset(inst, 0, sizeof(*inst));
xlat_register("dhcp_options", dhcp_options_xlat, inst);
/*
* If the configuration parameters can't be parsed, then
* fail.
*/
if (cf_section_parse(conf, inst, module_config) < 0) {
free(inst);
return -1;
}
*instance = inst;
return 0;
}
开发者ID:FabioPedretti,项目名称:freeradius-server,代码行数:28,代码来源:rlm_dhcp.c
示例14: attr_req_out_to_string
static int attr_req_out_to_string(ATTR_REQ_OUT *input, char **output)
{
char buffer[STR_MAXLEN];
int i;
memset(buffer, 0, STR_MAXLEN);
sprintf(buffer, "%ld:%s:%i:", input->timestamp, input->servicedn, input->provided_attr_len);
for (i = 0; i < input->provided_attr_len; i++)
{
sprintf(buffer + strlen(buffer), "%s=%s:", input->provided_attr[i].attribute, input->provided_attr[i].value);
}
sprintf(buffer + strlen(buffer), "%i:", input->requested_attr_len);
for (i = 0; i < input->requested_attr_len; i++)
{
if (i == input->requested_attr_len - 1)
sprintf(buffer + strlen(buffer), "%s", input->requested_attr[i]);
else
sprintf(buffer + strlen(buffer), "%s:", input->requested_attr[i]);
}
*output = rad_malloc(strlen(buffer));
strcpy(*output, buffer);
return strlen(*output);
}
开发者ID:MoonshotNL,项目名称:moonshotnl_testing,代码行数:25,代码来源:idpmodule.c
示例15: rad_malloc
static AVP *get_avps_by_attributes(char **attributes, int length)
{
//This function is to be implemented for the IDPs auathentication backend
AVP *avp_list;
int i;
char *dummy_attribute = "DummyAttr";
char *dummy_value = "DummyVal";
avp_list = rad_malloc(sizeof(AVP) * length);
if (!avp_list)
{
return NULL;
}
for (i = 0; i < length; i++)
{
avp_list[i].attribute = strdup(dummy_attribute);
if (!avp_list[i].attribute)
return NULL;
avp_list[i].value = strdup(dummy_value);
if (!avp_list[i].value)
return NULL;
}
return avp_list;
}
开发者ID:MoonshotNL,项目名称:moonshotnl_testing,代码行数:27,代码来源:idpmodule.c
示例16: parse_print
/*
* print foo
* print "foo"
*/
static int parse_print(policy_lex_file_t *lexer, policy_item_t **tail)
{
policy_lex_t token;
char mystring[1024];
policy_print_t *this;
debug_tokens("[PRINT] ");
this = rad_malloc(sizeof(*this));
memset(this, 0, sizeof(*this));
this->item.type = POLICY_TYPE_PRINT;
this->item.lineno = lexer->lineno;
token = policy_lex_file(lexer, 0, mystring, sizeof(mystring));
if ((token != POLICY_LEX_BARE_WORD) &&
(token != POLICY_LEX_DOUBLE_QUOTED_STRING)) {
fprintf(stderr, "%s[%d]: Bad print command\n",
lexer->filename, lexer->lineno);
rlm_policy_free_item((policy_item_t *) this);
return 0;
}
this->rhs_type = token;
this->rhs = strdup(mystring);
*tail = (policy_item_t *) this;
return 1;
}
开发者ID:jacques,项目名称:freeradius-server,代码行数:34,代码来源:parse.c
示例17: sql_init_socket
/*************************************************************************
*
* Function: sql_create_socket
*
* Purpose: Establish connection to the db
*
*************************************************************************/
static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
{
SQLRETURN retval;
rlm_sql_db2_sock *sock;
/* allocate socket */
if (!sqlsocket->conn) {
sqlsocket->conn = (rlm_sql_db2_sock*)rad_malloc(sizeof(rlm_sql_db2_sock));
if (!sqlsocket->conn) {
return -1;
}
}
sock = sqlsocket->conn;
memset(sock, 0, sizeof(*sock));
/* allocate handles */
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &(sock->henv));
SQLAllocHandle(SQL_HANDLE_DBC, sock->henv, &(sock->hdbc));
/* connect to database */
retval = SQLConnect(sock->hdbc,
config->sql_server, SQL_NTS,
config->sql_login, SQL_NTS,
config->sql_password, SQL_NTS);
if(retval != SQL_SUCCESS) {
radlog(L_ERR, "could not connect to DB2 server %s\n", config->sql_server);
SQLDisconnect(sock->hdbc);
SQLFreeHandle(SQL_HANDLE_DBC, sock->hdbc);
SQLFreeHandle(SQL_HANDLE_ENV, sock->henv);
return -1;
}
return 0;
}
开发者ID:TheMysteriousX,项目名称:freeradius-abfab,代码行数:41,代码来源:sql_db2.c
示例18: wimax_instantiate
/*
* Do any per-module initialization that is separate to each
* configured instance of the module. e.g. set up connections
* to external databases, read configuration files, set up
* dictionary entries, etc.
*
* If configuration information is given in the config section
* that must be referenced in later calls, store a handle to it
* in *instance otherwise put a null pointer there.
*/
static int wimax_instantiate(CONF_SECTION *conf, void **instance)
{
rlm_wimax_t *inst;
/*
* Set up a storage area for instance data
*/
inst = rad_malloc(sizeof(*inst));
if (!inst) {
return -1;
}
memset(inst, 0, sizeof(*inst));
/*
* If the configuration parameters can't be parsed, then
* fail.
*/
if (cf_section_parse(conf, inst, module_config) < 0) {
wimax_detach(inst);
return -1;
}
*instance = inst;
return 0;
}
开发者ID:Antti,项目名称:freeradius-server,代码行数:36,代码来源:rlm_wimax.c
示例19: while
static indexed_modcallable *new_sublist(int comp, int idx)
{
indexed_modcallable **head = &components[comp];
indexed_modcallable *node = *head;
indexed_modcallable **last = head;
while (node) {
/* It is an error to try to create a sublist that already
* exists. It would almost certainly be caused by accidental
* duplication in the config file.
*
* index 0 is the exception, because it is used when we want
* to collect _all_ listed modules under a single index by
* default, which is currently the case in all components
* except authenticate. */
if (node->idx == idx) {
if (idx == 0)
return node;
else
return NULL;
}
last = &node->next;
node = node->next;
}
node = rad_malloc(sizeof *node);
node->next = NULL;
node->modulelist = NULL;
node->idx = idx;
*last = node;
return node;
}
开发者ID:kubuqi,项目名称:802.1x-supplicant,代码行数:32,代码来源:modules.c
示例20: sql_init_socket
/*************************************************************************
*
* Function: sql_create_socket
*
* Purpose: Establish connection to the db
*
*************************************************************************/
static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
{
int status;
rlm_sql_sqlite_sock *sqlite_sock;
char *filename;
char buffer[2048];
if (!sqlsocket->conn) {
sqlsocket->conn = (rlm_sql_sqlite_sock *)rad_malloc(sizeof(rlm_sql_sqlite_sock));
if (!sqlsocket->conn) {
return -1;
}
}
sqlite_sock = sqlsocket->conn;
memset(sqlite_sock, 0, sizeof(rlm_sql_sqlite_sock));
filename = config->sql_file;
if (!filename) {
snprintf(buffer, sizeof(buffer), "%s/sqlite_radius_client_database",
radius_dir);
filename = buffer;
}
radlog(L_INFO, "rlm_sql_sqlite: Opening sqlite database %s",
filename);
status = sqlite3_open(filename, &sqlite_sock->pDb);
radlog(L_INFO, "rlm_sql_sqlite: sqlite3_open() = %d\n", status);
return (status != SQLITE_OK) * -1;
}
开发者ID:iliyap,项目名称:freeradius-server,代码行数:36,代码来源:rlm_sql_sqlite.c
注:本文中的rad_malloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论