Skip to content

Commit

Permalink
Criando verificador de senha // criando as funcionalidades da lista d…
Browse files Browse the repository at this point in the history
…os pre cadastrados
  • Loading branch information
contrasov committed Jul 2, 2022
1 parent ff04e27 commit 6a32820
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 53 deletions.
3 changes: 1 addition & 2 deletions .vscode/dryrun.log
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
make --dry-run --always-make --keep-going --print-directory
make: Entering directory '/home/lukaian/Desktop/trabalhos_faculdade/trabalho_de_ED'
make: Leaving directory '/home/lukaian/Desktop/trabalhos_faculdade/trabalho_de_ED'

make: *** No targets specified and no makefile found. Stop.

make: Leaving directory '/home/lukaian/Desktop/trabalhos_faculdade/trabalho_de_ED'

24 changes: 12 additions & 12 deletions .vscode/targets.log
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ make: *** No rule to make target 'all'. Stop.
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.

# Make data base, printed on Thu Jun 30 12:34:13 2022
# Make data base, printed on Sat Jul 2 12:30:58 2022

# Variables

Expand All @@ -21,7 +21,7 @@ NO_AT_BRIDGE = 1
# environment
GJS_DEBUG_OUTPUT = stderr
# environment
VSCODE_IPC_HOOK_EXTHOST = /run/user/1000/vscode-ipc-c3f50e32-2734-4b1e-8dae-016792327f3e.sock
VSCODE_IPC_HOOK_EXTHOST = /run/user/1000/vscode-ipc-21b6637e-e4e6-470f-af21-84da88e37917.sock
# environment
VSCODE_CWD = /home/lukaian
# environment
Expand Down Expand Up @@ -63,7 +63,7 @@ VSCODE_CODE_CACHE_PATH = /home/lukaian/.config/Code/CachedData/30d9c6cd9483b2cc5
# environment
LANG = C
# environment
XAUTHORITY = /run/user/1000/.mutter-Xwaylandauth.CL75N1
XAUTHORITY = /run/user/1000/.mutter-Xwaylandauth.AIRSO1
# default
.LOADED :=
# default
Expand Down Expand Up @@ -101,13 +101,13 @@ MAKEFILE_LIST :=
# environment
VSCODE_VERBOSE_LOGGING = true
# environment
VSCODE_PID = 26198
VSCODE_PID = 2819
# environment
XDG_SESSION_TYPE = wayland
# automatic
?D = $(patsubst %/,%,$(dir $?))
# environment
SESSION_MANAGER = local/unix:@/tmp/.ICE-unix/1685,unix/unix:/tmp/.ICE-unix/1685
SESSION_MANAGER = local/unix:@/tmp/.ICE-unix/1665,unix/unix:/tmp/.ICE-unix/1665
# automatic
*F = $(notdir $*)
# environment
Expand Down Expand Up @@ -145,7 +145,7 @@ MAKEFILES :=
# automatic
^F = $(notdir $^)
# environment
INVOCATION_ID = b1a38313f06a483ebb8f9a99673e2465
INVOCATION_ID = 995a6d7d7cc04bb48ca31a298c98e21c
# environment
VSCODE_LOG_NATIVE = false
# environment
Expand Down Expand Up @@ -175,7 +175,7 @@ GIO_LAUNCHED_DESKTOP_FILE = /usr/share/applications/code.desktop
# makefile
.DEFAULT_GOAL :=
# environment
SYSTEMD_EXEC_PID = 1737
SYSTEMD_EXEC_PID = 1725
# environment
HISTCONTROL = ignoredups
# environment
Expand All @@ -187,19 +187,19 @@ USER = lukaian
# default
MAKE_VERSION := 4.3
# environment
MANAGERPID = 1569
MANAGERPID = 1550
# environment
which_declare = declare -f
# environment
DEBUGINFOD_URLS = https://debuginfod.fedoraproject.org/
# environment
GIO_LAUNCHED_DESKTOP_FILE_PID = 26198
GIO_LAUNCHED_DESKTOP_FILE_PID = 2819
# environment
_ = /usr/bin/make
# environment
XDG_RUNTIME_DIR = /run/user/1000
# environment
JOURNAL_STREAM = 8:29466
JOURNAL_STREAM = 8:28545
# environment
XDG_SESSION_CLASS = user
# environment
Expand Down Expand Up @@ -285,13 +285,13 @@ GNUmakefile:

# No general ('VPATH' variable) search path.


# strcache buffers: 1 (0) / strings = 20 / storage = 210 B / avg = 10 B
# current buf: size = 8162 B / used = 210 B / count = 20 / avg = 10 B

# strcache performance: lookups = 23 / hit rate = 13%
# hash-table stats:

# Load=20/8192=0%, Rehash=0, Collisions=0/23=0%
# Finished Make data base on Thu Jun 30 12:34:13 2022
# Finished Make data base on Sat Jul 2 12:30:58 2022


41 changes: 20 additions & 21 deletions fila_pre_cadastrados.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
//imports
#include <stdio.h>
#include <stdlib.h>
//file
#include "structs.h"

//create variables
Fifopre_node *fifopre_start = NULL; Fifopre_node *fifopre_last = NULL; int fifopre_tam = 0;


//fuctions

