- char buf[8192], *ptr;
-
- ptr = buf;
- if ( which & SLAP_LIMIT_TIME ) {
- if ( lim->lms_t_soft != SLAPD_DEFAULT_TIMELIMIT ) {
- ptr = lutil_strcopy( ptr, " time.soft=" );
- if ( lim->lms_t_soft == -1 )
- ptr = lutil_strcopy( ptr, "unlimited" );
- else
- ptr += sprintf( ptr, "%d", lim->lms_t_soft );
- *ptr++ = ' ';
- }
- if ( lim->lms_t_hard ) {
- ptr = lutil_strcopy( ptr, " time.hard=" );
- if ( lim->lms_t_hard == -1 )
- ptr = lutil_strcopy( ptr, "unlimited" );
- else
- ptr += sprintf( ptr, "%d", lim->lms_t_hard );
- *ptr++ = ' ';
+ struct berval btmp;
+ char *ptr, *bufEnd; /* Updated/used by ptr_APPEND_*()/WHATSLEFT */
+ ber_len_t tmpLen; /* Used by ptr_APPEND_FMT*() */
+ unsigned type, style;
+ int rc = 0;
+
+ if ( !bv || !bv->bv_val ) return -1;
+
+ ptr = bv->bv_val;
+ bufEnd = ptr + buflen;
+ type = lim->lm_flags & SLAP_LIMITS_TYPE_MASK;
+
+ if ( type == SLAP_LIMITS_TYPE_GROUP ) {
+ rc = ptr_APPEND_FMT(( ptr, WHATSLEFT, "group/%s/%s=\"%s\"",
+ lim->lm_group_oc->soc_cname.bv_val,
+ lim->lm_group_ad->ad_cname.bv_val,
+ lim->lm_pat.bv_val ));
+ } else {
+ style = lim->lm_flags & SLAP_LIMITS_MASK;
+ switch( style ) {
+ case SLAP_LIMITS_ANONYMOUS:
+ case SLAP_LIMITS_USERS:
+ case SLAP_LIMITS_ANY:
+ rc = ptr_APPEND_BV( lmpats[style] );
+ break;
+ case SLAP_LIMITS_UNDEFINED:
+ case SLAP_LIMITS_EXACT:
+ case SLAP_LIMITS_ONE:
+ case SLAP_LIMITS_SUBTREE:
+ case SLAP_LIMITS_CHILDREN:
+ case SLAP_LIMITS_REGEX:
+ rc = ptr_APPEND_FMT(( ptr, WHATSLEFT, "dn.%s%s=\"%s\"",
+ type == SLAP_LIMITS_TYPE_SELF ? "" : "this.",
+ lmpats[style].bv_val, lim->lm_pat.bv_val ));
+ break;