added lib header and makefile

ulab-original
jsorg71 20 years ago
parent cf3e17cb73
commit 750f55b6ef

@ -506,7 +506,9 @@ void g_set_term(int in_val)
}
/*****************************************************************************/
#ifdef _WIN32
#ifdef XRDP_LIB
/* this is so libxrdp don't require libpthread */
#elif defined(_WIN32)
int g_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg)
{
DWORD thread;

@ -4,7 +4,8 @@ XRDPOBJ = ../common/os_calls.o \
xrdp_rdp.o xrdp_process.o xrdp_listen.o xrdp_orders.o \
xrdp_bitmap.o xrdp_wm.o xrdp_painter.o xrdp_list.o \
xrdp_region.o xrdp_cache.o xrdp_font.o funcs.o \
xrdp_login_wnd.o xrdp_file.o xrdp_bitmap_compress.o
xrdp_login_wnd.o xrdp_file.o xrdp_bitmap_compress.o \
xrdp_interface.o
#CFLAGS = -Wall -O2 -I../common -DXRDP_DEBUG
CFLAGS = -Wall -O2 -I../common

@ -0,0 +1,19 @@
/*
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2004-2005
use freely
*/
int server_init(void);
int server_exit(void);
int server_connect(int sck, int* width, int* height, int* bpp);
int server_loop(int sck);
int server_set_callback(int (* callback)(int, int, int));
int server_begin_update(void);
int server_end_update(void);
int server_fill_rect(int x, int y, int cx, int cy, int color);
int server_screen_blt(int x, int y, int cx, int cy, int srcx, int srcy);
int server_paint_rect(int x, int y, int cx, int cy, char* data);
int server_set_cursor(int x, int y, char* data, char* mask);
int server_palette(int* palette);

@ -0,0 +1,21 @@
XRDPOBJ = ../common/os_calls.o \
xrdp_tcp.o xrdp_iso.o xrdp_mcs.o xrdp_sec.o \
xrdp_rdp.o xrdp_process.o xrdp_orders.o \
xrdp_bitmap.o xrdp_wm.o xrdp_painter.o xrdp_list.o \
xrdp_region.o xrdp_cache.o xrdp_font.o funcs.o \
xrdp_file.o xrdp_bitmap_compress.o \
xrdp_interface.o
CFLAGS = -Wall -O2 -I../common -DXRDP_LIB
LDFLAGS = -L /usr/gnu/lib -shared
LIBS = -lcrypto
CC = gcc
all: xrdp
xrdp: $(XRDPOBJ)
$(CC) $(LDFLAGS) -o libxrdp.so $(XRDPOBJ) $(LIBS)
clean:
rm -f $(XRDPOBJ) xrdp

@ -160,6 +160,7 @@ int xrdp_wm_send_cursor(struct xrdp_wm* self, int cache_idx,
/* xrdp_process.c */
struct xrdp_process* xrdp_process_create(struct xrdp_listen* owner);
void xrdp_process_delete(struct xrdp_process* self);
int xrdp_process_loop(struct xrdp_process* self, struct stream* s);
int xrdp_process_main_loop(struct xrdp_process* self);
/* xrdp_listen.c */
@ -272,3 +273,19 @@ int xrdp_bitmap_compress(char* in_data, int width, int height,
struct stream* s, int bpp, int byte_limit,
int start_line, struct stream* temp,
int e);
#ifndef XRDP_LIB
/* xrdp_interface.c */
int server_begin_update(struct xrdp_mod* mod);
int server_end_update(struct xrdp_mod* mod);
int server_fill_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int color);
int server_screen_blt(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int srcx, int srcy);
int server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
char* data);
int server_set_cursor(struct xrdp_mod* mod, int x, int y,
char* data, char* mask);
int server_palette(struct xrdp_mod* mod, int* palette);
int server_error_popup(struct xrdp_mod* mod, char* error, char* caption);
#endif

