/[rdesktop]/sourceforge.net/trunk/rdesktop/serial.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/serial.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1363 by astrand, Wed Aug 3 10:56:16 2005 UTC revision 1364 by jsorg71, Thu Jan 4 04:55:56 2007 UTC
# Line 2  Line 2 
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3    
4     Copyright (C) Matthew Chapman 1999-2005     Copyright (C) Matthew Chapman 1999-2005
5      
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.     (at your option) any later version.
10      
11     This program is distributed in the hope that it will be useful,     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# Line 150  Line 150 
150  extern RDPDR_DEVICE g_rdpdr_device[];  extern RDPDR_DEVICE g_rdpdr_device[];
151    
152  static SERIAL_DEVICE *  static SERIAL_DEVICE *
153  get_serial_info(NTHANDLE handle)  get_serial_info(RD_NTHANDLE handle)
154  {  {
155          int index;          int index;
156    
# Line 163  get_serial_info(NTHANDLE handle) Line 163  get_serial_info(NTHANDLE handle)
163  }  }
164    
165  static BOOL  static BOOL
166  get_termios(SERIAL_DEVICE * pser_inf, NTHANDLE serial_fd)  get_termios(SERIAL_DEVICE * pser_inf, RD_NTHANDLE serial_fd)
167  {  {
168          speed_t speed;          speed_t speed;
169          struct termios *ptermios;          struct termios *ptermios;
# Line 316  get_termios(SERIAL_DEVICE * pser_inf, NT Line 316  get_termios(SERIAL_DEVICE * pser_inf, NT
316  }  }
317    
318  static void  static void
319  set_termios(SERIAL_DEVICE * pser_inf, NTHANDLE serial_fd)  set_termios(SERIAL_DEVICE * pser_inf, RD_NTHANDLE serial_fd)
320  {  {
321          speed_t speed;          speed_t speed;
322    
# Line 553  serial_enum_devices(uint32 * id, char *o Line 553  serial_enum_devices(uint32 * id, char *o
553          return count;          return count;
554  }  }
555    
556  static NTSTATUS  static RD_NTSTATUS
557  serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition,  serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition,
558                uint32 flags_and_attributes, char *filename, NTHANDLE * handle)                uint32 flags_and_attributes, char *filename, RD_NTHANDLE * handle)
559  {  {
560          NTHANDLE serial_fd;          RD_NTHANDLE serial_fd;
561          SERIAL_DEVICE *pser_inf;          SERIAL_DEVICE *pser_inf;
562          struct termios *ptermios;          struct termios *ptermios;
563    
# Line 568  serial_create(uint32 device_id, uint32 a Line 568  serial_create(uint32 device_id, uint32 a
568          if (serial_fd == -1)          if (serial_fd == -1)
569          {          {
570                  perror("open");                  perror("open");
571                  return STATUS_ACCESS_DENIED;                  return RD_STATUS_ACCESS_DENIED;
572          }          }
573    
574          if (!get_termios(pser_inf, serial_fd))          if (!get_termios(pser_inf, serial_fd))
575          {          {
576                  printf("INFO: SERIAL %s access denied\n", g_rdpdr_device[device_id].name);                  printf("INFO: SERIAL %s access denied\n", g_rdpdr_device[device_id].name);
577                  fflush(stdout);                  fflush(stdout);
578                  return STATUS_ACCESS_DENIED;                  return RD_STATUS_ACCESS_DENIED;
579          }          }
580    
581          /* Store handle for later use */          /* Store handle for later use */
# Line 607  serial_create(uint32 device_id, uint32 a Line 607  serial_create(uint32 device_id, uint32 a
607    
608          pser_inf->read_total_timeout_constant = 5;          pser_inf->read_total_timeout_constant = 5;
609    
610          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
611  }  }
612    
613  static NTSTATUS  static RD_NTSTATUS
614  serial_close(NTHANDLE handle)  serial_close(RD_NTHANDLE handle)
615  {  {
616          int i = get_device_index(handle);          int i = get_device_index(handle);
617          if (i >= 0)          if (i >= 0)
618                  g_rdpdr_device[i].handle = 0;                  g_rdpdr_device[i].handle = 0;
619    
620          rdpdr_abort_io(handle, 0, STATUS_TIMEOUT);          rdpdr_abort_io(handle, 0, RD_STATUS_TIMEOUT);
621          close(handle);          close(handle);
622          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
623  }  }
624    
625  static NTSTATUS  static RD_NTSTATUS
626  serial_read(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)  serial_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
627  {  {
628          long timeout;          long timeout;
629          SERIAL_DEVICE *pser_inf;          SERIAL_DEVICE *pser_inf;
# Line 678  serial_read(NTHANDLE handle, uint8 * dat Line 678  serial_read(NTHANDLE handle, uint8 * dat
678                  hexdump(data, *result);                  hexdump(data, *result);
679  #endif  #endif
680    
681          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
682  }  }
683    
684  static NTSTATUS  static RD_NTSTATUS
685  serial_write(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)  serial_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
686  {  {
687          SERIAL_DEVICE *pser_inf;          SERIAL_DEVICE *pser_inf;
688    
# Line 695  serial_write(NTHANDLE handle, uint8 * da Line 695  serial_write(NTHANDLE handle, uint8 * da
695    
696          DEBUG_SERIAL(("serial_write length %d, offset %d result %d\n", length, offset, *result));          DEBUG_SERIAL(("serial_write length %d, offset %d result %d\n", length, offset, *result));
697    
698          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
699  }  }
700    
701  static NTSTATUS  static RD_NTSTATUS
702  serial_device_control(NTHANDLE handle, uint32 request, STREAM in, STREAM out)  serial_device_control(RD_NTHANDLE handle, uint32 request, STREAM in, STREAM out)
703  {  {
704          int flush_mask, purge_mask;          int flush_mask, purge_mask;
705          uint32 result, modemstate;          uint32 result, modemstate;
# Line 708  serial_device_control(NTHANDLE handle, u Line 708  serial_device_control(NTHANDLE handle, u
708          struct termios *ptermios;          struct termios *ptermios;
709    
710          if ((request >> 16) != FILE_DEVICE_SERIAL_PORT)          if ((request >> 16) != FILE_DEVICE_SERIAL_PORT)
711                  return STATUS_INVALID_PARAMETER;                  return RD_STATUS_INVALID_PARAMETER;
712    
713          pser_inf = get_serial_info(handle);          pser_inf = get_serial_info(handle);
714          ptermios = pser_inf->ptermios;          ptermios = pser_inf->ptermios;
# Line 904  serial_device_control(NTHANDLE handle, u Line 904  serial_device_control(NTHANDLE handle, u
904                          if (flush_mask != 0)                          if (flush_mask != 0)
905                                  tcflush(handle, flush_mask);                                  tcflush(handle, flush_mask);
906                          if (purge_mask & SERIAL_PURGE_TXABORT)                          if (purge_mask & SERIAL_PURGE_TXABORT)
907                                  rdpdr_abort_io(handle, 4, STATUS_CANCELLED);                                  rdpdr_abort_io(handle, 4, RD_STATUS_CANCELLED);
908                          if (purge_mask & SERIAL_PURGE_RXABORT)                          if (purge_mask & SERIAL_PURGE_RXABORT)
909                                  rdpdr_abort_io(handle, 3, STATUS_CANCELLED);                                  rdpdr_abort_io(handle, 3, RD_STATUS_CANCELLED);
910                          break;                          break;
911                  case SERIAL_WAIT_ON_MASK:                  case SERIAL_WAIT_ON_MASK:
912                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_WAIT_ON_MASK %X\n",                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_WAIT_ON_MASK %X\n",
# Line 918  serial_device_control(NTHANDLE handle, u Line 918  serial_device_control(NTHANDLE handle, u
918                                  out_uint32_le(out, result);                                  out_uint32_le(out, result);
919                                  break;                                  break;
920                          }                          }
921                          return STATUS_PENDING;                          return RD_STATUS_PENDING;
922                          break;                          break;
923                  case SERIAL_SET_BREAK_ON:                  case SERIAL_SET_BREAK_ON:
924                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_BREAK_ON\n"));                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_BREAK_ON\n"));
# Line 939  serial_device_control(NTHANDLE handle, u Line 939  serial_device_control(NTHANDLE handle, u
939                          break;                          break;
940                  default:                  default:
941                          unimpl("SERIAL IOCTL %d\n", request);                          unimpl("SERIAL IOCTL %d\n", request);
942                          return STATUS_INVALID_PARAMETER;                          return RD_STATUS_INVALID_PARAMETER;
943          }          }
944    
945          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
946  }  }
947    
948  BOOL  BOOL
949  serial_get_event(NTHANDLE handle, uint32 * result)  serial_get_event(RD_NTHANDLE handle, uint32 * result)
950  {  {
951          int index;          int index;
952          SERIAL_DEVICE *pser_inf;          SERIAL_DEVICE *pser_inf;
# Line 1044  serial_get_event(NTHANDLE handle, uint32 Line 1044  serial_get_event(NTHANDLE handle, uint32
1044    
1045  /* Read timeout for a given file descripter (device) when adding fd's to select() */  /* Read timeout for a given file descripter (device) when adding fd's to select() */
1046  BOOL  BOOL
1047  serial_get_timeout(NTHANDLE handle, uint32 length, uint32 * timeout, uint32 * itv_timeout)  serial_get_timeout(RD_NTHANDLE handle, uint32 length, uint32 * timeout, uint32 * itv_timeout)
1048  {  {
1049          int index;          int index;
1050          SERIAL_DEVICE *pser_inf;          SERIAL_DEVICE *pser_inf;

Legend:
Removed from v.1363  
changed lines
  Added in v.1364

  ViewVC Help
Powered by ViewVC 1.1.26