コード例 #1
0
ファイル: tixBalloon.c プロジェクト: iivvoo-abandoned/circus
void	tixBalloon::bind(widget *w, const char *status,
                         const char *balloon)
/*
 * bind this balloon to a specific widget, with a separate message
 * for the statusbar and for the balloon
 */
// Bind to widget 'w' using 'options', and _msg etc if they're set.
{
	if(status && balloon)
	{
		tk << _path << " bind " << w->path() << " " 
	     	   << "-statusmsg \"" << esc(status) << "\" " 
	           << "-balloonmsg \"" << esc(balloon) << "\"" << end;
	}
	else if(status)
	{
		tk << _path << " bind " << w->path() << " " 
	     	   << "-statusmsg \"" << esc(status) << "\"" << end;

	}
	else	// assume just balloon, both NULL doesn't make sense
	{
		tk << _path << " bind " << w->path() << " " 
	           << "-balloonmsg \"" << esc(balloon) << "\"" << end;
	}
}
コード例 #2
0
ファイル: channelwin.c プロジェクト: iivvoo-abandoned/circus
int	channelwin::operator()()
{
	int 	i;
	int 	argc = _event->argc(); char **argv = _event->argv();
	cstring	cmd;

	if(dbg > 5)
	{
	    cout << "Channelwin event happened:" << endl;
	    for(i = 0; i < argc; i++)
		cout << "Arg " << i << ": " << argv[i] << endl;
	}

	cmd = eventname + " " + esc(cname);	// .lower()?
	
	for(i = 0; i < argc; i++)
	{
		cmd += " ";
		cmd += esc(argv[i]);
	}

	cmd << " " <<  _event->x_root() << " " << _event->y_root();

	tk->eval(cmd);
	return true;
}
コード例 #3
0
void torrent_view::print_torrent(lt::torrent_status const& s, bool selected)
{
	int pos = 0;
	char str[512];

	// the active torrent is highligted in the list
	// this inverses the forground and background colors
	char const* selection = "";
	if (selected)
		selection = "\x1b[1m\x1b[44m";

	char queue_pos[16] = {0};
	if (s.queue_position == -1)
		snprintf(queue_pos, sizeof(queue_pos), "-");
	else
		snprintf(queue_pos, sizeof(queue_pos), "%d", s.queue_position);

	std::string name = s.name;
	if (name.size() > 50) name.resize(50);

	color_code progress_bar_color = col_yellow;
	if (!s.error.empty()) progress_bar_color = col_red;
	else if (s.paused) progress_bar_color = col_blue;
	else if (s.state == lt::torrent_status::downloading_metadata)
		progress_bar_color = col_magenta;
	else if (s.current_tracker.empty())
		progress_bar_color = col_green;

	pos += snprintf(str + pos, sizeof(str) - pos, "%s%c%-3s %-50s %s%s %s (%s) "
		"%s (%s) %5d:%-5d %s %s %c%s"
		, selection
		, s.is_loaded ? 'L' : ' '
		, queue_pos
		, name.c_str()
		, progress_bar(s.progress_ppm / 1000, 35, progress_bar_color, '-', '#', torrent_state(s)).c_str()
		, selection
		, color(add_suffix(s.download_rate, "/s"), col_green).c_str()
		, color(add_suffix(s.total_download), col_green).c_str()
		, color(add_suffix(s.upload_rate, "/s"), col_red).c_str()
		, color(add_suffix(s.total_upload), col_red).c_str()
		, s.num_peers - s.num_seeds, s.num_seeds
		, color(add_suffix(s.all_time_download), col_green).c_str()
		, color(add_suffix(s.all_time_upload), col_red).c_str()
		, s.need_save_resume?'S':' ', esc("0"));

	// if this is the selected torrent, restore the background color
	if (selected)
		pos += snprintf(str + pos, sizeof(str) - pos, "%s", esc("0"));

	pos += snprintf(str + pos, sizeof(str) - pos, "\x1b[K");

	if (m_width + 1 < sizeof(str))
		str[m_width + 1] = '\0';

	print(str);
}
コード例 #4
0
RES ResourceFormatLoaderChibi::load(const String &p_path, const String& p_original_path, Error *r_error) {

	if (r_error)
		*r_error=ERR_FILE_CANT_OPEN;
	String el = p_path.extension().to_lower();

	CPFileAccessWrapperImpl f;

	if (el=="it") {

		Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) );
		CPLoader_IT loader(&f);
		CPLoader::Error err = loader.load_song(p_path.utf8().get_data(),&esc->song,false);
		ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES());
		if (r_error)
			*r_error=OK;

		return esc;

	} else if (el=="xm") {

		Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) );
		CPLoader_XM loader(&f);
		CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false);
		ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES());
		if (r_error)
			*r_error=OK;
		return esc;

	} else if (el=="s3m") {

		Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) );
		CPLoader_S3M loader(&f);
		CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false);
		ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES());
		if (r_error)
			*r_error=OK;

		return esc;

	} else if (el=="mod") {

		Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) );
		CPLoader_MOD loader(&f);
		CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false);
		ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES());
		if (r_error)
			*r_error=OK;
		return esc;
	}

	return RES();

}
コード例 #5
0
ファイル: main.cpp プロジェクト: mpapierski/simpledaemon
	server(boost::asio::io_service & io_service,
				const boost::asio::ip::tcp::endpoint & endpoint)
		: io_service_(io_service)
		, acceptor_(io_service_, endpoint)
	{
		std::cout << esc(MAKE_GREEN)
			<< LOG_HEADER
			<< "Echo server is listening on port: "
			<< endpoint.port()
			<< esc(RESET_COLOR)
			<< std::endl;
		start_accept();
	}
