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