home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckosftp.h < prev    next >
C/C++ Source or Header  |  2020-01-01  |  12KB  |  310 lines

  1. /*    $OpenBSD: sftp-common.h,v 1.4 2002/09/11 22:41:50 djm Exp $    */
  2.  
  3. /*
  4.  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
  5.  * Copyright (c) 2001 Damien Miller.  All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in the
  14.  *    documentation and/or other materials provided with the distribution.
  15.  *
  16.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26.  */
  27.  
  28. typedef struct Attrib Attrib;
  29.  
  30. /* File attributes */
  31. struct Attrib {
  32.     u_int32_t    flags;
  33.     u_int64_t    size;
  34.     u_int32_t    uid;
  35.     u_int32_t    gid;
  36.     u_int32_t    perm;
  37.     u_int32_t    atime;
  38.     u_int32_t    mtime;
  39. };
  40.  
  41. void     attrib_clear(Attrib *);
  42. void     stat_to_attrib(struct _stat *, Attrib *);
  43. void     attrib_to_stat(Attrib *, struct _stat *);
  44. Attrib    *decode_attrib(Buffer *);
  45. void     encode_attrib(Buffer *, Attrib *);
  46. char    *ls_file(char *, struct _stat *, int);
  47.  
  48. const char *fx2txt(int);
  49. /* $OpenBSD: sftp-glob.h,v 1.8 2002/09/11 22:41:50 djm Exp $ */
  50.  
  51. /*
  52.  * Copyright (c) 2001,2002 Damien Miller.  All rights reserved.
  53.  *
  54.  * Redistribution and use in source and binary forms, with or without
  55.  * modification, are permitted provided that the following conditions
  56.  * are met:
  57.  * 1. Redistributions of source code must retain the above copyright
  58.  *    notice, this list of conditions and the following disclaimer.
  59.  * 2. Redistributions in binary form must reproduce the above copyright
  60.  *    notice, this list of conditions and the following disclaimer in the
  61.  *    documentation and/or other materials provided with the distribution.
  62.  *
  63.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  64.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  65.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  66.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  67.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  68.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  69.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  70.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  71.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  72.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  73.  */
  74.  
  75. /* Remote sftp filename globbing */
  76.  
  77. #ifndef _SFTP_GLOB_H
  78. #define _SFTP_GLOB_H
  79.  
  80. int remote_glob(struct sftp_conn *, const char *, int,
  81.     int (*)(const char *, int), glob_t *);
  82.  
  83. #endif
  84. /* $OpenBSD: sftp-client.h,v 1.11 2002/09/11 22:41:50 djm Exp $ */
  85.  
  86. /*
  87.  * Copyright (c) 2001,2002 Damien Miller.  All rights reserved.
  88.  *
  89.  * Redistribution and use in source and binary forms, with or without
  90.  * modification, are permitted provided that the following conditions
  91.  * are met:
  92.  * 1. Redistributions of source code must retain the above copyright
  93.  *    notice, this list of conditions and the following disclaimer.
  94.  * 2. Redistributions in binary form must reproduce the above copyright
  95.  *    notice, this list of conditions and the following disclaimer in the
  96.  *    documentation and/or other materials provided with the distribution.
  97.  *
  98.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  99.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  100.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  101.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  102.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  103.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  104.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  105.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  106.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  107.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  108.  */
  109.  
  110. /* Client side of SSH2 filexfer protocol */
  111.  
  112. #ifndef _SFTP_CLIENT_H
  113. #define _SFTP_CLIENT_H
  114.  
  115. typedef struct SFTP_DIRENT SFTP_DIRENT;
  116.  
  117. struct SFTP_DIRENT {
  118.     char *filename;
  119.     char *longname;
  120.     Attrib a;
  121. };
  122.  
  123. /*
  124.  * Initialiase a SSH filexfer connection. Returns -1 on error or
  125.  * protocol version on success.
  126.  */
  127. struct sftp_conn *do_init(u_int, u_int);
  128.  
  129. u_int sftp_proto_version(struct sftp_conn *);
  130.  
  131. /* Close file referred to by 'handle' */
  132. int do_close(struct sftp_conn *, char *, u_int);
  133.  
  134. /* Read contents of 'path' to NULL-terminated array 'dir' */
  135. int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***);
  136.  
  137. /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
  138. void free_sftp_dirents(SFTP_DIRENT **);
  139.  
  140. /* Delete file 'path' */
  141. int do_rm(struct sftp_conn *, char *);
  142.  
  143. /* Create directory 'path' */
  144. int do_mkdir(struct sftp_conn *, char *, Attrib *);
  145.  
  146. /* Remove directory 'path' */
  147. int do_rmdir(struct sftp_conn *, char *);
  148.  
  149. /* Get file attributes of 'path' (follows symlinks) */
  150. Attrib *do_stat(struct sftp_conn *, char *, int);
  151.  
  152. /* Get file attributes of 'path' (does not follow symlinks) */
  153. Attrib *do_lstat(struct sftp_conn *, char *, int);
  154.  
  155. /* Get file attributes of open file 'handle' */
  156. Attrib *do_fstat(struct sftp_conn *, char *, u_int, int);
  157.  
  158. /* Set file attributes of 'path' */
  159. int do_setstat(struct sftp_conn *, char *, Attrib *);
  160.  
  161. /* Set file attributes of open file 'handle' */
  162. int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *);
  163.  
  164. /* Canonicalise 'path' - caller must free result */
  165. char *do_realpath(struct sftp_conn *, char *);
  166.  
  167. /* Rename 'oldpath' to 'newpath' */
  168. int do_rename(struct sftp_conn *, char *, char *);
  169.  
  170. /* Rename 'oldpath' to 'newpath' */
  171. int do_symlink(struct sftp_conn *, char *, char *);
  172.  
  173. /* Return target of symlink 'path' - caller must free result */
  174. char *do_readlink(struct sftp_conn *, char *);
  175.  
  176. /* XXX: add callbacks to do_download/do_upload so we can do progress meter */
  177.  
  178. /*
  179.  * Download 'remote_path' to 'local_path'. Preserve permissions and times
  180.  * if 'pflag' is set
  181.  */
  182. int do_download(struct sftp_conn *, char *, char *, int);
  183.  
  184. /*
  185.  * Upload 'local_path' to 'remote_path'. Preserve permissions and times
  186.  * if 'pflag' is set
  187.  */
  188. int do_upload(struct sftp_conn *, char *, char *, int);
  189.  
  190. #endif
  191. /* $OpenBSD: sftp-int.h,v 1.6 2003/01/08 23:53:26 djm Exp $ */
  192.  
  193. /*
  194.  * Copyright (c) 2001,2002 Damien Miller.  All rights reserved.
  195.  *
  196.  * Redistribution and use in source and binary forms, with or without
  197.  * modification, are permitted provided that the following conditions
  198.  * are met:
  199.  * 1. Redistributions of source code must retain the above copyright
  200.  *    notice, this list of conditions and the following disclaimer.
  201.  * 2. Redistributions in binary form must reproduce the above copyright
  202.  *    notice, this list of conditions and the following disclaimer in the
  203.  *    documentation and/or other materials provided with the distribution.
  204.  *
  205.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  206.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  207.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  208.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  209.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  210.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  211.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  212.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  213.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  214.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  215.  */
  216.  
  217. int     interactive_loop(int, int, char *, char *);
  218. /*    $OpenBSD: sftp.h,v 1.4 2002/02/13 00:59:23 djm Exp $    */
  219.  
  220. /*
  221.  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
  222.  *
  223.  * Redistribution and use in source and binary forms, with or without
  224.  * modification, are permitted provided that the following conditions
  225.  * are met:
  226.  * 1. Redistributions of source code must retain the above copyright
  227.  *    notice, this list of conditions and the following disclaimer.
  228.  * 2. Redistributions in binary form must reproduce the above copyright
  229.  *    notice, this list of conditions and the following disclaimer in the
  230.  *    documentation and/or other materials provided with the distribution.
  231.  *
  232.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  233.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  234.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  235.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  236.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  237.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  238.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  239.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  240.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  241.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  242.  */
  243.  
  244. /*
  245.  * draft-ietf-secsh-filexfer-01.txt
  246.  */
  247.  
  248. /* version */
  249. #define    SSH2_FILEXFER_VERSION        3
  250.  
  251. /* client to server */
  252. #define SSH2_FXP_INIT            1
  253. #define SSH2_FXP_OPEN            3
  254. #define SSH2_FXP_CLOSE            4
  255. #define SSH2_FXP_READ            5
  256. #define SSH2_FXP_WRITE            6
  257. #define SSH2_FXP_LSTAT            7
  258. #define SSH2_FXP_STAT_VERSION_0        7
  259. #define SSH2_FXP_FSTAT            8
  260. #define SSH2_FXP_SETSTAT        9
  261. #define SSH2_FXP_FSETSTAT        10
  262. #define SSH2_FXP_OPENDIR        11
  263. #define SSH2_FXP_READDIR        12
  264. #define SSH2_FXP_REMOVE            13
  265. #define SSH2_FXP_MKDIR            14
  266. #define SSH2_FXP_RMDIR            15
  267. #define SSH2_FXP_REALPATH        16
  268. #define SSH2_FXP_STAT            17
  269. #define SSH2_FXP_RENAME            18
  270. #define SSH2_FXP_READLINK        19
  271. #define SSH2_FXP_SYMLINK        20
  272.  
  273. /* server to client */
  274. #define SSH2_FXP_VERSION        2
  275. #define SSH2_FXP_STATUS            101
  276. #define SSH2_FXP_HANDLE            102
  277. #define SSH2_FXP_DATA            103
  278. #define SSH2_FXP_NAME            104
  279. #define SSH2_FXP_ATTRS            105
  280.  
  281. #define SSH2_FXP_EXTENDED        200
  282. #define SSH2_FXP_EXTENDED_REPLY        201
  283.  
  284. /* attributes */
  285. #define SSH2_FILEXFER_ATTR_SIZE        0x00000001
  286. #define SSH2_FILEXFER_ATTR_UIDGID    0x00000002
  287. #define SSH2_FILEXFER_ATTR_PERMISSIONS    0x00000004
  288. #define SSH2_FILEXFER_ATTR_ACMODTIME    0x00000008
  289. #define SSH2_FILEXFER_ATTR_EXTENDED    0x80000000
  290.  
  291. /* portable open modes */
  292. #define SSH2_FXF_READ            0x00000001
  293. #define SSH2_FXF_WRITE            0x00000002
  294. #define SSH2_FXF_APPEND            0x00000004
  295. #define SSH2_FXF_CREAT            0x00000008
  296. #define SSH2_FXF_TRUNC            0x00000010
  297. #define SSH2_FXF_EXCL            0x00000020
  298.  
  299. /* status messages */
  300. #define SSH2_FX_OK            0
  301. #define SSH2_FX_EOF            1
  302. #define SSH2_FX_NO_SUCH_FILE        2
  303. #define SSH2_FX_PERMISSION_DENIED    3
  304. #define SSH2_FX_FAILURE            4
  305. #define SSH2_FX_BAD_MESSAGE        5
  306. #define SSH2_FX_NO_CONNECTION        6
  307. #define SSH2_FX_CONNECTION_LOST        7
  308. #define SSH2_FX_OP_UNSUPPORTED        8
  309. #define SSH2_FX_MAX            8
  310.