DWORD WINAPI processStdin()

in nailgun-client/c/ng.c [433:464]


DWORD WINAPI processStdin (LPVOID lpParameter) {
  /* buffer used for reading and sending stdin chunks */
  char wbuf[BUFSIZE];

  /* number of bytes read */
  DWORD numberOfBytes;

  for (;;) {

    /* wait for ready to send */
    if(WaitForSingleObject(readyToSend, INFINITE) != WAIT_OBJECT_0) {
      handleError();
    }

	/* read data from stdin */
	if (! ReadFile(NG_STDIN_FILENO, wbuf, BUFSIZE, &numberOfBytes, NULL)) {
		if (numberOfBytes != 0) {
			handleError();
		}
	}

    /* send data to server */
    if (numberOfBytes > 0) {
      sendStdin(wbuf, numberOfBytes);
    } else {
      processEof();
      break;
    }

  }
  return 0;
}