コード例 #1
0
ファイル: message.cpp プロジェクト: philippedax/vreng
void Messages::performRequest(const UStr& req) // req starts with a '!'
{
#if HAVE_OCAML
  if (req.empty() || !isalpha(req[1])) return;

  const char* req_chars = req.c_str() + 1;  // skip the initial '!'
  entry = "";
  int r = read_request(req_chars);

  if (r > 0) {
    nclicks = r;
    for (int i=0; i<7 ;i++) {clicked[i] = MAXFLOAT;}

    char *phrase = strdup(req_chars);
    char *brkt = null;
    char *p = strtok_r(phrase, " ", &brkt);
    while (p) {
      entry.append(p); entry.append(" ");	// should be with red color
      p = strtok_r(NULL, " ", &brkt);
    }
    free(phrase);
  }
  else {
    g.gui.writeMessage("request", null, req_chars); // display in request history
    entry.append(req);
  }
#endif //HAVE_OCAML
}
コード例 #2
0
ファイル: main.c プロジェクト: bruceg/twoftpd
int main(int argc, char* argv[])
{
  const char* tmp;
  const char* end;
  int log_requests;
  
  log_requests = getenv("LOGREQUESTS") != 0;
  log_responses = getenv("LOGRESPONSES") != 0;

  tmp = getenv("TIMEOUT");
  if (tmp) {
    if ((timeout = strtou(tmp, &end)) == 0 || *end != 0) {
      respond(421, 1, "Configuration error, invalid timeout value");
      return 1;
    }
  }
  else
    timeout = 900;
  inbuf.io.timeout = timeout * 1000;
  outbuf.io.timeout = timeout * 1000;

  sig_alarm_catch(handle_alrm);
  if (!startup(argc, argv)) return 1;
  for (;;) {
    int len = read_request();
    if (len < 0) break;
    parse_request(len);
    if (!dispatch_request(internal_verbs, verbs, log_requests)) break;
  }
  return 0;
}
コード例 #3
0
static void service(FILE *in, FILE *out, char *docroot) {
  struct HTTPRequest *req;

  req = read_request(in);
  respond_to(req, out, docroot);
  free_request(req);
}
コード例 #4
0
ファイル: client_console.c プロジェクト: joaoelvas/Calendar
/**
 * The command line interpreter
 */ 
