⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 de_stdout.c

📁 minix软件源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    	case S_IFCHR :  printf( "character  " );		    	special = 1;		    	break;    	case S_IFBLK :  printf( "block  " );		   	special = 1;		    	break;    	case S_IFREG :  printf( "regular  " );		    	break;#ifdef S_IFIFO    	case S_IFIFO :  printf( "fifo  " );		    	break;#endif#ifdef S_IFLNK    	case S_IFLNK :  printf( "symlink  " );		    	break;#endif#ifdef S_IFSOCK    	case S_IFSOCK:  printf( "socket  " );		    	break;#endif    	default      :  printf( "unknown  " );    	}	for ( m = 11;  m >= 0;  --m )	  putchar( (inode->i_mode & (1<<m)) ? "xwrxwrxwrtgu"[m] : '-' );	if ( s->magic == SUPER_MAGIC )	  {	  /* V1 file system */	  Goto( INFO_COLUMN, INFO_LINE + 1 );	  printf( "user %s", user ? user->pw_name : "" );	  Goto( INFO_COLUMN, INFO_LINE + 2 );	  printf( "file size %lu", inode->i_size );	  Goto( INFO_COLUMN, INFO_LINE + 4 );	  printf( "m_time %s", ctime( &inode->i_mtime ) );	  Goto( INFO_COLUMN, INFO_LINE + 6 );	  printf( "links %d, group %s",		  inode->i_nlinks, grp ? grp->gr_name : "" );	  Draw_Zone_Numbers( s, inode, 0, 7 );	  }	else	  {	  /* V2 file system, even page. */	  Goto( INFO_COLUMN, INFO_LINE + 1 );	  printf( "links %d ", inode->i_nlinks);	  Goto( INFO_COLUMN, INFO_LINE + 2 );	  printf( "user %s", user ? user->pw_name : "" );	  Goto( INFO_COLUMN, INFO_LINE + 3 );	  printf( "group %s", grp ? grp->gr_name : "" );	  Goto( INFO_COLUMN, INFO_LINE + 4 );	  printf( "file size %lu", inode->i_size );	  Goto( INFO_COLUMN, INFO_LINE + 6 );	  printf( "a_time %s", ctime( &inode->i_atime ) );	  Goto( INFO_COLUMN, INFO_LINE + 8 );	  printf( "m_time %s", ctime( &inode->i_mtime ) );	  Goto( INFO_COLUMN, INFO_LINE + 10 );	  printf( "c_time %s", ctime( &inode->i_ctime ) );	  Draw_Zone_Numbers( s, inode, 0, 12 );	}      if ( special )	{	Goto( INFO_COLUMN, INFO_LINE + 7 );	dev = (dev_t) inode->i_zone[0];	printf( "major %d, minor %d", major(dev), minor(dev) );	}      }  else  /*  Print ASCII characters for each byte in page  */      {      char *p = &s->buffer[ s->offset & ~ PAGE_MASK ];      for ( i = 0;  i < 16;  ++i )        {        Goto( INFO_COLUMN, INFO_LINE + i );        Print_Ascii( *p++ );        Print_Ascii( *p++ );        }      if ( s->block >= s->first_data  &&  page == 0 )	{	unsigned magic  = ((s->buffer[1] & 0xff) << 8) | (s->buffer[0] & 0xff);	unsigned second = ((s->buffer[3] & 0xff) << 8) | (s->buffer[2] & 0xff);	/*  Is this block the start of an executable file?  */	if ( magic == (unsigned) A_OUT )	  {          Goto( INFO_COLUMN, INFO_LINE );	  printf( "executable" );          Goto( INFO_COLUMN, INFO_LINE + 1 );	  if ( second == (unsigned) SPLIT )	    printf( "separate I & D" );	  else	    printf( "combined I & D" );	  }	}      }  }/****************************************************************//*								*//*	Draw_Block( block )					*//*								*//*		Redraw a 1k block in character format.		*//*								*//****************************************************************/void Draw_Block( block )  char *block;  {  int line;  int column;  int reverse = 0;  int msb_flag = 0;  for ( line = 0;  line < 16;  ++line )    {    Goto( BLOCK_COLUMN, BLOCK_LINE + line );    for ( column = 0;  column < 64;  ++column )      {      char c = *block++;      if ( c & 0x80 )	{	msb_flag = 1;	c &= 0x7f;	}      if ( c >= ' '  &&  c < DEL )	{	if ( reverse )	  { fputs( Tnormal, stdout ); reverse = 0; }        putchar( c );	}      else	{	if ( ! reverse )	  { fputs( Treverse, stdout ); reverse = 1; }	putchar( c == DEL ? '?' : '@' + c );	}      }  /*  end for ( column )  */    }  /*  end for ( line )  */  if ( reverse )    { fputs( Tnormal, stdout ); reverse = 0; }  if ( msb_flag )    {    Goto( BLOCK_COLUMN + 68, BLOCK_LINE + 6 );    fputs( "(MSB)", stdout );    }  }/****************************************************************//*								*//*	Draw_Map( block, max_bits )				*//*								*//*		Redraw a block in a bit map format.		*//*		Display min( max_bits, 2048 ) bits.		*//*								*//*		The 256 bytes in "block" are displayed from	*//*		top to bottom and left to right. Bit 0 of	*//*		a byte is towards the top of the screen.	*//*								*//*		Special graphic codes are used to generate	*//*		two "bits" per character position. So a 16	*//*		line by 64 column display is 32 "bits" by	*//*		64 "bits". Or 4 bytes by 64 bytes.		*//*								*//****************************************************************/void Draw_Map( block, max_bits )  char *block;  int   max_bits;  {  int line;  int column;  int bit_count = 0;  for ( line = 0;  line < 16;  ++line )    {    char *p = &block[ (line & 0xC) >> 2 ];    int shift = (line & 0x3) << 1;    Goto( BLOCK_COLUMN, BLOCK_LINE + line );    for ( column = 0;  column < 64;  ++column, p += 4 )      {      char c = (*p >> shift) & 0x3;      int current_bit = ((p - block) << 3) + shift;      /*  Don't display bits past "max_bits"  */      if ( current_bit >= max_bits )	break;      /*  If "max_bits" occurs in between the two bits  */      /*  I am trying to display as one character, then	*/      /*  zero off the high-order bit.			*/      if ( current_bit + 1 == max_bits )	c &= 1;      switch ( c )	{	case 0 :  putchar( BOX_CLR );		  break;	case 1 :  putchar( BOX_TOP );		  ++bit_count;		  break;	case 2 :  putchar( BOX_BOT );		  ++bit_count;		  break;	case 3 :  putchar( BOX_ALL );		  bit_count += 2;		  break;	}      }  /*  end for ( column )  */    }  /*  end for ( line )  */  Goto( BLOCK_COLUMN + 68, BLOCK_LINE + 6 );  printf( "(%d)", bit_count );  }/****************************************************************//*								*//*	Draw_Pointers( state )					*//*								*//*		Redraw the pointers and the offset field.	*//*		The rest of the screen stays intact.		*//*								*//****************************************************************/void Draw_Pointers( s )  de_state *s;  {  Draw_Offset( s );  switch ( s->mode )    {    case WORD :   Word_Pointers( s->last_addr, s->address );		  break;    case BLOCK :  Block_Pointers( s->last_addr, s->address );		  break;    case MAP :	  Map_Pointers( s->last_addr, s->address );		  break;    }  Goto( PROMPT_COLUMN, PROMPT_LINE );  }/****************************************************************//*								*//*	Draw_Offset( state )					*//*								*//*		Display the offset in the current buffer	*//*		and the relative position if within a map	*//*		or i-node block.				*//*								*//****************************************************************/void Draw_Offset( s )  de_state *s;  {  Goto( STATUS_COLUMN, STATUS_LINE + 2 );  printf( "Offset = %5d           ", s->offset );  if ( s->block < 2 )    return;  if ( s->block < 2 + s->inode_maps )    {    long bit = (s->address - 2 * K) * 8;    if ( bit < s->inodes_in_map )	printf( "I-node %ld of %d     ", bit, s->inodes );    else	printf( "(padding)                " );    }  else if ( s->block < 2 + s->inode_maps + s->zone_maps )    {    long bit = (s->address - (2 + s->inode_maps) * K) * 8;    if ( bit < s->zones_in_map )	printf( "Block %ld of %u     ", bit + s->first_data - 1, s->zones );    else	printf( "(padding)                " );    }  else if ( s->block < s->first_data )    {    bit_t node = (s->address - (2 + s->inode_maps + s->zone_maps) * K) /		s->inode_size + 1;    if ( node <= s->inodes )	printf( "I-node %lu of %lu  (%sin use)       ",		(unsigned long) node, (unsigned long) s->inodes,		In_Use( node, s->inode_map ) ? "" : "not " );    else	printf( "(padding)                             " );    }  }/****************************************************************//*								*//*	Word_Pointers( old_addr, new_addr )			*//*								*//*	Block_Pointers( old_addr, new_addr )			*//*								*//*	Map_Pointers( old_addr, new_addr )			*//*								*//*		Redraw the index pointers for a each type	*//*		of display. The pointer at "old_addr" is	*//*		erased and a new pointer is positioned		*//*		for "new_addr". This makes the screen		*//*		update faster and more pleasant for the user.	*//*								*//****************************************************************/void Word_Pointers( old_addr, new_addr )  off_t old_addr;  off_t new_addr;  {  int from = ( (int) old_addr & PAGE_MASK ) >> 1;  int to   = ( (int) new_addr & PAGE_MASK ) >> 1;  Goto( BLOCK_COLUMN - 2, BLOCK_LINE + from );  putchar( ' ' );  Goto( BLOCK_COLUMN - 2, BLOCK_LINE + to );  putchar( '>' );  }void Block_Pointers( old_addr, new_addr )  off_t old_addr;  off_t new_addr;  {  int from = (int) old_addr & ~K_MASK;  int to   = (int) new_addr & ~K_MASK;  Goto( BLOCK_COLUMN - 2, BLOCK_LINE + from / 64 );  putchar( ' ' );  Goto( BLOCK_COLUMN - 2, BLOCK_LINE + to / 64 );  putchar( '>' );  Goto( BLOCK_COLUMN + from % 64, BLOCK_LINE + 17 );  putchar( ' ' );  Goto( BLOCK_COLUMN + to % 64, BLOCK_LINE + 17 );  putchar( '^' );  }void Map_Pointers( old_addr, new_addr )  off_t old_addr;  off_t new_addr;  {  int from = ( (int) old_addr & MAP_MASK ) >> 2;  int to   = ( (int) new_addr & MAP_MASK ) >> 2;  Goto( BLOCK_COLUMN + from, BLOCK_LINE + 17 );  putchar( ' ' );  Goto( BLOCK_COLUMN + to, BLOCK_LINE + 17 );  putchar( '^' );  }/****************************************************************//*								*//*	Print_Number( number, output_base )			*//*								*//*		Output "number" in the output base.		*//*								*//****************************************************************/void Print_Number( number, output_base )  word_t number;  int output_base;  {  switch ( output_base )    {    case 16 :	printf( "%5x", number );		break;    case 10 :	printf( "%7u", number );		break;    case 8 :	printf( "%7o", number );		break;    case 2 :	{      		unsigned int mask;      		char pad = ' ';      		for ( mask = 0x8000;  mask > 1;  mask >>= 1 )		  putchar( (mask & number) ? (pad = '0', '1') : pad );      		putchar( (0x01 & number) ? '1' : '0' );		break;      		}    default :	Error( "Internal fault (output_base)" );    }  }/****************************************************************//*								*//*	Print_Ascii( char )					*//*								*//*		Display a character in reverse mode if it	*//*		is not a normal printable ASCII character.	*//*								*//****************************************************************/void Print_Ascii( c )  char c;  {  c &= 0x7f;  if ( c < ' ' )    printf( "%s%c%s", Treverse, '@' + c, Tnormal );  else if ( c == DEL )    printf( "%s?%s", Treverse, Tnormal );  else    putchar( c );  }/****************************************************************//*								*//*	Warning( text, arg1, arg2 )				*//*								*//*		Display a message for 2 seconds.		*//*								*//****************************************************************/#if __STDC__void Warning( const char *text, ... )#elsevoid Warning( text )  char *text;#endif    {  va_list argp;    printf( "%c%s", BELL, Tclr_all );  Goto( WARNING_COLUMN, WARNING_LINE );  printf( "%s Warning: ", Treverse );  va_start( argp, text );  vprintf( text, argp );  va_end( argp );  printf( " %s", Tnormal );  fflush(stdout);		/* why does everyone forget this? */  sleep( 2 );  }void Draw_Zone_Numbers( s, inode, zindex, zrow )  de_state *s;  struct inode *inode;  int zindex;  int zrow;  {  static char *plurals[] = { "", "double ", "triple " };  zone_t zone;  for ( ; zrow < 16;	++zindex, zrow += s->zone_num_size / sizeof (word_t) )    {    Goto( INFO_COLUMN, INFO_LINE + zrow );    if ( zindex < s->ndzones )      printf( "zone %d", zindex );    else      printf( "%sindirect", plurals[ zindex - s->ndzones ] );    if ( s->magic != SUPER_MAGIC )      {      zone = inode->i_zone[ zindex ];      if ( zone != (word_t) zone )	{	Goto( INFO_COLUMN + 16, INFO_LINE + zrow );	printf("%ld", (long) zone );	}      }    }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -