Пример #1
0
 void read(RawReader & raw_reader, State & state, native_type & t) const {
     // TODO verify overflow
     native_index_type sz;
     index_format().read(raw_reader, state, sz);
     output_info().initialize(t, sz);
     auto output = output_info().output_iterator(t);
     for (native_index_type i=0; i<sz; ++i) {
         native_value_type v;
         value_format().read(raw_reader, state, v);
         *(output++) = v;
     }
 }
Пример #2
0
int lua_tinker::break_point(lua_State *L)
{
    output_info("/n[LUA_DEBUG] |/t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   /n");
    call_stack_info(L, 0);
    output_info("[LUA_ERROR] |/t<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   /n/n");

    #ifdef _WIN32_WINNT 
    if (IsDebuggerPresent())
    {
        DebugBreak();
    }
    #endif
    return 0;
}
Пример #3
0
// 定跡データから、現在の局面kの合法手がその局面でどれくらいの頻度で指されたかを返す。
void Book::fromJoseki(Position &pos, int &mNum, MoveStack moves[], BookEntry data[])
{
	BookKey key;
	BookEntry d_null;
	MoveStack *last = generate<MV_LEGAL>(pos, moves);
	mNum = last - moves;
	memset(&d_null, 0, sizeof(d_null));

	int i;
	StateInfo newSt;
	for (i = 0; i < mNum; i++) {
		Move m = moves[i].move;
		pos.do_move(m, newSt);
		int ret = pos.EncodeHuffman(key.data);
		pos.undo_move(m);
		if (ret < 0) {
			pos.print_csa(m);
			output_info("Error!:Huffman encode!\n");
			continue;
		}
		Joseki_type::iterator p;
		p = joseki.find(key);
		if (p == joseki.end()) {
			// データなし
			data[i] = d_null;
		} else {
			// データあり
			data[i] = p->second;
		}
	}
}
Пример #4
0
void Book::open(const std::string& fileName)
{
	FILE *fp = fopen(fileName.c_str(), "rb");
	if (fp == NULL) {
		perror(fileName.c_str());
		return;
	}

	BookKey key;
	BookEntry data;

	for (;;) {
		size_t n;
		n = fread(&key, sizeof(key), 1, fp);
		if (n == 0) break;
		n = fread(&data, sizeof(data), 1, fp);
		if (n == 0) break;
		Joseki_type::iterator p;
		p = joseki.find(key);
		if (p == joseki.end()) {
			joseki.insert(Joseki_value(key, data));
		} else {
			output_info("Error!:Duplicated opening data\n");
		}
	}

	fclose(fp);
}
Пример #5
0
        void dynamic_shader_format::load_shader(boost::filesystem::path const& filename) {
          std::string extension     = filename.extension().string();
          bool        parse_outputs = false;

          if ((extension.compare(".fs") == 0) || (extension.compare(".frag") == 0)) {
            obj::shader_base::create_shader< fshd::type::gl_fragment_shader >();
            parse_outputs = true;
          } else if ((extension.compare(".vs") == 0) || (extension.compare(".vert") == 0)) {
            obj::shader_base::create_shader< fshd::type::gl_vertex_shader >();
          } else if ((extension.compare(".gs") == 0) || (extension.compare(".geom") == 0)) {
            obj::shader_base::create_shader< fshd::type::gl_geometry_shader >();
          } else {
            __gtulu_error() << "Unknown shader extension " << extension
                            << ", please use one of .fs/.frag, .gs/.geom or .vs/.vert.";
          }

          std::string source = gu::file::get_contents(filename);
          obj::shader_base::set_source(source.c_str());

          outputs_.clear();
          if (parse_outputs) {
            boost::regex           expression("out\\s+(\\S+)\\s+(\\S+);");
            boost::regex           array_expression("\\s*(\\S+)\\s*\\[(\\S*)\\]\\s*");
            boost::sregex_iterator it(source.begin(), source.end(), expression);
            boost::sregex_iterator end;

            std::uint32_t id = 0;
            while (it != end) {
              std::string type_name = it->str(1);
              std::string name      = it->str(2);

              std::uint32_t size = 1;

              boost::sregex_iterator name_it(name.begin(), name.end(), array_expression);
              boost::sregex_iterator type_it(type_name.begin(), type_name.end(), array_expression);

              // We've found a static sized output vector, that's really nice...
              if (name_it != end) {
                name = name_it->str(1);
                size = boost::lexical_cast< std::uint32_t >(name_it->str(2));

                // We've just found a dynamic sized output vector, what a wonderful idea...
              } else if (type_it != end) {
                type_name = type_it->str(1);
                size      = -1;
              }

              outputs_.push_back(output_info(id++, name, fout::format::get(type_name), size, -1, -1));
              ++it;
            }
          }
        } // load_shader
