libwget-progress(3)

NAME
libwget-progress - Progress Display Functions

SYNOPSIS

  Data Structures
struct bar_slot
struct wget_bar_st

  Enumerations
enum BAR_SIZES { BAR_FILENAME_SIZE = 20, BAR_RATIO_SIZE = 3, BAR_METER_COST = 2, BAR_DOWNBYTES_SIZE = 8, BAR_SPEED_SIZE = 8 }
enum BAR_DECOR_SIZE { BAR_DECOR_COST }
enum SCREEN_WIDTH { DEFAULT_SCREEN_WIDTH = 70, MINIMUM_SCREEN_WIDTH = BAR_DECOR_COST }
enum bar_slot_status { EMPTY = 0, DOWNLOADING = 1, COMPLETE = 2 }
enum BAR_SETTINGS { SPEED_RING_SIZE = 24 }

  Functions
wget_bar * wget_bar_init (wget_bar *bar, int nslots)
void wget_bar_set_slots (wget_bar *bar, int nslots)
void wget_bar_slot_begin (wget_bar *bar, int slot, const char *filename, int new_file, ssize_t file_size)
void wget_bar_slot_downloaded (wget_bar *bar, int slot, size_t nbytes)
void wget_bar_slot_deregister (wget_bar *bar, int slot)
void wget_bar_update (wget_bar *bar)
void wget_bar_deinit (wget_bar *bar)
void wget_bar_free (wget_bar **bar)
void wget_bar_print (wget_bar *bar, int slot, const char *display)
void wget_bar_vprintf (wget_bar *bar, int slot, const char *fmt, va_list args)
void wget_bar_printf (wget_bar *bar, int slot, const char *fmt,...)
void wget_bar_screen_resized (void)
void wget_bar_write_line (wget_bar *bar, const char *buf, size_t len)
void wget_bar_write_line_ext (wget_bar *bar, const char *buf, size_t len, const char *pre, const char *post)
void wget_bar_set_speed_type (wget_report_speed type)

Detailed Description

Methods for creating and printing a progress bar display.

Enumeration Type Documentation

  enum BAR_SETTINGS
The settings for drawing the progress bar.

This includes things like how often it is updated, how many values are stored in the speed ring, etc.

Enumerator

SPEED_RING_SIZE
    The number of values to store in the speed ring.

Function Documentation

  wget_bar * wget_bar_init (wget_bar * bar, int nslots)

Parameters
    bar Pointer to a wget_bar object
    nslots Number of progress bars

Returns
    Pointer to a wget_bar object

Initialize a new progress bar instance. If bar is a NULL pointer, it will be allocated on the heap and a pointer to the newly allocated memory will be returned. To free this memory, call either the wget_bar_deinit() or wget_bar_free() functions based on your needs.

nslots is the number of screen lines to reserve for printing the progress bars. This may be any number, but you generally want at least as many slots as there are downloader threads.

  void wget_bar_set_slots (wget_bar * bar, int nslots)

Parameters
    bar Pointer to a wget_bar object
    nslots The new number of progress bars that should be drawn

Update the number of progress bar lines that are drawn on the screen. This is useful when the number of downloader threads changes dynamically or to change the number of reserved lines. Calling this function will immediately reserve nslots lines on the screen. However if nslots is lower than the existing value, nothing will be done.

  void wget_bar_slot_begin (wget_bar * bar, int slot, const char * filename, int new_file, ssize_t file_size)

Parameters
    bar Pointer to a wget_bar object
    slot The slot number to use
    filename The file name to display in the given slot
    new_file if this is the start of a download of the body of a new file (unused)
    file_size The file size that would be 100%

Initialize the given slot of the bar object with it's (file) name to display and the (file) size to be assumed 100%.

  void wget_bar_slot_downloaded (wget_bar * bar, int slot, size_t nbytes)

Parameters
    bar Pointer to a wget_bar object
    slot The slot number to use
    nbytes The number of bytes downloaded since the last invocation of this function

Set the current number of bytes for slot for the next update of the bar/slot.

  void wget_bar_slot_deregister (wget_bar * bar, int slot)

Parameters
    bar Pointer to a wget_bar object
    slot The slot number to use

Redraw the given slot as being completed.

  void wget_bar_update (wget_bar * bar)

Parameters
    bar Pointer to a wget_bar object

Redraw the parts of the bar that have been changed so far.

  void wget_bar_deinit (wget_bar * bar)

Parameters
    bar Pointer to wget_bar

Free the various progress bar data structures without freeing bar itself.

  void wget_bar_free (wget_bar ** bar)

Parameters
    bar Pointer to wget_bar

Free the various progress bar data structures including the bar pointer itself.

  void wget_bar_print (wget_bar * bar, int slot, const char * display)

Parameters
    bar Pointer to wget_bar
    slot The slot number to use
    display The string to be displayed in the given slot

Displays the display string in the given slot.

  void wget_bar_vprintf (wget_bar * bar, int slot, const char * fmt, va_list args)

Parameters
    bar Pointer to wget_bar
    slot The slot number to use
    fmt Printf-like format to build the display string
    args Arguments matching the fmt format string

Displays the string build using the printf-style fmt and args.

  void wget_bar_printf (wget_bar * bar, int slot, const char * fmt, ...)

Parameters
    bar Pointer to wget_bar
    slot The slot number to use
    fmt Printf-like format to build the display string
    ... List of arguments to match fmt

Displays the string build using the printf-style fmt and the given arguments.

  void wget_bar_screen_resized (void )
Call this function when a resize of the screen / console has been detected.

  void wget_bar_write_line (wget_bar * bar, const char * buf, size_t len)

Parameters
    bar Pointer to wget_bar
    buf Pointer to buffer to be displayed
    len Number of bytes to be displayed

Write 'above' the progress bar area, scrolls screen one line up if needed. Currently used by Wget2 to display error messages in color red.

This function needs a redesign to be useful for general purposes.

  void wget_bar_write_line_ext (wget_bar * bar, const char * buf, size_t len, const char * pre, const char * post)

Parameters
    bar Pointer to wget_bar
    buf Pointer to buffer to be displayed
    len Number of bytes to be displayed

Write 'above' the progress bar area, scrolls screen one line up if needed. Currently used by Wget2 to display error messages in color red.

This function needs a redesign to be useful for general purposes.

  void wget_bar_set_speed_type (wget_report_speed type)

Parameters
    type Report speed type

Set the progress bar report speed type to WGET_REPORT_SPEED_BYTES or WGET_REPORT_SPEED_BITS.

Default is WGET_REPORT_SPEED_BYTES.

Author

Generated automatically by Doxygen for wget2 from the source code.