/[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

Annotation of /sourceforge.net/trunk/rdesktop/parallel.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 580 - (hide annotations)
Fri Jan 23 08:35:52 2004 UTC (20 years, 5 months ago) by astrand
File MIME type: text/plain
File size: 2600 byte(s)
Ran indent-all.sh

1 n-ki 569 #define MAX_PARALLEL_DEVICES 1
2    
3     #define FILE_DEVICE_PARALLEL 0x22
4    
5     #define IOCTL_PAR_QUERY_RAW_DEVICE_ID 0x0c
6    
7     #define PARALLELDEV0 "/dev/lp0"
8    
9     #include "rdesktop.h"
10     #include <unistd.h>
11     #include <fcntl.h>
12    
13     extern RDPDR_DEVICE g_rdpdr_device[];
14    
15 astrand 580 PARALLEL_DEVICE *
16     get_parallel_data(HANDLE handle)
17 n-ki 569 {
18     int index;
19    
20     for (index = 0; index < RDPDR_MAX_DEVICES; index++)
21     {
22     if (handle == g_rdpdr_device[index].handle)
23     return (PARALLEL_DEVICE *) g_rdpdr_device[index].pdevice_data;
24     }
25     return NULL;
26     }
27    
28    
29     /* Enumeration of devices from rdesktop.c */
30     /* returns numer of units found and initialized. */
31     /* optarg looks like ':LPT1=/dev/lp0' */
32     /* when it arrives to this function. */
33     int
34     parallel_enum_devices(int *id, char *optarg)
35     {
36     //TODO: Read from configuration file? CUPS?
37     PARALLEL_DEVICE *ppar_info;
38    
39     char *pos = optarg;
40     char *pos2;
41     int count = 0;
42    
43     // skip the first colon
44     optarg++;
45     while ((pos = next_arg(optarg, ',')) && *id < RDPDR_MAX_DEVICES)
46     {
47     ppar_info = (PARALLEL_DEVICE *) xmalloc(sizeof(PARALLEL_DEVICE));
48    
49     pos2 = next_arg(optarg, '=');
50     strcpy(g_rdpdr_device[*id].name, optarg);
51    
52 stargo 570 toupper_str(g_rdpdr_device[*id].name);
53 n-ki 569
54     g_rdpdr_device[*id].local_path = xmalloc(strlen(pos2) + 1);
55     strcpy(g_rdpdr_device[*id].local_path, pos2);
56     printf("PARALLEL %s to %s\n", optarg, pos2);
57    
58     // set device type
59     g_rdpdr_device[*id].device_type = DEVICE_TYPE_PARALLEL;
60     g_rdpdr_device[*id].pdevice_data = (void *) ppar_info;
61     count++;
62     (*id)++;
63    
64     optarg = pos;
65     }
66     return count;
67     }
68    
69     static NTSTATUS
70     parallel_create(uint32 device_id, HANDLE * handle)
71     {
72     int parallel_fd;
73    
74     parallel_fd = open(PARALLELDEV0, O_WRONLY);
75     if (parallel_fd == -1)
76     return STATUS_ACCESS_DENIED;
77    
78     *handle = parallel_fd;
79     return STATUS_SUCCESS;
80     }
81    
82     static NTSTATUS
83     parallel_close(HANDLE handle)
84     {
85     close(handle);
86     return STATUS_SUCCESS;
87     }
88    
89     static NTSTATUS
90     parallel_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
91     {
92     *result = write(handle, data, length);
93     return STATUS_SUCCESS;
94     }
95    
96     static NTSTATUS
97     parallel_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
98     {
99     if ((request >> 16) != FILE_DEVICE_PARALLEL)
100     return STATUS_INVALID_PARAMETER;
101    
102     /* extract operation */
103     request >>= 2;
104     request &= 0xfff;
105    
106     printf("PARALLEL IOCTL %d: ", request);
107    
108     switch (request)
109     {
110     case IOCTL_PAR_QUERY_RAW_DEVICE_ID:
111    
112     default:
113    
114     printf("\n");
115     unimpl("UNKNOWN IOCTL %d\n", request);
116     }
117     return STATUS_SUCCESS;
118     }
119    
120     DEVICE_FNS parallel_fns = {
121     parallel_create,
122     parallel_close,
123     NULL,
124     parallel_write,
125     parallel_device_control
126     };

  ViewVC Help
Powered by ViewVC 1.1.26