History

merge

23hiro committed 10 years ago

Commit 7d2ec9b2 parents 08a8630 9bec8b112 files · +128 −95Browse files

Unified · Split

12 files
  1. 9ball.ico +0 −0
  2. 9ball.png +0 −0
  3. 9ball.rc +0 −1
  4. Make.win32 +3 −3
  5. drawterm.ico +0 −0
  6. drawterm.rc +1 −1
  7. glenda-t.ico +0 −0
  8. glenda-t.rc +1 −0
  9. gui-win32/screen.c +2 −3
  10. include/keyboard.h +44 −26
  11. kern/devssl.c +80 −64
  12. main.c +1 −1
9ball.ico+0−0

Binary file not shown.

9ball.png+0−0

Binary file not shown.

9ball.rc+0−1
@@ -1 +0,0 @@
1−IDI_ICON1 ICON DISCARDABLE "9ball.ico"
Make.win32+3−3
@@ -19,7 +19,7 @@ GUI=win32 · 18 unmodified lines
1919 LDFLAGS=-mwindows
2020 LDADD=-lkernel32 -ladvapi32 -lgdi32 -lmpr -lwsock32 -lmsvcrt -lmingw32
2121 TARG=drawterm.exe
22−XOFILES=9ball.$O
22+XOFILES=glenda-t.$O
2323
2424 # Windows via MSVC
2525 #AR=???
@@ -37,6 +37,6 @@ all: default · 11 unmodified lines
3737 libmachdep.a:
3838 (cd win32-386; make)
3939
40−9ball.$O: 9ball.rc 9ball.ico
41− $(WINDRES) -i 9ball.rc -o 9ball.o
40+glenda-t.$O: glenda-t.rc glenda-t.ico
41+ $(WINDRES) -i glenda-t.rc -o glenda-t.o
4242
drawterm.ico+0−0

Binary file not shown.

drawterm.rc+1−1
@@ -28,7 +28,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US · 27 unmodified lines
2828
2929 // Icon with lowest ID value placed first to ensure application icon
3030 // remains consistent on all systems.
31−IDI_ICON1 ICON DISCARDABLE "drawterm.ico"
31+IDI_ICON1 ICON DISCARDABLE "glenda-t.ico"
3232
3333 #ifdef APSTUDIO_INVOKED
3434 /////////////////////////////////////////////////////////////////////////////
glenda-t.ico+0−0

Binary file not shown.

