This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.h
168 lines (150 loc) · 5.04 KB
/
types.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
Bibtex Project - types.h
Maxime B. & Nathan O. (TC03)
types.h : cointains declarations of our constants, of our data structures (Linked List and others) and the prototypes of our fonctions.
*/
#ifndef __TYPES__
#define __TYPES__
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <regex.h>
/* == Constantes == */
/* Constantes for defining the BOOL type */
#define BOOL int
#define TRUE 1
#define FALSE 0
/* == Structures == */
/* AbstractList : may also be used as Library */
typedef struct elemAbstract {
void* value;
struct elemAbstract* next;
struct elemAbstract* prev;
} AbstractElement;
typedef struct {
AbstractElement* head;
AbstractElement* tail;
int count;
size_t size;
} AbstractList;
/* EntryField */
typedef struct {
char* name;
void* value; /* If name="author" => abstractList of authors, else => char* */
} EntryField;
/* Entry */
typedef struct {
char* key;
char* type;
AbstractList requiredFieldList; /* List of entryField */
AbstractList optionalFieldList; /* List of entryField */
} Entry;
/* Author */
typedef struct {
char* lastName; /* Example : GAUD */
char* firstName; /* Example : Nicolas */
} Author;
/* AuthorPublications */
typedef struct {
Author author;
AbstractList publicationsList; /* List of Entry */
} AuthorPublications;
/* DataPublications : List of publications */
typedef struct {
char* year;
AbstractList publicationsList; /* List of entry */
} DatePublications;
typedef AbstractList Library;
typedef AbstractList ListAuthorPublications;
typedef AbstractList AuthorList;
typedef AbstractList ListDatePublications;
/* == Functions' prototypes == */
int testRegex(char* line, char* regexString, char*** regexArray, int sizeMax);
/*
* isContained : replace all the special characters in a string
*
* value : a string we want to search in the variable string
* string : the given string in which we want to search value
*
* return a boolean : TRUE if value is contained in string, FALSE if not
*/
BOOL isContained(char* value, char* string);
/*
* isEmpty : indicates if the list is empty or not
*
* list : a generic list
*
* return a boolean : TRUE if the list is empty, FALSE if the list isnt
*/
BOOL isEmpty(AbstractList list);
/*
* replaceSpecialChars : replace all the special characters in a string
*
* string : the given string in which we want to replace special characters
*
* return the string special characters replaced
*/
char* replaceSpecialChars(char* string);
/*
* initEntry : initialize an entry
*
* typeEntry : the entry's type
* key : the entry's key
*
* return an Entry initialized
*/
Entry* initEntry(char* typeEntry, char* key);
/*
* initList : initialize a list (which is returned) setting his head/tail equal to NULL, his count equal to 0 and his size equal to the given size (function's argument)
*
* size : since the list is a abstract list (including void*) we must have a list.size which contains the size of the list's element,
for Example : if it's a list of entryField then we'll have size=sizeof(entryField), if it's a list of publications for then we'll have size=sizeof(Entry)
*
* return an AbstractList initialized
*/
AbstractList initList(int size);
/*
* insertHead : insert an element or a pointer at the beginning of the list
*
* list : the list in which we have to put the element/pointer
* element : a pointer on a given element we want to put in the beginning of list
* allocMemory : if allocMemory is equal to TRUE (1) then we create a new element at the beginning of the list and we will copy the value of element into the new created element
else then we just copy the pointer at the end of the list (which means element is not a temporary element so we can just copy his adress)
*
* return the list with the new element
*/
AbstractList insertHead(AbstractList list, void* element, BOOL allocMemory);
/*
* removeHead : remove the first element of the list
*
* list : the list in which we have to remove the first element
*
* return the list without the first element
*/
AbstractList removeHead(AbstractList list);
/*
* insertTail : insert an element or a pointer at the end of the list
*
* list : the list in which we have to put the element/pointer
* element : a pointer on a given element we want to put in the end of list
* allocMemory : if allocMemory is equal to TRUE (1) then we create a new element at the beginning of the list and we will copy the value of element into the new created element
else then we just copy the pointer at the end of the list (which means element is not a temporary element so we can just copy his adress)
*
* return the list with the new element
*/
AbstractList insertTail(AbstractList list, void* element, BOOL allocMemory);
/*
* removeTail : remove the first element of the list
*
* list : the list in which we have to remove the first element
*
* return the list without the last element
*/
AbstractList removeTail(AbstractList list);
/*
* clean_stdin : clean the keyboard buffer
*/
void clean_stdin(void);
#endif