[CONTACT]

[ABOUT]

[POLICY]

The author of this software is

Found at: ftp.icm.edu.pl:70/packages/netlib/crc/oldplausible.c

/*
 * The author of this software is Eric Grosse.  Copyright (c) 1993 by AT&T.
 * Permission to use, copy, modify, and distribute this software for any
 * purpose without fee is hereby granted, provided that this entire notice
 * is included in all copies of any software which is or includes a copy
 * or modification of this software and in all copies of the supporting
 * documentation for such software.
 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
 */

/* deprecated version of plausible.c, suitable for some non-POSIX systems */

typedef unsigned long ulong;
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>

char *progname;

void
filechk(f)
	char *f;
{
	char *p;
	unsigned char c;
	if(!f || !*f) Error("null filename");
	if(*f=='/') Error("leading slash");
	if(strncmp(f,"../",3)==0) Error("leading ..");
	for(p = strchr(f,'/'); p; p = strchr(p+1,'/'))
		if(p[1]=='.' && p[2]=='.' && (p[3]==0 || p[3]=='/') )
			Error("embedded ..");
	for(p = f; *p; p++){
		c = *p;
		if( !isascii(c) || isspace(c) || !isprint(c) )
			Error("bad char");
	}
}

nt
main(argc, argv)
	int argc;
	char **argv;
{
	int rc, removes = 0;
	ulong tim, len, sum;
	char cmd[21], name[2001];
	double space = 0.;

	progname = argv[0];
	while((rc=fscanf(stdin,"%20s %2000s %lu %lu %lx",
				cmd,name,&tim,&len,&sum))!=EOF){
		if(rc!=5) Error("saw %d fields, expected 5",rc);
		filechk(name);
		switch(*cmd){
		case 'g': /* get */
			space += len;
			break;
		case 'r': /* rm */
			space -= len;
			removes++;
			break;
		case 't': /* time */
			break;
		default:
			Error("? %s %s",cmd,name);
		}
	}
	space /= 1.e6;
	if(space>50.){
		fprintf(stderr,"will need %gMB additional disk\n",space);
		Error("");
	}
	if(removes>50){
		fprintf(stderr,"%d files to be removed\n",removes);
		Error("");
	}
	exit(0);
}

.


AD:

NEW PAGES:

[ODDNUGGET]

[GOPHER]