fetch.h revision 60376
137535Sdes/*- 237535Sdes * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav 337535Sdes * All rights reserved. 437535Sdes * 537535Sdes * Redistribution and use in source and binary forms, with or without 637535Sdes * modification, are permitted provided that the following conditions 737535Sdes * are met: 837535Sdes * 1. Redistributions of source code must retain the above copyright 937535Sdes * notice, this list of conditions and the following disclaimer 1037535Sdes * in this position and unchanged. 1137535Sdes * 2. Redistributions in binary form must reproduce the above copyright 1237535Sdes * notice, this list of conditions and the following disclaimer in the 1337535Sdes * documentation and/or other materials provided with the distribution. 1437535Sdes * 3. The name of the author may not be used to endorse or promote products 1537535Sdes * derived from this software without specific prior written permission 1637535Sdes * 1737535Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1837535Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1937535Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2037535Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2137535Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2237535Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2337535Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2437535Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2537535Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2637535Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2737535Sdes * 2850476Speter * $FreeBSD: head/lib/libfetch/fetch.h 60376 2000-05-11 13:31:02Z des $ 2937535Sdes */ 3037535Sdes 3137535Sdes#ifndef _FETCH_H_INCLUDED 3237535Sdes#define _FETCH_H_INCLUDED 3337535Sdes 3440975Sdes#include <fetch_err.h> 3540975Sdes 3637535Sdes#define _LIBFETCH_VER "libfetch/1.0" 3737535Sdes 3837535Sdes#define URL_SCHEMELEN 16 3937535Sdes#define URL_USERLEN 256 4037535Sdes#define URL_PWDLEN 256 4137535Sdes 4240975Sdesstruct url { 4340975Sdes char scheme[URL_SCHEMELEN+1]; 4440975Sdes char user[URL_USERLEN+1]; 4540975Sdes char pwd[URL_PWDLEN+1]; 4640975Sdes char host[MAXHOSTNAMELEN+1]; 4740975Sdes int port; 4860376Sdes char *doc; 4960376Sdes off_t offset; 5060376Sdes size_t length; 5137535Sdes}; 5237535Sdes 5340975Sdesstruct url_stat { 5440975Sdes off_t size; 5541862Sdes time_t atime; 5641862Sdes time_t mtime; 5740975Sdes}; 5837535Sdes 5941989Sdesstruct url_ent { 6041989Sdes char name[MAXPATHLEN]; 6141989Sdes struct url_stat stat; 6241989Sdes}; 6341989Sdes 6437535Sdes/* FILE-specific functions */ 6540975SdesFILE *fetchGetFile(struct url *, char *); 6640975SdesFILE *fetchPutFile(struct url *, char *); 6740975Sdesint fetchStatFile(struct url *, struct url_stat *, char *); 6841989Sdesstruct url_ent *fetchListFile(struct url *, char *); 6937535Sdes 7037535Sdes/* HTTP-specific functions */ 7140975Sdeschar *fetchContentType(FILE *); 7240975SdesFILE *fetchGetHTTP(struct url *, char *); 7340975SdesFILE *fetchPutHTTP(struct url *, char *); 7440975Sdesint fetchStatHTTP(struct url *, struct url_stat *, char *); 7541989Sdesstruct url_ent *fetchListHTTP(struct url *, char *); 7637535Sdes 7737535Sdes/* FTP-specific functions */ 7840975SdesFILE *fetchGetFTP(struct url *, char *); 7940975SdesFILE *fetchPutFTP(struct url *, char *); 8040975Sdesint fetchStatFTP(struct url *, struct url_stat *, char *); 8141989Sdesstruct url_ent *fetchListFTP(struct url *, char *); 8237535Sdes 8337535Sdes/* Generic functions */ 8440975SdesFILE *fetchGetURL(char *, char *); 8540975SdesFILE *fetchPutURL(char *, char *); 8640975Sdesint fetchStatURL(char *, struct url_stat *, char *); 8741989Sdesstruct url_ent *fetchListURL(char *, char *); 8840975SdesFILE *fetchGet(struct url *, char *); 8940975SdesFILE *fetchPut(struct url *, char *); 9040975Sdesint fetchStat(struct url *, struct url_stat *, char *); 9141989Sdesstruct url_ent *fetchList(struct url *, char *); 9237535Sdes 9360376Sdes/* URL parsing */ 9460376Sdesstruct url *fetchParseURL(char *); 9560376Sdesvoid fetchFreeURL(struct url *); 9660376Sdes 9741862Sdes/* Last error code */ 9841862Sdesextern int fetchLastErrCode; 9955557Sdesextern int fetchTimeout; 10041862Sdes 10137535Sdes#endif 102