1/* 2 * Copyright (c) 1998 Michael Smith. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/lib/libstand/gzipfs.c 92494 2002-03-17 12:18:05Z sobomax $"); |
29 30#include "stand.h" 31 32#include <sys/stat.h> 33#include <string.h> 34#include <zlib.h> 35 36#define Z_BUFSIZE 2048 /* XXX larger? */ --- 133 unchanged lines hidden (view full) --- 170 struct stat sb; 171 172 /* Have to be in "just read it" mode */ 173 if (f->f_flags != F_READ) 174 return(EPERM); 175 176 /* If the name already ends in .gz or .bz2, ignore it */ 177 if ((cp = strrchr(fname, '.')) && (!strcmp(cp, ".gz") |
178 || !strcmp(cp, ".bz2") || !strcmp(cp, ".split"))) |
179 return(ENOENT); 180 181 /* Construct new name */ 182 zfname = malloc(strlen(fname) + 4); 183 if (zfname == NULL) 184 return(ENOMEM); 185 sprintf(zfname, "%s.gz", fname); 186 --- 138 unchanged lines hidden --- |