Lines Matching defs:sp

46  * @param sp the storage buffer to set the flags on
53 krb5_storage_set_flags(krb5_storage *sp, krb5_flags flags)
55 sp->flags |= flags;
61 * @param sp the storage buffer to clear the flags on
68 krb5_storage_clear_flags(krb5_storage *sp, krb5_flags flags)
70 sp->flags &= ~flags;
77 * @param sp the storage buffer to check flags on
86 krb5_storage_is_flags(krb5_storage *sp, krb5_flags flags)
88 return (sp->flags & flags) == flags;
94 * @param sp the storage buffer to set the byte order for.
104 krb5_storage_set_byteorder(krb5_storage *sp, krb5_flags byteorder)
106 sp->flags &= ~KRB5_STORAGE_BYTEORDER_MASK;
107 sp->flags |= byteorder;
117 krb5_storage_get_byteorder(krb5_storage *sp)
119 return sp->flags & KRB5_STORAGE_BYTEORDER_MASK;
125 * @param sp the storage buffer set the max allow for
132 krb5_storage_set_max_alloc(krb5_storage *sp, size_t size)
134 sp->max_alloc = size;
139 size_too_large(krb5_storage *sp, size_t size)
141 if (sp->max_alloc && sp->max_alloc < size)
147 size_too_large_num(krb5_storage *sp, size_t count, size_t size)
149 if (sp->max_alloc == 0 || size == 0)
151 size = sp->max_alloc / size;
160 * @param sp the storage buffer to seek in.
171 krb5_storage_seek(krb5_storage *sp, off_t offset, int whence)
173 return (*sp->seek)(sp, offset, whence);
177 * Truncate the storage buffer in sp to offset.
179 * @param sp the storage buffer to truncate.
188 krb5_storage_truncate(krb5_storage *sp, off_t offset)
190 return (*sp->trunc)(sp, offset);
196 * @param sp the storage buffer to read from
206 krb5_storage_read(krb5_storage *sp, void *buf, size_t len)
208 return sp->fetch(sp, buf, len);
214 * @param sp the storage buffer to write to
224 krb5_storage_write(krb5_storage *sp, const void *buf, size_t len)
226 return sp->store(sp, buf, len);
232 * @param sp the storage
239 krb5_storage_set_eof_code(krb5_storage *sp, int code)
241 sp->eof_code = code;
247 * @param sp the storage
255 krb5_storage_get_eof_code(krb5_storage *sp)
257 return sp->eof_code;
263 * @param sp the storage to free.
271 krb5_storage_free(krb5_storage *sp)
273 if(sp->free)
274 (*sp->free)(sp);
275 free(sp->data);
276 free(sp);
283 * @param sp the storage to copy to a data
292 krb5_storage_to_data(krb5_storage *sp, krb5_data *data)
297 pos = sp->seek(sp, 0, SEEK_CUR);
300 size = sp->seek(sp, 0, SEEK_END);
301 ret = size_too_large(sp, size);
306 sp->seek(sp, pos, SEEK_SET);
310 sp->seek(sp, 0, SEEK_SET);
311 sp->fetch(sp, data->data, data->length);
312 sp->seek(sp, pos, SEEK_SET);
318 krb5_store_int(krb5_storage *sp,
328 ret = sp->store(sp, v, len);
332 return sp->eof_code;
340 * @param sp the storage to write too
349 krb5_store_int32(krb5_storage *sp,
352 if(BYTEORDER_IS_HOST(sp))
354 else if(BYTEORDER_IS_LE(sp))
356 return krb5_store_int(sp, value, 4);
363 * @param sp the storage to write too
372 krb5_store_uint32(krb5_storage *sp,
375 return krb5_store_int32(sp, (int32_t)value);
379 krb5_ret_int(krb5_storage *sp,
386 ret = sp->fetch(sp, v, len);
390 return sp->eof_code;
400 * @param sp the storage to write too
409 krb5_ret_int32(krb5_storage *sp,
412 krb5_error_code ret = krb5_ret_int(sp, value, 4);
415 if(BYTEORDER_IS_HOST(sp))
417 else if(BYTEORDER_IS_LE(sp))
426 * @param sp the storage to write too
435 krb5_ret_uint32(krb5_storage *sp,
441 ret = krb5_ret_int32(sp, &v);
452 * @param sp the storage to write too
461 krb5_store_int16(krb5_storage *sp,
464 if(BYTEORDER_IS_HOST(sp))
466 else if(BYTEORDER_IS_LE(sp))
468 return krb5_store_int(sp, value, 2);
475 * @param sp the storage to write too
484 krb5_store_uint16(krb5_storage *sp,
487 return krb5_store_int16(sp, (int16_t)value);
494 * @param sp the storage to write too
503 krb5_ret_int16(krb5_storage *sp,
508 ret = krb5_ret_int(sp, &v, 2);
512 if(BYTEORDER_IS_HOST(sp))
514 else if(BYTEORDER_IS_LE(sp))
523 * @param sp the storage to write too
532 krb5_ret_uint16(krb5_storage *sp,
538 ret = krb5_ret_int16(sp, &v);
548 * @param sp the storage to write too
557 krb5_store_int8(krb5_storage *sp,
562 ret = sp->store(sp, &value, sizeof(value));
564 return (ret<0)?errno:sp->eof_code;
571 * @param sp the storage to write too
580 krb5_store_uint8(krb5_storage *sp,
583 return krb5_store_int8(sp, (int8_t)value);
589 * @param sp the storage to write too
598 krb5_ret_int8(krb5_storage *sp,
603 ret = sp->fetch(sp, value, sizeof(*value));
605 return (ret<0)?errno:sp->eof_code;
612 * @param sp the storage to write too
621 krb5_ret_uint8(krb5_storage *sp,
627 ret = krb5_ret_int8(sp, &v);
638 * @param sp the storage buffer to write to
647 krb5_store_data(krb5_storage *sp,
651 ret = krb5_store_int32(sp, data.length);
654 ret = sp->store(sp, data.data, data.length);
658 return sp->eof_code;
665 * @param sp the storage buffer to read from
674 krb5_ret_data(krb5_storage *sp,
680 ret = krb5_ret_int32(sp, &size);
683 ret = size_too_large(sp, size);
690 ret = sp->fetch(sp, data->data, size);
692 return (ret < 0)? errno : sp->eof_code;
701 * @param sp the storage buffer to write to
710 krb5_store_string(krb5_storage *sp, const char *s)
715 return krb5_store_data(sp, data);
721 * @param sp the storage buffer to read from
731 krb5_ret_string(krb5_storage *sp,
736 ret = krb5_ret_data(sp, &data);
752 * @param sp the storage buffer to write to
761 krb5_store_stringz(krb5_storage *sp, const char *s)
766 ret = sp->store(sp, s, len);
770 return sp->eof_code;
777 * @param sp the storage buffer to read from
786 krb5_ret_stringz(krb5_storage *sp,
794 while((ret = sp->fetch(sp, &c, 1)) == 1){
798 ret = size_too_large(sp, len);
814 return sp->eof_code;
822 krb5_store_stringnl(krb5_storage *sp, const char *s)
827 ret = sp->store(sp, s, len);
831 return sp->eof_code;
832 ret = sp->store(sp, "\n", 1);
837 return sp->eof_code;
845 krb5_ret_stringnl(krb5_storage *sp,
854 while((ret = sp->fetch(sp, &c, 1)) == 1){
867 ret = size_too_large(sp, len);
885 return sp->eof_code;
895 * @param sp the storage buffer to write to
904 krb5_store_principal(krb5_storage *sp,
910 if(!krb5_storage_is_flags(sp, KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE)) {
911 ret = krb5_store_int32(sp, p->name.name_type);
914 if(krb5_storage_is_flags(sp, KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS))
915 ret = krb5_store_int32(sp, p->name.name_string.len + 1);
917 ret = krb5_store_int32(sp, p->name.name_string.len);
920 ret = krb5_store_string(sp, p->realm);
923 ret = krb5_store_string(sp, p->name.name_string.val[i]);
932 * @param sp the storage buffer to read from
941 krb5_ret_principal(krb5_storage *sp,
954 if(krb5_storage_is_flags(sp, KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE))
956 else if((ret = krb5_ret_int32(sp, &type))){
960 if((ret = krb5_ret_int32(sp, &ncomp))){
964 if(krb5_storage_is_flags(sp, KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS))
970 ret = size_too_large_num(sp, ncomp, sizeof(p->name.name_string.val[0]));
977 ret = krb5_ret_string(sp, &p->realm);
989 ret = krb5_ret_string(sp, &p->name.name_string.val[i]);
1005 * @param sp the storage buffer to write to
1014 krb5_store_keyblock(krb5_storage *sp, krb5_keyblock p)
1017 ret = krb5_store_int16(sp, p.keytype);
1020 if(krb5_storage_is_flags(sp, KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE)){
1023 ret = krb5_store_int16(sp, p.keytype);
1027 ret = krb5_store_data(sp, p.keyvalue);
1034 * @param sp the storage buffer to write to
1043 krb5_ret_keyblock(krb5_storage *sp, krb5_keyblock *p)
1048 ret = krb5_ret_int16(sp, &tmp);
1052 if(krb5_storage_is_flags(sp, KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE)){
1053 ret = krb5_ret_int16(sp, &tmp);
1057 ret = krb5_ret_data(sp, &p->keyvalue);
1064 * @param sp the storage buffer to write to
1073 krb5_store_times(krb5_storage *sp, krb5_times times)
1076 ret = krb5_store_int32(sp, times.authtime);
1078 ret = krb5_store_int32(sp, times.starttime);
1080 ret = krb5_store_int32(sp, times.endtime);
1082 ret = krb5_store_int32(sp, times.renew_till);
1089 * @param sp the storage buffer to write to
1098 krb5_ret_times(krb5_storage *sp, krb5_times *times)
1102 ret = krb5_ret_int32(sp, &tmp);
1105 ret = krb5_ret_int32(sp, &tmp);
1108 ret = krb5_ret_int32(sp, &tmp);
1111 ret = krb5_ret_int32(sp, &tmp);
1119 * @param sp the storage buffer to write to
1128 krb5_store_address(krb5_storage *sp, krb5_address p)
1131 ret = krb5_store_int16(sp, p.addr_type);
1133 ret = krb5_store_data(sp, p.address);
1140 * @param sp the storage buffer to write to
1149 krb5_ret_address(krb5_storage *sp, krb5_address *adr)
1153 ret = krb5_ret_int16(sp, &t);
1156 ret = krb5_ret_data(sp, &adr->address);
1163 * @param sp the storage buffer to write to
1172 krb5_store_addrs(krb5_storage *sp, krb5_addresses p)
1176 ret = krb5_store_int32(sp, p.len);
1179 ret = krb5_store_address(sp, p.val[i]);
1188 * @param sp the storage buffer to write to
1197 krb5_ret_addrs(krb5_storage *sp, krb5_addresses *adr)
1203 ret = krb5_ret_int32(sp, &tmp);
1205 ret = size_too_large_num(sp, tmp, sizeof(adr->val[0]));
1212 ret = krb5_ret_address(sp, &adr->val[i]);
1221 * @param sp the storage buffer to write to
1230 krb5_store_authdata(krb5_storage *sp, krb5_authdata auth)
1234 ret = krb5_store_int32(sp, auth.len);
1237 ret = krb5_store_int16(sp, auth.val[i].ad_type);
1239 ret = krb5_store_data(sp, auth.val[i].ad_data);
1248 * @param sp the storage buffer to write to
1257 krb5_ret_authdata(krb5_storage *sp, krb5_authdata *auth)
1263 ret = krb5_ret_int32(sp, &tmp);
1265 ret = size_too_large_num(sp, tmp, sizeof(auth->val[0]));
1271 ret = krb5_ret_int16(sp, &tmp2);
1274 ret = krb5_ret_data(sp, &auth->val[i].ad_data);
1295 * @param sp the storage buffer to write to
1304 krb5_store_creds(krb5_storage *sp, krb5_creds *creds)
1308 ret = krb5_store_principal(sp, creds->client);
1311 ret = krb5_store_principal(sp, creds->server);
1314 ret = krb5_store_keyblock(sp, creds->session);
1317 ret = krb5_store_times(sp, creds->times);
1320 ret = krb5_store_int8(sp, creds->second_ticket.length != 0); /* is_skey */
1324 if(krb5_storage_is_flags(sp, KRB5_STORAGE_CREDS_FLAGS_WRONG_BITORDER))
1325 ret = krb5_store_int32(sp, creds->flags.i);
1327 ret = krb5_store_int32(sp, bitswap32(TicketFlags2int(creds->flags.b)));
1331 ret = krb5_store_addrs(sp, creds->addresses);
1334 ret = krb5_store_authdata(sp, creds->authdata);
1337 ret = krb5_store_data(sp, creds->ticket);
1340 ret = krb5_store_data(sp, creds->second_ticket);
1347 * @param sp the storage buffer to write to
1356 krb5_ret_creds(krb5_storage *sp, krb5_creds *creds)
1363 ret = krb5_ret_principal (sp, &creds->client);
1365 ret = krb5_ret_principal (sp, &creds->server);
1367 ret = krb5_ret_keyblock (sp, &creds->session);
1369 ret = krb5_ret_times (sp, &creds->times);
1371 ret = krb5_ret_int8 (sp, &dummy8);
1373 ret = krb5_ret_int32 (sp, &dummy32);
1392 ret = krb5_ret_addrs (sp, &creds->addresses);
1394 ret = krb5_ret_authdata (sp, &creds->authdata);
1396 ret = krb5_ret_data (sp, &creds->ticket);
1398 ret = krb5_ret_data (sp, &creds->second_ticket);
1419 * @param sp the storage buffer to write to
1428 krb5_store_creds_tag(krb5_storage *sp, krb5_creds *creds)
1448 ret = krb5_store_int32(sp, header);
1453 ret = krb5_store_principal(sp, creds->client);
1459 ret = krb5_store_principal(sp, creds->server);
1465 ret = krb5_store_keyblock(sp, creds->session);
1470 ret = krb5_store_times(sp, creds->times);
1473 ret = krb5_store_int8(sp, creds->second_ticket.length != 0); /* is_skey */
1477 ret = krb5_store_int32(sp, bitswap32(TicketFlags2int(creds->flags.b)));
1482 ret = krb5_store_addrs(sp, creds->addresses);
1488 ret = krb5_store_authdata(sp, creds->authdata);
1494 ret = krb5_store_data(sp, creds->ticket);
1500 ret = krb5_store_data(sp, creds->second_ticket);
1511 * @param sp the storage buffer to write to
1520 krb5_ret_creds_tag(krb5_storage *sp,
1529 ret = krb5_ret_int32 (sp, &header);
1533 ret = krb5_ret_principal (sp, &creds->client);
1537 ret = krb5_ret_principal (sp, &creds->server);
1541 ret = krb5_ret_keyblock (sp, &creds->session);
1544 ret = krb5_ret_times (sp, &creds->times);
1546 ret = krb5_ret_int8 (sp, &dummy8);
1548 ret = krb5_ret_int32 (sp, &dummy32);
1568 ret = krb5_ret_addrs (sp, &creds->addresses);
1572 ret = krb5_ret_authdata (sp, &creds->authdata);
1576 ret = krb5_ret_data (sp, &creds->ticket);
1580 ret = krb5_ret_data (sp, &creds->second_ticket);