- /* Make filedescriptor asynchronous. */
-
- if (__with_async) {
- retcode=fcntl(fd, F_SETFL, FASYNC);
- if (retcode == -1){
- perror("Gnokii serial_opendevice: fnctl(F_SETFL)");
- serial_close(fd);
- return(-1);
- }
- }
-
- /* Initialise the port settings */
-
- memcpy(&tp, &serial_termios, sizeof(struct termios));
-
- /* Set port settings for canonical input processing */
-
- tp.c_cflag = B0 | CS8 | CLOCAL | CREAD;
- if (__with_odd_parity) {
- tp.c_cflag |= (PARENB | PARODD);
- tp.c_iflag = 0;
- }
- else
- tp.c_iflag = IGNPAR;
- if (__with_hw_handshake)
- tp.c_cflag |= CRTSCTS;
- else
- tp.c_cflag &= ~CRTSCTS;
-
- tp.c_oflag = 0;
- tp.c_lflag = 0;
- tp.c_cc[VMIN] = 1;
- tp.c_cc[VTIME] = 0;
-
- retcode=tcflush(fd, TCIFLUSH);
- if (retcode == -1) {
- perror("Gnokii serial_opendevice: tcflush");
- serial_close(fd);
- return(-1);
- }
-
- retcode=tcsetattr(fd, TCSANOW, &tp);
- if (retcode == -1){
- perror("Gnokii serial_opendevice: tcsetattr");
- serial_close(fd);
- return(-1);
- }
-
- return fd;
+ /* Make filedescriptor asynchronous. */
+ if (__with_async) {
+ retcode = fcntl(fd, F_SETFL, FASYNC);
+ if (retcode == -1) {
+ perror("Gnokii serial_opendevice: fnctl(F_SETFL)");
+ serial_close(fd);
+ return (-1);
+ }
+ }
+
+ /* Initialise the port settings */
+ memcpy(&tp, &serial_termios, sizeof(struct termios));
+
+ /* Set port settings for canonical input processing */
+ tp.c_cflag = B0 | CS8 | CLOCAL | CREAD;
+ if (__with_odd_parity) {
+ tp.c_cflag |= (PARENB | PARODD);
+ tp.c_iflag = 0;
+ } else
+ tp.c_iflag = IGNPAR;
+ if (__with_hw_handshake)
+ tp.c_cflag |= CRTSCTS;
+ else
+ tp.c_cflag &= ~CRTSCTS;
+
+ tp.c_oflag = 0;
+ tp.c_lflag = 0;
+ tp.c_cc[VMIN] = 1;
+ tp.c_cc[VTIME] = 0;
+
+ retcode = tcflush(fd, TCIFLUSH);
+ if (retcode == -1) {
+ perror("Gnokii serial_opendevice: tcflush");
+ serial_close(fd);
+ return (-1);
+ }
+
+ retcode = tcsetattr(fd, TCSANOW, &tp);
+ if (retcode == -1) {
+ perror("Gnokii serial_opendevice: tcsetattr");
+ serial_close(fd);
+ return (-1);
+ }
+
+ return fd;