• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/passwordserver_sasl-193/cyrus_sasl/lib/

Lines Matching refs:ctx

115 static int prop_init(struct propctx *ctx, unsigned estimate) 
119 ctx->mem_base = alloc_proppool(VALUES_SIZE + estimate);
120 if(!ctx->mem_base) return SASL_NOMEM;
122 ctx->mem_cur = ctx->mem_base;
124 ctx->values = (struct propval *)ctx->mem_base->data;
125 ctx->mem_base->unused = ctx->mem_base->size - VALUES_SIZE;
126 ctx->allocated_values = PROP_DEFAULT;
127 ctx->used_values = 0;
129 ctx->data_end = ctx->mem_base->data + ctx->mem_base->size;
130 ctx->list_end = (char **)(ctx->mem_base->data + VALUES_SIZE);
132 ctx->prev_val = NULL;
214 * ctx -- is disposed and set to NULL; noop if ctx or *ctx is NULL
216 void prop_dispose(struct propctx **ctx)
220 if(!ctx || !*ctx) return;
222 while((*ctx)->mem_base) {
223 tmp = (*ctx)->mem_base;
224 (*ctx)->mem_base = tmp->next;
228 sasl_FREE(*ctx);
229 *ctx = NULL;
235 * ctx -- context from prop_new()
242 int prop_request(struct propctx *ctx, const char **names)
246 if(!ctx || !names) return SASL_BADPARAM;
255 total_values = new_values + ctx->used_values + 1;
258 if(total_values > ctx->allocated_values) {
262 max_in_pool = (unsigned) (ctx->mem_base->size / sizeof(struct propval));
267 ctx->allocated_values = total_values;
268 ctx->mem_base->unused =
269 ctx->mem_base->size - (sizeof(struct propval)
270 * ctx->allocated_values);
276 new_alloc_length = 2 * ctx->allocated_values;
282 ctx->mem_base = resize_proppool(ctx->mem_base, new_size);
284 if(!ctx->mem_base) {
285 ctx->values = NULL;
286 ctx->allocated_values = ctx->used_values = 0;
291 ctx->values = (struct propval *)ctx->mem_base->data;
292 ctx->allocated_values = new_alloc_length;
293 ctx->mem_base->unused = ctx->mem_base->size
294 - sizeof(struct propval) * ctx->allocated_values;
298 memset(&(ctx->values[ctx->used_values]), 0,
299 sizeof(struct propval) * (ctx->allocated_values - ctx->used_values));
302 /* ctx->list_end = (char **)(ctx->values + ctx->allocated_values); */
304 ctx->list_end = (char **)(ctx->values + total_values);
314 for(j=0;j<ctx->used_values;j++) {
315 if(!strcmp(ctx->values[j].name, names[i])) {
324 ctx->values[ctx->used_values++].name = names[i];
327 prop_clear(ctx, 0);
336 const struct propval *prop_get(struct propctx *ctx)
338 if(!ctx) return NULL;
340 return ctx->values;
346 * returns -1 on error (no properties ever requested, ctx NULL, etc)
351 int prop_getnames(struct propctx *ctx, const char **names,
359 if(!ctx || !names || !vals) return SASL_BADPARAM;
363 for(val = ctx->values; val->name; val++) {
383 * ctx -- property context
386 void prop_clear(struct propctx *ctx, int requests)
392 new_pool = alloc_proppool(ctx->mem_base->size +
393 (ctx->used_values+1) * sizeof(struct propval));
397 ctx->used_values = 0;
401 for(i=0; i<ctx->used_values; i++) {
402 new_values[i].name = ctx->values[i].name;
406 while(ctx->mem_base) {
407 tmp = ctx->mem_base;
408 ctx->mem_base = tmp->next;
413 ctx->allocated_values = ctx->used_values+1;
415 new_pool->size - (ctx->allocated_values * sizeof(struct propval));
418 ctx->values = (struct propval *)new_pool->data;
419 ctx->prev_val = NULL;
422 ctx->mem_base = ctx->mem_cur = new_pool;
425 ctx->list_end =
426 (char **)((char *)ctx->mem_base->data + ctx->allocated_values * sizeof(struct propval));
427 ctx->data_end = (char *)ctx->mem_base->data + ctx->mem_base->size;
435 void prop_erase(struct propctx *ctx, const char *name)
440 if(!ctx || !name) return;
442 for(val = ctx->values; val->name; val++) {
469 * ctx -- context from prop_new()/prop_request()
477 int prop_format(struct propctx *ctx, const char *sep, int seplen,
483 if (!ctx || !outbuf) return SASL_BADPARAM;
491 needed = seplen * (ctx->used_values - 1);
492 for(val = ctx->values; val->name; val++) {
504 for(val = ctx->values; val->name; val++) {
517 * ctx -- context from prop_new()/prop_request()
524 int prop_set(struct propctx *ctx, const char *name,
529 if(!ctx) return SASL_BADPARAM;
530 if(!name && !ctx->prev_val) return SASL_BADPARAM;
535 ctx->prev_val = NULL;
537 for(val = ctx->values; val->name; val++) {
539 ctx->prev_val = val;
545 if(!ctx->prev_val) return SASL_BADPARAM;
548 cur = ctx->prev_val;
578 if(size > ctx->mem_cur->unused) {
581 for(needed = ctx->mem_cur->size * 2; needed < size; needed *= 2);
584 ctx->mem_cur->next = alloc_proppool(needed);
585 if(!ctx->mem_cur->next) return SASL_NOMEM;
587 ctx->mem_cur = ctx->mem_cur->next;
589 ctx->list_end = (char **)ctx->mem_cur->data;
590 ctx->data_end = ctx->mem_cur->data + needed;
594 ctx->mem_cur->unused -= size;
595 cur->values = (const char **)ctx->list_end;
599 ctx->list_end = (char **)(cur->values + nvalues);
621 if(size > ctx->mem_cur->unused) {
624 needed = ctx->mem_cur->size * 2;
631 ctx->mem_cur->next = alloc_proppool(needed);
632 if(!ctx->mem_cur->next) return SASL_NOMEM;
634 ctx->mem_cur = ctx->mem_cur->next;
635 ctx->list_end = (char **)ctx->mem_cur->data;
636 ctx->data_end = ctx->mem_cur->data + needed;
640 ctx->data_end -= size;
641 ctx->mem_cur->unused -= size;
644 memcpy(ctx->data_end, value, size-1);
645 ctx->data_end[size - 1] = '\0';
646 cur->values[nvalues - 2] = ctx->data_end;
660 if(size > ctx->mem_cur->unused &&
661 (void *)cur->values > (void *)(ctx->mem_cur->data) &&
662 (void *)cur->values < (void *)(ctx->mem_cur->data + ctx->mem_cur->size)) {
664 return prop_set(ctx, cur->name, value, vallen);
671 ctx->mem_cur->unused -= size;
672 ctx->list_end++;
674 *(ctx->list_end - 1) = NULL;
675 tmp = (ctx->list_end - 2);
683 if(size > ctx->mem_cur->unused) {
686 needed = ctx->mem_cur->size * 2;
693 ctx->mem_cur->next = alloc_proppool(needed);
694 if(!ctx->mem_cur->next) return SASL_NOMEM;
696 ctx->mem_cur = ctx->mem_cur->next;
697 ctx->list_end = (char **)ctx->mem_cur->data;
698 ctx->data_end = ctx->mem_cur->data + needed;
702 ctx->data_end -= size;
703 ctx->mem_cur->unused -= size;
706 memcpy(ctx->data_end, value, size-1);
707 ctx->data_end[size - 1] = '\0';
708 *tmp = ctx->data_end;
719 * ctx -- context from prop_new()/prop_request()
725 int prop_setvals(struct propctx *ctx, const char *name,
731 if(!ctx) return SASL_BADPARAM;
738 result = prop_set(ctx, name, *val, 0);
744 result = prop_set(ctx, NULL, *val,0);
1018 struct propctx *ctx, const char *user)
1030 if (ctx) {
1051 sparams, ctx, user, userlen);
1085 sparams, ctx, user, userlen);