| 1 | /* | 
|---|
| 2 | CIFSDD - dd for SMB. | 
|---|
| 3 | Declarations and administrivia. | 
|---|
| 4 |  | 
|---|
| 5 | Copyright (C) James Peach 2005-2006 | 
|---|
| 6 |  | 
|---|
| 7 | This program is free software; you can redistribute it and/or modify | 
|---|
| 8 | it under the terms of the GNU General Public License as published by | 
|---|
| 9 | the Free Software Foundation; either version 3 of the License, or | 
|---|
| 10 | (at your option) any later version. | 
|---|
| 11 |  | 
|---|
| 12 | This program is distributed in the hope that it will be useful, | 
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 15 | GNU General Public License for more details. | 
|---|
| 16 |  | 
|---|
| 17 | You should have received a copy of the GNU General Public License | 
|---|
| 18 | along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| 19 | */ | 
|---|
| 20 |  | 
|---|
| 21 | extern const char * const PROGNAME; | 
|---|
| 22 |  | 
|---|
| 23 | enum argtype | 
|---|
| 24 | { | 
|---|
| 25 | ARG_NUMERIC, | 
|---|
| 26 | ARG_SIZE, | 
|---|
| 27 | ARG_PATHNAME, | 
|---|
| 28 | ARG_BOOL, | 
|---|
| 29 | }; | 
|---|
| 30 |  | 
|---|
| 31 | struct argdef | 
|---|
| 32 | { | 
|---|
| 33 | const char *    arg_name; | 
|---|
| 34 | enum argtype    arg_type; | 
|---|
| 35 | const char *    arg_help; | 
|---|
| 36 |  | 
|---|
| 37 | union | 
|---|
| 38 | { | 
|---|
| 39 | bool            bval; | 
|---|
| 40 | uint64_t        nval; | 
|---|
| 41 | const char *    pval; | 
|---|
| 42 | } arg_val; | 
|---|
| 43 | }; | 
|---|
| 44 |  | 
|---|
| 45 | int set_arg_argv(const char * argv); | 
|---|
| 46 | void set_arg_val(const char * name, ...); | 
|---|
| 47 |  | 
|---|
| 48 | bool check_arg_bool(const char * name); | 
|---|
| 49 | uint64_t check_arg_numeric(const char * name); | 
|---|
| 50 | const char * check_arg_pathname(const char * name); | 
|---|
| 51 |  | 
|---|
| 52 | typedef bool (*dd_seek_func)(void * handle, uint64_t offset); | 
|---|
| 53 | typedef bool (*dd_read_func)(void * handle, uint8_t * buf, | 
|---|
| 54 | uint64_t wanted, uint64_t * actual); | 
|---|
| 55 | typedef bool (*dd_write_func)(void * handle, uint8_t * buf, | 
|---|
| 56 | uint64_t wanted, uint64_t * actual); | 
|---|
| 57 |  | 
|---|
| 58 | struct dd_stats_record | 
|---|
| 59 | { | 
|---|
| 60 | struct | 
|---|
| 61 | { | 
|---|
| 62 | uint64_t        fblocks;        /* Full blocks. */ | 
|---|
| 63 | uint64_t        pblocks;        /* Partial blocks. */ | 
|---|
| 64 | uint64_t        bytes;          /* Total bytes read. */ | 
|---|
| 65 | } in; | 
|---|
| 66 | struct | 
|---|
| 67 | { | 
|---|
| 68 | uint64_t        fblocks;        /* Full blocks. */ | 
|---|
| 69 | uint64_t        pblocks;        /* Partial blocks. */ | 
|---|
| 70 | uint64_t        bytes;          /* Total bytes written. */ | 
|---|
| 71 | } out; | 
|---|
| 72 | }; | 
|---|
| 73 |  | 
|---|
| 74 | extern struct dd_stats_record dd_stats; | 
|---|
| 75 |  | 
|---|
| 76 | struct dd_iohandle | 
|---|
| 77 | { | 
|---|
| 78 | dd_seek_func    io_seek; | 
|---|
| 79 | dd_read_func    io_read; | 
|---|
| 80 | dd_write_func   io_write; | 
|---|
| 81 | int             io_flags; | 
|---|
| 82 | }; | 
|---|
| 83 |  | 
|---|
| 84 | #define DD_END_OF_FILE          0x10000000 | 
|---|
| 85 |  | 
|---|
| 86 | #define DD_DIRECT_IO            0x00000001 | 
|---|
| 87 | #define DD_SYNC_IO              0x00000002 | 
|---|
| 88 | #define DD_WRITE                0x00000004 | 
|---|
| 89 | #define DD_OPLOCK               0x00000008 | 
|---|
| 90 |  | 
|---|
| 91 | struct smbcli_options; | 
|---|
| 92 | struct smbcli_session_options; | 
|---|
| 93 | struct tevent_context; | 
|---|
| 94 |  | 
|---|
| 95 | struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, | 
|---|
| 96 | struct tevent_context *ev, | 
|---|
| 97 | const char * path, | 
|---|
| 98 | const char **ports, | 
|---|
| 99 | uint64_t io_size, int options, | 
|---|
| 100 | const char *socket_options, | 
|---|
| 101 | struct smbcli_options *smb_options, | 
|---|
| 102 | struct smbcli_session_options *smb_session_options, | 
|---|
| 103 | struct smb_iconv_convenience *iconv_convenience, | 
|---|
| 104 | struct gensec_settings *gensec_settings); | 
|---|
| 105 | bool dd_fill_block(struct dd_iohandle * h, uint8_t * buf, | 
|---|
| 106 | uint64_t * buf_size, uint64_t need_size, uint64_t block_size); | 
|---|
| 107 | bool dd_flush_block(struct dd_iohandle * h, uint8_t * buf, | 
|---|
| 108 | uint64_t * buf_size, uint64_t block_size); | 
|---|
| 109 |  | 
|---|
| 110 | /* vim: set sw=8 sts=8 ts=8 tw=79 : */ | 
|---|