Rev 7626 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6446 | GerdtR | 1 | #define SEEK_SET (0) |
2 | #define SEEK_CUR (1) |
||
3 | #define SEEK_END (2) |
||
4 | |||
5 | |||
6 | #define _PORT_CPP_ |
||
7 | #include "port.h" |
||
8 | |||
9 | |||
10 | long getfilelen(int fd) |
||
11 | { |
||
12 | long reslt,curr; |
||
13 | curr = lseek(fd,0,SEEK_CUR); |
||
14 | reslt = lseek(fd,0,SEEK_END); |
||
15 | lseek(fd,curr,SEEK_SET); |
||
16 | return reslt; |
||
17 | } |
||
18 | |||
19 | |||
20 | |||
21 | #ifndef _WIN32_ |
||
22 | |||
23 | char* strupr(char* s) |
||
24 | { |
||
25 | char* p = s; |
||
26 | while (*p = toupper(*p)) p++; |
||
27 | return s; |
||
28 | } |
||
29 | |||
30 | char* strlwr(char* s) |
||
31 | { |
||
32 | char* p = s; |
||
33 | while (*p = tolower(*p)) p++; |
||
34 | return s; |
||
35 | } |
||
36 | |||
37 | |||
38 | int strnicmp(const char* s1, const char* s2, int len) |
||
39 | { |
||
40 | unsigned char c1,c2; |
||
41 | |||
42 | if(!len) |
||
43 | return 0; |
||
44 | |||
45 | do{ |
||
46 | c1 = *s1++; |
||
47 | c2 = *s2++; |
||
48 | if (!c1||!c2) |
||
49 | break; |
||
50 | if (c1 == c2) |
||
51 | continue; |
||
52 | c1 = tolower(c1); |
||
53 | c2 = tolower(c2); |
||
54 | if (c1!=c2) |
||
55 | break; |
||
56 | } while (--len); |
||
57 | return (int)c1 - (int)c2; |
||
58 | } |
||
59 | |||
60 | int stricmp(const char* s1, const char* s2) |
||
61 | { |
||
62 | unsigned char c1,c2; |
||
63 | |||
64 | do{ |
||
65 | c1 = *s1++; |
||
66 | c2 = *s2++; |
||
67 | if (!c1||!c2) |
||
68 | break; |
||
69 | if (c1 == c2) |
||
70 | continue; |
||
71 | c1 = tolower(c1); |
||
72 | c2 = tolower(c2); |
||
73 | if (c1!=c2) |
||
74 | break; |
||
75 | } while (c1); |
||
76 | |||
77 | return (int)c1 - (int)c2; |
||
78 | } |
||
79 | |||
80 | bool OemToCharA(char* a, char* b) |
||
81 | { |
||
82 | *b = *a; |
||
83 | return true; |
||
84 | } |
||
85 | |||
86 | bool CharToOemA(char* a, char* b) |
||
87 | { |
||
88 | *b = *a; |
||
89 | return true; |
||
90 | } |
||
91 | |||
92 | //строка-результат не используется |
||
93 | int MultiByteToWideChar( |
||
94 | unsigned int CodePage, // code page |
||
95 | unsigned int dwFlags, // character-type options |
||
96 | char* lpMultiByteStr, // address of string to map |
||
97 | int cchMultiByte, // number of characters in string |
||
98 | wchar_t* lpWideCharStr, // address of wide-character buffer |
||
99 | int cchWideChar // size of buffer |
||
100 | ) |
||
101 | { |
||
7700 | leency | 102 | int i = 0; |
6446 | GerdtR | 103 | while ((lpMultiByteStr[i*2]!=0) && (lpMultiByteStr[i*2+1]!=0)) i++; |
104 | return i/2; |
||
105 | } |
||
106 | |||
107 | |||
108 | #ifdef _KOS_ |
||
109 | |||
110 | typedef struct _fs |
||
111 | { |
||
112 | int cmd; |
||
113 | int numL; |
||
114 | int numH; |
||
115 | int size; |
||
116 | void* pointer; |
||
117 | unsigned char nul; |
||
118 | char* path; |
||
119 | } fs; |
||
120 | |||
121 | int stat (const char* path, struct _stat* buf) |
||
122 | { |
||
123 | //fs fstruc; |
||
124 | char buff[40]; |
||
125 | int __ret; |
||
126 | char pathin[256]; |
||
127 | int i; |
||
128 | char fstruc[25]; |
||
129 | |||
130 | for(i=0; i<256; i++){ |
||
131 | pathin[i]=path[i]; |
||
132 | if (pathin[i]==0) break; |
||
133 | } |
||
134 | pathin[255]=0; |
||
135 | |||
136 | *((int*)(fstruc+0)) = 5; |
||
137 | *((int*)(fstruc+4)) = 0; |
||
138 | *((int*)(fstruc+8)) = 0; |
||
139 | *((int*)(fstruc+12)) = 0; |
||
140 | *((char**)(fstruc+16)) = buff; |
||
141 | *((char*)(fstruc+20)) = 0; |
||
142 | *((char**)(fstruc+21)) = pathin; |
||
143 | __asm__ __volatile__("int $0x40":"=a"(__ret):"a"(70),"b"(&fstruc)); |
||
144 | |||
145 | return __ret; |
||
146 | } |
||
147 | |||
148 | char * getcwd (char *buffer, int size) |
||
149 | { |
||
7700 | leency | 150 | int len=0; |
6446 | GerdtR | 151 | if (size==0){ |
152 | if (buffer!=0) |
||
153 | return 0; |
||
154 | size = 256; |
||
155 | } |
||
156 | |||
157 | if (buffer==0) |
||
158 | buffer = (char*)malloc(size); |
||
159 | |||
160 | __asm__ __volatile__("int $0x40":"=a"(len):"a"(30),"b"(2),"c"(buffer),"d"(size)); |
||
161 | if (len!=0) |
||
162 | return buffer; |
||
163 | else |
||
164 | return 0; |
||
165 | } |
||
166 | |||
167 | void exit(int a){ |
||
168 | __asm__ __volatile__("int $0x40"::"a"(-1)); |
||
169 | } |
||
170 | |||
171 | #endif //_KOS_ |
||
172 | |||
173 | #endif //not _WIN32_256;> |
||
174 |