예제 #1
0
//------------------------------------------------------------------------------
// FUNCTION
//
//
// DESCRIPTION
//
//  
// PARAMETERS
//
//  
// RETURN
//
//  
//------------------------------------------------------------------------------
int WEB_printf( http_req *req, const char *format, ...)
{
	int rc;      // return code
    va_list ap;  // for variable args
	char buf[1024];
	
	
	buf[0] = 0;
	va_start(ap, format); // init specifying last non-var arg
	rc = vsnprintf(buf, sizeof(buf), format, ap);
	va_end(ap); // end var args
	
	return httpd_write(req, buf, strlen(buf));
}
예제 #2
0
파일: httpd.c 프로젝트: zoobab/linuxAP-eh
//----------------------------------------------------------------------
// HTTPD
// Main Dispatcher
//----------------------------------------------------------------------
int httpd (char *what)
{
    int ix;
    ix = argvindex(httpd_funcs,what,strcmp);

    switch(ix) {
	case HTTPD_OPTION:
	    httpd_option();
	    break;
	case HTTPD_WRITE:
	    httpd_write();
	    break;
	case HTTPD_MENU:
	    httpd_menu();
	    break;
    }
}
static void handle_send(struct connect_s *conn, struct timeval *tv)
{
  httpd_conn *hc = conn->hc;
  int nwritten;
  int nread;

  /* Read until the entire file is sent -- this could take awhile!! */

  while (conn->offset < conn->end_offset)
    {
      nvdbg("offset: %d end_offset: %d bytes_sent: %d\n",
            conn->offset, conn->end_offset, conn->hc->bytes_sent);

      /* Fill the rest of the response buffer with file data */

      nread = read_buffer(conn);
      if (nread < 0)
        {
          ndbg("File read error: %d\n", errno);
          goto errout_clear_connection;
        }
      nvdbg("Read %d bytes, buflen %d\n", nread, hc->buflen);

      /* Send the buffer */

      if (hc->buflen > 0)
        {
          /* httpd_write does not return until all bytes have been sent
           * (or an error occurs).
           */

          nwritten = httpd_write(hc->conn_fd, hc->buffer, hc->buflen);
          if (nwritten < 0)
            {
              ndbg("Error sending %s: %d\n", hc->encodedurl, errno);
              goto errout_clear_connection;
            }

          /* We wrote one full buffer of data (httpd_write does not
           * return until the full buffer is written (or an error occurs).
           */

          conn->active_at       = tv->tv_sec;
          hc->buflen            = 0;

          /* And update how much of the file we wrote */

          conn->offset         += nwritten;
          conn->hc->bytes_sent += nwritten;
          nvdbg("Wrote %d bytes\n", nwritten);
        }
    }

  /* The file transfer is complete -- finish the connection */

  nvdbg("Finish connection\n");
  finish_connection(conn, tv);
  return;

errout_clear_connection:
  ndbg("Clear connection\n");
  clear_connection(conn, tv);
  return;
}
예제 #4
0
//------------------------------------------------------------------------------
// FUNCTION
//
//
// DESCRIPTION
//
//  
// PARAMETERS
//
//  
// RETURN
//
//  
//------------------------------------------------------------------------------
int WEB_puts(char *s, http_req *req)
{
	return httpd_write(req, s, strlen(s)+1);
}
예제 #5
0
//------------------------------------------------------------------------------
// FUNCTION
//
//
// DESCRIPTION
//
//  
// PARAMETERS
//
//  
// RETURN
//
//  
//------------------------------------------------------------------------------
int WEB_write_blk(http_req *req, char *startp, int offset, int len)
{
	return httpd_write(req, startp+offset, len);
}