Example #1
0
void LogManager::Initialize(const string& LogStreamName,
                            LogFileCompressionTechniqueT LogCompressionTechnique)
{
    Finalize();

    if (LogStreamName == "") {
        LogStream() = &std::cout;
    } else {
        auto LogStreamFileName = LogStreamName;
        auto LocalLogStream = new boost::iostreams::filtering_ostream();
        LocalLogStream->set_auto_close(true);
        if (LogCompressionTechnique == LogFileCompressionTechniqueT::COMPRESS_BZIP2) {
            LocalLogStream->push(boost::iostreams::bzip2_compressor(9));
            if (!boost::algorithm::ends_with(LogStreamFileName, ".bz2")) {
                LogStreamFileName = LogStreamFileName + ".bz2";
            }
        } else if (LogCompressionTechnique == LogFileCompressionTechniqueT::COMPRESS_GZIP) {
            LocalLogStream->push(boost::iostreams::gzip_compressor(9));
            if (!boost::algorithm::ends_with(LogStreamFileName, ".gz")) {
                LogStreamFileName += ".gz";
            }
        }

        auto OpenFlags = ios_base::out;
        if (LogCompressionTechnique != LogFileCompressionTechniqueT::COMPRESS_NONE) {
            OpenFlags = OpenFlags | ios_base::binary;
        }

        LocalLogStream->push(boost::iostreams::file_sink(LogStreamFileName, OpenFlags));
        LogStream() = LocalLogStream;
    }
}
Example #2
0
File: serial.cpp Project: reddec/io
io::Serial::Serial(const std::string &path) : path_(path) {
    set_auto_close(true);
}
Example #3
0
/*
 * APOLLO_init
 *
 *	initialises window to occupy current window
 */
APOLLO_init()
{
	pad_$window_desc_t 	window;
	int 	size, prefx, prefy, prefxs, prefys, x, y, w, h;
	short 	i;

	pad_$set_scale(stream_$stdout,
		       1,
		       1,
		       status);

	pad_$inq_windows(stream_$stdout,
			 window_info,
				  10,
			   n_windows,
			     status);

	w = window_info[0].width;
	h = window_info[0].height;
	x = window_info[0].left;
	y = window_info[0].top;

	getprefposandsize(&prefx, &prefy, &prefxs, &prefys);

	if (prefx > -1) {
		x = prefx;
		y = prefy;
	}

	if (prefxs > -1) {
		w = prefxs;
		h = prefys;
	}

	size = MIN(w, h);
	vdevice.sizeX = vdevice.sizeY = size - 1;
	vdevice.sizeSx = w - 1;
	vdevice.sizeSy = h - 1;

        init_bitmap_size.x_size = w;
        init_bitmap_size.y_size = h;

	source.window_base.x_coord = source.window_base.y_coord = 0;
	source.window_size.x_size = init_bitmap_size.x_size;
	source.window_size.y_size = init_bitmap_size.y_size;
	dest_pos.x_coord = dest_pos.y_coord = 0;

	/*
	 * Inquire about the actual display ....
	 */

	gpr_$inq_disp_characteristics(mode,
				      stream_$stdout,
				      (short)60,
				      disp,
				      disp_len,
				      status);

	vdevice.depth = disp.n_planes;
	hi_plane_id = disp.n_planes - 1;

	if (prefx == -1 && prefxs == -1) {
		stream_id = stream_$stdout;
	} else {
		window.top = y;
		window.left = x;
		window.width = w;
		window.height = h;

		pad_$create_window("", 0,
				pad_$transcript, 
				1, 
				window,
				stream_id,
				status
		);

		pad_$set_auto_close(stream_id, 1, true, status);
	}

        gpr_$init(mode,
                  stream_id,
                  init_bitmap_size,
                  hi_plane_id,
                  front_bitmap,
                  status);

	current_bitmap = front_bitmap;

	gpr_$set_auto_refresh(true, status);
  
	gpr_$set_cursor_active(false,status);

	/*  Set up all the character stuff  */

	first_time = 1;

	/*  create a key set for the event interupts  */

	lib_$init_set(keys, (short)256);
	lib_$init_set(mouse_keys, (short)6);

	lib_$add_to_set(mouse_keys, (short)6, KBD_$M1D);
	lib_$add_to_set(mouse_keys, (short)6, KBD_$M2D);
	lib_$add_to_set(mouse_keys, (short)6, KBD_$M3D);
	lib_$add_to_set(mouse_keys, (short)6, KBD_$M1U);
	lib_$add_to_set(mouse_keys, (short)6, KBD_$M2U);
	lib_$add_to_set(mouse_keys, (short)6, KBD_$M3U);

	for (i = 0; i < 128; i++) 
		lib_$add_to_set(keys, (short)256, (short)i);

	gpr_$enable_input(gpr_$keystroke, keys, status);
	gpr_$enable_input(gpr_$buttons, keys, status);
	gpr_$enable_input(gpr_$locator, keys, status);

	/*  set default color (colour)   */

	if (disp.n_planes > 1) {
		gpr_$inq_color_map(0L, (short)MAXCOLORS, old_color_value, status);
		gpr_$inq_color_map(0L, (short)MAXCOLORS, color_value, status);

		color_value[0] = COLOR_ENTRY(0,0,0);         /* color--black   */
		color_value[1] = COLOR_ENTRY(255,0,0);       /* color--red     */
		color_value[2] = COLOR_ENTRY(0,255,0);       /* color--green   */
		color_value[3] = COLOR_ENTRY(255,255,0);     /* color--yellow  */
		color_value[4] = COLOR_ENTRY(0,0,255);       /* color--blue    */
		color_value[5] = COLOR_ENTRY(255,0,255);     /* color--magenta */
		color_value[6] = COLOR_ENTRY(0,255,255);     /* color--cyan    */
		color_value[7] = COLOR_ENTRY(255,255,255);   /* color--white   */

		/* modify color table */
		gpr_$acquire_display(status);
		gpr_$set_color_map((long)0,
				    (short)MAXCOLORS,
				    color_value,
				    status);
		gpr_$release_display(status);
	}

	back_used = 0;

	return(1);
}