Skip to content
This repository has been archived by the owner on Jun 24, 2023. It is now read-only.

Commit

Permalink
colors are back!
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jun 14, 2016
1 parent f673cf7 commit ad90949
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static int parse_options (int argc, char** argv)
xlog(LOG_CRITICAL, "realpath(logfile) failed: %s\n", strerror(errno));
return -1;
}
if(is_readable_file(cfg->logfile)) {
if(is_writable_file(cfg->logfile)) {
cfg->logfile_fd = fopen(cfg->logfile, "w");
if(!cfg->logfile_fd) {
cfg->logfile_fd = stderr;
Expand All @@ -368,8 +368,9 @@ static int parse_options (int argc, char** argv)
}
}

/* disable color to avoid tty color code in file */
cfg->use_color = false;
/* disable color to avoid tty color code in file + make sure that file is not in /dev */
if(strncmp(cfg->logfile, "/dev", 4)!=0)
cfg->use_color = false;
}

/* check if nb of threads is in boundaries */
Expand Down
1 change: 1 addition & 0 deletions proxenet-control-web.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def do_start():

cmd.append(PROXENET_BIN + "/proxenet")
cmd.append("--daemon")
cmd.append("--no-color")
cmd.append("--bind=%s" % addr)
cmd.append("--port=%d" % port)
cmd.append("--plugins=%s" % plugins_dir)
Expand Down
12 changes: 12 additions & 0 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,18 @@ bool is_readable_file(char* path)
}


/**
* Check if the argument provided is a (regular) file and is writable by user calling
*
* @param path to the file to check
* @return true is it's a regular and is writable, false otherwise
*/
bool is_writable_file(char* path)
{
return is_file(path) && access(path, W_OK)==0;
}


/**
* Prints a hexdump like version the buffer pointed by argument
*
Expand Down
1 change: 1 addition & 0 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ int proxenet_xsnprintf(char *str, size_t size, const char *format, ...);
bool is_valid_plugin_path(char*, char**, char**);
bool is_file(char*);
bool is_readable_file(char*);
bool is_writable_file(char*);
char* expand_file_path(char*);
void proxenet_hexdump(char*, int);

Expand Down

0 comments on commit ad90949

Please sign in to comment.