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