#include "tmp/libpq-fs.h"

main(argc,argv)
     int argc; char *argv[];
{
    char buf[1024];
    PDIR *d;
    struct pgdirent *de;
    
    PQsetdb(getenv("USER"));
    if (argc <2) {
	printf ("usage: %s dir\n",argv[0]);
	exit(1);
    }
    (void) PQexec("begin");
    d = p_opendir(argv[1]);
    for(de =p_readdir(d); de != NULL;de =p_readdir(d))  {
	struct pgstat st;
	char name[1024];
	int fd, n;
	sprintf(name,"/%s",de->d_name);
	printf ("%s\t%d\n",de->d_name,de->d_ino);
	fd = p_open(name,O_RDONLY);
	p_stat(name,&st);
/*
	n = p_read(fd,buf,sizeof(buf));
*/
	printf ("fd = %d, n = %d\n",fd,n);
	if (fd >= 0) p_close(fd);
	printf ("mode: %o size %d\n",st.st_mode,st.st_size);
    }
    p_closedir(d);
    (void) PQexec("end");
    PQfinish();
}
