ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

uimain.c
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 8 -*-
00002    rdesktop: A Remote Desktop Protocol client.
00003    Main ui file
00004    Copyright (C) Jay Sorg 2006
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License along
00017    with this program; if not, write to the Free Software Foundation, Inc.,
00018    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00019 */
00020 
00021 #include <precomp.h>
00022 
00023 char g_username[256] = "";
00024 char g_hostname[256] = "";
00025 char g_servername[256] = "";
00026 char g_password[256] = "";
00027 char g_shell[256] = "";
00028 char g_directory[256] = "";
00029 char g_domain[256] = "";
00030 BOOL g_desktop_save = False; /* desktop save order */
00031 BOOL g_polygon_ellipse_orders = False; /* polygon / ellipse orders */
00032 BOOL g_bitmap_compression = True;
00033 uint32 g_rdp5_performanceflags =
00034   RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS;
00035 BOOL g_bitmap_cache_persist_enable = False;
00036 BOOL g_bitmap_cache_precache = True;
00037 BOOL g_bitmap_cache = True;
00038 BOOL g_encryption = True;
00039 int g_server_depth = 8;
00040 BOOL g_use_rdp5 = False;
00041 int g_width = 800;
00042 int g_height = 600;
00043 uint32 g_keylayout = 0x409; /* Defaults to US keyboard layout */
00044 int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */
00045 int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */
00046 int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */
00047 BOOL g_console_session = False;
00048 
00049 /* can't be static, hardware file or bsops need these */
00050 int g_tcp_sck = 0;
00051 int pal_entries[256];
00052 
00053 /* Session Directory redirection */
00054 BOOL g_redirect = False;
00055 char g_redirect_server[64];
00056 char g_redirect_domain[16];
00057 char g_redirect_password[64];
00058 char g_redirect_username[64];
00059 char g_redirect_cookie[128];
00060 uint32 g_redirect_flags = 0;
00061 
00062 extern int g_tcp_port_rdp;
00063 
00064 static int g_deactivated = 0;
00065 static uint32 g_ext_disc_reason = 0;
00066 
00067 struct bitmap
00068 {
00069   uint8 * data;
00070   uint32 width;
00071   uint32 height;
00072 };
00073 
00074 /* in ui specific file eg win32.c, qt.c, df.c, ... */
00075 int
00076 mi_create_window(void);
00077 int
00078 mi_main_loop(void);
00079 void
00080 mi_error(char * msg);
00081 void
00082 mi_warning(char * msg);
00083 void
00084 mi_paint_rect(char * data, int width, int height, int x, int y, int cx, int cy);
00085 void
00086 mi_begin_update(void);
00087 void
00088 mi_end_update(void);
00089 void
00090 mi_fill_rect(int x, int y, int cx, int cy, int colour);
00091 void
00092 mi_screen_copy(int x, int y, int cx, int cy, int srcx, int srcy);
00093 void
00094 mi_set_clip(int x, int y, int cx, int cy);
00095 void
00096 mi_reset_clip(void);
00097 void
00098 mi_line(int x1, int y1, int x2, int y2, int colour);
00099 void*
00100 mi_create_cursor(unsigned int x, unsigned int y,
00101                  int width, int height,
00102                  unsigned char * andmask, unsigned char * xormask);
00103 
00104 
00105 void
00106 mi_destroy_cursor(void * cursor);
00107 void
00108 mi_set_cursor(void * cursor);
00109 void
00110 mi_set_null_cursor(void);
00111 int
00112 mi_read_keyboard_state(void);
00113 
00114 /*****************************************************************************/
00115 /* put part of the screen from the backing store to the display */
00116 void
00117 ui_invalidate(int x, int y, int cx, int cy)
00118 {
00119   char * data;
00120 
00121   if (cx < 1 || cy < 1)
00122   {
00123     return;
00124   }
00125   if (bs_warp_coords(&x, &y, &cx, &cy, 0, 0))
00126   {
00127     cx = (cx + 3) & ~3;
00128     data = (char *) xmalloc(cx * cy * 4);
00129     bs_copy_box(data, x, y, cx, cy, cx * ((g_server_depth + 7) / 8));
00130     mi_paint_rect(data, cx, cy, x, y, cx, cy);
00131     xfree(data);
00132   }
00133 }
00134 
00135 /*****************************************************************************/
00136 void
00137 ui_bell(void)
00138 {
00139 }
00140 
00141 /*****************************************************************************/
00142 int
00143 ui_select(int in)
00144 {
00145   if (g_tcp_sck == 0)
00146   {
00147     g_tcp_sck = in;
00148   }
00149   return 1;
00150 }
00151 
00152 /*****************************************************************************/
00153 void *
00154 ui_create_cursor(uint32 x, uint32 y,
00155                  int width, int height,
00156                  uint8 * andmask, uint8 * xormask)
00157 {
00158   int i;
00159   int j;
00160   char am[32 * 4];
00161   char xm[32 * 4];
00162 
00163   if (width != 32 || height != 32)
00164   {
00165     return 0;
00166   }
00167   memset(am, 0, 32 * 4);
00168   memset(xm, 0, 32 * 4);
00169   for (i = 0; i < 32; i++)
00170   {
00171     for (j = 0; j < 32; j++)
00172     {
00173       if (bs_is_pixel_on((char *)andmask, j, i, 32, 1))
00174       {
00175         bs_set_pixel_on(am, j, 31 - i, 32, 1, 1);
00176       }
00177       if (bs_is_pixel_on((char *)xormask, j, i, 32, 24))
00178       {
00179         bs_set_pixel_on(xm, j, 31 - i, 32, 1, 1);
00180       }
00181     }
00182   }
00183   return (void *) mi_create_cursor(x, y, width, height, (unsigned char *)am, (unsigned char *)xm);
00184 }
00185 
00186 /*****************************************************************************/
00187 void
00188 ui_destroy_cursor(void * cursor)
00189 {
00190   mi_destroy_cursor(cursor);
00191 }
00192 
00193 /*****************************************************************************/
00194 void
00195 ui_set_cursor(void * cursor)
00196 {
00197   mi_set_cursor(cursor);
00198 }
00199 
00200 /*****************************************************************************/
00201 void
00202 ui_set_null_cursor(void)
00203 {
00204   mi_set_null_cursor();
00205 }
00206 
00207 /*****************************************************************************/
00208 void *
00209 ui_create_glyph(int width, int height, uint8 * data)
00210 {
00211   int i;
00212   int j;
00213   char * glyph_data;
00214   struct bitmap * the_glyph;
00215 
00216   glyph_data = (char *) xmalloc(width * height);
00217   memset(glyph_data, 0, width * height);
00218   the_glyph = (struct bitmap *) xmalloc(sizeof(struct bitmap));
00219   memset(the_glyph, 0, sizeof(struct bitmap));
00220   the_glyph->width = width;
00221   the_glyph->height = height;
00222   the_glyph->data = (uint8 *)glyph_data;
00223   for (i = 0; i < height; i++)
00224   {
00225     for (j = 0; j < width; j++)
00226     {
00227       if (bs_is_pixel_on((char *)data, j, i, width, 1))
00228       {
00229         bs_set_pixel_on(glyph_data, j, i, width, 8, 255);
00230       }
00231     }
00232   }
00233   return the_glyph;
00234 }
00235 
00236 /*****************************************************************************/
00237 void
00238 ui_destroy_glyph(void * glyph)
00239 {
00240   struct bitmap * the_glyph;
00241 
00242   the_glyph = glyph;
00243   if (the_glyph != 0)
00244   {
00245     xfree(the_glyph->data);
00246   }
00247   xfree(the_glyph);
00248 }
00249 
00250 /*****************************************************************************/
00251 void *
00252 ui_create_bitmap(int width, int height, uint8 * data)
00253 {
00254   struct bitmap * b;
00255   int size;
00256 
00257   size = width * height * ((g_server_depth + 7) / 8);
00258   b = (struct bitmap *) xmalloc(sizeof(struct bitmap));
00259   b->data = (uint8 *) xmalloc(size);
00260   memcpy(b->data, data, size);
00261   b->width = width;
00262   b->height = height;
00263   return b;
00264 }
00265 
00266 /*****************************************************************************/
00267 void
00268 ui_destroy_bitmap(void * bmp)
00269 {
00270   struct bitmap * b;
00271 
00272   b = (struct bitmap *) bmp;
00273   if (b != 0)
00274   {
00275     xfree(b->data);
00276   }
00277   xfree(b);
00278 }
00279 
00280 /*****************************************************************************/
00281 void
00282 ui_paint_bitmap(int x, int y, int cx, int cy,
00283                 int width, int height, uint8 * data)
00284 {
00285   struct bitmap b;
00286 
00287   b.width = width;
00288   b.height = height;
00289   b.data = data;
00290   ui_memblt(12, x, y, cx, cy, &b, 0, 0);
00291 }
00292 
00293 /*****************************************************************************/
00294 void
00295 ui_set_clip(int x, int y, int cx, int cy)
00296 {
00297   bs_set_clip(x, y, cx, cy);
00298   mi_set_clip(x, y, cx, cy);
00299 }
00300 
00301 /*****************************************************************************/
00302 void
00303 ui_reset_clip(void)
00304 {
00305   bs_reset_clip();
00306   mi_reset_clip();
00307 }
00308 
00309 /*****************************************************************************/
00310 void *
00311 ui_create_colourmap(COLOURMAP * colours)
00312 {
00313   int i;
00314   int n;
00315 
00316   n = MIN(256, colours->ncolours);
00317   memset(pal_entries, 0, sizeof(pal_entries));
00318   for (i = 0; i < n; i++)
00319   {
00320     pal_entries[i] = (colours->colours[i].red << 16) |
00321                      (colours->colours[i].green << 8) |
00322                      colours->colours[i].blue;
00323   }
00324   return 0;
00325 }
00326 
00327 /*****************************************************************************/
00328 void
00329 ui_set_colourmap(void * map)
00330 {
00331 }
00332 
00333 /*****************************************************************************/
00334 static void
00335 draw_glyph(int x, int y, void * glyph, int fgcolor)
00336 {
00337   struct bitmap * b;
00338 
00339   b = glyph;
00340   bs_draw_glyph(x, y, (char *)b->data, b->width, b->height, fgcolor);
00341 }
00342 
00343 /*****************************************************************************/
00344 #define DO_GLYPH(ttext,idx) \
00345 { \
00346   glyph = cache_get_font(font, ttext[idx]); \
00347   if (!(flags & TEXT2_IMPLICIT_X)) \
00348   { \
00349     xyoffset = ttext[++idx]; \
00350     if (xyoffset & 0x80) \
00351     { \
00352       if (flags & TEXT2_VERTICAL) \
00353       { \
00354         y += ttext[idx + 1] | (ttext[idx + 2] << 8); \
00355       } \
00356       else \
00357       { \
00358         x += ttext[idx + 1] | (ttext[idx + 2] << 8); \
00359       } \
00360       idx += 2; \
00361     } \
00362     else \
00363     { \
00364       if (flags & TEXT2_VERTICAL) \
00365       { \
00366         y += xyoffset; \
00367       } \
00368       else \
00369       { \
00370         x += xyoffset; \
00371       } \
00372     } \
00373   } \
00374   if (glyph != NULL) \
00375   { \
00376     draw_glyph(x + glyph->offset, y + glyph->baseline, glyph->pixmap, \
00377                fgcolour); \
00378     if (flags & TEXT2_IMPLICIT_X) \
00379     { \
00380       x += glyph->width; \
00381     } \
00382   } \
00383 }
00384 
00385 /*****************************************************************************/
00386 void
00387 ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode,
00388              int x, int y,
00389              int clipx, int clipy, int clipcx, int clipcy,
00390              int boxx, int boxy, int boxcx, int boxcy, BRUSH * brush,
00391              int bgcolour, int fgcolour, uint8 * text, uint8 length)
00392 {
00393   int i;
00394   int j;
00395   int xyoffset;
00396   DATABLOB * entry;
00397   FONTGLYPH * glyph;
00398 
00399   if (boxx + boxcx > g_width)
00400   {
00401     boxcx = g_width - boxx;
00402   }
00403   if (boxcx > 1)
00404   {
00405     bs_rect(boxx, boxy, boxcx, boxcy, bgcolour, 0xc);
00406   }
00407   else
00408   {
00409     if (mixmode == MIX_OPAQUE)
00410     {
00411       bs_rect(clipx, clipy, clipcx, clipcy, bgcolour, 0xc);
00412     }
00413   }
00414   /* Paint text, character by character */
00415   for (i = 0; i < length;)
00416   {
00417     switch (text[i])
00418     {
00419       case 0xff:
00420         if (i + 2 < length)
00421         {
00422           cache_put_text(text[i + 1], text, text[i + 2]);
00423         }
00424         else
00425         {
00426           error("this shouldn't be happening\n");
00427           exit(1);
00428         }
00429         /* this will move pointer from start to first character after */
00430         /* FF command */
00431         length -= i + 3;
00432         text = &(text[i + 3]);
00433         i = 0;
00434         break;
00435       case 0xfe:
00436         entry = cache_get_text(text[i + 1]);
00437         if (entry != NULL)
00438         {
00439           if ((((uint8 *) (entry->data))[1] == 0) &&
00440                               (!(flags & TEXT2_IMPLICIT_X)))
00441           {
00442             if (flags & TEXT2_VERTICAL)
00443             {
00444               y += text[i + 2];
00445             }
00446             else
00447             {
00448               x += text[i + 2];
00449             }
00450           }
00451           for (j = 0; j < entry->size; j++)
00452           {
00453             DO_GLYPH(((uint8 *) (entry->data)), j);
00454           }
00455         }
00456         if (i + 2 < length)
00457         {
00458           i += 3;
00459         }
00460         else
00461         {
00462           i += 2;
00463         }
00464         length -= i;
00465         /* this will move pointer from start to first character after */
00466         /* FE command */
00467         text = &(text[i]);
00468         i = 0;
00469         break;
00470       default:
00471         DO_GLYPH(text, i);
00472         i++;
00473         break;
00474     }
00475   }
00476   if (boxcx > 1)
00477   {
00478     ui_invalidate(boxx, boxy, boxcx, boxcy);
00479   }
00480   else
00481   {
00482     ui_invalidate(clipx, clipy, clipcx, clipcy);
00483   }
00484 }
00485 
00486 /*****************************************************************************/
00487 void
00488 ui_line(uint8 opcode, int startx, int starty, int endx, int endy,
00489         PEN * pen)
00490 {
00491   int x;
00492   int y;
00493   int cx;
00494   int cy;
00495 
00496   bs_line(opcode, startx, starty, endx, endy, pen->width, pen->style,
00497           pen->colour);
00498   if (pen->style == 0 && pen->width < 2 && opcode == 12)
00499   {
00500     mi_line(startx, starty, endx, endy, pen->colour);
00501   }
00502   else
00503   {
00504     x = MIN(startx, endx);
00505     y = MIN(starty, endy);
00506     cx = (MAX(startx, endx) + 1) - x;
00507     cy = (MAX(starty, endy) + 1) - y;
00508     ui_invalidate(x, y, cx, cy);
00509   }
00510 }
00511 
00512 /*****************************************************************************/
00513 void
00514 ui_triblt(uint8 opcode, int x, int y, int cx, int cy,
00515           void * src, int srcx, int srcy,
00516           BRUSH* brush, int bgcolour, int fgcolour)
00517 {
00518   /* not used */
00519 }
00520 
00521 /*****************************************************************************/
00522 void
00523 ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
00524           void * src, int srcx, int srcy)
00525 {
00526   struct bitmap* b;
00527 
00528   b = (struct bitmap*)src;
00529   bs_memblt(opcode, x, y, cx, cy, b->data, b->width, b->height,
00530             srcx, srcy);
00531   ui_invalidate(x, y, cx, cy);
00532 }
00533 
00534 /*****************************************************************************/
00535 void
00536 ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
00537 {
00538 }
00539 
00540 /*****************************************************************************/
00541 void
00542 ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
00543 {
00544 }
00545 
00546 /*****************************************************************************/
00547 void
00548 ui_rect(int x, int y, int cx, int cy, int colour)
00549 {
00550   bs_rect(x, y, cx, cy, colour, 12);
00551   mi_fill_rect(x, y, cx, cy, colour);
00552 }
00553 
00554 /*****************************************************************************/
00555 void
00556 ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
00557              int srcx, int srcy)
00558 {
00559   bs_screenblt(opcode, x, y, cx, cy, srcx, srcy);
00560   if (opcode == 12)
00561   {
00562     mi_screen_copy(x, y, cx, cy, srcx, srcy);
00563   }
00564   else
00565   {
00566     ui_invalidate(x, y, cx, cy);
00567   }
00568 }
00569 
00570 /*****************************************************************************/
00571 void
00572 ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
00573           BRUSH * brush, int bgcolour, int fgcolour)
00574 {
00575   bs_patblt(opcode, x, y, cx, cy, brush->style, (char *)brush->pattern,
00576             brush->xorigin, brush->yorigin, bgcolour, fgcolour);
00577   ui_invalidate(x, y, cx, cy);
00578 }
00579 
00580 /*****************************************************************************/
00581 void
00582 ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
00583 {
00584   bs_rect(x, y, cx, cy, 0, opcode);
00585   ui_invalidate(x, y, cx, cy);
00586   /* todo */
00587 }
00588 
00589 /*****************************************************************************/
00590 void
00591 ui_move_pointer(int x, int y)
00592 {
00593 }
00594 
00595 /*****************************************************************************/
00596 uint16
00597 ui_get_numlock_state(uint32 state)
00598 {
00599   return (uint16) state;
00600 }
00601 
00602 /*****************************************************************************/
00603 /* get the num, caps, and scroll lock state */
00604 /* scroll lock is 1, num lock is 2 and caps lock is 4 */
00605 /* just returning 0, the hardware specific file is responsable for this */
00606 uint32
00607 read_keyboard_state(void)
00608 {
00609   return (uint32) mi_read_keyboard_state();
00610 }
00611 
00612 /*****************************************************************************/
00613 void
00614 ui_set_modifier_state(int code)
00615 
00616 {
00617 
00618   //error("%8.8x", code);
00619 
00620   rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, (uint16) code, 0);
00621 
00622 }
00623 
00624 /*****************************************************************************/
00625 void
00626 ui_resize_window(void)
00627 {
00628 }
00629 
00630 /*****************************************************************************/
00631 void
00632 ui_begin_update(void)
00633 {
00634   mi_begin_update();
00635 }
00636 
00637 /*****************************************************************************/
00638 void
00639 ui_end_update(void)
00640 {
00641   mi_end_update();
00642 }
00643 
00644 /*****************************************************************************/
00645 void
00646 ui_polygon(uint8 opcode, uint8 fillmode, POINT * point, int npoints,
00647            BRUSH * brush, int bgcolour, int fgcolour)
00648 {
00649   /* not used */
00650 }
00651 
00652 /*****************************************************************************/
00653 void
00654 ui_polyline(uint8 opcode, POINT * points, int npoints, PEN * pen)
00655 {
00656   int i, x, y, dx, dy;
00657   if (npoints > 0)
00658   {
00659     x = points[0].x;
00660     y = points[0].y;
00661     for (i = 1; i < npoints; i++)
00662     {
00663       dx = points[i].x;
00664       dy = points[i].y;
00665       ui_line(opcode, x, y, x + dx, y + dy, pen);
00666       x = x + dx;
00667       y = y + dy;
00668     }
00669   }
00670 }
00671 
00672 /*****************************************************************************/
00673 void
00674 ui_ellipse(uint8 opcode, uint8 fillmode,
00675            int x, int y, int cx, int cy,
00676            BRUSH * brush, int bgcolour, int fgcolour)
00677 {
00678   /* not used */
00679 }
00680 
00681 /*****************************************************************************/
00682 /* get a 32 byte random */
00683 void
00684 generate_random(uint8 * random)
00685 {
00686   int i;
00687 
00688   rand();
00689   rand();
00690   for (i = 0; i < 32; i++)
00691   {
00692     random[i] = rand() >> 16; /* higher bits are more random */
00693   }
00694 }
00695 
00696 /*****************************************************************************/
00697 void
00698 save_licence(uint8 * data, int length)
00699 {
00700 }
00701 
00702 /*****************************************************************************/
00703 int
00704 load_licence(uint8 ** data)
00705 {
00706   return 0;
00707 }
00708 
00709 /*****************************************************************************/
00710 void *
00711 xrealloc(void * in, int size)
00712 {
00713   if (size < 1)
00714   {
00715     size = 1;
00716   }
00717   return realloc(in, size);
00718 }
00719 
00720 /*****************************************************************************/
00721 void *
00722 xmalloc(int size)
00723 {
00724   if (size < 1)
00725   {
00726     size = 1;
00727   }
00728   return malloc(size);
00729 }
00730 
00731 /*****************************************************************************/
00732 void
00733 xfree(void * in)
00734 {
00735   if (in != 0)
00736   {
00737     free(in);
00738   }
00739 }
00740 
00741 /*****************************************************************************/
00742 char *
00743 xstrdup(const char * s)
00744 {
00745   int len;
00746   char * p;
00747 
00748   if (s == 0)
00749   {
00750     return 0;
00751   }
00752   len = strlen(s);
00753   p = (char *) xmalloc(len + 1);
00754   strcpy(p, s);
00755   return p;
00756 }
00757 
00758 /*****************************************************************************/
00759 void
00760 warning(char * format, ...)
00761 {
00762   va_list ap;
00763   char text[512];
00764   char text1[512];
00765 
00766   sprintf(text1, "WARNING: ");
00767   va_start(ap, format);
00768   vsprintf(text, format, ap);
00769   va_end(ap);
00770   strcat(text1, text);
00771   mi_warning(text1);
00772 }
00773 
00774 /*****************************************************************************/
00775 void
00776 unimpl(char * format, ...)
00777 {
00778   va_list ap;
00779   char text[512];
00780   char text1[512];
00781 
00782   sprintf(text1, "UNIMPL: ");
00783   va_start(ap, format);
00784   vsprintf(text, format, ap);
00785   va_end(ap);
00786   strcat(text1, text);
00787   mi_warning(text1);
00788 }
00789 
00790 /*****************************************************************************/
00791 void
00792 error(char * format, ...)
00793 {
00794   va_list ap;
00795   char text[512];
00796   char text1[512];
00797 
00798   sprintf(text1, "ERROR: ");
00799   va_start(ap, format);
00800   vsprintf(text, format, ap);
00801   va_end(ap);
00802   strcat(text1, text);
00803   mi_error(text1);
00804 }
00805 
00806 /*****************************************************************************/
00807 BOOL
00808 rd_pstcache_mkdir(void)
00809 {
00810   return 0;
00811 }
00812 
00813 /*****************************************************************************/
00814 int
00815 rd_open_file(char * filename)
00816 {
00817   return 0;
00818 }
00819 
00820 /*****************************************************************************/
00821 void
00822 rd_close_file(int fd)
00823 {
00824   return;
00825 }
00826 
00827 /*****************************************************************************/
00828 int
00829 rd_read_file(int fd, void * ptr, int len)
00830 {
00831   return 0;
00832 }
00833 
00834 /*****************************************************************************/
00835 int
00836 rd_write_file(int fd, void * ptr, int len)
00837 {
00838   return 0;
00839 }
00840 
00841 /*****************************************************************************/
00842 int
00843 rd_lseek_file(int fd, int offset)
00844 {
00845   return 0;
00846 }
00847 
00848 /*****************************************************************************/
00849 BOOL
00850 rd_lock_file(int fd, int start, int len)
00851 {
00852   return False;
00853 }
00854 
00855 
00856 /*****************************************************************************/
00857 void
00858 ui_mouse_move(int x, int y)
00859 {
00860   rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, (uint16) x, (uint16) y);
00861 }
00862 
00863 
00864 /*****************************************************************************/
00865 void
00866 ui_mouse_button(int button, int x, int y, int down)
00867 {
00868   uint16 flags;
00869 
00870   flags = 0;
00871   if (down)
00872   {
00873     flags |= MOUSE_FLAG_DOWN;
00874   }
00875   switch (button)
00876   {
00877     case 1:
00878       flags |= MOUSE_FLAG_BUTTON1;
00879       break;
00880     case 2:
00881       flags |= MOUSE_FLAG_BUTTON2;
00882       break;
00883     case 3:
00884       flags |= MOUSE_FLAG_BUTTON3;
00885       break;
00886     case 4:
00887       flags |= MOUSE_FLAG_BUTTON4;
00888       break;
00889     case 5:
00890       flags |= MOUSE_FLAG_BUTTON5;
00891       break;
00892   }
00893   rdp_send_input(0, RDP_INPUT_MOUSE, flags, (uint16) x, (uint16) y);
00894 }
00895 
00896 
00897 /*****************************************************************************/
00898 void
00899 ui_key_down(int key, int ext)
00900 
00901 {
00902   rdp_send_input(0, RDP_INPUT_SCANCODE, (uint16) (RDP_KEYPRESS | ext),
00903                  (uint16) key, 0);
00904 }
00905 
00906 /*****************************************************************************/
00907 void
00908 ui_key_up(int key, int ext)
00909 {
00910   rdp_send_input(0, RDP_INPUT_SCANCODE, (uint16) (RDP_KEYRELEASE | ext),
00911                  (uint16) key, 0);
00912 }
00913 
00914 /*****************************************************************************/
00915 /* returns boolean, non zero is good */
00916 int
00917 ui_read_wire(void)
00918 {
00919   return rdp_loop(&g_deactivated, &g_ext_disc_reason);
00920 }
00921 
00922 /*****************************************************************************/
00923 /* called after the command line parameters are processed */
00924 /* returns boolean, non zero is ok */
00925 int
00926 ui_main(void)
00927 {
00928   uint32 flags;
00929 
00930   /* try to connect */
00931   flags = RDP_LOGON_NORMAL;
00932   if (g_password[0] != 0)
00933   {
00934     flags |= RDP_LOGON_AUTO;
00935   }
00936   if (!rdp_connect(g_servername, flags, g_domain, g_password,
00937                    g_shell, g_directory))
00938   {
00939     return 0;
00940   }
00941   /* init backingstore */
00942   bs_init(g_width, g_height, g_server_depth);
00943   /* create the window */
00944   if (!mi_create_window())
00945   {
00946     return 0;
00947   }
00948   /* if all ok, enter main loop */
00949   return mi_main_loop();
00950 }
00951 
00952 /*****************************************************************************/
00953 /* produce a hex dump */
00954 void
00955 hexdump(uint8 * p, uint32 len)
00956 {
00957   uint8 * line = p;
00958   int i, thisline, offset = 0;
00959 
00960   while (offset < (int)len)
00961   {
00962     printf("%04x ", offset);
00963     thisline = len - offset;
00964     if (thisline > 16)
00965       thisline = 16;
00966 
00967     for (i = 0; i < thisline; i++)
00968       printf("%02x ", line[i]);
00969 
00970     for (; i < 16; i++)
00971       printf("   ");
00972 
00973     for (i = 0; i < thisline; i++)
00974       printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
00975 
00976     printf("\n");
00977     offset += thisline;
00978     line += thisline;
00979   }
00980 }
00981 

Generated on Sun May 27 2012 04:17:12 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.