60 lines
1.2 KiB
C
60 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <server.h>
|
|
#include <sys/types.h>
|
|
#include <sys/ipc.h>
|
|
#include <sys/sem.h>
|
|
#include <sys/stat.h>
|
|
#include <string.h>
|
|
|
|
#include <errExit.h>
|
|
#include <signal.h>
|
|
#include <custom_msgq.h>
|
|
#include <custom_sem.h>
|
|
#include <custom_shm.h>
|
|
#include <custom_sig.h>
|
|
#include <forza4.h>
|
|
|
|
int ID;
|
|
pid_t SERVER_PID;
|
|
int clientBot = 0;
|
|
|
|
void checkClientinput(int argc, char *argv[]);
|
|
|
|
void setupClient(int argc, char *argv[]) {
|
|
// CHECK INPUT
|
|
checkClientinput(argc, argv);
|
|
|
|
// MSGQ
|
|
setupClientMsgq();
|
|
|
|
// SIGNAL
|
|
setupClientSignalHandler();
|
|
|
|
// SHM
|
|
setupClientShm();
|
|
|
|
setupClientSem();
|
|
}
|
|
|
|
void checkClientinput(int argc, char *argv[]){
|
|
if (argc < 2) {
|
|
printf(PHELP "./F4Client PLAYER_NAME\n"
|
|
"\t- PLAYER_NAME \t\tplayer name\n"
|
|
);
|
|
exit(EXIT_SUCCESS);
|
|
} else if (argc > 3) {
|
|
errExitMsg("To many arguments");
|
|
}
|
|
|
|
if (!argv[1] || strlen(argv[1]) > MAX_NAME) {
|
|
errExitMsg("Invalid player name");
|
|
}
|
|
|
|
if (argv[2]) {
|
|
if (strcmp(argv[2], "bot") && strcmp(argv[2], "auto")) {
|
|
errExitMsg("Invalid third argument");
|
|
}
|
|
}
|
|
} |