I am working on a program that uses interrupts and a buffer to read/write characters from/to the console screen. (This is a tty.c program with ttywrite(), ttyread(), ect...)
I also have a given queue folder, which contains queue.c that has the methods:
int init_queue(Queue *q, int max_chars); make a new empty queue, filling in *q
int enqueue(Queue *q,char ch); enqueue char ch on q, or return -1 if can't
int dequeue(Queue *q); dequeue a char and return it, or return -1 if can't
int queuecount(Queue *q); return # chars currently in queue q
Along with queue.h, which mainly contains:
typedef struct queue {
char ch[MAXCHARBUF]; /* char contain in queue */
int front; /* front index of queue */
int rear; /* rear index of queue */
int count; /* current numbers of element in queue */
int max; /* actually use length */
} Queue;
along with some of the method headers and defined variables.
In the separate file tty.c where I am hoping to replace the buffers with queues, how can I develop a queue struct atop of the program that allows me to make instances of queue.c?
I am new to C (coming from C#/Java) and am lost trying to wrap my head around the logic.
Any advice will be greatly appreciated and needed.