HW12/display_bar.h
ubuntu201711081 f2e8bf2376 add comment
2020-12-14 10:19:49 +00:00

40 lines
1.0 KiB
C

#include<stdio.h>
#include<time.h>
#include<stdbool.h>
#include<stddef.h>
#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);
//
void myd_perror(const char * msg);
int myd_vfprintf(int line,FILE * f,const char * msg,va_list arg);
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);
void DisplayProgressBar(progress_bar_t * bar,size_t offset,size_t total,const char * filename, bool sync);
#endif