# Path: afl_utils/AflPrettyPrint.py
# def print_err(msg_str):
#     print("{0}[!] {1}{2}".format(clr.LRD, clr.RST, msg_str))
# 
# def print_ok(msg_str):
#     print("{0}[*] {1}{2}".format(clr.LGN, clr.RST, msg_str))
# 
# class clr:
#     # taken from AFL's debug.h
#     BLK = "\x1b[0;30m"
#     RED = "\x1b[0;31m"
#     GRN = "\x1b[0;32m"
#     BRN = "\x1b[0;33m"
#     BLU = "\x1b[0;34m"
#     MGN = "\x1b[0;35m"
#     CYA = "\x1b[0;36m"
#     NOR = "\x1b[0;37m"
#     GRA = "\x1b[1;30m"
#     LRD = "\x1b[1;31m"
#     LGN = "\x1b[1;32m"
#     YEL = "\x1b[1;33m"
#     LBL = "\x1b[1;34m"
#     PIN = "\x1b[1;35m"
#     LCY = "\x1b[1;36m"
#     BRI = "\x1b[1;37m"
#     RST = "\x1b[0m"


import argparse
    import simplejson as json
    import json
import os
import shutil
import signal
import subprocess
import sys
import time
import afl_utils
from afl_utils.AflPrettyPrint import print_err, print_ok, clr


def setup_screen_env(env_list):
    if len(env_list) > 0:
        # set environment variables in initializer window
        for env in env_list:
            env_tuple = env.split("=")
            screen_env_cmd = ["screen", "-X", "setenv", env_tuple[0], env_tuple[1]]
            subprocess.Popen(screen_env_cmd)

    # Set working directory for all newly
    # created screen windows to the directory
    # afl-multicore was executed from.
    cwd = os.getcwd()
    subprocess.Popen(["screen", "-X", "chdir", cwd])


def setup_screen(windows, env_list):
    setup_screen_env(env_list)

    # create number of windows
    for i in range(0, windows, 1):
        subprocess.Popen(["screen"])

    # go back to 1st window
    subprocess.Popen("screen -X select 0".split())


def sigint_handler(signal, frame):
    print()

# Path: afl_utils/AflPrettyPrint.py
# def print_err(msg_str):
#     print("{0}[!] {1}{2}".format(clr.LRD, clr.RST, msg_str))
# 
# def print_ok(msg_str):
#     print("{0}[*] {1}{2}".format(clr.LGN, clr.RST, msg_str))
# 
# class clr:
#     # taken from AFL's debug.h
#     BLK = "\x1b[0;30m"
#     RED = "\x1b[0;31m"
#     GRN = "\x1b[0;32m"
#     BRN = "\x1b[0;33m"
#     BLU = "\x1b[0;34m"
#     MGN = "\x1b[0;35m"
#     CYA = "\x1b[0;36m"
#     NOR = "\x1b[0;37m"
#     GRA = "\x1b[1;30m"
#     LRD = "\x1b[1;31m"
#     LGN = "\x1b[1;32m"
#     YEL = "\x1b[1;33m"
#     LBL = "\x1b[1;34m"
#     PIN = "\x1b[1;35m"
#     LCY = "\x1b[1;36m"
#     BRI = "\x1b[1;37m"
#     RST = "\x1b[0m"


# Path: afl_utils/afl_multicore.py
import argparse
    import simplejson as json
    import json
import os
import shutil
import signal
import subprocess
import sys
import time
import afl_utils
from afl_utils.AflPrettyPrint import print_err, print_ok, clr



def setup_screen_env(env_list):
    if len(env_list) > 0:
        # set environment variables in initializer window
        for env in env_list:
            env_tuple = env.split("=")
            screen_env_cmd = ["screen", "-X", "setenv", env_tuple[0], env_tuple[1]]
            subprocess.Popen(screen_env_cmd)

    # Set working directory for all newly
    # created screen windows to the directory
    # afl-multicore was executed from.
    cwd = os.getcwd()
    subprocess.Popen(["screen", "-X", "chdir", cwd])


def setup_screen(windows, env_list):
    setup_screen_env(env_list)

    # create number of windows
    for i in range(0, windows, 1):
        subprocess.Popen(["screen"])

    # go back to 1st window
    subprocess.Popen("screen -X select 0".split())


def sigint_handler(signal, frame):
    print()

    print_ok("Test run aborted by user!")