head	1.3;
access;
symbols;
locks; strict;
comment	@ * @;


1.3
date	92.06.15.08.35.23;	author dpassage;	state Exp;
branches;
next	1.2;

1.2
date	92.02.07.04.04.59;	author clarsen;	state Exp;
branches;
next	1.1;

1.1
date	92.02.03.23.36.31;	author clarsen;	state Exp;
branches;
next	;


desc
@baseline
@


1.3
log
@*** empty log message ***
@
text
@/* usage: loadfile unix-path postfs-path bufsize(in bytes) */
#include <sys/file.h>
#include "tmp/libpq-fs.h"
#include "catalog/pg_lobj.h"
void main(ac,av)
     int ac;
     char *av[];
{
    int fd, pfd;
    int n, pn;
    int blen = 65536;
    char *buf;
    char *res;

    PQsetdb(getenv("USER"));
    if (ac != 3) {
	printf ("usage: %s unix-path postfs-path\n",av[0]);
	exit(1);
    }

    res = PQexec("begin");
/*    blen = atoi(av[3]);*/
    buf = (char *)malloc(blen);
    if (p_open(av[2],O_RDONLY) < 0) {
	fd = open(av[1],O_RDONLY);
	pfd = p_creat(av[2],0 /*DEFAULT_SMGR*/,Inversion);
	while ((n = read(fd,buf,blen)) > 0) {
	    if ((pn = p_write(pfd,buf,n)) != n) {
	    }
/*	    printf ("p_write returned %d\n",pn);*/
	}
	close(fd);
	p_close(pfd);
    } else {
	printf ("file already exists\n");
    }
    res = PQexec("end");
    PQfinish();
    exit(0);
}
@


1.2
log
@*** empty log message ***
@
text
@d13 1
d20 2
d26 1
a26 1
	pfd = p_creat(av[2],0666,Inversion);
d37 1
@


1.1
log
@Initial revision
@
text
@d23 1
a23 1
	pfd = p_creat(av[2],0666,Unix);
@
