head 1.9;
access;
symbols;
locks; strict;
comment @ * @;
1.9
date 94.03.25.15.01.39; author paul; state Exp;
branches;
next 1.8;
1.8
date 94.03.12.00.59.25; author paul; state Exp;
branches;
next 1.7;
1.7
date 93.12.19.18.43.04; author paul; state Exp;
branches;
next 1.6;
1.6
date 93.07.24.19.02.46; author paul; state Exp;
branches;
next 1.5;
1.5
date 93.04.02.17.54.42; author paul; state Exp;
branches;
next 1.4;
1.4
date 93.02.27.21.06.24; author paul; state Exp;
branches;
next 1.3;
1.3
date 92.07.30.03.46.08; author paul; state Exp;
branches;
next 1.2;
1.2
date 92.07.27.22.20.02; author paul; state Exp;
branches;
next 1.1;
1.1
date 92.07.27.21.37.00; author paul; state Exp;
branches;
next ;
desc
@@
1.9
log
@Renamed db.h to qdb.h to avoid conflict with the Berkeley DB package.
@
text
@/*
* Copyright (c) 1985 Corporation for Research and Educational Networking
* Copyright (c) 1988 University of Illinois Board of Trustees, Steven
* Dorner, and Paul Pomes
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Corporation for
* Research and Educational Networking (CREN), the University of
* Illinois at Urbana, and their contributors.
* 4. Neither the name of CREN, the University nor the names of their
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE TRUSTEES AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char RcsId[] = "@@(#)$Id: border.c,v 1.8 1994/03/12 00:59:25 paul Exp paul $";
#endif
/*
* this program goes from Vax byteorder to normal byteorder, or vice-versa
*/
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/file.h>
#include "bintree.h"
#include "qdb.h"
if (doMask & DIR)
ReverseDir(root);
if (doMask & DOV)
ReverseDov(root);
if (doMask & IDX)
ReverseIdx(root);
if (doMask & IOV)
ReverseIov(root);
if (doMask & SEQ)
ReverseSeq(root);
if (doMask & BDX)
ReverseBdx(root);
exit(Error);
}
/*
* reverse the dir file
*/
ReverseDir(root)
char *root;
{
char filename[80];
int fd;
int bytes;
unsigned long spot;
long lastTime;
unsigned long size;
/*
* done
*/
if (!Quiet)
fputc('\n', stderr);
close(fd);
}
/*
* reverse the dov file
*/
ReverseDov(root)
char *root;
{
char filename[80];
int fd;
int bytes;
unsigned long spot;
long lastTime;
unsigned long size;
/*
* done
*/
if (!Quiet)
fputc('\n', stderr);
close(fd);
}
/*
* reverse the idx file
*/
ReverseIdx(root)
char *root;
{
char filename[80];
int fd;
int bytes;
unsigned long spot;
register long *where;
long lastTime;
unsigned long size;
/*
* done
*/
if (!Quiet)
fputc('\n', stderr);
close(fd);
}
/*
* reverse the iov file
*/
ReverseIov(root)
char *root;
{
char filename[80];
int fd;
int bytes;
unsigned long spot;
long lastTime;
unsigned long size;
/*
* done
*/
if (!Quiet)
fputc('\n', stderr);
close(fd);
}
/*
* reverse the bdx file
*/
ReverseBdx(root)
char *root;
{
char filename[80];
int fd;
int bytes;
unsigned long spot;
long lastTime;
unsigned long size;
1.7
log
@fcntl.h is normally in /usr/include .
@
text
@d2 33
a34 5
* This software is Copyright (C) 1988 by Steven Dorner and the
* University of Illinois Board of Trustees. No warranties of any
* kind are expressed or implied. No support will be provided.
* This software may not be redistributed for commercial purposes.
* You may direct questions to nameserv@@uiuc.edu
d36 4
@
1.6
log
@Added -q (Quiet) flag to suppress in progress messages.
@
text
@d14 1
a14 1
#include <sys/fcntl.h>
@
1.4
log
@System 5 changes, 1 or more of #include <sys/fcntl.h> instead of <sys/file.h>,
define index/rindex replacements using strchr/strrchr, define L_SET, etc
values if not present.
@
text
@d396 1
a396 1
if (read(fd, buffer, sizeof (HEADER)) < sizeof (HEADER))
d402 1
a402 1
ReverseLongs(buffer, sizeof (HEADER) / sizeof (long));
d409 1
a409 1
if (write(fd, buffer, sizeof (HEADER)) < 0)
@
1.3
log
@Renamed BSIZE to LBSIZE.
@
text
@d14 5
a18 1
#include <sys/file.h>
d21 8
@
1.2
log
@Re-formatted for clarity
@
text
@d407 1
a407 1
for (spot = HEADBLKS * BSIZE; lseek(fd, spot, L_SET) < size; spot += sizeof (LEAF))
@
1.1
log
@Initial revision
@
text
@d1 11
a11 11
/*********************************************************************
* This software is Copyright (C) 1988 by Steven Dorner and the
* University of Illinois Board of Trustees. No warranties of any
* kind are expressed or implied. No support will be provided.
* This software may not be redistributed for commercial purposes.
* You may direct questions to dorner@@garcon.cso.uiuc.edu
**********************************************************************/
/***********************************************************************
* this program goes from Vax byteorder to normal byteorder, or vice-versa
***********************************************************************/
d18 4
a21 3
int Error=0;
char *buffer;
long junk;
d26 2
a27 2
char *suffix;
int mask;
d29 1
d37 3
a39 3
main(argc,argv)
int argc;
char **argv;
d41 48
a88 48
char *me = *argv;
char *root;
int doMask = 0;
int sNum;
static struct suffix sfx[]=
{
{"dir",DIR},
{"dov",DOV},
{"idx",IDX},
{"iov",IOV},
{"seq",SEQ},
{"bdx",BDX}
};
int sCount = sizeof(sfx)/sizeof(struct suffix);
for (argc--,argv++; argc && **argv=='-'; argc--,argv++)
{
for (sNum=0;sNum<sCount;sNum++)
if (!strcmp(*argv+1,sfx[sNum].suffix))
{
doMask |= sfx[sNum].mask;
break;
}
}
if (!doMask) doMask = -1;
if (argc==0)
{
fprintf(stderr,"Usage:%s <database>\n",me);
exit(1);
}
root = *argv;
buffer = (char *)malloc(B_BYTES);
if (doMask & DIR)
ReverseDir(root);
if (doMask & DOV)
ReverseDov(root);
if (doMask & IDX)
ReverseIdx(root);
if (doMask & IOV)
ReverseIov(root);
if (doMask & SEQ)
ReverseSeq(root);
if (doMask & BDX)
ReverseBdx(root);
exit(Error);
d91 3
a93 3
/***********************************************************************
* reverse the dir file
***********************************************************************/
d95 1
a95 1
char *root;
d97 74
a170 74
char filename[80];
int fd;
int bytes;
long spot;
long time(),lastTime;
long size;
if ((fd=open(filename,O_RDWR))<0)
{
perror(filename);
Error = 1;
return;
}
/*
* the first long
*/
if (read(fd,buffer,sizeof(long))<sizeof(long))
{
perror(filename);
Error = 1;
return;
}
ReverseLongs(buffer,1);
if (lseek(fd,(long)0,L_SET)<0)
{
perror("ReverseBdx");
exit(1);
}
if (write(fd,buffer,sizeof(long))<0)
{
perror("ReverseBdx");
exit(1);
}
/*
* the rest
*/
lastTime=0;
size = lseek(fd,(long)0,L_XTND);
for (spot=sizeof(NODE)-sizeof(long);lseek(fd,spot,L_SET)<size;spot+=sizeof(NODE))
{
if (time(&junk)-lastTime>5)
{
lastTime=time(&junk);
fprintf(stderr,"%%%ld\r",spot*100/size);
}
if ((bytes = read(fd,buffer,2*sizeof(long)))<0)
break;
ReverseLongs(buffer,2);
if (lseek(fd,spot,L_SET)<0)
{
perror("ReverseBdx");
exit(1);
}
if (write(fd,buffer,bytes)<0)
{
perror("ReverseBdx");
exit(1);
}
}