Lines Matching refs:ber

50 kmfber_read(BerElement *ber, char *buf, ber_len_t len)  in kmfber_read()  argument
55 nleft = ber->ber_end - ber->ber_ptr; in kmfber_read()
58 (void) memmove(buf, ber->ber_ptr, (size_t)actuallen); in kmfber_read()
60 ber->ber_ptr += actuallen; in kmfber_read()
70 kmfber_realloc(BerElement *ber, ber_len_t len) in kmfber_realloc() argument
78 have_bytes = ber->ber_end - ber->ber_buf; in kmfber_realloc()
83 oldbuf = ber->ber_buf; in kmfber_realloc()
85 if (ber->ber_buf == NULL) { in kmfber_realloc()
86 if ((ber->ber_buf = (char *)malloc((size_t)total)) in kmfber_realloc()
90 ber->ber_flags &= ~KMFBER_FLAG_NO_FREE_BUFFER; in kmfber_realloc()
92 if (ber->ber_flags & KMFBER_FLAG_NO_FREE_BUFFER) { in kmfber_realloc()
94 if ((ber->ber_buf = (char *)malloc( in kmfber_realloc()
98 ber->ber_flags &= ~KMFBER_FLAG_NO_FREE_BUFFER; in kmfber_realloc()
101 (void) memmove(ber->ber_buf, oldbuf, have_bytes); in kmfber_realloc()
103 if ((ber->ber_buf = (char *)realloc( in kmfber_realloc()
111 ber->ber_end = ber->ber_buf + total; in kmfber_realloc()
118 if (ber->ber_buf != oldbuf) { in kmfber_realloc()
119 ber->ber_ptr = ber->ber_buf + (ber->ber_ptr - oldbuf); in kmfber_realloc()
121 for (s = ber->ber_sos; s != NULLSEQORSET; s = s->sos_next) { in kmfber_realloc()
123 s->sos_first = ber->ber_buf + off; in kmfber_realloc()
126 s->sos_ptr = ber->ber_buf + off; in kmfber_realloc()
137 kmfber_write(BerElement *ber, char *buf, ber_len_t len, int nosos) in kmfber_write() argument
139 if (nosos || ber->ber_sos == NULL) { in kmfber_write()
140 if (ber->ber_ptr + len > ber->ber_end) { in kmfber_write()
141 if (kmfber_realloc(ber, len) != 0) in kmfber_write()
144 (void) memmove(ber->ber_ptr, buf, (size_t)len); in kmfber_write()
145 ber->ber_ptr += len; in kmfber_write()
148 if (ber->ber_sos->sos_ptr + len > ber->ber_end) { in kmfber_write()
149 if (kmfber_realloc(ber, len) != 0) in kmfber_write()
152 (void) memmove(ber->ber_sos->sos_ptr, buf, (size_t)len); in kmfber_write()
153 ber->ber_sos->sos_ptr += len; in kmfber_write()
154 ber->ber_sos->sos_clen += len; in kmfber_write()
160 kmfber_free(BerElement *ber, int freebuf) in kmfber_free() argument
162 if (ber != NULL) { in kmfber_free()
164 !(ber->ber_flags & KMFBER_FLAG_NO_FREE_BUFFER)) in kmfber_free()
165 free(ber->ber_buf); in kmfber_free()
166 free((char *)ber); in kmfber_free()
174 BerElement *ber; in kmfber_alloc_t() local
176 if ((ber = (BerElement*)calloc(1, in kmfber_alloc_t()
181 ber->ber_tag = KMFBER_DEFAULT; in kmfber_alloc_t()
182 ber->ber_options = options; in kmfber_alloc_t()
183 ber->ber_buf = (char *)ber + sizeof (struct berelement); in kmfber_alloc_t()
184 ber->ber_ptr = ber->ber_buf; in kmfber_alloc_t()
185 ber->ber_end = ber->ber_buf + EXBUFSIZ; in kmfber_alloc_t()
186 ber->ber_flags = KMFBER_FLAG_NO_FREE_BUFFER; in kmfber_alloc_t()
188 return (ber); in kmfber_alloc_t()
205 kmfber_dup(BerElement *ber) in kmfber_dup() argument
212 *new = *ber; in kmfber_dup()
219 ber_init_w_nullchar(BerElement *ber, int options) in ber_init_w_nullchar() argument
221 (void) memset((char *)ber, '\0', sizeof (struct berelement)); in ber_init_w_nullchar()
222 ber->ber_tag = KMFBER_DEFAULT; in ber_init_w_nullchar()
224 ber->ber_options = options; in ber_init_w_nullchar()
229 kmfber_reset(BerElement *ber, int was_writing) in kmfber_reset() argument
232 ber->ber_end = ber->ber_ptr; in kmfber_reset()
233 ber->ber_ptr = ber->ber_buf; in kmfber_reset()
235 ber->ber_ptr = ber->ber_end; in kmfber_reset()
238 ber->ber_rwptr = NULL; in kmfber_reset()
245 ber_dump(BerElement *ber, int inout) in ber_dump() argument
249 ber->ber_buf, ber->ber_ptr, ber->ber_rwptr, ber->ber_end); in ber_dump()
253 ber->ber_end - ber->ber_ptr); in ber_dump()
255 lber_bprint(ber->ber_ptr, ber->ber_end - ber->ber_ptr); in ber_dump()
258 ber->ber_ptr - ber->ber_buf); in ber_dump()
260 lber_bprint(ber->ber_buf, ber->ber_ptr - ber->ber_buf); in ber_dump()
304 kmfber_flatten(BerElement *ber, struct berval **bvPtr) in kmfber_flatten() argument
320 if (ber == NULL) { in kmfber_flatten()
324 len = ber->ber_ptr - ber->ber_buf; in kmfber_flatten()
330 (void) memmove(new->bv_val, ber->ber_buf, (size_t)len); in kmfber_flatten()
344 BerElement *ber; in kmfder_init() local
347 if ((ber = kmfber_alloc_t(KMFBER_OPT_USE_DER)) != NULL) { in kmfder_init()
350 if ((kmfber_write(ber, bv->bv_val, bv->bv_len, 0)) != in kmfder_init()
352 kmfber_free(ber, 1); in kmfder_init()
360 kmfber_reset(ber, 1); in kmfder_init()
366 return (ber); in kmfder_init()
372 BerElement *ber; in kmfber_init() local
375 if ((ber = kmfber_alloc_t(0)) != NULL) { in kmfber_init()
378 if ((kmfber_write(ber, bv->bv_val, bv->bv_len, 0)) != in kmfber_init()
380 kmfber_free(ber, 1); in kmfber_init()
388 kmfber_reset(ber, 1); in kmfber_init()
394 return (ber); in kmfber_init()