コード例 #6
0
ファイル: querywin.c プロジェクト: iivvoo-abandoned/circus
int	messagewin::operator()()
{
	int 	i;
	int 	argc = _event->argc(); char **argv = _event->argv();
	cstring	cmd;

	if(dbg > 5)
	{
	    cout << "An event happened:" << endl;
	    for(i = 0; i < argc; i++)
	  	cout << "Arg " << i << ": " << argv[i] << endl;
	}

	cmd = "MessageWin ";
	cmd += (path() + 1);

	for(i = 0; i < argc; i++)
	{
	        cmd += " ";
		cmd += argv[i];
	}

	tk->eval(esc(cmd));
	return true;
}
コード例 #7
0
ファイル: SockBuffer.cpp プロジェクト: gene-hightower/ghsmtp
std::streamsize SockBuffer::read(char* s, std::streamsize n)
{
  if (maxed_out()) {
    LOG(ERROR) << "read attempted when"
               << " total of " << octets_read_ << " is over limit of "
               << read_limit_;
    return static_cast<std::streamsize>(-1);
  }
  auto read = tls_active_ ? tls_.read(s, n, read_timeout_, timed_out_)
                          : POSIX::read(fd_in_, s, n, read_hook_, read_timeout_,
                                        timed_out_);
  if (read != static_cast<std::streamsize>(-1)) {
    octets_read_ += read;
    total_octets_read_ += read;
  }
  if (maxed_out()) {
    LOG(ERROR) << "read of " << read << " puts total of " << octets_read_
               << " over limit of " << read_limit_;
    return static_cast<std::streamsize>(-1);
  }

  if (log_data_) {
    auto str = std::string(s, static_cast<size_t>(read));
    LOG(INFO) << "< «" << esc(str, esc_line_option::multi) << "»";
  }

  return read;
}
コード例 #8
0
void main()
{
	char i;
	printf("      欢迎进入电子与信息工程学院2011计算机2班通讯录系统\n");
	printf("1:添加     2:查找       3:修改     4:删除     5:统计     6:打印    7:退出\n");
    check();
	i=getch();
	while(1)
	{
		switch(i)
		{
		   case '1':creat();break;
		   case '2':search();break;
		   case '3':correct();break;
		   case '4':del();break;
		   case '5':printf("通讯录共有%d人!\n",n);	break;	
	       case '6':print();;break;
		   case '7':esc();break;
		default: printf("您的输入有误,请重新输入\n");
		}
		if(i=='7') break;
		printf("1:添加     2:查找       3:修改     4:删除     5:统计     6:打印    7:退出\n");
		i=getch();
	}
	



}
コード例 #9
0
ファイル: find.c プロジェクト: 8l/FUZIX
char * PROC
dodash(char *src)

