-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlista_servidores.h
72 lines (64 loc) · 2.22 KB
/
lista_servidores.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
#include <stdio.h>
#include <stdlib.h>
servidor * inicio_lista = NULL;
servidor * fim_lista = NULL;
int tamanho_lista = 0;
void add_servidor(int cpf, char *nome, int senha, char ocupacao){
servidor * novo = malloc(sizeof(servidor));
novo->cpf = cpf;
novo->nome_serv = nome;
novo->senha = senha;
novo->ocupacao = ocupacao;
novo->prox = NULL;
novo->ant = NULL;
if( inicio_lista == NULL ){
inicio_lista = novo;
fim_lista = novo;
tamanho_lista++;
}else {
novo->prox = inicio_lista;
inicio_lista->ant = novo;
inicio_lista = novo;
tamanho_lista++;
}
}
int busca_transportador(int cpf, int senha){
int resposta = 0;
if(inicio_lista->cpf == cpf && inicio_lista->senha == senha && inicio_lista->ocupacao == 't'){
resposta = 1;
}else if(fim_lista->cpf == cpf && fim_lista->senha == senha && inicio_lista->ocupacao == 't'){
resposta = 1;
}else{
servidor * aux = inicio_lista;
for(int i= 0; i < tamanho_lista; i++){
if(aux->cpf != cpf || aux->senha != senha || inicio_lista->ocupacao != 't')
aux = aux->prox;
else
break;
}
resposta = 1;
}
if(resposta == 1){
}
return resposta;
}
int busca_bibliotecario(int cpf, int senha){
int resposta = 0;
if(inicio_lista->cpf == cpf && inicio_lista->senha == senha && inicio_lista->ocupacao == 'b'){
resposta = 1;
}else if(fim_lista->cpf == cpf && fim_lista->senha == senha && inicio_lista->ocupacao == 'b'){
resposta = 1;
}else{
servidor * aux = inicio_lista;
for(int i= 0; i < tamanho_lista; i++){
if(aux->cpf != cpf || aux->senha != senha || inicio_lista->ocupacao != 'b')
aux = aux->prox;
else
break;
}
resposta = 1;
}
if(resposta == 1){
}
return resposta;
}