Example #1
0
int		my_printf(char *format, ...)
{
  va_list	ap;
  unsigned int	i;
  unsigned int	width;

  va_start(ap, format);
  i = 0;
  width = 0;
  while (format[i] != '\0')
    {
      if (format[i] != '%')
	my_putchar(format[i]);
      else
	{
	  i = i + 1;
	  while (format[i] == ' ')
	    i = i + 1;
	  if (format[i] >= '0' && format[i] <= '9')
	    {
	      width = find_width(format, i);
	      i = i + my_nbrlen(width);
	    }
	  if (format[i] == '%')
	    my_putchar(format[i]);
	  else
	      find_fmt(ap, format, i, width);
	}
      i = i + 1;
    }
  va_end(ap);
  return (0);
}
Example #2
0
unsigned Cluster::get_width(){
	if(width == 0){
		if(DEBUG)
			std::cout<<"I am starting to caluclate the width"
				<<std::endl;
		find_width();
	}
	return width;
}
Example #3
0
void show_data( WINDOW *win, const Hubyte *data, int len )
{
    int i;
    int line;
    int space;
    int width;
    int waste;

    werase( win );
    wmove( win, 1, 1 );

    wattron( win, A_BOLD );
    wprintw( win, "Packet Data\n" );
    wattroff( win, A_BOLD );

    wmove( win, 2, 1 );
    whline( win, 0, 5000 );

    width = find_width( COLS - 2, 9 );
    waste = (COLS - 2) - width*9;
    waste /= 2;
    waste += 1;
    
    width *= 4;
    if( data != NULL && len > 0 )
    {
        line = 3;
        space = 0;
        for( i = 0; i < len; i++ )
        {
            if( i % width == 0 )
            {
                wmove( win, line++, waste );
                space = 0;
            }
            
            if( space == 4 )
            {
                wprintw( win, " " );
                space = 0;
            }

            space++;
            wprintw( win, "%2.2x", data[i] );
        }
        wprintw( win, "\n" );
    }
}