/* parse the innards of a [] */
{
    int k;
    register char *start = src;
    char cs[128];

    fillchar(cs,sizeof(cs),FALSE);
    while (*src && *src != CCLEND) {
	if (*src == DASH && src>start && src[1] != CCLEND && src[-1]<src[1]) {
	    for ( k = src[-1]; k <= src[1]; k++)
		cs[k] = TRUE;
	    src++;
	}
	else
	    cs[esc(&src)] = TRUE;
	src++;
    }
    for (k=0; k < sizeof(cs); k++)
	if (cs[k])
	    concatch((char)k);
    return src;
}
コード例 #10
0
ファイル: main.cpp プロジェクト: mpapierski/simpledaemon
	void handle_accept(const boost::system::error_code & error,
		const boost::shared_ptr<session> & session_ptr)
	{
		if (!error)
		{
			boost::asio::ip::tcp::endpoint remote_endpoint =
				session_ptr->socket_.remote_endpoint();
			boost::asio::ip::address remote_addr = remote_endpoint.address();
			std::cout << esc(MAKE_GREEN)
				<< LOG_HEADER
				<< "New client connected (" << remote_addr.to_string() << ")"
				<< esc(RESET_COLOR)
				<< std::endl;
			session_ptr->start();
		}
		start_accept();
	}
コード例 #11
0
 static bool checkChange(const AccelString &as)  {
     QString t2 = as.accelerated();
     QString t1 = as.originalText();
     if (t1 != t2)
     {
         if (as.accel() == -1)  {
             removed_string  += "<tr><td>" + esc(t1) + "</td></tr>";
         } else if (as.originalAccel() == -1) {
             added_string += "<tr><td>" + esc(t2) + "</td></tr>";
         } else {
             changed_string += "<tr><td>" + esc(t1) + "</td>";
             changed_string += "<td>" + esc(t2) + "</td></tr>";
         }
         return true;
     }
     return false;
 }
コード例 #12
0
ファイル: call_cc.cpp プロジェクト: iley/intelib
void SchFunctionCall_cc::
DoApply(int paramsc, const SReference paramsv[], IntelibContinuation& lf) const
{
    SReference esc(new SchExpressionEscapeFunction(lf));
    lf.PushTodo(1);   // call with one argument
    lf.PushTodo(IntelibContinuation::quote_parameter, esc);
    lf.PushTodo(IntelibContinuation::quote_parameter, paramsv[0]);
}
コード例 #13
0
ファイル: querywin.c プロジェクト: iivvoo-abandoned/circus
void	querywin::bindings()
{
	// are path and person different?
	cstring wpath = path();
	cstring	which = esc(person.lower());

	tk->eval("wm protocol " + wpath + " WM_DELETE_WINDOW "
	         "\" QueryWin " + esc(which) + " xx close_query \"");
	bind(this);
	toplevel::bind("<Any-FocusIn>", this, "take_focus");
	stopbutton->bind(this, "close_query");
	dcc_button->bind(this, "dcc_pressed");
	chat_button->bind(this, "chat_pressed");
//	in->bind("<Return>", this, "input_typed");
	in->bind("<Return>", (void *)this, StaticHandleInput, "input");
	queryscroll->bind("<ButtonPress>", this, "togglelock");
	queryscroll->bind("<ButtonRelease>", this, "togglelock");
}
コード例 #14
0
ファイル: chatwidget.cpp プロジェクト: hexaditidom/Drawpile
/**
 * The received message is displayed in the chat box.
 * @param nick nickname of the user who said something
 * @param message what was said
 * @param isme if true, the message was sent by this user
 */
void ChatBox::receiveMessage(const QString& nick, const QString& message, bool isme)
{
	QString extrastyle;
	if(isme)
		extrastyle = "color: white";

	// TODO turn URLs into links
	_view->append("<p style=\"margin: 5px 0\"><b style=\""+ extrastyle + "\">&lt;" + esc(nick) + "&gt;</b> " + esc(message) + "</p>");
}
コード例 #15
0
ファイル: tixBalloon.c プロジェクト: iivvoo-abandoned/circus
void	tixBalloon::bind(widget *w, const char *msg)
/*
 * bind this balloon to a specific widget, using 'msg' for both
 * balloon and (if any) statusbar
 */
{
	tk << _path << " bind " << w->path() << " " 
	   << "-msg \"" << esc(msg) << "\"" << end;
}
コード例 #16
0
ファイル: main.cpp プロジェクト: mpapierski/simpledaemon
	void handle_write(const boost::system::error_code & error)
	{
		if (!error)
		{
			start();
		}
		else
		{
			std::cerr << esc(MAKE_RED)
				<< LOG_HEADER
				<< "Unable to write data: "
				<< error.message()
				<< " [Errno: "
				<< error.value()
				<< ']'
				<< esc(RESET_COLOR)
				<< std::endl;
		}
	}
