qtewin.cpp.org
来自「远程桌面登陆软件 用rdesktop 但不基于Xwindows 可基于(nano」· ORG 代码 · 共 2,378 行 · 第 1/5 页
ORG
2,378 行
if (p > 0) { startx += incx; starty += incy; p += dpru; } else { startx += incx; p += dpr; } } } else { dpr = dx << 1; dpru = dpr - (dy << 1); p = dpr - dy; for (; dy >= 0; dy--) { set_pixel(startx, starty, pen->colour, opcode); if (p > 0) { startx += incx; starty += incy; p += dpru; } else { starty += incy; p += dpr; } } } redraw(left, top, (right - left) + 1, (bottom - top) + 1);}/******************************************************************************/void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour){ struct bitmap *the_glyph; int i, j; the_glyph = (struct bitmap*)glyph; if (the_glyph == NULL) return; for (i = 0; i < the_glyph->h; i++) for (j = 0; j < the_glyph->w; j++) if (is_pixel_on(the_glyph->data, j, i, the_glyph->w, 8)) set_pixel(x + j, y + i, fgcolour);}#define DO_GLYPH(ttext,idx) \{\ glyph = cache_get_font (font, ttext[idx]);\ if (!(flags & TEXT2_IMPLICIT_X))\ {\ xyoffset = ttext[++idx];\ if ((xyoffset & 0x80))\ {\ if (flags & TEXT2_VERTICAL) \ y += ttext[idx+1] | (ttext[idx+2] << 8);\ else\ x += ttext[idx+1] | (ttext[idx+2] << 8);\ idx += 2;\ }\ else\ {\ if (flags & TEXT2_VERTICAL) \ y += xyoffset;\ else\ x += xyoffset;\ }\ }\ if (glyph != NULL)\ {\ draw_glyph (x + glyph->offset, y + glyph->baseline, glyph->pixmap, fgcolour);\ if (flags & TEXT2_IMPLICIT_X)\ x += glyph->width;\ }\}/******************************************************************************///*****************************************************************************void ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, BRUSH * brush, int bgcolour, int fgcolour, uint8 * text, uint8 length){ FONTGLYPH * glyph; int i, j, xyoffset; DATABLOB * entry; if (boxx + boxcx > g_width) boxcx = g_width - boxx; if (boxy + boxcy > g_height) boxcy = g_height - boxy; if (boxcx > 1) fill_rect(boxx, boxy, boxcx, boxcy, bgcolour); else if (mixmode == MIX_OPAQUE) fill_rect(clipx, clipy, clipcx, clipcy, bgcolour); /* Paint text, character by character */ for (i = 0; i < length;) { switch (text[i]) { case 0xff: if (i + 2 < length) cache_put_text(text[i + 1], text, text[i + 2]); else { error("this shouldn't be happening\n"); exit(1); } /* this will move pointer from start to first character after FF command */ length -= i + 3; text = &(text[i + 3]); i = 0; break; case 0xfe: entry = cache_get_text(text[i + 1]); if (entry != NULL) { if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X))) { if (flags & TEXT2_VERTICAL) y += text[i + 2]; else x += text[i + 2]; } for (j = 0; j < entry->size; j++) DO_GLYPH(((uint8 *) (entry->data)), j); } if (i + 2 < length) i += 3; else i += 2; length -= i; /* this will move pointer from start to first character after FE command */ text = &(text[i]); i = 0; break; default: DO_GLYPH(text, i); i++; break; } } if (boxcx > 1) redraw(boxx, boxy, boxcx, boxcy); else redraw(clipx, clipy, clipcx, clipcy);}/******************************************************************************/void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy){ uint8 * data; int i, j, Bpp, pixel; Bpp = 4; switch (g_server_bpp) { case 8: Bpp = 1; break; case 15: Bpp = 2; break; case 16: Bpp = 2; break; } data = (uint8*)xmalloc(cx * cy * Bpp); if (g_server_bpp == 8) { for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) { pixel = get_pixel(x + j, y + i); SETPIXEL8(data, j, i, cx, pixel); } } else if (g_server_bpp == 16) { for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) { pixel = get_pixel(x + j, y + i); SETPIXEL16(data, j, i, cx, pixel); } } else if (g_server_bpp == 24) { for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) *(((uint32*)data) + (i * cx + j)) = get_pixel(x + j, y + i); } offset *= Bpp; cache_put_desktop(offset, cx, cy, cx * Bpp, Bpp, data); xfree(data);}/******************************************************************************/void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy){ uint8 * data; int i, j; int Bpp; Bpp = 4; switch (g_server_bpp) { case 8: Bpp = 1; break; case 15: Bpp = 2; break; case 16: Bpp = 2; break; } offset *= Bpp; data = cache_get_desktop(offset, cx, cy, Bpp); if (g_server_bpp == 8) { for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) set_pixel(x + j, y + i, data[i * cx + j]); } else if (g_server_bpp == 16) { for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) set_pixel(x + j, y + i, *(((uint16*)data) + (i * cx + j))); } else if (g_server_bpp == 24) { for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) set_pixel(x + j, y + i, *(((uint32*)data) + (i * cx + j))); } redraw(x, y, cx, cy);}/*****************************************************************************/void * xrealloc(void * in_val, int size){ if (size < 1) { size = 1; } return realloc(in_val, size);}/*****************************************************************************/void * xmalloc(int size){ return malloc(size);}/*****************************************************************************/void xfree(void * in_val){ if (in_val != NULL) { free(in_val); }}/*****************************************************************************/char * xstrdup(const char * s){ char * mem = strdup(s); if (mem == NULL) { perror("strdup"); exit(1); } return mem;}/*****************************************************************************/void warning(char * format, ...){ va_list ap; fprintf(stderr, "WARNING: "); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);}/*****************************************************************************/void unimpl(char * format, ...){ va_list ap; fprintf(stderr, "NOT IMPLEMENTED: "); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);}/*****************************************************************************/void error(char * format, ...){ va_list ap; fprintf(stderr, "ERROR: "); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);}/*****************************************************************************/BOOL rd_pstcache_mkdir(void){ return 0;}/*****************************************************************************/int rd_open_file(char * filename){ return 0;}/*****************************************************************************/void rd_close_file(int fd){ return;}/*****************************************************************************/int rd_read_file(int fd, void * ptr, int len){ return 0;}/*****************************************************************************/int rd_write_file(int fd, void * ptr, int len){ return 0;}/*****************************************************************************/int rd_lseek_file(int fd, int offset){ return 0;}/*****************************************************************************/BOOL rd_lock_file(int fd, int start, int len){ return False;}/*****************************************************************************/int load_licence(uint8 ** data){ return 0;}/*****************************************************************************/void save_licence(uint8 * data, int length){}/*****************************************************************************/void generate_random(uint8 * random){ QFile File("/dev/random"); File.open(IO_ReadOnly); if (File.readBlock((char*)random, 32) == 32) { return; } warning("no /dev/random\n"); memcpy(random, "12345678901234567890123456789012", 32);}/*****************************************************************************//* produce a hex dump */void hexdump(uint8 * p, uint32 len){ uint8 * line = p; int i, thisline; uint32 offset = 0; while (offset < len) { printf("%04x ", offset); thisline = len - offset; if (thisline > 16) { thisline = 16; } for (i = 0; i < thisline; i++) { printf("%02x ", line[i]); } for (; i < 16; i++) { printf(" "); } for (i = 0; i < thisline; i++) { printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); } printf("\n"); offset += thisline; line += thisline; }}/*****************************************************************************/void get_username_and_hostname(void){ char fullhostname[64]; char * p; struct passwd * pw; STRNCPY(g_username, "unknown", sizeof(g_username)); STRNCPY(g_hostname, "unknown", sizeof(g_hostname)); pw = getpwuid(getuid()); if (pw != NULL && pw->pw_name != NULL) { STRNCPY(g_username, pw->pw_name, sizeof(g_username)); } if (gethostname(fullhostname, sizeof(fullhostname)) != -1) { p = strchr(fullhostname, '.'); if (p != NULL) { *p = 0; } STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); }}/*****************************************************************************/void out_params(void){ fprintf(stderr, "qterdesktop: A Remote Desktop Protocol client.\n"); fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2004 Matt Chapman.\n"); fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); fprintf(stderr, "Usage: qterdesktop [options] server\n"); fprintf(stderr, " -g: desktop geometry (WxH)\n"); fprintf(stderr, " -4: use RDP version 4\n"); fprintf(stderr, " -5: use RDP version 5 (default)\n"); fprintf(stderr, " -t: tcp port)\n"); fprintf(stderr, " -a: connection colour depth\n"); fprintf(stderr, " -u: user name\n"); fprintf(stderr, " -d: domain\n"); fprintf(stderr, " -s: shell\n"); fprintf(stderr, " -c: working directory\n"); fprintf(stderr, " -p: password (- to prompt)\n"); fprintf(stderr, " -n: client hostname\n"); fprintf(stderr, " -f: full screen\n"); fprintf(stderr, " -r sound: enable sound\n"); fprintf(stderr, "\n");}/*****************************************************************************/int parse_parameters(int in_argc, char ** in_argv){ int i; char * p; for (i = 1; i < in_argc; i++) { strcpy(g_server, in_argv[i]); if (strcmp(in_argv[i], "-h") == 0) { out_params(); return 0; } else if (strcmp(in_argv[i], "-g") == 0) { g_width = strtol(in_argv
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?