本文整理汇总了C++中slapi_ch_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ slapi_ch_strdup函数的具体用法?C++ slapi_ch_strdup怎么用?C++ slapi_ch_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slapi_ch_strdup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slapi_lookup_instance_name_by_suffix
/*
* lookup instance names by suffix.
* if isexact == 0: returns instances including ones that associates with
* its sub suffixes.
* e.g., suffix: "o=<suffix>" is given, these are returned:
* suffixes: o=<suffix>, ou=<ou>,o=<suffix>, ...
* instances: inst of "o=<suffix>",
* inst of "ou=<ou>,o=<suffix>",
* ...
* if isexact != 0: returns an instance that associates with the given suffix
* e.g., suffix: "o=<suffix>" is given, these are returned:
* suffixes: "o=<suffix>"
* instances: inst of "o=<suffix>"
* Note: if suffixes
*/
int
slapi_lookup_instance_name_by_suffix(char *suffix,
char ***suffixes, char ***instances, int isexact)
{
Slapi_Backend *be = NULL;
struct suffixlist *list;
char *cookie = NULL;
const char *thisdn;
int thisdnlen;
int suffixlen;
int count;
int i;
int rval = -1;
if (instances == NULL)
return rval;
PR_ASSERT(suffix);
rval = 0;
suffixlen = strlen(suffix);
cookie = NULL;
be = slapi_get_first_backend (&cookie);
while (be) {
if (NULL == be->be_suffixlist) {
be = (backend *)slapi_get_next_backend (cookie);
continue;
}
count = slapi_counter_get_value(be->be_suffixcounter);
list = be->be_suffixlist;
for (i = 0; list && i < count; i++) {
thisdn = slapi_sdn_get_ndn(list->be_suffix);
thisdnlen = slapi_sdn_get_ndn_len(list->be_suffix);
if (isexact?suffixlen!=thisdnlen:suffixlen>thisdnlen){
list = list->next;
continue;
}
if (isexact?(!slapi_UTF8CASECMP(suffix, (char *)thisdn)):
(!slapi_UTF8CASECMP(suffix, (char *)thisdn+thisdnlen-suffixlen)))
{
charray_add(instances, slapi_ch_strdup(be->be_name));
if (suffixes)
charray_add(suffixes, slapi_ch_strdup(thisdn));
}
list = list->next;
}
be = (backend *)slapi_get_next_backend (cookie);
}
slapi_ch_free((void **)&cookie);
return rval;
}
示例2: ipa_topo_connection_fanout_new
struct node_fanout *
ipa_topo_connection_fanout_new (char *from, char *to)
{
struct node_fanout *new_fanout = (struct node_fanout *)
slapi_ch_malloc(sizeof(struct node_fanout));
struct node_list *targets = (struct node_list *)
slapi_ch_malloc(sizeof(struct node_list));
targets->next = NULL;
targets->node = slapi_ch_strdup(to);
new_fanout->next = NULL;
new_fanout->node = slapi_ch_strdup(from);
new_fanout->targets = targets;
new_fanout->visited = 0;
return new_fanout;
}
示例3: has_attr
/*
Checks whether an entry has a particular attribute type, and optionally
returns the value. Only for use with single-valued attributes - it returns
the first value it finds.
*/
int
has_attr( Slapi_Entry* target_entry, char* attr_name, char** val ) {
Slapi_ValueSet *values = NULL;
Slapi_Value* sval;
char *actual_type_name = NULL;
int type_name_disposition = 0, attr_free_flags = 0, rc = 0;
/* Use vattr interface to support virtual attributes, e.g.
acctPolicySubentry has a good chance of being supplied by CoS */
if ( slapi_vattr_values_get( target_entry, attr_name, &values, &type_name_disposition, &actual_type_name, 0, &attr_free_flags) == 0) {
if( slapi_valueset_first_value( values, &sval ) == -1 ) {
rc = 0;
} else {
rc = 1;
if( val ) {
/* Caller wants a copy of the found attribute's value */
*val = slapi_ch_strdup( slapi_value_get_string( sval ) );
}
}
} else {
rc = 0;
}
slapi_vattr_values_free(&values, &actual_type_name, attr_free_flags);
return( rc );
}
示例4: slapi_over_config
int slapi_over_config( BackendDB *be, ConfigReply *cr )
{
if ( slapi_over_initialized == 0 ) {
int rc;
/* do global initializaiton */
ldap_pvt_thread_mutex_init( &slapi_hn_mutex );
ldap_pvt_thread_mutex_init( &slapi_time_mutex );
ldap_pvt_thread_mutex_init( &slapi_printmessage_mutex );
if ( slapi_log_file == NULL )
slapi_log_file = slapi_ch_strdup( LDAP_RUNDIR LDAP_DIRSEP "errors" );
rc = slapi_int_init_object_extensions();
if ( rc != 0 )
return rc;
rc = slapi_over_init();
if ( rc != 0 )
return rc;
slapi_over_initialized = 1;
}
return overlay_config( be, SLAPI_OVERLAY_NAME, -1, NULL, cr );
}
示例5: GetDomainUsername
int
GetDomainUsername(
char *pszNTuserdomainid,
char *pszNTDomain,
char *pszNTUsername
)
{
char *pszAttr, *pDomain, *pUsername;
if( !pszNTuserdomainid )
return( 1 );
// Split the specially constructed attribute.
pszAttr = slapi_ch_strdup( pszNTuserdomainid );
pDomain = pszAttr;
pUsername = strchr( pszAttr, ':' );
if( pUsername == NULL )
return( 1 );
// Set the end of the NT Domain name,
// and the start of the NT username.
*pUsername = (char)NULL;
pUsername++;
strcpy( pszNTDomain, pDomain);
strcpy( pszNTUsername, pUsername);
slapi_ch_free( (void**)&pszAttr );
return( 0 );
}
示例6: get_rdn_plus_uniqueid
static char *
get_rdn_plus_uniqueid(char *sessionid, const char *olddn, const char *uniqueid)
{
char *newrdn;
/* Check if the RDN already contains the Unique ID */
Slapi_DN *sdn= slapi_sdn_new_dn_byval(olddn);
Slapi_RDN *rdn= slapi_rdn_new();
slapi_sdn_get_rdn(sdn,rdn);
PR_ASSERT(uniqueid!=NULL);
if(slapi_rdn_contains(rdn,SLAPI_ATTR_UNIQUEID,uniqueid,strlen(uniqueid)))
{
/* The Unique ID is already in the RDN.
* This is a highly improbable collision.
* It suggests that a duplicate UUID was generated.
* This will cause replication divergence and will
* require admin intercession
*/
slapi_log_error(SLAPI_LOG_FATAL, sessionid,
"Annotated DN %s has naming conflict\n", olddn );
newrdn= NULL;
}
else
{
slapi_rdn_add(rdn,SLAPI_ATTR_UNIQUEID,uniqueid);
newrdn= slapi_ch_strdup(slapi_rdn_get_rdn(rdn));
}
slapi_sdn_free(&sdn);
slapi_rdn_free(&rdn);
return newrdn;
}
示例7: or_indexer_create
static int
or_indexer_create (Slapi_PBlock* pb)
{
auto int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; /* failed to initialize */
auto char* mrOID = NULL;
auto void* mrOBJECT = NULL;
if (slapi_pblock_get (pb, SLAPI_PLUGIN_MR_OID, &mrOID) || mrOID == NULL) {
slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM,
"or_indexer_create - No OID parameter\n");
} else {
auto indexer_t* ix = indexer_create (mrOID);
auto char* mrTYPE = NULL;
slapi_pblock_get (pb, SLAPI_PLUGIN_MR_TYPE, &mrTYPE);
slapi_log_err(SLAPI_LOG_FILTER, "or_indexer_create", "(oid %s; type %s)\n",
mrOID, mrTYPE ? mrTYPE : "<NULL>");
if (ix != NULL) {
if (ix->ix_index != NULL &&
!slapi_pblock_set (pb, SLAPI_PLUGIN_OBJECT, ix) &&
!slapi_pblock_set (pb, SLAPI_PLUGIN_MR_OID, ix->ix_oid) &&
!slapi_pblock_set (pb, SLAPI_PLUGIN_MR_INDEX_FN, (void*)op_index_entry) &&
!slapi_pblock_set (pb, SLAPI_PLUGIN_DESTROY_FN, (void*)op_indexer_destroy)) {
mrOBJECT = ix;
rc = 0; /* success */
} else {
indexer_free (ix);
}
} else { /* mrOID does not identify an ordering rule. */
/* Is it an ordering rule OID with the substring suffix? */
auto size_t oidlen = strlen (mrOID);
if (oidlen > 2 && mrOID[oidlen-2] == '.' &&
atoi (mrOID + oidlen - 1) == SLAPI_OP_SUBSTRING) {
auto char* or_oid = slapi_ch_strdup (mrOID);
or_oid [oidlen-2] = '\0';
ix = indexer_create (or_oid);
if (ix != NULL) {
auto ss_indexer_t* ss = (ss_indexer_t*) slapi_ch_malloc (sizeof (ss_indexer_t));
ss->ss_indexer = ix;
oidlen = strlen (ix->ix_oid);
ss->ss_oid = slapi_ch_malloc (oidlen + 3);
memcpy (ss->ss_oid, ix->ix_oid, oidlen);
sprintf (ss->ss_oid + oidlen, ".%1i", SLAPI_OP_SUBSTRING);
if (ix->ix_index != NULL &&
!slapi_pblock_set (pb, SLAPI_PLUGIN_OBJECT, ss) &&
!slapi_pblock_set (pb, SLAPI_PLUGIN_MR_OID, ss->ss_oid) &&
!slapi_pblock_set (pb, SLAPI_PLUGIN_MR_INDEX_FN, (void*)ss_index_entry) &&
!slapi_pblock_set (pb, SLAPI_PLUGIN_DESTROY_FN, (void*)ss_indexer_destroy)) {
mrOBJECT = ss;
rc = 0; /* success */
} else {
ss_indexer_free (ss);
}
}
slapi_ch_free((void**)&or_oid);
}
}
}
slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM,
"or_indexer_create - (%p) %i\n", mrOBJECT, rc);
return rc;
}
示例8: ipa_topo_connection_fanout_extend
struct node_fanout *
ipa_topo_connection_fanout_extend (struct node_fanout *fanout_in, char *from, char *to)
{
struct node_fanout *cursor;
if (fanout_in == NULL) {
/* init fanout */
return ipa_topo_connection_fanout_new(from,to);
}
/* extend existing fanout struct */
cursor = fanout_in;
while (cursor) {
if (strcasecmp(cursor->node, from) == 0) break;
cursor = cursor->next;
}
if (cursor) {
struct node_list *target = (struct node_list *)
slapi_ch_malloc(sizeof(struct node_list));
target->next = cursor->targets;
target->node = slapi_ch_strdup(to);
cursor->targets = target;
return fanout_in;
} else {
cursor = ipa_topo_connection_fanout_new(from,to);
cursor->next = fanout_in;
return cursor;
}
}
示例9: task_sampletask_add
/*
* Invoked when the task instance is added by the client (step 5 of the comment)
* Get the necessary attributes from the task entry, and spawns a thread to do
* the task.
*/
static int
task_sampletask_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter, int *returncode, char *returntext,
void *arg)
{
PRThread *thread = NULL;
const char *cn;
int rv = SLAPI_DSE_CALLBACK_OK;
Slapi_PBlock *mypb = NULL;
Slapi_Task *task = NULL;
const char *myarg;
*returncode = LDAP_SUCCESS;
if ((cn = fetch_attr(e, "cn", NULL)) == NULL) {
*returncode = LDAP_OBJECT_CLASS_VIOLATION;
rv = SLAPI_DSE_CALLBACK_ERROR;
goto out;
}
/* get arg(s) */
if ((myarg = fetch_attr(e, "myarg", NULL)) == NULL) {
*returncode = LDAP_OBJECT_CLASS_VIOLATION;
rv = SLAPI_DSE_CALLBACK_ERROR;
goto out;
}
/* allocate new task now */
task = slapi_new_task(slapi_entry_get_ndn(e));
if (task == NULL) {
slapi_log_err(SLAPI_LOG_ERR, "sampletask", "unable to allocate new task!\n");
*returncode = LDAP_OPERATIONS_ERROR;
rv = SLAPI_DSE_CALLBACK_ERROR;
goto out;
}
/* set a destructor that will clean up myarg for us when the task is complete */
slapi_task_set_destructor_fn(task, task_sampletask_destructor);
/* Stash our argument in the task for use by the task thread */
slapi_task_set_data(task, slapi_ch_strdup(myarg));
/* start the sample task as a separate thread */
thread = PR_CreateThread(PR_USER_THREAD, task_sampletask_thread,
(void *)task, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
if (thread == NULL) {
slapi_log_err(SLAPI_LOG_ERR, "sampletask",
"unable to create sample task thread!\n");
*returncode = LDAP_OPERATIONS_ERROR;
rv = SLAPI_DSE_CALLBACK_ERROR;
slapi_task_finish(task, *returncode);
} else {
/* thread successful */
rv = SLAPI_DSE_CALLBACK_OK;
}
out:
return rv;
}
示例10: slapi_register_supported_feature
int
slapi_register_supported_feature( char *featureoid )
{
slapi_rwlock_wrlock(supported_features_lock);
charray_add( &supported_features, slapi_ch_strdup( featureoid ));
slapi_rwlock_unlock(supported_features_lock);
return LDAP_SUCCESS;
}
示例11: ldbm_instance_config_instance_dir_set
static int
ldbm_instance_config_instance_dir_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
ldbm_instance *inst = (ldbm_instance *)arg;
if (!apply) {
return LDAP_SUCCESS;
}
if ((value == NULL) || (strlen(value) == 0))
{
inst->inst_dir_name = NULL;
inst->inst_parent_dir_name = NULL;
}
else
{
char *dir = (char *)value;
if (is_fullpath(dir))
{
char sep = get_sep(dir);
char *p = strrchr(dir, sep);
if (NULL == p) /* should not happens, tho */
{
inst->inst_parent_dir_name = NULL;
inst->inst_dir_name = rel2abspath(dir); /* normalize dir;
strdup'ed in
rel2abspath */
}
else
{
*p = '\0';
inst->inst_parent_dir_name = rel2abspath(dir); /* normalize dir;
strdup'ed in
rel2abspath */
inst->inst_dir_name = slapi_ch_strdup(p+1);
*p = sep;
}
}
else
{
inst->inst_parent_dir_name = NULL;
inst->inst_dir_name = slapi_ch_strdup(dir);
}
}
return LDAP_SUCCESS;
}
示例12: new_bitwise_match_cb
/*
The type and val pointers are assumed to have sufficient lifetime -
we don't have to copy them - they are usually just pointers into
the SLAPI_PLUGIN_MR_TYPE and SLAPI_PLUGIN_MR_VALUE fields of the
operation pblock, whose lifetime should encompass the creation
and destruction of the bitwise_match_cb object.
*/
static struct bitwise_match_cb *
new_bitwise_match_cb(char *type, struct berval *val)
{
struct bitwise_match_cb *bmc = (struct bitwise_match_cb *)slapi_ch_calloc(1, sizeof(struct bitwise_match_cb));
bmc->type = slapi_ch_strdup(type);
bmc->val = val;
return bmc;
}
示例13: subentry_create_filter
/* Function which wraps a filter with (AND !(objectclass=ldapsubentry)) */
void subentry_create_filter(Slapi_Filter** filter)
{
Slapi_Filter *sub_filter = NULL;
Slapi_Filter *new_filter = NULL;
char *buf = slapi_ch_strdup("(!(objectclass=ldapsubentry))");
sub_filter = slapi_str2filter( buf );
new_filter = slapi_filter_join( LDAP_FILTER_AND, *filter, sub_filter );
*filter = new_filter;
slapi_ch_free((void **)&buf);
}
示例14: sasl_map_str_concat
static char *
sasl_map_str_concat(char *s1, char *s2)
{
if (NULL == s2) {
return (slapi_ch_strdup(s1));
} else {
char *newstr = slapi_ch_smprintf("%[email protected]%s",s1,s2);
return newstr;
}
}
示例15: 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;
}