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
|
/*
WebDAV / HTTP authoring client routines,
Copyright (C) 1998, 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 HTTPDAV_H
#define HTTPDAV_H
/* For fetch_list */
#include "protocol.h"
extern char http_error[];
/* Set by http_options to true if server is a WebDAV class 1 server */
extern bool http_webdav_server;
/* Set to false to bypass http_init OPTIONS check */
extern bool http_init_checks;
#define REQSIZ 2048
typedef enum {
http_body_buffer,
http_body_file,
http_body_none
} http_body_t;
/* This is called with each block of the response body, if len > 0.
* For the last block, it is called with len==0 */
typedef void (*http_request_body_read_t) (
void *userdata,
const char *buffer,
const size_t len );
/* This is called with each of the headers in the response */
typedef void (*http_request_hdrs_read_t) (
const char *name,
const char *value );
/* HTTP request information */
typedef struct {
/* Fill in these with http_req_init */
const char *method;
char *uri;
/* Fill in these yourself */
char headers[REQSIZ];
/* Set these if you want to send a request body */
http_body_t body;
FILE *body_file;
const char *body_buffer;
/* Set this is you want to read the response headers */
http_request_hdrs_read_t hdrs_callback;
/* Set this if you want to read the response body */
http_request_body_read_t body_callback;
/* If non-NULL, this will be set to the total size of the
* response body */
size_t *resp_body_size;
/* If non-NULL, passed as first parameter to body_callback */
void *body_callback_userdata;
/* We fill in these for you */
size_t body_size;
char *date;
/* You use this for the status response code */
int status;
int class; /* == status/100 */
} http_req_t;
/* Public Interface:
* Call:
* http_init( "/", "www.myhttpserver.com", 80, "myusername", "mypassword" );
* then any of the method functions, in any order
* http_put, http_delete, dav_move, dav_rmdir, dav_mkcol.
* lastly:
* http_finish( );
*/
int http_init( const char *remote_root, const char *hostname, const int port,
const char *username, const char *password );
int http_finish( void );
int http_head( const char *directory );
int http_options( const char *directory );
int http_put( const char *local, const char *remote, const bool ascii );
int http_delete( const char *filename );
int http_get( const char *local, const char *remote, const int remotesize,
const bool ascii );
int dav_move( const char *from, const char *to );
int dav_rmdir( const char *dirname );
int dav_mkcol( const char *dirname );
int dav_mkref( const char *refres, const char *target );
int dav_chref( const char *refres, const char *target );
int dav_rmref( const char *refres );
#ifdef HAVE_LIBEXPAT
int dav_fetch( const char *dirname, struct proto_file_t **files );
#endif
/* The request mechanism */
int http_request( http_req_t *req );
void http_request_init( http_req_t *req, const char *method, const char *uri );
void http_request_end( http_req_t *req );
#endif /* HTTPDAV_H */
|