Subversion Repositories Kolibri OS

Rev

Rev 6857 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. int cmd_more(char file[]) {
  3.  
  4.         kol_struct70    k70;
  5.         kol_struct_BDVK bdvk;
  6.         unsigned        result, i;
  7.         unsigned long long filesize, pos;
  8.         char            buf[81]; //����
  9.         char            temp[FILENAME_MAX];
  10.         unsigned        flags;
  11.  
  12.         if (strlen(file)<1) {
  13.                 printf (CMD_MORE_USAGE);
  14.                 return TRUE;
  15.         }
  16.  
  17.         if ( '/' == file[0])
  18.                 {
  19.                 strcpy(temp, file);
  20.  
  21.                 if ( !file_check(temp) )
  22.                         {
  23.                         file_not_found(file);
  24.                         return FALSE;
  25.                         }
  26.                 }
  27.         else
  28.                 {
  29.                 strcpy(temp, cur_dir);
  30.                 if (temp[strlen(temp)-1] != '/')
  31.                         strcat(temp, "/"); // add slash
  32.                 strcat(temp, file);
  33.                
  34.                 if ( !file_check(temp) )
  35.                         {
  36.                         file_not_found(file);
  37.                         return FALSE;
  38.                         }
  39.                 }
  40.  
  41.         k70.p00 = 5;
  42.         k70.p04 = k70.p12 = 0;
  43.         //k70.p08 = 0;
  44.         k70.p16 = (unsigned) &bdvk;
  45.         k70.p20 = 0;
  46.         k70.p21 = temp;
  47.  
  48.         result = kol_file_70(&k70); // ����砥� ���ଠ�� � 䠩��
  49.         if ( 0 != result )
  50.                 return FALSE;
  51.  
  52.         filesize = bdvk.p32; // ����砥� ࠧ��� 䠩��
  53.  
  54.         buf[80]=0;
  55.         flags = con_get_flags();
  56.  
  57.         for (pos=0;pos<filesize;pos+=80)
  58.                 {
  59.  
  60.                 memset(buf, 0, 80);
  61.  
  62.                 k70.p00 = 0;
  63.                 k70.p04 = pos;
  64.         //      k70.p08 = 0;   // bug for over 4Gb files, but "more" is unusable there
  65.                 k70.p12 = 80;
  66.                 k70.p16 = (unsigned) buf;
  67.                 k70.p20 = 0;
  68.                 k70.p21 = temp;
  69.  
  70.                 result = kol_file_70(&k70); // �⥭�� 80 ᨬ�����
  71.                 for (i=0; i<80; i++)
  72.                         {
  73.  
  74.                         if (27 == buf[i])
  75.                                 con_set_flags(flags|0x100);
  76.                         else con_set_flags(flags);
  77.  
  78.                         printf ("%c", buf[i]);
  79.                         }
  80.                 if ( 0 != result )
  81.                         {
  82.                         con_set_flags(flags);
  83.                         printf ("\n\r");
  84.                         return TRUE;   
  85.                         }
  86.  
  87.                 }
  88.         con_set_flags(flags);
  89.         printf ("\n\r");
  90.         return TRUE;
  91. }
  92.  
  93.