Beispiel #1
0
void MythPianod::Refresh() {
	MythPianoService* service = GetMythPianoService();

	if (service->GetCurrentSong().size()) {

		if(service->SongChanged()) {
			m_songText->SetText(QString(service->GetCurrentSong()["Title"].c_str()));
			m_artistText->SetText(QString(service->GetCurrentSong()["Artist"].c_str()));
			m_albumText->SetText(QString(service->GetCurrentSong()["Album"].c_str()));
			m_stationText->SetText(QString(service->GetCurrentStation().c_str()));

			// kick off cover art load
			if (m_coverArtFetcher)
				delete m_coverArtFetcher;

			if (m_coverArtTempFile)
				delete m_coverArtTempFile;

			m_coverArtFetcher = new QHttp();
			connect(m_coverArtFetcher, SIGNAL(done(bool)), this, SLOT(coverArtFetched()));  
			QUrl u(service->GetCurrentSong()["CoverArt"].c_str());
			QHttp::ConnectionMode conn_mode = QHttp::ConnectionModeHttp;
			m_coverArtFetcher->setHost(u.host(), conn_mode, 80);
			QByteArray path = QUrl::toPercentEncoding(u.path(), "!$&'()*+,;=:@/");
			m_coverArtFetcher->get(path);
		}

		string played, duration;
		service->GetTimes(&played, &duration);
		string rating = service->GetCurrentSong()["Rating"];

		if(rating == "good" || rating == "good artistseed") {
			m_ratingText->SetText(QString("This song makes me warm and fuzzy inside!"));
		}
		else if(rating == "bad") {
			m_ratingText->SetText(QString("Terrible song! Make it stop! Ahhh..."));
		}
		else if(rating == "neutral" || rating == "neutral artistseed") {
			m_ratingText->SetText(QString("Can't put my finger on this song yet..."));
		}
		else {
			cout<<"unknown rating: " << rating << endl;
		}

		if(played == "Intertrack") {
			QString time_string("00:00 / 00:00 Loading next track...");
			m_playTimeText->SetText(time_string);
		}
		else {
			QString time_string((played + " / " + duration).c_str());
			m_playTimeText->SetText(time_string);
		}
	}
Beispiel #2
0
/*
 * Initialise the given ctr_drbg context, using a personalisation string and an
 * entropy gathering function.
 */
ctr_drbg_context * rand_ctx_get()
{
  static entropy_context ec = {0};
  static ctr_drbg_context cd_ctx = {0};
  static bool rand_initialised = false;

  if (!rand_initialised)
    {
      struct gc_arena gc = gc_new();
      struct buffer pers_string = alloc_buf_gc(100, &gc);

      /*
       * Personalisation string, should be as unique as possible (see NIST
       * 800-90 section 8.7.1). We have very little information at this stage.
       * Include Program Name, memory address of the context and PID.
       */
      buf_printf(&pers_string, "OpenVPN %0u %p %s", platform_getpid(), &cd_ctx, time_string(0, 0, 0, &gc));

      /* Initialise PolarSSL RNG, and built-in entropy sources */
      entropy_init(&ec);

      if (0 != ctr_drbg_init(&cd_ctx, entropy_func, &ec, BPTR(&pers_string), BLEN(&pers_string)))
        msg (M_FATAL, "Failed to initialize random generator");

      gc_free(&gc);
      rand_initialised = true;
  }

  return &cd_ctx;
}
const std::string pretty_pv(const Position &pos, int time, int depth,
                            uint64_t nodes, Value score, Move pv[]) {
  std::stringstream s;

  // Depth
  s << std::setw(2) << std::setfill(' ') << depth << "  ";

  // Score
  s << std::setw(8) << score_string(score);

  // Time
  s << std::setw(8) << std::setfill(' ') << time_string(time) << " ";

  // Nodes
  if(nodes < 1000000ULL)
    s << std::setw(8) << std::setfill(' ') << nodes << " ";
  else if(nodes < 1000000000ULL)
    s << std::setw(7) << std::setfill(' ') << nodes/1000ULL << 'k' << " ";
  else
    s << std::setw(7) << std::setfill(' ') << nodes/1000000ULL << 'M' << " ";

  // PV
  s << line_to_san(pos, pv, 30, true, 0);

  return s.str();
}
Beispiel #4
0
/*
 * Print statistics.
 *
 * Triggered by SIGUSR2 or F2 on Windows.
 */
void
print_status (const struct context *c, struct status_output *so)
{
  struct gc_arena gc = gc_new ();

  status_reset (so);

  status_printf (so, PACKAGE_NAME " STATISTICS");
  status_printf (so, "Updated,%s", time_string (0, 0, false, &gc));
  status_printf (so, "TUN/TAP read bytes," counter_format, c->c2.tun_read_bytes);
  status_printf (so, "TUN/TAP write bytes," counter_format, c->c2.tun_write_bytes);
  status_printf (so, "TCP/UDP read bytes," counter_format, c->c2.link_read_bytes);
  status_printf (so, "TCP/UDP write bytes," counter_format, c->c2.link_write_bytes);
  status_printf (so, "Auth read bytes," counter_format, c->c2.link_read_bytes_auth);
#ifdef USE_LZO
  if (lzo_defined (&c->c2.lzo_compwork))
    lzo_print_stats (&c->c2.lzo_compwork, so);
#endif
#ifdef PACKET_TRUNCATION_CHECK
  status_printf (so, "TUN read truncations," counter_format, c->c2.n_trunc_tun_read);
  status_printf (so, "TUN write truncations," counter_format, c->c2.n_trunc_tun_write);
  status_printf (so, "Pre-encrypt truncations," counter_format, c->c2.n_trunc_pre_encrypt);
  status_printf (so, "Post-decrypt truncations," counter_format, c->c2.n_trunc_post_decrypt);
#endif
#ifdef WIN32
  if (tuntap_defined (c->c1.tuntap))
    status_printf (so, "TAP-WIN32 driver status,\"%s\"",
	 tap_win32_getinfo (c->c1.tuntap, &gc));
#endif

  status_printf (so, "END");
  status_flush (so);
  gc_free (&gc);
}
/* 
 * Return an ascii string describing an absolute
 * date/time in a struct timeval.
 * 
 */
const char *
tv_string_abs (const struct timeval *tv, struct gc_arena *gc)
{
  return time_string ((time_t) tv->tv_sec,
		      (int) tv->tv_usec,
		      true,
		      gc);
}
Beispiel #6
0
void update_display(void)
{
  char      start[9], *utime;
  struct tm *ltime;
  time_t    now;
  run       *rptr;
  proc      *pptr;
  int       index, row, col, y, x;

  now = time(NULL);
  mvprintw(0, 2, "Active Jobs: %2d/%2d", ac, sc);
  mvprintw(0, 28, "%s", ctime(&now));

  getmaxyx(stdscr, row, col);

  mvaddstr(2, 3, "START   PID  ST   CPU   COMMAND");
  for (index=0, y=3; index<rc; index++) {
    if (row-y <= rc-index && rptr->stage == STAGE_DONE)
      continue;
    rptr = runs+index;
    pptr = &(rptr->pc);

    if (rptr->stage == STAGE_ISSUE) {
      pptr->state = '!';
      proc_stat(rptr->run_pid, pptr);
      attron(A_REVERSE);
    }
    if (rptr->stage == STAGE_ATTN)
      attron(A_BLINK);

    move(y++, 0);
    if (rptr->stage != STAGE_FETCH) {
      utime = time_string(pptr->utime);
      ltime = localtime(&(pptr->start_time));
      strftime(start, sizeof (start), "%T", ltime);
      printw("%s %5d ", start, rptr->run_pid);
      if (rptr->stage == STAGE_ISSUE)
        printw("  %c %s  ", pptr->state, utime);
      else
        printw("%3d %s  ", rptr->status, utime);
    }
    else {
      addstr("       -     - ");
      addstr("        -   ");
    }

    addnstr(rptr->cmd.buffer, col-27);
    for (x=27+strlen(rptr->cmd.buffer); x<col; x++)
      addch(' ');
    attroff(A_REVERSE);
    attroff(A_BLINK);
  }
  move(0, col-1);
  refresh();
}
Beispiel #7
0
static void
waitTime (
  pwr_tTime		*t
)
{
  pwr_tStatus		sts;
  pwr_tTime		now;
  pwr_tTime		then = *t;
  char tims[24];
  short len;
  struct dsc$descriptor_s tims_desc = {
    sizeof(tims)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S,};

#if 0
  subTime(&then, nowTime(&now));
#endif

  if ((int)then.tv_sec > 0 || ((int)then.tv_sec == 0 && then.tv_nsec > 0)) {
#if defined OS_VMS || defined OS_ELN
    int			tv_nsec;
    int			vmstime[2];
    int			multiplier = -10000000;	      /* Used to convert 1 s to 100 ns, delta time.  */
    static pwr_tTime	tick = {0, 10000000};

    addTime(&then, &tick);
    tv_nsec = -then.tv_nsec/100;   /* Convert to 100 ns.  */
    sts = lib$emul(&then.tv_sec, &multiplier, &tv_nsec, vmstime);

#if defined OS_VMS
    tims_desc.dsc$a_pointer = tims;
    sys$asctim( &len, &tims_desc, vmstime, 0);
    tims[len] = '\0';
    printf("  %s\n", tims);
#if 0
    sts = sys$clref(timerFlag);
    sts = sys$setimr(timerFlag, vmstime, 0, 0, 0);
    sts = sys$waitfr(timerFlag);
#endif
#elif defined OS_ELN
    eln$time_string(tims, vmstime);
    tims[23] = '\0';
    printf("  %s\n", tims);
#if 0
    ker$wait_any(&sts, NULL, vmstime);
#endif
#endif

#elif defined OS_LYNX
    pwr_tTime rmt;

    nanosleep(&then, &rmt);
#endif
  }
}
Beispiel #8
0
static void update_time() {
    if (!curr_time) return;
    char buffer[BUFFER_SIZE];
    uint8_t vbuffer[GRID_ROW_COUNT];

    time_string(buffer, BUFFER_SIZE);

    for (uint8_t i = 0; i < GRID_ROW_COUNT; i++) {
        vbuffer[i] = char_to_uint(buffer[i]);
    }

    square_grid_set_values(grid, &vbuffer);
}
Beispiel #9
0
std::string Dynamics::csv_fields() {
  stringstream ss;

  // "timestamp,ms,us,"
  ss << time_string(this->datetime) << ",";
  ss << ms << ",";
  ss << us << ",";

  // "str,esc,battery_voltage,"
  ss << str << ",";
  ss << esc << ",";
  ss << battery_voltage << ",";

  // "odo_fl,odo_fl_us,"
  ss << odometer_front_left << ",";
  ss << odometer_front_left_last_us << ",";

  // "odo_fr,odo_fr_us,"
  ss << odometer_front_right << ",";
  ss << odometer_front_right_last_us << ",";

  // "odo_bl,odo_bl_us,"
  ss << odometer_back_left << ",";
  ss << odometer_back_left_last_us << ",";

  // "odo_br,odo_br_us,"
  ss << odometer_back_right << ",";
  ss << odometer_back_right_last_us << ",";

  // "odo_spur,odo_spur_us,"
  ss << spur_odo << ",";
  ss << spur_last_us << ",";

  // "yaw,pitch,roll,"
  ss << yaw.degrees() << ",";
  ss << pitch.degrees() << ",";
  ss << roll.degrees() << ",";

  // "ax,ay,az,"
  ss << ax << ",";
  ss << ay << ",";
  ss << az << ",";

  // "imu_calib";
  ss << calibration_status;

  return ss.str();
}
	RawDataVisualization::RawDataVisualization(Form ^ parentForm,Panel ^ parentPanel, GLsizei iWidth, GLsizei iHeight,ReadCSV read_csv_ref,Preprocessing_Data preprocessing_data_ref):VisualizationPanel(parentForm,parentPanel,iWidth,iHeight,read_csv_ref,preprocessing_data_ref){
			parentPanel->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &RawDataVisualization::RawDataMouseDown);
			parentPanel->MouseWheel += gcnew System::Windows::Forms::MouseEventHandler( this, &RawDataVisualization::RawDataMouseWheel );
			parentPanel->MouseMove += gcnew System::Windows::Forms::MouseEventHandler( this, &RawDataVisualization::RawDataMouseMove );	
			parentPanel->MouseUp += gcnew System::Windows::Forms::MouseEventHandler( this, &RawDataVisualization::RawDataMouseUp );	
			parentPanel->MouseDoubleClick += gcnew System::Windows::Forms::MouseEventHandler( this, &RawDataVisualization::RawDataMouseDoubleClick );	 
			time_string();
			//Initialize mouse handler variable
			scale_x[1] = 1.7; scale_y[1] = 0.2; scale_z[1] = 0.0;
			scale_size[1] = 0.05;
			move_x[1] = 0.0; move_y[1] = 0.0; move_z[1] = 0.0;
			scale_factor[1] = 0.6;
			//Initialize window size
			windowWidth[1] = iWidth; 
			windowHeight[1] = iHeight;
			//raw_data_position_table.resize(100);
			//for(int i=0;i<100;i++) raw_data_position_table[i].resize(31);
			//raw_data_position_table.resize( preprocessing_data.month_vec.size() );
			//for(int i=0;i<preprocessing_data.month_vec.size();i++) raw_data_position_table[i].resize( preprocessing_data.month_vec[i].day_vec.size() );
			select_histogram_flag = false;
	}
