1 /* 2 sitecopy, remote web site copy manager. 3 Copyright (C) 1998-2002, Joe Orton <joe@manyfish.co.uk> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 */ 19 20 #ifndef RCFILE_H 21 #define RCFILE_H 22 23 #include "sites.h" 24 25 /* You MUST call the initialization functions in this order: 26 * 27 * init_env() - sets up rcfile, copypath etc global vars. 28 * init_paths() - checks the rcfile permissions etc 29 * init_netrc() - read the netrc if there is one 30 * rcfile_read() - read the rcfile 31 */ 32 33 /* Filename of rcfile stored here */ 34 extern char *rcfile; 35 /* Filename of directory used to store info files */ 36 extern char *copypath; 37 38 /* rcfile_read: 39 * Read the rcfile, filling the list pointed to by sites. 40 * Returns 0 on success, or: 41 * RC_OPENFILE if the rcfile could not be opened 42 * RC_CORRUPT if the rcfile is not of valid syntax 43 * When RC_CORRUPT is returned, then 44 * rcfile_linenum is set to the line at which parsing stopped. 45 * rcfile_err is set to the contents of that line. 46 * When RC_OPENFILE is returned, 47 * rcfile_err is set to the strerror(errno) 48 */ 49 extern int rcfile_linenum; 50 extern char *rcfile_err; 51 52 int rcfile_read(struct site **sites); 53 54 /* Check the permission of the rcfile and storage directory. 55 * Returns 0 on success, or: 56 * RC_OPENFILE if the rcfile could not be stat'ed 57 * RC_DIROPEN if the direcory could not be stat'ed 58 * RC_PERMS if the rcfile had invalid permissions 59 * RC_DIRPERMS if the directory had invalid permissions 60 * RC_NETRCPERMS if the netrcfile had invalid permissions 61 */ 62 int init_paths(void); 63 64 /* Initialize the rcfile, copypath, netrcfile variables from the 65 * environment. 66 * Returns 0 on success or 1 if the copypath 67 */ 68 int init_env(void); 69 70 /* Read in the netrc file. 71 * Return 0 on success or 1 if the .netrc could not be parsed. 72 */ 73 int init_netrc(void); 74 75 /* Verify that the given site entry is correct, and fill in 76 * missing bits as necessary (e.g. password from netrc, default 77 * Returns 0 on success, or: 78 * SITE_UNSUPPORTED if the protocol is not supported 79 * SITE_NOSERVER if no server name has been specified 80 * SITE_NOREMOTEDIR if no remote directory has been specified 81 * SITE_NOLOCALDIR if no local directory has been specified 82 * SITE_ACCESSLOCALDIR if the local directory is not readable 83 * SITE_INVALIDPORT if an invalid port name has been specified 84 * SITE_NOMAINTAIN if the proto driver doesn't support symlink maintain mode 85 * SITE_NOREMOTEREL if the proto driver doesn't allow relative remote dirs 86 * SITE_NOPERMS if the proto driver doesn't support permissions 87 * SITE_NOLOCALREL if a local relative dir could not be used 88 * SITE_NOSAFEOVER if they used nooverwrite mode and safe mode 89 * SITE_NOSAFETEMPUP if they used tempupload and safe mode 90 * SITE_NORENAMES if they want renames + not using state checksum 91 */ 92 int rcfile_verify(struct site *any_site); 93 94 /* Writes the given sites list into the given rcfile. 95 * This overwrites any previous contents of filename. 96 * Returns 0 on success, or: 97 * RC_OPENFILE if the file could not be opened for writing 98 * RC_PERMS if the file permissions could not be set 99 * RC_CORRUPT if there were errors while writing to the file 100 */ 101 int rcfile_write (char *filename, struct site *list_of_sites); 102 103 /* Constants */ 104 105 #define RC_OPENFILE 900 106 #define RC_CORRUPT 901 107 #define RC_PERMS 902 108 #define RC_DIRPERMS 903 109 #define RC_DIROPEN 904 110 #define RC_NETRCOPEN 905 111 #define RC_NETRCPERMS 906 112 113 #define SITE_NOSITE 901 114 #define SITE_NONAME 920 115 #define SITE_NOSERVER 921 116 #define SITE_NOREMOTEDIR 924 117 #define SITE_NOLOCALDIR 925 118 #define SITE_ACCESSLOCALDIR 926 119 #define SITE_INVALIDPORT 927 120 #define SITE_NOMAINTAIN 928 121 #define SITE_NOREMOTEREL 929 122 #define SITE_NOLOCALREL 930 123 #define SITE_NOPERMS 931 124 #define SITE_NOSAFEOVER 932 125 #define SITE_NORENAMES 933 126 #define SITE_NOSAFETEMPUP 934 127 #define SITE_NOSERVERCERT 935 128 129 #endif /* RCFILE_H */ 130