From b56991c995e828819fa5d4646b7fce2b5a46f487 Mon Sep 17 00:00:00 2001 From: DanArmor <39347109+DanArmor@users.noreply.github.com> Date: Fri, 10 Mar 2023 20:19:13 +0300 Subject: [PATCH] feat: prefix and no prefix mode --- inc/util.h | 1 + src/mailserver.c | 12 +++++++++--- src/util.c | 12 +++++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/inc/util.h b/inc/util.h index 2b4a8c4..e71e6ee 100644 --- a/inc/util.h +++ b/inc/util.h @@ -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; diff --git a/src/mailserver.c b/src/mailserver.c index 60f02b0..ae5f010 100644 --- a/src/mailserver.c +++ b/src/mailserver.c @@ -21,6 +21,7 @@ char errorBuffer[512]; int keepRunning = 1; int isGuiRunning = 1; int flagNOGUI = 0; +int flagIsPrefix = 1; HANDLE glOutputMutex; HANDLE glThreadMutex; @@ -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){ diff --git a/src/util.c b/src/util.c index 15fab8e..4149d45 100644 --- a/src/util.c +++ b/src/util.c @@ -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); + } } } @@ -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);