コード例 #1
0
int from_backend(void *frontend_handle, int is_stderr,
		 const char *data, int len)
{
    if (is_stderr) {
	handle_write(stderr_handle, data, len);
    } else {
	handle_write(stdout_handle, data, len);
    }

    return handle_backlog(stdout_handle) + handle_backlog(stderr_handle);
}
コード例 #2
0
template<class T> void AsyncEndpoint<T>::deliver_impl(NMEAmsg_ptr msg){
    bool wasEmpty = true;
    bool nowFull = false;
    {
        boost::mutex::scoped_lock lock(message_queueMutex);
        wasEmpty = message_queue.empty();
        while(message_queue.size()>=message_queue_size){
            message_queue.pop_front();
            nowFull=true;
        }
        message_queue.push_back(msg);
    }
    if(wasEmpty){
        boost::system::error_code ec(0,boost::system::system_category());
        handle_write(ec);
    }
    if(!nowFull){
        wasFull=false;
    }
    else if(nowFull && !wasFull){
        wasFull=true;
        std::ostringstream oss;
        oss << "The message queue for "<<getSessionId()<<" was too small, old messages were lost!";
        log(oss.str());
    }
}
コード例 #3
0
ファイル: client_hello.c プロジェクト: Rachel-Lu/socket
int main()
{
	int fd;
	struct sockaddr_in addr;
	
	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = inet_addr(SERVER_ADDR);
	addr.sin_port = htons(SERVER_PORT); 
	
	if( (fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
	{
		printf("error to create the socket\n");
		exit(-1);
	} 

	if(connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1)
	{
		printf("error to connect to the server\n");
		exit(-2);
	} 

	handle_write(fd);

}
コード例 #4
0
ファイル: routing.cpp プロジェクト: vicoslab/echolib
void Router::handle_client(int sfd) {
    if (clients.find(sfd) == clients.end()) {
        DEBUGMSG("Connecting client FID=%d\n", sfd);
        clients[sfd] = make_shared<Client>(sfd);
    } else if(!clients[sfd]->is_connected()) {
        clients.erase(sfd);
        clients[sfd] = make_shared<Client>(sfd);
    }

    SharedClient client = clients[sfd];
    while (true) {
        SharedMessage msg = client->read();

        if (msg) {
            received_messages_size+=(msg->get_length());
            handle_message(client, msg);
            //if we have received too many messages we should send the ones we currently have
            if(received_messages_size > MAX_RECEIVED_MESSAGES_SIZE) {
                handle_write();
            }
        } else {
            if (!client->is_connected()) {
                clients.erase(sfd);

            }
            return;

        }

    }


}
コード例 #5
0
ファイル: hime-im-client.c プロジェクト: czchen/hime
void hime_im_client_clear_flags(HIME_client_handle *handle, int flags, int *ret_flag)
{
  HIME_req req;

  if (!handle)
    return;

  if (is_special_user)
    return;

  if (!gen_req(handle, HIME_req_set_flags, &req))
    return;

  req.flag &= ~flags;

  flags_backup = req.flag;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_set_flags error");
  }

  if (handle_read(handle, ret_flag, sizeof(int)) <= 0) {
    error_proc(handle, "cannot read reply str from hime server");
  }
}
コード例 #6
0
ファイル: hwReadWrite.c プロジェクト: ToasTer86/ES6-
/**
 * This method is called when the user calls echo on our kernel module
 * *dev and *attr: not yet required for our functionality
 * buffer: the message that is being echoed to our kernel
 * size: the size of the message.
 * return value: if return != count, then sysfs will call echo with the remainder of the message. (should not be >1024 bytes)
 * */
static ssize_t sysfs_store(struct device *dev, struct device_attribute *attr, const char *buffer, size_t count)
{
    if ( count > max_data )
    {
		used_buffer_size = max_data;
		printk(KERN_INFO "Input is too large: %d is max, %d was supplied", max_data, count);
	}
	else
	{
		used_buffer_size = count;
	}
	
	if(strncmp(buffer, "r", 1) == 0)
	{
		handle_read(&buffer[msg_param_offset]);
	}
	else if(strncmp(buffer, "w", 1) == 0)
	{
		handle_write(&buffer[msg_param_offset]);
	}
	else
	{
		printk(KERN_INFO "Input is not according to the protocol. Input: %s\n" , buffer);
		printk(KERN_INFO "If you wish to read:\n");
		printk(KERN_INFO "\"r <amount of registers to read> <physical address of register to start at>\"\n");
		printk(KERN_INFO "Example: echo \"r 8 0x40024000\"\n\n");
		printk(KERN_INFO "If you wish to write:\n");
		printk(KERN_INFO "\"w <physical address of register to write to> <value to write>\"\n");
		printk(KERN_INFO "Example: echo \"w 0x40024000 0x222\"\n");
	}
	
    return used_buffer_size;
}
コード例 #7
0
ファイル: proxy.c プロジェクト: Gastlag/Opentracker
static void server_mainloop() {
  int64 sock;

  /* inlined livesync_init() */
  memset( g_peerbuffer_start, 0, sizeof( g_peerbuffer_start ) ); 
  g_peerbuffer_pos = g_peerbuffer_start;
  memcpy( g_peerbuffer_pos, &g_tracker_id, sizeof( g_tracker_id ) );
  uint32_pack_big( (char*)g_peerbuffer_pos + sizeof( g_tracker_id ), OT_SYNC_PEER);
  g_peerbuffer_pos += sizeof( g_tracker_id ) + sizeof( uint32_t);
  g_next_packet_time = time(NULL) + LIVESYNC_MAXDELAY;

  while(1) {
    /* See, if we need to connect to anyone */
    if( time(NULL) > g_connection_reconn )
      handle_reconnects( );

    /* Wait for io events until next approx reconn check time */
    io_waituntil2( 30*1000 );

    /* Loop over readable sockets */
    while( ( sock = io_canread( ) ) != -1 ) {
      const void *cookie = io_getcookie( sock );
      if( (uintptr_t)cookie == FLAG_SERVERSOCKET )
        handle_accept( sock );
      else
        handle_read( sock );
    }

    /* Loop over writable sockets */
    while( ( sock = io_canwrite( ) ) != -1 )
      handle_write( sock );

    livesync_ticker( );
  }
}
コード例 #8
0
ファイル: winser.c プロジェクト: NaldoDj/VeraCrypt
/*
 * Called to send data down the serial connection.
 */
static size_t serial_send(Backend *be, const char *buf, size_t len)
{
    Serial *serial = container_of(be, Serial, backend);

    if (serial->out == NULL)
	return 0;

    serial->bufsize = handle_write(serial->out, buf, len);
    return serial->bufsize;
}
コード例 #9
0
ファイル: winser.c プロジェクト: rdebath/sgt
/*
 * Called to send data down the serial connection.
 */
static int serial_send(void *handle, char *buf, int len)
{
    Serial serial = (Serial) handle;

    if (serial->out == NULL)
	return 0;

    serial->bufsize = handle_write(serial->out, buf, len);
    return serial->bufsize;
}
コード例 #10
0
template<class T> void AsyncEndpoint<T>::deliverAnswer_impl(Answer_ptr answer){
    bool wasEmpty = true;
    {
        boost::mutex::scoped_lock lock(message_queueMutex);
        wasEmpty = message_queue.empty();
        message_queue.push_back(answer);
    }
    if(wasEmpty){
        boost::system::error_code ec(0,boost::system::system_category());
        handle_write(ec);
    }
}
コード例 #11
0
ファイル: hime-im-client.c プロジェクト: czchen/hime
static int hime_im_client_forward_key_event(HIME_client_handle *handle,
                                          HIME_req_t event_type,
                                          KeySym key, u_int state,
                                          char **rstr)
{
  HIME_reply reply;
  HIME_req req;

  *rstr = NULL;

  if (is_special_user) {
      return 0;
  }

  if (!gen_req(handle, event_type, &req))
    return 0;

  req.keyeve.key = key;
  to_hime_endian_4(&req.keyeve.key);
  req.keyeve.state = state;
  to_hime_endian_4(&req.keyeve.state);


  if (handle_write(handle, &req, sizeof(req)) <= 0) {
    error_proc(handle, "cannot write to hime server");
    return FALSE;
  }

  bzero(&reply, sizeof(reply));
  if (handle_read(handle, &reply, sizeof(reply)) <=0) {
    error_proc(handle, "cannot read reply from hime server");
    return FALSE;
  }

  to_hime_endian_4(&reply.datalen);
  to_hime_endian_4(&reply.flag);

  if (reply.datalen > 0) {
    *rstr = (char *)malloc(reply.datalen);
    if (handle_read(handle, *rstr, reply.datalen) <= 0) {
      free(*rstr); *rstr = NULL;
      error_proc(handle, "cannot read reply str from hime server");
      return FALSE;
    }
  }

//  dbg("hime_im_client_forward_key_event %x\n", reply.flag);

  return reply.flag;
}
コード例 #12
0
ファイル: io.c プロジェクト: WabashOS/xen
int handle_mmio(mmio_info_t *info)
{
    struct vcpu *v = current;
    const struct mmio_handler *handler = NULL;

    handler = find_mmio_handler(v->domain, info->gpa);
    if ( !handler )
        return 0;

    if ( info->dabt.write )
        return handle_write(handler, v, info);
    else
        return handle_read(handler, v, info);
}
コード例 #13
0
ファイル: hime-im-client.c プロジェクト: czchen/hime
void hime_im_client_message(HIME_client_handle *handle, char *message)
{
  HIME_req req;
  short len;
#if DBG
  dbg("hime_im_client_message\n");
#endif
  if (!gen_req(handle, HIME_req_message, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_message error 1");
  }

  len = strlen(message)+1;
  if (handle_write(handle, &len, sizeof(len)) <=0) {
    error_proc(handle,"hime_im_client_message error 2");
  }

  if (handle_write(handle, message, len) <=0) {
    error_proc(handle,"hime_im_client_message error 2");
  }
}
コード例 #14
0
static void handle_client(struct sstate *ss, struct client *c)
{
	unsigned char buf[2048];
	int len = sizeof(buf);
	int cmd;

	cmd = net_get(c->c_s, buf, &len);
	if (cmd == -1) {
		debug(ss, c, 2, "handle_client: net_get()\n");
		client_kill(c);
		return;
	}

	/* figure out command */
	switch (cmd) {
	case NET_SET_CHAN:
		handle_set_chan(ss, c, buf, len);
		break;

	case NET_SET_RATE:
		handle_set_rate(ss, c, buf, len);
		break;

	case NET_GET_MAC:
		handle_get_mac(ss, c);
		break;

	case NET_GET_CHAN:
		handle_get_chan(ss, c);
		break;

	case NET_GET_RATE:
		handle_get_rate(ss, c);
		break;

	case NET_GET_MONITOR:
		handle_get_monitor(ss, c);
		break;

	case NET_WRITE:
		handle_write(ss, c, buf, len);
		break;

	default:
		printf("Unknown request %d\n", cmd);
		client_kill(c);
		break;
	}
}
コード例 #15
0
ファイル: hime-im-client.c プロジェクト: czchen/hime
void hime_im_client_focus_out2(HIME_client_handle *handle, char **rstr)
{
  HIME_req req;
  HIME_reply reply;

  if (rstr)
    *rstr = NULL;

  if (!handle)
    return;

  if (is_special_user)
    return;

#if DBG
  dbg("hime_im_client_focus_out2\n");
#endif
  handle->flag &= ~FLAG_HIME_client_handle_has_focus;

  if (!gen_req(handle, HIME_req_focus_out2, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_focus_out error");
  }

  bzero(&reply, sizeof(reply));
  if (handle_read(handle, &reply, sizeof(reply)) <=0) {
    error_proc(handle, "cannot read reply from hime server");
    return;
  }

  to_hime_endian_4(&reply.datalen);
  to_hime_endian_4(&reply.flag);

  if (reply.datalen > 0) {
    *rstr = (char *)malloc(reply.datalen);
    if (handle_read(handle, *rstr, reply.datalen) <= 0) {
      free(*rstr); *rstr = NULL;
      error_proc(handle, "cannot read reply str from hime server");
      return;
    }
  }

//  dbg("hime_im_client_forward_key_event %x\n", reply.flag);

  return;
}
コード例 #16
0
ファイル: master2.c プロジェクト: Wayt/AnciensProjets
void		process_fd(fd_set *fds)
{
    int		size;
    t_server	*server;

    if (FD_ISSET(0, fds))
        handle_write();
    size = (int)list_get_size(server_list) - 1;
    while (size >= 0)
    {
        if ((server = (t_server*)GET_AT(server_list, size)) != NULL)
            if (FD_ISSET(server->sockfd, fds))
                handle_input(server);
        --size;
    }
}
コード例 #17
0
ファイル: hime-im-client.c プロジェクト: czchen/hime
void hime_im_client_focus_out(HIME_client_handle *handle)
{
  if (!handle)
    return;
  if (is_special_user)
    return;

  HIME_req req;
//  dbg("hime_im_client_focus_out\n");
  handle->flag &= ~FLAG_HIME_client_handle_has_focus;

  if (!gen_req(handle, HIME_req_focus_out, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_focus_out error");
  }
}
コード例 #18
0
ファイル: opentracker.c プロジェクト: mchelen/opentracker_ono
static void server_mainloop( ) {
  static time_t ot_last_clean_time;
  time_t        next_timeout_check = g_now + OT_CLIENT_TIMEOUT_CHECKINTERVAL;
  struct        iovec *iovector;
  int           iovec_entries;

  for( ; ; ) {
    int64 i;

    io_wait();

    while( ( i = io_canread( ) ) != -1 ) {
      const void *cookie = io_getcookie( i );
      if( cookie == FLAG_TCP )
        handle_accept( i );
      else if( cookie == FLAG_UDP )
        handle_udp4( i );
      else
        handle_read( i );
    }

    while( ( i = mutex_workqueue_popresult( &iovec_entries, &iovector ) ) != -1 )
      http_sendiovecdata( i, iovec_entries, iovector );

    while( ( i = io_canwrite( ) ) != -1 )
      handle_write( i );

    if( g_now > next_timeout_check ) {
      while( ( i = io_timeouted() ) != -1 )
        handle_dead( i );
      next_timeout_check = g_now + OT_CLIENT_TIMEOUT_CHECKINTERVAL;
    }

    /* See if we need to move our pools */
    if( NOW != ot_last_clean_time ) {
      ot_last_clean_time = NOW;
      clean_all_torrents();
    }

    /* Enforce setting the clock */
    signal_handler( SIGALRM );
  }
}
コード例 #19
0
ファイル: hime-im-client.c プロジェクト: czchen/hime
void hime_im_client_reset(HIME_client_handle *handle)
{
  if (!handle)
    return;

  if (is_special_user)
    return;

  HIME_req req;
#if DBG
  dbg("hime_im_client_reset\n");
#endif
  if (!gen_req(handle, HIME_req_reset, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_reset error");
  }
}
コード例 #20
0
ファイル: app.cpp プロジェクト: shengang1006/libserver
int app::dispatch(const app_hd * msg){
	
	if(msg->type == tcp_type){
		switch(msg->event){
			case ev_sys_recv:
				on_recv(msg->u.tcp.n, msg->content, msg->length);
				break;
				
			case ev_sys_close:
				on_close(msg->u.tcp.n, *((int*)msg->content));
				delete msg->u.tcp.n;
				break;
				
			case ev_sys_accept:
				on_accept(msg->u.tcp.n);
				break;
				
			case ev_sys_connect_ok:
				on_connect(msg->u.tcp.n);
				break;
				
			case ev_sys_connect_fail:
				on_connect(msg->u.tcp.n);
				delete msg->u.tcp.n;
			break;
			
			case ev_sys_write:
				handle_write(msg->u.tcp.n);
			break;
		}
	}
	else if(msg->type == timer_type){
		on_timer(msg->event, msg->u.timer.interval, msg->u.timer.ptr);
	}
	else if(msg->type == app_type){
		on_app(msg->event, msg->content, msg->length);
	}
	else{
		error_log("msg from unknown app_name(%s)\n", m_name);
	}
	return 0;	
}
コード例 #21
0
void message_session::do_send(boost::shared_ptr<zmq::message_t> message_ptr)
{
	
	std::cout << (char *)message_ptr->data() << std::endl;
	
	message msg;
	msg.body_length(message_ptr->size());
	memcpy(msg.body(), message_ptr->data(), message_ptr->size());
	msg.encode_header();
	write_msgs_.push_back(msg);
	
	handle_write(boost::system::error_code());

	//¶ÁÇ°ÏÈÇåÁã
	read_msg_.bzero();
	boost::asio::async_read(socket_,
		boost::asio::buffer(read_msg_.data(), message::header_length),
		boost::bind(&message_session::handle_read_header, shared_from_this(),
		boost::asio::placeholders::error));
}
コード例 #22
0
template<class T> void AsyncEndpoint<T>::start()
{
    registerEndpoint();
    if(boost::shared_ptr<AsyncEndpoint<T> > activated = activateSession(this->shared_from_this())){
        //Transfer session object over to old session
        activated->unregisterEndpoint();
        {
            boost::mutex::scoped_lock lock(message_queueMutex);
            message_queue = std::deque<Message_ptr>(activated->message_queue);
        }
        log("Session reactivated");
    }
    boost::system::error_code ec(0,boost::system::system_category());
    handle_write(ec);
    isActive=true;
    aostream->async_read_some(boost::asio::buffer(data_, max_length),
                              boost::bind(&AsyncEndpoint::handle_read, this,
                                          boost::asio::placeholders::error,
                                          boost::asio::placeholders::bytes_transferred));
}//  NMEA-Protocol-Server
コード例 #23
0
static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
  GPR_ASSERT(error == GRPC_ERROR_NONE);
  state.incoming_data_length += state.temp_incoming_buffer.length;

  size_t i;
  for (i = 0; i < state.temp_incoming_buffer.count; i++) {
    char *dump = gpr_dump_slice(state.temp_incoming_buffer.slices[i],
                                GPR_DUMP_HEX | GPR_DUMP_ASCII);
    gpr_log(GPR_DEBUG, "Server received: %s", dump);
    gpr_free(dump);
  }

  gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, expected %" PRIuPTR " bytes",
          state.incoming_data_length, EXPECTED_INCOMING_DATA_LENGTH);
  if (state.incoming_data_length > EXPECTED_INCOMING_DATA_LENGTH) {
    handle_write(exec_ctx);
  } else {
    grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer,
                       &on_read);
  }
}
コード例 #24
0
ファイル: hime-im-client.c プロジェクト: czchen/hime
void hime_im_client_focus_in(HIME_client_handle *handle)
{
  if (!handle)
    return;
  if (is_special_user)
    return;

  HIME_req req;
//  dbg("hime_im_client_focus_in\n");
  handle->flag |= FLAG_HIME_client_handle_has_focus;

  if (!gen_req(handle, HIME_req_focus_in, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_focus_in error");
  }

  hime_im_client_set_cursor_location(handle, handle->spot_location.x,
     handle->spot_location.y);
}
コード例 #25
0
ファイル: async.c プロジェクト: Elohim/FGmud
void check_reqs() {
	while (reqs) {
		int val = reqs->status;
		if (val != BUSY) {
			enum atypes type =  (reqs->type);
			reqs->type = done;
			switch (type) {
			case aread:
				handle_read(reqs);
				break;
			case awrite:
				handle_write(reqs);
				break;
#ifdef F_ASYNC_GETDIR
			case agetdir:
				handle_getdir(reqs);
				break;
#endif
#ifdef F_ASYNC_DB_EXEC
			case adbexec:
				handle_db_exec(reqs);
				break;
#endif
			case done:
				//must have had an error while handling it before.
				break;
			default:
				fatal("unknown async type\n");
			}
			struct request *here = reqs;
			reqs = reqs->next;
			if(!reqs)
				lastreq = reqs;
			free_funp(here->fun->f.fp);
			free_cb(here->fun);
			free_req(here);
		} else
			return;
	}
}
コード例 #26
0
ファイル: syscall_server.c プロジェクト: 7perl/akaros
void handle_syscall(syscall_req_t* req, syscall_rsp_t* rsp)
{
	switch (req->header.id) {
		case OPEN_ID:
			handle_open(req, rsp);
			break;
		case CLOSE_ID:
			handle_close(req, rsp);
			break;
		case READ_ID:
			handle_read(req, rsp);
			break;
		case WRITE_ID:
			handle_write(req, rsp);
			break;
		case LINK_ID:
			handle_link(req, rsp);
			break;
		case UNLINK_ID:
			handle_unlink(req, rsp);
			break;
		case LSEEK_ID:
			handle_lseek(req, rsp);
			break;
		case FSTAT_ID:
			handle_fstat(req, rsp);
			break;
		case ISATTY_ID:
			handle_isatty(req, rsp);
			break;
		case STAT_ID:
			handle_stat(req, rsp);
			break;
		default:
			error(-1, "Illegal syscall, should never be here...");
	}
	
	rsp->header.return_errno = errno;
}
コード例 #27
0
ファイル: client_parallel.c プロジェクト: Rachel-Lu/socket
int main()
{
	pid_t pid;
	int fd;
	int i;

	for(i = 0; i < 20; ++i)
	{
		if( (pid = fork()) == 0)
		{
			fd = connect_server();
			handle_write(fd);
		}
	}

	while(wait(NULL) > 0)
		;

	if(errno != ECHILD)
		exit(-5);

	exit(0);
}
コード例 #28
0
ファイル: hime-im-client.c プロジェクト: czchen/hime
void hime_im_client_set_cursor_location(HIME_client_handle *handle, int x, int y)
{
  if (!handle)
    return;
  if (is_special_user)
    return;

//  dbg("hime_im_client_set_cursor_location %d   %d,%d\n", handle->flag, x, y);

  HIME_req req;
  handle->spot_location.x = x;
  handle->spot_location.y = y;

  if (!BITON(handle->flag, FLAG_HIME_client_handle_has_focus))
    return;

  if (!gen_req(handle, HIME_req_set_cursor_location, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_set_cursor_location error");
  }
}
コード例 #29
0
ファイル: select.c プロジェクト: djjsindy/dawn
static void select_process_event(event_context_t *ec){
  struct timeval tv={timeout,0};
  fd_set read_set;
  fd_set write_set;
  intptr_t max=prepare_fd_set(ec,&read_set,&write_set);
  intptr_t ret = select(max+1, &read_set, &write_set, NULL, &tv);
  if(ret==-1){
    my_log(ERROR,"select event error\n");
    return;
  }else if(ret==0){
    return;
  }
  event_t *events=(event_t *)ec->events;
  intptr_t i=0;  
  for(;i<max_event_count;i++){
    intptr_t fd=events[i].fd;
    if(fd==0){
      continue;
    }
    if(FD_ISSET(fd,&read_set)){
      if(fd==ec->listen_fd){
        accept_connection();
      }else if(fd==ec->worker_fd){
        handle_notify(fd,ec);
      }else{
        handle_read(events[i].data);
      }
    }
    if(FD_ISSET(fd,&write_set)){
      intptr_t result=handle_write(events[i].data);
      if(result==OK){
        event_operation.del_event(fd,WRITE,ec);
      }
    }
  }
}
コード例 #30
0
ファイル: syscall.c プロジェクト: DrailDragon/sem5
/*
 * System call handler
 *
 * retrieves system call number from user space
 * and invokes the requested method
 */
static void
syscall_handler (struct intr_frame *f)
{

        /* retrieve system call number
        and switch to corresponding method */
        unsigned int syscall_number = *((unsigned int*) syscall_get_kernel_address(f->esp));

        switch(syscall_number)
        {
                /* process system calls */
                case SYS_HALT:
                        handle_halt(f);
                        break;

                case SYS_EXIT:
                        handle_exit(f);
                        break;

                case SYS_EXEC:
                        handle_exec(f);
                        break;

                case SYS_WAIT:
                        handle_wait(f);
                        break;

                /* file system calls */
                case SYS_CREATE:
                        handle_create(f);
                        break;
 
                case SYS_REMOVE:
                        handle_remove(f);
                        break;

                case SYS_OPEN:
                        handle_open(f);
                        break;

                case SYS_FILESIZE:
                        handle_filesize(f);
                        break;

                case SYS_READ:
                        handle_read(f);
                        break;

                case SYS_WRITE:
                        handle_write(f);
                        break;

                case SYS_SEEK:
                        handle_seek(f);
                        break;

                case SYS_TELL:
                        handle_tell(f);
                        break;

                case SYS_CLOSE:
                        handle_close(f);
                        break;

                case SYS_CHDIR:
                        handle_chdir(f);
                        break;

                case SYS_MKDIR:
                        handle_mkdir(f);
                        break;

                case SYS_READDIR:
                        handle_readdir(f);
                        break;

                case SYS_ISDIR:
                        handle_isdir(f);
                        break;

                case SYS_INUMBER:
                        handle_inumber(f);
                        break;

                default: /* SYSCALL_ERROR: */
                        handle_no_such_syscall(f);
                        break;
        }
}