Пример #6
0
bool group::output_info(base_stream &out, const std::vector<std::string> &args) const {
	bool detailed = false;

	for (std::vector<std::string>::const_iterator i =
			args.begin(); i != args.end(); ++i) {
		if (*i == "detail")
			detailed = true;
		else
			return false;
	}

	return output_info(out, detailed);
}
Пример #7
0
void output_ascii(const stdString &archive_name,
                  const stdString &channel_name,
                  const epicsTime &start, const epicsTime &end)
{
    Archive         archive(new ARCHIVE_TYPE(archive_name));
    ChannelIterator channel(archive);
    ValueIterator   value(archive);
    if (! archive.findChannelByName(channel_name, channel))
    {
        printf("# Channel not found: %s\n", channel_name.c_str());
        return;
    }

    printf("channel=%s\n", channel_name.c_str());

    if (! channel->getValueAfterTime (start, value))
    {
        printf("# no values\n");
        return;
    }

    CtrlInfo   info;
    double period=-1;
    epicsTime last_time = nullTime;
    while (value && (!isValidTime(end)  ||  value->getTime() < end))
    {
        if (period != value.getPeriod())
        {
            period = value.getPeriod();
            output_header(value);
        }
        if (info != *value->getCtrlInfo())
        {
            info = *value->getCtrlInfo();
            output_info(&info);
        }
        if (isValidTime(last_time) && value->getTime() < last_time)
            printf("Error: back in time:\n");
        value->show(stdout);
        fputs("\n", stdout);
        last_time = value->getTime();
        ++value;
    }
}
Пример #8
0
// 現在の局面がどのくらいの頻度で指されたか定跡データを調べる
int Book::getHindo(const Position &pos)
{
	BookKey key;
	int hindo = 0;

	int ret = pos.EncodeHuffman(key.data);
	if (ret < 0) {
		pos.print_csa();
		output_info("Error!:Huffman encode!\n");
		return 0;
	}
	Joseki_type::iterator p;
	p = joseki.find(key);
	if (p != joseki.end()) {
		// データあり
		hindo = p->second.hindo;
	}

	return hindo;
}
Пример #9
0
bool group_interface::output_info(base_stream &out, const std::vector<std::string> &args) const {
	output_info(out, false);
	return true;
}
Пример #10
0
int svpn_server_handle_thread(struct svpn_server* pvoid)
{
	struct svpn_server *psc = pvoid;

	struct sockaddr_in6 addr;
	socklen_t alen = sizeof(addr);

	struct timeval tv;

	char tmpstr[32];
	struct svpn_net_ipv4_header* pheader = NULL;
	unsigned char buffer[BUFFER_LEN], tmp_buffer[BUFFER_LEN];
	int ret, uid, len;
	fd_set fd_list;
	int maxfd = (psc->sock_fd > psc->tun_fd) ? psc->sock_fd : psc->tun_fd;
	maxfd++;

	strcpy(fmtstr, "Send:99,000,000,000B [9,000,000B/s], Recv:99,000,000,000B [9,000,000B/s]\r");

	memset(&stat, 0, sizeof(stat));
	gettimeofday(&tv, NULL);
	stat.ts_last = tv.tv_sec * 1000000LL + tv.tv_usec;

	while(1)
	{
		FD_ZERO(&fd_list);
		FD_SET(psc->tun_fd, &fd_list);
		FD_SET(psc->sock_fd, &fd_list);
		
		ret = select(maxfd, &fd_list, NULL, NULL, NULL);
		if(ret < 0)
		{
			if(errno == EINTR)
				return 0;
			continue;
		}

		// update statistics data
		gettimeofday(&tv, NULL);
		stat.ts_current = tv.tv_sec * 1000000LL + tv.tv_usec;


		if(FD_ISSET(psc->sock_fd, &fd_list))
		{
			len = recvfrom(psc->sock_fd, tmp_buffer, BUFFER_LEN, 0, 
				(struct sockaddr*)&addr, &alen);

			if(len <= 0 || len > BUFFER_LEN)
				continue;

			uid = tmp_buffer[0];
			if (psc->clients[uid] == NULL)
			{
				mprintf(LWARN, "Unknown user #%d", uid);
				continue;
			}

			Decrypt(&(psc->clients[uid]->table), tmp_buffer, buffer, len);

			pheader = (struct svpn_net_ipv4_header*)buffer;
			if (pheader->src_ip[0] != psc->local_addr[0] ||
				pheader->src_ip[1] != psc->local_addr[1] ||
				pheader->src_ip[2] != psc->local_addr[2] ||
				pheader->src_ip[3] != uid)
			{
				mprintf(LWARN, "Invalid password : %s", inet_ntop(PF_INET6, (char*)&addr + 8, tmpstr, sizeof(tmpstr)));
				continue;
			}

			if (memcmp(&addr, &psc->clients[uid]->addr, sizeof(addr)) != 0)
			{
				memcpy(&psc->clients[uid]->addr, &addr, sizeof(addr));
				mprintf(LINFO, "Client #%d move to %s", uid,
						inet_ntop(PF_INET6, (char*)&addr + 8, tmpstr, sizeof(tmpstr)));
			}

			stat.total_send += len;
			stat.total_pkgsend++;
			output_info();

			len = write(psc->tun_fd, buffer, len);
		}

		if(FD_ISSET(psc->tun_fd, &fd_list))
		{
			len = read(psc->tun_fd, tmp_buffer, BUFFER_LEN);

			if (len <= 0 || len > BUFFER_LEN)
				continue;

			pheader = (struct svpn_net_ipv4_header*)tmp_buffer;

			uid = pheader->dst_ip[3];
			if (psc->clients[uid] == NULL)
			{
				mprintf(LWARN, "User #%d not exist", uid);
				continue;
			}

			Encrypt(&(psc->clients[uid]->table), tmp_buffer, buffer, len);

			len = sendto(psc->sock_fd, buffer, len, 0,
					(struct sockaddr*)&psc->clients[uid]->addr,
					sizeof(struct sockaddr_in6));

			if (len <= 0)
			{
				mprintf(LERROR, "Client #%d disconnected", uid);
				continue;
			}

			// update statistics data
			stat.total_recv += len;
			stat.total_pkgrecv++;
			output_info();
		}
	}
	return 0;
}
Пример #11
0
/*
 * parse_commandline
 * read our args, parse them
 * and return a struct of the data
 */
