/[rdesktop]/sourceforge.net/trunk/rdesktop/parallel.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/parallel.c

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

revision 1363 by astrand, Tue Aug 23 20:27:14 2005 UTC revision 1364 by jsorg71, Thu Jan 4 04:55:56 2007 UTC
# Line 1  Line 1 
1  /* -*- c-basic-offset: 8 -*-  /* -*- c-basic-offset: 8 -*-
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     Copyright (C) Matthew Chapman 1999-2005     Copyright (C) Matthew Chapman 1999-2005
4      
5     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
6     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
7     the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
# Line 11  Line 11 
11     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.     GNU General Public License for more details.
14      
15     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# Line 75  parallel_enum_devices(uint32 * id, char Line 75  parallel_enum_devices(uint32 * id, char
75          return count;          return count;
76  }  }
77    
78  static NTSTATUS  static RD_NTSTATUS
79  parallel_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition,  parallel_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition,
80                  uint32 flags, char *filename, NTHANDLE * handle)                  uint32 flags, char *filename, RD_NTHANDLE * handle)
81  {  {
82          int parallel_fd;          int parallel_fd;
83    
# Line 85  parallel_create(uint32 device_id, uint32 Line 85  parallel_create(uint32 device_id, uint32
85          if (parallel_fd == -1)          if (parallel_fd == -1)
86          {          {
87                  perror("open");                  perror("open");
88                  return STATUS_ACCESS_DENIED;                  return RD_STATUS_ACCESS_DENIED;
89          }          }
90    
91          /* all read and writes should be non blocking */          /* all read and writes should be non blocking */
# Line 101  parallel_create(uint32 device_id, uint32 Line 101  parallel_create(uint32 device_id, uint32
101    
102          *handle = parallel_fd;          *handle = parallel_fd;
103    
104          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
105  }  }
106    
107  static NTSTATUS  static RD_NTSTATUS
108  parallel_close(NTHANDLE handle)  parallel_close(RD_NTHANDLE handle)
109  {  {
110          int i = get_device_index(handle);          int i = get_device_index(handle);
111          if (i >= 0)          if (i >= 0)
112                  g_rdpdr_device[i].handle = 0;                  g_rdpdr_device[i].handle = 0;
113          close(handle);          close(handle);
114          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
115  }  }
116    
117  static NTSTATUS  static RD_NTSTATUS
118  parallel_read(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)  parallel_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
119  {  {
120          *result = read(handle, data, length);          *result = read(handle, data, length);
121          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
122  }  }
123    
124  static NTSTATUS  static RD_NTSTATUS
125  parallel_write(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)  parallel_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
126  {  {
127          int rc = STATUS_SUCCESS;          int rc = RD_STATUS_SUCCESS;
128    
129          int n = write(handle, data, length);          int n = write(handle, data, length);
130          if (n < 0)          if (n < 0)
# Line 137  parallel_write(NTHANDLE handle, uint8 * Line 137  parallel_write(NTHANDLE handle, uint8 *
137                  switch (errno)                  switch (errno)
138                  {                  {
139                          case EAGAIN:                          case EAGAIN:
140                                  rc = STATUS_DEVICE_OFF_LINE;                                  rc = RD_STATUS_DEVICE_OFF_LINE;
141                          case ENOSPC:                          case ENOSPC:
142                                  rc = STATUS_DEVICE_PAPER_EMPTY;                                  rc = RD_STATUS_DEVICE_PAPER_EMPTY;
143                          case EIO:                          case EIO:
144                                  rc = STATUS_DEVICE_OFF_LINE;                                  rc = RD_STATUS_DEVICE_OFF_LINE;
145                          default:                          default:
146                                  rc = STATUS_DEVICE_POWERED_OFF;                                  rc = RD_STATUS_DEVICE_POWERED_OFF;
147                  }                  }
148  #if defined(LPGETSTATUS)  #if defined(LPGETSTATUS)
149                  if (ioctl(handle, LPGETSTATUS, &status) == 0)                  if (ioctl(handle, LPGETSTATUS, &status) == 0)
# Line 157  parallel_write(NTHANDLE handle, uint8 * Line 157  parallel_write(NTHANDLE handle, uint8 *
157          return rc;          return rc;
158  }  }
159    
160  static NTSTATUS  static RD_NTSTATUS
161  parallel_device_control(NTHANDLE handle, uint32 request, STREAM in, STREAM out)  parallel_device_control(RD_NTHANDLE handle, uint32 request, STREAM in, STREAM out)
162  {  {
163          if ((request >> 16) != FILE_DEVICE_PARALLEL)          if ((request >> 16) != FILE_DEVICE_PARALLEL)
164                  return STATUS_INVALID_PARAMETER;                  return RD_STATUS_INVALID_PARAMETER;
165    
166          /* extract operation */          /* extract operation */
167          request >>= 2;          request >>= 2;
# Line 178  parallel_device_control(NTHANDLE handle, Line 178  parallel_device_control(NTHANDLE handle,
178                          printf("\n");                          printf("\n");
179                          unimpl("UNKNOWN IOCTL %d\n", request);                          unimpl("UNKNOWN IOCTL %d\n", request);
180          }          }
181          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
182  }  }
183    
184  DEVICE_FNS parallel_fns = {  DEVICE_FNS parallel_fns = {

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

  ViewVC Help
Powered by ViewVC 1.1.26