]> icculus.org git repositories - taylor/freespace2.git/blob - src/platform/unix.cpp
added a few files that needed to be compiled
[taylor/freespace2.git] / src / platform / unix.cpp
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <ctype.h>
5 #include <errno.h>
6
7 #include "unix.h"
8
9 void strlwr (char * str)
10 {
11         while (*str) {*str = tolower (*str); str++; }
12 }
13
14 int filelength (int fd)
15 {
16         FILE *f = fdopen (dup(fd), "r");
17         fseek (f, 0, SEEK_END);
18         int len = ftell (f);
19         fclose (f);
20         return len;
21 }
22
23 void Sleep (int mili)
24 {
25         usleep (mili * 1000);
26 }
27
28 void OutputDebugString (const char *str)
29 {
30         fprintf(stderr, "OutputDebugString: %s\n", str);
31 }
32
33 int WSAGetLastError()
34 {
35         return errno;
36 }
37
38 int MulDiv(int a, int b, int c)
39 {
40         /* slow long long version */
41         __extension__ long long aa = a;
42         __extension__ long long bb = b;
43         __extension__ long long cc = c;
44         
45         __extension__ long long dd = aa * bb;
46         __extension__ long long ee = dd / cc;
47         
48         int retr = (int) ee;
49         
50         return retr;
51 }