]> icculus.org git repositories - taylor/freespace2.git/blob - src/platform/unix.cpp
Filesystem mods, actually reads some data files now
[taylor/freespace2.git] / src / platform / unix.cpp
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <stdarg.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <ctype.h>
7 #include <errno.h>
8
9 #include "unix.h"
10
11 #define MAX_LINE_WIDTH 128
12
13 void strlwr (char * str)
14 {
15         while (*str) {*str = tolower (*str); str++; }
16 }
17
18 int filelength (int fd)
19 {
20         FILE *f = fdopen (dup(fd), "r");
21         fseek (f, 0, SEEK_END);
22         int len = ftell (f);
23         fclose (f);
24         return len;
25 }
26
27 unsigned long _beginthread (void (*pfuncStart)(void *), unsigned unStackSize, void* pArgList)
28 {
29         STUB_FUNCTION;
30         
31         return 0;
32 }
33
34 void Sleep (int mili)
35 {
36         usleep (mili * 1000);
37 }
38
39 void OutputDebugString (const char *str)
40 {
41         fprintf(stderr, "OutputDebugString: %s\n", str);
42 }
43
44 int WSAGetLastError()
45 {
46         return errno;
47 }
48
49 int MulDiv(int a, int b, int c)
50 {
51         /* slow long long version */
52         __extension__ long long aa = a;
53         __extension__ long long bb = b;
54         __extension__ long long cc = c;
55         
56         __extension__ long long dd = aa * bb;
57         __extension__ long long ee = dd / cc;
58         
59         int retr = (int) ee;
60         
61         return retr;
62 }
63
64 /* mem debug junk */
65 int TotalRam = 0;
66
67 void vm_free(void* ptr, char*, int)
68 {
69         free(ptr);
70 }
71
72 void *vm_malloc(int size, char*, int)
73 {
74         return malloc(size);
75 }
76
77 char *vm_strdup(char const* str, char*, int)
78 {
79         return strdup(str);
80 }
81
82 void windebug_memwatch_init()
83 {
84         TotalRam = 0;
85 }
86
87 /* error message debugging junk */
88 int Log_debug_output_to_file = 0;
89
90 void load_filter_info(void)
91 {
92         STUB_FUNCTION;
93 }
94
95 void outwnd_printf(char* id, char* format, ...)
96 {
97         char tmp[MAX_LINE_WIDTH*4];
98         va_list args;
99
100         va_start (args, format);
101         vsprintf (tmp, format, args);
102         va_end(args);
103         fprintf (stderr, "%s: %s", id, tmp);
104         if (!strcmp ("Error", id)) exit (1);
105 }
106
107 void outwnd_printf2(char* format, ...)
108 {
109         char tmp[MAX_LINE_WIDTH*4];
110         va_list args;
111
112         va_start (args, format);
113         vsprintf (tmp, format, args);
114         va_end(args);
115         fprintf (stderr, "General: %s", tmp);
116 }
117
118 void outwnd_close()
119 {
120         STUB_FUNCTION;
121 }
122
123 void Warning( char * filename, int line, char * format, ... )
124 {
125         STUB_FUNCTION;
126 }
127
128 void Error( char * filename, int line, char * format, ... )
129 {
130         STUB_FUNCTION;
131 }
132
133 void WinAssert(char * text,char *filename, int line)
134 {
135         STUB_FUNCTION;
136 }