Skip to content

Commit

Permalink
feat: prefix and no prefix mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DanArmor committed Mar 10, 2023
1 parent 4616cab commit b56991c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions inc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ BOOL WINAPI IsServerCommand(LocalThreadInfo *lThInfo, char *command);

extern int keepRunning;
extern int isGuiRunning;
extern int flagIsPrefix;

extern HANDLE glOutputMutex;
extern HANDLE glThreadMutex;
Expand Down
12 changes: 9 additions & 3 deletions src/mailserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ char errorBuffer[512];
int keepRunning = 1;
int isGuiRunning = 1;
int flagNOGUI = 0;
int flagIsPrefix = 1;

HANDLE glOutputMutex;
HANDLE glThreadMutex;
Expand Down Expand Up @@ -82,9 +83,14 @@ UserInfo *ReadUsersFromFile(char *filename, int *nUsers){
// сообщения пользователей во время старта сессии - а читать их по требованию
int main(int argc, char **argv){
if(argc != 1){
if(strncmp(argv[1], "-NO-GUI", 8) == 0){
flagNOGUI = 1;
isGuiRunning = 0;
for(int i = 1; i < argc; i++){
if(strncmp(argv[1], "-NO-GUI", 8) == 0){
flagNOGUI = 1;
isGuiRunning = 0;
}
if(strncmp(argv[1], "-NO-PREF", 9) == 0){
flagIsPrefix = 0;
}
}
}
if(flagNOGUI == 0){
Expand Down
12 changes: 7 additions & 5 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ void WriteToSession(SessionLog *sessionLog, char *msg, int size){
}

void WriteToSessionPrefix(SessionLog *sessionLog, int isServer){
if(isServer){
WriteToSession(sessionLog, "SERVER: ", 8);
} else{
WriteToSession(sessionLog, "CLIENT: ", 8);
if(flagIsPrefix){
if(isServer){
WriteToSession(sessionLog, "=== SERVER ===\015\012", 16);
} else{
WriteToSession(sessionLog, "=== CLIENT ===\015\012", 16);
}
}
}

Expand Down Expand Up @@ -118,7 +120,7 @@ void StopProcessingClient(LocalThreadInfo *lThInfo){
PLTH_REPORT(lThInfo, "Terminating.\nBuffer data:\n===\n%s===\n", lThInfo->buff);

lThInfo->sessionLog.isDead = 1;
WriteToSession(&lThInfo->sessionLog, "======END OF SESSION======\015\012", 28);
WriteToSession(&lThInfo->sessionLog, "======END OF SESSION======\015\012", 30);
MigrateDeadSession(&lThInfo->sessionLog);
closesocket(lThInfo->pthreadInfo->client);
free(lThInfo->buff);
Expand Down

0 comments on commit b56991c

Please sign in to comment.