/* File: queues.h Author: Jim Mayfield This file provides access to the standard queue routines developed in CMSC 202. To use it: 1. Typedef the type `queue_item_type' in your program. Queue_item_type MUST BE NO LARGER THAN A POINTER TYPE! (So it's OK to use `int' for queue_item_type, but not an array or a struct). You can put a call to check_queue_item_size() at the top of your main program to make sure your list_item_type is of an appropriate size. 2. #include "queues.h" AFTER your definition of queue_item_type. 3. Compile your program so that it uses the 202 libraries. To do so, you will need add several items to your Makefile. Lines of the Makefile that create .o files will need to include `-I ~mayfield/lib202' immediately after the cc command, e.g.: cc -I ~mayfield/lib202 -g -c myfile.c Lines of the makefile that build executables will need to include `-L ~mayfield/lib202 -l202' immediately after the queue of .o files, e.g.: cc -o myprog myfile.o myfile_aux.o -L ~mayfield/lib202 -l202 */ #ifndef _CMSC_202_QUEUES_ #define _CMSC_202_QUEUES_ /* For check_queue_item_size: */ #include #include #include "basics.h" typedef struct queue_tag *queue_type; queue_type create_queue(void); void enqueue(queue_item_type item, queue_type q); queue_item_type dequeue(queue_type q); BOOL empty_queue(queue_type q); BOOL full_queue(queue_type q); #define check_queue_item_size() \ do { if (sizeof(queue_item_type) > sizeof(void *)) {\ fprintf(stderr, "Queue error: queue_item_type is larger than a pointer.\n"); \ exit(EXIT_FAILURE); \ }} while (0) #endif