str[0] = 'R';
type = 'R';
static void portfwd_handler(union control *ctrl, void *dlg,			    void *data, int event){    Config *cfg = (Config *)data;    struct portfwd_data *pfd =	(struct portfwd_data *)ctrl->generic.context.p;    if (event == EVENT_REFRESH) {	if (ctrl == pfd->listbox) {	    char *p = cfg->portfwd;	    dlg_update_start(ctrl, dlg);	    dlg_listbox_clear(ctrl, dlg);	    while (*p) {		dlg_listbox_add(ctrl, dlg, p);		p += strlen(p) + 1;	    }	    dlg_update_done(ctrl, dlg);	} else if (ctrl == pfd->direction) {	    /*	     * Default is Local.	     */	    dlg_radiobutton_set(ctrl, dlg, 0);	}    } else if (event == EVENT_ACTION) {	if (ctrl == pfd->addbutton) {	    char str[sizeof(cfg->portfwd)];	    char *p;	    int whichbutton = dlg_radiobutton_get(pfd->direction, dlg);	    if (whichbutton == 0)		str[0] = 'L';	    else if (whichbutton == 1)		str[0] = 'R';	    else		str[0] = 'D';	    dlg_editbox_get(pfd->sourcebox, dlg, str+1, sizeof(str) - 2);	    if (!str[1]) {		dlg_error_msg(dlg, "You need to specify a source port number");		return;	    }	    p = str + strlen(str);	    if (str[0] != 'D') {		*p++ = '\t';		dlg_editbox_get(pfd->destbox, dlg, p,				sizeof(str)-1 - (p - str));		if (!*p || !strchr(p, ':')) {		    dlg_error_msg(dlg,				  "You need to specify a destination address\n"				  "in the form \"host.name:port\"");		    return;		}	    } else		*p = '\0';	    p = cfg->portfwd;	    while (*p) {		while (*p)		    p++;		p++;	    }	    if ((p - cfg->portfwd) + strlen(str) + 2 <		sizeof(cfg->portfwd)) {		strcpy(p, str);		p[strlen(str) + 1] = '\0';		dlg_listbox_add(pfd->listbox, dlg, str);		dlg_editbox_set(pfd->sourcebox, dlg, "");		dlg_editbox_set(pfd->destbox, dlg, "");	    } else {		dlg_error_msg(dlg, "Too many forwardings");	    }	} else if (ctrl == pfd->rembutton) {	    int i = dlg_listbox_index(pfd->listbox, dlg);	    if (i < 0)		dlg_beep(dlg);	    else {		char *p, *q;		dlg_listbox_del(pfd->listbox, dlg, i);		p = cfg->portfwd;		while (i > 0) {		    if (!*p)			goto disaster2;		    while (*p)			p++;		    p++;		    i--;		}		q = p;		if (!*p)		    goto disaster2;		while (*p)		    p++;		p++;		while (*p) {		    while (*p)			*q++ = *p++;		    *q++ = *p++;		}		*q = '\0';		disaster2:;	    }	}    }}