Renamming/changing vocabulary and signatures
This commit is contained in:
parent
eb3f2c29cf
commit
3b04e4c01b
2
Makefile
2
Makefile
|
@ -27,7 +27,7 @@ INCDIR=include
|
|||
SRCDIR=src
|
||||
DEBDIR=debian
|
||||
|
||||
SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \
|
||||
SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/worker.o \
|
||||
$(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/model.o \
|
||||
$(BINDIR)/main.o $(BINDIR)/arrows.o
|
||||
CLIOBJ= $(BINDIR)/cli.o
|
||||
|
|
|
@ -23,27 +23,29 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
static inline int createArrowLock(ArrowArray_t *arrowArray)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static inline int ArrowsInitLock(ArrowArray_t *arrowArray)
|
||||
{
|
||||
return pthread_spin_init(&arrowArray->lock, PTHREAD_PROCESS_SHARED);
|
||||
}
|
||||
|
||||
static inline int destroyArrowLock(ArrowArray_t *arrowArray)
|
||||
static inline int ArrowsDestroyLock(ArrowArray_t *arrowArray)
|
||||
{
|
||||
return pthread_spin_destroy(&arrowArray->lock);
|
||||
}
|
||||
|
||||
static inline int acquireArrowLock(ArrowArray_t *arrowArray)
|
||||
static inline int ArrowsAcquireLock(ArrowArray_t *arrowArray)
|
||||
{
|
||||
return pthread_spin_lock(&arrowArray->lock);
|
||||
}
|
||||
|
||||
static inline int acquireNonBlockingArrowLock(ArrowArray_t *arrowArray)
|
||||
static inline int ArrowsAcquireNonBlockingLock(ArrowArray_t *arrowArray)
|
||||
{
|
||||
return pthread_spin_trylock(&arrowArray->lock);
|
||||
}
|
||||
|
||||
static inline int releaseArrowLock(ArrowArray_t *arrowArray)
|
||||
static inline int ArrowsReleaseLock(ArrowArray_t *arrowArray)
|
||||
{
|
||||
return pthread_spin_unlock(&arrowArray->lock);
|
||||
}
|
||||
|
|
|
@ -41,36 +41,36 @@
|
|||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
struct {
|
||||
struct IntArray_t {
|
||||
size_t size;
|
||||
int *space;
|
||||
} typedef IntArray_t;
|
||||
|
||||
struct {
|
||||
struct Arrow_t {
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int siteId;
|
||||
} typedef Arrow_t;
|
||||
|
||||
struct {
|
||||
struct ArrowArray_t {
|
||||
size_t size;
|
||||
pthread_spinlock_t lock;
|
||||
Arrow_t *array;
|
||||
} typedef ArrowArray_t;
|
||||
|
||||
struct {
|
||||
struct Site_t {
|
||||
char *label;
|
||||
int nArrow;
|
||||
} typedef Site_t;
|
||||
|
||||
struct {
|
||||
struct SpaceUnit_t {
|
||||
int nSite;
|
||||
char *label;
|
||||
Site_t *sites;
|
||||
} typedef SpaceUnit_t;
|
||||
|
||||
struct {
|
||||
struct Space_t {
|
||||
int xMax;
|
||||
int yMax;
|
||||
int zMax;
|
||||
|
@ -83,7 +83,7 @@ struct {
|
|||
//
|
||||
// Scheduler
|
||||
//
|
||||
struct {
|
||||
struct Scheduler_t {
|
||||
pthread_t id;
|
||||
bool pleaseStop;
|
||||
Space_t *globalDrawingSpace;
|
||||
|
@ -107,11 +107,11 @@ struct Center_t {
|
|||
struct Center_t *prev;
|
||||
} typedef Center_t;
|
||||
|
||||
struct {
|
||||
struct Worker_t {
|
||||
pthread_t id;
|
||||
Center_t *localWorkAreaCenter;
|
||||
Space_t *globalDrawingSpace;
|
||||
IntArray_t *conditionTree;
|
||||
IntArray_t *conditionTree; // XXX
|
||||
ArrowArray_t *arrowArray;
|
||||
bool pleaseStop;
|
||||
bool terminated;
|
||||
|
@ -123,20 +123,20 @@ struct {
|
|||
//
|
||||
// Server
|
||||
//
|
||||
struct {
|
||||
struct Server_t {
|
||||
pthread_t id;
|
||||
bool pleaseStop;
|
||||
int returnValue;
|
||||
int sockfd;
|
||||
int sockfd; // Socket file descriptor
|
||||
} typedef Server_t;
|
||||
|
||||
struct {
|
||||
struct ServerCommunication_t {
|
||||
pthread_t id;
|
||||
bool pleaseStop;
|
||||
Server_t *parent;
|
||||
int sockfd;
|
||||
Server_t *associatedServer;
|
||||
int sockfd; // Socket file descriptor
|
||||
struct sockaddr_in clientAddr;
|
||||
socklen_t socklen;
|
||||
socklen_t sockLen;
|
||||
} typedef ServerCommunication_t;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -144,10 +144,10 @@ struct {
|
|||
//
|
||||
// Supervisor
|
||||
//
|
||||
struct {
|
||||
struct Supervisor_t {
|
||||
pthread_t id;
|
||||
bool pleaseStop;
|
||||
int *workerCreationOccurency;
|
||||
int *workerCreationOccurency; // XXX ???
|
||||
} typedef Supervisor_t;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -155,32 +155,35 @@ struct {
|
|||
//
|
||||
// Model
|
||||
//
|
||||
struct {
|
||||
struct Model_t {
|
||||
// Identity
|
||||
int id;
|
||||
bool validated; // true if model has been correctly parsed
|
||||
char *name;
|
||||
char *author;
|
||||
time_t date;
|
||||
char *version;
|
||||
char *filename;
|
||||
bool validated;
|
||||
// Parameters
|
||||
int space_xMax;
|
||||
int space_yMax;
|
||||
int space_zMax;
|
||||
int nmaxThread;
|
||||
int nmaxCycles;
|
||||
int siteNumber;
|
||||
// Model instance
|
||||
bool isRunning;
|
||||
Scheduler_t *scheduler;
|
||||
Supervisor_t *supervisor;
|
||||
} typedef Model_t;
|
||||
|
||||
struct ModelField_t {
|
||||
bool mandatory;
|
||||
char tag[25];
|
||||
char *value;
|
||||
size_t valueSize;
|
||||
struct ModelField_t *son;
|
||||
struct ModelField_t *next;
|
||||
bool mandatory; // true if field must exist in file
|
||||
char tag[25]; // XML tag attached to that field
|
||||
char *destination; // data destination of that field
|
||||
size_t size; // max size of data allowed
|
||||
struct ModelField_t *son; // son in XML tree
|
||||
struct ModelField_t *next; // brother in XML tree
|
||||
} typedef ModelField_t;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -188,7 +191,7 @@ struct ModelField_t {
|
|||
//
|
||||
// Parameters
|
||||
//
|
||||
struct {
|
||||
struct Parameters_t {
|
||||
char *configDir;
|
||||
char *modelDir;
|
||||
char *userDir;
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Add a center to the center list //
|
||||
// -------------------------------------------------------------------------- //
|
||||
Center_t *CenterAdd(Center_t *anyCenter, Center_t *newCenter);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Remove a center from the center list //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void CenterRemove(Center_t *oldCenter);
|
||||
|
|
|
@ -23,17 +23,25 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
//char *CmdHelp(char **, Server_t *);
|
||||
char *CmdModel(char*, char**, Server_t*);
|
||||
char *CmdShutdown(char*, char**, Server_t*);
|
||||
char *CmdHelp(char*, char**, Server_t*);
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
struct {
|
||||
struct Command_t {
|
||||
const char *name;
|
||||
char* (*execute)(char*, char**, Server_t*);
|
||||
const char *help;
|
||||
} typedef Command_t;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//
|
||||
// Existing commands
|
||||
//
|
||||
char *CmdModel(char*, char**, Server_t*);
|
||||
char *CmdShutdown(char*, char**, Server_t*);
|
||||
char *CmdHelp(char*, char**, Server_t*);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
Command_t cmdList[] =
|
||||
{
|
||||
{"help", CmdHelp, "Help command"},
|
||||
|
|
|
@ -23,20 +23,49 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Model init function (and model discovery) //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void ModelSystemInit(Parameters_t *parameters);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Model stopping function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void ModelSystemDestroy(void);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Load a model ready to execute //
|
||||
// -------------------------------------------------------------------------- //
|
||||
int ModelLoad(int id);
|
||||
|
||||
void ModelCreate(Model_t **newModel);
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Unload a model //
|
||||
// -------------------------------------------------------------------------- //
|
||||
int ModelUnload(int id);
|
||||
|
||||
int ModelLoad(int id);
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Add a model to the known model list //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void ModelAddToKnown(Model_t **newModel);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Print informations about all models (known and loaded) to the client //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void printModels(char *buf);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Launch a model execution //
|
||||
// -------------------------------------------------------------------------- //
|
||||
int ModelRun(int id);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Stop a model execution //
|
||||
// -------------------------------------------------------------------------- //
|
||||
int ModelStop(int id);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Stop and unload all loaded or running model //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void ModelShutdown(void);
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler init function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
@ -54,7 +56,7 @@ static inline void SchedContentDestroy(Scheduler_t *scheduler)
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler destructor function //
|
||||
// Scheduler destructor function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void SchedDestroy(Scheduler_t *scheduler)
|
||||
{
|
||||
|
@ -63,7 +65,6 @@ static inline void SchedDestroy(Scheduler_t *scheduler)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler wait function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
|
|
@ -23,18 +23,13 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Server init function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
void ServerInit(Server_t *server);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Server destructor function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void ServerDestroy(Server_t *server)
|
||||
{
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Server wait function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Supervisor init function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
|
@ -48,12 +50,16 @@
|
|||
|
||||
#define NON_BLOCKING 1
|
||||
|
||||
volatile struct winsize terminalSize;
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//
|
||||
// Get a character code from the keyboard
|
||||
//
|
||||
static inline int getch(bool nonBlocking)
|
||||
volatile struct winsize TermWindowSize;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Get a character code from the keyboard //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline int TermGetch(bool nonBlocking)
|
||||
{
|
||||
int buf = 0;
|
||||
// old terminal
|
||||
|
@ -112,62 +118,62 @@ static inline int getch(bool nonBlocking)
|
|||
return buf;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the screen size
|
||||
//
|
||||
static inline void getScreenSize(int signum)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Get the screen size //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void TermGetScreenSize(int signum)
|
||||
{
|
||||
// Get current terminal size
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &terminalSize);
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &TermWindowSize);
|
||||
}
|
||||
|
||||
//
|
||||
// Set cursor location
|
||||
//
|
||||
static inline void setCursorLocation(char x, char y)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Set cursor location //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void TermSetCursorLocation(char x, char y)
|
||||
{
|
||||
printf("\x1b[%d;%dH", y, x);
|
||||
}
|
||||
|
||||
//
|
||||
// Save cursor location
|
||||
//
|
||||
static inline void saveCursorLocation(void)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Save cursor location //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void TermSaveCursorLocation(void)
|
||||
{
|
||||
printf(C_SAVE_CURSORPOS);
|
||||
}
|
||||
|
||||
//
|
||||
// Restore cursor location
|
||||
//
|
||||
static inline void restoreCursorLocation(void)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Restore cursor location //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void TermRestoreCursorLocation(void)
|
||||
{
|
||||
printf(C_RESTORE_CURSORPOS);
|
||||
}
|
||||
|
||||
//
|
||||
// Move cursor location to the right
|
||||
//
|
||||
static inline void moveCursorForward(void)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Move cursor location to the right //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void TermMoveCursorForward(void)
|
||||
{
|
||||
printf(C_CURSORRIGHT);
|
||||
}
|
||||
|
||||
//
|
||||
// Move cursor location to the left
|
||||
//
|
||||
static inline void moveCursorBackward(void)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Move cursor location to the left //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void TermMoveCursorBackward(void)
|
||||
{
|
||||
printf(C_CURSORLEFT);
|
||||
}
|
||||
|
||||
//
|
||||
// Clear screen
|
||||
//
|
||||
static inline void clearScreen(void)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Clear screen //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void TermClearScreen(void)
|
||||
{
|
||||
printf(C_CLEARSCREEN);
|
||||
setCursorLocation(1,1);
|
||||
TermSetCursorLocation(1,1);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Worker init function //
|
||||
// -------------------------------------------------------------------------- //
|
|
@ -23,15 +23,24 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml2/libxml/xmlmemory.h>
|
||||
#include <libxml2/libxml/parser.h>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static xmlDocPtr currentDocument = NULL;
|
||||
static xmlNodePtr currentDocumentRoot = NULL;
|
||||
|
||||
static inline void openCurrentDocument(const char *filename)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Open and set a document as current document //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void XmlSetNewDocument(const char *filename)
|
||||
{
|
||||
currentDocument = xmlParseFile(filename);
|
||||
|
||||
|
@ -53,19 +62,29 @@ static inline void openCurrentDocument(const char *filename)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void closeCurrentDocument(void)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Close and unset current document //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void XmlCloseCurrentDocument(void)
|
||||
{
|
||||
xmlFreeDoc(currentDocument);
|
||||
currentDocumentRoot = NULL;
|
||||
currentDocument = NULL;
|
||||
}
|
||||
|
||||
static inline void resetDocumentRoot(void)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Reset current working root to document root //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void XmlResetWorkingRoot(void)
|
||||
{
|
||||
currentDocumentRoot = xmlDocGetRootElement(currentDocument);
|
||||
}
|
||||
|
||||
static inline int parseTag(const char* tagName, char *destination, char destSize)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Parse content of a given XML tag //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline int XmlParseTag(const char* tagName, char *destination,
|
||||
char destSize)
|
||||
{
|
||||
char *curString;
|
||||
size_t cursor = 0;
|
||||
|
@ -103,7 +122,11 @@ static inline int parseTag(const char* tagName, char *destination, char destSize
|
|||
return res;
|
||||
}
|
||||
|
||||
static inline xmlNodePtr findRoot(const char *tagName, xmlNodePtr curRoot)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Find a working root for a given tag //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline xmlNodePtr findWorkingRoot(const char *tagName,
|
||||
xmlNodePtr curRoot)
|
||||
{
|
||||
xmlNodePtr cur = curRoot;
|
||||
xmlNodePtr recur;
|
||||
|
@ -127,7 +150,11 @@ static inline xmlNodePtr findRoot(const char *tagName, xmlNodePtr curRoot)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static inline int parseTree(ModelField_t *curTree)
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Parse and validate an XML tree from given structural tree //
|
||||
// and current document //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline int XmlParseTree(ModelField_t *curTree)
|
||||
{
|
||||
int currentOrSonCorrectlyParsed = 0;
|
||||
int curValueLen;
|
||||
|
|
90
src/cli.c
90
src/cli.c
|
@ -47,7 +47,7 @@
|
|||
//
|
||||
// Print monitor screen
|
||||
//
|
||||
void decorateMonitor(int signum)
|
||||
void CliDecorateMonitor(int signum)
|
||||
{
|
||||
const char titleText[] = "GEM-GRAPH MONITOR";
|
||||
const char screenTitleText[] = "Model view";
|
||||
|
@ -59,95 +59,95 @@ void decorateMonitor(int signum)
|
|||
const char infosSchedulerText[] = "Scheduler id";
|
||||
const char infosScThreadsText[] = "+ threads ";
|
||||
|
||||
getScreenSize(signum);
|
||||
TermTermGetScreenSize(signum);
|
||||
|
||||
clearScreen();
|
||||
TermTermClearScreen();
|
||||
|
||||
setCursorLocation(1,1);
|
||||
TermSetCursorLocation(1,1);
|
||||
printf(C_COLOR_NORMAL C_COLOR_WHITE_ON_BLUE);
|
||||
for (int i = 0; i < terminalSize.ws_col; i++) {
|
||||
for (int i = 0; i < TermWindowSize.ws_col; i++) {
|
||||
printf(" ");
|
||||
}
|
||||
setCursorLocation(1,1);
|
||||
TermSetCursorLocation(1,1);
|
||||
printf("%s%s",
|
||||
C_COLOR_NORMAL C_COLOR_WHITE_ON_BLUE,
|
||||
titleText
|
||||
);
|
||||
|
||||
setCursorLocation(1,2);
|
||||
TermSetCursorLocation(1,2);
|
||||
printf(C_COLOR_NORMAL C_COLOR_BLACK_ON_GREEN);
|
||||
for (int i = 0; i < terminalSize.ws_col; i++) {
|
||||
for (int i = 0; i < TermWindowSize.ws_col; i++) {
|
||||
printf(" ");
|
||||
}
|
||||
setCursorLocation(1,2);
|
||||
TermSetCursorLocation(1,2);
|
||||
printf("%s%s",
|
||||
C_COLOR_NORMAL C_COLOR_BLACK_ON_GREEN,
|
||||
screenTitleText
|
||||
);
|
||||
setCursorLocation(terminalSize.ws_col / 3 * 2, 2);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 2);
|
||||
printf("%s%s",
|
||||
C_COLOR_NORMAL C_COLOR_BLACK_ON_GREEN,
|
||||
infosTitleText
|
||||
);
|
||||
|
||||
setCursorLocation(terminalSize.ws_col / 3 * 2, 4);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 4);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_NORMAL C_COLOR_BLACK_ON_LIGHTGREY,
|
||||
infosNameText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
setCursorLocation(terminalSize.ws_col / 3 * 2, 6);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 6);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_BLACK_ON_GREEN,
|
||||
infosStatusText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
setCursorLocation(terminalSize.ws_col / 3 * 2, 8);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 8);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_BLACK_ON_LIGHTGREY,
|
||||
infosOwnerText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
setCursorLocation(terminalSize.ws_col / 3 * 2, 10);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 10);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_BLACK_ON_GREEN,
|
||||
infosSchedulerText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
setCursorLocation(terminalSize.ws_col / 3 * 2, 12);
|
||||
TermSetCursorLocation(TermWindowSize.ws_col / 3 * 2, 12);
|
||||
printf("%s%s%s (void)",
|
||||
C_COLOR_BLACK_ON_LIGHTGREY,
|
||||
infosScThreadsText,
|
||||
C_COLOR_NORMAL
|
||||
);
|
||||
|
||||
setCursorLocation(1, terminalSize.ws_row - 1);
|
||||
TermSetCursorLocation(1, TermWindowSize.ws_row - 1);
|
||||
printf(C_COLOR_NORMAL C_COLOR_WHITE_ON_BLUE);
|
||||
for (int i = 0; i < terminalSize.ws_col; i++) {
|
||||
for (int i = 0; i < TermWindowSize.ws_col; i++) {
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
setCursorLocation(1, terminalSize.ws_row);
|
||||
TermSetCursorLocation(1, TermWindowSize.ws_row);
|
||||
printf(C_COLOR_NORMAL);
|
||||
for (int i = 0; i < terminalSize.ws_col; i++) {
|
||||
for (int i = 0; i < TermWindowSize.ws_col; i++) {
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
setCursorLocation(1, terminalSize.ws_row);
|
||||
TermSetCursorLocation(1, TermWindowSize.ws_row);
|
||||
printf("%sQ%s Quit\t%sS%s Start/Stop",
|
||||
C_COLOR_NORMAL C_COLOR_REVERSE,
|
||||
C_COLOR_NORMAL,
|
||||
C_COLOR_REVERSE,
|
||||
C_COLOR_NORMAL);
|
||||
|
||||
setCursorLocation(1, 3);
|
||||
TermSetCursorLocation(1, 3);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
//
|
||||
// Monitor mode main loop
|
||||
//
|
||||
int connectedMonitor(int sockfd)
|
||||
int CliConnectedMonitor(int sockfd)
|
||||
{
|
||||
char sendBuff[SEND_BUFFER_SIZE] = {0};
|
||||
char receiveBuff[RECEIVE_BUFFER_SIZE] = {0};
|
||||
|
@ -157,15 +157,15 @@ int connectedMonitor(int sockfd)
|
|||
char curChar;
|
||||
int answerLength;
|
||||
|
||||
signal(SIGWINCH ,decorateMonitor);
|
||||
decorateMonitor(0);
|
||||
signal(SIGWINCH ,CliDecorateMonitor);
|
||||
CliDecorateMonitor(0);
|
||||
|
||||
while (!pleaseStop) {
|
||||
// Zeroing buffer
|
||||
bzero(sendBuff, sizeof(sendBuff));
|
||||
|
||||
// Read command from terminal
|
||||
curChar = getch(NON_BLOCKING);
|
||||
curChar = TermGetch(NON_BLOCKING);
|
||||
|
||||
switch (curChar) {
|
||||
case 'q':
|
||||
|
@ -193,7 +193,7 @@ int connectedMonitor(int sockfd)
|
|||
/* // Invalid command */
|
||||
/* } */
|
||||
}
|
||||
clearScreen();
|
||||
TermClearScreen();
|
||||
printf("%sEnd of monitoring session\n\e[0m", C_COLOR_YELLOW);
|
||||
|
||||
return 0;
|
||||
|
@ -202,7 +202,7 @@ int connectedMonitor(int sockfd)
|
|||
//
|
||||
// Main CLI loop
|
||||
//
|
||||
void connectedCommandLine(int sockfd)
|
||||
void CliConnectedCommandLine(int sockfd)
|
||||
{
|
||||
char sendBuff[SEND_BUFFER_SIZE] = {0};
|
||||
char receiveBuff[RECEIVE_BUFFER_SIZE] = {0};
|
||||
|
@ -230,7 +230,7 @@ void connectedCommandLine(int sockfd)
|
|||
curPosition = 0;
|
||||
continueReadLine = 1;
|
||||
historyModifier = -1;
|
||||
while (continueReadLine && (curChar = getch(0))) {
|
||||
while (continueReadLine && (curChar = TermGetch(0))) {
|
||||
|
||||
switch (curChar) {
|
||||
|
||||
|
@ -249,7 +249,7 @@ void connectedCommandLine(int sockfd)
|
|||
|
||||
if (curLineLength >= 0) {
|
||||
|
||||
saveCursorLocation();
|
||||
TermSaveCursorLocation();
|
||||
|
||||
memmove(sendBuff + curPosition, sendBuff + curPosition + 1,
|
||||
SEND_BUFFER_SIZE);
|
||||
|
@ -260,15 +260,15 @@ void connectedCommandLine(int sockfd)
|
|||
sendBuff
|
||||
);
|
||||
|
||||
restoreCursorLocation();
|
||||
TermRestoreCursorLocation();
|
||||
moveCursorBackward();
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_ESCAPE_1:
|
||||
if (getch(0) == KEY_ESCAPE_2) {
|
||||
if (TermGetch(0) == KEY_ESCAPE_2) {
|
||||
|
||||
switch(getch(0)) {
|
||||
switch(TermGetch(0)) {
|
||||
|
||||
case KEY_ARROW_UP:
|
||||
if (historyIndex <= 0)
|
||||
|
@ -321,13 +321,13 @@ void connectedCommandLine(int sockfd)
|
|||
|
||||
case KEY_ARROW_RIGHT:
|
||||
if (curPosition < curLineLength) {
|
||||
moveCursorForward();
|
||||
TermMoveCursorForward();
|
||||
curPosition++;
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_ESCAPE_3:
|
||||
if (getch(0) == KEY_DELETE) {
|
||||
if (TermGetch(0) == KEY_DELETE) {
|
||||
if (strlen(sendBuff) == 0)
|
||||
break;
|
||||
|
||||
|
@ -337,7 +337,7 @@ void connectedCommandLine(int sockfd)
|
|||
|
||||
if (curLineLength >= 0) {
|
||||
|
||||
saveCursorLocation();
|
||||
TermSaveCursorLocation();
|
||||
|
||||
memmove(sendBuff + curPosition, sendBuff + curPosition + 1,
|
||||
SEND_BUFFER_SIZE);
|
||||
|
@ -348,10 +348,10 @@ void connectedCommandLine(int sockfd)
|
|||
sendBuff
|
||||
);
|
||||
|
||||
restoreCursorLocation();
|
||||
TermRestoreCursorLocation();
|
||||
}
|
||||
else {
|
||||
moveCursorForward(); // XXX
|
||||
TermMoveCursorForward(); // XXX
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -362,9 +362,9 @@ void connectedCommandLine(int sockfd)
|
|||
|
||||
default:
|
||||
if (curLineLength < MIN(SEND_BUFFER_SIZE,
|
||||
terminalSize.ws_col - promptLength - 3)
|
||||
TermWindowSize.ws_col - promptLength - 3)
|
||||
&& curChar > 0) {
|
||||
saveCursorLocation();
|
||||
TermSaveCursorLocation();
|
||||
|
||||
memmove(sendBuff + curPosition + 1, sendBuff + curPosition,
|
||||
SEND_BUFFER_SIZE);
|
||||
|
@ -378,8 +378,8 @@ void connectedCommandLine(int sockfd)
|
|||
sendBuff
|
||||
);
|
||||
|
||||
restoreCursorLocation();
|
||||
moveCursorForward();
|
||||
TermRestoreCursorLocation();
|
||||
TermMoveCursorForward();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ void connectedCommandLine(int sockfd)
|
|||
|
||||
// Launch monitor mode if asked
|
||||
if (strcmp(monitorCommand, sendBuff) == 0) {
|
||||
connectedMonitor(sockfd);
|
||||
CliConnectedMonitor(sockfd);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -465,10 +465,10 @@ int main(void)
|
|||
|
||||
printLog("%sConnected to server!\n\n", C_COLOR_GREEN);
|
||||
|
||||
signal(SIGWINCH, getScreenSize);
|
||||
getScreenSize(0);
|
||||
signal(SIGWINCH, TermGetScreenSize);
|
||||
TermGetScreenSize(0);
|
||||
|
||||
connectedCommandLine(sockfd);
|
||||
CliConnectedCommandLine(sockfd);
|
||||
|
||||
// close the socket
|
||||
close(sockfd);
|
||||
|
|
|
@ -53,7 +53,7 @@ char *CmdModel(char *buf, char **argv, Server_t *args)
|
|||
// TODO get the file content (sent by the client) from args
|
||||
|
||||
// Creating model
|
||||
ModelCreate(&newModel);
|
||||
ModelAddToKnown(&newModel);
|
||||
|
||||
// TODO modify model according to things in file
|
||||
|
||||
|
|
|
@ -135,7 +135,6 @@ int main(int argc, char **argv)
|
|||
|
||||
// Exiting
|
||||
returnValue |= server->returnValue;
|
||||
ServerDestroy(server);
|
||||
ModelSystemDestroy();
|
||||
free(server);
|
||||
server = NULL;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "../include/base.h"
|
||||
#include "../include/centers.h"
|
||||
#include "../include/localworker.h"
|
||||
#include "../include/worker.h"
|
||||
#include "../include/arrows.h"
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
|
@ -103,7 +103,7 @@ static void *schedulerMain(void *scheduler)
|
|||
centersList = (Center_t*) calloc(1, sizeof(Center_t));
|
||||
|
||||
// Initiate the arrowArray lock
|
||||
if (err = createArrowLock(args->arrowArray), err != 0) { // TODO destroy this
|
||||
if (err = ArrowsInitLock(args->arrowArray), err != 0) { // TODO destroy this
|
||||
printLog("Impossible to create the arrow array lock (error %d)\n", err);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ static void *schedulerMain(void *scheduler)
|
|||
workArea = NULL;
|
||||
|
||||
// Acquiring lock to consistently read the arrowArray
|
||||
if (acquireNonBlockingArrowLock(args->arrowArray)) {
|
||||
if (ArrowsAcquireNonBlockingLock(args->arrowArray)) {
|
||||
// Random choice of an arrow
|
||||
electedArrow =
|
||||
&args->arrowArray->array[rand() % args->arrowArray->size];
|
||||
|
@ -135,7 +135,7 @@ static void *schedulerMain(void *scheduler)
|
|||
args->globalDrawingSpace->yMax,
|
||||
args->globalDrawingSpace->zMax
|
||||
);
|
||||
releaseArrowLock(args->arrowArray);
|
||||
ArrowsReleaseLock(args->arrowArray);
|
||||
}
|
||||
|
||||
// If a free area exists,
|
||||
|
|
|
@ -58,7 +58,7 @@ void *serverCommunicationInstance(void *server)
|
|||
inet_ntop(AF_INET,
|
||||
&args->clientAddr.sin_addr,
|
||||
clientIP,
|
||||
args->socklen);
|
||||
args->sockLen);
|
||||
|
||||
// Get port number from client
|
||||
clientPort = ntohs(args->clientAddr.sin_port);
|
||||
|
@ -106,7 +106,7 @@ void *serverCommunicationInstance(void *server)
|
|||
// Execute command by first arg in cmdList
|
||||
for (int i = 0; i < LEN(cmdList); i++) {
|
||||
if (strcmp(cmdList[i].name, argv[0]) == 0) {
|
||||
cmdList[i].execute(sendBuff, argv, args->parent);
|
||||
cmdList[i].execute(sendBuff, argv, args->associatedServer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,9 +225,9 @@ static void *serverMain(void *server)
|
|||
ntohs(serverSlots[serverSlotIndex].clientAddr.sin_port)); // TODO envisager déplacement dans thread
|
||||
|
||||
// Populate communicator slot
|
||||
serverSlots[serverSlotIndex].socklen = socklen; // XXX
|
||||
serverSlots[serverSlotIndex].sockLen = socklen; // XXX
|
||||
serverSlots[serverSlotIndex].sockfd = connfd;
|
||||
serverSlots[serverSlotIndex].parent = args;
|
||||
serverSlots[serverSlotIndex].associatedServer = args;
|
||||
|
||||
// Create thread
|
||||
threadStatus = pthread_create(&serverSlots[serverSlotIndex].id,
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "../include/base.h"
|
||||
|
||||
static void *workerMain(void *worker);
|
||||
static void *WorkerMain(void *worker);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -30,7 +30,7 @@ static void *workerMain(void *worker);
|
|||
// -------------------------------------------------------------------------- //
|
||||
void WorkerInit(Worker_t *worker)
|
||||
{
|
||||
if (pthread_create(&worker->id, NULL, workerMain, worker)) {
|
||||
if (pthread_create(&worker->id, NULL, WorkerMain, worker)) {
|
||||
printLog("Worker #%lu can't be initialized!\n", worker->id);
|
||||
return;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ void WorkerInit(Worker_t *worker)
|
|||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler thread main function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static void *workerMain(void *worker)
|
||||
static void *WorkerMain(void *worker)
|
||||
{
|
||||
Worker_t *args;
|
||||
int a = rand()%__INT_MAX__;
|
Loading…
Reference in New Issue