1 /* 2 * Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, 6 * with or without modification, are permitted provided 7 * that the following conditions are met: 8 * 9 * Redistributions of source code must retain the above 10 * copyright notice, this list of conditions and the 11 * following disclaimer. 12 * 13 * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials 16 * provided with the distribution. 17 * 18 * Neither the name of the copyright holder nor the names 19 * of any other contributors may be used to endorse or 20 * promote products derived from this software without 21 * specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 35 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 36 * OF SUCH DAMAGE. 37 */ 38 39 #ifndef LIBSSH2_MACROS_H_ 40 #define LIBSSH2_MACROS_H_ 41 42 #include "libssh2.h" 43 #include "libssh2_publickey.h" 44 #include "libssh2_sftp.h" 45 46 /* 47 * Dummy prototypes to generate wrapper procedures to C macros. 48 * This is a helper for languages without a clever preprocessor (ILE/RPG). 49 */ 50 51 LIBSSH2_API LIBSSH2_SESSION * libssh2_session_init(void); 52 LIBSSH2_API int libssh2_session_disconnect(LIBSSH2_SESSION *session, 53 const char *description); 54 LIBSSH2_API int libssh2_userauth_password(LIBSSH2_SESSION *session, 55 const char *username, 56 const char *password); 57 LIBSSH2_API int 58 libssh2_userauth_publickey_fromfile(LIBSSH2_SESSION *session, 59 const char *username, 60 const char *publickey, 61 const char *privatekey, 62 const char *passphrase); 63 LIBSSH2_API int 64 libssh2_userauth_hostbased_fromfile(LIBSSH2_SESSION *session, 65 const char *username, 66 const char *publickey, 67 const char *privatekey, 68 const char *passphrase, 69 const char *hostname); 70 LIBSSH2_API int 71 libssh2_userauth_keyboard_interactive(LIBSSH2_SESSION* session, 72 const char *username, 73 LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC( 74 (*response_callback))); 75 LIBSSH2_API LIBSSH2_CHANNEL * 76 libssh2_channel_open_session(LIBSSH2_SESSION *session); 77 LIBSSH2_API LIBSSH2_CHANNEL * 78 libssh2_channel_direct_tcpip(LIBSSH2_SESSION *session, const char *host, 79 int port); 80 LIBSSH2_API LIBSSH2_LISTENER * 81 libssh2_channel_forward_listen(LIBSSH2_SESSION *session, int port); 82 LIBSSH2_API int 83 libssh2_channel_setenv(LIBSSH2_CHANNEL *channel, 84 const char *varname, const char *value); 85 LIBSSH2_API int 86 libssh2_channel_request_pty(LIBSSH2_CHANNEL *channel, const char *term); 87 LIBSSH2_API int 88 libssh2_channel_request_pty_size(LIBSSH2_CHANNEL *channel, 89 int width, int height); 90 LIBSSH2_API int 91 libssh2_channel_x11_req(LIBSSH2_CHANNEL *channel, int screen_number); 92 LIBSSH2_API int 93 libssh2_channel_shell(LIBSSH2_CHANNEL *channel); 94 LIBSSH2_API int 95 libssh2_channel_exec(LIBSSH2_CHANNEL *channel, const char *command); 96 LIBSSH2_API int 97 libssh2_channel_subsystem(LIBSSH2_CHANNEL *channel, const char *subsystem); 98 LIBSSH2_API ssize_t 99 libssh2_channel_read(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen); 100 LIBSSH2_API ssize_t 101 libssh2_channel_read_stderr(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen); 102 LIBSSH2_API unsigned long 103 libssh2_channel_window_read(LIBSSH2_CHANNEL *channel); 104 LIBSSH2_API ssize_t 105 libssh2_channel_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t buflen); 106 LIBSSH2_API ssize_t 107 libssh2_channel_write_stderr(LIBSSH2_CHANNEL *channel, 108 const char *buf, size_t buflen); 109 LIBSSH2_API unsigned long 110 libssh2_channel_window_write(LIBSSH2_CHANNEL *channel); 111 LIBSSH2_API int libssh2_channel_flush(LIBSSH2_CHANNEL *channel); 112 LIBSSH2_API int libssh2_channel_flush_stderr(LIBSSH2_CHANNEL *channel); 113 LIBSSH2_API LIBSSH2_CHANNEL * 114 libssh2_scp_send(LIBSSH2_SESSION *session, 115 const char *path, int mode, libssh2_int64_t size); 116 117 LIBSSH2_API int 118 libssh2_publickey_add(LIBSSH2_PUBLICKEY *pkey, const unsigned char *name, 119 const unsigned char *blob, unsigned long blob_len, 120 char overwrite, unsigned long num_attrs, 121 const libssh2_publickey_attribute attrs[]); 122 LIBSSH2_API int 123 libssh2_publickey_remove(LIBSSH2_PUBLICKEY *pkey, const unsigned char *name, 124 const unsigned char *blob, unsigned long blob_len); 125 126 LIBSSH2_API int LIBSSH2_SFTP_S_ISLNK(unsigned long permissions); 127 LIBSSH2_API int LIBSSH2_SFTP_S_ISREG(unsigned long permissions); 128 LIBSSH2_API int LIBSSH2_SFTP_S_ISDIR(unsigned long permissions); 129 LIBSSH2_API int LIBSSH2_SFTP_S_ISCHR(unsigned long permissions); 130 LIBSSH2_API int LIBSSH2_SFTP_S_ISBLK(unsigned long permissions); 131 LIBSSH2_API int LIBSSH2_SFTP_S_ISFIFO(unsigned long permissions); 132 LIBSSH2_API int LIBSSH2_SFTP_S_ISSOCK(unsigned long permissions); 133 LIBSSH2_API LIBSSH2_SFTP_HANDLE * 134 libssh2_sftp_open(LIBSSH2_SFTP *sftp, const char *filename, 135 unsigned long flags, long mode); 136 LIBSSH2_API LIBSSH2_SFTP_HANDLE * 137 libssh2_sftp_opendir(LIBSSH2_SFTP *sftp, const char *path); 138 LIBSSH2_API int libssh2_sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, 139 char *buffer, size_t buffer_maxlen, 140 LIBSSH2_SFTP_ATTRIBUTES *attrs); 141 LIBSSH2_API int libssh2_sftp_close(LIBSSH2_SFTP_HANDLE *handle); 142 LIBSSH2_API int libssh2_sftp_closedir(LIBSSH2_SFTP_HANDLE *handle); 143 LIBSSH2_API void libssh2_sftp_rewind(LIBSSH2_SFTP_HANDLE *handle); 144 LIBSSH2_API int libssh2_sftp_fstat(LIBSSH2_SFTP_HANDLE *handle, 145 LIBSSH2_SFTP_ATTRIBUTES *attrs); 146 LIBSSH2_API int libssh2_sftp_fsetstat(LIBSSH2_SFTP_HANDLE *handle, 147 LIBSSH2_SFTP_ATTRIBUTES *attrs); 148 LIBSSH2_API int libssh2_sftp_rename(LIBSSH2_SFTP *sftp, 149 const char *source_filename, 150 const char *dest_filename); 151 LIBSSH2_API int libssh2_sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename); 152 LIBSSH2_API int libssh2_sftp_mkdir(LIBSSH2_SFTP *sftp, 153 const char *path, long mode); 154 LIBSSH2_API int libssh2_sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path); 155 LIBSSH2_API int libssh2_sftp_stat(LIBSSH2_SFTP *sftp, const char *path, 156 LIBSSH2_SFTP_ATTRIBUTES *attrs); 157 LIBSSH2_API int libssh2_sftp_lstat(LIBSSH2_SFTP *sftp, const char *path, 158 LIBSSH2_SFTP_ATTRIBUTES *attrs); 159 LIBSSH2_API int libssh2_sftp_setstat(LIBSSH2_SFTP *sftp, const char *path, 160 LIBSSH2_SFTP_ATTRIBUTES *attrs); 161 LIBSSH2_API int libssh2_sftp_symlink(LIBSSH2_SFTP *sftp, const char *orig, 162 char *linkpath); 163 LIBSSH2_API int libssh2_sftp_readlink(LIBSSH2_SFTP *sftp, const char *path, 164 char *target, unsigned int maxlen); 165 LIBSSH2_API int libssh2_sftp_realpath(LIBSSH2_SFTP *sftp, const char *path, 166 char *target, unsigned int maxlen); 167 168 #endif 169