Ignore:
Timestamp:
11/09/12 01:09:22 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

commit 0: make protocol emulations for esd, gopher and rplay more independed so they can be moved into plugins easily (See: #311)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/roard/protocol-gopher.c

    r5640 r5739  
    631631} 
    632632 
    633 int emul_gopher_check_client(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara) { 
     633static int emul_gopher_check_client(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara) { 
    634634 struct roar_client_server * cs; 
    635  struct roar_vio_calls     rvio; 
    636635 struct item * c = NULL; 
    637636 char inbuf[1024]; 
     
    646645 
    647646 if ( clients_get_server(client, &cs) == -1 ) { 
    648   clients_delete(client); 
    649647  return -1; 
    650648 } 
    651649 
    652650 ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio); 
    653  
    654  if ( vio == NULL ) { 
    655   vio = &rvio; 
    656   roar_vio_open_fh_socket(vio, clients_get_fh(client)); 
    657  } 
    658651 
    659652 ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio); 
     
    662655  len = sizeof(inbuf)-1; 
    663656  if ( roar_buffer_shift_out(&(cs->inbuf), inbuf, &len) == -1 ) { 
    664    clients_delete(client); 
    665657   return -1; 
    666658  } 
     
    668660  if ( cs->inbuf != NULL ) { 
    669661   roar_buffer_free(cs->inbuf); 
    670    clients_delete(client); 
    671662   return -1; 
    672663  } 
     
    674665  // test if we have still buffer space left. 
    675666  if ( len == (sizeof(inbuf)-1) ) { 
    676    clients_delete(client); 
    677667   return -1; 
    678668  } 
     
    683673 ret = roar_vio_read(vio, inbuf+len, sizeof(inbuf)-len-1); 
    684674 if ( ret < 1 ) { 
    685   clients_delete(client); 
    686675  ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = -1", client, vio); 
    687676  return -1; 
     
    696685 if ( !strip_nl(inbuf) ) { 
    697686  if ( roar_buffer_new_data(&(cs->inbuf), ret, &data) == -1 ) { 
    698    clients_delete(client); 
    699687   ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = -1", client, vio); 
    700688   return -1; 
     
    719707 
    720708 if ( c == NULL ) { 
    721   clients_delete(client); 
    722709  ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = -1", client, vio); 
    723710  return -1; 
     
    752739 
    753740 if ( funcret == -1 ) { 
    754   clients_delete(client); 
    755741  ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = -1", client, vio); 
    756742  return -1; 
     
    762748} 
    763749 
    764 int emul_gopher_flushed_client(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara) { 
     750static int emul_gopher_flushed_client(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara) { 
    765751 ROAR_DBG("emul_gopher_flushed_client(client=%i, vio=%p) = ?", client, vio); 
    766752 
    767  return clients_delete(client); 
    768 } 
     753 return -1; 
     754} 
     755 
     756struct roar_dl_proto __proto_common_gopher = { 
     757 .proto = ROAR_PROTO_GOPHER, 
     758 .description = "The Internet Gopher Protocol", 
     759 .flags = ROAR_DL_PROTO_FLAGS_NONE, 
     760 .handle = emul_gopher_check_client, 
     761 .flushed = emul_gopher_flushed_client 
     762}; 
    769763 
    770764#endif 
Note: See TracChangeset for help on using the changeset viewer.