argdata_t *parse_commandline (int argc, char **argv)
{
  argdata_t *data;
  extern char *optarg;
  extern int optind, opterr, optopt;
  int done, fail;
  int quota_type;
  int opt;

  if (argc == 1) {
    output_help ();
    return NULL;
  }

  data = (argdata_t *) calloc (1,sizeof(argdata_t));
  if ( ! data ) {
    output_error ("Insufficient memory");
    exit (ERR_MEM);
  }

  quota_type = _PARSE_UNDEF;
  optarg = NULL;
  opterr = 0;
  done = fail = 0;
  while ( ! done && ! fail ) {
    opt = getopt(argc, argv, OPTSTRING);

    if (opt > 0)
       output_debug ("option: '%c', argument: '%s'", opt, optarg);

    switch (opt) {

    case EOF:
      done = 1;
      break;

    case 'h':
      output_help ();
      exit (0);

    case 'V':
      output_version();
      exit (0);

    case 'v':
      output_level++;
      break;

    case 'n':
      data->noaction = 1;
      break;


    case 'u':   /* set username */
      if ( data->id_type ) {
	output_error("Only one quota (user or group) can be set");
	fail = 1;
	continue;
      }
      data->id_type = QUOTA_USER;
#if HAVE_GNU_GETOPT
      /* -uuser */
      if ( optarg ) {
	output_debug ("not mangling: optarg='%s', next='%s'", optarg,
		      argv[optind]);
	data->id = optarg;
      }
      /* -u [-next-opt] */
      else if ( ! argv[optind] || argv[optind][0] == '-' ) {
	output_debug ("not mangling: NULL user");
	data->id = NULL;
      }
      /* -u user */
      else {
	output_debug ("mangling everything: next='%s'", argv[optind]);
	data->id = argv[optind];
	optind++;
      }
#else
      if (optarg && ((data->block_grace || data->inode_grace) || (optarg[0] == '-'))) {
          /* -u [-next-opt] */
          optind--;
          data->id = NULL;
      }
      else {
          /* -u user */
          data->id = optarg;
      }
#endif
      output_info ("using uid %s", data->id);
      break;

    case 'g':   /* set groupname */
      if ( data->id_type ) {
	output_error("Only one quota (user or group) can be set");
	fail = 1;
	continue;
      }
      data->id_type = QUOTA_GROUP;
#if HAVE_GNU_GETOPT
      if ( optarg ) {
	output_debug ("not mangling: optarg='%s', next='%s'", optarg,
		      argv[optind]);
	data->id = optarg;
      }
      else if ( ! argv[optind] || argv[optind][0] == '-' ) {
	output_debug ("not mangling: NULL user");
	data->id = NULL;
      }
      else {
	output_debug ("mangling everything: next='%s', argv[optind]");
	data->id = argv[optind];
	optind++;
      }
#else
      data->id = optarg;
#endif
      output_info ("using gid  %s", data->id);
      break;

    case 'b':   // Work with block limits
      output_info ("working with block limits");
      quota_type = _PARSE_BLOCK;
      break;

    case 'i':   // Work with inode limits
      output_info ("working with inode limits");
      quota_type = _PARSE_INODE;
      break;

    case 'q': // soft limit
      switch ( quota_type ) {
      case _PARSE_UNDEF:
	output_error ("Must specify either block (-b) or inode (-i) before -q");
	fail = 1;
	break;
      case _PARSE_BLOCK:
	data->block_soft = optarg;
	break;
      case _PARSE_INODE:
	data->inode_soft = optarg;
	break;
      default:
	output_error ("Impossible error #42q: evacuate the building!");
	break;
      }
      output_info ("setting soft limit to %s", optarg);
      break;


    case 'l': // hard limit
      switch ( quota_type ) {
      case _PARSE_UNDEF:
	output_error ("Must specify either block (-b) or inode (-i) before -l");
	fail = 1;
	break;
      case _PARSE_BLOCK:
	data->block_hard = optarg;
	break;
      case _PARSE_INODE:
	data->inode_hard = optarg;
	break;
      default:
	output_error ("Impossible error #42l: evacuate the building!");
	break;
      }
      output_info ("setting hard limit to %s", optarg);
      break;



    case 't': // set grace period
      data->id = NULL;
      switch ( quota_type ) {
      case _PARSE_UNDEF:
	output_error ("Must specify either block (-b) or inode (-i) before -t");
	fail = 1;
	break;
      case _PARSE_BLOCK:
	data->block_grace = optarg;
	break;
      case _PARSE_INODE:
	data->inode_grace = optarg;
	break;
      default:
	output_error ("Impossible error #42t: evacuate the building!");
	break;
      }
      break;


    case 'r': // reset grace time
      switch ( quota_type ) {
      case _PARSE_UNDEF:
	output_error ("Must specify either block (-b) or inode (-i) before -r");
	fail = 1;
	break;
      case _PARSE_BLOCK:
	data->block_reset = 1;
	break;
      case _PARSE_INODE:
	data->inode_reset = 1;
	break;
      default:
	output_error ("Impossible error #42r: evacuate the building!");
	break;
      }
      break;

    case 'd':
       data->dump_info = 1;
       break;

    case 'R':
       data->raise_only = 1;
       break;

    case ':':
      output_error ("Option '%c' requires an argument", optopt);
      break;

    case '?':
      output_error ("Unrecognized option: '%c'", optopt);
      __attribute__ ((fallthrough));

    default:
      output_help();
      fail = 1;
      break;
    }
  }

  if ( fail ) {
    free (data);
    return NULL;
  }

  if ( ! data->id_type ) {
    output_error ("Must specify either user or group quota");
    return NULL;
  }

  if ( data->dump_info) {
     output_info("Option 'd' => just dumping quota-info for %s", data->id_type == QUOTA_USER ? "user" : "group");
  }

  /* the remaining arg is the filesystem */
  data->qfile = argv[optind];
  if ( ! data->qfile || strlen(data->qfile) == 0) {
    output_error ("No filesystem specified");
    return NULL;
  }

  /* remove trailing slash(es) except for / filesystem */
  while (strlen(data->qfile) > 1) {
    if (data->qfile[strlen(data->qfile) - 1] != '/') break;
    data->qfile[strlen(data->qfile) - 1] = '\0';
  }

  /* check for mixing -t with other options in the wrong way */
  if (data->block_grace || data->inode_grace) {
     if (data->block_hard || data->block_soft || data->inode_hard || data->inode_soft || data->id) {
	output_error("Wrong options for -t, please see manpage for usage instructions!");
	return NULL;
     }
  }

  /* check for mixing -r with other options in the wrong way */
  if (data->block_reset || data->inode_reset) {
      if (data->block_hard || data->block_soft || data->inode_hard || data->inode_soft) {
          output_error("Wrong options for -r, please see manpage for usage instructions!");
          return NULL;
      }
  }

  output_info ("using filesystem %s", data->qfile);

  return data;
}
Пример #12
0
string difmap_wkey::compare(){

	indexed_points *ds1_ip = dynamic_cast<indexed_points*>(dataset1);
	indexed_points *ds2_ip = dynamic_cast<indexed_points*>(dataset2);

	if(ds1_ip == NULL || ds2_ip == NULL)
		return string("Improper Datasets");

	string ret("");

	if(!check_card_match()){
		ret = "No Output";
		return ret;
	}

	long double max = get_max_dif();
	long double min = get_min_dif();

	long double range = fabs( max - min );

	CImg<unsigned char> imgOut( ds1_ip->get_dim().sizes[0] + border_width + key_width, 
								ds1_ip->get_dim().sizes[1],
								ds1_ip->get_dim().sizes[2], 
								3, 0 );	

	//Write difference map to image
	for(int x=0; x<ds1_ip->get_dim().sizes[0]; x++){
		for(int y=0; y<ds1_ip->get_dim().sizes[1]; y++){
			for(int z=0; z<ds1_ip->get_dim().sizes[2]; z++){
				//TODO: loop over every dep_var

				layout loc;
				loc.arr_size = 3;
				loc.sizes = new int[3];
				loc.sizes[0] = x;
				loc.sizes[1] = y;
				loc.sizes[2] = z;

				long double pt_val = fabs( ds1_ip->get_indexed_point(loc).vals[var_ds1]
										   - ds2_ip->get_indexed_point(loc).vals[var_ds2] );

				rgb_color col = get_color_double_sided(pt_val, range, min, 0);

				imgOut(x, ds1_ip->get_dim().sizes[1] - y - 1, z, 0) = col.r;
				imgOut(x, ds1_ip->get_dim().sizes[1] - y - 1, z, 1) = col.g;
				imgOut(x, ds1_ip->get_dim().sizes[1] - y - 1, z, 2) = col.b;
			}
		}
	}


	//Determine if one dataset is always larger
	int large_ds;
	if( 0 >= min && 0 <= max )
		large_ds = -1;
	else{

		layout loc;
		loc.arr_size = 3;
		loc.sizes = new int[3];
		loc.sizes[0] = 0;
		loc.sizes[1] = 0;
		loc.sizes[2] = 0;

		if(ds1_ip->get_indexed_point(loc).vals[var_ds1] 
			> ds2_ip->get_indexed_point(loc).vals[var_ds2]){

			large_ds = 1;
		}
		else
			large_ds = 2;
	}

	//Write border
	int border_start = ds1_ip->get_dim().sizes[0];

	for(int y=0; y < ds1_ip->get_dim().sizes[1]; y++){
		for(int x=border_start; x < border_start + border_width; x++){
			for(int z=0; z<ds1_ip->get_dim().sizes[2]; z++){

				imgOut( x, y, z, 0 ) = border_color.r;
				imgOut( x, y, z, 1 ) = border_color.g;
				imgOut( x, y, z, 2 ) = border_color.b;
			}
		}
	}

	//Write key
	int x_start = ds1_ip->get_dim().sizes[0] + border_width;

	long double k_height = ds1_ip->get_dim().sizes[1];
	long double unit = range / (k_height-1.0);

	for(int y=0; y<ds1_ip->get_dim().sizes[1]; y++){
		for(int x=x_start; x < x_start + key_width; x++){
			for(int z=0; z<ds1_ip->get_dim().sizes[2]; z++){
				rgb_color col = get_color_double_sided(min+unit*y, range, min, 0);

				imgOut( x, ds1_ip->get_dim().sizes[1] - y - 1, z, 0 ) = col.r;
				imgOut( x, ds1_ip->get_dim().sizes[1] - y - 1, z, 1 ) = col.g;
				imgOut( x, ds1_ip->get_dim().sizes[1] - y - 1, z, 2 ) = col.b;
			}
		}
	}

	//Construct file name
	string output_name(outprefix);
	output_name += "_difmap_wkey_";
	output_name += "var1_";
	output_name += itoa(var_ds1);
	output_name += "_var2_";
	output_name += itoa(var_ds2);

	//Write info to txt file
	output_info(output_name + ".txt", max, min, large_ds);

	//Write image
	imgOut.save_bmp((output_name + ".bmp").c_str());

	ret = output_name;
	return ret;
}
Пример #13
0
    int