void console(Request *request) { 
	char line[LINESIZE];
				
	printf("> "); 
	fflush(stdout); 
	
	 	
	while (fgets(line, LINESIZE, stdin) != NULL) {
		ConsoleResult res = read_request(line, request); 
		switch (res) {
			case ERROR: 
				printf("Error: %s\n", error_msg);
				break;
			
			case EXIT: 
				return;
				
			case OK:
			//pthread_mutex_lock(&lock);	// NOT IMPLEMENTED 
				communicate_event_request(request);
			//pthread_mutex_unlock(&lock); // NOT IMPLEMENTED
			
			default: // IGNORE
				break;	
		}
		
		printf("> ");
		fflush(stdout);	
	}
}	
コード例 #5
0
static void serve_one_client(FILE *in, FILE *out)
{
	struct credential c = CREDENTIAL_INIT;
	struct strbuf action = STRBUF_INIT;
	int timeout = -1;

	if (read_request(in, &c, &action, &timeout) < 0)
		/* ignore error */ ;
	else if (!strcmp(action.buf, "get")) {
		struct credential_cache_entry *e = lookup_credential(&c);
		if (e) {
			fprintf(out, "username=%s\n", e->item.username);
			fprintf(out, "password=%s\n", e->item.password);
		}
	}
	else if (!strcmp(action.buf, "exit"))
		exit(0);
	else if (!strcmp(action.buf, "erase"))
		remove_credential(&c);
	else if (!strcmp(action.buf, "store")) {
		if (timeout < 0)
			warning("cache client didn't specify a timeout");
		else if (!c.username || !c.password)
			warning("cache client gave us a partial credential");
		else {
			remove_credential(&c);
			cache_credential(&c, timeout);
		}
	}
	else
		warning("cache client sent unknown action: %s", action.buf);

	credential_clear(&c);
	strbuf_release(&action);
}
コード例 #6
0
ファイル: main.c プロジェクト: SylvanHuang/clowwindy_server
void handle_request ( int sock )
{
    if ( sock == listen_sock )
    {
        accept_sock ( sock );
    }
    else
    {
        struct process* process = find_process_by_sock ( sock );
        if ( process != 0 )
        {
            switch ( process->status )
            {
            case STATUS_READ_REQUEST_HEADER:
                read_request ( process );
                break;
            case STATUS_SEND_RESPONSE_HEADER:
                send_response_header ( process );
                break;
            case STATUS_SEND_RESPONSE:
                send_response ( process );
                break;
            default:
                break;
            }
        }
    }
}
コード例 #7
0
ファイル: temphum.c プロジェクト: OvidiuMM/iot-class
int sens_inquire(SENSOR *sense){
    sense->buf[0]=0;
    read_request(sense->fd,sense->buf);
    sensor_data(sense->fd,sense->buf);

//Check data
    unsigned int read_status = sense->buf[0]>>6;

    if (read_status >1)
    {

        printf("Status is : %i", read_status);

    }
    else{
        if (read_status == 1){
            printf("Status is : %i so it has been already fetched", read_status);

        }
        //parse data

        sense->hum=get_humidity( sense->buf[0], sense->buf[1]);
        sense->temp=get_temperature( sense->buf[2], sense->buf[3]);

        sleep(1);
    }
    return 1;

}
コード例 #8
0
ファイル: rsh_daemon.cpp プロジェクト: Voidmster/OS_2015
left_side::left_side(rsh_daemon *parent, std::function<void(left_side*)> on_disconnect)
        : parent(parent),
          socket(parent->get_server().accept()),
          partner(nullptr),
          ioEvent(parent->get_service(), socket.get_fd(), EPOLLRDHUP, [this] (uint32_t events) mutable throw(std::runtime_error)
          {
              try {
                  std::cerr << "In right_side " << epoll_event_to_str(events) << "\n";
                  if (events & EPOLLIN) {
                      read_request();
                  }
                  if (events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) {
                      this->on_disconnect(this);
                  }
                  if (events & EPOLLOUT) {
                      send_response();
                  }
              } catch (std::exception &e) {
                  this->on_disconnect(this);
              }

          }),
          on_disconnect(on_disconnect)
{
    partner = parent->create_new_right_side(this);
    std::cerr << "Left_side created " << this <<" \n";
}
コード例 #9
0
void ProxyServer::session(boost::asio::ip::tcp::socket* socket)
{
  try
  {
    while (true)
    {
      std::string message = read_request(socket);
      boost::algorithm::trim(message);

      if (message == "DISCONNECTED")
      {
        std::cerr << "Application Server - Client has disconnected." << socket->remote_endpoint() << std::endl;
        break;
      }

      process_request(socket, message);
    }
  }
  catch (std::exception &e)
  {
    std::cerr << "Application Server - Session error - " << e.what() << std::endl;
  }

  if (socket->is_open())
    socket->close();

  // libera uma conexão para o pool...
  boost::unique_lock<boost::mutex> lock(m);
  ++available_connections;
  cv.notify_one();
}
コード例 #10
0
ファイル: console.cpp プロジェクト: Azzurrio/rubinius
    void Console::process_requests(STATE) {
      GCTokenImpl gct;
      RBX_DTRACE_CONST char* thread_name =
        const_cast<RBX_DTRACE_CONST char*>("rbx.console.request");
      request_vm_->set_name(thread_name);

      RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name),
                            state->vm()->thread_id(), 1);

      state->vm()->thread->hard_unlock(state, gct, 0);
      state->gc_independent(gct, 0);

      while(!request_exit_) {
        Object* status = fsevent_.get()->wait_for_event(state);

        if(request_exit_) break;
        if(status->nil_p()) continue;

        char* request = read_request(state);

        if(request) {
          utilities::thread::Mutex::LockGuard lg(list_lock_);

          request_list_->push_back(request);
          response_cond_.signal();
        }
      }

      state->gc_dependent(gct, 0);

      RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CONST char*>(thread_name),
                           state->vm()->thread_id(), 1);
    }
コード例 #11
0
ファイル: cachemgr.c プロジェクト: CoolerVoid/squid
int
main(int argc, char *argv[])
{
    char *s;
    cachemgr_request *req;
    safe_inet_addr("255.255.255.255", &no_addr);
    now = time(NULL);
#ifdef _SQUID_MSWIN_
    Win32SockInit();
    atexit(Win32SockCleanup);
    _setmode(_fileno(stdin), _O_BINARY);
    _setmode(_fileno(stdout), _O_BINARY);
    _fmode = _O_BINARY;
    if ((s = strrchr(argv[0], '\\')))
#else
    if ((s = strrchr(argv[0], '/')))
#endif
	progname = xstrdup(s + 1);
    else
	progname = xstrdup(argv[0]);
    if ((s = getenv("SCRIPT_NAME")) != NULL)
	script_name = xstrdup(s);
    req = read_request();
    return process_request(req);
}
コード例 #12
0
/* Does the actual work of handling the client. This allows spawn_handler to
 * create a new thread and immediately return.
 */