コード例 #17
0
ファイル: main.cpp プロジェクト: mpapierski/simpledaemon
	void operator()(const boost::system::error_code & ec)
	{
		if (ec == boost::asio::error::operation_aborted)
		{
			std::cout << esc(MAKE_YELLOW)
				<< LOG_HEADER
				<< "Echo timer is aborted."
				<< esc(RESET_COLOR)
				<< std::endl;
			return;
		}
		++counter_;
		std::cout << esc(counter_ % 2 == 0 ? MAKE_GREEN : MAKE_YELLOW)
			<< LOG_HEADER
			<< counter_
			<< ". Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." 			<< esc(RESET_COLOR)
			<< std::endl;
		start();
	}
コード例 #18
0
ファイル: torrent_view.cpp プロジェクト: VrajPandya/storm
void torrent_view::print_tabs()
{
	set_cursor_pos(0, 0);

	char str[400];
	int pos = 0;
	char const* filter_names[] = { "all", "downloading", "non-paused"
		, "seeding", "queued", "stopped", "checking", "loaded"};
	for (int i = 0; i < int(sizeof(filter_names)/sizeof(filter_names[0])); ++i)
	{
		pos += snprintf(str+ pos, sizeof(str) - pos, "%s[%s]%s"
			, m_torrent_filter == i?esc("7"):""
			, filter_names[i], m_torrent_filter == i?esc("0"):"");
	}
	pos += snprintf(str + pos, sizeof(str) - pos, "\x1b[K");

	if (m_width + 1 < int(sizeof(str)))
		str[m_width + 1] = '\0';
	print(str);
}
コード例 #19
0
ファイル: main.cpp プロジェクト: mpapierski/simpledaemon
	void handle_motd(const boost::system::error_code & ec)
	{
		std::ifstream ifs("motd.txt", std::ios::binary);
		if (!ifs.is_open())
		{
			std::cerr << esc(MAKE_RED) << LOG_HEADER
				<< "Unable to read MOTD. motd.txt file not found!"
				<< esc(RESET_COLOR)
				<< std::endl;
			return;
		}
		std::string line;
		while (std::getline(ifs, line))
		{
			std::cout << esc(MAKE_BLUE) << LOG_HEADER
				<< "MOTD: " << line
				<< esc(RESET_COLOR)
				<< std::endl;
		}
		start_motd_timer();
	}