Beispiel #11
0
static void export_stats(int_status_t *intrnl, export_status_t *exp, iterator_t *it)
{
	uint32_t total_sent = iterator_get_sent(it);
	uint32_t total_fail = iterator_get_fail(it);
	uint32_t total_recv = zrecv.pcap_recv;
	uint32_t recv_success = zrecv.success_unique;
	uint32_t app_success = zrecv.app_success_unique;
	double cur_time = now();
	double age = cur_time - zsend.start; // time of entire scan
	double delta = cur_time - intrnl->last_now; // time since the last time we updated
	double remaining_secs = compute_remaining_time(age, total_sent);

	// export amount of time the scan has been running
	if (age < WARMUP_PERIOD) {
		exp->time_remaining_str[0] = '\0';
	} else {
		char buf[20];
		time_string(ceil(remaining_secs), 1, buf, sizeof(buf));
		snprintf(exp->time_remaining_str, NUMBER_STR_LEN, " (%s left)", buf);
	}
	exp->time_past = age;
	exp->time_remaining = remaining_secs;
	time_string((int)age, 0, exp->time_past_str, NUMBER_STR_LEN);

	// export recv statistics
	exp->recv_rate = (recv_success - intrnl->last_recv_net_success)/delta;
	number_string(exp->recv_rate, exp->recv_rate_str, NUMBER_STR_LEN);
	exp->recv_avg = recv_success/age;
	number_string(exp->recv_avg, exp->recv_avg_str, NUMBER_STR_LEN);
	exp->recv_total_rate = (total_recv - intrnl->last_recv_total)/delta;
	exp->recv_total_avg = total_recv/age;

	// application level statistics
	if (zconf.fsconf.app_success_index >= 0) {
		exp->app_success_rate = (app_success - intrnl->last_recv_app_success)/delta;
		number_string(exp->app_success_rate, exp->app_success_rate_str, NUMBER_STR_LEN);
		exp->app_success_avg = (app_success/age);
		number_string(exp->app_success_avg, exp->app_success_avg_str, NUMBER_STR_LEN);
	}

	if (!total_sent) {
		exp->hitrate = 0;
		exp->app_hitrate = 0;
	} else {
		exp->hitrate = recv_success*100.0/total_sent;
		exp->app_hitrate = app_success*100.0/total_sent;
	}

	if (age > WARMUP_PERIOD && exp->hitrate < zconf.min_hitrate) {
            if (fabs(intrnl->min_hitrate_start) < .00001) {
                intrnl->min_hitrate_start = cur_time;
            }
	} else {
		intrnl->min_hitrate_start = 0.0;
	}
	if (fabs(intrnl->min_hitrate_start) < .00001) {
	    exp->seconds_under_min_hitrate = 0;
	} else {
		exp->seconds_under_min_hitrate = cur_time - intrnl->min_hitrate_start;
	}
	if (!zsend.complete) {
		exp->send_rate = (total_sent - intrnl->last_sent)/delta;
		number_string(exp->send_rate, exp->send_rate_str, NUMBER_STR_LEN);
		exp->send_rate_avg = total_sent/age;
		number_string(exp->send_rate_avg, exp->send_rate_avg_str, NUMBER_STR_LEN);
	} else {
		exp->send_rate_avg = total_sent/(zsend.finish - zsend.start);
		number_string(exp->send_rate_avg, exp->send_rate_avg_str, NUMBER_STR_LEN);
	}
	// export other pre-calculated values
	exp->total_sent = total_sent;
	exp->percent_complete = 100.*age/(age + remaining_secs);
	exp->recv_success_unique = recv_success;
	exp->app_recv_success_unique = app_success;
	exp->total_recv = total_recv;
	exp->complete = zsend.complete;

	// pcap dropped packets
	exp->pcap_drop = zrecv.pcap_drop;
	exp->pcap_ifdrop = zrecv.pcap_ifdrop;
	exp->pcap_drop_total = exp->pcap_drop + exp->pcap_ifdrop;
	exp->pcap_drop_last = (exp->pcap_drop_total - intrnl->last_pcap_drop)/delta;
	exp->pcap_drop_avg = exp->pcap_drop_total/age;
	number_string(exp->pcap_drop_total, exp->pcap_drop_total_str, NUMBER_STR_LEN);
	number_string(exp->pcap_drop_last, exp->pcap_drop_last_str, NUMBER_STR_LEN);
	number_string(exp->pcap_drop_avg, exp->pcap_drop_avg_str, NUMBER_STR_LEN);

	zsend.sendto_failures = total_fail;
	exp->fail_total = zsend.sendto_failures;
	exp->fail_last = (exp->fail_total - intrnl->last_send_failures) / delta;
	exp->fail_avg = exp->fail_total/age;

	// misc
	exp->send_threads = iterator_get_curr_send_threads(it);

	// Update internal stats
	intrnl->last_now = cur_time;
	intrnl->last_sent = exp->total_sent;
	intrnl->last_recv_net_success = exp->recv_success_unique;
	intrnl->last_recv_app_success = exp->app_recv_success_unique;
	intrnl->last_pcap_drop = exp->pcap_drop_total;
	intrnl->last_send_failures = exp->fail_total;
	intrnl->last_recv_total = exp->total_recv;
}
Beispiel #12
0
void x_msg_va (const unsigned int flags, const char *format, va_list arglist)
{
  struct gc_arena gc;
#if SYSLOG_CAPABILITY
  int level;
#endif
  char *m1;
  char *m2;
  char *tmp;
  int e;
  const char *prefix;
  const char *prefix_sep;

  void usage_small (void);

#ifndef HAVE_VARARG_MACROS
  /* the macro has checked this otherwise */
  if (!MSG_TEST (flags))
    return;
#endif

  e = openvpn_errno ();

  /*
   * Apply muting filter.
   */
#ifndef HAVE_VARARG_MACROS
  /* the macro has checked this otherwise */
  if (!dont_mute (flags))
    return;
#endif

  gc_init (&gc);

  m1 = (char *) gc_malloc (ERR_BUF_SIZE, false, &gc);
  m2 = (char *) gc_malloc (ERR_BUF_SIZE, false, &gc);

  vsnprintf (m1, ERR_BUF_SIZE, format, arglist);
  m1[ERR_BUF_SIZE - 1] = 0; /* windows vsnprintf needs this */

  if ((flags & M_ERRNO) && e)
    {
      openvpn_snprintf (m2, ERR_BUF_SIZE, "%s: %s (errno=%d)",
			m1, strerror_ts (e, &gc), e);
      SWAP;
    }

#ifdef ENABLE_CRYPTO
#ifdef ENABLE_CRYPTO_OPENSSL
  if (flags & M_SSL)
    {
      int nerrs = 0;
      int err;
      while ((err = ERR_get_error ()))
	{
	  openvpn_snprintf (m2, ERR_BUF_SIZE, "%s: %s",
			    m1, ERR_error_string (err, NULL));
	  SWAP;
	  ++nerrs;
	}
      if (!nerrs)
	{
	  openvpn_snprintf (m2, ERR_BUF_SIZE, "%s (OpenSSL)", m1);
	  SWAP;
	}
    }
#endif
#endif

  if (flags & M_OPTERR)
    {
      openvpn_snprintf (m2, ERR_BUF_SIZE, "Options error: %s", m1);
      SWAP;
    }

#if SYSLOG_CAPABILITY
  if (flags & (M_FATAL|M_NONFATAL|M_USAGE_SMALL))
    level = LOG_ERR;
  else if (flags & M_WARN)
    level = LOG_WARNING;
  else
    level = LOG_NOTICE;
#endif

  /* set up client prefix */
  if (flags & M_NOIPREFIX)
    prefix = NULL;
  else
    prefix = msg_get_prefix ();
  prefix_sep = " ";
  if (!prefix)
    prefix_sep = prefix = "";

  /* virtual output capability used to copy output to management subsystem */
  if (!forked)
    {
      const struct virtual_output *vo = msg_get_virtual_output ();
      if (vo)
	{
	  openvpn_snprintf (m2, ERR_BUF_SIZE, "%s%s%s",
			    prefix,
			    prefix_sep,
			    m1);
	  virtual_output_print (vo, flags, m2);
	}
    }

  if (!(flags & M_MSG_VIRT_OUT))
    {
      if (use_syslog && !std_redir && !forked)
	{
#if SYSLOG_CAPABILITY
	  syslog (level, "%s%s%s",
		  prefix,
		  prefix_sep,
		  m1);
#endif
	}
      else
	{
	  FILE *fp = msg_fp(flags);
	  const bool show_usec = check_debug_level (DEBUG_LEVEL_USEC_TIME);

	  if ((flags & M_NOPREFIX) || suppress_timestamps)
	    {
	      fprintf (fp, "%s%s%s%s",
		       prefix,
		       prefix_sep,
		       m1,
		       (flags&M_NOLF) ? "" : "\n");
	    }
	  else
	    {
	      fprintf (fp, "%s %s%s%s%s",
		       time_string (0, 0, show_usec, &gc),
		       prefix,
		       prefix_sep,
		       m1,
		       (flags&M_NOLF) ? "" : "\n");
	    }
	  fflush(fp);
	  ++x_msg_line_num;
	}
    }

  if (flags & M_FATAL)
    msg (M_INFO, "Exiting due to fatal error");

  if (flags & M_FATAL)
    openvpn_exit (OPENVPN_EXIT_STATUS_ERROR); /* exit point */

  if (flags & M_USAGE_SMALL)
    usage_small ();

  gc_free (&gc);
}
Beispiel #13
0
std::string Condition::getName(bool tip, NameFlags::Value flags, int recursion) const
{
    if (!tip) {
	    return (type < scen.pergame->max_condition_types) ? types[type] : "Unknown!";
	} else {
	    std::string stype = std::string("");
        std::ostringstream convert;
        switch (type) {
        case ConditionType::None:
            // Let this act like a separator
            convert << "                                                                                    ";
            stype.append(convert.str());
            break;
        case ConditionType::BringObjectToArea:
            convert << get_unit_full_name(object) << " " << object;
            convert << " is" << areaName();
            stype.append(convert.str());
            break;
        case ConditionType::BringObjectToObject:
            convert << get_unit_full_name(object) << " " << object << " is next to unit " << get_unit_full_name(u_loc) << " " << u_loc;
            stype.append(convert.str());
            break;
        case ConditionType::OwnObjects:
        case ConditionType::OwnFewerObjects:
        case ConditionType::ObjectsInArea:
            { // we define some variables in this block, therefore need scope as we are also in a case
                if (valid_player()) {
                    convert << playerPronoun(player) << " has ";
                }
                switch (type) {
                case ConditionType::OwnObjects:
                case ConditionType::ObjectsInArea:
                    if (amount == 0) {
                        convert << "any number of";
                    } else {
                        convert << "at least " << amount;
                    }
                    break;
                case ConditionType::OwnFewerObjects:
                    if (amount == 0) {
                        convert << "no";
                    } else {
                        convert << "at most " << amount;
                    }
                    break;
                }
                if (valid_unit_spec()) {
                    std::string un(wstringToString(pUnit->name()));
                    if (amount > 1 && !un.empty() && *un.rbegin() != 's' && !replaced(un, "man", "men")) {
                        convert << " " << un << "s";
                    } else {
                        convert << " " << un;
                    }
                } else {
                    if (amount != 1) {
                        convert << " units";
                    } else {
                        convert << " unit";
                    }
                }
                convert << areaName();
                stype.append(convert.str());
            }
            break;
        case ConditionType::DestroyObject:
            convert << get_unit_full_name(object) << " is killed";
            stype.append(convert.str());
            break;
        case ConditionType::CaptureObject:
            convert << playerPronoun(player) << " captured " << get_unit_full_name(object);
            stype.append(convert.str());
            break;
        case ConditionType::AccumulateAttribute:
            switch (res_type) {
            case 0: // Food accumulated
                convert << playerPronoun(player) << " has " << amount << " food";
                break;
            case 1: // Wood accumulated
                convert << playerPronoun(player) << " has " << amount << " wood";
                break;
            case 2: // Stone accumulated
                convert << playerPronoun(player) << " has " << amount << " stone";
                break;
            case 3: // Gold accumulated
                convert << playerPronoun(player) << " has " << amount << " gold";
                break;
            case 20: // Units killed
                if (amount == 1) {
                    convert << playerPronoun(player) << " kills a unit";
                } else {
                    convert << playerPronoun(player) << " has killed " << amount << " units";
                }
                break;
            case 44: // Kill ratio
                if (amount == 0) {
                    convert << playerPronoun(player) << " has equal kills and deaths";
                } else if (amount == 1) {
                    convert << playerPronoun(player) << " has killed one more than lost";
                } else if (amount > 0) {
                    convert << playerPronoun(player) << " has " << amount << " more kills than deaths";
                } else if (amount == -1) {
                    convert << playerPronoun(player) << " has lost one more unit than has killed";
                } else {
                    convert << playerPronoun(player) << " has " << -amount << " more deaths than kills";
                }
                break;
            default:
                //convert << types_short[type];
                if (res_type >= 0) {
                    const Link * list = esdata.resources.head();
	                for (int i=0; list; list = list->next(), i++)
	                {
		                if (i == res_type) {
                            std::wstring resname(list->name());
		                    convert << playerPronoun(player) << "'s ";
                            convert << std::string( resname.begin(), resname.end());
                            convert << " >= " << amount;
		                    break;
		                }
	                }
	            }
                break;
            }
            stype.append(convert.str());
            break;
        case ConditionType::ResearchTehcnology:
            if (valid_technology_spec()) {
                convert << playerPronoun(player) << " has tech ";
                std::wstring techname(pTech->name());
                convert << std::string( techname.begin(), techname.end());
                convert << " researched";
            } else {
                convert << "INVALID";
            }
            stype.append(convert.str());
            break;
        case ConditionType::ResearchingTechnology:
            if (pTech && pTech->id()) {
                convert << playerPronoun(player) << " is researching ";
                std::wstring techname(pTech->name());
                convert << std::string( techname.begin(), techname.end());
            } else {
                convert << "INVALID";
            }
            stype.append(convert.str());
            break;
        case ConditionType::Timer:
            convert << time_string(timer) << " has passed";
            stype.append(convert.str());
            break;
        case ConditionType::ObjectSelected:
            convert << "selected unit " << object;
            convert << " (" << get_unit_full_name(object) << ")";
            stype.append(convert.str());
            break;
        case ConditionType::AISignal:
            switch (ai_signal) {
            case -1034:
                convert << "singleplayer / cheats enabled";
                break;
            case -1036:
                convert << "starting resources set to standard";
                break;
            case -1039:
                convert << "regicide";
                break;
            case -1040:
                convert << "deathmatch";
                break;
            case -70850:
                convert << "one-click garrison";
                break;
            default:
                if (ai_signal >= -518 && ai_signal <= -7) {
                    int signal = ai_signal + 518;
                    int taunt_player = signal / 64;
                    int taunt_set_id = signal % 64;
                    convert << "player " << taunt_player + 1 << " taunted " << taunt_set[taunt_set_id];
                } else if (ai_signal >= -774 && ai_signal <= -519) {
                    convert << "AI goal " << ai_signal + 774 << " achieved";
                } else {
                    convert << "AI signalled " << ai_signal;
                }
            }
            stype.append(convert.str());
            break;
        case ConditionType::ObjectVisible:
            convert << "unit " << object;
            convert << " (" << get_unit_full_name(object) << ") is visible";
            stype.append(convert.str());
            break;
        case ConditionType::PlayerDefeated:
            if (player == 0) {
                convert << "Gaia";
            } else {
                convert << playerPronoun(player);
            }
            convert << " is defeated";
            stype.append(convert.str());
            break;
        case ConditionType::ObjectHasTarget:
            convert << "unit " << object << " (" << get_unit_full_name(object) << ") is targetting";
            if (null_location_unit()) {
                convert << " something";
            } else {
                convert << " " << u_loc << " (" << get_unit_full_name(u_loc) << ")";
            }
            stype.append(convert.str());
            break;
        case ConditionType::UnitsGarrisoned:
            if (amount == 1) {
                convert << "unit " << object << " (" << get_unit_full_name(object) << ") has " << amount << " units garrisoned";
            } else {
                convert << "unit " << object << " (" << get_unit_full_name(object) << ") has one unit garrisoned";
            }
            stype.append(convert.str());
            break;
        case ConditionType::DifficultyLevel:
            convert << "difficulty is ";
            switch (amount) {
            case DifficultyLevel::Hardest:
                convert << "Hardest";
                break;
            case DifficultyLevel::Hard:
                convert << "Hard";
                break;
            case DifficultyLevel::Moderate:
                convert << "Moderate";
                break;
            case DifficultyLevel::Standard:
                convert << "Standard";
                break;
            case DifficultyLevel::Easiest:
                convert << "Easiest";
                break;
            }
            stype.append(convert.str());
            break;
        case ConditionType::UnitsQueuedPastPopCap_SWGB:
            if (valid_player()) {
                convert << playerPronoun(player) << " has " << amount << " units queued past the pop cap";
            } else {
                convert << "INVALID";
            }
            stype.append(convert.str());
            break;
        case ConditionType::OwnFewerFoundations_SWGB: // Chance_HD:
            switch (scen.game) {
            case AOHD:
            case AOF:
            case AOHD4:
            case AOF4:
            case AOHD6:
            case AOF6:
                convert << amount << "% chance ";
                stype.append(convert.str());
                break;
            case SWGB:
            case SWGBCC:
                if (valid_player()) {
                    convert << playerPronoun(player) << " has ";
                }
                if (amount == 0) {
                    convert << "no";
                } else {
                    convert << "at most " << amount;
                }
                if (valid_unit_spec()) {
                    std::string un(wstringToString(pUnit->name()));
                    if (amount > 1 && !un.empty() && *un.rbegin() != 's' && !replaced(un, "man", "men")) {
                        convert << " " << un << " foundations";
                    } else {
                        convert << " " << un << " foundation";
                    }
                } else {
                    if (amount != 1) {
                        convert << " foundations";
                    } else {
                        convert << " foundation";
                    }
                }
                convert << areaName();
                stype.append(convert.str());
                break;
            default:
                convert << amount << "UNKNOWN CONDITION";
                stype.append(convert.str());
            }
            break;
        default:
            stype.append((type < scen.pergame->max_condition_types) ? types_short[type] : "Unknown!");
        }

        return flags&NameFlags::LIMITLEN?stype.substr(0,MAX_CHARS):stype;
    }
}
Beispiel #14
0
static void export_stats(int_status_t *intrnl, export_status_t *exp, iterator_t *it)
{
	uint32_t total_sent = iterator_get_sent(it);
	double age = now() - zsend.start; // time of entire scan
	double delta = now() - intrnl->last_now; // time since the last time we updated
	double remaining_secs = compute_remaining_time(age, total_sent);

	// export amount of time the scan has been running
	if (age < 5) {
		exp->time_remaining_str[0] = '\0';
	} else {
		char buf[20];
		time_string(ceil(remaining_secs), 1, buf, sizeof(buf));
		snprintf(exp->time_remaining_str, NUMBER_STR_LEN, " (%s left)", buf);
	}
	exp->time_past = age;
	exp->time_remaining = remaining_secs;
	time_string((int)age, 0, exp->time_past_str, NUMBER_STR_LEN);

	// export recv statistics
	exp->recv_rate = (zrecv.success_unique - intrnl->last_recv_net_success)/delta;
	number_string(exp->recv_rate, exp->recv_rate_str, NUMBER_STR_LEN);
	exp->recv_avg = zrecv.success_unique/age;
	number_string(exp->recv_avg, exp->recv_avg_str, NUMBER_STR_LEN);

	// application level statistics
	if (zconf.fsconf.app_success_index >= 0) {
		exp->app_success_rate = (zrecv.app_success_unique - intrnl->last_recv_app_success)/delta;
		number_string(exp->app_success_rate, exp->app_success_rate_str, NUMBER_STR_LEN);
		exp->app_success_avg = (zrecv.app_success_unique/age);
		number_string(exp->app_success_avg, exp->app_success_avg_str, NUMBER_STR_LEN);
	}

	if (!total_sent) {
		exp->hitrate = 0;
		exp->app_hitrate = 0;
	} else {
		exp->hitrate = zrecv.success_unique*100./total_sent;
		exp->app_hitrate = zrecv.app_success_unique*100./total_sent;
	}

	if (!zsend.complete) {
		exp->send_rate = (total_sent - intrnl->last_sent)/delta;
		number_string(exp->send_rate, exp->send_rate_str, NUMBER_STR_LEN);
		exp->send_rate_avg = total_sent/age;
		number_string(exp->send_rate_avg, exp->send_rate_avg_str, NUMBER_STR_LEN);
	} else {
		exp->send_rate_avg = total_sent/(zsend.finish - zsend.start);
		number_string(exp->send_rate_avg, exp->send_rate_avg_str, NUMBER_STR_LEN);
	}
	// export other pre-calculated values
	exp->total_sent = total_sent;
	exp->percent_complete = 100.*age/(age + remaining_secs);
	exp->recv_success_unique = zrecv.success_unique;
	exp->app_recv_success_unique = zrecv.app_success_unique;
	exp->complete = zsend.complete;

	// pcap dropped packets
	exp->pcap_drop = zrecv.pcap_drop;
	exp->pcap_ifdrop = zrecv.pcap_ifdrop;
	exp->pcap_drop_total = zrecv.pcap_drop + zrecv.pcap_ifdrop;
	exp->pcap_drop_last = (zrecv.pcap_drop + zrecv.pcap_ifdrop - intrnl->last_pcap_drop)/delta;
	exp->pcap_drop_avg = (zrecv.pcap_drop + zrecv.pcap_ifdrop)/age;
	number_string(exp->pcap_drop_total, exp->pcap_drop_total_str, NUMBER_STR_LEN);
	number_string(exp->pcap_drop_last, exp->pcap_drop_last_str, NUMBER_STR_LEN);
	number_string(exp->pcap_drop_avg, exp->pcap_drop_avg_str, NUMBER_STR_LEN);

	exp->fail_total = zsend.sendto_failures;
	exp->fail_last = (zsend.sendto_failures - intrnl->last_send_failures) / delta;
	exp->fail_avg = zsend.sendto_failures/age;

	// misc
	exp->send_threads = iterator_get_curr_send_threads(it);
}
Beispiel #15
0
static void monitor_update(iterator_t *it, pthread_mutex_t *recv_ready_mutex)
{
	uint32_t total_sent = iterator_get_sent(it);
	if (last_now > 0.0) {
		double age = now() - zsend.start;
		double delta = now() - last_now;
		double remaining_secs = compute_remaining_time(age, total_sent);
		double percent_complete = 100.*age/(age + remaining_secs);

		// ask pcap for fresh values
		pthread_mutex_lock(recv_ready_mutex);
		recv_update_pcap_stats();
		pthread_mutex_unlock(recv_ready_mutex);

		// format times for display
		char time_left[20];
		if (age < 5) {
			time_left[0] = '\0';
		} else {
			char buf[20];
			time_string(ceil(remaining_secs), 1, buf, sizeof(buf));
			snprintf(time_left, sizeof(time_left), " (%s left)", buf);
		}
		char time_past[20];
		time_string((int)age, 0, time_past, sizeof(time_past));

		char send_rate[20], send_avg[20],
			 recv_rate[20], recv_avg[20],
			 pcap_drop[20], pcap_drop_avg[20];
		// recv stats
		number_string((zrecv.success_unique - last_rcvd)/delta,
						recv_rate, sizeof(recv_rate));
		number_string((zrecv.success_unique/age), recv_avg, sizeof(recv_avg));
		// dropped stats
		number_string((zrecv.pcap_drop + zrecv.pcap_ifdrop - last_drop)/delta,
						pcap_drop, sizeof(pcap_drop));
		number_string(((zrecv.pcap_drop + zrecv.pcap_ifdrop)/age),
						pcap_drop_avg, sizeof(pcap_drop_avg));

		// Warn if we drop > 5% of our average receive rate
		uint32_t drop_rate = (uint32_t)((zrecv.pcap_drop + zrecv.pcap_ifdrop - last_drop) / delta);
		if (drop_rate > (uint32_t)((zrecv.success_unique - last_rcvd) / delta) / 20) {
			log_warn("monitor", "Dropped %d packets in the last second, (%d total dropped (pcap: %d + iface: %d))",
					 drop_rate, zrecv.pcap_drop + zrecv.pcap_ifdrop, zrecv.pcap_drop, zrecv.pcap_ifdrop);
		}

		// Warn if we fail to send > 1% of our average send rate
		uint32_t fail_rate = (uint32_t)((zsend.sendto_failures - last_failures) / delta); // failures/sec
		if (fail_rate > ((total_sent / age) / 100)) {
			log_warn("monitor", "Failed to send %d packets/sec (%d total failures)",
					 fail_rate, zsend.sendto_failures);
		}
		float hits;
		if (!total_sent) {
			hits = 0;
		} else {
			hits = zrecv.success_unique*100./total_sent;
		}
		if (!zsend.complete) {
			// main display (during sending)
			number_string((total_sent - last_sent)/delta,
							send_rate, sizeof(send_rate));
			number_string((total_sent/age), send_avg, sizeof(send_avg));
			fprintf(stderr,
					"%5s %0.0f%%%s; send: %u %sp/s (%sp/s avg); "
					"recv: %u %sp/s (%sp/s avg); "
					"drops: %sp/s (%sp/s avg); "
					"hits: %0.2f%%\n",
					time_past,
					percent_complete,
					time_left,
					total_sent,
					send_rate,
					send_avg,
					zrecv.success_unique,
					recv_rate,
					recv_avg,
					pcap_drop,
					pcap_drop_avg,
					hits);
		} else {
		  	// alternate display (during cooldown)
			number_string((total_sent/(zsend.finish - zsend.start)), send_avg, sizeof(send_avg));
			fprintf(stderr,
					"%5s %0.0f%%%s; send: %u done (%sp/s avg); "
					"recv: %u %sp/s (%sp/s avg); "
					"drops: %sp/s (%sp/s avg); "
					"hits: %0.2f%%\n",
					time_past,
					percent_complete,
					time_left,
					total_sent,
					send_avg,
					zrecv.success_unique,
					recv_rate,
					recv_avg,
					pcap_drop,
					pcap_drop_avg,
					hits);
		}
	}
	last_now  = now();
	last_sent = total_sent;
	last_rcvd = zrecv.success_unique;
	last_drop = zrecv.pcap_drop + zrecv.pcap_ifdrop;
	last_failures = zsend.sendto_failures;
}
Beispiel #16
0
static void
print_stats(const gchar *filename, capture_info *cf_info)
{
  const gchar           *file_type_string, *file_encap_string;
  time_t                start_time_t;
  time_t                stop_time_t;

  /* Build printable strings for various stats */
  file_type_string = wtap_file_type_string(cf_info->file_type);
  file_encap_string = wtap_encap_string(cf_info->file_encap);
  start_time_t = (time_t)cf_info->start_time;
  stop_time_t = (time_t)cf_info->stop_time;

  if (filename)           printf     ("File name:           %s\n", filename);
  if (cap_file_type)      printf     ("File type:           %s%s\n",
                                      file_type_string,
                                      cf_info->iscompressed ? " (gzip compressed)" : "");
  if (cap_file_encap)     printf     ("File encapsulation:  %s\n", file_encap_string);
  if (cap_file_encap && (cf_info->file_encap == WTAP_ENCAP_PER_PACKET)) {
    int i;
    for (i=0; i<WTAP_NUM_ENCAP_TYPES; i++) {
      if (cf_info->encap_counts[i] > 0)
        printf("                       %s\n", wtap_encap_string(i));
    }
  }
  if (cap_snaplen && cf_info->snap_set)
                          printf     ("Packet size limit:   file hdr: %u bytes\n", cf_info->snaplen);
  else if(cap_snaplen && !cf_info->snap_set)
                          printf     ("Packet size limit:   file hdr: (not set)\n");
  if (cf_info->snaplen_max_inferred > 0) {
    if (cf_info->snaplen_min_inferred == cf_info->snaplen_max_inferred)
                          printf     ("Packet size limit:   inferred: %u bytes\n", cf_info->snaplen_min_inferred);
    else
                          printf     ("Packet size limit:   inferred: %u bytes - %u bytes (range)\n",
                                      cf_info->snaplen_min_inferred, cf_info->snaplen_max_inferred);
  }
  if (cap_packet_count)   printf     ("Number of packets:   %u\n", cf_info->packet_count);
  if (cap_file_size)      printf     ("File size:           %" G_GINT64_MODIFIER "d bytes\n", cf_info->filesize);
  if (cap_data_size)      printf     ("Data size:           %" G_GINT64_MODIFIER "u bytes\n", cf_info->packet_bytes);
  if (cf_info->times_known) {
    if (cap_duration)
                          print_value("Capture duration:    ", 0, " seconds",   cf_info->duration);
    if (cap_start_time)
                          printf     ("Start time:          %s", time_string(start_time_t, cf_info, TRUE));
    if (cap_end_time)
                          printf     ("End time:            %s", time_string(stop_time_t, cf_info, TRUE));
    if (cap_data_rate_byte)
                          print_value("Data byte rate:      ", 2, " bytes/sec",   cf_info->data_rate);
    if (cap_data_rate_bit)
                          print_value("Data bit rate:       ", 2, " bits/sec",    cf_info->data_rate*8);
  }
  if (cap_packet_size)    printf     ("Average packet size: %.2f bytes\n",        cf_info->packet_size);
  if (cf_info->times_known) {
    if (cap_packet_rate) 
                          print_value("Average packet rate: ", 2, " packets/sec", cf_info->packet_rate);
  }
#ifdef HAVE_LIBGCRYPT
  if (cap_file_hashes) {
                          printf     ("SHA1:                %s\n", file_sha1);
                          printf     ("RIPEMD160:           %s\n", file_rmd160);
                          printf     ("MD5:                 %s\n", file_md5);
  }
#endif /* HAVE_LIBGCRYPT */
  if (cap_order)          printf     ("Strict time order:   %s\n", order_string(cf_info->order));
}
Beispiel #17
0
/*****************************************************************************
* FUNCTION
*	EntrySpofApp
* DESCRIPTION
*   Entry function of schedule power on off application.
* PARAMETERS
*	None.
* RETURNS
*	None.
* GLOBALS AFFECTED
*	None
*****************************************************************************/
void EntrySpofApp(void)
{
	U8* guiBuffer;
	S32 i;
	S32 num_of_items = NUM_OF_SPOF;
	MYTIME	tmpTime;
	U16 spof_states_icon[NUM_OF_SPOF];
	U16 spof_type_icon[NUM_OF_SPOF];
	
#ifdef __MMI_TWO_SPOF__
	num_of_items = 2;
#endif

	EntryNewScreen(SCR_ID_SPOF_APP, NULL, EntrySpofApp, NULL);
	
	guiBuffer = GetCurrGuiBuffer(SCR_ID_SPOF_APP);
	if(guiBuffer == NULL)
		g_spof_cntx.CurrItem = 0;

	/* initialize list to display */
	for (i=0;i<NUM_OF_SPOF;i++) 
	{
		/* get the value of spof_list*/ 
		memset(&tmpTime,0,sizeof(MYTIME));
		
		tmpTime.nHour = g_spof_cntx.SPOFList[i].Hour;
		tmpTime.nMin = g_spof_cntx.SPOFList[i].Min;
		
		time_string(&tmpTime,(UI_string_type)subMenuDataPtrs[i],DT_IDLE_SCREEN);
		
		/* get the value of spof_vicons*/   
#if defined(__PROJECT_GALLITE_C01__)
		if(g_spof_cntx.SPOFList[i].Status == SPOF_DISABLE) 
			spof_states_icon[i] = IMG_VICON;
		else 
		{      
        		/*get the value of spof_type poweon off */
        		if(g_spof_cntx.SPOFList[i].Type == SPOF_POWERON)
        			spof_states_icon[i] = SPOF_TYPEPOWERON_IMAGEID;
        		else
        			spof_states_icon[i] = SPOF_TYPEPOWEROFF_IMAGEID;
		}
#else 
		if(g_spof_cntx.SPOFList[i].Status == SPOF_DISABLE) 
			spof_states_icon[i] = SPOF_BLANK_IMAGEID;
		else 
			spof_states_icon[i] = IMG_VICON;
#endif
		/*get the value of spof_type poweon off */
		if(g_spof_cntx.SPOFList[i].Type == SPOF_POWERON)
			spof_type_icon[i] = SPOF_TYPEPOWERON_IMAGEID;
		else
			spof_type_icon[i] = SPOF_TYPEPOWEROFF_IMAGEID;

	}

	ShowCategory73Screen(SPOF_MAIN_TITLE_STRINGID,IMG_SCR_SETTING_CAPTION,STR_GLOBAL_EDIT,
    	SPOF_EDIT_BUTTON_IMAGEID,STR_GLOBAL_BACK,IMG_GLOBAL_BACK,num_of_items,subMenuDataPtrs,
	spof_states_icon,spof_type_icon, 0,guiBuffer,1);

	RegisterHighlightHandler(HighlightSpofList);

	SetLeftSoftkeyFunction(EntrySpofEdit,KEY_EVENT_UP);	
	SetKeyHandler(EntrySpofEdit, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);

	SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);	
	SetKeyHandler(GoBackHistory,KEY_LEFT_ARROW,KEY_EVENT_DOWN);
}
Beispiel #18
0
// ////////////////////////////////////////////////////////////////////////////
std::string CoreDumperBase::DecorateBaseName(const char *file_name_base,
	MLB::Utility::ProcessId process_id, const std::string &host_name,
	const MLB::Utility::TimeT &time_stamp)
{
	std::string tmp_base;

	if ((file_name_base == NULL) || (!(*file_name_base))) {
		try {
			GetProcessExecutableName(tmp_base);
			tmp_base = MLB::Utility::GetFileNamePortion(tmp_base);
#ifdef _Windows
			std::string::size_type base_size = tmp_base.size();
			if (base_size > 4) {
				if ((!stricmp(tmp_base.data() + (base_size - 4), ".EXE")) ||
					(!stricmp(tmp_base.data() + (base_size - 4), ".COM")))
					tmp_base.assign(tmp_base, 0, base_size - 4);
			}
#elif _VMS_
			std::string::size_type base_size = tmp_base.size();
			if (base_size > 4) {
				if (!stricmp(tmp_base.data() + (base_size - 4), ".COM"))
					tmp_base.assign(tmp_base, 0, base_size - 4);
			}
#endif // #ifdef _Windows
		}
		catch (const std::exception &) {
		}
		if (tmp_base.empty())
			tmp_base = "_UNSPECIFIED_CORE_DUMP_NAME_";
	}
	else {
		tmp_base = file_name_base;
		tmp_base = MLB::Utility::GetFileNamePortion(tmp_base);
#ifdef _Windows
		std::string::size_type base_size = tmp_base.size();
		if (base_size > 4) {
			if ((!stricmp(tmp_base.data() + (base_size - 4), ".EXE")) ||
				(!stricmp(tmp_base.data() + (base_size - 4), ".COM")))
				tmp_base.assign(tmp_base, 0, base_size - 4);
		}
#elif _VMS_
		std::string::size_type base_size = tmp_base.size();
		if (base_size > 4) {
			if (!stricmp(tmp_base.data() + (base_size - 4), ".COM"))
				tmp_base.assign(tmp_base, 0, base_size - 4);
		}
#endif // #ifdef _Windows
	}

	tmp_base = MLB::Utility::GetFileNamePortion(tmp_base);
	tmp_base = MLB::Utility::Trim(tmp_base, ". \t\r\n\v\f");

	if (tmp_base.empty())
		tmp_base = "_UNSPECIFIED_CORE_DUMP_NAME_";

	std::string time_string(time_stamp.ToString());

	time_string[10]  = '.';
	time_string[13]  = '.';
	time_string[16]  = '.';
	tmp_base         = "CoreDump." + tmp_base + "." + time_string + "." +
		host_name + "." + MLB::Utility::ZeroFill(process_id, 10);

	return(tmp_base);
}
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitWindowSize(900, 900);
	glutInitWindowPosition(0, 0);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); // GLUT_DOUBLE : Bit mask to select a double buffered window
	glutCreateWindow("Visualization");
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	//glutKeyboardFunc(keyboard);
	glutMouseFunc(mouse);
	glutMotionFunc(motion);

	/*
	//=================Read CSV file====================//
	clock_t begin = clock();
	read_raw_data();
	clock_t end = clock();
	printf("Read csv elapsed time: %f\n",double(end - begin) / CLOCKS_PER_SEC);
	//==================================================//

	int attribute_title_size = 11;
	int attribute_title[] = {4,5,6,7,8,9,10,11,12,22,23};//(gravity_x,gravity_y,gravity_z,linear_acc_x),(linear_acc_x,linear_acc_y,linear_acc_z),(gyro_x,gyro_y,gyro_z),(latitude,longitude)
	int time_title[] = {29,30,31,32,33};//hour(30),minute(31)
	
	//============Setting matrix for K-means============//
	clock_t begin2 = clock();
	set_hour_data(time_title);
	Mat model = set_matrix(attribute_title,attribute_title_size).clone();
	clock_t end2 = clock();
	printf("Setting matrix elapsed time: %f\n",double(end2 - begin2) / CLOCKS_PER_SEC);
	//==================================================//
	output_mat_as_txt_file("model.txt",model);
    int k = 50; 
    Mat cluster_tag; //Tag:0~k-1
    int attempts = 2;//應該是執行次數
	Mat cluster_centers;
	//==============K means clustering==================//
    
	//使用k means分群
	clock_t begin3 = clock();
	kmeans(model, k, cluster_tag,TermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 10, 0.0001), attempts,KMEANS_PP_CENTERS,cluster_centers);
	clock_t end3 = clock();
    //TermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 10, 1),  這裡有三個參數,決定k-means何時結束,第二個參數是指迭代最大次數,第三個參數是精確度多少,第一個參數是指依照前兩個參數的哪一個為準,以範例中就是兩者都參照,以 or 的方式決定
	printf("Kmeans (K = %d) elapsed time: %f\n",k,double(end3 - begin3) / CLOCKS_PER_SEC);
	//==================================================//
	
	voting(k,cluster_tag,model.rows); // Type: int
	cluster_tag.release();
	model.release();
	//===================PCA RGB=======================//
	Mat components, result;
	int rDim = 3;
	clock_t begin4 = clock();
	reduceDimPCA(cluster_centers, rDim, components, result);
	clock_t end4 = clock();
	printf("PCA RGB elapsed time: %f\n",double(end4 - begin4) / CLOCKS_PER_SEC);
	rgb_mat = result.clone();
	for(int i=0;i<result.cols;i++)
		normalize(result.col(i),rgb_mat.col(i),0,1,NORM_MINMAX); //normalize to 0-1
	output_mat_as_txt_file("rgb_mat.txt",rgb_mat);
	//===============Position (MDS)=====================//
	clock_t begin5 = clock();
	position = Position_by_MDS(cluster_centers,k,20).clone(); //Type:double
	clock_t end5 = clock();
	printf("MDS Position elapsed time: %f\n",double(end5 - begin5) / CLOCKS_PER_SEC);
	cluster_centers.release();
	//==================================================//
	*/
	time_string();

	//raw_data.clear();

	preprocessing_data.start();

	glutMainLoop();

	return 0;
}
Beispiel #20
0
/*!
* \brief Creates the GUI for read or delivery reports.
*
* \param titleStrId The form title.
* \param from The from address.
* \param subject The subject.
* \param statusStrId The status of the message.
* \param date The date of the message
* \return TRUE if successful, otherwise FALSE.
*****************************************************************************/
MSF_BOOL meaCreateMvRrDrView(MSF_UINT32 titleStrId, const char *from, const char *subject,
                             MSF_UINT32 statusStrId, MmsTimeSec rDate)
{
    ctk_screen_handle	scrid;
    kal_uint8 			*text;
    int					text_size;
    MYTIME time;
    MSF_UINT16* dateOrTimeString;
    MeaAddrType addrType;
    char *name = NULL;

    if (0 != meaMvRrDrView.formHandle)
    {
        /* Delete the GUI so that all resources are de-allocated */
        meaDeleteMvRrDrView();
    }
    memset(&meaMvRrDrView, 0, sizeof(meaMvRrDrView));

    /* Prepare text */
    text_size = 150; /* The default size. widget_ucs2str_append_* will realloc the buffer on necessary */
    text = MEA_ALLOC(text_size);
    widget_utf8_to_ucs2_string(text, text_size, (kal_uint8*) "");

    text = widget_ucs2str_append_id(MSF_MODID_MEA, text, &text_size, (MSF_UINT16)titleStrId);
    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)"\n\n");

    /* To */
    text = widget_ucs2str_append_id(MSF_MODID_MEA, text, &text_size, MEA_STR_ID_TO);
    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)":\n");

    if (MEA_ADDR_TYPE_PLMN == (addrType = meaGetAddrType(from)))
    {
        name = meaLookupNameFromPHB((char *)from);
        text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)name);
    }
    else
    {
        text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)from);
    }

    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)"\x1B\n");

    /* Subject */
    text = widget_ucs2str_append_id(MSF_MODID_MEA, text, &text_size, MEA_STR_ID_SUBJECT);
    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)":\n");
    if (subject)
    {
        text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)subject);
    }
    else
    {
        text = widget_ucs2str_append_id(MSF_MODID_MEA, text, &text_size, MEA_STR_ID_NO_SUBJECT);
    }
    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)"\x1B\n");

    /* Date */
    text = widget_ucs2str_append_id(MSF_MODID_MEA, text, &text_size, MEA_STR_ID_DATE);
    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)"\n");
    dateOrTimeString = MEA_ALLOC(MEA_MAX_DATE_SIZE);
    rDate += (HDIa_timeGetTimeZone() * 60);
    mmi_dt_utc_sec_2_mytime((kal_int32)rDate, &time, KAL_TRUE);
    date_string(&time, dateOrTimeString, DT_IDLE_SCREEN);
    text = widget_ucs2str_append_ucs2(MSF_MODID_MEA, text, &text_size, (kal_uint8 *)dateOrTimeString);
    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)"\n");
    time_string(&time, dateOrTimeString, DT_IDLE_SCREEN);
    text = widget_ucs2str_append_ucs2(MSF_MODID_MEA, text, &text_size, (kal_uint8 *)dateOrTimeString);
    MEA_FREE(dateOrTimeString);
    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)"\x1B\n");

    /* Status */
    text = widget_ucs2str_append_id(MSF_MODID_MEA, text, &text_size, MEA_STR_ID_STATUS);
    text = widget_ucs2str_append_utf8(MSF_MODID_MEA, text, &text_size, (kal_uint8*)"\n");
    text = widget_ucs2str_append_id(MSF_MODID_MEA, text, &text_size, (MSF_UINT16)statusStrId);

    /* Create widow */
    meaMvRrDrView.formHandle = HDIa_widgetExtCreateTextViewSeparator(MSF_MODID_MEA, text,
                               (MSF_UINT16)titleStrId, 0);

    MEA_FREE(text);
    meaAddWidgetList(meaMvRrDrView.formHandle);

    /* Set Key */
    scrid = HDIa_widgetCtkGetScreenHandle(meaMvRrDrView.formHandle);

