-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauxiliar.h
81 lines (71 loc) · 1.95 KB
/
auxiliar.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
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
#include <stdlib.h>
#include <time.h>
/* TAMANHO DA HASH ( SHA256_DIGEST_LENGTH ) = 32 */
/* dadosA : dados Arvore */
struct dadosa{
unsigned char hash[32];
};
typedef struct dadosa Datab;
struct node{
Datab info;
struct node *esq; /*no filho esquerdo*/
struct node *dir; /*no filho direito*/
struct node *pai; /*no pai*/
};
typedef struct node ARV;
/* dados da transação */
struct data{
char Nome[40];
char idade[3];
char Diagnostico[40];
char Medico[40];
};
typedef struct data Data;
struct bloco{
unsigned char Hash[32];
unsigned char Hash_Pai[32];
ARV **arv;
Data lista[16];
char timestamp[30];
};
typedef struct bloco Bloco;
struct Blc{
Bloco *atual;
struct Blc *ant;
};
typedef struct Blc Blockchain;
struct buffer{
Data lista[16];
int contador;
};
typedef struct buffer Buffer;
/* FUNCOES DE HASH */
void print(unsigned char *hashf);
void hash(const char *s, unsigned char *dest);
void hashConcat(unsigned char d1[], unsigned char d2[], unsigned char dest[]);
int comparaHash(unsigned char *d1, unsigned char *d2);
/* FUNCOES DA ARVORE */
ARV** criaArv();
int existeArv(ARV **arv);
int vaziaArv(ARV **arv);
ARV* removeRaiz(ARV *nobase);
void destroiArv(ARV **arv);
void caminhaComparando(ARV *arv, unsigned char *hash, int *a);
int procuranode(ARV *nodo,unsigned char *hash);
/* FUNCOES DA BLOCKCHAIN */
Blockchain **inicializa();
void adiciona_blockchain(Blockchain **dados, Bloco *atual);
Bloco* criar();
char* junta_data(Data info);
void adiciona_bloco(Blockchain **Dados,Buffer buff);
void inicializaBuffer(Buffer *buff);
void encheBuffer(Buffer buff, Data paciente);
int checaBuffer(Buffer buff);
void libera_blocos(Blockchain **Block);
Blockchain* buscaBlockchain(Blockchain ** Dados, Data paciente);
void imprimirData(Data paciente, int i);
void imprimeBloco(Blockchain *block);
int buscaPaciente(Blockchain ** Dados, Data paciente);