Subject: p_create and p_open don't work

From: [email-masked] (Siu Wah Lau)
Date: Fri, 4 Jun 93 17:14:08 -0700

Hi everyone,

I have tried to use the above routines but they are not working.
For p_creat, I get an error message "Error: Unexpected identifier: ?`A@".

Could anyone tell me what might be the problem?

Thank a lot.

Clarence.

The following is my program.

------------------- cut here ----------

#include <stdio.h>
#include "tmp/c.h"
#include "tmp/libpq-fe.h"
#include "tmp/libpq-fs.h"
#include "catalog/pg_lobj.h"

main()
{
int	inv_fd, fd;
char	*res;
char buf[1024];
int nbytes;
int tmp;

	PQsetdb("lau");
	res = PQexec ("begin");
	if (*res == 'E')
	{
		printf("error in PQexec\n"); exit(1);
	}

	fd = open ("/etc/hosts", O_RDONLY, 0666);
	if (fd < 0) 
	{
		perror("/etc/hosts");
		printf("error in open\n"); exit(1);
	}

	inv_fd = p_creat("/inv_file", INV_READ|INV_WRITE, Inversion);
	if (inv_fd < 0) 
	{
		printf("error in p_open\n"); exit(1);
	}

	while ((nbytes = read(fd, buf, 1024)) > 0)
	{
		tmp = p_write(inv_fd, buf, nbytes);
		if (tmp < nbytes)
		{
			printf("error in writing\n"); exit(1);
		}
	}
	close(fd);
	p_close(inv_fd);

	res = PQexec("end");
	if (*res == 'E')
	{
		printf("error in PQexec\n"); exit(1);
	}

	PQfinish();
}