set_raw(slp);
if (!(slp->flags & FL_MODE)) { slp->mode = SL_MODE_RAW; slp->flags |= FL_MODE; } if (!(slp->flags & FL_BAUD)) { slp->baud = 9600; slp->flags |= FL_BAUD; } if (!(slp->flags & FL_PARITY)) { slp->parity = 0; slp->flags |= FL_PARITY; } if (!(slp->flags & FL_ECHO)) { slp->echo = 0; slp->flags |= FL_ECHO; } if (!(slp->flags & FL_CSIZE)) { slp->csize = 8; slp->flags |= FL_CSIZE; } if (!(slp->flags & FL_HWFLOW)) { slp->hwflow = 1; slp->flags |= FL_HWFLOW; } if (!(slp->flags & FL_SWFLOW)) { slp->swflow = 0; slp->flags |= FL_SWFLOW; }
static int do_open(sl_t* slp){    do_close(slp);    if (slp->dev == NULL)	return -1;    #ifdef __WIN32__    slp->com = CreateFile(slp->dev,  			  GENERIC_READ | GENERIC_WRITE, 			  0, 			  0, 			  OPEN_EXISTING,			  FILE_FLAG_OVERLAPPED,			  0);    if (slp->com == INVALID)	return -1;    slp->in.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);    slp->out.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);    slp->stat.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);    {	DWORD mask;	SetCommMask(slp->com, EV_RXCHAR);	WaitCommEvent(slp->com, &mask, &slp->stat);    }#else    slp->com = open(slp->dev, O_RDWR);    if (slp->com == INVALID)	return -1;    fcntl(slp->com, F_SETFL, fcntl(slp->com, F_GETFL, 0) | O_NONBLOCK);#endif    if (get_com_state(slp) < 0)	return -1;    set_raw(slp);     /* set raw mode */    /* update pending changes */    slp->flags |= FL_FORCE;  /* force update of above stuff */    do_update(slp);        return 0;}