@ -0,0 +1,347 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2004-2005
interface
*/
#include "xrdp.h"
#ifdef XRDP_LIB
struct xrdp_mod g_mod;
struct xrdp_process* g_rdp_process;
struct stream* g_s;
int (* g_callback)(int, int, int);
/*****************************************************************************/
int mod_event(struct xrdp_mod* v, int msg, int param1, int param2)
{
if (g_callback != 0)
{
return g_callback(msg, param1, param2);
}
else
{
return 0;
}
}
/*****************************************************************************/
int server_init(void)
{
g_init_system();
g_memset(&g_mod, 0, sizeof(struct xrdp_mod));
g_rdp_process = 0;
make_stream(g_s);
init_stream(g_s, 8192);
g_mod.handle = (int)(&g_mod);
g_mod.mod_event = mod_event;
return 0;
}
/*****************************************************************************/
int server_exit(void)
{
xrdp_process_delete(g_rdp_process);
free_stream(g_s);
g_exit_system();
return 0;
}
/*****************************************************************************/
int server_connect(int sck, int* width, int* height, int* bpp)
{
g_rdp_process = xrdp_process_create(0);
g_rdp_process->sck = sck;
if (xrdp_rdp_incoming(g_rdp_process->rdp_layer) != 0)
{
return 1;
}
if (width != 0)
{
*width = g_rdp_process->rdp_layer->client_info.width;
}
if (height != 0)
{
*height = g_rdp_process->rdp_layer->client_info.height;
}
if (bpp != 0)
{
*bpp = g_rdp_process->rdp_layer->client_info.bpp;
}
return 0;
}
/*****************************************************************************/
int server_loop(int sck)
{
if (g_rdp_process == 0)
{
return 1;
}
if (g_rdp_process->term)
{
return 1;
}
if (g_rdp_process->wm != 0)
{
if (g_rdp_process->wm->mod == 0)
{
g_rdp_process->wm->mod = &g_mod;
}
if (g_mod.wm == 0)
{
g_mod.wm = (int)(g_rdp_process->wm);
}
}
init_stream(g_s, 8192);
if (xrdp_process_loop(g_rdp_process, g_s) != 0)
{
return 1;
}
return 0;
}
/*****************************************************************************/
int server_set_callback(int (* callback)(int, int, int))
{
g_callback = callback;
return 0;
}
/*****************************************************************************/
int server_begin_update(void)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)g_mod.wm;
p = xrdp_painter_create(wm);
xrdp_painter_begin_update(p);
g_mod.painter = (int)p;
return 0;
}
/*****************************************************************************/
int server_end_update(void)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)g_mod.painter;
xrdp_painter_end_update(p);
xrdp_painter_delete(p);
g_mod.painter = 0;
return 0;
}
/*****************************************************************************/
int server_fill_rect(int x, int y, int cx, int cy, int color)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)g_mod.wm;
p = (struct xrdp_painter*)g_mod.painter;
p->fg_color = color;
xrdp_painter_fill_rect(p, wm->screen, x, y, cx, cy);
return 0;
}
/*****************************************************************************/
int server_screen_blt(int x, int y, int cx, int cy, int srcx, int srcy)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)g_mod.wm;
xrdp_orders_init(wm->orders);
xrdp_orders_screen_blt(wm->orders, x, y, cx, cy, srcx, srcy, 0xcc, 0);
xrdp_orders_send(wm->orders);
return 0;
}
/*****************************************************************************/
int server_paint_rect(int x, int y, int cx, int cy, char* data)
{
struct xrdp_wm* wm;
struct xrdp_bitmap* b;
wm = (struct xrdp_wm*)g_mod.wm;
b = xrdp_bitmap_create_with_data(cx, cy, wm->screen->bpp, data, wm);
xrdp_painter_draw_bitmap((struct xrdp_painter*)g_mod.painter,
wm->screen, b, x, y, cx, cy);
xrdp_bitmap_delete(b);
return 0;
}
/*****************************************************************************/
int server_set_cursor(int x, int y, char* data, char* mask)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)g_mod.wm;
xrdp_wm_send_cursor(wm, 2, data, mask, x, y);
return 0;
}
/*****************************************************************************/
int server_palette(int* palette)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)g_mod.wm;
if (g_memcmp(wm->palette, palette, 255 * sizeof(int)) != 0)
{
g_memcpy(wm->palette, palette, 256 * sizeof(int));
xrdp_wm_send_palette(wm);
}
return 0;
}
#else
/*****************************************************************************/
int server_begin_update(struct xrdp_mod* mod)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = xrdp_painter_create(wm);
xrdp_painter_begin_update(p);
mod->painter = (int)p;
return 0;
}
/*****************************************************************************/
int server_end_update(struct xrdp_mod* mod)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
xrdp_painter_end_update(p);
xrdp_painter_delete(p);
mod->painter = 0;
return 0;
}
/*****************************************************************************/
int server_fill_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int color)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = (struct xrdp_painter*)mod->painter;
p->fg_color = color;
xrdp_painter_fill_rect(p, wm->screen, x, y, cx, cy);
return 0;
}
/*****************************************************************************/
int server_screen_blt(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int srcx, int srcy)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
xrdp_orders_init(wm->orders);
xrdp_orders_screen_blt(wm->orders, x, y, cx, cy, srcx, srcy, 0xcc, 0);
xrdp_orders_send(wm->orders);
return 0;
}
/*****************************************************************************/
int server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
char* data)
{
struct xrdp_wm* wm;
struct xrdp_bitmap* b;
wm = (struct xrdp_wm*)mod->wm;
b = xrdp_bitmap_create_with_data(cx, cy, wm->screen->bpp, data, wm);
xrdp_painter_draw_bitmap((struct xrdp_painter*)mod->painter,
wm->screen, b, x, y, cx, cy);
xrdp_bitmap_delete(b);
return 0;
}
/*****************************************************************************/
int server_set_cursor(struct xrdp_mod* mod, int x, int y,
char* data, char* mask)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
xrdp_wm_send_cursor(wm, 2, data, mask, x, y);
return 0;
}
/*****************************************************************************/
int server_palette(struct xrdp_mod* mod, int* palette)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
if (g_memcmp(wm->palette, palette, 255 * sizeof(int)) != 0)
{
g_memcpy(wm->palette, palette, 256 * sizeof(int));
xrdp_wm_send_palette(wm);
}
return 0;
}
/*****************************************************************************/
int server_error_popup(struct xrdp_mod* mod, char* error, char* caption)
{
#if 0
struct xrdp_wm* wm;
struct xrdp_bitmap* wnd;
struct xrdp_bitmap* but;
wm = (struct xrdp_wm*)mod->wm;
wnd = xrdp_bitmap_create(400, 200, wm->screen->bpp, WND_TYPE_WND, wm);
xrdp_list_add_item(wm->screen->child_list, (int)wnd);
wnd->parent = wm->screen;
wnd->owner = wm->screen;
wnd->bg_color = wm->grey;
wnd->left = wm->screen->width / 2 - wnd->width / 2;
wnd->top = wm->screen->height / 2 - wnd->height / 2;
wnd->notify = xrdp_wm_popup_notify;
g_strcpy(wnd->caption, caption);
/* button */
but = xrdp_bitmap_create(60, 25, wm->screen->bpp, WND_TYPE_BUTTON, wm);
xrdp_list_add_item(wnd->child_list, (int)but);
but->parent = wnd;
but->owner = wnd;
but->left = 180;
but->top = 160;
but->id = 1;
g_strcpy(but->caption, "OK");
but->tab_stop = 1;
xrdp_bitmap_invalidate(wm->screen, 0);
//xrdp_bitmap_invalidate(wnd, 0);
g_sleep(2000);
#endif
return 0;
}
#endif /* XRDP_LIB */

