Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2.  
  3. #ifndef kolibc_h
  4. #define kolibc_h
  5.  
  6. #ifdef __cplusplus
  7. extern "C"
  8. {
  9. #endif
  10.  
  11. typedef unsigned char byte;
  12. typedef unsigned short int word;
  13. typedef unsigned int dword;
  14.  
  15. typedef unsigned int fpos_t;
  16. typedef unsigned int size_t;
  17.  
  18. #define NULL (void*)0
  19.  
  20. typedef enum SEEKPOS {SEEK_SET=0,SEEK_CUR,SEEK_END};
  21.  
  22. #define FILE_OPEN_READ    0x01
  23. #define FILE_OPEN_WRITE   0x02
  24. #define FILE_OPEN_APPEND  0x04
  25. #define FILE_OPEN_TEXT    0x08
  26. #define FILE_OPEN_PLUS    0x10
  27. #define EOF -1
  28.  
  29. typedef struct
  30. {
  31.   char   *buffer;
  32.   char   *stream;
  33.   size_t    strpos;
  34.   size_t    remain;
  35.  
  36.   size_t filepos;
  37.  
  38.   size_t buffersize;
  39.   size_t filesize;
  40.   char*  filename;
  41.   int    mode;
  42. } FILE;
  43.  
  44. extern FILE* fopen(const char* filename, const char *mode);
  45. extern int fclose(FILE* file);
  46. extern int feof(FILE* file);
  47. extern int fflush(FILE* file);
  48. extern int fgetc(FILE* file);
  49. extern int fgetpos(FILE* file,fpos_t* pos);
  50. extern int fsetpos(FILE* file,const fpos_t* pos);
  51. extern int fputc(int c,FILE* file);
  52. extern int fread(void* buffer,size_t size,size_t count,FILE* file);
  53. extern int fwrite(const void* buffer,size_t size,size_t count,FILE* file);
  54. extern long ftell(FILE* file);
  55. extern int fseek(FILE* file,long offset,int origin);
  56. extern void rewind(FILE* file);
  57. extern int fprintf(FILE* file, const char* format, ...);
  58. extern int fscanf(FILE* file,const char* format, ...);
  59. extern int ungetc(int c,FILE* file);
  60.  
  61. extern int sprintf(char *dest, const char *format,...);
  62. extern int printf(const char *format,...);
  63.  
  64. typedef char *va_list;
  65. #define _roundsize(n)    ( (sizeof(n) + 3) & ~3 )
  66. #define va_start(ap,v) (ap = (va_list)&v+_roundsize(v))
  67. #define va_arg(ap,t)    ( *(t *)((ap += _roundsize(t)) - _roundsize(t)) )
  68. #define va_end(ap) (ap = (va_list)0)
  69.  
  70. /*
  71. ** All character classification functions except isascii().
  72. ** Integer argument (c) must be in ASCII range (0-127) for
  73. ** dependable answers.
  74. */
  75.  
  76. #define ALNUM     1
  77. #define ALPHA     2
  78. #define CNTRL     4
  79. #define DIGIT     8
  80. #define GRAPH    16
  81. #define LOWER    32
  82. #define PRINT    64
  83. #define PUNCT   128
  84. #define BLANK   256
  85. #define UPPER   512
  86. #define XDIGIT 1024
  87.  
  88. extern short int _is[128];
  89.  
  90. #define isalnum(c)(_is[c] & ALNUM ) /* 'a'-'z', 'A'-'Z', '0'-'9' */
  91. #define isalpha(c)(_is[c] & ALPHA ) /* 'a'-'z', 'A'-'Z' */
  92. #define iscntrl(c)(_is[c] & CNTRL ) /* 0-31, 127 */
  93. #define isdigit(c)(_is[c] & DIGIT ) /* '0'-'9' */
  94. #define isgraph(c)(_is[c] & GRAPH ) /* '!'-'~' */
  95. #define islower(c)(_is[c] & LOWER ) /* 'a'-'z' */
  96. #define isprint(c)(_is[c] & PRINT ) /* ' '-'~' */
  97. #define ispunct(c)(_is[c] & PUNCT ) /* !alnum && !cntrl && !space */
  98. #define isspace(c)(_is[c] & BLANK ) /* HT, LF, VT, FF, CR, ' ' */
  99. #define isupper(c)(_is[c] & UPPER ) /* 'A'-'Z' */
  100. #define isxdigit(c)(_is[c] & XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */
  101.  
  102.  
  103. #define _LOWER  0x80
  104. #define _UPPER  0x40
  105. #define _DIGIT  0x20
  106. #define _XDIGT  0x10
  107. #define _PRINT  0x08
  108. #define _PUNCT  0x04
  109. #define _SPACE  0x02
  110. #define _CNTRL  0x01
  111.  
  112. #define abs(i) (((i)<0)?(-(i)):(i))
  113.  
  114. extern int atoib(char *s,int b);
  115. extern int atoi(char *s);
  116. extern char tolower(char c);
  117. extern char toupper(char c);
  118. extern void itoab(int n,char* s,int  b);
  119. extern void itoa(int n,char* s);
  120.  
  121. extern char* strcat(char*,const char*);
  122. extern char* strchr(const char*,int);
  123. extern int strcmp(const char*,const char*);
  124. extern int strcoll(const char*,const char*);
  125. extern char* strcpy(char*,const char*);
  126. extern int strcspn(const char*,const char*);
  127. extern size_t strlen(const char*);
  128. extern char* strncat(char*,const char*,int);
  129. extern int strncmp(const char*,const char*,int);
  130. extern char* strncpy(char*,const char*,int);
  131. extern char* strpbrk(const char*,const char*);
  132. extern char* strrchr(const char*,int);
  133. extern int strspn(const char*,const char*);
  134. extern char* strstr(const char*,const char*);
  135. extern char* strtok(char*,const char*);
  136. extern int strxfrm(char*,const char*,int);
  137. extern char* strdup(const char*);
  138. extern char toupper(char c);
  139. #define isascii(char)   ( (unsigned)char < 0x80 )
  140.  
  141. extern void* memchr(const void*,int,int);
  142. extern int memcmp(const void*,const void*,int);
  143. extern void* memcpy(void*,const void*,int);
  144. extern void* memmove(void*,const void*,int);
  145. extern void* memset(void*,int,int);
  146.  
  147. extern void *malloc(size_t size);
  148. extern void* realloc(void* oldmem, size_t bytes);
  149. extern void free(void *mem);
  150.  
  151.  
  152. #ifdef __cplusplus
  153. extern "C"
  154. }
  155. #endif
  156.  
  157. #endif  //kolibc_h