157 lines
3.8 KiB
C
157 lines
3.8 KiB
C
/*
|
|
* data.h - Data structures for libglacier
|
|
*
|
|
* This file is part of Glacier.
|
|
*
|
|
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
|
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
|
* version 3 of the License, or (at your option) any later version.
|
|
*
|
|
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
|
* not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef GLACIERDATA_H_
|
|
#define GLACIERDATA_H_
|
|
|
|
/*
|
|
* create_node
|
|
*
|
|
* DESCRIPTION: Create_node creates a node for a dependency tree data structure.
|
|
* PARAMETERS:
|
|
* char *data -> The name of the node to create
|
|
* RETURN VALUES:
|
|
* None.
|
|
* CAVEATS:
|
|
* None.
|
|
* EXAMPLE:
|
|
* struct node package = create_node("Package");
|
|
*/
|
|
|
|
struct node *create_node(char *data);
|
|
|
|
/**************************************************************************************************************/
|
|
|
|
/*
|
|
* add_child
|
|
*
|
|
* DESCRIPTION: Add_child adds a child node to a parent node.
|
|
* PARAMETERS:
|
|
* struct node *parent -> The parent node which the child will be added to
|
|
* struct node *child -> The child node which will be added to the parent node
|
|
* RETURN VALUES:
|
|
* 1 on maximum children exceeded
|
|
* CAVEATS:
|
|
* None.
|
|
* EXAMPLE:
|
|
* add_child(package, dep1);
|
|
*/
|
|
|
|
void add_child(struct node *parent, struct node *child);
|
|
|
|
/**************************************************************************************************************/
|
|
|
|
/*
|
|
* print_tree
|
|
*
|
|
* DESCRIPTION: Print_tree prints a dependency tree specified at its root node
|
|
* PARAMETERS:
|
|
* struct node *root -> The tree to print
|
|
* int level -> The number of levels to descend
|
|
* RETURN VALUES:
|
|
* None.
|
|
* CAVEATS:
|
|
* None.
|
|
* EXAMPLE:
|
|
* print_tree(package, 0);
|
|
*/
|
|
|
|
void print_tree(struct node *root, int level);
|
|
|
|
/**************************************************************************************************************/
|
|
|
|
/*
|
|
* init_queue
|
|
*
|
|
* DESCRIPTION: Init_queue initializes a queue data structue.
|
|
* PARAMETERS:
|
|
* queue *q -> The name of the queue to initialize
|
|
* RETURN VALUES:
|
|
* None.
|
|
* CAVEATS:
|
|
* None.
|
|
* EXAMPLE:
|
|
* init_queue("operation_queue");
|
|
*/
|
|
|
|
void init_queue(queue *q);
|
|
|
|
/**************************************************************************************************************/
|
|
|
|
/*
|
|
* queue_is_empty
|
|
*
|
|
* DESCRIPTION: Queue_is_empty checks if queue *q is empty
|
|
* PARAMETERS:
|
|
* queue *q -> The queue to check
|
|
* RETURN VALUES:
|
|
* true on empty, false on not empty
|
|
* CAVEATS:
|
|
* None.
|
|
* EXAMPLE:
|
|
* if (queue_is_empty(q)) {
|
|
* printf("Queue is empty\n");
|
|
* return;
|
|
* }
|
|
*/
|
|
|
|
bool queue_is_empty(queue *q);
|
|
|
|
/**************************************************************************************************************/
|
|
|
|
/*
|
|
* queue_is_full
|
|
*
|
|
* DESCRIPTION: Queue_is_full checks if queue *q is full
|
|
* PARAMETERS:
|
|
* queue *q -> The queue to check
|
|
* RETURN VALUES:
|
|
* true on full, false on not full
|
|
* CAVEATS:
|
|
* None.
|
|
* EXAMPLE:
|
|
* if (queue_is_full(q)) {
|
|
* printf("Queue is full\n");
|
|
* return;
|
|
* }
|
|
*/
|
|
|
|
bool queue_is_full(queue *q);
|
|
|
|
/**************************************************************************************************************/
|
|
|
|
/*
|
|
* enqueue
|
|
*
|
|
* DESCRIPTION: Enqueue enqueues an element at the back of the queue
|
|
* PARAMETERS:
|
|
* queue *q -> The queue to enqueue to
|
|
* int value ->
|
|
* RETURN VALUES:
|
|
* true on full, false on not full
|
|
* CAVEATS:
|
|
* None.
|
|
* EXAMPLE:
|
|
* if (queue_is_full(q)) {
|
|
* printf("Queue is full\n");
|
|
* return;
|
|
* }
|
|
*/
|
|
|
|
|
|
#endif
|