#include #include #include #include #ifndef _DISPLAY_BAR_H_ #define _DISPLAY_BAR_H_ //declare for raw operation typedef unsigned raw_progress_bar_t; void lock_scrolled(); void unlock_scrolled(); void add_scrolled_unlocked(unsigned int i); raw_progress_bar_t create_raw_progress_bar(); void RawDisplayProgressBar(raw_progress_bar_t bar,size_t offset,size_t total,const char * filename); //you should call before using progrees bar. void ready_progress_bar(); //quit progress bar system. void quit_progress_bar(); //same as isatty bool isatty_file(FILE * file); //After calling ready_progress_bar, you must use following functions on print. void myd_perror(const char * msg); //argument `line` is number of newline created by argument `msg`. int myd_vfprintf(int line,FILE * f,const char * msg,va_list arg); //argument `line` is number of newline created by argument `msg`. int myd_fprintf(int line,FILE * f,const char * msg, ...); typedef struct { raw_progress_bar_t bar; //millisecond unit int update_rate; struct timespec last_update; } progress_bar_t; //update rate is millsecond unit void init_progress_bar(progress_bar_t * bar,int update_rate); /// display progress bar /// if `sync`, update unconditionally. void DisplayProgressBar(progress_bar_t * bar,size_t offset,size_t total,const char * filename, bool sync); #endif