1 /***************************************************************************
2  *                                                                         *
3  *    LIBDSK: General floppy and diskimage access library                  *
4  *    Copyright (C) 2001,2005  John Elliott <seasip.webmaster@gmail.com>       *
5  *                                                                         *
6  *    This library is free software; you can redistribute it and/or        *
7  *    modify it under the terms of the GNU Library General Public          *
8  *    License as published by the Free Software Foundation; either         *
9  *    version 2 of the License, or (at your option) any later version.     *
10  *                                                                         *
11  *    This library is distributed in the hope that it will be useful,      *
12  *    but WITHOUT ANY WARRANTY; without even the implied warranty of       *
13  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    *
14  *    Library General Public License for more details.                     *
15  *                                                                         *
16  *    You should have received a copy of the GNU Library General Public    *
17  *    License along with this library; if not, write to the Free           *
18  *    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,      *
19  *    MA 02111-1307, USA                                                   *
20  *                                                                         *
21  ***************************************************************************/
22 
23 /*  LibDsk remoting is handled much like compression; the DSK_DRIVER contains
24  *  a pointer to remoting instance data (dr_remote). This in turn has a
25  *  pointer to the remoting function table.
26  */
27 
28 typedef struct remote_data
29 {
30 	struct remote_class *rd_class;
31 /* rd_handle is a handle used by the remote end of the connection. Don't
32  * try to use it for local instance data. */
33 	unsigned rd_handle;
34 	unsigned *rd_functions;	/* Implemented functions */
35 	char *rd_name;		/* Remote system name */
36 	unsigned rd_testing;	/* Disable optimisations for testing? */
37 } REMOTE_DATA;
38 
39 typedef struct remote_class
40 {
41 	size_t rc_selfsize;	/* Size of associated remote_data */
42 
43 	const char *rc_name;	/* Short name of this protocol */
44 	const char *rc_desc;	/* Description of this protocol */
45 
46 	/* Open the _connection_ (not anything at the target end; the
47 	 * driver will then call dsk_r_open() or dsk_r_creat().) The
48 	 * filename passed in will be parsed, and nameout will be
49 	 * the name that should be passed to dsk_r_open() / dsk_r_creat().
50 	 */
51 	dsk_err_t (*rc_open)(DSK_PDRIVER pDriver, const char *name,
52 				char *nameout);
53 	/* Close the connection. */
54 	dsk_err_t (*rc_close)(DSK_PDRIVER pDriver);
55 
56 	/* Remote comms method. This must match the prototype of RPCFUNC
57 	 *
58 	 * Entered with:
59 	 * 	input    = bytes to send
60 	 * 	inp_len  = number of bytes to send
61 	 * 	output   = receive buffer
62 	 *	*out_len = max number of bytes to receive
63 	 *
64 	 *  Return
65 	 *  	output contains received bytes
66 	 *  	*out_len = number of received bytes
67 	 * */
68 	dsk_err_t (*rc_call)(DSK_PDRIVER pDriver, unsigned char *input,
69 		int inp_len, unsigned char *output, int *out_len);
70 } REMOTE_CLASS;
71 
72 
73 /* The 'remote' LibDsk driver: */
74 
75 dsk_err_t remote_open(DSK_DRIVER *self, const char *filename);
76 dsk_err_t remote_creat(DSK_DRIVER *self, const char *filename);
77 dsk_err_t remote_close(DSK_DRIVER *self);
78 dsk_err_t remote_read(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
79                               void *buf, dsk_pcyl_t cylinder,
80                               dsk_phead_t head, dsk_psect_t sector);
81 dsk_err_t remote_write(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
82                               const void *buf, dsk_pcyl_t cylinder,
83                               dsk_phead_t head, dsk_psect_t sector);
84 dsk_err_t remote_format(DSK_DRIVER *self, DSK_GEOMETRY *geom,
85                                 dsk_pcyl_t cylinder, dsk_phead_t head,
86                                 const DSK_FORMAT *format, unsigned char filler);
87 dsk_err_t remote_secid(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
88                                 dsk_pcyl_t cylinder, dsk_phead_t head,
89                                 DSK_FORMAT *result);
90 dsk_err_t remote_getgeom(DSK_DRIVER *self, DSK_GEOMETRY *geom);
91 dsk_err_t remote_status(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
92                       dsk_phead_t head, unsigned char *result);
93 
94 dsk_err_t remote_xseek(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
95 		dsk_pcyl_t cylinder, dsk_phead_t head);
96 
97 dsk_err_t remote_xread(DSK_DRIVER *self, const DSK_GEOMETRY *geom, void *buf,
98                       dsk_pcyl_t cylinder, dsk_phead_t head,
99 		      dsk_pcyl_t cyl_expected, dsk_phead_t head_expected,
100 		      dsk_psect_t sector, size_t sector_size, int *deleted);
101 
102 dsk_err_t remote_xwrite(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
103 			const void *buf,
104                       dsk_pcyl_t cylinder, dsk_phead_t head,
105 		      dsk_pcyl_t cyl_expected, dsk_phead_t head_expected,
106 			dsk_psect_t sector, size_t sector_size, int deleted);
107 
108 dsk_err_t remote_tread(DSK_DRIVER *self, const DSK_GEOMETRY *geom, void *buf,
109 		                     dsk_pcyl_t cylinder, dsk_phead_t head);
110 
111 dsk_err_t remote_xtread(DSK_DRIVER *self, const DSK_GEOMETRY *geom, void *buf,
112 		        dsk_pcyl_t cylinder, dsk_phead_t head,
113 		        dsk_pcyl_t cyl_expected, dsk_phead_t head_expected);
114 /* List driver-specific options */
115 dsk_err_t remote_option_enum(DSK_DRIVER *self, int idx, char **optname);
116 
117 /* Set a driver-specific option */
118 dsk_err_t remote_option_set(DSK_DRIVER *self, const char *optname, int value);
119 /* Get a driver-specific option */
120 dsk_err_t remote_option_get(DSK_DRIVER *self, const char *optname, int *value);
121 
122 dsk_err_t remote_trackids(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
123 			  dsk_pcyl_t cylinder, dsk_phead_t head,
124 			  dsk_psect_t *count, DSK_FORMAT **result);
125 
126 /* Read raw track, including sector headers */
127 dsk_err_t remote_rtread(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
128 		       void *buf, dsk_pcyl_t cylinder,  dsk_phead_t head,
129 		       int reserved, size_t *bufsize);
130 
131