コード例 #20
0
ファイル: TR.C プロジェクト: k0gaMSX/legacy
/* Построение ttb (таблицы трансляции) из array. */
char *makttb(char *a, char *ttb, char *xxx) {
	int c;
	char *t = ttb;

	for (; (c = *a) != 0; ++a) {
		if ((ttb - t) >= SSIZE)
			error("Expansion to long for",xxx);
		if (c == ESCAPE)
			*ttb++ = esc(&a);
		else if (c == PCLASS && a[1]) {
			switch (c = tolower(*++a)) {
			case 'z':
				break;
			case 'n':
				ttb = insrange('0','9',ttb);
			case 'a':
				ttb = insrange('A','Z',ttb);
			case 'l':
				ttb = insrange('a','z',ttb);
				break;
			case 'u':
				ttb  = insrange('A','Z',ttb);
				break;
			case 'r':
				ttb = insrange('А','Я',ttb);
			case 'm':
				ttb = insrange('а','п',ttb);
				ttb = insrange('р','я',ttb);
				break;
			case 'b':
				ttb = insrange('А','Я',ttb);
				break;
			case 'd':
				ttb = insrange('0','9',ttb);
				break;
			case 's':
				ttb = insrange(1,' ',ttb);
				break;
			case '.':
				ttb = insrange(1,0377,ttb);
				break;
			default:
				error("Unknown class type",a-1);
			}
		}
		else if (*a == RANGE && ttb != t && a[1])
			ttb = dorange(&a,ttb);
		else	*ttb++ = *a;
	}
	*ttb = 0;
	return t;
}
コード例 #21
0
/*----------------------------------------------------------------------*/
static const tchar *
doccl( pattern  *map, const tchar * src)
{
  /*
   * Set bits in the map corresponding to characters specified in the src
   * character class.
   */

  int first, last, negative;
  const tchar  *start;

  ++src;            /* skip past the [          */
  negative = (*src == NCCL);
  if (negative)         /* check for negative ccl   */
    ++src;
  start = src;          /* start of characters in class */
  memset(map, 0, MAPSIZE);  /* bitmap initially empty       */

  while (*src && *src != CCLEND) {
    if (*src != _T('-')) {
      first = esc(&src);    /* Use temp. to avoid macro  */
      SETBIT(first, map);   /* side effects.             */
    }
    else if (src == start) {
      SETBIT(_T('-'), map);     /* literal dash at start or end */
      ++src;
    }
    else {
      ++src;            /* skip to end-of-sequence char */
      if (*src < src[-2]) {
        first = *src;
        last = src[-2];
      }
      else {
        first = src[-2];
        last = *src;
      }
      while (++first <= last)
        SETBIT(first, map);
      src++;
    }
  }

  if (*src == CCLEND)
    ++src;          /* Skip CCLEND */

  if (negative)
    for (first = MAPSIZE; --first >= 0;)
      *map++ ^= ~0;     /* invert all bits */

  return src;
}
コード例 #22
0
ファイル: checkversion.cpp プロジェクト: LukasKoudela/agros2d
void CheckVersion::run(bool quiet)
{
    m_quiet = quiet;

    QByteArray postData;
    postData.append("OS=" +  esc(SystemUtils::operatingSystem()) + "&");    
    postData.append("PROCESSOR=" +  esc(SystemUtils::cpuType()) + "&");
    postData.append("THREADS=" +  QString::number(SystemUtils::numberOfThreads()) + "&");
    postData.append("MEMORY=" +  QString::number(SystemUtils::totalMemorySize()) + "&");
    postData.append("RESOLUTION=" +  esc(QString("%1 x %2").
                                         arg(QApplication::desktop()->screenGeometry().width()).
                                         arg(QApplication::desktop()->screenGeometry().height())) + "&");
    postData.append("AGROS2D_VERSION=" +  esc(QApplication::applicationVersion()) + "&");
    postData.append("AGROS2D_ARCH=" +  esc(version64bit() ? "64 bit" : "32 bit") + "&");

    QNetworkRequest req(m_url);
    req.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/x-www-form-urlencoded"));

    m_networkReply = m_manager->post(req, postData);

    connect(m_networkReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(handleError(QNetworkReply::NetworkError)));
}
コード例 #23
0
ファイル: main.cpp プロジェクト: mpapierski/simpledaemon
	void handle_read(const boost::system::error_code& error,
		size_t bytes_transferred)
	{
		if (!error)
		{
			boost::asio::async_write(socket_,
				boost::asio::buffer(data_.data(), bytes_transferred),
				boost::bind(&session::handle_write, shared_from_this(),
					boost::asio::placeholders::error));
		}
		else
		{
			std::cerr << esc(MAKE_RED)
				<< LOG_HEADER
				<< "Unable to receive data: "
				<< error.message()
				<< " [Errno: "
				<< error.value()
				<< ']'
				<< esc(RESET_COLOR)
				<< std::endl;
		}
	}
