Subversion Repositories NedoOS

Rev

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

  1. //#ifdef __BORLANDC__
  2. //typedef unsigned long intptr_t;
  3. //#else
  4. //#include <stdint.h>
  5. //#endif
  6.  
  7. #define BIGMEM
  8.  
  9. #define TRUE 0xff
  10. #define FALSE 0x00
  11. #define CONST const
  12. #define CHAR char
  13. #define BYTE unsigned char
  14. #ifdef TARGET_THUMB
  15. #define INT int
  16. #else
  17. #define INT short int
  18. #endif
  19. #define UINT unsigned INT
  20. #ifdef TARGET_THUMB
  21. #define LONG unsigned long
  22. #else
  23. #define LONG unsigned int
  24. #endif
  25. //#define FLOAT double
  26. #define BOOL unsigned char
  27. #define PBYTE BYTE*
  28. #define PCHAR CHAR*
  29. #define PBOOL BOOL*
  30. #define PINT INT*
  31. #define PUINT UINT*
  32. #define PLONG LONG*
  33. //#define PFLOAT FLOAT*
  34. //#define POINTER intptr_t
  35. //#define PPROC void*
  36. //#define PPOI void**
  37. #define EXTERN extern
  38. #define FORWARD /**/
  39. #define FUNC /**/
  40. #define PROC void
  41. #define BREAK break
  42. #define RETURN return
  43. #define VAR /**/
  44. #define RECURSIVE /**/
  45. #define POKE /**/
  46. #define IF(x) if(x)
  47. //#define IFNOT(x) if(!(x))
  48. //#define IFZ(x) if(!(x))
  49. //#define IFNZ(x) if(x)
  50. #define ELSE else
  51. #define WHILE(x) while(x)
  52. //#define WHILENOT(x) while(!(x))
  53. //#define WHILEZ(x) while(!(x))
  54. //#define WHILENZ(x) while(x)
  55. #define REPEAT do
  56. #define UNTIL(x) while(!(x));
  57. //#define UNTILNOT(x) while(x);
  58. //#define UNTILZ(x) while(x);
  59. //#define UNTILNZ(x) while(!(x));
  60. #define ENUM enum
  61. #define INC ++
  62. #define DEC --
  63. #define CALL(x) ((void(*)(void))(x))() /**хёыш яЁюёЄю x, Єю эхы№ч  т√Ёрцхэшх*/
  64. #define STRUCT struct
  65. #define TYPEDEF struct
  66. #define EXPORT /**/
  67.  
  68. #include "../_sdk/str.h"
  69.  
  70. VAR PBYTE _fin;
  71. VAR PBYTE _fout;
  72. VAR BOOL _waseof;
  73. //CONST UINT _STRLEN; /**тъы■ўр  0*/
  74. //CONST UINT _STRMAX; /**эх тъы■ўр  0*/
  75.  
  76. FUNC BYTE readfin()
  77. {
  78. VAR BYTE c;
  79.   //rd(handle, &c, 1);
  80.   IF (+(UINT)fread(/*+*/(PBYTE)&c, +sizeof(BYTE), 1, (FILE*)_fin) == 0) {
  81.     _waseof = +TRUE;
  82.     c = '\n'; //EOF returns '\n'
  83.   };
  84.   RETURN c;
  85. }
  86.  
  87. FUNC BYTE readf(PBYTE file)
  88. {
  89. VAR BYTE c;
  90.   //rd(handle, &c, 1);
  91.   IF (+(UINT)fread(/*+*/(PBYTE)&c, +sizeof(BYTE), 1, (FILE*)file) == 0) {
  92.     _waseof = +TRUE;
  93.     c = '\n'; //EOF returns '\n'
  94.   };
  95.   RETURN c;
  96. }
  97.  
  98. PROC writefout(BYTE c)
  99. {
  100.   //writebyte(_fout, token);
  101.   fwrite(/*+*/(PBYTE)&c, +sizeof(BYTE), 1, (FILE*)_fout);
  102. }
  103.  
  104. FUNC PBYTE nfopen(PCHAR s, PCHAR mode)
  105. {
  106. /**UINT i;
  107. CHAR __fn[256];
  108.   i = 0;
  109.   WHILE (s[i] != '\0') {
  110.     IF (s[i] == '/') {
  111.       __fn[i] = '\\';
  112.     }ELSE {
  113.       __fn[i] = s[i];
  114.     };
  115.     INC i;
  116.   };
  117.   __fn[i] = '\0';*/
  118.   RETURN (PBYTE)fopen(s/**__fn*/, mode);
  119. }
  120.  
  121. FUNC PBYTE openwrite(PCHAR s)
  122. {
  123.   RETURN nfopen(s, "wb");
  124. }
  125.  
  126. PROC closewrite(PBYTE file)
  127. {
  128.   fclose((FILE*)file);
  129. }
  130.  
  131. PROC writebyte(PBYTE file, BYTE c)
  132. {
  133.   //fprintf(file,"%c",c);
  134.   fwrite(/*+*/(PBYTE)&c, +sizeof(BYTE), 1, (FILE*)file);
  135. }
  136.  
  137. #include "../_sdk/str.c"
  138.  
  139. FUNC UINT readfinstr(PBYTE pstr)
  140. {
  141. VAR UINT len;
  142. VAR BYTE c;
  143.   len = 0;
  144. readfinstr0:
  145.   c = readfin(); //EOF фр╕Є '\n'
  146.   IF (c==0x0d) goto readfinstr0; //skip 0x0d
  147.   IF (c==+(BYTE)'\n') goto readfinstrq; //EOL or EOF
  148.   POKE *(PBYTE)pstr = c;
  149.   INC pstr;
  150.   INC len;
  151.   IF (len<_STRMAX) goto readfinstr0;
  152. readfinstrq:
  153.   POKE *(PBYTE)pstr = 0x00;
  154.   INC len;
  155.   RETURN len;
  156. };
  157.