Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. /*
  3.  * Backy_lib.h
  4.  * Author: JohnXenox aka Aleksandr Igorevich.
  5.  */
  6.  
  7. #ifndef __Backy_lib_h__
  8. #define __Backy_lib_h__
  9. /*
  10. typedef  unsigned int        uint32_t;
  11. typedef  unsigned char       uint8_t;
  12. typedef  unsigned short int  uint16_t;
  13. typedef  unsigned long long  uint64_t;
  14. typedef  char                int8_t;
  15. typedef  short int           int16_t;
  16. typedef  int                 int32_t;
  17. typedef  long long           int64_t;
  18. */
  19. static inline uint32_t getDate(void)
  20. {
  21.     uint32_t date;
  22.     __asm__ __volatile__("int $0x40":"=a"(date):"a"(29));
  23.     return date;
  24. }
  25.  
  26.  
  27.  
  28. static inline uint32_t getTime(void)
  29. {
  30.     uint32_t time;
  31.     __asm__ __volatile__("int $0x40":"=a"(time):"a"(3));
  32.     return time;
  33. }
  34.  
  35.  
  36.  
  37. static inline void *openFile(uint32_t *length, const uint8_t *path)
  38. {
  39.     uint8_t *fd;
  40.  
  41.     __asm__ __volatile__ ("int $0x40":"=a"(fd), "=d"(*length):"a" (68), "b"(27),"c"(path));
  42.  
  43.     return fd;
  44. }
  45.  
  46. // FILE SAVING NOT WORKING
  47. /*
  48. struct saveFile__
  49. {
  50.     int num;
  51.     int res_;
  52.     int res;
  53.     int nbyte;
  54.  
  55.     char* data_;
  56.     int enc_;
  57.     char* path_;
  58. };
  59. */
  60. static inline int32_t saveFile(uint32_t nbytes, uint8_t *data, uint32_t enc, uint8_t  *path)
  61. {
  62.     int32_t val;
  63. /*
  64.     struct saveFile__ dt;
  65.     //uint8_t dt[28];  // basic information structure.
  66.    
  67.     dt.num = 2;       // subfunction number.
  68.     dt.res_= 0;       // reserved.
  69.     dt.res = 0;       // reserved.
  70.     dt.nbyte = nbytes;  // number of bytes to write.
  71.     dt.data_ = data;    // pointer to data.
  72.     dt.enc_ = enc;     // string encoding (0 = default, 1 = cp866, 2 = UTF-16LE, 3 = UTF-8).
  73.     dt.path_ = path;    // pointer to path.
  74.  
  75.     __asm__ __volatile__("int $0x40":"=a"(val):"a"(80), "b"(&dt));
  76. */
  77.     return val;
  78. }
  79.  
  80. int checkStateOnSave(int state)
  81. {
  82.     #if defined (lang_en)
  83.  
  84.         switch(state)
  85.         {
  86.             case 2:  con_printf("\nThe function isn't supported for the given file system!\n");
  87.                      return 2;
  88.  
  89.             case 3:  con_printf("\nUnknown file system!\n");
  90.                      return 3;
  91.  
  92.             case 5:  con_printf("\nFile isn't found!\n");
  93.                      return 5;
  94.  
  95.             case 6:  con_printf("\nEnd of a file, EOF!\n");
  96.                      return 6;
  97.  
  98.             case 7:  con_printf("\nPointer lies outside of application memory!\n");
  99.                      return 7;
  100.  
  101.             case 8:  con_printf("\nDisk is full!\n");
  102.                      return 8;
  103.  
  104.             case 9:  con_printf("\nFile system error!\n");
  105.                      return 9;
  106.  
  107.             case 10: con_printf("\nAccess denied!\n");
  108.                      return 10;
  109.  
  110.             case 11: con_printf("\nDevice error!\n");
  111.                      return 11;
  112.  
  113.             case 12: con_printf("\nFile system requires more memory!\n");
  114.                      return 12;
  115.         }
  116.  
  117.     #elif defined (lang_ru)
  118.  
  119.         switch(state)
  120.         {
  121.             case 2:  con_printf("\n”ã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë!\n");
  122.                      return 2;
  123.  
  124.             case 3:  con_printf("\n¥¨§¢¥áâ­ ï ä ©«®¢ ï á¨á⥬ !\n");
  125.                      return 3;
  126.  
  127.             case 5:  con_printf("\n” ©« ­¥ ­ ©¤¥­!\n");
  128.                      return 5;
  129.  
  130.             case 6:  con_printf("\n” ©« § ª®­ç¨«áï!\n");
  131.                      return 6;
  132.  
  133.             case 7:  con_printf("\n“ª § â¥«ì ¢­¥ ¯ ¬ï⨠¯à¨«®¦¥­¨ï!\n");
  134.                      return 7;
  135.  
  136.             case 8:  con_printf("\n„¨áª § ¯®«­¥­!\n");
  137.                      return 8;
  138.  
  139.             case 9:  con_printf("\nŽè¨¡ª  ä ©«®¢®© á¨á⥬ë!\n");
  140.                      return 9;
  141.  
  142.             case 10: con_printf("\n„®áâ㯠§ ¯à¥éñ­!\n");
  143.                      return 10;
  144.  
  145.             case 11: con_printf("\nŽè¨¡ª  ãáâனá⢠!\n");
  146.                      return 11;
  147.  
  148.             case 12: con_printf("\n” ©«®¢®© á¨á⥬¥ ­¥¤®áâ â®ç­® ®¯¥à â¨¢­®© ¯ ¬ïâ¨!\n");
  149.                      return 12;
  150.         }
  151.  
  152.     #endif
  153. }
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161. #endif
  162.