static void handler(int fd)
	{
	Request req;
	
	main_log << DEBUG << "Reading request...";
	req = read_request(fd);
	
	main_log << DEBUG <<"Finished reading request.";
  
  
  
	std::string file_path(get_config("root_dir"));
	file_path=file_path + "/" + req.URI;
	
	int error_code;
	std::string response_body = get_resource(file_path,NULL,error_code);
	
	if (!response_body.size()) {
		main_log << ERROR << "Server error occurred. Ending handler...\n";
		return;
		}
  
	if (send_data(fd,response_body.c_str())) {
		main_log << WARNING << "Server error occured. Ending handler...\n";
		return;
		}
  
	return;
	}
コード例 #13
0
ファイル: httpd.c プロジェクト: jrswanson91/HTTPServer
/**
 * The main function that handles an HTTP request.
 */
int main(int argc, const char *argv[])
{
    req_t *req;
    if (argc < 2) {
        return -1;
    }

    document_root = argv[1];

    req = read_request(0);

    if (!req && errno != 0) {
        // internal error
        perror("httpd");
        send_error(stdout, 500, "Internal Server Error",
                   "Internal server error: %s", strerror(errno));
        return 1;
    } else if (!req || !req_is_valid(req)) {
        send_error(stdout, 400, "Bad Request", "Incomplete or invalid request.");
        return 0;
    } else {
        if (handle_request(req, stdout) < 0) {
            return 1;
        } else {
            return 0;
        }
    }
}
コード例 #14
0
ファイル: tee_supplicant.c プロジェクト: liuyq/optee_client
static bool process_one_request(struct thread_arg *arg)
{
	union tee_rpc_invoke request;
	size_t num_params;
	size_t num_meta;
	struct tee_ioctl_param *params;
	uint32_t func;
	uint32_t ret;

	DMSG("looping");
	memset(&request, 0, sizeof(request));
	request.recv.num_params = RPC_NUM_PARAMS;

	/* Let it be known that we can deal with meta parameters */
	params = (struct tee_ioctl_param *)(&request.send + 1);
	params->attr = TEE_IOCTL_PARAM_ATTR_META;

	num_waiters_inc(arg);

	if (!read_request(arg->fd, &request))
		return false;

	if (!find_params(&request, &func, &num_params, &params, &num_meta))
		return false;

	if (num_meta && !num_waiters_dec(arg) && !spawn_thread(arg))
		return false;

	switch (func) {
	case OPTEE_MSG_RPC_CMD_LOAD_TA:
		ret = load_ta(num_params, params);
		break;
	case OPTEE_MSG_RPC_CMD_FS:
		ret = tee_supp_fs_process(num_params, params);
		break;
	case OPTEE_MSG_RPC_CMD_RPMB:
		ret = process_rpmb(num_params, params);
		break;
	case OPTEE_MSG_RPC_CMD_SHM_ALLOC:
		ret = process_alloc(arg, num_params, params);
		break;
	case OPTEE_MSG_RPC_CMD_SHM_FREE:
		ret = process_free(num_params, params);
		break;
	case OPTEE_MSG_RPC_CMD_GPROF:
		ret = gprof_process(num_params, params);
		break;
	case OPTEE_MSG_RPC_CMD_SOCKET:
		ret = tee_socket_process(num_params, params);
		break;
	default:
		EMSG("Cmd [0x%" PRIx32 "] not supported", func);
		/* Not supported. */
		ret = TEEC_ERROR_NOT_SUPPORTED;
		break;
	}

	request.send.ret = ret;
	return write_response(arg->fd, &request);
}
コード例 #15
0
void accept_request(dino_http_site_t *dino_site, dino_handle_t *dhandle) {
    // Setup DHANDLE:
    //
    if (!read_request(&dhandle->http)) {
        bad_request(dhandle->http.socket);
    }
    else {
        // Parse the URL Parameters.
        //
        stack_char_ptr_t *url_stack = stack_ptr_parse(NULL, string_buffer_c_string(dhandle->http.request.url), "/");

        // Search for a match...
        //
        dino_route_t *route = list_method_find(dino_site->list, dhandle->http.request.method, url_stack);

        // Do we have a route?
        //
        if (NULL != route) {
            invoke_method(route, &dhandle->http, url_stack);
        }
        else {
            fprintf(stderr, "[ERROR] Path %s not found; \n\r", string_buffer_c_string(dhandle->http.request.url));
        }

        stack_ptr_free(url_stack);
    }
}
コード例 #16
0
ファイル: step_test.c プロジェクト: hzaskywalker/homework
int main(int argc, char* argv[]){

    int msg_id = shmget(MSG_NAME(0), 0, 0);
    volatile int* msg0 = shmat(msg_id, 0, 0);
    msg_id = shmget(MSG_NAME(1), 0, 0);
    volatile int* msg1 = shmat(msg_id, 0, 0);
    read_request(msg0, 6, 1);
    read_request(msg1, 3, 1);
    read_request(msg0, 8, 1);
    read_request(msg1, 9, 1);
    write_request(msg0, 1, 1, 1);
    write_request(msg0, 4, 3, 1);
    write_request(msg0, 2, 4, 1);
    write_request(msg1, 8, 3, 1);
    write_request(msg1, 7, 0, 1);
    int ans = read_request(msg0, 8, 1);
    printf("%d\n", ans);
    return 0;
}
コード例 #17
0
ファイル: rest_server.cpp プロジェクト: kermitas/intellihome
boolean RestServer::handle_requests(Stream &_client) {
	if (_client.available()) {
		start_timer();
		read_request(_client.read());
	}
	parse_request();
	process();	
	if (server_state == PROCESS) return true;
	else return false;
}
コード例 #18
0
ファイル: http-backend.c プロジェクト: PKRoma/git
static void copy_request(const char *prog_name, int out, ssize_t req_len)
{
	unsigned char *buf;
	ssize_t n = read_request(0, &buf, req_len);
	if (n < 0)
		die_errno("error reading request body");
	write_to_child(out, buf, n, prog_name);
	close(out);
	free(buf);
}
コード例 #19
0
// Dequeue an operation
//
// In the Linux implementation there is only a single operation and clients
// cannot queue commands (except at the socket level). 
//
LinuxAttachOperation* LinuxAttachListener::dequeue() {
  for (;;) {
    int s;

    // wait for client to connect
#ifdef AZ_PROXIED
    RESTARTABLE(proxy_invoke_remote_VMAttachAccept(listener()), s);
#else // !AZ_PROXIED
    struct sockaddr addr;
    socklen_t len = sizeof(addr);
    RESTARTABLE(::accept(listener(), &addr, &len), s);
#endif // !AZ_PROXIED
    if (s == -1) {
      return NULL;	// log a warning?
    }

#ifdef AZ_PROXIED
    if (proxy_invoke_remote_VMAttachCheckCredentials(s) == -1) {
      int res;
      RESTARTABLE(VM_ATTACH_CLOSE(s), res);

      continue;
    }

#else // !AZ_PROXIED
    // get the credentials of the peer and check the effective uid/guid
    // - check with jeff on this.
    struct ucred cred_info;
    socklen_t optlen = sizeof(cred_info);
    if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) == -1) {
      int res;
RESTARTABLE(VM_ATTACH_CLOSE(s),res);
      continue;
    }
    uid_t euid = geteuid();
    gid_t egid = getegid();

    if (cred_info.uid != euid || cred_info.gid != egid) {
      int res;
RESTARTABLE(VM_ATTACH_CLOSE(s),res);
      continue;
    }
