Lines Matching +full:block +full:- +full:fetch

2  * Copyright (c) 1997-2008 Kungliga Tekniska Högskolan
35 #include "store-int.h"
37 #define BYTEORDER_IS(SP, V) (((SP)->flags & KRB5_STORAGE_BYTEORDER_MASK) == (V))
44 * Add the flags on a storage buffer by or-ing in the flags to the buffer.
55 sp->flags |= flags; in krb5_storage_set_flags()
70 sp->flags &= ~flags; in krb5_storage_clear_flags()
88 return (sp->flags & flags) == flags; in krb5_storage_is_flags()
106 sp->flags &= ~KRB5_STORAGE_BYTEORDER_MASK; in krb5_storage_set_byteorder()
107 sp->flags |= byteorder; in krb5_storage_set_byteorder()
119 return sp->flags & KRB5_STORAGE_BYTEORDER_MASK; in krb5_storage_get_byteorder()
134 sp->max_alloc = size; in krb5_storage_set_max_alloc()
141 if (sp->max_alloc && sp->max_alloc < size) in size_too_large()
149 if (sp->max_alloc == 0 || size == 0) in size_too_large_num()
151 size = sp->max_alloc / size; in size_too_large_num()
173 return (*sp->seek)(sp, offset, whence); in krb5_storage_seek()
190 return (*sp->trunc)(sp, offset); in krb5_storage_truncate()
208 return sp->fetch(sp, buf, len); in krb5_storage_read()
226 return sp->store(sp, buf, len); in krb5_storage_write()
241 sp->eof_code = code; in krb5_storage_set_eof_code()
257 return sp->eof_code; in krb5_storage_get_eof_code()
273 if(sp->free) in krb5_storage_free()
274 (*sp->free)(sp); in krb5_storage_free()
275 free(sp->data); in krb5_storage_free()
297 pos = sp->seek(sp, 0, SEEK_CUR); in krb5_storage_to_data()
300 size = sp->seek(sp, 0, SEEK_END); in krb5_storage_to_data()
306 sp->seek(sp, pos, SEEK_SET); in krb5_storage_to_data()
310 sp->seek(sp, 0, SEEK_SET); in krb5_storage_to_data()
311 sp->fetch(sp, data->data, data->length); in krb5_storage_to_data()
312 sp->seek(sp, pos, SEEK_SET); in krb5_storage_to_data()
328 ret = sp->store(sp, v, len); in krb5_store_int()
332 return sp->eof_code; in krb5_store_int()
386 ret = sp->fetch(sp, v, len); in krb5_ret_int()
390 return sp->eof_code; in krb5_ret_int()
562 ret = sp->store(sp, &value, sizeof(value)); in krb5_store_int8()
564 return (ret<0)?errno:sp->eof_code; in krb5_store_int8()
603 ret = sp->fetch(sp, value, sizeof(*value)); in krb5_ret_int8()
605 return (ret<0)?errno:sp->eof_code; in krb5_ret_int8()
654 ret = sp->store(sp, data.data, data.length); in krb5_store_data()
658 return sp->eof_code; in krb5_store_data()
690 ret = sp->fetch(sp, data->data, size); in krb5_ret_data()
692 return (ret < 0)? errno : sp->eof_code; in krb5_ret_data()
766 ret = sp->store(sp, s, len); in krb5_store_stringz()
770 return sp->eof_code; in krb5_store_stringz()
794 while((ret = sp->fetch(sp, &c, 1)) == 1){ in krb5_ret_stringz()
807 s[len - 1] = c; in krb5_ret_stringz()
814 return sp->eof_code; in krb5_ret_stringz()
827 ret = sp->store(sp, s, len); in krb5_store_stringnl()
831 return sp->eof_code; in krb5_store_stringnl()
832 ret = sp->store(sp, "\n", 1); in krb5_store_stringnl()
837 return sp->eof_code; in krb5_store_stringnl()
854 while((ret = sp->fetch(sp, &c, 1)) == 1){ in krb5_ret_stringnl()
877 s[len - 1] = '\0'; in krb5_ret_stringnl()
880 s[len - 1] = c; in krb5_ret_stringnl()
885 return sp->eof_code; in krb5_ret_stringnl()
893 * Write a principal block to storage.
896 * @param p the principal block to write.
911 ret = krb5_store_int32(sp, p->name.name_type); in krb5_store_principal()
915 ret = krb5_store_int32(sp, p->name.name_string.len + 1); in krb5_store_principal()
917 ret = krb5_store_int32(sp, p->name.name_string.len); in krb5_store_principal()
920 ret = krb5_store_string(sp, p->realm); in krb5_store_principal()
922 for(i = 0; i < p->name.name_string.len; i++){ in krb5_store_principal()
923 ret = krb5_store_string(sp, p->name.name_string.val[i]); in krb5_store_principal()
965 ncomp--; in krb5_ret_principal()
970 ret = size_too_large_num(sp, ncomp, sizeof(p->name.name_string.val[0])); in krb5_ret_principal()
975 p->name.name_type = type; in krb5_ret_principal()
976 p->name.name_string.len = ncomp; in krb5_ret_principal()
977 ret = krb5_ret_string(sp, &p->realm); in krb5_ret_principal()
982 p->name.name_string.val = calloc(ncomp, sizeof(p->name.name_string.val[0])); in krb5_ret_principal()
983 if(p->name.name_string.val == NULL && ncomp != 0){ in krb5_ret_principal()
984 free(p->realm); in krb5_ret_principal()
989 ret = krb5_ret_string(sp, &p->name.name_string.val[i]); in krb5_ret_principal()
992 free(p->name.name_string.val[i--]); in krb5_ret_principal()
993 free(p->realm); in krb5_ret_principal()
1050 p->keytype = tmp; in krb5_ret_keyblock()
1057 ret = krb5_ret_data(sp, &p->keyvalue); in krb5_ret_keyblock()
1062 * Write a times block to storage.
1065 * @param times the times block to write.
1087 * Read a times block from the storage.
1090 * @param times the times block read from storage
1103 times->authtime = tmp; in krb5_ret_times()
1106 times->starttime = tmp; in krb5_ret_times()
1109 times->endtime = tmp; in krb5_ret_times()
1112 times->renew_till = tmp; in krb5_ret_times()
1117 * Write a address block to storage.
1120 * @param p the address block to write.
1138 * Read a address block from the storage.
1141 * @param adr the address block read from storage
1155 adr->addr_type = t; in krb5_ret_address()
1156 ret = krb5_ret_data(sp, &adr->address); in krb5_ret_address()
1161 * Write a addresses block to storage.
1164 * @param p the addresses block to write.
1186 * Read a addresses block from the storage.
1189 * @param adr the addresses block read from storage
1205 ret = size_too_large_num(sp, tmp, sizeof(adr->val[0])); in krb5_ret_addrs()
1207 adr->len = tmp; in krb5_ret_addrs()
1208 ALLOC(adr->val, adr->len); in krb5_ret_addrs()
1209 if (adr->val == NULL && adr->len != 0) in krb5_ret_addrs()
1211 for(i = 0; i < adr->len; i++){ in krb5_ret_addrs()
1212 ret = krb5_ret_address(sp, &adr->val[i]); in krb5_ret_addrs()
1219 * Write a auth data block to storage.
1222 * @param auth the auth data block to write.
1249 * @param auth the auth data block read from storage
1265 ret = size_too_large_num(sp, tmp, sizeof(auth->val[0])); in krb5_ret_authdata()
1268 if (auth->val == NULL && tmp != 0) in krb5_ret_authdata()
1273 auth->val[i].ad_type = tmp2; in krb5_ret_authdata()
1274 ret = krb5_ret_data(sp, &auth->val[i].ad_data); in krb5_ret_authdata()
1293 * Write a credentials block to storage.
1296 * @param creds the creds block to write.
1308 ret = krb5_store_principal(sp, creds->client); in krb5_store_creds()
1311 ret = krb5_store_principal(sp, creds->server); in krb5_store_creds()
1314 ret = krb5_store_keyblock(sp, creds->session); in krb5_store_creds()
1317 ret = krb5_store_times(sp, creds->times); in krb5_store_creds()
1320 ret = krb5_store_int8(sp, creds->second_ticket.length != 0); /* is_skey */ in krb5_store_creds()
1325 ret = krb5_store_int32(sp, creds->flags.i); in krb5_store_creds()
1327 ret = krb5_store_int32(sp, bitswap32(TicketFlags2int(creds->flags.b))); in krb5_store_creds()
1331 ret = krb5_store_addrs(sp, creds->addresses); in krb5_store_creds()
1334 ret = krb5_store_authdata(sp, creds->authdata); in krb5_store_creds()
1337 ret = krb5_store_data(sp, creds->ticket); in krb5_store_creds()
1340 ret = krb5_store_data(sp, creds->second_ticket); in krb5_store_creds()
1345 * Read a credentials block from the storage.
1348 * @param creds the credentials block read from storage
1363 ret = krb5_ret_principal (sp, &creds->client); in krb5_ret_creds()
1365 ret = krb5_ret_principal (sp, &creds->server); in krb5_ret_creds()
1367 ret = krb5_ret_keyblock (sp, &creds->session); in krb5_ret_creds()
1369 ret = krb5_ret_times (sp, &creds->times); in krb5_ret_creds()
1384 creds->flags.i = 0; in krb5_ret_creds()
1385 creds->flags.b.anonymous = 1; in krb5_ret_creds()
1386 if (creds->flags.i & mask) in krb5_ret_creds()
1391 creds->flags.i = dummy32; in krb5_ret_creds()
1392 ret = krb5_ret_addrs (sp, &creds->addresses); in krb5_ret_creds()
1394 ret = krb5_ret_authdata (sp, &creds->authdata); in krb5_ret_creds()
1396 ret = krb5_ret_data (sp, &creds->ticket); in krb5_ret_creds()
1398 ret = krb5_ret_data (sp, &creds->second_ticket); in krb5_ret_creds()
1417 * Write a tagged credentials block to storage.
1420 * @param creds the creds block to write.
1433 if (creds->client) in krb5_store_creds_tag()
1435 if (creds->server) in krb5_store_creds_tag()
1437 if (creds->session.keytype != ETYPE_NULL) in krb5_store_creds_tag()
1439 if (creds->ticket.data) in krb5_store_creds_tag()
1441 if (creds->second_ticket.length) in krb5_store_creds_tag()
1443 if (creds->authdata.len) in krb5_store_creds_tag()
1445 if (creds->addresses.len) in krb5_store_creds_tag()
1452 if (creds->client) { in krb5_store_creds_tag()
1453 ret = krb5_store_principal(sp, creds->client); in krb5_store_creds_tag()
1458 if (creds->server) { in krb5_store_creds_tag()
1459 ret = krb5_store_principal(sp, creds->server); in krb5_store_creds_tag()
1464 if (creds->session.keytype != ETYPE_NULL) { in krb5_store_creds_tag()
1465 ret = krb5_store_keyblock(sp, creds->session); in krb5_store_creds_tag()
1470 ret = krb5_store_times(sp, creds->times); in krb5_store_creds_tag()
1473 ret = krb5_store_int8(sp, creds->second_ticket.length != 0); /* is_skey */ in krb5_store_creds_tag()
1477 ret = krb5_store_int32(sp, bitswap32(TicketFlags2int(creds->flags.b))); in krb5_store_creds_tag()
1481 if (creds->addresses.len) { in krb5_store_creds_tag()
1482 ret = krb5_store_addrs(sp, creds->addresses); in krb5_store_creds_tag()
1487 if (creds->authdata.len) { in krb5_store_creds_tag()
1488 ret = krb5_store_authdata(sp, creds->authdata); in krb5_store_creds_tag()
1493 if (creds->ticket.data) { in krb5_store_creds_tag()
1494 ret = krb5_store_data(sp, creds->ticket); in krb5_store_creds_tag()
1499 if (creds->second_ticket.data) { in krb5_store_creds_tag()
1500 ret = krb5_store_data(sp, creds->second_ticket); in krb5_store_creds_tag()
1509 * Read a tagged credentials block from the storage.
1512 * @param creds the credentials block read from storage
1533 ret = krb5_ret_principal (sp, &creds->client); in krb5_ret_creds_tag()
1537 ret = krb5_ret_principal (sp, &creds->server); in krb5_ret_creds_tag()
1541 ret = krb5_ret_keyblock (sp, &creds->session); in krb5_ret_creds_tag()
1544 ret = krb5_ret_times (sp, &creds->times); in krb5_ret_creds_tag()
1559 creds->flags.i = 0; in krb5_ret_creds_tag()
1560 creds->flags.b.anonymous = 1; in krb5_ret_creds_tag()
1561 if (creds->flags.i & mask) in krb5_ret_creds_tag()
1566 creds->flags.i = dummy32; in krb5_ret_creds_tag()
1568 ret = krb5_ret_addrs (sp, &creds->addresses); in krb5_ret_creds_tag()
1572 ret = krb5_ret_authdata (sp, &creds->authdata); in krb5_ret_creds_tag()
1576 ret = krb5_ret_data (sp, &creds->ticket); in krb5_ret_creds_tag()
1580 ret = krb5_ret_data (sp, &creds->second_ticket); in krb5_ret_creds_tag()