#ifdef __UNIFIED_MSG_SUPPORT__
    ctk_screen_addRSK_UA(scrid, STR_GLOBAL_BACK, IMG_GLOBAL_BACK, NULL, meaMvDrViewOk, KAL_TRUE);
    ctk_screen_add_key_UA(scrid, KEY_LEFT_ARROW, NULL, meaMvDrViewOk, KAL_TRUE);
    ctk_screen_addLSK_UA(scrid, MEA_STR_ID_OPTIONS, IMG_GLOBAL_OK, NULL, handleMvPropOptionAction, KAL_TRUE);
#else
    ctk_screen_addLSK_UA(scrid, STR_GLOBAL_OK, IMG_GLOBAL_OK, NULL, meaMvDrViewOk, KAL_TRUE);
    //ctk_screen_add_key_UA(scrid, KEY_LEFT_ARROW, NULL, meaMvPropViewOnlyGoBack, KAL_TRUE);
#endif

    return meaDisplayWindow(meaMvRrDrView.formHandle, meaGetPosLeftTop());
}
Beispiel #21
0
static void
print_stats_table(const gchar *filename, capture_info *cf_info)
{
  const gchar           *file_type_string, *file_encap_string;
  time_t                start_time_t;
  time_t                stop_time_t;

  /* Build printable strings for various stats */
  file_type_string = wtap_file_type_string(cf_info->file_type);
  file_encap_string = wtap_encap_string(cf_info->file_encap);
  start_time_t = (time_t)cf_info->start_time;
  stop_time_t = (time_t)cf_info->stop_time;

  if (filename) {
    putquote();
    printf("%s", filename);
    putquote();
  }

  if (cap_file_type) {
    putsep();
    putquote();
    printf("%s", file_type_string);
    putquote();
  }

  /* ToDo: If WTAP_ENCAP_PER_PACKET, show the list of encapsulations encountered;
   *       Output a line for each different encap with all fields repeated except
   *        the encapsulation field which has "Per Packet: ..." for each
   *        encapsulation type seen ?
   */
  if (cap_file_encap) {
    putsep();
    putquote();
    printf("%s", file_encap_string);
    putquote();
  }

  if (cap_snaplen) {
    putsep();
    putquote();
    if(cf_info->snap_set)
      printf("%u", cf_info->snaplen);
    else
      printf("(not set)");
    putquote();
    if (cf_info->snaplen_max_inferred > 0) {
      putsep();
      putquote();
      printf("%u", cf_info->snaplen_min_inferred);
      putquote();
      putsep();
      putquote();
      printf("%u", cf_info->snaplen_max_inferred);
      putquote();
    }
    else {
      putsep();
      putquote();
      printf("n/a");
      putquote();
      putsep();
      putquote();
      printf("n/a");
      putquote();
    }
  }

  if (cap_packet_count) {
    putsep();
    putquote();
    printf("%u", cf_info->packet_count);
    putquote();
  }

  if (cap_file_size) {
    putsep();
    putquote();
    printf("%" G_GINT64_MODIFIER "d", cf_info->filesize);
    putquote();
  }

  if (cap_data_size) {
    putsep();
    putquote();
    printf("%" G_GINT64_MODIFIER "u", cf_info->packet_bytes);
    putquote();
  }

  if (cap_duration) {
    putsep();
    putquote();
    if (cf_info->times_known)
      printf("%f", cf_info->duration);
    else
      printf("n/a");
    putquote();
  }

  if (cap_start_time) {
    putsep();
    putquote();
    printf("%s", time_string(start_time_t, cf_info, FALSE));
    putquote();
  }

  if (cap_end_time) {
    putsep();
    putquote();
    printf("%s", time_string(stop_time_t, cf_info, FALSE));
    putquote();
  }

  if (cap_data_rate_byte) {
    putsep();
    putquote();
    if (cf_info->times_known)
      printf("%.2f", cf_info->data_rate);
    else
      printf("n/a");
    putquote();
  }

  if (cap_data_rate_bit) {
    putsep();
    putquote();
    if (cf_info->times_known)
      printf("%.2f", cf_info->data_rate*8);
    else
      printf("n/a");
    putquote();
  }

  if (cap_packet_size) {
    putsep();
    putquote();
    printf("%.2f", cf_info->packet_size);
    putquote();
  }

  if (cap_packet_rate) {
    putsep();
    putquote();
    if (cf_info->times_known)
      printf("%.2f", cf_info->packet_rate);
    else
      printf("n/a");
    putquote();
  }

#ifdef HAVE_LIBGCRYPT
  if (cap_file_hashes) {
    putsep();
    putquote();
    printf("%s", file_sha1);
    putquote();

    putsep();
    putquote();
    printf("%s", file_rmd160);
    putquote();

    putsep();
    putquote();
    printf("%s", file_md5);
    putquote();
  }
#endif /* HAVE_LIBGCRYPT */

  if (cap_order) {
    putsep();
    putquote();
    printf("%s", order_string(cf_info->order));
    putquote();
  }

  printf("\n");
}
Beispiel #22
0
 for (i = 0; i < uri_length; ++i) {
Beispiel #23
0
/* Extract the data postioned at src_stream to either filesystem, stdout or
 * buffer depending on the value of 'function' which is defined in bbtargz.h
 *
 * prefix doesnt have to be just a directory, it may prefix the filename as well.
 *
 * e.g. '/var/lib/dpkg/info/dpkg.' will extract all files to the base bath
 * '/var/lib/dpkg/info/' and all files/dirs created in that dir will have
 * 'dpkg.' as their prefix
 *
 * For this reason if prefix does point to a dir then it must end with a
 * trailing '/' or else the last dir will be assumed to be the file prefix
 */
static char *extract_archive(struct gzip_handle *src_stream, FILE * out_stream,
			     const file_header_t * file_entry,
			     const int function, const char *prefix, int *err)
{
	FILE *dst_stream = NULL;
	char *full_name = NULL;
	char *full_link_name = NULL;
	char *buffer = NULL;
	struct utimbuf t;

	*err = 0;

	/* prefix doesnt have to be a proper path it may prepend
	 * the filename as well */
	if (prefix != NULL) {
		/* strip leading '/' in filename to extract as prefix may not be dir */
		/* Cant use concat_path_file here as prefix might not be a directory */
		char *path = file_entry->name;
		if (strncmp("./", path, 2) == 0) {
			path += 2;
			if (strlen(path) == 0)
				/* Do nothing, current dir already exists. */
				return NULL;
		}
		full_name = xmalloc(strlen(prefix) + strlen(path) + 1);
		strcpy(full_name, prefix);
		strcat(full_name, path);
		if (file_entry->link_name) {
			full_link_name =
			    xmalloc(strlen(prefix) +
				    strlen(file_entry->link_name) + 1);
			strcpy(full_link_name, prefix);
			strcat(full_link_name, file_entry->link_name);
		}
	} else {
		full_name = xstrdup(file_entry->name);
		if (file_entry->link_name)
			full_link_name = xstrdup(file_entry->link_name);
	}

	if (function & extract_to_stream) {
		if (S_ISREG(file_entry->mode)) {
			*err =
			    gzip_copy(src_stream, out_stream, file_entry->size);
			archive_offset += file_entry->size;
		}
	} else if (function & extract_one_to_buffer) {
		if (S_ISREG(file_entry->mode)) {
			buffer = (char *)xmalloc(file_entry->size + 1);
			gzip_read(src_stream, buffer, file_entry->size);
			buffer[file_entry->size] = '\0';
			archive_offset += file_entry->size;
			goto cleanup;
		}
	} else if (function & extract_all_to_fs) {
		struct stat oldfile;
		int stat_res;
		stat_res = lstat(full_name, &oldfile);
		if (stat_res == 0) {	/* The file already exists */
			if ((function & extract_unconditional)
			    || (oldfile.st_mtime < file_entry->mtime)) {
				if (!S_ISDIR(oldfile.st_mode)) {
					unlink(full_name);	/* Directories might not be empty etc */
				}
			} else {
				if ((function & extract_quiet) != extract_quiet) {
					*err = -1;
					error_msg
					    ("%s not created: newer or same age file exists",
					     file_entry->name);
				}
				seek_forward(src_stream, file_entry->size);
				goto cleanup;
			}
		}
		if (function & extract_create_leading_dirs) {	/* Create leading directories with default umask */
			char *buf, *parent;
			buf = xstrdup(full_name);
			parent = dirname(buf);
			if (make_directory(parent, -1, FILEUTILS_RECUR) != 0) {
				if ((function & extract_quiet) != extract_quiet) {
					*err = -1;
					error_msg
					    ("couldn't create leading directories");
				}
			}
			free(buf);
		}
		switch (file_entry->mode & S_IFMT) {
		case S_IFREG:
			if (file_entry->link_name) {	/* Found a cpio hard link */
				if (link(full_link_name, full_name) != 0) {
					if ((function & extract_quiet) !=
					    extract_quiet) {
						*err = -1;
						perror_msg
						    ("Cannot link from %s to '%s'",
						     file_entry->name,
						     file_entry->link_name);
					}
				}
			} else {
				if ((dst_stream =
				     wfopen(full_name, "w")) == NULL) {
					*err = -1;
					seek_forward(src_stream,
						     file_entry->size);
					goto cleanup;
				}
				archive_offset += file_entry->size;
				*err =
				    gzip_copy(src_stream, dst_stream,
					      file_entry->size);
				fclose(dst_stream);
			}
			break;
		case S_IFDIR:
			if (stat_res != 0) {
				if (mkdir(full_name, file_entry->mode) < 0) {
					if ((function & extract_quiet) !=
					    extract_quiet) {
						*err = -1;
						perror_msg("Cannot make dir %s",
							   full_name);
					}
				}
			}
			break;
		case S_IFLNK:
			if (symlink(file_entry->link_name, full_name) < 0) {
				if ((function & extract_quiet) != extract_quiet) {
					*err = -1;
					perror_msg
					    ("Cannot create symlink from %s to '%s'",
					     file_entry->name,
					     file_entry->link_name);
				}
				goto cleanup;
			}
			break;
		case S_IFSOCK:
		case S_IFBLK:
		case S_IFCHR:
		case S_IFIFO:
			if (mknod
			    (full_name, file_entry->mode,
			     file_entry->device) == -1) {
				if ((function & extract_quiet) != extract_quiet) {
					*err = -1;
					perror_msg("Cannot create node %s",
						   file_entry->name);
				}
				goto cleanup;
			}
			break;
		default:
			*err = -1;
			perror_msg("Don't know how to handle %s", full_name);

		}

		/* Changing a symlink's properties normally changes the properties of the
		 * file pointed to, so dont try and change the date or mode, lchown does
		 * does the right thing, but isnt available in older versions of libc */
		if (S_ISLNK(file_entry->mode)) {
#if (__GLIBC__ > 2) && (__GLIBC_MINOR__ > 1)
			lchown(full_name, file_entry->uid, file_entry->gid);
#endif
		} else {
			if (function & extract_preserve_date) {
				t.actime = file_entry->mtime;
				t.modtime = file_entry->mtime;
				utime(full_name, &t);
			}
			chown(full_name, file_entry->uid, file_entry->gid);
			chmod(full_name, file_entry->mode);
		}
	} else {
		/* If we arent extracting data we have to skip it,
		 * if data size is 0 then then just do it anyway
		 * (saves testing for it) */
		seek_forward(src_stream, file_entry->size);
	}

	/* extract_list and extract_verbose_list can be used in conjunction
	 * with one of the above four extraction functions, so do this seperately */
	if (function & extract_verbose_list) {
		fprintf(out_stream, "%s %d/%d %8d %s ",
			mode_string(file_entry->mode), file_entry->uid,
			file_entry->gid, (int)file_entry->size,
			time_string(file_entry->mtime));
	}
	if ((function & extract_list) || (function & extract_verbose_list)) {
		/* fputs doesnt add a trailing \n, so use fprintf */
		fprintf(out_stream, "%s\n", file_entry->name);
	}

cleanup:
	free(full_name);
	if (full_link_name)
		free(full_link_name);

	return buffer;
}
Beispiel #24
0
/*****************************************************************************
 * FUNCTION
 *  mmi_rmgr_populate_drm_info_aux
 * DESCRIPTION
 *  
 * PARAMETERS
 *  rights          [?]         
 *  permission      [IN]        
 *  data            [?]         
 * RETURNS
 *  
 *****************************************************************************/
kal_bool mmi_rmgr_populate_drm_info_aux(kal_wchar *path, kal_uint8 app_perm, kal_uint8 *data, kal_int32 ref)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    FS_HANDLE input = FS_ERROR_RESERVED;
    kal_int32 start = 0, end = 0, cons_ret = DRM_RESULT_NON_DRM;
    kal_bool ret = KAL_FALSE, flag = KAL_TRUE;
    kal_uint8 permission;
    drm_method_enum method;
        
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* permission's incorrect, but ok here*/
    if (app_perm == DRM_PERMISSION_ALL)
         permission = DRM_PERMISSION_PLAY;
    else
        permission = app_perm;
    
    if(ref < 0)
    {
        input = DRM_open_file(path, FS_READ_ONLY, permission);

        if (input < FS_NO_ERROR)
            return ret;
        
        method = DRM_get_object_method(input, NULL);    
    }
    else
    {
        method = DRM_get_object_method_by_ref(ref);
    }
    
    if (method != DRM_METHOD_NONE)
    {
        if (ref < 0)
        {
            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_RIGHT));
            mmi_ucs2cat((PS8) data, (PS8) L"\n");
            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_PROTECTED));
            mmi_ucs2cat((PS8) data, (PS8) L"\n");
        }
    }
    else
    {
        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_RIGHT));
        mmi_ucs2cat((PS8) data, (PS8) L"\n");
        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_UNPROTECTED));
        mmi_ucs2cat((PS8) data, (PS8) L"\n");

        if (ref < 0)
        {
            DRM_close_file(input);
        }
        else
        {
            DRM_free_ro_detail();
        }
        return ret;
    }

