Skip to content

Commit

Permalink
update header
Browse files Browse the repository at this point in the history
  • Loading branch information
briandowns committed Sep 10, 2019
1 parent a45aadb commit c8cb818
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
57 changes: 34 additions & 23 deletions spinner.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define _SPINNER_H

#include <pthread.h>
#include <stdint.h>
#include <sys/types.h>

/*
Expand All @@ -42,73 +43,83 @@
/*
* char_sets is the collection of spinners.
*/
extern char *char_sets[][MAX_CHARS];
extern char* char_sets[][MAX_CHARS];

/*
* spinner_t maintains the state of the spinner
* and allows for control.
*/
typedef struct {
uint8_t char_set_id;
uint64_t delay;
pthread_mutex_t mu;
FILE *output_dst;
char *prefix;
char *suffix;
char *final_msg;
char *last_output;
int active;
int reversed;
typedef struct
{
uint8_t char_set_id;
uint64_t delay;
pthread_mutex_t mu;
FILE* output_dst;
char* prefix;
char* suffix;
char* final_msg;
char* last_output;
int active;
int reversed;
} spinner_t;

/*
* spinner_new creates a new pointer to a spinner_t
* struct and sets sane defaults for immediate use.
*/
spinner_t *spinner_new(int id);
spinner_t*
spinner_new(int id);

/*
* spinner_free frees the used memory of the
* spinner_free frees the used memory of the
* spinner_t pointer.
*/
void spinner_free(spinner_t *s);
void
spinner_free(spinner_t* s);

/*
* spinner_start starts the spinner.
*/
void spinner_start(spinner_t *s);
void
spinner_start(spinner_t* s);

/*
* spinner_stop stops the spinner.
*/
void spinner_stop(spinner_t *s);
void
spinner_stop(spinner_t* s);

/*
* spinner_restart will restart the spinner.
*/
void spinner_restart(spinner_t *s);
void
spinner_restart(spinner_t* s);

/*
* spinner_char_set_update updates the character
* set with the new given one.
*/
void spinner_char_set_update(spinner_t *s, const int id);
void
spinner_char_set_update(spinner_t* s, const int id);

/*
* spinner_update_speed updates the speed at which
* the spinner is spinning.
*/
void spinner_update_speed(spinner_t *s, const uint64_t delay);
void
spinner_update_speed(spinner_t* s, const uint64_t delay);

/*
* spinner_set_output_dest sets the file descriptor to
* spinner_set_output_dest sets the file descriptor to
* write spinner output to.
*/
void spinner_set_output_dest(spinner_t *s, FILE *fd);
void
spinner_set_output_dest(spinner_t* s, FILE* fd);

/*
* spinner_reverse reverses the direction of the spinner.
*/
void spinner_reverse(spinner_t *s);
void
spinner_reverse(spinner_t* s);

#endif
1 change: 0 additions & 1 deletion tests/tests.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
Expand Down

0 comments on commit c8cb818

Please sign in to comment.