#include #include #include #include using namespace std; #define RESET "\033[0m" #define BLACK "\033[30m" /* Black */ #define RED "\033[31m" /* Red */ #define GREEN "\033[32m" /* Green */ #define YELLOW "\033[33m" /* Yellow */ #define BLUE "\033[34m" /* Blue */ #define MAGENTA "\033[35m" /* Magenta */ #define CYAN "\033[36m" /* Cyan */ #define WHITE "\033[37m" /* White */ #define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ #define BOLDRED "\033[1m\033[31m" /* Bold Red */ #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ #define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ #define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ #define BOLDWHITE "\033[1m\033[37m" /* Bold White */ //---------------------------------------------------------------- int get_run_num(int cmd); //--------------------------------------------------------------------------------------- // BUFFER description //--------------------------------------------------------------------------------------- class LogBuffer { public: int MAXBUF; char *log_buf; //-- event buffer int *wr_p, *rd_p, *loop_flag, *fill_level; LogBuffer(LogBufferShm *buf, int size) { printf("Logbuffer:: Constructor, size=%d\n",size); sleep(1); MAXBUF=size-1; wr_p=&buf->wr_ptr; rd_p=&buf->rd_ptr; loop_flag=&buf->loop_ptr; fill_level=&buf->level_ptr; //log_buf = new char [size]; *wr_p=0; *rd_p=0; log_buf = buf->buf; } ~LogBuffer() { printf("Logbuffer:: Destructor\n"); //delete log_buf; } int write(char *text, int size) { //if (wr_p==*rd_p && loop_flag>0) { fill_level=MAXBUF*loop_flag+wr_p-*rd_p; return 1; } printf("LogBuffer:write():: 1:: size=%d wr=%d\n",size,*wr_p); for (int bc=0; bcMAXBUF) size=MAXBUF; if (size<=*wr_p) { *rd_p=(*wr_p)-size; *loop_flag=0; } else { *rd_p=MAXBUF-(size-*wr_p); *loop_flag=1; } int ic=0; printf("LogBuffer:read():: 3:: size=%d rd=%d (p=%p) wr=%d(p=%p) loop=%d(p=%p) \n",size,*rd_p,rd_p,*wr_p,wr_p,*loop_flag,loop_flag ); for (int bc=0; bc0) { //printf("LogBuffer:read():: 3:: size=%d rd=%d wr=%d char(%d)=(0x%x)%c \n",size,*rd_p,*wr_p, ic,text[ic],text[ic] ); ic++; } } return ic; } int level() { return MAXBUF*(*loop_flag)+(*wr_p)-(*rd_p); } }; //--------------------------------------------------------------------------------------- const int LHOST=128; struct HOST { int PORT; char NAME[LHOST]; roc_shmem *shmem_ptr; LogBuffer *logbuffer_ptr; int semid; int shmid; };