1 #ifndef __CMIOS9_IO_H
2 #define __CMIOS9_IO_H
3 /*
4 * Copyright (C) 2001, 2002, 2003, 2004, 2005  K. M. Indlekofer
5 *
6 * M.Indlekofer@fz-juelich.de
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22 
23 
24 
25 #ifdef WIN32
26 /* e.g. VC++ */
27 
28 #include "winlib_cmios9.h"
29 
30 #else /* !WIN32 */
31 /* e.g. UNIX-like systems or cygwin */
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <fcntl.h>
36 #include <sys/stat.h>
37 #include <sys/types.h>
38 #include <limits.h>
39 #include <unistd.h>
40 #include <strings.h>
41 #include <string.h>
42 #include <ctype.h>
43 #include <time.h>
44 
45 #endif /* !WIN32 */
46 
47 
48 
49 /* might need improved lseek and off_t to handle >=2GB */
50 #ifndef LSEEK
51 #define LSEEK lseek
52 #endif /* !LSEEK */
53 #ifndef OFF_T
54 #define OFF_T off_t
55 #endif /* !OFF_T */
56 
57 
58 
59 /* O_BINARY important for Windows-based systems (esp. cygwin or VC++) */
60 #ifndef O_BINARY
61 #define O_BINARY 0
62 #endif /* !O_BINARY */
63 
64 
65 
66 /* basic I/O */
67 /* device */
68 extern int readonly;
69 
70 /* default device I/O granularity */
71 #ifndef DEV_BLOCKSIZE
72 #define DEV_BLOCKSIZE 2048 /* XXX needed for CDROM drives, OK with others */
73 #endif
74 /* XXX if device size not integer multiples of DEV_BLOCKSIZE, */
75 /* we might get access-problems for data in last incomplete DEV_BLOCKSIZE chunk!!! */
76 
77 
78 
79 extern int readblock(int devdes,u_int blknr,void *buf,u_int bufsiz,u_int startsec,u_int totsize,u_int blksiz);
80 extern int writeblock(int devdes,u_int blknr,void *buf,u_int bufsiz,u_int startsec,u_int totsize,u_int blksiz);
81 extern int opendevice(char *devpath);
82 
83 
84 
85 #endif /* !__CMIOS9_IO_H */
86