1 #ifndef _LIBBACKUPPCD_H 2 #define _LIBBACKUPPCD_H 1 3 /* 4 * Copyright (C) 2005 Roy Keene 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 20 * Author Information 21 * Roy Keene 22 * Planning Systems Inc 23 * Slidell, LA 24 * backuppcd-bugs@psislidell.com 25 */ 26 27 #include <unistd.h> 28 #include <backuppcd.h> 29 30 /* 31 * These define symbols to determine whether or not write() or send() should 32 * be used to transfer data to a descriptor. write() may not be usable on 33 * socket descriptors, and send() will never work for file descriptors. 34 */ 35 typedef enum { 36 BPC_MODE_WRITE, 37 BPC_MODE_SEND 38 } bpc_mode_t; 39 40 /* 41 * This structure is used to give access to file information from a GET or 42 * LIST operation. 43 */ 44 struct bpc_fileinfo { 45 backuppc_filetype_t type; 46 unsigned long long size; 47 unsigned char hash_md4[16]; 48 unsigned char hash_md5[16]; 49 unsigned char hash_bpc[16]; 50 unsigned char hash_sha1[20]; 51 time_t mtime; 52 time_t ctime; 53 long dev_major; 54 long dev_minor; 55 long uid; 56 long gid; 57 char owner_group[BPC_MAXPATH_LEN]; 58 char owner_user[BPC_MAXPATH_LEN]; 59 char linkdest[BPC_MAXPATH_LEN]; 60 char name[BPC_MAXPATH_LEN]; 61 int mode; 62 }; 63 64 /* 65 * The BPC_CONN type is used as a handle to represent an individual connection 66 * a BackupPCd Server. 67 */ 68 typedef struct bpc_conn BPC_CONN; 69 70 /* 71 * LibBackupPCd API 72 */ 73 74 /* 75 * Operations associated with connection management 76 */ 77 BPC_CONN *bpc_connect(const char *host, const int port, const char *username, const char *password); 78 int bpc_disconnect(BPC_CONN *handle); 79 80 /* 81 * Operations associated with authentication 82 */ 83 int bpc_auth(BPC_CONN *handle, const char *username, const char *password); 84 85 /* 86 * Operations associated with getting a listing of files 87 */ 88 int bpc_list_open(BPC_CONN *handle, const char *rootpath, const int recursive, backuppc_hashid_t hashalgo, const char *exclpat, const char *inclpat); 89 struct bpc_fileinfo *bpc_list(BPC_CONN *handle); 90 int bpc_list_close(BPC_CONN *handle); 91 92 /* 93 * Operations associated with transfering files 94 */ 95 int bpc_get_open(BPC_CONN *handle, const char *rootpath, const int recursive, backuppc_hashid_t hashalgo, const char *exclpat, const char *inclpat); 96 struct bpc_fileinfo *bpc_get_head(BPC_CONN *handle); 97 ssize_t bpc_get(BPC_CONN *handle, void *buf, size_t count); 98 int bpc_copy(BPC_CONN *handle, bpc_mode_t mode, int fd); 99 int bpc_copyfile(BPC_CONN *handle, struct bpc_fileinfo *src, const char *dest, int preserve); 100 int bpc_get_close(BPC_CONN *handle); 101 102 #endif |