fetch.h revision 60924
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 60924 2000-05-25 16:24:31Z des $ 2937535Sdes */ 3037535Sdes 3137535Sdes#ifndef _FETCH_H_INCLUDED 3237535Sdes#define _FETCH_H_INCLUDED 3337535Sdes 3460924Sdes#define _LIBFETCH_VER "libfetch/2.0" 3540975Sdes 3637535Sdes#define URL_SCHEMELEN 16 3737535Sdes#define URL_USERLEN 256 3837535Sdes#define URL_PWDLEN 256 3937535Sdes 4040975Sdesstruct url { 4140975Sdes char scheme[URL_SCHEMELEN+1]; 4240975Sdes char user[URL_USERLEN+1]; 4340975Sdes char pwd[URL_PWDLEN+1]; 4440975Sdes char host[MAXHOSTNAMELEN+1]; 4540975Sdes int port; 4660376Sdes char *doc; 4760376Sdes off_t offset; 4860376Sdes size_t length; 4937535Sdes}; 5037535Sdes 5140975Sdesstruct url_stat { 5240975Sdes off_t size; 5341862Sdes time_t atime; 5441862Sdes time_t mtime; 5540975Sdes}; 5637535Sdes 5741989Sdesstruct url_ent { 5841989Sdes char name[MAXPATHLEN]; 5941989Sdes struct url_stat stat; 6041989Sdes}; 6141989Sdes 6260924Sdes/* Error codes */ 6360924Sdes#define FETCH_ABORT 1 6460924Sdes#define FETCH_AUTH 2 6560924Sdes#define FETCH_DOWN 3 6660924Sdes#define FETCH_EXISTS 4 6760924Sdes#define FETCH_FULL 5 6860924Sdes#define FETCH_INFO 6 6960924Sdes#define FETCH_MEMORY 7 7060924Sdes#define FETCH_MOVED 8 7160924Sdes#define FETCH_NETWORK 9 7260924Sdes#define FETCH_OK 10 7360924Sdes#define FETCH_PROTO 11 7460924Sdes#define FETCH_RESOLV 12 7560924Sdes#define FETCH_SERVER 13 7660924Sdes#define FETCH_TEMP 14 7760924Sdes#define FETCH_TIMEOUT 15 7860924Sdes#define FETCH_UNAVAIL 16 7960924Sdes#define FETCH_UNKNOWN 17 8060924Sdes#define FETCH_URL 18 8160924Sdes#define FETCH_VERBOSE 19 8260924Sdes 8337535Sdes/* FILE-specific functions */ 8440975SdesFILE *fetchGetFile(struct url *, char *); 8540975SdesFILE *fetchPutFile(struct url *, char *); 8640975Sdesint fetchStatFile(struct url *, struct url_stat *, char *); 8741989Sdesstruct url_ent *fetchListFile(struct url *, char *); 8837535Sdes 8937535Sdes/* HTTP-specific functions */ 9040975Sdeschar *fetchContentType(FILE *); 9140975SdesFILE *fetchGetHTTP(struct url *, char *); 9240975SdesFILE *fetchPutHTTP(struct url *, char *); 9340975Sdesint fetchStatHTTP(struct url *, struct url_stat *, char *); 9441989Sdesstruct url_ent *fetchListHTTP(struct url *, char *); 9537535Sdes 9637535Sdes/* FTP-specific functions */ 9740975SdesFILE *fetchGetFTP(struct url *, char *); 9840975SdesFILE *fetchPutFTP(struct url *, char *); 9940975Sdesint fetchStatFTP(struct url *, struct url_stat *, char *); 10041989Sdesstruct url_ent *fetchListFTP(struct url *, char *); 10137535Sdes 10237535Sdes/* Generic functions */ 10340975SdesFILE *fetchGetURL(char *, char *); 10440975SdesFILE *fetchPutURL(char *, char *); 10540975Sdesint fetchStatURL(char *, struct url_stat *, char *); 10641989Sdesstruct url_ent *fetchListURL(char *, char *); 10740975SdesFILE *fetchGet(struct url *, char *); 10840975SdesFILE *fetchPut(struct url *, char *); 10940975Sdesint fetchStat(struct url *, struct url_stat *, char *); 11041989Sdesstruct url_ent *fetchList(struct url *, char *); 11137535Sdes 11260376Sdes/* URL parsing */ 11360376Sdesstruct url *fetchParseURL(char *); 11460376Sdesvoid fetchFreeURL(struct url *); 11560376Sdes 11641862Sdes/* Last error code */ 11741862Sdesextern int fetchLastErrCode; 11860924Sdes#define MAXERRSTRING 256 11960924Sdesextern char fetchLastErrString[MAXERRSTRING]; 12055557Sdesextern int fetchTimeout; 12141862Sdes 12237535Sdes#endif 123