static void test_otrl_instag_read_FILEp(void) { FILE* instf = fopen(instag_filepath, "rb"); OtrlUserState us = otrl_userstate_create(); OtrlInsTag* one, *two, *three, *four; char sone[9] = {0}, stwo[9] = {0}, sfour[9] = {0}; one = two = three = four = NULL; ok(otrl_instag_read_FILEp(us, instf) == gcry_error(GPG_ERR_NO_ERROR), "Instead read from FILEp"); fclose(instf); one = otrl_instag_find(us, "alice_xmpp", "XMPP"); snprintf(sone, sizeof(sone), "%08x", one->instag); two = otrl_instag_find(us, "alice_irc", "IRC"); snprintf(stwo, sizeof(stwo), "%08x", two->instag); three = otrl_instag_find(us, "alice_inv", "IRC"); four = otrl_instag_find(us, "alice_icq", "ICQ"); snprintf(sfour, sizeof(sfour), "%08x", four->instag); ok(one && two && !three && four && strcmp(sone, "01234567") == 0 && strcmp(stwo, "9abcdef0") == 0 && strcmp(sfour, "98765432") == 0, "Instag succesfully read"); }
/* Read our instance tag from a file on disk into the given * OtrlUserState. */ gcry_error_t otrl_instag_read(OtrlUserState us, const char *filename) { gcry_error_t err; FILE *instf; /* Open the instance tag file. */ instf = fopen(filename, "rb"); if (!instf) { return gcry_error_from_errno(errno); } err = otrl_instag_read_FILEp(us, instf); fclose(instf); return err; }