Example #1
0
static unsigned char *
get_progress_msg_2(struct progress *progress, struct terminal *term,
		 int wide, int full, unsigned char *separator, unsigned char *type)
{
	struct string msg;
	int newlines = separator[strlen(separator) - 1] == '\n';

	if (!init_string(&msg)) return NULL;

	/* FIXME: The following is a PITA from the l10n standpoint. A *big*
	 * one, _("of")-like pearls are a nightmare. Format strings need to
	 * be introduced to this fuggy corner of code as well. --pasky */

	add_to_string(&msg, type);
	add_char_to_string(&msg, ' ');
	add_xnum_to_string(&msg, progress->pos);
	if (progress->size >= 0) {
		add_char_to_string(&msg, ' ');
		add_to_string(&msg, _("of", term));
		add_char_to_string(&msg, ' ');
		add_xnum_to_string(&msg, progress->size);
	}

	add_to_string(&msg, separator);

	if (wide) {
		/* Do the following only if there is room */

		add_to_string(&msg,
			      _(full ? (newlines ? N_("Average speed")
					         : N_("average speed"))
				     : N_("avg"),
				term));
		add_char_to_string(&msg, ' ');
		add_xnum_to_string(&msg, progress->average_speed);
		add_to_string(&msg, "/s");

		add_to_string(&msg, ", ");
		add_to_string(&msg,
			      _(full ? N_("current speed") : N_("cur"), term));
		add_char_to_string(&msg, ' '),
		add_xnum_to_string(&msg, progress->current_speed);
		add_to_string(&msg, "/s");

		add_to_string(&msg, separator);

		add_to_string(&msg, _(full ? (newlines ? N_("Elapsed time")
						       : N_("elapsed time"))
					   : N_("ETT"),
				   term));
		add_char_to_string(&msg, ' ');
		add_timeval_to_string(&msg, &progress->elapsed);

	} else {
		add_to_string(&msg, _(newlines ? N_("Speed") : N_("speed"),
					term));

		add_char_to_string(&msg, ' ');
		add_xnum_to_string(&msg, progress->average_speed);
		add_to_string(&msg, "/s");
	}

	if (progress->size >= 0 && progress->loaded > 0) {
		add_to_string(&msg, ", ");
		add_to_string(&msg, _(full ? N_("estimated time")
					   : N_("ETA"),
				      term));
		add_char_to_string(&msg, ' ');
		add_timeval_to_string(&msg, &progress->estimated_time);
	}

	return msg.source;
}
Example #2
0
unsigned char *get_progress_msg( struct progress *progress, struct terminal *term, int wide, int full, unsigned char *separator )
{
  int eax;
  int edx;
  struct string msg;
  int newlines;
  newlines/*.1_1of4*/ = *(char*)(( separator + strlen( (char*)separator ) ) - 1);
  if ( init_string( &msg ) == 0 )
  {
    return msg.source;
  }
  if ( 0 != 82 )
  {
    if ( term && current_charset != get_terminal_codepage( term ) )
    {
      bind_textdomain_codeset( "elinks", get_cp_mime_name( get_terminal_codepage( term ) ) );
      current_charset = get_terminal_codepage( term );
    }
    gettext( "Received" );
  }
  add_to_string( &msg, gettext( "Received" ) );
  add_char_to_string( &msg, 32 );
  add_xnum_to_string( &msg, progress->pos );
  if ( (int)(progress->size << 32) >= 0 )
  {
    add_char_to_string( &msg, 32 );
    if ( 0 != 111 )
    {
      if ( term && current_charset != get_terminal_codepage( term ) )
      {
        bind_textdomain_codeset( "elinks", get_cp_mime_name( get_terminal_codepage( term ) ) );
        current_charset = get_terminal_codepage( term );
      }
      gettext( "of" );
    }
    add_to_string( &msg, gettext( "of" ) );
    add_char_to_string( &msg, 32 );
    add_xnum_to_string( &msg, progress->size );
  }
  newlines = newlines/*.1_1of4*/ == 10;
  add_to_string( &msg, &separator[0] );
  if ( wide )
  {
    if ( *(char*)(newlines != 0 ? "average speed" : "Average speed") )
    {
      if ( term && current_charset != get_terminal_codepage( term ) )
      {
        bind_textdomain_codeset( "elinks", get_cp_mime_name( get_terminal_codepage( term ) ) );
        *ebp_48 = newlines != 0 ? "average speed" : "Average speed";
        current_charset = get_terminal_codepage( term );
      }
      return (unsigned char*)eax;
    }
    add_to_string( &ebx, &edx );
    add_char_to_string( &msg, 32 );
    add_xnum_to_string( &msg, progress->average_speed );
    add_to_string( &msg, "/s" );
    add_to_string( &msg, ", " );
    if ( *(char*)(full == 0 ? "current speed" : "cur") )
    {
      if ( term && current_charset != get_terminal_codepage( term ) )
      {
        bind_textdomain_codeset( "elinks", get_cp_mime_name( get_terminal_codepage( term ) ) );
        *ebp_48 = full == 0 ? "current speed" : "cur";
        current_charset = get_terminal_codepage( term );
      }
      return (unsigned char*)eax;
    }
    add_to_string( &ebx, &edx );
    add_char_to_string( &msg, 32 );
    add_xnum_to_string( &msg, progress->current_speed );
    add_to_string( &msg, "/s" );
    add_to_string( &msg, &separator[0] );
    if ( *(char*)(newlines != 0 ? "elapsed time" : "Elapsed time") )
    {
      if ( term && current_charset != get_terminal_codepage( term ) )
      {
        bind_textdomain_codeset( "elinks", get_cp_mime_name( get_terminal_codepage( term ) ) );
        current_charset = get_terminal_codepage( term );
      }
    }
    add_to_string( &ebx, &edi );
    add_char_to_string( &msg, 32 );
    add_timeval_to_string( &msg, &progress[0].elapsed );
  }
  else
  {
    if ( *(char*)(newlines != 0 ? "speed" : "Speed") )
    {
      if ( term && current_charset != get_terminal_codepage( term ) )
      {
        bind_textdomain_codeset( "elinks", get_cp_mime_name( get_terminal_codepage( term ) ) );
        current_charset = get_terminal_codepage( term );
      }
      gettext( newlines != 0 ? "speed" : "Speed" );
    }
    add_to_string( &msg, gettext( newlines != 0 ? "speed" : "Speed" ) );
    add_char_to_string( &msg, 32 );
    add_xnum_to_string( &msg, progress->average_speed );
    add_to_string( &msg, "/s" );
  }
  if ( (int)(progress->size << 32) >= 0 && (int)(progress->loaded << 32) >= 0 )
  {
    if ( ccdep1 <= ccdep2 )
    {
      if ( (int)(progress->loaded & 0xFFFFFFFF) >= 1 )
      {
      }
    }
    add_to_string( &msg, ", " );
    if ( *(char*)(full == 0 ? "estimated time" : "ETA") )
    {
      if ( term && current_charset != get_terminal_codepage( term ) )
      {
        bind_textdomain_codeset( "elinks", get_cp_mime_name( get_terminal_codepage( term ) ) );
        current_charset = get_terminal_codepage( term );
      }
    }
    add_to_string( &ebx, &edi );
    add_char_to_string( &msg, 32 );
    add_timeval_to_string( &msg, &progress->estimated_time );
  }
  return msg.source;
}