ref: 20156393be201341d9b374b71ce43a7bc69a068b
parent: dbbe3d1bc62440febca9086f83615ee2859df54c
author: Yaroslav Kolomiiets <[email protected]>
date: Wed May 18 15:51:28 EDT 2016
add initscreen()
--- a/dat.h
+++ b/dat.h
@@ -25,6 +25,7 @@
{
int fd; /* connection I/O descriptor */
long sproto; /* magic to bounce back to server */
+ char *label; /* window label */
char *local; /* local system name */
char *user; /* user name for auto logon */
char *windom; /* domain for auto logon */
@@ -45,7 +46,7 @@
Vchan *vc; /* static virtual channels table */
uint nvc; /* number of vctab entries */
uchar cmap[256]; /* rfb color map for depths ≤ 8 */
- uchar rbuf[MAXTPDU]; /* read buffer */
+ uchar rbuf[MAXTPDU]; /* read buffer */
};
int starttls(Rdp*);
int rdphandshake(Rdp*);
@@ -64,10 +65,10 @@
void clipvcfn(Rdp*, uchar*,uint);
void pollsnarf(Rdp*);
+void initscreen(Rdp*);
void readkbd(Rdp*);
void readdevmouse(Rdp*);
void eresized(Rdp*, int);
-
struct Vchan
{
--- a/rd.c
+++ b/rd.c
@@ -97,6 +97,20 @@
return 0;
}
+void
+initscreen(Rdp* c)
+{
+ if(c->label == nil)
+ c->label = smprint("rd %s", server);
+ if(initdraw(drawerror, nil, c->label) < 0)
+ sysfatal("initdraw: %r");
+ display->locking = 1;
+ unlockdisplay(display);
+
+ c->ysz = Dy(screen->r);
+ c->xsz = (Dx(screen->r) +3) & ~3;
+}
+
static int killpid[32];
static int nkillpid;
@@ -120,7 +134,7 @@
main(int argc, char *argv[])
{
int doauth;
- char *server, *addr, *keyspec, *label;
+ char *server, *addr, *keyspec;
UserPasswd *creds;
Rdp* c;
@@ -138,7 +152,7 @@
keyspec = EARGF(usage());
break;
case 'T':
- label = strdup(EARGF(usage()));
+ c->label = strdup(EARGF(usage()));
break;
case 'd':
c->windom = strdup(EARGF(usage()));
@@ -189,17 +203,7 @@
sysfatal("dial %s: %r", addr);
if(x224handshake(c) < 0)
sysfatal("X.224 handshake: %r");
-
- if(label == nil)
- label = smprint("rd %s", server);
- if(initdraw(drawerror, nil, label) < 0)
- sysfatal("initdraw: %r");
- display->locking = 1;
- unlockdisplay(display);
-
- c->ysz = Dy(screen->r);
- c->xsz = (Dx(screen->r) +3) & ~3;
-
+ initscreen(c);
if(rdphandshake(c) < 0)
sysfatal("handshake: %r");