Refactor code
This commit is contained in:
parent
f227b7ee38
commit
26b5fafa01
2
Makefile
2
Makefile
|
@ -1,8 +1,6 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CCFLAGS = -Wall -std=c99 -pedantic -g
|
CCFLAGS = -Wall -std=c99 -pedantic -g
|
||||||
|
|
||||||
# OBJECTS = errors.o server.o client.o
|
|
||||||
|
|
||||||
CLIENT=client.o
|
CLIENT=client.o
|
||||||
SERVER=server.o
|
SERVER=server.o
|
||||||
ERROR=errors.o
|
ERROR=errors.o
|
||||||
|
|
38
challenges.c
38
challenges.c
|
@ -1,45 +1,13 @@
|
||||||
#include "include/challenges.h"
|
#include "include/challenges.h"
|
||||||
|
|
||||||
// char introChallenge(int fd, char * output, char * message, char * question, char * flag) {
|
|
||||||
// printf("%s\n", message);
|
|
||||||
|
|
||||||
// int readChars;
|
|
||||||
// while ((readChars = read(fd, output, MAX_LEN - 1)) != 0) {
|
|
||||||
// if (readChars < 0)
|
|
||||||
// printSystemError("Challenges: read()");
|
|
||||||
// output[readChars] = '\0';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// printf("%s\n", question);
|
|
||||||
|
|
||||||
// return strcmp(output, flag) == 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// char genChallenge(int fd, char * output, char * message, char * question, char * flag) {
|
|
||||||
// printf("%s\n", message);
|
|
||||||
|
|
||||||
// int readChars;
|
|
||||||
// while ((readChars = read(fd, output, MAX_LEN - 1)) != 0) {
|
|
||||||
// if (readChars < 0)
|
|
||||||
// printSystemError("Challenges: read()");
|
|
||||||
// output[readChars] = '\0';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// printf("%s\n", question);
|
|
||||||
|
|
||||||
// return !strcmp(output, flag);
|
|
||||||
// }
|
|
||||||
|
|
||||||
char genChallenge(int fd, char * output, challenge_t challenge) {
|
char genChallenge(int fd, char * output, challenge_t challenge) {
|
||||||
printf("%s\n", challenge.message);
|
printf("%s\n", challenge.message);
|
||||||
|
|
||||||
int readChars;
|
int readChars;
|
||||||
// while ((readChars = read(fd, output, MAX_LEN - 1)) != 0) {
|
|
||||||
readChars = read(fd, output, MAX_LEN - 1);
|
readChars = read(fd, output, MAX_LEN - 1);
|
||||||
if (readChars < 0)
|
if (readChars < 0)
|
||||||
printSystemError("Challenges: read()");
|
printSystemError("Challenges: read()");
|
||||||
output[readChars] = '\0';
|
output[readChars] = '\0';
|
||||||
// }
|
|
||||||
|
|
||||||
printf("%s\n", challenge.question);
|
printf("%s\n", challenge.question);
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,11 @@
|
||||||
#define MAX_LEN 100
|
#define MAX_LEN 100
|
||||||
|
|
||||||
typedef struct challenge_t {
|
typedef struct challenge_t {
|
||||||
// char (* challenge) (int fd, char * output, char * message, char * question, char * flag);
|
|
||||||
char * message;
|
char * message;
|
||||||
char * question;
|
char * question;
|
||||||
char * flag;
|
char * flag;
|
||||||
} challenge_t;
|
} challenge_t;
|
||||||
|
|
||||||
// char genChallenge(int fd, char * output, char * message, char * question, char * flag);
|
|
||||||
char genChallenge(int fd, char * output, challenge_t challenge);
|
char genChallenge(int fd, char * output, challenge_t challenge);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue