Subversion Repositories Kolibri OS

Rev

Rev 6826 | Rev 8827 | 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.  
  5. kol_struct70    k70;
  6. kol_struct_BDVK bdvk;
  7. unsigned        result, i;
  8. unsigned long long filesize, pos;
  9. char            buf[81]; //¡ãä¥à
  10. char            temp[FILENAME_MAX];
  11. unsigned        flags;
  12.  
  13. if (strlen(file)<1)
  14.         {
  15.         #if LANG_ENG
  16.                 printf ("  more <filename>\n\r");
  17.         #elif LANG_RUS
  18.                 printf ("  more <¨¬ï ä ©« >\n\r");
  19.         #endif
  20.         return TRUE;
  21.         }
  22.  
  23. if ( '/' == file[0])
  24.         {
  25.         strcpy(temp, file);
  26.  
  27.         if ( !file_check(temp) )
  28.                 {
  29.                 file_not_found(file);
  30.                 return FALSE;
  31.                 }
  32.         }
  33. else
  34.         {
  35.         strcpy(temp, cur_dir);
  36.         if (temp[strlen(temp)-1] != '/')
  37.                 strcat(temp, "/"); // add slash
  38.         strcat(temp, file);
  39.        
  40.         if ( !file_check(temp) )
  41.                 {
  42.                 file_not_found(file);
  43.                 return FALSE;
  44.                 }
  45.         }
  46.  
  47. k70.p00 = 5;
  48. k70.p04 = k70.p12 = 0;
  49. //k70.p08 = 0;
  50. k70.p16 = (unsigned) &bdvk;
  51. k70.p20 = 0;
  52. k70.p21 = temp;
  53.  
  54. result = kol_file_70(&k70); // ¯®«ãç ¥¬ ¨­ä®à¬ æ¨î ® ä ©«¥
  55. if ( 0 != result )
  56.         return FALSE;
  57.  
  58. filesize = bdvk.p32; // ¯®«ãç ¥¬ à §¬¥à ä ©« 
  59.  
  60. buf[80]=0;
  61. flags = con_get_flags();
  62.  
  63. for (pos=0;pos<filesize;pos+=80)
  64.         {
  65.  
  66.         memset(buf, 0, 80);
  67.  
  68.         k70.p00 = 0;
  69.         k70.p04 = pos;
  70. //      k70.p08 = 0;   // bug for over 4Gb files, but "more" is unusable there
  71.         k70.p12 = 80;
  72.         k70.p16 = (unsigned) buf;
  73.         k70.p20 = 0;
  74.         k70.p21 = temp;
  75.  
  76.         result = kol_file_70(&k70); // ç⥭¨¥ 80 ᨬ¢®«®¢
  77.         for (i=0; i<80; i++)
  78.                 {
  79.  
  80.                 if (27 == buf[i])
  81.                         con_set_flags(flags|0x100);
  82.                 else con_set_flags(flags);
  83.  
  84.                 printf ("%c", buf[i]);
  85.                 }
  86.         if ( 0 != result )
  87.                 {
  88.                 con_set_flags(flags);
  89.                 printf ("\n\r");
  90.                 return TRUE;   
  91.                 }
  92.  
  93.         }
  94. con_set_flags(flags);
  95. printf ("\n\r");
  96. return TRUE;
  97. }
  98.  
  99.