#ifdef __DRM_V02__
    if (ref < 0)
    {
        kal_wchar *sepa = kal_wstrrchr(path, (kal_int32) '\\');
    
        if (DRM_is_archive(input, NULL) && sepa && kal_wstrncmp(sepa - 4, L".odf\\", 5) != 0)
        {
            /* Multi Part ODF */
            mmi_ucs2cat((PS8) data, (PS8) L" ");
            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_MULTI_PART));
            mmi_ucs2cat((PS8) data, (PS8) L"\n");
            return ret;
        }
    }
#endif    
    
    if (method == DRM_METHOD_FORWARD_LOCK)
    {
        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_SUMMARY));
        mmi_ucs2cat((PS8) data, (PS8) L"\n");
        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_UNLIMITED));
        mmi_ucs2cat((PS8) data, (PS8) L"\n");
        
        if (ref < 0)
        {
            DRM_close_file(input);
        }
        else
        {
            DRM_free_ro_detail();
        }
        return ret;
    }

   
    do
    {
        if (permission & (DRM_PERMISSION_PLAY | DRM_PERMISSION_DISPLAY | DRM_PERMISSION_EXECUTE | DRM_PERMISSION_PRINT | DRM_PERMISSION_EXPORT))
        {
            drm_constraint_struct cons;
            if (ref < 0)
            {
                if (app_perm == DRM_PERMISSION_ALL && permission != DRM_PERMISSION_PLAY)
                {
                    input = DRM_open_file(path, FS_READ_ONLY, permission);

                    if (input < FS_NO_ERROR)
                        return KAL_FALSE;
                }
                
                cons_ret = DRM_get_constraint(input, NULL, permission, &cons);
            }
            else
            {
                cons_ret = DRM_get_constraint_by_ref(ref, permission, &cons);
            }
            
            if (cons_ret >= DRM_RESULT_OK && cons.status == DRM_STATUS_RIGHTS_PRESENT)
            {
                
                if (flag)
                {
                    mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_SUMMARY));
                    mmi_ucs2cat((PS8) data, (PS8) L"\n");
                    flag = KAL_FALSE;
                }

                switch(permission)
                {
                    case DRM_PERMISSION_PLAY:
                        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_DRM_PLAY));
                        mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        break;
                    case DRM_PERMISSION_DISPLAY:
                        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_DRM_DISPLAY));
                        mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        break;
                    case DRM_PERMISSION_EXECUTE:
                        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_DRM_EXECUTE));
                        mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        break;
                    case DRM_PERMISSION_PRINT:
                        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_DRM_PRINT));
                        mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        break;
                    case DRM_PERMISSION_EXPORT:
                        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_DRM_EXPORT));
                        mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        break;
                    default:
                        break;
                }

                if (((method & DRM_METHOD_COMBINED_DELIVERY) ||
                     (method & DRM_METHOD_SEPARATE_DELIVERY) || 
                     (method & DRM_METHOD_V2)) &&
                    (cons.status != DRM_STATUS_NO_RIGHTS))
                {
                
                    MYTIME t;
                    S8 buffer[20];
                    drm_constraint_struct *constraint;
                
                    constraint = &cons;
                    
                    if (constraint->type != DRM_CONSTRAINT_NONE)
                    {
                        if (constraint->type & DRM_CONSTRAINT_COUNT)
                        {
                            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_COUNT));
                            sprintf((char*)buffer, "\n%d/%d", constraint->used_count, constraint->total_count);
                            mmi_asc_to_ucs2((PS8) & data[mmi_ucs2strlen((PS8) data) << 1], (PS8) buffer);
                            mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        }

                #ifdef __DRM_V02__
                        if (constraint->type & DRM_CONSTRAINT_ACCUMULATED)
                        {
                            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_ACCUMULATED));
                            sprintf((char*)buffer, "\n%d ", constraint->accum_dur);
                            mmi_asc_to_ucs2((PS8) & data[mmi_ucs2strlen((PS8) data) << 1], (PS8) buffer);
                            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_SEC));
                            mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        }
                    
                        if (constraint->type & DRM_CONSTRAINT_TIMEDCOUNT)
                        {
                            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_TIMEDCOUNT));
                            mmi_ucs2cat((PS8) data, (PS8) L"\n");
                            sprintf((char*)buffer, "%d ", constraint->timed_count);
                            mmi_asc_to_ucs2((PS8) & data[mmi_ucs2strlen((PS8) data) << 1], (PS8) buffer);
                            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_TIMEDCOUNT_TIME));
                            sprintf((char*)buffer, "%d ", constraint->period);
                            mmi_asc_to_ucs2((PS8) & data[mmi_ucs2strlen((PS8) data) << 1], (PS8) buffer);
                            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_SEC));
                            mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        }
                #endif /* __DRM_V02__ */

                        if (constraint->type & DRM_CONSTRAINT_DATETIME)
                        {
                            if ((constraint->type & DRM_CONSTRAINT_INTERVAL) && constraint->start_intv != 0)
                            {
                                 /* date time contains interval -> show interval*/
                                 if (constraint->start_time <= constraint->start_intv &&
                                      constraint->end_time >= constraint->end_intv)
                                 {
                                          start = constraint->start_intv;
                                          end = constraint->end_intv;
                                 }
                                 /* interval contains date time -> show date time*/
                                 else if (constraint->start_intv <= constraint->start_time &&
                                      constraint->end_intv >= constraint->end_time)
                                 {
                                          start = constraint->start_time;
                                          end = constraint->end_time;
                                 }
                                 /* date time overlaps interval -> show overlap*/
                                 else if (constraint->start_intv <= constraint->start_time &&
                                      constraint->end_intv <= constraint->end_time && 
                                      constraint->start_time <= constraint->end_intv)
                                 {
                                          start = constraint->start_time;
                                          end = constraint->end_intv;
                                 }
                                 /* interval overlaps date time -> show overlap*/
                                 else if (constraint->start_time <= constraint->start_intv &&
                                      constraint->end_time <= constraint->end_intv &&
                                      constraint->start_intv <= constraint->end_time)
                                 {
                                      start = constraint->start_intv;
                                    end = constraint->end_time;
                                 }
                                 else
                                 {
                                          start = constraint->start_intv;
                                          end = constraint->end_intv;
                                 }
                            }
                            else
                            {
                                start = constraint->start_time;
                                end = constraint->end_time;
                            }
                        }
                        else if (constraint->type & DRM_CONSTRAINT_INTERVAL)
                        {
                            if (constraint->interval <= 0)
                            {
                                start = -1;
                                end = -1;
                            }
                            else
                            {
                                start = constraint->start_intv;
                                end = constraint->end_intv;
                            }
                        }
                        
                        if (start > 0)
                        {
                            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_START));
                            mmi_ucs2cat((PS8) data, (PS8) L"\n");
                            mmi_dt_utc_sec_2_mytime(start, &t, FALSE);
                            date_string(&t, (PU16) & data[mmi_ucs2strlen((PS8) data) << 1], DT_IDLE_SCREEN);
                            mmi_ucs2cat((PS8) data, (PS8) L" ");
                            time_string(&t, (PU16) & data[mmi_ucs2strlen((PS8) data) << 1], DT_IDLE_SCREEN);
                            mmi_ucs2cat((PS8) data, (PS8) L"\n");
                        }
                    
                        if (end > 0)
                        {
                            mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_END));
                            mmi_ucs2cat((PS8) data, (PS8) L"\n");
                            mmi_dt_utc_sec_2_mytime(end, &t, FALSE);
                            date_string(&t, (PU16) & data[mmi_ucs2strlen((PS8) data) << 1], DT_IDLE_SCREEN);
                            mmi_ucs2cat((PS8) data, (PS8) L" ");
                            time_string(&t, (PU16) & data[mmi_ucs2strlen((PS8) data) << 1], DT_IDLE_SCREEN);
                            mmi_ucs2cat((PS8) data, (PS8) L"\n");                    
                        }
                    }
                    else
                    {
                        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_DETAIL_UNLIMITED));
                        mmi_ucs2cat((PS8) data, (PS8) L"\n");
                    }

                }
                
            }

            if (ref < 0)
            {
                DRM_close_file(input);
            }

        }

        permission = permission<<1;
    }
    while(permission < DRM_PERMISSION_ALL && app_perm == DRM_PERMISSION_ALL);
    
    if (flag)
    {
        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_ID_RMGR_SUMMARY));
        mmi_ucs2cat((PS8) data, (PS8) L"\n");
        mmi_ucs2cat((PS8) data, (PS8) GetString(STR_GLOBAL_INVALID));
        mmi_ucs2cat((PS8) data, (PS8) L"\n");
    }

    return ret;
}