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