OSDN Git Service

Add PuTTY 0.61 to contrib directory.
[ffftp/ffftp.git] / contrib / putty / PSFTP.H
diff --git a/contrib/putty/PSFTP.H b/contrib/putty/PSFTP.H
new file mode 100644 (file)
index 0000000..3e13887
--- /dev/null
@@ -0,0 +1,178 @@
+/*\r
+ * psftp.h: interface between psftp.c / scp.c and each\r
+ * platform-specific SFTP module.\r
+ */\r
+\r
+#include "int64.h"\r
+\r
+#ifndef PUTTY_PSFTP_H\r
+#define PUTTY_PSFTP_H\r
+\r
+/*\r
+ * psftp_getcwd returns the local current directory. The returned\r
+ * string must be freed by the caller.\r
+ */\r
+char *psftp_getcwd(void);\r
+\r
+/*\r
+ * psftp_lcd changes the local current directory. The return value\r
+ * is NULL on success, or else an error message which must be freed\r
+ * by the caller.\r
+ */\r
+char *psftp_lcd(char *newdir);\r
+\r
+/*\r
+ * Retrieve file times on a local file. Must return two unsigned\r
+ * longs in POSIX time_t format.\r
+ */\r
+void get_file_times(char *filename, unsigned long *mtime,\r
+                   unsigned long *atime);\r
+\r
+/*\r
+ * One iteration of the PSFTP event loop: wait for network data and\r
+ * process it, once.\r
+ */\r
+int ssh_sftp_loop_iteration(void);\r
+\r
+/*\r
+ * Read a command line for PSFTP from standard input. Caller must\r
+ * free.\r
+ * \r
+ * If `backend_required' is TRUE, should also listen for activity\r
+ * at the backend (rekeys, clientalives, unexpected closures etc)\r
+ * and respond as necessary, and if the backend closes it should\r
+ * treat this as a failure condition. If `backend_required' is\r
+ * FALSE, a back end is not (intentionally) active at all (e.g.\r
+ * psftp before an `open' command).\r
+ */\r
+char *ssh_sftp_get_cmdline(char *prompt, int backend_required);\r
+\r
+/*\r
+ * The main program in psftp.c. Called from main() in the platform-\r
+ * specific code, after doing any platform-specific initialisation.\r
+ */\r
+int psftp_main(int argc, char *argv[]);\r
+\r
+/*\r
+ * These functions are used by PSCP to transmit progress updates\r
+ * and error information to a GUI window managing it. This will\r
+ * probably only ever be supported on Windows, so these functions\r
+ * can safely be stubs on all other platforms.\r
+ */\r
+void gui_update_stats(char *name, unsigned long size,\r
+                     int percentage, unsigned long elapsed,\r
+                     unsigned long done, unsigned long eta,\r
+                     unsigned long ratebs);\r
+void gui_send_errcount(int list, int errs);\r
+void gui_send_char(int is_stderr, int c);\r
+void gui_enable(char *arg);\r
+\r
+/*\r
+ * It's likely that a given platform's implementation of file\r
+ * transfer utilities is going to want to do things with them that\r
+ * aren't present in stdio. Hence we supply an alternative\r
+ * abstraction for file access functions.\r
+ * \r
+ * This abstraction tells you the size and access times when you\r
+ * open an existing file (platforms may choose the meaning of the\r
+ * file times if it's not clear; whatever they choose will be what\r
+ * PSCP sends to the server as mtime and atime), and lets you set\r
+ * the times when saving a new file.\r
+ * \r
+ * On the other hand, the abstraction is pretty simple: it supports\r
+ * only opening a file and reading it, or creating a file and writing\r
+ * it. None of this read-and-write, seeking-back-and-forth stuff.\r
+ */\r
+typedef struct RFile RFile;\r
+typedef struct WFile WFile;\r
+/* Output params size, mtime and atime can all be NULL if desired */\r
+RFile *open_existing_file(char *name, uint64 *size,\r
+                         unsigned long *mtime, unsigned long *atime);\r
+WFile *open_existing_wfile(char *name, uint64 *size);\r
+/* Returns <0 on error, 0 on eof, or number of bytes read, as usual */\r
+int read_from_file(RFile *f, void *buffer, int length);\r
+/* Closes and frees the RFile */\r
+void close_rfile(RFile *f);\r
+WFile *open_new_file(char *name);\r
+/* Returns <0 on error, 0 on eof, or number of bytes written, as usual */\r
+int write_to_file(WFile *f, void *buffer, int length);\r
+void set_file_times(WFile *f, unsigned long mtime, unsigned long atime);\r
+/* Closes and frees the WFile */\r
+void close_wfile(WFile *f);\r
+/* Seek offset bytes through file */\r
+enum { FROM_START, FROM_CURRENT, FROM_END };\r
+int seek_file(WFile *f, uint64 offset, int whence);\r
+/* Get file position */\r
+uint64 get_file_posn(WFile *f);\r
+/*\r
+ * Determine the type of a file: nonexistent, file, directory or\r
+ * weird. `weird' covers anything else - named pipes, Unix sockets,\r
+ * device files, fish, badgers, you name it. Things marked `weird'\r
+ * will be skipped over in recursive file transfers, so the only\r
+ * real reason for not lumping them in with `nonexistent' is that\r
+ * it allows a slightly more sane error message.\r
+ */\r
+enum {\r
+    FILE_TYPE_NONEXISTENT, FILE_TYPE_FILE, FILE_TYPE_DIRECTORY, FILE_TYPE_WEIRD\r
+};\r
+int file_type(char *name);\r
+\r
+/*\r
+ * Read all the file names out of a directory.\r
+ */\r
+typedef struct DirHandle DirHandle;\r
+DirHandle *open_directory(char *name);\r
+/* The string returned from this will need freeing if not NULL */\r
+char *read_filename(DirHandle *dir);\r
+void close_directory(DirHandle *dir);\r
+\r
+/*\r
+ * Test a filespec to see whether it's a local wildcard or not.\r
+ * Return values:\r
+ * \r
+ *  - WCTYPE_WILDCARD (this is a wildcard).\r
+ *  - WCTYPE_FILENAME (this is a single file name).\r
+ *  - WCTYPE_NONEXISTENT (whichever it was, nothing of that name exists).\r
+ * \r
+ * Some platforms may choose not to support local wildcards when\r
+ * they come from the command line; in this case they simply never\r
+ * return WCTYPE_WILDCARD, but still test the file's existence.\r
+ * (However, all platforms will probably want to support wildcards\r
+ * inside the PSFTP CLI.)\r
+ */\r
+enum {\r
+    WCTYPE_NONEXISTENT, WCTYPE_FILENAME, WCTYPE_WILDCARD\r
+};\r
+int test_wildcard(char *name, int cmdline);\r
+\r
+/*\r
+ * Actually return matching file names for a local wildcard.\r
+ */\r
+typedef struct WildcardMatcher WildcardMatcher;\r
+WildcardMatcher *begin_wildcard_matching(char *name);\r
+/* The string returned from this will need freeing if not NULL */\r
+char *wildcard_get_filename(WildcardMatcher *dir);\r
+void finish_wildcard_matching(WildcardMatcher *dir);\r
+\r
+/*\r
+ * Vet a filename returned from the remote host, to ensure it isn't\r
+ * in some way malicious. The idea is that this function is applied\r
+ * to filenames returned from FXP_READDIR, which means we can panic\r
+ * if we see _anything_ resembling a directory separator.\r
+ * \r
+ * Returns TRUE if the filename is kosher, FALSE if dangerous.\r
+ */\r
+int vet_filename(char *name);\r
+\r
+/*\r
+ * Create a directory. Returns 0 on error, !=0 on success.\r
+ */\r
+int create_directory(char *name);\r
+\r
+/*\r
+ * Concatenate a directory name and a file name. The way this is\r
+ * done will depend on the OS.\r
+ */\r
+char *dir_file_cat(char *dir, char *file);\r
+\r
+#endif /* PUTTY_PSFTP_H */\r