glenda-t.rc+1−0
@@ -0,0 +1 @@
1+101 ICON DISCARDABLE "glenda-t.ico"
gui-win32/screen.c+2−3
@@ -186,7 +186,7 @@ winproc(void *a) · 185 unmodified lines
186186 wc.cbClsExtra = 0;
187187 wc.cbWndExtra = 0;
188188 wc.hInstance = inst;
189− wc.hIcon = LoadIcon(inst, NULL);
189+ wc.hIcon = LoadIcon(inst, MAKEINTRESOURCE(101));
190190 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
191191 wc.hbrBackground = GetStockObject(WHITE_BRUSH);
192192 wc.lpszMenuName = 0;
@@ -416,8 +416,7 @@ WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) · 223 unmodified lines
416416 kbdputc(kbdq, Kins);
417417 break;
418418 case VK_DELETE:
419−// kbdputc(kbdq, Kdel);
420− kbdputc(kbdq, 0x7f); // should have Kdel in keyboard.h
419+ kbdputc(kbdq, Kdel);
421420 break;
422421 case VK_UP:
423422 kbdputc(kbdq, Kup);
include/keyboard.h+44−26
@@ -1,8 +1,3 @@
1−#ifdef PLAN9
2−#pragma src "/sys/src/libdraw"
3−#pragma lib "libdraw.a"
4−#endif
5−
61 typedef struct Keyboardctl Keyboardctl;
72 typedef struct Channel Channel;
83
@@ -18,27 +13,50 @@ struct Keyboardctl · 9 unmodified lines
1813
1914
2015 extern Keyboardctl* initkeyboard(char*);
21−extern int ctlkeyboard(Keyboardctl*, char*);
22−extern void closekeyboard(Keyboardctl*);
16+extern int ctlkeyboard(Keyboardctl*, char*);
17+extern void closekeyboard(Keyboardctl*);
2318
2419 enum {
25− KF= 0xF000, /* Rune: beginning of private Unicode space */
26− Spec= 0xF800,
27− /* KF|1, KF|2, ..., KF|0xC is F1, F2, ..., F12 */
28− Khome= KF|0x0D,
29− Kup= KF|0x0E,
30− Kpgup= KF|0x0F,
31− Kprint= KF|0x10,
32− Kleft= KF|0x11,
33− Kright= KF|0x12,
34− Kdown= Spec|0x00,
35− Kview= Spec|0x00,
36− Kpgdown= KF|0x13,
37− Kins= KF|0x14,
38− Kend= KF|0x18,
39−
40− Kalt= KF|0x15,
41− Kshift= KF|0x16,
42− Kctl= KF|0x17,
20+ KF= 0xF000, /* Rune: beginning of private Unicode space */
21+ Spec= 0xF800,
22+ PF= Spec|0x20, /* num pad function key */
23+ Kview= Spec|0x00, /* view (shift window up) */
24+ /* KF|1, KF|2, ..., KF|0xC is F1, F2, ..., F12 */
25+ Khome= KF|0x0D,
26+ Kup= KF|0x0E,
27+ Kdown= Kview,
28+ Kpgup= KF|0x0F,
29+ Kprint= KF|0x10,
30+ Kleft= KF|0x11,
31+ Kright= KF|0x12,
32+ Kpgdown= KF|0x13,
33+ Kins= KF|0x14,
34+
35+ Kalt= KF|0x15,
36+ Kshift= KF|0x16,
37+ Kctl= KF|0x17,
38+
39+ Kend= KF|0x18,
40+ Kscroll= KF|0x19,
41+ Kscrolloneup= KF|0x20,
42+ Kscrollonedown= KF|0x21,
43+
44+ Ksoh= 0x01,
45+ Kstx= 0x02,
46+ Ketx= 0x03,
47+ Keof= 0x04,
48+ Kenq= 0x05,
49+ Kack= 0x06,
50+ Kbs= 0x08,
51+ Knack= 0x15,
52+ Ketb= 0x17,
53+ Kdel= 0x7f,
54+ Kesc= 0x1b,
55+
56+ Kbreak= Spec|0x61,
57+ Kcaps= Spec|0x64,
58+ Knum= Spec|0x65,
59+ Kmiddle= Spec|0x66,
60+ Kaltgr= Spec|0x67,
61+ Kmouse= Spec|0x100,
4362 };
44−
kern/devssl.c+80−64
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 #include "fns.h"
88 #include "error.h"
99
10−#include "libsec.h"
10+#include <libsec.h>
1111
1212 #define NOSPOOKS 1
1313
@@ -72,15 +72,15 @@ struct Dstate · 58 unmodified lines
7272 enum
7373 {
7474 Maxdmsg= 1<<16,
75− Maxdstate= 128, /* must be a power of 2 */
75+ Maxdstate= 512, /* max. open ssl conn's; must be a power of 2 */
7676 };
7777
78−Lock dslock;
79−int dshiwat;
80−char *dsname[Maxdstate];
81−Dstate *dstate[Maxdstate];
82−char *encalgs;
83−char *hashalgs;
78+static Lock dslock;
79+static int dshiwat;
80+static char *dsname[Maxdstate];
81+static Dstate *dstate[Maxdstate];
82+static char *encalgs;
83+static char *hashalgs;
8484
8585 enum{
8686 Qtopdir = 1, /* top level directory */
@@ -113,17 +113,13 @@ static void dsnew(Chan *c, Dstate **); · 26 unmodified lines
113113 static long sslput(Dstate *s, Block * volatile b);
114114
115115 char *sslnames[] = {
116− /* unused */ 0,
117− /* topdir */ 0,
118− /* protodir */ 0,
119− "clone",
120− /* convdir */ 0,
121− "data",
122− "ctl",
123− "secretin",
124− "secretout",
125− "encalgs",
126− "hashalgs",
116+[Qclonus] "clone",
117+[Qdata] "data",
118+[Qctl] "ctl",
119+[Qsecretin] "secretin",
120+[Qsecretout] "secretout",
121+[Qencalgs] "encalgs",
122+[Qhashalgs] "hashalgs",
127123 };
128124
129125 static int
@@ -237,7 +233,6 @@ sslgen(Chan *c, char *n, Dirtab *d, int nd, int s, Dir *dp) · 107 unmodified lines
237233 devdir(c, c->qid, sslnames[TYPE(c->qid)], 0, nm, 0660, dp);
238234 return 1;
239235 }
240− return -1;
241236 }
242237
243238 static Chan*
@@ -358,7 +353,7 @@ sslwstat(Chan *c, uchar *db, int n) · 114 unmodified lines
358353
359354 if(!emptystr(dir->uid))
360355 kstrdup(&s->user, dir->uid);
361− if(dir->mode != ~0)
356+ if(dir->mode != ~0UL)
362357 s->perm = dir->mode;
363358
364359 free(dir);
@@ -766,9 +761,8 @@ sslput(Dstate *s, Block * volatile b) · 401 unmodified lines
766761 int offset;
767762
768763 if(waserror()){
769−iprint("error: %s\n", up->errstr);
770764 if(b != nil)
771− free(b);
765+ freeb(b);
772766 nexterror();
773767 }
774768
@@ -900,7 +894,7 @@ initDESkey_40(OneWay *w) · 125 unmodified lines
900894 key[6] &= 0x0f;
901895 }
902896
903− w->state = malloc(sizeof(DESstate));
897+ w->state = smalloc(sizeof(DESstate));
904898 if(w->slen >= 16)
905899 setupDESstate(w->state, key, w->secret+8);
906900 else if(w->slen >= 8)
@@ -936,7 +930,7 @@ initRC4key_40(OneWay *w) · 29 unmodified lines
936930 if(w->slen > 5)
937931 w->slen = 5;
938932
939− w->state = malloc(sizeof(RC4state));
933+ w->state = smalloc(sizeof(RC4state));
940934 setupRC4state(w->state, w->secret, w->slen);
941935 }
942936
@@ -955,7 +949,7 @@ initRC4key_128(OneWay *w) · 12 unmodified lines
955949 if(w->slen > 16)
956950 w->slen = 16;
957951
958− w->state = malloc(sizeof(RC4state));
952+ w->state = smalloc(sizeof(RC4state));
959953 setupRC4state(w->state, w->secret, w->slen);
960954 }
961955
@@ -1004,6 +998,7 @@ struct Encalg · 42 unmodified lines
1004998 };
1005999
10061000 #ifdef NOSPOOKS
1001+static
10071002 Encalg encrypttab[] =
10081003 {
10091004 { "descbc", 8, DESCBC, initDESkey, }, /* DEPRECATED -- use des_56_cbc */
@@ -1019,6 +1014,7 @@ Encalg encrypttab[] = · 9 unmodified lines
10191014 { 0 }
10201015 };
10211016 #else
1017+static
10221018 Encalg encrypttab[] =
10231019 {
10241020 { "des_40_cbc", 8, DESCBC, initDESkey_40, },
@@ -1048,14 +1044,31 @@ parseencryptalg(char *p, Dstate *s) · 23 unmodified lines
10481044 return -1;
10491045 }
10501046
1047+enum {
1048+ Cfd,
1049+ Calg,
1050+ Csin,
1051+ Csout,
1052+};
1053+
1054+static
1055+Cmdtab sslcmds[] = {
1056+ {Cfd, "fd", 2 },
1057+ {Calg, "alg", 0 },
1058+ {Csin, "secretin", 2 },
1059+ {Csout, "secretout", 2 },
1060+};
1061+
10511062 static long
10521063 sslwrite(Chan *c, void *a, long n, vlong o)
10531064 {
10541065 Dstate * volatile s;
10551066 Block * volatile b;
1056− int m, t;
1057− char *p, *np, *e, buf[128];
1067+ int m, t, i;
1068+ char *p, *e;
10581069 uchar *x;
1070+ Cmdbuf *cb;
1071+ Cmdtab *ct;
10591072
10601073 USED(o);
10611074 s = dstate[CONV(c->qid)];
@@ -1073,9 +1086,8 @@ sslwrite(Chan *c, void *a, long n, vlong o) · 11 unmodified lines
10731086 nexterror();
10741087 }
10751088 qlock(&s->out.q);
1089+
10761090 p = a;
1077−if(0) iprint("write %d %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux\n",
1078− n, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
10791091 e = p + n;
10801092 do {
10811093 m = e - p;
@@ -1095,9 +1107,7 @@ if(0) iprint("write %d %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux\n", · 13 unmodified lines
10951107
10961108 p += m;
10971109 } while(p < e);
1098− p = a;
1099−if(0) iprint("wrote %d %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux\n",
1100− n, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
1110+
11011111 poperror();
11021112 qunlock(&s->out.q);
11031113 return n;
@@ -1125,19 +1135,15 @@ if(0) iprint("wrote %d %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux\n", · 21 unmodified lines
11251135 break;
11261136 }
11271137
1128− if(n >= sizeof(buf))
1129− error("arg too long");
1130− strncpy(buf, a, n);
1131− buf[n] = 0;
1132− p = strchr(buf, '\n');
1133− if(p)
1134− *p = 0;
1135− p = strchr(buf, ' ');
1136− if(p)
1137− *p++ = 0;
1138−
1139− if(strcmp(buf, "fd") == 0){
1140− s->c = buftochan(p);
1138+ cb = parsecmd(a, n);
1139+ if(waserror()){
1140+ free(cb);
1141+ nexterror();
1142+ }
1143+ ct = lookupcmd(cb, sslcmds, nelem(sslcmds));
1144+ switch(ct->index){
1145+ case Cfd:
1146+ s->c = buftochan(cb->f[1]);
11411147
11421148 /* default is clear (msg delimiters only) */
11431149 s->state = Sclear;
@@ -1146,7 +1152,11 @@ if(0) iprint("wrote %d %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux\n", · 2 unmodified lines
11461152 s->maxpad = s->max = (1<<15) - s->diglen - 1;
11471153 s->in.mid = 0;
11481154 s->out.mid = 0;
1149− } else if(strcmp(buf, "alg") == 0 && p != 0){
1155+ break;
1156+ case Calg:
1157+ if(cb->nf < 2)
1158+ cmderror(cb, "no algorithms");
1159+
11501160 s->blocklen = 1;
11511161 s->diglen = 0;
11521162
@@ -1155,9 +1165,8 @@ if(0) iprint("wrote %d %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux\n", · 2 unmodified lines
11551165
11561166 s->state = Sclear;
11571167 s->maxpad = s->max = (1<<15) - s->diglen - 1;
1158− if(strcmp(p, "clear") == 0){
1159− goto out;
1160− }
1168+ if(strcmp(cb->f[1], "clear") == 0)
1169+ break;
11611170
11621171 if(s->in.secret && s->out.secret == 0)
11631172 setsecret(&s->out, s->in.secret, s->in.slen);
@@ -1170,18 +1179,11 @@ if(0) iprint("wrote %d %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux\n", · 6 unmodified lines
11701179 s->encryptalg = Noencryption;
11711180 s->blocklen = 1;
11721181
1173− for(;;){
1174− np = strchr(p, ' ');
1175− if(np)
1176− *np++ = 0;
1177−
1182+ for(i=1; i<cb->nf; i++){
1183+ p = cb->f[i];
11781184 if(parsehashalg(p, s) < 0)
11791185 if(parseencryptalg(p, s) < 0)
11801186 error("bad algorithm");
1181−
1182− if(np == 0)
1183− break;
1184− p = np;
11851187 }
11861188
11871189 if(s->hf == 0 && s->encryptalg == Noencryption)
@@ -1194,20 +1196,34 @@ if(0) iprint("wrote %d %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux %.2ux\n", · 6 unmodified lines
11941196 s->maxpad -= s->maxpad % s->blocklen;
11951197 } else
11961198 s->maxpad = s->max = (1<<15) - s->diglen - 1;
1197− } else if(strcmp(buf, "secretin") == 0 && p != 0) {
1199+ break;
1200+ case Csin:
1201+ p = cb->f[1];
11981202 m = (strlen(p)*3)/2;
11991203 x = smalloc(m);
12001204 t = dec64(x, m, p, strlen(p));
1205+ if(t <= 0){
1206+ free(x);
1207+ error(Ebadarg);
1208+ }
12011209 setsecret(&s->in, x, t);
12021210 free(x);
1203− } else if(strcmp(buf, "secretout") == 0 && p != 0) {
1211+ break;
1212+ case Csout:
1213+ p = cb->f[1];
12041214 m = (strlen(p)*3)/2 + 1;
12051215 x = smalloc(m);
12061216 t = dec64(x, m, p, strlen(p));
1217+ if(t <= 0){
1218+ free(x);
1219+ error(Ebadarg);
1220+ }
12071221 setsecret(&s->out, x, t);
12081222 free(x);
1209− } else
1210− error(Ebadarg);
1223+ break;
1224+ }
1225+ poperror();
1226+ free(cb);
12111227
12121228 out:
12131229 qunlock(&s->in.ctlq);
@@ -1426,7 +1442,7 @@ checkdigestb(Dstate *s, Block *bin) · 212 unmodified lines
14261442 *p = n;
14271443 (*s->hf)(msgid, 4, digest, &ss);
14281444
1429− if(memcmp(digest, bin->rp, s->diglen) != 0)
1445+ if(tsmemcmp(digest, bin->rp, s->diglen) != 0)
14301446 error("bad digest");
14311447 }
14321448
main.c+1−1
@@ -111,7 +111,7 @@ findkey(char **puser, char *dom) · 110 unmodified lines
111111 pass = f[i]+10;
112112 if(strncmp(f[i], "dom=", 4) == 0 && strcmp(f[i]+4, dom) == 0)
113113 havedom = 1;
114− if(strcmp(f[i], "proto=p9sk1") == 0)
114+ if(strcmp(f[i], "proto=p9sk1") == 0 || strcmp(f[i], "proto=dp9ik") == 0)
115115 haveproto = 1;
116116 }
117117 if(!haveproto || !havedom || !pass || !user)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t