?login_element?

Subversion Repositories NedoOS

Rev

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