message(void* d, unsigned int id, int param1, void* param2, char* str)
{
    static int filenum = 0, totalsize = 0, proxyflag = 0;
    static char proxy[256];
    int confirm;

    switch (id)
    {
	case FRESHEN_MSG_USEPROXY:
	    proxyflag = 1;
	    strncpy(proxy, (char*)param2, sizeof(proxy));
	    output_info("ダウンロードにプロキシ %s を使用します。", proxy);
	    break;
	case FRESHEN_MSG_START:
	    output_info("ネットワークアップデートを開始します。");
	    output_info("");
	    break;
	case FRESHEN_MSG_NOUPDATE:
	    output_info("更新されたファイルはありませんでした。");
	    break;
	case FRESHEN_MSG_FLESHOUT:
	    if (param1 >= 0)
		output_info("更新を完了しました。");
	    else
		output_info("更新は行なわれませんでした");
	    output_info("「閉じる」ボタンを押して終了してください。");
	    break;
	case FRESHEN_MSG_BADINFO:
	    output_info("更新情報を取得出来ませんでした。");
	    MessageBox(g_hwnd,
		    "Vimの更新情報を正しく取得出来ませんでした。\r\n"
		    "管理者 <*****@*****.**> にメールで連絡を取るか、\r\n"
		    "香り屋 http://www.kaoriya.net/ へアクセスしてください。"
		    , "Vimの更新情報取得に失敗", MB_OK | MB_ICONERROR);
	    break;
	case FRESHEN_MSG_GOODINFO:
	    output_info("更新情報の取得を完了しました。");
	    break;
	case FRESHEN_MSG_SCHEDULE:
	    filenum = param1;
	    totalsize = (int)param2;
	    output_info("%d ファイル 合計 %d バイトをダウンロードします。",
		    filenum, totalsize);
	    output_info("");
	    break;
	case FRESHEN_MSG_CONFIRM:
	    {
		char buf[1024];
		char proxymsg[512];

		proxymsg[0] = '\0';
		if (proxyflag)
		    _snprintf(proxymsg, sizeof(proxymsg), " プロキシ %s",
			    proxy);
		_snprintf(buf, sizeof(buf),
			"ファイルのダウンロード\r\n"
			"(%d ファイル 合計 %d バイト%s)\r\n"
			"を開始しますか?"
			, filenum, totalsize, proxymsg);
		confirm = MessageBox(g_hwnd, buf, "ダウンロード確認",
			MB_ICONQUESTION | MB_YESNO);
	    }
	    return confirm == IDNO ? 0 : 1;
	case FRESHEN_MSG_CANCEL:
	    switch (param1)
	    {
		case FRESHEN_CANCEL_NOFILE:
		    output_info("更新されたファイルはありませんでした。");
		    break;
		case FRESHEN_CANCEL_CONFIRM:
		case FRESHEN_CANCEL_DOWNLOAD:
		    output_info("ダウンロードを中止しました。");
		    break;
		default:
		    output_info(str);
		    break;
	    }
	    break;
	case FRESHEN_MSG_DLBEGIN:
	    output_info("");
	    output_info("URL %s", param2);
	    output_info("%d バイトをダウンロードしています。", param1);
	    break;
	case FRESHEN_MSG_DLEND:
	    output_info("ダウンロード(%d バイト)を完了しました。", param1);
	    break;
	case FRESHEN_MSG_DECOMPRESS:
	    output_info("ダウンロードしたファイルを解凍しています。");
	    break;
	case FRESHEN_MSG_BADMD5:
	    output_info("MD5値が一致しませんでした。"
		    "ダウンロードに失敗したようです。");
	    break;
	case FRESHEN_MSG_GOODMD5:
	    output_info("MD5値が一致しました。ダウンロードに成功しました。");
	    break;
	case FRESHEN_MSG_DLALLEND:
	    output_info("");
	    if (param1 > 0)
	    {
		output_info("%d 個のファイルをダウンロードし終わりました。",
			param1);
	    }
	    break;
	case FRESHEN_MSG_UPDATEINFO:
	    output_info("更新情報をチェックします。");
	    break;
	case FRESHEN_MSG_DLINFO:
	    output_info("URL %s", param2);
	    output_info("から最新の更新情報をダウンロードしています"
		    "(%d 回目)。", param1);
	    break;
	case FRESHEN_MSG_CHDIR:
	    break;
	default:
	    output_info(str);
	    break;
    }
    return 1;
}
Пример #14
0
bool pim_interface::output_info(base_stream &out, const std::vector<std::string> &args) const {
	bool extended = !args.empty() && args[0] == "extended";

	return output_info(out, extended);
}
Пример #15
0
int main (int argc, char **argv) {
    u_int64_t old_quota;
    int id;
    time_t old_grace;
    argdata_t *argdata;
    quota_t *quota;
    char* tmpstr;



    /* parse commandline and fill argdata */
    argdata = parse_commandline (argc, argv);
    if ( ! argdata ) {
        exit (ERR_PARSE);
    }


    /* initialize the id to use */
    if ( ! argdata->id ) {
        id = 0;
    }
    /* numerical uid starting with ':', don't check uid/gid against system users/groups */
    else if ( strlen(argdata->id) > 1 && argdata->id[0] == ':' && isdigit(argdata->id[1]) ) {
        argdata->id++; // skip leading ':'
        id = strtol(argdata->id, &tmpstr, 10);
    }
    else if ( argdata->id_type == QUOTA_USER ) {
        id = (int) system_getuid (argdata->id);
    }
    else {
        id = (int) system_getgid (argdata->id);
    }
    if ( id < 0 ) {
        exit (ERR_ARG);
    }


    /* get the quota info */
    quota = quota_new (argdata->id_type, id, argdata->qfile);
    if ( ! quota ) {
        exit (ERR_SYS);
    }

    if ( ! quota_get(quota) ) {
        exit (ERR_SYS);
    }

// FIXME: remote debug
//output_info("BLOCKS_TO_KB(quota->block_soft): %llu\n", BLOCKS_TO_KB(quota->block_soft));
//output_info("DIV_UP(quota->block_soft, 1024): %llu\n", DIV_UP(quota->block_soft, 1024));
//output_info("DEBUG: quota->block_soft: %llu\n", quota->block_soft);

    if (argdata->dump_info) {
        time_t now = time(NULL);
        u_int64_t display_blocks_used = 0;

        output_info ("");
        output_info ("%s Filesystem blocks quota limit grace files quota limit grace",
                     argdata->id_type == QUOTA_USER ? "uid" : "gid");

        // quota->diskspace_used is bytes. Display in Kb
        display_blocks_used = DIV_UP(quota->diskspace_used, 1024);

#ifdef HAVE_INTTYPES_H
        printf("%d %s %" PRIu64 " %" PRIu64 " %" PRIu64 " %lu %" PRIu64 " %" PRIu64 " %" PRIu64 " %lu\n",
#else
        printf("%d %s %llu %llu %llu %lu %llu %llu %llu %lu\n",
#endif
               id,
               argdata->qfile,
               display_blocks_used,
               BLOCKS_TO_KB(quota->block_soft),
               BLOCKS_TO_KB(quota->block_hard),
#if ANY_BSD || PLATFORM_DARWIN
               (unsigned long)
               ((
                    (quota->block_soft && (BYTES_TO_BLOCKS(quota->diskspace_used) >= quota->block_soft))
                    ||
                    (quota->block_hard && (BYTES_TO_BLOCKS(quota->diskspace_used) >= quota->block_hard))
                ) ? quota->block_time - now : 0),
#else
               (unsigned long) quota->block_time ? quota->block_time - now : 0,
#endif /* ANY_BSD */
               quota->inode_used,
               quota->inode_soft,
               quota->inode_hard,
#if ANY_BSD || PLATFORM_DARWIN
               (unsigned long)
               ((
                    (quota->inode_soft && (quota->inode_used >= quota->inode_soft))
                    ||
                    (quota->inode_hard && (quota->inode_used >= quota->inode_hard))
                ) ? quota->inode_time - now : 0));

#else
               (unsigned long) quota->inode_time ? quota->inode_time - now : 0);
#endif /* ANY_BSD */
        exit(0);
    }
Пример #16
0
int main(int argc,char *argv[])
{
	if(argc < 2)
	{
		printf("usage :%s dir_name\n",argv[0]);exit(EXIT_FAILURE);
	}

	int i;
	for(i=1;i<argc;i++)
	{
		struct fnode *linklist=NULL;


		struct stat stat_info;
		if(stat(argv[i],&stat_info)==-1)
		{
			perror("stat");exit(EXIT_FAILURE);
		}
	
		if (S_ISREG(stat_info.st_mode))		//regular file
		{
			struct fnode *temp=(struct fnode *)malloc(sizeof(struct fnode));
			if(NULL==temp)
			{
				perror("malloc");exit(EXIT_FAILURE);
			}
			temp->next=NULL;
			memset(temp->name,'\0',NAME_SIZE);
			memcpy(temp->name,argv[i],strlen(argv[i]));
			linklist=insert_list(temp,linklist);
			output_info(linklist);//output information of the file
		}
		else if(S_ISDIR(stat_info.st_mode))
		{
			char buf[NAME_SIZE];
			getcwd(buf,128);
			
			DIR  *dirp=NULL;
			dirp=opendir(argv[i]);
			if(NULL==dirp)
			{
				perror("opendir");exit(EXIT_FAILURE);
			}

			struct dirent *entp=NULL;
			while(entp=readdir(dirp))
			{
				struct fnode *temp=(struct fnode *)malloc(sizeof(struct fnode));
				if(NULL==temp)
				{
					perror("malloc");exit(EXIT_FAILURE);
				}
				temp->next=NULL;
				memset(temp->name,'\0',NAME_SIZE);
				memcpy(temp->name,entp->d_name,strlen(entp->d_name));
				linklist=insert_list(temp,linklist);
			}
			chdir(argv[i]);//change the current dirctory
			close(dirp);
			output_info(linklist);
			chdir(buf);			
		}		
		free_list(linklist);
	}	
	return 1;
}
Пример #17
0
Move Book::get_move(Position& pos, bool findBestMove)
{
	// 定跡データに手があればそれを使う.
	// 新形式を優先する
	if (size() > 0) {
		int teNum = 0;
		MoveStack moves[MAX_MOVES];
		BookEntry hindo2[MAX_MOVES];
		BookEntry candidate[4];
		int i;
		memset(candidate, 0, sizeof(candidate));

		fromJoseki(pos, teNum, moves, hindo2);
		// 一番勝率の高い手を選ぶ。
		float swin = 0.5f;
		float win_max = 0.0f;
		int max = -1;
		int max_hindo = -1;
		// 極端に少ない手は選択しない ⇒最頻出数の10分の1以下とする
		for (i = 0; i < teNum; i++) {
			if (max_hindo < hindo2[i].hindo) {
				max_hindo = hindo2[i].hindo;
			}
		}
		for (i = 0; i < teNum; i++) {
			if (hindo2[i].hindo > 0) {
				// 多いものを候補に入れる
				if (candidate[3].hindo < hindo2[i].hindo) {
					for (int j = 0; j < 4; j++) {
						if (candidate[j].hindo < hindo2[i].hindo) {
							for (int k = 3; k > j; k--) {
								candidate[k] = candidate[k-1];
							}
							candidate[j] = hindo2[i];
							candidate[j].eval = i;
							break;
						}
					}
				}

				// 勝率算出
				if (hindo2[i].swin + hindo2[i].gwin > 0) {
					swin = hindo2[i].swin / float(hindo2[i].swin + hindo2[i].gwin);
				} else {
					swin = 0.5f;
				}
				if (pos.side_to_move() != BLACK) swin = 1.0f - swin;

				// 極端に少ない手は選択しない ⇒最頻出数の10分の1以下とする
				if (max_hindo / 10 < hindo2[i].hindo && win_max < swin) {
					max = i;
					win_max = swin;
				}
			}
		}

		if (max >= 0) {
			if (!findBestMove) {
				// 乱数で返す
				int n = Min(teNum, 4);
				int total = 0;
				for (i = 0; i < n; i++) {
					total += candidate[i].hindo;
				}
				float p = prng.rand<unsigned short>() / 65536.0f;
				max = candidate[0].eval;
				int sum = 0;
				for (i = 0; i < n; i++) {
					sum += candidate[i].hindo;
					if (float(sum) / total >= p) {
						max = candidate[i].eval;
						break;
					}
				}
				if (hindo2[max].swin + hindo2[max].gwin > 0) {
					swin = hindo2[max].swin / float(hindo2[max].swin + hindo2[max].gwin);
					if (pos.side_to_move() != BLACK) swin = 1.0f - swin;
				} else {
					swin = 0.5f;
				}
			}
			// もっともよさそうな手を返す
			output_info("info string %5.1f%%, P(%d, %d)\n", swin*100.0f, hindo2[max].swin, hindo2[max].gwin);
			return moves[max].move;
		} else {
			output_info("info string No book data(plys=%d)\n", pos.startState.gamePly);
		}
	}

	return MOVE_NONE;
}