Libpq coding assistance

Поиск
Список
Период
Сортировка
От Scott Holmes
Тема Libpq coding assistance
Дата
Msg-id 1004903734.17832.12.camel@scotts
обсуждение исходный текст
Ответы Is there an internal timestamp on a table when it was created?  ("Jeff Lu" <jklcom@mindspring.com>)
Список pgsql-general
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
---------------------------------------------------------------------


В списке pgsql-general по дате отправления:

Предыдущее
От: Jakub Ouhrabka
Дата:
Сообщение: foreign keys and deadlock
Следующее
От: "Command Prompt, Inc."
Дата:
Сообщение: Re: One more question about intervals