| 2376 | ----------------------------------------------------------*/ |
| 2377 | |
| 2378 | int tcgetattr(int fd, struct termios *s_termios) |
| 2379 | { |
| 2380 | DCB myDCB; |
| 2381 | COMMTIMEOUTS timeouts; |
| 2382 | struct termios_list *index; |
| 2383 | char message[80]; |
| 2384 | |
| 2385 | ENTER("tcgetattr"); |
| 2386 | |
| 2387 | if (fd <= 0) |
| 2388 | { |
| 2389 | return 0; |
| 2390 | } |
| 2391 | |
| 2392 | index = win32_serial_find_port(fd); |
| 2393 | |
| 2394 | if (!index) |
| 2395 | { |
| 2396 | LEAVE("tcgetattr"); |
| 2397 | return -1; |
| 2398 | } |
| 2399 | |
| 2400 | if (!GetCommState(index->hComm, &myDCB)) |
| 2401 | { |
| 2402 | SNPRINTF(message, sizeof(message), "GetCommState failed\n"); |
| 2403 | report(message); |
| 2404 | return -1; |
| 2405 | } |
| 2406 | |
| 2407 | memcpy(s_termios, index->ttyset, sizeof(struct termios)); |
| 2408 | |
| 2409 | show_DCB(myDCB); |
| 2410 | |
| 2411 | /***** input mode flags (c_iflag ) ****/ |
| 2412 | /* parity check enable */ |
| 2413 | if (myDCB.fParity) |
| 2414 | { |
| 2415 | s_termios->c_iflag |= INPCK; |
| 2416 | s_termios->c_iflag &= ~IGNPAR; |
| 2417 | } |
| 2418 | else |
| 2419 | { |
| 2420 | s_termios->c_iflag &= ~INPCK; |
| 2421 | s_termios->c_iflag |= IGNPAR; |
| 2422 | } |
| 2423 | |
| 2424 | /* FIXME: IGNBRK: ignore break */ |
| 2425 | /* FIXME: BRKINT: interrupt on break */ |
| 2426 | |
| 2427 | if (myDCB.fOutX) |
| 2428 | { |
| 2429 | s_termios->c_iflag |= IXON; |
| 2430 | } |
| 2431 | else |
| 2432 | { |
| 2433 | /* IXON: output start/stop control */ |
| 2434 | s_termios->c_iflag &= ~IXON; |
| 2435 | } |
no test coverage detected