-
Notifications
You must be signed in to change notification settings - Fork 1
/
rep.c
executable file
·85 lines (72 loc) · 2.11 KB
/
rep.c
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
#include <stdlib.h>
#include "rep.h"
/*!
*This function receives the head of the list of authors
*to calculate the dimension of the list.
*
*\param head
* The head of the list of the authors for a given reference.
*\return The length of the list.
*/
int authorsListLength(authorsList head) {
int cont;
for(cont=0; head; head=head->next,cont++)
;
return cont;
}
/*!
*This function insert in the list of authors a given author.
*
*\param l
* The head of the list that has to be filled with the second parameter.
*\param author
* The name and/or family name of the author that has to be inserted in the list in the first argument.
*/
void insertAuthorsInTail(authorsList *l, char* author) {
authorsList last;
authorsList paux;
paux = (authorsList) malloc(sizeof(tauthors));
paux->author = author;
paux->next = NULL;
if (*l == NULL) {
*l = paux;
} else {
last = *l;
while (last->next != NULL) {
last = last->next;
}
last->next = paux;
}
}
/*!
*This function insert in the list of authors a given list of author,
*the title of the reference, and the optional url of the eletronic resources.
*
*\param l
* The head of the list that has to be filled with the other parameters.
*\param authorsList
* The list of authors that realized this reference.
*\param title
* The title of the reference.
*\param urlEletronicResource
* The url of the eletronic resource(ee). If ee is not available the url must be "".
*/
void insertReferencesInTail(referencesList *l, char* p, authorsList a, char* title, char* urlEletronicResource) {
referencesList last;
referencesList paux;
paux = (referencesList)malloc(sizeof(treferences));
paux->urlEletronicResource = urlEletronicResource;
paux->title = title;
paux->pages = p;
paux->listAuthors = a;
paux->next = NULL;
if (*l == NULL) {
*l = paux;
} else {
last = *l;
while (last->next != NULL) {
last = last->next;
}
last->next = paux;
}
}