void print_error_messages ( FILE *fd, char const *source, STRTAB_str_t source_id, error_log_rec_t *log_rec_ptr ) { if (log_rec_ptr->links.asBinTree.left != NULL) print_error_messages(fd, source, source_id, log_rec_ptr->links.asBinTree.left); print_errors_for_line(fd, source, source_id, log_rec_ptr); if (log_rec_ptr->links.asBinTree.right != NULL) print_error_messages(fd, source, source_id, log_rec_ptr->links.asBinTree.right); }
boolean print_errors ( void ) { FILE *fd; char const *fn; int i; STRTAB_str_t source_id; error_log_rec_t *error_root; /* * If there are no errors, just return */ if (errors == NULL) return 0; /* * Copy the root of the error tree and null it out so that * it looks like all the errors have been printed if we get * an error while printing them out. */ error_root = errors; errors = NULL; /* * Loop through all files with errors */ for (i = 0; i < error_file_count; i++) { source_id = error_files[i]; STRTAB_str_to_string(source_id, &fn); fd = fopen(fn, "r"); print_error_messages(fd, fn, source_id, error_root); last_error_line = 0; } /* * Free the tree of errors, */ free_log_rec(error_root); error_file_count = 0; /* * Return true if we found any errors. */ return (error_file_count != 0); }
int output_dirsync_status(music_query_t* music_query){ int i = 0; apr_bucket_brigade* output_bb = music_query->output->bucket_brigade; apr_table_add(music_query->output->headers,"Access-Control-Allow-Origin", "*"); apr_cpystrn((char*)music_query->output->content_type, "application/json", 255); apr_brigade_puts(music_query->output->bucket_brigade, NULL,NULL, "{\n"); //Print Status if(music_query->globals->music_dirs != NULL){ apr_brigade_puts(output_bb, NULL,NULL,"\t\"dir_sync_status\" : {\n"); for(i = 0; i < music_query->globals->music_dirs->nelts; i++){ dir_t* dir = &(((dir_t*)music_query->globals->music_dirs->elts)[i]); apr_brigade_printf(output_bb, NULL, NULL, "\t\t\"%s\" : {\n",dir->path); apr_brigade_printf(output_bb, NULL,NULL, "\t\t\"Progress\" : \"%.2f\",\n",dir->stats->sync_progress); apr_brigade_printf(output_bb, NULL,NULL, "\t\t\"Files Scanned\" : \"%d\"\n", dir->stats->files_scanned); apr_brigade_printf(output_bb, NULL, NULL, "\t\t}"); if(i < (music_query->globals->music_dirs->nelts - 1)){ apr_brigade_printf(output_bb, NULL, NULL, ","); } } apr_brigade_puts(output_bb, NULL,NULL,"\t},\n"); } apr_brigade_puts(output_bb, NULL,NULL,"\t\"db_status\" : "); output_db_result_json(music_query->results,music_query->db_query,music_query->output); apr_brigade_puts(output_bb, NULL,NULL,"\n,"); print_error_messages(music_query->pool,output_bb, music_query->error_messages); apr_brigade_puts(output_bb, NULL,NULL,"\n}\n"); return 0; }