fetch.h revision 40975
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 *
2840975Sdes *	$Id: fetch.h,v 1.5 1998/11/05 19:48:17 des Exp $
2937535Sdes */
3037535Sdes
3137535Sdes#ifndef _FETCH_H_INCLUDED
3237535Sdes#define _FETCH_H_INCLUDED
3337535Sdes
3437535Sdes#include <sys/param.h>
3537573Sdes#include <stdio.h>
3637535Sdes
3740975Sdes#include <fetch_err.h>
3840975Sdes
3937535Sdes#define _LIBFETCH_VER "libfetch/1.0"
4037535Sdes
4137535Sdes#define URL_SCHEMELEN 16
4237535Sdes#define URL_USERLEN 256
4337535Sdes#define URL_PWDLEN 256
4437535Sdes
4540975Sdesstruct url {
4640975Sdes    char	 scheme[URL_SCHEMELEN+1];
4740975Sdes    char	 user[URL_USERLEN+1];
4840975Sdes    char	 pwd[URL_PWDLEN+1];
4940975Sdes    char	 host[MAXHOSTNAMELEN+1];
5040975Sdes    int		 port;
5140975Sdes    char	 doc[2];
5237535Sdes};
5337535Sdes
5440975Sdesstruct url_stat {
5540975Sdes    off_t	 size;
5640975Sdes    time_t	 time;
5740975Sdes};
5837535Sdes
5937535Sdes/* FILE-specific functions */
6040975SdesFILE		*fetchGetFile(struct url *, char *);
6140975SdesFILE		*fetchPutFile(struct url *, char *);
6240975Sdesint		 fetchStatFile(struct url *, struct url_stat *, char *);
6337535Sdes
6437535Sdes/* HTTP-specific functions */
6540975Sdeschar		*fetchContentType(FILE *);
6640975SdesFILE		*fetchGetHTTP(struct url *, char *);
6740975SdesFILE		*fetchPutHTTP(struct url *, char *);
6840975Sdesint		 fetchStatHTTP(struct url *, struct url_stat *, char *);
6937535Sdes
7037535Sdes/* FTP-specific functions */
7140975SdesFILE		*fetchGetFTP(struct url *, char *);
7240975SdesFILE		*fetchPutFTP(struct url *, char *);
7340975Sdesint		 fetchStatFTP(struct url *, struct url_stat *, char *);
7437535Sdes
7537535Sdes/* Generic functions */
7640975Sdesstruct url	*fetchParseURL(char *);
7740975SdesFILE		*fetchGetURL(char *, char *);
7840975SdesFILE		*fetchPutURL(char *, char *);
7940975Sdesint		 fetchStatURL(char *, struct url_stat *, char *);
8040975SdesFILE		*fetchGet(struct url *, char *);
8140975SdesFILE		*fetchPut(struct url *, char *);
8240975Sdesint		 fetchStat(struct url *, struct url_stat *, char *);
8337535Sdes
8437535Sdes#endif
85