@ -71,99 +71,6 @@ logging on.");
return 0;
}
/*****************************************************************************/
int server_begin_update(struct xrdp_mod* mod)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = xrdp_painter_create(wm);
xrdp_painter_begin_update(p);
mod->painter = (int)p;
return 0;
}
/*****************************************************************************/
int server_end_update(struct xrdp_mod* mod)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
xrdp_painter_end_update(p);
xrdp_painter_delete(p);
mod->painter = 0;
return 0;
}
/*****************************************************************************/
int server_fill_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int color)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = (struct xrdp_painter*)mod->painter;
p->fg_color = color;
xrdp_painter_fill_rect(p, wm->screen, x, y, cx, cy);
return 0;
}
/*****************************************************************************/
int server_screen_blt(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int srcx, int srcy)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
xrdp_orders_init(wm->orders);
xrdp_orders_screen_blt(wm->orders, x, y, cx, cy, srcx, srcy, 0xcc, 0);
xrdp_orders_send(wm->orders);
return 0;
}
/*****************************************************************************/
int server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
char* data)
{
struct xrdp_wm* wm;
struct xrdp_bitmap* b;
wm = (struct xrdp_wm*)mod->wm;
b = xrdp_bitmap_create_with_data(cx, cy, wm->screen->bpp, data, wm);
//xrdp_wm_send_bitmap(wm, b, x, y, cx, cy);
xrdp_painter_draw_bitmap((struct xrdp_painter*)mod->painter,
wm->screen, b, x, y, cx, cy);
xrdp_bitmap_delete(b);
return 0;
}
/*****************************************************************************/
int server_set_cursor(struct xrdp_mod* mod, int x, int y,
char* data, char* mask)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
xrdp_wm_send_cursor(wm, 2, data, mask, x, y);
return 0;
}
/*****************************************************************************/
int server_palette(struct xrdp_mod* mod, int* palette)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
if (g_memcmp(wm->palette, palette, 255 * sizeof(int)) != 0)
{
g_memcpy(wm->palette, palette, 256 * sizeof(int));
xrdp_wm_send_palette(wm);
}
return 0;
}
/*****************************************************************************/
int xrdp_wm_popup_notify(struct xrdp_bitmap* wnd,
struct xrdp_bitmap* sender,
@ -172,43 +79,6 @@ int xrdp_wm_popup_notify(struct xrdp_bitmap* wnd,
return 0;
}
/*****************************************************************************/
int server_error_popup(struct xrdp_mod* mod, char* error, char* caption)
{
#ifdef aa0
struct xrdp_wm* wm;
struct xrdp_bitmap* wnd;
struct xrdp_bitmap* but;
wm = (struct xrdp_wm*)mod->wm;
wnd = xrdp_bitmap_create(400, 200, wm->screen->bpp, WND_TYPE_WND, wm);
xrdp_list_add_item(wm->screen->child_list, (int)wnd);
wnd->parent = wm->screen;
wnd->owner = wm->screen;
wnd->bg_color = wm->grey;
wnd->left = wm->screen->width / 2 - wnd->width / 2;
wnd->top = wm->screen->height / 2 - wnd->height / 2;
wnd->notify = xrdp_wm_popup_notify;
g_strcpy(wnd->caption, caption);
/* button */
but = xrdp_bitmap_create(60, 25, wm->screen->bpp, WND_TYPE_BUTTON, wm);
xrdp_list_add_item(wnd->child_list, (int)but);
but->parent = wnd;
but->owner = wnd;
but->left = 180;
but->top = 160;
but->id = 1;
g_strcpy(but->caption, "OK");
but->tab_stop = 1;
xrdp_bitmap_invalidate(wm->screen, 0);
//xrdp_bitmap_invalidate(wnd, 0);
g_sleep(2000);
#endif
return 0;
}
/*****************************************************************************/
int xrdp_wm_setup_mod(struct xrdp_wm* self,
struct xrdp_mod_data* mod_data)

@ -46,30 +46,20 @@ void xrdp_process_delete(struct xrdp_process* self)
}
/*****************************************************************************/
int xrdp_process_main_loop(struct xrdp_process* self)
int xrdp_process_loop(struct xrdp_process* self, struct stream* s)
{
int code;
int i;
int cont;
struct stream* s;
int rv;
int code;
make_stream(s);
self->status = 1;
self->rdp_layer = xrdp_rdp_create(self, self->sck);
g_tcp_set_non_blocking(self->sck);
if (xrdp_rdp_incoming(self->rdp_layer) == 0)
{
while (!g_is_term() && !self->term)
{
i = g_tcp_select(self->sck, self->app_sck);
if (i & 1)
{
init_stream(s, 8192);
code = 0;
rv = 0;
cont = 1;
while (cont && !self->term)
{
if (xrdp_rdp_recv(self->rdp_layer, s, &code) != 0)
{
rv = 1;
break;
}
DEBUG(("xrdp_process_main_loop code %d\n\r", code));
@ -100,11 +90,7 @@ int xrdp_process_main_loop(struct xrdp_process* self)
cont = s->next_packet < s->end;
}
}
if (cont) /* we must have errored out */
{
break;
}
if (self->rdp_layer->up_and_running && self->wm == 0)
if (self->rdp_layer->up_and_running && self->wm == 0 && rv == 0)
{
/* only do this once */
DEBUG(("xrdp_process_main_loop up and running\n\r"));
@ -112,6 +98,29 @@ int xrdp_process_main_loop(struct xrdp_process* self)
self->wm = xrdp_wm_create(self, &self->rdp_layer->client_info);
xrdp_wm_init(self->wm);
}
return rv;
}
/*****************************************************************************/
int xrdp_process_main_loop(struct xrdp_process* self)
{
#ifndef XRDP_LIB
int i;
struct stream* s;
make_stream(s);
self->status = 1;
self->rdp_layer = xrdp_rdp_create(self, self->sck);
g_tcp_set_non_blocking(self->sck);
if (xrdp_rdp_incoming(self->rdp_layer) == 0)
{
while (!g_is_term() && !self->term)
{
i = g_tcp_select(self->sck, self->app_sck);
if (i & 1)
{
init_stream(s, 8192);
xrdp_process_loop(self, s);
}
if (i & 2) /* mod socket fired */
{
@ -152,5 +161,6 @@ int xrdp_process_main_loop(struct xrdp_process* self)
self->status = -1;
xrdp_listen_delete_pro(self->lis_layer, self);
free_stream(s);
#endif
return 0;
}

@ -462,6 +462,7 @@ int xrdp_wm_send_cursor(struct xrdp_wm* self, int cache_idx,
/*****************************************************************************/
int xrdp_wm_init(struct xrdp_wm* self)
{
#ifndef XRDP_LIB /* if lib, dodn't create login screen */
char data[32 * (32 * 3)];
char mask[32 * (32 / 8)];
int x;
@ -529,9 +530,7 @@ int xrdp_wm_init(struct xrdp_wm* self)
self->red = COLOR24(0xff, 0x00, 0x00);
self->green = COLOR24(0x00, 0xff, 0x00);
}
xrdp_login_wnd_create(self);
/* clear screen */
self->screen->bg_color = self->black;
xrdp_bitmap_invalidate(self->screen, 0);
@ -542,7 +541,7 @@ int xrdp_wm_init(struct xrdp_wm* self)
xrdp_wm_send_cursor(self, 1, data, mask, x, y);
xrdp_wm_load_cursor(self, "cursor0.cur", data, mask, &x, &y);
xrdp_wm_send_cursor(self, 0, data, mask, x, y);
#endif
return 0;
}

Loading…
Cancel
Save