本文整理汇总了C++中slapi_ch_free_string函数的典型用法代码示例。如果您正苦于以下问题:C++ slapi_ch_free_string函数的具体用法?C++ slapi_ch_free_string怎么用?C++ slapi_ch_free_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slapi_ch_free_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_db_version
/*
* this function reads the db/DBVERSION file and check
* 1) if the db version is supported, and
* 2) if the db version requires some migration operation
*
* return: 0: supported
* DBVERSION_NOT_SUPPORTED: not supported
*
* action: 0: nothing is needed
* DBVERSION_UPGRADE_3_4: db3->db4 uprev is needed
* DBVERSION_UPGRADE_4_4: db4->db4 uprev is needed
* DBVERSION_UPGRADE_4_5: db4->db uprev is needed
*/
int
check_db_version( struct ldbminfo *li, int *action )
{
int value = 0;
char *ldbmversion = NULL;
char *dataversion = NULL;
*action = 0;
dbversion_read(li, li->li_directory, &ldbmversion, &dataversion);
if (NULL == ldbmversion || '\0' == *ldbmversion) {
slapi_ch_free_string(&dataversion);
return 0;
}
value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION );
if ( !value )
{
LDAPDebug( LDAP_DEBUG_ANY,
"ERROR: Database version mismatch (expecting "
"'%s' but found '%s' in directory %s)\n",
LDBM_VERSION, ldbmversion, li->li_directory );
/*
* A non-zero return here will cause slapd to exit during startup.
*/
slapi_ch_free_string(&ldbmversion);
slapi_ch_free_string(&dataversion);
return DBVERSION_NOT_SUPPORTED;
}
if ( value & DBVERSION_UPGRADE_3_4 )
{
dblayer_set_recovery_required(li);
*action = DBVERSION_UPGRADE_3_4;
}
else if ( value & DBVERSION_UPGRADE_4_4 )
{
dblayer_set_recovery_required(li);
*action = DBVERSION_UPGRADE_4_4;
}
else if ( value & DBVERSION_UPGRADE_4_5 )
{
dblayer_set_recovery_required(li);
*action = DBVERSION_UPGRADE_4_5;
}
if (value & DBVERSION_RDN_FORMAT) {
if (entryrdn_get_switch()) {
/* nothing to do */
} else {
*action |= DBVERSION_NEED_RDN2DN;
}
} else {
if (entryrdn_get_switch()) {
*action |= DBVERSION_NEED_DN2RDN;
} else {
/* nothing to do */
}
}
slapi_ch_free_string(&ldbmversion);
slapi_ch_free_string(&dataversion);
return 0;
}
示例2: ldbm_instance_destructor
/* (ie, only when an instance is being deleted) */
static void
ldbm_instance_destructor(void **arg)
{
ldbm_instance *inst = (ldbm_instance *) *arg;
slapi_log_err(SLAPI_LOG_ERR, "ldbm_instance_destructor", "Destructor for instance %s called\n",
inst->inst_name);
slapi_counter_destroy(&(inst->inst_ref_count));
slapi_ch_free_string(&inst->inst_name);
PR_DestroyLock(inst->inst_config_mutex);
slapi_ch_free_string(&inst->inst_dir_name);
slapi_ch_free_string(&inst->inst_parent_dir_name);
PR_DestroyMonitor(inst->inst_db_mutex);
PR_DestroyLock(inst->inst_handle_list_mutex);
PR_DestroyLock(inst->inst_nextid_mutex);
PR_DestroyCondVar(inst->inst_indexer_cv);
attrinfo_deletetree(inst);
if (inst->inst_dataversion) {
slapi_ch_free((void **)&inst->inst_dataversion);
}
/* cache has already been destroyed */
slapi_ch_free((void **)&inst);
}
示例3: slapi_ch_realloc
char *
slapi_ch_realloc( char *block, unsigned long size )
{
char *newmem;
unsigned long lsize;
unsigned long origsize;
char *realblock;
char *realnewmem;
if ( block == NULL ) {
return( slapi_ch_malloc( size ) );
}
if (size <= 0) {
log_negative_alloc_msg( "realloc", "bytes", size );
return block;
}
lsize = size + sizeof(unsigned long);
if (lsize <= 1024) {
newmem = slapi_ch_realloc_core( block, lsize );
} else if (lsize <= 67108864) {
/* return 2KB ~ 64MB memory to memory pool */
unsigned long roundup = 1;
int n = 0;
while (1) {
roundup <<= 1;
n++;
if (roundup >= lsize) {
break;
}
}
PR_ASSERT(n >= 11 && n <= 26);
newmem = (char *)mempool_get(n-11); /* 11: 2^11 = 2K */
if (NULL == newmem) {
newmem = slapi_ch_realloc_core( block, roundup );
} else {
realblock = block - sizeof(unsigned long);
origsize = *(unsigned long *)realblock - sizeof(unsigned long);;
memcpy(newmem, block, origsize);
slapi_ch_free_string(&block);
}
} else {
realblock = block - sizeof(unsigned long);
origsize = *(unsigned long *)realblock - sizeof(unsigned long);;
newmem = slapi_ch_mmap( size );
memcpy(newmem, block, origsize);
realnewmem = newmem - sizeof(unsigned long);
*(unsigned long *)realnewmem = lsize;
slapi_ch_free_string(&block);
}
if(!counters_created)
{
create_counters();
counters_created= 1;
}
PR_INCREMENT_COUNTER(slapi_ch_counter_realloc);
return( newmem );
}
示例4: sasl_map_config_parse_entry
static int
sasl_map_config_parse_entry(Slapi_Entry *entry, sasl_map_data **new_dp)
{
int ret = 0;
int priority;
char *regex = NULL;
char *basedntemplate = NULL;
char *filtertemplate = NULL;
char *priority_str = NULL;
char *map_name = NULL;
*new_dp = NULL;
regex = _sasl_unescape_parenthesis(slapi_entry_attr_get_charptr( entry, "nsSaslMapRegexString" ));
basedntemplate = slapi_entry_attr_get_charptr( entry, "nsSaslMapBaseDNTemplate" );
filtertemplate = slapi_entry_attr_get_charptr( entry, "nsSaslMapFilterTemplate" );
map_name = slapi_entry_attr_get_charptr( entry, "cn" );
priority_str = slapi_entry_attr_get_charptr( entry, "nsSaslMapPriority" );
if(priority_str){
priority = atoi(priority_str);
} else {
priority = LOW_PRIORITY;
}
if(priority < 1 || priority > LOW_PRIORITY){
struct berval desc;
struct berval *newval[2] = {0, 0};
desc.bv_val = LOW_PRIORITY_STR;
desc.bv_len = strlen(desc.bv_val);
newval[0] = &desc;
if (entry_replace_values(entry, "nsSaslMapPriority", newval) != 0){
slapi_log_err(SLAPI_LOG_ERR, "sasl_map_config_parse_entry", "Failed to reset entry "
"priority to (%d) - previous value (%s)\n", LOW_PRIORITY, priority_str);
} else {
slapi_log_err(SLAPI_LOG_ERR, "sasl_map_config_parse_entry", "Resetting invalid nsSaslMapPriority "
" value (%s) to the lowest priority (%d)\n",
priority_str, LOW_PRIORITY);
}
priority = LOW_PRIORITY;
}
if ( (NULL == map_name) || (NULL == regex) ||
(NULL == basedntemplate) || (NULL == filtertemplate) ) {
/* Invalid entry */
ret = -1;
} else {
/* Make the new dp */
*new_dp = sasl_map_new_data(map_name, regex, basedntemplate, filtertemplate, priority);
}
if (ret) {
slapi_ch_free_string(&map_name);
slapi_ch_free_string(®ex);
slapi_ch_free_string(&basedntemplate);
slapi_ch_free_string(&filtertemplate);
}
slapi_ch_free_string(&priority_str);
return ret;
}
示例5: ipa_winsync_upg_enabled
/*
* Check if User Private Groups are enabled in given IPA domain
* Returns: 0 - UPG are enabled
* 1 - UPG are disabled
* -1 - some sort of error
*/
static int
ipa_winsync_upg_enabled(const Slapi_DN *ds_subtree)
{
int ret = -1;
int rc;
char * dn = NULL;
Slapi_Entry *entry = NULL;
Slapi_Backend *be;
const Slapi_DN *ds_suffix = NULL;
Slapi_DN *sdn = NULL;
const char *attrs_list[] = {IPA_WINSYNC_UPG_DEF_ATTR, 0};
char * value = NULL;
/* find ancestor base DN */
be = slapi_be_select(ds_subtree);
ds_suffix = slapi_be_getsuffix(be, 0);
if (ds_suffix == NULL) {
LOG_FATAL("Invalid DS subtree [%s]\n", slapi_sdn_get_dn(ds_subtree));
goto done;
}
dn = slapi_ch_smprintf(IPA_WINSYNC_UPG_DEF_DN, slapi_sdn_get_dn(ds_suffix));
if (!dn) {
LOG_OOM();
goto done;
}
sdn = slapi_sdn_new_dn_byref(dn);
rc = slapi_search_internal_get_entry(sdn, (char **) attrs_list, &entry,
ipa_winsync_get_plugin_identity());
if (rc) {
LOG("failed to retrieve UPG definition (%s) with rc %d\n", dn, rc);
goto done;
}
value = slapi_entry_attr_get_charptr(entry, IPA_WINSYNC_UPG_DEF_ATTR);
if (!value) {
LOG("failed to read %s from UPG definition (%s)\n",
IPA_WINSYNC_UPG_DEF_ATTR, dn);
goto done;
}
if (strstr(value, IPA_WINSYNC_UPG_DEF_DISABLED) == NULL) {
ret = 0;
} else {
ret = 1;
}
done:
slapi_ch_free_string(&dn);
slapi_sdn_free(&sdn);
slapi_ch_free_string(&value);
slapi_entry_free(entry);
return ret;
}
示例6: free_config
void
free_config()
{
slapi_ch_free_string(&globalcfg.state_attr_name);
slapi_ch_free_string(&globalcfg.alt_state_attr_name);
slapi_ch_free_string(&globalcfg.spec_attr_name);
slapi_ch_free_string(&globalcfg.limit_attr_name);
slapi_ch_free_string(&globalcfg.always_record_login_attr);
}
示例7: sasl_map_free_data
static void
sasl_map_free_data(sasl_map_data **dp)
{
slapi_ch_free_string(&(*dp)->name);
slapi_ch_free_string(&(*dp)->regular_expression);
slapi_ch_free_string(&(*dp)->template_base_dn);
slapi_ch_free_string(&(*dp)->template_search_filter);
slapi_ch_free((void**)dp);
}
示例8: snmp_collator_start
int snmp_collator_start()
{
int err;
char *statspath = config_get_rundir();
char *instdir = config_get_configdir();
char *instname = NULL;
/*
* Get directory for our stats file
*/
if (NULL == statspath) {
statspath = slapi_ch_strdup("/tmp");
}
instname = PL_strrstr(instdir, "slapd-");
if (!instname) {
instname = PL_strrstr(instdir, "/");
if (instname) {
instname++;
}
}
PR_snprintf(szStatsFile, sizeof(szStatsFile), "%s/%s%s",
statspath, instname, AGT_STATS_EXTENSION);
PR_snprintf(stats_sem_name, sizeof(stats_sem_name), "/%s%s",
instname, AGT_STATS_EXTENSION);
tmpstatsfile = szStatsFile;
slapi_ch_free_string(&statspath);
slapi_ch_free_string(&instdir);
/* open the memory map */
if ((err = agt_mopen_stats(tmpstatsfile, O_RDWR, &hdl) != 0))
{
if (err != EEXIST) /* Ignore if file already exists */
{
slapi_log_error(SLAPI_LOG_FATAL, "snmp collator", "Failed to open stats file (%s) "
"(error %d): %s.\n", szStatsFile, err, slapd_system_strerror(err));
exit(1);
}
}
/* Create semaphore for stats file access */
snmp_collator_create_semaphore();
/* point stats struct at mmap data */
stats = (struct agt_stats_t *) mmap_tbl [hdl].fp;
/* initialize stats data */
snmp_collator_init();
/* Arrange to be called back periodically to update the mmap'd stats file. */
snmp_eq_ctx = slapi_eq_repeat(snmp_collator_update, NULL, (time_t)0,
SLAPD_SNMP_UPDATE_INTERVAL);
return 0;
}
示例9: linked_attrs_fixup_task_destructor
static void
linked_attrs_fixup_task_destructor(Slapi_Task *task)
{
if (task) {
task_data *mydata = (task_data *)slapi_task_get_data(task);
if (mydata) {
slapi_ch_free_string(&mydata->linkdn);
slapi_ch_free_string(&mydata->bind_dn);
/* Need to cast to avoid a compiler warning */
slapi_ch_free((void **)&mydata);
}
}
}
示例10: slapi_sdn_done
void slapi_sdn_done( Slapi_DN *sdn )
{
if ( sdn == NULL )
return;
if ( sdn->flag & FLAG_DN ) {
slapi_ch_free_string( &sdn->dn.bv_val );
}
if ( sdn->flag & FLAG_NDN ) {
slapi_ch_free_string( &sdn->ndn.bv_val );
}
slapi_sdn_init( sdn );
}
示例11: sidgen_task_destructor
static void sidgen_task_destructor(Slapi_Task *task)
{
struct worker_ctx *worker_ctx;
if (task != NULL) {
worker_ctx = slapi_task_get_data(task);
if (worker_ctx != NULL) {
free_ranges(&worker_ctx->ranges);
slapi_ch_free_string(&worker_ctx->dom_sid);
slapi_ch_free_string(&worker_ctx->base_dn);
slapi_ch_free((void **) &worker_ctx);
}
}
}
示例12: referint_postop_init
int
referint_postop_init( Slapi_PBlock *pb )
{
Slapi_Entry *plugin_entry = NULL;
char *plugin_type = NULL;
int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
/*
* Get plugin identity and stored it for later use.
* Used for internal operations.
*/
slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &referint_plugin_identity);
PR_ASSERT (referint_plugin_identity);
/* get the args */
if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
plugin_entry &&
(plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
plugin_type && strstr(plugin_type, "betxn"))
{
delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
use_txn = 1;
}
if(plugin_entry){
char *allow_repl_updates;
allow_repl_updates = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-pluginAllowReplUpdates");
if(allow_repl_updates && strcasecmp(allow_repl_updates,"on")==0){
allow_repl = 1;
}
slapi_ch_free_string(&allow_repl_updates);
}
slapi_ch_free_string(&plugin_type);
if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 ||
slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&pdesc ) != 0 ||
slapi_pblock_set( pb, delfn, (void *) referint_postop_del ) != 0 ||
slapi_pblock_set( pb, mdnfn, (void *) referint_postop_modrdn ) != 0 ||
slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) referint_postop_start ) != 0 ||
slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *) referint_postop_close ) != 0)
{
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM, "referint_postop_init failed\n" );
return( -1 );
}
return( 0 );
}
示例13: usn_bepostop_init
static int
usn_bepostop_init(Slapi_PBlock *pb)
{
int rc = 0;
Slapi_Entry *plugin_entry = NULL;
char *plugin_type = NULL;
int postadd = SLAPI_PLUGIN_BE_POST_ADD_FN;
int postmod = SLAPI_PLUGIN_BE_POST_MODIFY_FN;
int postmdn = SLAPI_PLUGIN_BE_POST_MODRDN_FN;
int postdel = SLAPI_PLUGIN_BE_POST_DELETE_FN;
if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
plugin_entry &&
(plugin_type = slapi_entry_attr_get_charptr(plugin_entry,
"nsslapd-plugintype")) &&
plugin_type && strstr(plugin_type, "betxn")) {
postadd = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
postmod = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
postmdn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
postdel = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
}
slapi_ch_free_string(&plugin_type);
if ((slapi_pblock_set(pb, postadd, (void *)usn_bepostop) != 0) ||
(slapi_pblock_set(pb, postdel, (void *)usn_bepostop_delete) != 0) ||
(slapi_pblock_set(pb, postmod, (void *)usn_bepostop_modify) != 0) ||
(slapi_pblock_set(pb, postmdn, (void *)usn_bepostop) != 0)) {
slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
"usn_bepostop_init: failed to register bepostop plugin\n");
rc = -1;
}
return rc;
}
示例14: delete_my_str_buf
static void
delete_my_str_buf(MyStrBuf *buf)
{
if (buf->str != buf->fixbuf) {
slapi_ch_free_string(&(buf->str));
}
}
示例15: get_plugin_config_dn_and_entry
static void
get_plugin_config_dn_and_entry( char *msg, Slapi_PBlock *pb )
{
char *dn = NULL;
Slapi_Entry *e = NULL;
int loglevel = SLAPI_LOG_PLUGIN;
if ( slapi_pblock_get( pb, SLAPI_TARGET_DN, &dn ) != 0 || dn == NULL ) {
slapi_log_err( loglevel, msg, "failed to get plugin config DN\n" );
} else {
slapi_log_err( loglevel, msg, "this plugin's config DN is \"%s\"\n",
dn );
}
if ( slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &e ) != 0 || e == NULL ) {
slapi_log_err( loglevel, msg, "failed to get plugin config entry\n" );
} else {
char *ldif;
ldif = slapi_entry2str_with_options( e, NULL, 0 );
slapi_log_err( loglevel, msg,
"this plugin's config entry is \"\n%s\"\n", ldif );
slapi_ch_free_string( &ldif );
}
}