static int php_ns_sapi_read_post(char *buf, uint count_bytes) { uint max_read; uint total_read = 0; max_read = MIN(NSG(data_avail), count_bytes); total_read = Ns_ConnRead(NSG(conn), buf, max_read); if(total_read == NS_ERROR) { total_read = -1; } else { NSG(data_avail) -= total_read; } return total_read; }
char * Ns_ConnGets(char *buf, size_t bufsize, Ns_Conn *conn) { char *p; p = buf; while (bufsize > 1) { if (Ns_ConnRead(conn, p, 1) != 1) { return NULL; } if (*p++ == '\n') { break; } --bufsize; } *p = '\0'; return buf; }