"Fossies" - the Fresh Open Source Software Archive

Member "sitecopy-0.16.6/src/frontend.h" (9 Jul 2008, 5680 Bytes) of archive /linux/www/sitecopy-0.16.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "frontend.h" see the Fossies "Dox" file reference documentation.

    1 /* 
    2    sitecopy, manage remote web sites.
    3    Copyright (C) 1998-2008, 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 /* You MUST implement all of the below functions in the front end.
   21  * After a site_update call, for each file which is being updated
   22  * the following calls are made:
   23  *   if (fe_can_update(file))  {
   24  *       fe_updating(file);
   25  *       fe_updated(file, true, NULL) if the update was successful, or
   26  *       fe_updated(file, false, "error message") otherwise.
   27  *   }
   28  * Similarly for site_synch calls.
   29  * If fe_can_updated(file) returns false, the update of that file
   30  * will not continue.
   31  *
   32  * During a file transfer, whenever a block is written to the remote
   33  * site, fe_transfer_progress(bytes_transferred, bytes_total) is 
   34  * called. In other words, for a 10k file, the calls might be:
   35  *  fe_t_p(1024, 10240), fe_t_p(2048, 10240),
   36  *  fe_t_p(3072, 10240) ... fe_t_p(10240, 10240)
   37  * File transfers occur in site_update and site_synch, when uploading
   38  * and downloading files, respectively.
   39  */
   40 
   41 #ifndef FRONTEND_H
   42 #define FRONTEND_H
   43 
   44 #include <ne_ssl.h>
   45 #include <ne_auth.h>
   46 
   47 #include "common.h"
   48 #include "sites.h"
   49 
   50 typedef enum {
   51     fe_namelookup,
   52     fe_connecting,
   53     fe_connected
   54 } fe_status;
   55 
   56 /* Connection Status API.
   57  *
   58  * fe_connection() is called to indicate what state the connection is
   59  * in. Note, the status may bounce between fe_connected and
   60  * fe_connecting many times during an operation - especially if
   61  * connected to a WebDAV server which doesn't implement HTTP/1.1
   62  * persistent connections.
   63  * info will indicate the hostname being looked up for fe_namelookup,
   64  * and will be NULL otherwise.
   65  */
   66 void fe_connection(fe_status status, const char *info);
   67 
   68 /* The user is required to authenticate themselves for given context,
   69  * in the given realm on the given hostname.
   70  * (The Netscape UI for this is: "Enter username for REALM at HOSTNAME:")
   71  * realm will be NULL for non-HTTP protocols, so the UI might be better as:
   72  *  "Enter username for HOSTNAME:" or whatever...
   73  * Must return:
   74  *    0:  Success: 
   75  *       *username must be non-NULL and *password must be non-NULL,
   76  *       malloc()-allocated memory. The FE MUST NOT free them ever.
   77  * non-zero: User cancelled operation. *username and *password ignored,
   78  * and never free()'d if non-NULL.
   79  */
   80 
   81 typedef enum {
   82     fe_login_server,
   83     fe_login_proxy
   84 } fe_login_context;
   85 
   86 #define FE_LBUFSIZ NE_ABUFSIZ
   87 
   88 /* Enter username/password; username and password are fixed-size
   89  * buffers of size FE_LBUFSIZ. The username field may be pre-filled
   90  * by the username from the rcfile; otherwise username[0] == '\0'.
   91  * Contents of password are undefined. */
   92 int fe_login(fe_login_context ctx, const char *realm, const char *hostname,
   93          char *username, char *password);
   94 
   95 /* Return zero if the given server certificate 'cert', which had a
   96  * failures mask of 'failures' (NE_SSL_*), should be accepted. */
   97 int fe_accept_cert(const ne_ssl_certificate *cert, int failures);
   98 
   99 /* Enter password needed to decrypt given client certificate.  Returns
  100  * zero on success, non-zero on failure.  'password' is of size
  101  * FE_LBUFSIZ. */
  102 int fe_decrypt_clicert(const ne_ssl_client_cert *cert, char *password);
  103 
  104 int fe_can_update(const struct site_file *file);
  105 void fe_updating(const struct site_file *file);
  106 void fe_updated(const struct site_file *file, int success, const char *error);
  107 
  108 /* Also called during updates: */
  109 void fe_setting_perms(const struct site_file *file);
  110 void fe_set_perms(const struct site_file *file, int success, const char *error);
  111 
  112 /* For synch mode */
  113 void fe_synching(const struct site_file *file);
  114 void fe_synched(const struct site_file *file, int success, const char *error);
  115 
  116 /* For synch and update modes... */
  117 void fe_transfer_progress(ne_off_t progress, ne_off_t total);
  118 
  119 /* Called while checksumming remote files, in fetch mode.
  120  * Note, these are just filenames not site_file *'s, because at the
  121  * checksumming state, we haven't yet modified the files list. */
  122 void fe_checksumming(const char *filename);
  123 void fe_checksummed(const char *filename, int success, const char *error);
  124 
  125 
  126 /* For fetch mode - called for each file found remotely */
  127 void fe_fetch_found(const struct site_file *file);
  128 
  129 /* To display a non-fatal warning message to the user. 
  130  * description is the user-friendly description of the warning,
  131  * subject is typically the filename 
  132  * reason is the low-level error message.
  133  * description may contain newlines (\n), but will not have a trailing 
  134  * new-line.
  135  * subject and reason will not contain newlines.
  136  * reason and/or reason may be NULL.
  137  */
  138 void fe_warning(const char *description, const char *subject,
  139                 const char *error);
  140 
  141 /* Verified - whether the remote file matches or not... 
  142  match will be one of file_new, file_deleted, file_changed, file_unchanged.
  143  (NOT file_moved yet)
  144 */
  145 
  146 void fe_verified(const char *fname, enum file_diff match);
  147 
  148 #endif /* FRONTEND_H */