bool store_tokens_to_file(std::string file_name, const evl_tokens &tokens) { std::ofstream output_file(file_name.c_str()); if(!output_file) { std::cerr << "I can't write Token file" << std::endl; return false; } display_tokens(output_file, tokens); std::cout << file_name << std::endl; return true; }
//This function opens an output file stream from the file name passed to it and forwards it to "display_tokens" bool store_tokens_to_file(string inputfilename, const evl_tokens tokens) { string outputfilename = inputfilename; outputfilename += ".tokens"; ofstream outfile(outputfilename.c_str()); if (!outfile) { cerr << "This file cannot be written to!" << endl; return false; } display_tokens(outfile, tokens); return true; }
int klist(struct klist_options *opt, int argc, char **argv) { krb5_error_code ret; int exit_status = 0; int do_verbose = opt->verbose_flag || opt->a_flag || opt->n_flag; int do_test = opt->test_flag || opt->s_flag; if (opt->list_all_flag) { exit_status = list_caches(kcc_context); return exit_status; } if (opt->v5_flag) { krb5_ccache id; if (opt->all_content_flag) { krb5_cc_cache_cursor cursor; ret = krb5_cc_cache_get_first(kcc_context, NULL, &cursor); if (ret) krb5_err(kcc_context, 1, ret, "krb5_cc_cache_get_first"); while (krb5_cc_cache_next(kcc_context, cursor, &id) == 0) { exit_status |= display_v5_ccache(kcc_context, id, do_test, do_verbose, opt->flags_flag, opt->hidden_flag); printf("\n\n"); } krb5_cc_cache_end_seq_get(kcc_context, cursor); } else { if(opt->cache_string) { ret = krb5_cc_resolve(kcc_context, opt->cache_string, &id); if (ret) krb5_err(kcc_context, 1, ret, "%s", opt->cache_string); } else { ret = krb5_cc_default(kcc_context, &id); if (ret) krb5_err(kcc_context, 1, ret, "krb5_cc_resolve"); } exit_status = display_v5_ccache(kcc_context, id, do_test, do_verbose, opt->flags_flag, opt->hidden_flag); } } if (!do_test) { #ifndef NO_AFS if (opt->tokens_flag && k_hasafs()) { if (opt->v5_flag) printf("\n"); display_tokens(opt->verbose_flag); } #endif } return exit_status; }