void fifopre_add(int identificador, char *nome_aluno, int prioridade){
Admin *admin = malloc(sizeof(Admin));

p->identificador = identificador;
p->nome_aluno = nome_aluno;
p->prioridade = prioridade;

void fifopre_add(char *nome, char *senha, int cpf, char cargo){
Fifopre_node *novo = malloc(sizeof(Fifopre_node));
novo->p = p;
novo->admin.nome = nome;
novo->admin.senha = senha;
novo->admin.cpf = cpf;
novo->admin.cargo = cargo;

novo->next = NULL;

if (fifopre_start == NULL){ //fila vazia
Expand All @@ -31,19 +31,18 @@ void fifopre_add(int identificador, char *nome_aluno, int prioridade){
void fifopre_imprimir(){
Fifopre_node *aux = fifopre_start;
for (int i=0; i<fifopre_tam; i++){
printf("Identificador: %d\n", aux->p->identificador);
printf("Nome dos cadastrados: %s - Cargo: %c\n", aux->admin.nome, aux->admin.cargo);
aux = aux->next;}}


Pedido fifopre_remover(){
Pedido pedido;
//remover!
if (fifopre_start != NULL){ //remover do antigo inicio da lista!
Fifopre_node *lixo = fifopre_start;
fifopre_start = fifopre_start->next;
pedido.identificador = lixo->p->identificador;
//...
free(lixo); fifopre_tam--;

if(fifopre_tam == 1){
fifopre_last = NULL;}} return pedido;}
void add_pre_cadastrados(){
//secretarios
fifopre_add("Brenda Vieira", "100", 100, 'S');
fifopre_add("Pietro Correia", "200", 200, 'S');
fifopre_add("Noah da Costa", "300", 300, 'S');
//transportadores
fifopre_add("Davi Lucca Nunes", "111", 111, 'T');
fifopre_add("André Martins", "112", 112, 'T');
fifopre_add("Agatha da Paz", "113", 113, 'T');
fifopre_add("Bruna Lima", "114", 114, 'T');
fifopre_add("Henrique Correia", "115", 115, 'T');}
2 changes: 1 addition & 1 deletion fila_prioridade.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
//file
#include "structs.h"
#include "fila_pre_cadastrados.h"

//create variables
Fifop_node *fifop_start = NULL; Fifop_node *fifop_last = NULL; int fifop_tam = 0;
Expand Down
33 changes: 19 additions & 14 deletions fuctions_system.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
//imports
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//file
#include "abb.h"
//#include "fila_pre_cadastrados.h"

//create variables
int add_esq_ou_dir = 0;


//fuctions

int verificar_senha(){
//verificar o usuario
char cpf[100]; char senha[100];
int verificar_senha(Fifopre_node *aux, char cargo){
int cpf; char senha[100];

printf(" Digite seu cpf:\n"); scanf("%s", &cpf);
printf(" Digite sua senha:\n"); scanf("%s", &senha);

//se o usuario e senha estiverem certos
return 1;
//se nao
return 0;}
printf("\nDigite seu cpf: "); scanf("%d", &cpf);

for (int i=0; i<fifopre_tam; i++){
if (cargo == aux->admin.cargo && cpf == aux->admin.cpf){
printf("\nDigite sua senha: "); scanf(" %[^\n]s", &senha);

if (strcasecmp(senha, aux->admin.senha) == 0){
printf("\nSenha correta!\n\n"); return 1;}

else {printf("\nSenha incorreta!\n\n"); return 0;}}
aux = aux->next;}

printf("\nNão há nenhum usuario cadastrado com esse CPF que possa usar essa função."); return 0;}


int gerador_id(){
Expand Down Expand Up @@ -85,7 +90,7 @@ void remover_encomenda(){
//visualizar as encomendas
in_ordem(root);

if (verificar_senha() == 1){
if (verificar_senha(fifopre_start, 'S') == 1){
//create variables
int selecionar_id; Abb_node *lixo = buscar(selecionar_id, root);

Expand Down Expand Up @@ -114,7 +119,7 @@ void remover_encomenda(){


void remover_pedido(){
//2 - verificar o usuario
if (verificar_senha() == 1){
//verificar o usuario
if (verificar_senha(fifopre_start, 'T') == 1){
//remover da fila de prioridade
remover_fila();}}
Binary file modified principal
Binary file not shown.
7 changes: 5 additions & 2 deletions principal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@


int main(){
//cadastrando secretarios e transportadores
add_pre_cadastrados(); fifopre_imprimir();

//create variables
int resp;

while (resp != 0){
printf("\n===SISTEMA DE ENCOMENDA DE LIVRO===\n\n");
printf("\n<<<SISTEMA DE ENCOMENDA DE LIVRO>>>\n\n");
printf(" 1 - Encomendar um livro.\n" //sem pedir senha
" 2 - Remover uma encomenda de livro.\n" //secretario - pedir senha
" 3 - Remover um pedido de livro.\n" //transportadores - pedir senha
Expand All @@ -26,7 +29,7 @@ int main(){
remover_encomenda(); break;

case 3:
break;
remover_pedido(); break;

case 1815: //OPCAO ESPECIAL (Ada Lovelace - reference)
printf("\n\n===Exibir estrutura da ABB (Graficamente)===\n\n");
Expand Down
2 changes: 1 addition & 1 deletion structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef struct fifop_node { //struct para os pedidos


typedef struct fifopre_node { //struct para os usuarios pre-cadastrados
Admin *admin;
Admin admin;

//mecanismo p/ unir nos!
struct fifopre_node *next;
Expand Down

0 comments on commit 6a32820

Please sign in to comment.