-
Notifications
You must be signed in to change notification settings - Fork 0
/
i-banco-terminal.h
56 lines (46 loc) · 1.09 KB
/
i-banco-terminal.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
#ifndef I_BANCO_TERMINAL_H
#define I_BANCO_TERMINAL_H
#include "commandlinereader.h"
#include <stdio.h>
#include <time.h>
#define COMANDO_DEBITAR "debitar"
#define COMANDO_CREDITAR "creditar"
#define COMANDO_LER_SALDO "lerSaldo"
#define COMANDO_SIMULAR "simular"
#define COMANDO_SAIR "sair"
#define COMANDO_SAIR_AGORA "agora"
#define COMANDO_SAIR_TERMINAL "sair-terminal"
#define COMANDO_TRANSFERIR "transferir"
#define OP_TERMINAL_SAIR -1
#define OP_DEBITAR 0
#define OP_CREDITAR 1
#define OP_LER_SALDO 2
#define OP_TRANSFERIR 3
#define OP_SAIR 4
#define OP_SIMULAR 5
#define MAXARGS 4
#define BUFFER_SIZE 100
#define NAO "n"
#define SIM "y"
/* Command structure */
typedef struct {
int operacao;
int idConta;
int idContaDestino;
int valor;
pid_t tpid;
} comando_t;
int sigpipeflag = 0 ;
int cmdpipe_fd;
int answerpipe_fd;
char *cmdpipe;
char *answerpipe = "/tmp/i-banco-answer";
char pipeName[26];
char buf[BUFFER_SIZE];
pid_t tpid;
time_t inicio,fim;
double tempo;
void wipebuf(char *x);
void writeCommand(int operacao, int idConta,int idContaDestino, int valor);
void sigpipehandler();
#endif