p = cfg.environ;
p = cfg.environmt;
static int CALLBACK TelnetProc (HWND hwnd, UINT msg,				    WPARAM wParam, LPARAM lParam) {    int i;    switch (msg) {      case WM_INITDIALOG:	SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype);	SetDlgItemText (hwnd, IDC3_TSEDIT, cfg.termspeed);	SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);	{	    char *p = cfg.environ;	    while (*p) {		SendDlgItemMessage (hwnd, IDC3_ENVLIST, LB_ADDSTRING, 0,				    (LPARAM) p);		p += strlen(p)+1;	    }	}	CheckRadioButton (hwnd, IDC3_EMBSD, IDC3_EMRFC,			  cfg.rfc_environ ? IDC3_EMRFC : IDC3_EMBSD);	break;      case WM_COMMAND:	switch (LOWORD(wParam)) {	  case IDC3_TTEDIT:	    if (HIWORD(wParam) == EN_CHANGE)	    GetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype,			    sizeof(cfg.termtype)-1);	    break;	  case IDC3_TSEDIT:	    if (HIWORD(wParam) == EN_CHANGE)		GetDlgItemText (hwnd, IDC3_TSEDIT, cfg.termspeed,				sizeof(cfg.termspeed)-1);	    break;	  case IDC3_LOGEDIT:	    if (HIWORD(wParam) == EN_CHANGE)		GetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username,				sizeof(cfg.username)-1);	    break;	  case IDC3_EMBSD:	  case IDC3_EMRFC:	    cfg.rfc_environ = IsDlgButtonChecked (hwnd, IDC3_EMRFC);	    break;	  case IDC3_ENVADD:	    if (HIWORD(wParam) == BN_CLICKED ||		HIWORD(wParam) == BN_DOUBLECLICKED) {		char str[sizeof(cfg.environ)];		char *p;		GetDlgItemText (hwnd, IDC3_VAREDIT, str, sizeof(str)-1);		if (!*str) {		    MessageBeep(0);		    break;		}		p = str + strlen(str);		*p++ = '\t';		GetDlgItemText (hwnd, IDC3_VALEDIT, p, sizeof(str)-1-(p-str));		if (!*p) {		    MessageBeep(0);		    break;		}		p = cfg.environ;		while (*p) {		    while (*p) p++;		    p++;		}		if ((p-cfg.environ) + strlen(str) + 2 < sizeof(cfg.environ)) {		    strcpy (p, str);		    p[strlen(str)+1] = '\0';		    SendDlgItemMessage (hwnd, IDC3_ENVLIST, LB_ADDSTRING,					0, (LPARAM)str);		    SetDlgItemText (hwnd, IDC3_VAREDIT, "");		    SetDlgItemText (hwnd, IDC3_VALEDIT, "");		} else {		    MessageBox(hwnd, "Environment too big", "PuTTY Error",			       MB_OK | MB_ICONERROR);		}	    }	    break;	  case IDC3_ENVREMOVE:	    if (HIWORD(wParam) != BN_CLICKED &&		HIWORD(wParam) != BN_DOUBLECLICKED)		break;	    i = SendDlgItemMessage (hwnd, IDC3_ENVLIST, LB_GETCURSEL, 0, 0);	    if (i == LB_ERR)		MessageBeep (0);	    else {		char *p, *q;	        SendDlgItemMessage (hwnd, IDC3_ENVLIST, LB_DELETESTRING,				    i, 0);		p = cfg.environ;		while (i > 0) {		    if (!*p)			goto disaster;		    while (*p) p++;		    p++;		    i--;		}		q = p;		if (!*p)		    goto disaster;		while (*p) p++;		p++;		while (*p) {		    while (*p)			*q++ = *p++;		    *q++ = *p++;		}		*q = '\0';		disaster:;	    }	    break;	}	break;    }    return GeneralPanelProc (hwnd, msg, wParam, lParam);}