-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinked_list.h
45 lines (39 loc) · 1.03 KB
/
linked_list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Created by Antonis Karvelas.
// Here lies the generic linked list, plus a few client specific things:
#ifndef ERGASIA_1_LINKEDLIST_H
#define ERGASIA_1_LINKEDLIST_H
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
typedef struct client
{
int16_t clientPort;
int32_t clientIP;
} Client;
typedef struct Node
{
void* item;
struct Node* next;
struct Node* previous;
} Node;
typedef struct LinkedList
{
Node* head;
Node* tail;
} LinkedList;
// Generic part:
Node* initializeNode(void* item);
LinkedList* initializeLinkedList();
void appendToLinkedList(LinkedList* linkedList, Node* node);
void freeLinkedList(LinkedList* linkedList);
Node* popStart(LinkedList* linkedList);
int linkedListSize(LinkedList* linkedList);
// Client part:
Client* initializeClient(int16_t port, int32_t clientIP);
int checkClientInLinkedList(LinkedList* linkedList, int16_t port, int32_t ip);
#endif //ERGASIA_1_LINKEDLIST_H