#endif // !AZ_PROXIED

    // peer credential look okay so we read the request
    LinuxAttachOperation* op = read_request(s);
    if (op == NULL) {
      int res;
RESTARTABLE(VM_ATTACH_CLOSE(s),res);
      continue;
    } else {
      return op;
    }
  }
}
コード例 #20
0
ファイル: http-backend.c プロジェクト: 9b/git
static void inflate_request(const char *prog_name, int out, int buffer_input)
{
	git_zstream stream;
	unsigned char *full_request = NULL;
	unsigned char in_buf[8192];
	unsigned char out_buf[8192];
	unsigned long cnt = 0;

	memset(&stream, 0, sizeof(stream));
	git_inflate_init_gzip_only(&stream);

	while (1) {
		ssize_t n;

		if (buffer_input) {
			if (full_request)
				n = 0; /* nothing left to read */
			else
				n = read_request(0, &full_request);
			stream.next_in = full_request;
		} else {
			n = xread(0, in_buf, sizeof(in_buf));
			stream.next_in = in_buf;
		}

		if (n <= 0)
			die("request ended in the middle of the gzip stream");
		stream.avail_in = n;

		while (0 < stream.avail_in) {
			int ret;

			stream.next_out = out_buf;
			stream.avail_out = sizeof(out_buf);

			ret = git_inflate(&stream, Z_NO_FLUSH);
			if (ret != Z_OK && ret != Z_STREAM_END)
				die("zlib error inflating request, result %d", ret);

			n = stream.total_out - cnt;
			if (write_in_full(out, out_buf, n) != n)
				die("%s aborted reading request", prog_name);
			cnt += n;

			if (ret == Z_STREAM_END)
				goto done;
		}
	}

done:
	git_inflate_end(&stream);
	close(out);
	free(full_request);
}
コード例 #21
0
ファイル: http-backend.c プロジェクト: 9b/git
static void copy_request(const char *prog_name, int out)
{
	unsigned char *buf;
	ssize_t n = read_request(0, &buf);
	if (n < 0)
		die_errno("error reading request body");
	if (write_in_full(out, buf, n) != n)
		die("%s aborted reading request", prog_name);
	close(out);
	free(buf);
}
コード例 #22
0
ファイル: proxy.c プロジェクト: LuLuPan/proxylab
/*proxy executation routine*/
int run_proxy(int connfd)
{
    char hostname[MAXLINE];
    char req_buf[MAX_OBJECT_SIZE];
    char resp_buf[MAX_OBJECT_SIZE];
    char uri[MAXLINE]; 
    int port = 80;
    int clientfd;
    rio_t rio;

    memset(hostname, 0, MAXLINE);
    memset(req_buf, 0, MAX_OBJECT_SIZE);
    memset(resp_buf, 0 , MAX_OBJECT_SIZE);

    /* read request */
    if(read_request(connfd, req_buf, uri, hostname, &port) < 0) {
        //printf("close fd: %d, tid: %d\n", connfd, gettid());
        Close(connfd);
        return -1;
    }

    /* open connection to server */
    if((clientfd = open_clientfd_r(hostname, port)) < 0)
    {
        //printf("connfd: %d, clientfd: %d, host: %s, tid: %d\n", connfd, clientfd, hostname, gettid());
        printf("Open_clientfd error\n");
        fprintf(stderr, "Error: connection refused: %s !\n", hostname);
        Close(connfd);
        return -1;
    }

    if(forward_request(&rio, req_buf, clientfd) < 0)
    {
        printf("forward_request error\n");
        fprintf(stderr, "Error: Send request to server failed !\n");
        Close(clientfd);
        Close(connfd);
        return -1;
    }
    
    if(forward_response(&rio, uri, resp_buf, connfd) < 0)
    {
        printf("forward_response\n");
        fprintf(stderr, "Error: Send response to client failed !\n");
        Close(clientfd);
        Close(connfd);
        return -1;
    }
        
    
    Close(clientfd);
    Close(connfd);
    return 0;
}
コード例 #23
0
ファイル: hmdp_server.c プロジェクト: ablochha/Resume
// Handle's a client's request
// @param connectionfd the descriptor for the connection
// @param server the database server
// @param command the type of request
// @param client the client's information
// @return 1 if the server should handle another request, -1 otherwise
int handle_request(int connectionfd, char *server, char **command, client_info **client) {
    
    // Check if the client used the correct protocol
    if (read_request(connectionfd, &(*client)->username, &(*client)->password, &(*client)->token, &(*client)->list, command) == 1) {
        
        // The client sent an 'Auth' request
        if (strcmp(*command, COMMAND_AUTH) == 0) {
            
            // Attempt to authenticate the client with the Hooli database
            if (handle_auth(connectionfd, server, command, &(*client)->username, &(*client)->password) == -1) {
                
                return -1;
                
            } //end if
            
        } //end if
        
        // The client sent a 'List' request
        else if (strcmp(*command, COMMAND_LIST) == 0) {
            
            // Attempt to sync the client with the Hooli database
            if (handle_list(connectionfd, server, command, &(*client)->token,
                            &(*client)->response_list, (*client)->list) == -1) {
                
                return -1;
                
            } //end if
            
        } //end else if
        
        // The client gave an invalid command
        else {
            
            syslog(LOG_DEBUG, "Expected valid command, got '%s'", *command);
            response_401(connectionfd);
            return -1;
            
        } //end else
        
    } //end if
    
    // The client's message did not follow the protocol
    else {
        
        syslog(LOG_DEBUG, "Received message failed to follow protocol");
        response_401(connectionfd);
        return -1;
        
    } //end else
    
    return 1;
    
} //end handle_request
コード例 #24
0
void server_connection::read_request(completion_handler&& handler, std::chrono::seconds timeout)
{
    LOG_COMP_TRACE_FUNCTION(server_connection);

    read_request(std::forward<completion_handler>(handler));

    if(timeout > std::chrono::seconds::zero())
    {
        timeout_timer_.expires_from_now(timeout);
        timeout_timer_.async_wait(bind_to_stop_handler());
    }
}
コード例 #25
0
static int
child_main(int fd)
{
    header_info_t header;
    memset(&header, 0, sizeof(header_info_t));
    header.fd = fd;
    read_request(&header);

    /* interpret stuff */
    /*
    fprintf(stderr, "\nDONE\n");
    fprintf(stderr, "url: %s\n", header.url);
    fprintf(stderr, "content-length: %s\n", header.content_length);
    fprintf(stderr, "content-type: %s\n", header.content_type);
    fprintf(stderr, "accept: %s\n", header.accept);
    fprintf(stderr, "host: %s\n", header.host);
    fprintf(stderr, "UA: %s\n", header.user_agent);
    fprintf(stderr, "expect: %s\n", header.expect);
    */
    /* echo back shit */

    /* close */
    if (header.url) {
        free(header.url);
    }
    if (header.base_url) {
        free(header.base_url);
    }
    if (header.host) {
        free(header.host);
    }
    if (header.accept) {
        free(header.accept);
    }
    if (header.content_type) {
        free(header.content_type);
    }
    if (header.user_agent) {
        free(header.user_agent);
    }
    if (header.content_length) {
        free(header.content_length);
    }
    if (header.expect) {
        free(header.expect);
    }
    if (header.query_map) {
        query_map_destroy(header.query_map);
    }

    close(fd);
    return 0;
}
コード例 #26
0
ファイル: myhttp.cpp プロジェクト: kasru/smallhttp
void connection::process()
{
	read_request();
	parse_request();
	make_body();
	make_header();
	send_header();
	if (is_get())
	{
		send_body();
	}
	m_socket.close();
}
コード例 #27
0
int
main(int argc, char *argv[])
{
    char *s;
    cachemgr_request *req;
    safe_inet_addr("255.255.255.255", &no_addr);
    now = time(NULL);
    if ((s = strrchr(argv[0], '/')))
	progname = xstrdup(s + 1);
    else
	progname = xstrdup(argv[0]);
    if ((s = getenv("SCRIPT_NAME")) != NULL)
	script_name = xstrdup(s);
    req = read_request();
    return process_request(req);
}
コード例 #28
0
ファイル: httpd.c プロジェクト: tomonacci/Gauche-libev
static void init_read(EV_P_ struct cs_io *cs_w) {
  int cs;
  switch (read_request(cs_w)) {
    case 0:
      cs = cs_w->io.fd;
      ev_io_init(&cs_w->io, cs_r_cb, cs, EV_READ);
      ev_io_start(EV_A_ &cs_w->io);
      break;
    case 1:
      init_write(EV_A_ cs_w);
      break;
    default:
      fputs("first read was null\n", stderr);
      fflush(stderr);
      break;
  }
}
コード例 #29
0
ファイル: httpd.c プロジェクト: tomonacci/Gauche-libev
// Process events from clients
static void cs_r_cb(EV_P_ struct ev_io *w, int revents) {
  switch (read_request((struct cs_io *)w)) {
    case 0:
      if (((struct cs_io *)w)->recv_count++ >= 500) {
        fputs("watcher should have been stopped!\n", stderr);
        fflush(stderr);
        ev_io_stop(EV_A_ w);
      }
      break;
    case 1:
      ev_io_stop(EV_A_ w);
      init_write(EV_A_ (struct cs_io *)w);
      break;
    default:
      ev_io_stop(EV_A_ w);
      break;
  }
}
コード例 #30
0
ファイル: main.c プロジェクト: tomohikoseven/http
static void
service
(
    FILE    *in,        /* input fd     */
    FILE    *out,       /* output fd    */
    char    *docroot    /* docroot path */
)
{
    struct HTTPRequest  *req = NULL;

    dbg( "in=%p, out=%p, docroot=%p\n", in, out, docroot );

    req = read_request( in );

    respond_to( req, out, docroot );

    free_request( req );
}