WIP: server commands

This commit is contained in:
Adrien Bourmault 2021-06-17 12:05:03 +02:00
parent 057cad2bfb
commit 1256c65f62
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
4 changed files with 9 additions and 63 deletions

View File

@ -26,7 +26,7 @@ INCDIR=include
SRCDIR=src SRCDIR=src
DEBDIR=debian DEBDIR=debian
SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \ SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \
$(BINDIR)/centers.o $(BINDIR)/main.o $(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/main.o
CLIOBJ= $(BINDIR)/cli.o CLIOBJ= $(BINDIR)/cli.o
.DEFAULT_GOAL:= all .DEFAULT_GOAL:= all

View File

@ -114,6 +114,12 @@ struct {
// Server // Server
// //
struct {
const char *name;
void* (*func)(void*);
const char *help;
} typedef Command_t;
struct { struct {
pthread_t *id; pthread_t *id;
bool pleaseStop; bool pleaseStop;

View File

@ -24,18 +24,9 @@
#include "../include/scheduler.h" #include "../include/scheduler.h"
#define ARROW_NUMBER 150
#define MAX_CYCLES 15
#define MAX_THREAD 0
#define XMAX 1000
#define YMAX 1000
#define ZMAX 0
#define SPACE_SIZE (XMAX+1) * (YMAX+1) * (ZMAX+1)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
time_t t; time_t t;
//Scheduler_t *scheduler0;
Server_t *server0; Server_t *server0;
// Go! // Go!
@ -47,58 +38,6 @@ int main(int argc, char **argv)
t = time(&t); t = time(&t);
srand((unsigned) t); srand((unsigned) t);
//
// Creating structure for the Scheduler
//
/* scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t)); */
/* scheduler0->globalDrawingSpace = */
/* (Space_t*) calloc(1, sizeof(Space_t)); */
/* scheduler0->globalDrawingSpace->space = */
/* (SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t)); */
/* scheduler0->globalDrawingSpace->size = SPACE_SIZE; */
/* scheduler0->globalDrawingSpace->xmax = SPACE_SIZE; */
/* scheduler0->globalDrawingSpace->ymax = SPACE_SIZE; */
/* scheduler0->globalDrawingSpace->zmax = SPACE_SIZE; */
/* scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t)); */
/* scheduler0->arrowList->array = */
/* (Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t)); */
/* scheduler0->arrowList->size = ARROW_NUMBER; */
/* printLog("Populating a random arrow list...\n"); */
/* for (int i = 0; i < ARROW_NUMBER; i++) { */
/* if (scheduler0->globalDrawingSpace->xmax) */
/* scheduler0->arrowList->array[i].x = */
/* rand() % (scheduler0->globalDrawingSpace->xmax + 1); */
/* if (scheduler0->globalDrawingSpace->ymax) */
/* scheduler0->arrowList->array[i].y = */
/* rand() % (scheduler0->globalDrawingSpace->ymax + 1); */
/* if (scheduler0->globalDrawingSpace->zmax) */
/* scheduler0->arrowList->array[i].z = */
/* rand() % (scheduler0->globalDrawingSpace->zmax + 1); */
/* } */
/* scheduler0->nmaxThread = MAX_THREAD; */
/* scheduler0->nmaxCycles = MAX_CYCLES; */
/* // */
/* // Creating the Scheduler thread */
/* // */
/* SchedInit(scheduler0); */
/* SchedWait(scheduler0); */
/* SchedDestroy(scheduler0); */
/* free(scheduler0); */
//
// Creating structure for the server
//
server0 = (Server_t*) calloc(1, sizeof(Server_t)); server0 = (Server_t*) calloc(1, sizeof(Server_t));
ServerInit(server0); ServerInit(server0);

View File

@ -20,6 +20,7 @@
//=-------------------------------------------------------------------------=// //=-------------------------------------------------------------------------=//
#include "../include/base.h" #include "../include/base.h"
#include "../include/cmds.h"
#include <sys/socket.h> #include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
@ -82,9 +83,9 @@ static void *serverMain(void *server)
Server_t *args; Server_t *args;
int socketDescriptor, effectiveSocket, clientLen; int socketDescriptor, effectiveSocket, clientLen;
struct sockaddr_in client; struct sockaddr_in client;
char clientRequest[255]= {0}; char clientRequest[255]= {0};
char serverAnswer[255] = {0}; char serverAnswer[255] = {0};
const char *pMessage = "hello"; const char *pMessage = "hello";
// Get args // Get args