コード例 #24
0
ファイル: Song.cpp プロジェクト: chasezimmy/carillon
Song::Song(int id) {
	MYSQL_RES* res = query("SELECT id, title, path, type FROM song WHERE id = '" + esc(intString(id)) + "'");

	if (num_rows(res)) {
		MYSQL_ROW row = next_res(res);

		this->id = stringInt(row[0]);
		this->title = row[1];
		this->path = row[2];
		this->type = row[3];
	}

	free_res(res);
}
コード例 #25
0
ファイル: querywin.c プロジェクト: iivvoo-abandoned/circus
int	querywin::operator()()
{
	int 	i;
	int 	argc = _event->argc(); char **argv = _event->argv();
	cstring	cmd;

	if(dbg > 5)
	{
	    cout << "An event happened:" << endl;
	    for(i = 0; i < argc; i++)
		cout << "Arg " << i << ": " << argv[i] << endl;
	}
	cmd = "QueryWin ";
	cmd += esc(person.lower());

	for(i = 0; i < argc; i++)
	{
	        cmd += " ";
		cmd += esc(argv[i]);
	}

	tk->eval(cmd);
	return true;
}
コード例 #26
0
ファイル: SockBuffer.cpp プロジェクト: gene-hightower/ghsmtp
std::streamsize SockBuffer::write(const char* s, std::streamsize n)
{
  auto written = tls_active_
                     ? tls_.write(s, n, write_timeout_, timed_out_)
                     : POSIX::write(fd_out_, s, n, write_timeout_, timed_out_);
  if (written != static_cast<std::streamsize>(-1)) {
    octets_written_ += written;
    total_octets_written_ += written;
  }

  if (log_data_) {
    auto str = std::string(s, static_cast<size_t>(written));
    LOG(INFO) << "> «" << esc(str, esc_line_option::multi) << "»";
  }

  return written;
}
コード例 #27
0
ファイル: parse_vernac.cpp プロジェクト: KarlHegbloom/texmacs
static string
parse_delimited (string s, int& i, char c) {
  int start= i + 1, n= N(s);
  string esc (c);
  esc= esc*esc;
  i++;
  while (i < n) {
    if (s[i] == c && !test (s, i, esc))
      break;
    else if (s[i] == c && test (s, i, esc))
      i++;
    i++;
  }
  if (i<n && s[i] == c)
    return s (start, i++);
  return s (start, n);
}
コード例 #28
0
ファイル: print.cpp プロジェクト: poltina/libtorrent
std::string const& progress_bar(int progress, int width, color_code c
	, char fill, char bg, std::string caption, int flags)
{
	static std::string bar;
	bar.clear();
	bar.reserve(size_t(width + 10));

	int const progress_chars = (progress * width + 500) / 1000;

	if (caption.empty())
	{
		char code[10];
		std::snprintf(code, sizeof(code), "\x1b[3%dm", c);
		bar = code;
		std::fill_n(std::back_inserter(bar), progress_chars, fill);
		std::fill_n(std::back_inserter(bar), width - progress_chars, bg);
		bar += esc("39");
	}
	else
	{
		// foreground color (depends a bit on background color)
		color_code tc = col_black;
		if (c == col_black || c == col_blue)
			tc = col_white;

		caption.resize(size_t(width), ' ');

#ifdef _WIN32
		char const* background = "40";
#else
		char const* background = "48;5;238";
#endif

		char str[256];
		if (flags & progress_invert)
			std::snprintf(str, sizeof(str), "\x1b[%sm\x1b[37m%s\x1b[4%d;3%dm%s\x1b[49;39m"
				, background, caption.substr(0, progress_chars).c_str(), c, tc
				, caption.substr(progress_chars).c_str());
		else
			std::snprintf(str, sizeof(str), "\x1b[4%d;3%dm%s\x1b[%sm\x1b[37m%s\x1b[49;39m"
				, c, tc, caption.substr(0, progress_chars).c_str(), background
				, caption.substr(progress_chars).c_str());
		bar = str;
	}
	return bar;
}
コード例 #29
0
ファイル: main.cpp プロジェクト: mpapierski/simpledaemon
	void operator()(const boost::system::error_code & ec, int signal_number)
	{
		std::string signal_name;
		switch (signal_number)
		{
		case SIGINT:
			signal_name = "SIGINT";
			break;
		case SIGTERM:
			signal_name = "SIGTERM";
			break;
		default:
			signal_name = "Unknown signal";
			break;
		}
		std::cerr << esc(MAKE_RED) << LOG_HEADER << signal_name << " received. Exiting!" << esc(RESET_COLOR) << std::endl;
		io_service_.stop();
	}
コード例 #30
0
ファイル: setup.c プロジェクト: akat1/impala
int
set_level(int request)
{
  if (cur_level < 0)
    find_levels();

  if (LOG_ENABLED)
    fprintf(log_fp, "set_level(%d)\n", request);

  if (request > max_level) {
    printf("Sorry, this terminal supports only VT%d\n", terminal_id());
    return FALSE;
  }

  if (request != cur_level) {
    if (request == 0) {
      rm("?2");      /* Reset ANSI (VT100) mode, Set VT52 mode  */
      input_8bits  = FALSE;
      output_8bits = FALSE;
    } else {
      if (cur_level == 0) {
        esc("<");    /* Enter ANSI mode (VT100 mode) */
      }
      if (request == 1) {
        input_8bits  = FALSE;
        output_8bits = FALSE;
      }
      if (request > 1)
        do_csi("6%d;%d\"p", request, !input_8bits);
      else
        do_csi("61\"p");
    }
    padding(5); /* FIXME: may not be needed */

    cur_level = request;
  }

  if (LOG_ENABLED)
    fprintf(log_fp, "...set_level(%d) in=%d, out=%d\n", cur_level,
        input_8bits ? 8 : 7,
        output_8bits ? 8 : 7);

  return TRUE;
}