-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
89 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
!srcs | ||
!srcs/Client | ||
!srcs/Debug | ||
!srcs/Result | ||
!srcs/Server | ||
!srcs/Socket | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# include <unistd.h> | ||
# include <stdarg.h> | ||
# include <cstdio> | ||
# include "Color.hpp" | ||
# include "Debug.hpp" | ||
|
||
pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
|
||
void DEBUG_SERVER_PRINT(const char *fmt, ...) { | ||
#ifdef DEBUG | ||
pthread_mutex_lock(&print_mutex); | ||
dprintf(STDERR_FILENO, "%s%s", BLUE, "#DEBUG server: "); | ||
va_list args; | ||
va_start(args, fmt); | ||
vdprintf(STDERR_FILENO, fmt, args); | ||
va_end(args); | ||
dprintf(STDERR_FILENO, "%s\n", RESET); | ||
pthread_mutex_unlock(&print_mutex); | ||
#else | ||
(void)fmt; | ||
#endif | ||
} | ||
|
||
void DEBUG_CLIENT_PRINT(const char *fmt, ...) { | ||
#ifdef DEBUG | ||
pthread_mutex_lock(&print_mutex); | ||
dprintf(STDERR_FILENO, "%s%s", MAGENTA, "#DEBUG client: "); | ||
va_list args; | ||
va_start(args, fmt); | ||
vdprintf(STDERR_FILENO, fmt, args); | ||
va_end(args); | ||
dprintf(STDERR_FILENO, "%s\n", RESET); | ||
pthread_mutex_unlock(&print_mutex); | ||
#else | ||
(void)fmt; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
# include <pthread.h> | ||
|
||
extern pthread_mutex_t print_mutex; | ||
|
||
void DEBUG_SERVER_PRINT(const char *fmt, ...); | ||
void DEBUG_CLIENT_PRINT(const char *fmt, ...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters