I am in need of some assistance in coding a c module using libpq on a
windows platform. Specifically, I need some help with providing the
input buffer for lo_write. The code sample provided in the
documentation contains this snippet:
------------
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
while ((nbytes = read(fd, buffer,BUFSIZE)) > 0)
{
tmp = lo_write(conn, lobj_fd, buffer, nbytes);
if (tmp < nbytes)
fprintf(stderr, "error while reading large object\n");
}
(void) CloseHandle(fd);
(void) lo_close(conn, lobj_fd);
------------
I need to change the read() statement to use ReadFile, thus:
------------
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
while (ReadFile(fd, buffer, BUFSIZE, &nbytes, NULL)!=EOF )
{
tmp = lo_write(conn, lobj_fd, buffer, nbytes);
if (tmp < nbytes)
fprintf(stderr, "error while reading large object\n");
}
(void) lo_close(conn, lobj_fd);
(void) CloseHandle(fd);
--------------
This, of course, doesn't work. The program is reported as no longer responding.
An infinite loop I suspect. If anyone is doing this or knows how to code it,
I would be grateful.
--
---------------------------------------------------------------------
Scott Holmes http://pages.sbcglobal.net/scottholmes
scottholmes@sbcglobal.net
Independent Programmer/Analyst Passport 4GL
PHP HTML Composer PostgreSQL Informix 4GL, SQL
---------------------------------------------------------------------
There are more things in heaven and earth, Horatio,
than are dreamt of in your philosophy
---------------------------------------------------------------------