summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2004-10-21 03:18:23 +0000
committerjsorg71 <jsorg71>2004-10-21 03:18:23 +0000
commitb4b62a619a2a7c52c1975580272646c7ae2111e6 (patch)
tree49a79553d3b295e46c5e20ff88f072d86763be77
parent330a4ffb9877563a8a95b773cc62f2cb8263723b (diff)
downloadxrdp-proprietary-b4b62a619a2a7c52c1975580272646c7ae2111e6.tar.gz
xrdp-proprietary-b4b62a619a2a7c52c1975580272646c7ae2111e6.zip
win32 compile changes
-rw-r--r--xrdp/makefile_win3228
-rw-r--r--xrdp/os_calls.c126
-rw-r--r--xrdp/xrdp.c3
-rw-r--r--xrdp/xrdp.h10
-rw-r--r--xrdp/xrdp_bitmap.c3
-rw-r--r--xrdp/xrdp_listen.c2
-rw-r--r--xrdp/xrdp_orders.c2
-rw-r--r--xrdp/xrdp_painter.c132
-rw-r--r--xrdp/xrdp_types.h1
-rw-r--r--xrdp/xrdp_wm.c2
10 files changed, 227 insertions, 82 deletions
diff --git a/xrdp/makefile_win32 b/xrdp/makefile_win32
new file mode 100644
index 00000000..37a76bdf
--- /dev/null
+++ b/xrdp/makefile_win32
@@ -0,0 +1,28 @@
+# borland windows makefile
+#
+# this assumes openssl and borland free command line tools are installed
+# this assumes c:\windows is windows directory
+#
+# run 'set PATH=c:\borland\bcc55\bin' and run 'make all'
+#
+
+XRDPOBJ = xrdp.obj os_calls.obj xrdp_tcp.obj xrdp_iso.obj xrdp_mcs.obj \
+ xrdp_sec.obj xrdp_rdp.obj xrdp_process.obj xrdp_listen.obj \
+ xrdp_orders.obj xrdp_bitmap.obj xrdp_wm.obj xrdp_painter.obj \
+ xrdp_list.obj xrdp_region.obj xrdp_cache.obj xrdp_font.obj \
+ funcs.obj
+
+CFLAGS = -w- -O2 -Ic:\borland\bcc55\include -Ic:\openssl\include
+LDFLAGS = -Lc:\borland\bcc55\lib
+
+xrdp: $(XRDPOBJ)
+ $(CC) $(LDFLAGS) libeay32.lib $(XRDPOBJ)
+
+all: lib xrdp
+
+clean:
+ del *.obj *.o xrdp.exe
+
+lib:
+ implib -a -w libeay32.lib c:\windows\system32\libeay32.dll
+
diff --git a/xrdp/os_calls.c b/xrdp/os_calls.c
index 0bb78e38..a9663a00 100644
--- a/xrdp/os_calls.c
+++ b/xrdp/os_calls.c
@@ -20,40 +20,53 @@
*/
-#include <stdlib.h>
-#include <string.h>
+#ifdef _WIN32
+#include <windows.h>
+#include <winsock.h>
+#else
#include <unistd.h>
-#include <errno.h>
#include <pthread.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <fcntl.h>
+#include <errno.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <sys/types.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <fcntl.h>
#include <openssl/rc4.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
#include <openssl/bn.h>
-#include "xrdp.h"
-
//#define MEMLEAK
+#ifdef _WIN32
+static CRITICAL_SECTION g_term_mutex;
+#else
static pthread_mutex_t g_term_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
static int g_term = 0;
#ifdef MEMLEAK
-int g_memsize = 0;
-int g_memid = 0;
+static int g_memsize = 0;
+static int g_memid = 0;
struct xrdp_list* g_memlist = 0;
#endif
/*****************************************************************************/
int g_init_system(void)
{
+#ifdef _WIN32
+ WSADATA w;
+
+ WSAStartup(2, &w);
+ InitializeCriticalSection(&g_term_mutex);
+#endif
#ifdef MEMLEAK
g_memlist = xrdp_list_create();
#endif
@@ -63,6 +76,10 @@ int g_init_system(void)
/*****************************************************************************/
int g_exit_system(void)
{
+#ifdef _WIN32
+ WSACleanup();
+ DeleteCriticalSection(&g_term_mutex);
+#endif
#ifdef MEMLEAK
int i;
struct xrdp_mem* p;
@@ -223,17 +240,26 @@ int g_tcp_socket(void)
/*****************************************************************************/
void g_tcp_close(int sck)
{
+#ifdef _WIN32
+ closesocket(sck);
+#else
close(sck);
+#endif
}
/*****************************************************************************/
int g_tcp_set_non_blocking(int sck)
{
- int i;
+ unsigned long i;
- i = fcntl(sck, F_GETFL);
+#ifdef _WIN32
+ i = 1;
+ ioctlsocket(sck, FIONBIO, &i);
+#else
+ i = fcntl(sck, F_GETFL);
i = i | O_NONBLOCK;
fcntl(sck, F_SETFL, i);
+#endif
return 0;
}
@@ -259,7 +285,11 @@ int g_tcp_listen(int sck)
int g_tcp_accept(int sck)
{
struct sockaddr_in s;
+#ifdef _WIN32
+ signed int i;
+#else
unsigned int i;
+#endif
i = sizeof(struct sockaddr_in);
memset(&s, 0, i);
@@ -281,7 +311,11 @@ int g_tcp_send(int sck, void* ptr, int len, int flags)
/*****************************************************************************/
int g_tcp_last_error_would_block(int sck)
{
+#ifdef _WIN32
+ return WSAGetLastError() == WSAEWOULDBLOCK;
+#else
return errno == EWOULDBLOCK;
+#endif
}
/*****************************************************************************/
@@ -293,7 +327,7 @@ int g_tcp_select(int sck)
time.tv_sec = 0;
time.tv_usec = 0;
FD_ZERO(&rfds);
- FD_SET(sck, &rfds);
+ FD_SET(((unsigned int)sck), &rfds);
return select(sck + 1, &rfds, 0, 0, &time);
}
@@ -302,33 +336,58 @@ int g_is_term(void)
{
int rv;
+#ifdef _WIN32
+ EnterCriticalSection(&g_term_mutex);
+ rv = g_term;
+ LeaveCriticalSection(&g_term_mutex);
+#else
pthread_mutex_lock(&g_term_mutex);
rv = g_term;
pthread_mutex_unlock(&g_term_mutex);
+#endif
return rv;
}
/*****************************************************************************/
void g_set_term(int in_val)
{
+#ifdef _WIN32
+ EnterCriticalSection(&g_term_mutex);
+ g_term = in_val;
+ LeaveCriticalSection(&g_term_mutex);
+#else
pthread_mutex_lock(&g_term_mutex);
g_term = in_val;
pthread_mutex_unlock(&g_term_mutex);
+#endif
}
/*****************************************************************************/
void g_sleep(int msecs)
{
+#ifdef _WIN32
+ Sleep(msecs);
+#else
usleep(msecs * 1000);
+#endif
}
/*****************************************************************************/
-int g_thread_create(void* (*start_routine)(void*), void* arg)
+#ifdef _WIN32
+int g_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg)
+{
+ DWORD thread;
+
+ return !CreateThread(0, 0, start_routine, arg, 0, &thread);
+}
+#else
+int g_thread_create(void* (* start_routine)(void*), void* arg)
{
pthread_t thread;
return pthread_create(&thread, 0, start_routine, arg);
}
+#endif
/* rc4 stuff */
@@ -451,6 +510,9 @@ int g_mod_exp(char* out, char* in, char* mod, char* exp)
/*****************************************************************************/
void g_random(char* data, int len)
{
+#ifdef _WIN32
+ memset(data, 0x44, len);
+#else
int fd;
memset(data, 0x44, len);
@@ -462,6 +524,7 @@ void g_random(char* data, int len)
read(fd, data, len);
close(fd);
}
+#endif
}
/*****************************************************************************/
@@ -479,13 +542,23 @@ int g_memcmp(void* s1, void* s2, int len)
/*****************************************************************************/
int g_file_open(char* file_name)
{
+#ifdef _WIN32
+ return (int)CreateFile(file_name, GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+#else
return open(file_name, O_RDWR | O_CREAT);
+#endif
}
/*****************************************************************************/
int g_file_close(int fd)
{
+#ifdef _WIN32
+ CloseHandle((HANDLE)fd);
+#else
close(fd);
+#endif
return 0;
}
@@ -493,27 +566,49 @@ int g_file_close(int fd)
/* read from file*/
int g_file_read(int fd, char* ptr, int len)
{
+#ifdef _WIN32
+ if (ReadFile((HANDLE)fd, (LPVOID)ptr, (DWORD)len, (LPDWORD)&len, 0))
+ return len;
+ else
+ return -1;
+#else
return read(fd, ptr, len);
+#endif
}
/*****************************************************************************/
/* write to file */
int g_file_write(int fd, char* ptr, int len)
{
+#ifdef _WIN32
+ if (WriteFile((HANDLE)fd, (LPVOID)ptr, (DWORD)len, (LPDWORD)&len, 0))
+ return len;
+ else
+ return -1;
+#else
return write(fd, ptr, len);
+#endif
}
/*****************************************************************************/
/* move file pointer */
int g_file_seek(int fd, int offset)
{
+#ifdef _WIN32
+ return SetFilePointer((HANDLE)fd, offset, 0, FILE_BEGIN);
+#else
return lseek(fd, offset, SEEK_SET);
+#endif
}
/*****************************************************************************/
/* do a write lock on a file */
+/* return boolean */
int g_file_lock(int fd, int start, int len)
{
+#ifdef _WIN32
+ return LockFile((HANDLE)fd, start, 0, len, 0);
+#else
struct flock lock;
lock.l_type = F_WRLCK;
@@ -523,6 +618,7 @@ int g_file_lock(int fd, int start, int len)
if (fcntl(fd, F_SETLK, &lock) == -1)
return 0;
return 1;
+#endif
}
/*****************************************************************************/
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c
index 5d10a2e9..21ba4986 100644
--- a/xrdp/xrdp.c
+++ b/xrdp/xrdp.c
@@ -26,9 +26,8 @@ static struct xrdp_listen* g_listen = 0;
/*****************************************************************************/
/* i can't get stupid in_val to work, hum using global var for now */
-void* xrdp_listen_run(void* in_val)
+THREAD_RV THREAD_CC xrdp_listen_run(void* in_val)
{
-
DEBUG(("listener started\n\r"));
xrdp_listen_main_loop(g_listen);
DEBUG(("listener done\n\r"));
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
index 7b06b86b..59d3b80e 100644
--- a/xrdp/xrdp.h
+++ b/xrdp/xrdp.h
@@ -68,6 +68,14 @@
/* font macros */
#define FONT_DATASIZE(f) ((((f)->height * (((f)->width + 7) / 8)) + 3) & ~3);
+#ifdef _WIN32
+#define THREAD_RV unsigned long
+#define THREAD_CC __stdcall
+#else
+#define THREAD_RV void*
+#define THREAD_CC
+#endif
+
/* os_calls.c */
int g_init_system(void);
int g_exit_system(void);
@@ -93,7 +101,7 @@ int g_tcp_select(int sck);
int g_is_term(void);
void g_set_term(int in_val);
void g_sleep(int msecs);
-int g_thread_create(void* (*start_routine)(void*), void* arg);
+int g_thread_create(THREAD_RV (THREAD_CC * start_routine)(void*), void* arg);
void* g_rc4_info_create(void);
void g_rc4_info_delete(void* rc4_info);
void g_rc4_set_key(void* rc4_info, char* key, int len);
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index bd54570f..75555080 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -532,8 +532,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
xrdp_painter_fill_rect(painter, self, 1, 1, self->width - 2, 1);
/* draw text */
painter->fg_color = self->wm->black;
- xrdp_painter_draw_text(painter, self, 2, 2, self->caption);
-// xrdp_painter_draw_text(painter, self, 2, 2, "hi");
+ xrdp_painter_draw_text(painter, self, 4, 2, self->caption);
}
else if (self->type == WND_TYPE_LABEL) /* 6 */
{
diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c
index 69124e9b..bcf3b119 100644
--- a/xrdp/xrdp_listen.c
+++ b/xrdp/xrdp_listen.c
@@ -108,7 +108,7 @@ int xrdp_listen_delete_pro(struct xrdp_listen* self, struct xrdp_process* pro)
/*****************************************************************************/
/* i can't get stupid in_val to work, hum using global var for now */
-void* xrdp_process_run(void* in_val)
+THREAD_RV THREAD_CC xrdp_process_run(void* in_val)
{
DEBUG(("process started\n\r"));
xrdp_process_main_loop(g_process);
diff --git a/xrdp/xrdp_orders.c b/xrdp/xrdp_orders.c
index c6998252..facdb1c2 100644
--- a/xrdp/xrdp_orders.c
+++ b/xrdp/xrdp_orders.c
@@ -642,7 +642,7 @@ int xrdp_orders_dest_blt(struct xrdp_orders* self, int x, int y,
}
if (rop != self->dest_blt_rop)
{
- present |= 0x0010;
+ present |= 0x10;
out_uint8(self->out_s, rop);
self->dest_blt_rop = rop;
}
diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c
index c54d5730..9ea7d46a 100644
--- a/xrdp/xrdp_painter.c
+++ b/xrdp/xrdp_painter.c
@@ -159,12 +159,16 @@ int xrdp_painter_fill_rect(struct xrdp_painter* self,
i = 0;
while (xrdp_region_get_rect(region, i, &rect) == 0)
{
- DEBUG(("sending rect order %d %d %d %d\n\r", rect.left, rect.top,
- rect.right, rect.bottom));
- xrdp_orders_rect(self->orders, rect.left, rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- self->fg_color, 0);
+ if (!ISRECTEMPTY(rect))
+ {
+ DEBUG(("sending rect order %d %d %d %d\n\r",
+ rect.left, rect.top,
+ rect.right, rect.bottom));
+ xrdp_orders_rect(self->orders, rect.left, rect.top,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ self->fg_color, 0);
+ }
i++;
}
xrdp_region_delete(region);
@@ -196,13 +200,17 @@ int xrdp_painter_fill_rect2(struct xrdp_painter* self,
i = 0;
while (xrdp_region_get_rect(region, i, &rect) == 0)
{
- DEBUG(("sending rect2 order %d %d %d %d\n\r", rect.left, rect.top,
- rect.right, rect.bottom));
- xrdp_orders_pat_blt(self->orders, rect.left, rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- self->rop, self->bg_color, self->fg_color,
- &self->brush, 0);
+ if (!ISRECTEMPTY(rect))
+ {
+ DEBUG(("sending rect2 order %d %d %d %d\n\r",
+ rect.left, rect.top,
+ rect.right, rect.bottom));
+ xrdp_orders_pat_blt(self->orders, rect.left, rect.top,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ self->rop, self->bg_color, self->fg_color,
+ &self->brush, 0);
+ }
i++;
}
xrdp_region_delete(region);
@@ -269,47 +277,50 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
k = 0;
while (xrdp_region_get_rect(region, k, &rect) == 0)
{
- MAKERECT(rect1, x1, y1, w, h);
- if (rect_intersect(&rect, &rect1, &rect2))
+ if (!ISRECTEMPTY(rect))
{
- ok = 1;
- if (self->use_clip)
- {
- rect = self->clip;
- RECTOFFSET(rect, x, y);
- if (!rect_intersect(&rect2, &rect, &rect1))
- ok = 0;
- }
- else
- rect1 = rect2;
- if (ok)
+ MAKERECT(rect1, x1, y1, w, h);
+ if (rect_intersect(&rect, &rect1, &rect2))
{
- rect1.right--;
- rect1.bottom--;
- /* check these so ms client don't crash */
- if (x1 + w >= self->wm->screen->width)
- w = self->wm->screen->width - x1;
- if (y1 + h >= self->wm->screen->height)
- h = self->wm->screen->height - y1;
- if (w > 0 && h > 0 && x1 + w > 0 && y1 + h > 0)
+ ok = 1;
+ if (self->use_clip)
{
- srcx = 0;
- srcy = 0;
- if (x1 < 0)
- {
- w = w + x1;
- srcx = srcx - x1;
- x1 = 0;
- }
- if (y1 < 0)
+ rect = self->clip;
+ RECTOFFSET(rect, x, y);
+ if (!rect_intersect(&rect2, &rect, &rect1))
+ ok = 0;
+ }
+ else
+ rect1 = rect2;
+ if (ok)
+ {
+ rect1.right--;
+ rect1.bottom--;
+ /* check these so ms client don't crash */
+ if (x1 + w >= self->wm->screen->width)
+ w = self->wm->screen->width - x1;
+ if (y1 + h >= self->wm->screen->height)
+ h = self->wm->screen->height - y1;
+ if (w > 0 && h > 0 && x1 + w > 0 && y1 + h > 0)
{
- h = h + y1;
- srcy = srcy - y1;
- y1 = 0;
+ srcx = 0;
+ srcy = 0;
+ if (x1 < 0)
+ {
+ w = w + x1;
+ srcx = srcx - x1;
+ x1 = 0;
+ }
+ if (y1 < 0)
+ {
+ h = h + y1;
+ srcy = srcy - y1;
+ y1 = 0;
+ }
+ xrdp_orders_mem_blt(self->orders, cache_id, palette_id,
+ x1, y1, w, h, self->rop, srcx, srcy,
+ cache_idx, &rect1);
}
- xrdp_orders_mem_blt(self->orders, cache_id, palette_id,
- x1, y1, w, h, self->rop, srcx, srcy,
- cache_idx, &rect1);
}
}
}
@@ -436,17 +447,20 @@ int xrdp_painter_draw_text(struct xrdp_painter* self,
k = 0;
while (xrdp_region_get_rect(region, k, &rect) == 0)
{
- if (rect_intersect(&rect, &clip_rect, &draw_rect))
+ if (!ISRECTEMPTY(rect))
{
- x1 = x;
- y1 = y + total_height;
- draw_rect.right--;
- draw_rect.bottom--;
- flags = 0x03; /* 0x73; TEXT2_IMPLICIT_X and something else */
- xrdp_orders_text(self->orders, f, flags, 0,
- font->color, 0,
- x, y, x + total_width, y + total_height,
- 0, 0, 0, 0, x1, y1, data, len * 2, &draw_rect);
+ if (rect_intersect(&rect, &clip_rect, &draw_rect))
+ {
+ x1 = x;
+ y1 = y + total_height;
+ draw_rect.right--;
+ draw_rect.bottom--;
+ flags = 0x03; /* 0x73; TEXT2_IMPLICIT_X and something else */
+ xrdp_orders_text(self->orders, f, flags, 0,
+ font->color, 0,
+ x, y, x + total_width, y + total_height,
+ 0, 0, 0, 0, x1, y1, data, len * 2, &draw_rect);
+ }
}
k++;
}
diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h
index 37ca1b03..4bed6cbe 100644
--- a/xrdp/xrdp_types.h
+++ b/xrdp/xrdp_types.h
@@ -390,6 +390,7 @@ struct xrdp_bitmap
struct xrdp_list* child_list;
struct xrdp_wm* wm;
int cursor;
+ int edit_pos;
/* msg 1 = click 2 = mouse move 3 = paint 100 = modal result */
int (*notify)(struct xrdp_bitmap* wnd, struct xrdp_bitmap* sender,
int msg, int param1, int param2);
diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c
index d4d84415..e1bdd6b4 100644
--- a/xrdp/xrdp_wm.c
+++ b/xrdp/xrdp_wm.c
@@ -31,7 +31,7 @@ struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner)
self = (struct xrdp_wm*)g_malloc(sizeof(struct xrdp_wm), 1);
self->screen = xrdp_bitmap_create(owner->rdp_layer->width,
owner->rdp_layer->height,
- owner->rdp_layer->bpp, 2);
+ owner->rdp_layer->bpp, WND_TYPE_SCREEN);
self->screen->wm = self;
self->pro_layer = owner;
self->orders = owner->orders;