• Home
  • Raw
  • Download

Lines Matching refs:client

36     Client  client = calloc( sizeof(*client), 1 );  in client_alloc()  local
38 client->channel = channel; in client_alloc()
39 return client; in client_alloc()
43 client_free( Client client ) in client_free() argument
45 sys_channel_close( client->channel ); in client_free()
46 client->channel = NULL; in client_free()
47 free( client ); in client_free()
51 client_append( Client client, const char* str, int len );
75 client_handle_line( Client client, const char* cmd ) in client_handle_line() argument
87 client_append( client, answer, -1 ); in client_handle_line()
88 client_append( client, "\r", 1 ); in client_handle_line()
94 Client client = _client; in client_handler() local
99 ret = sys_channel_read( client->channel, client->in_buff + client->in_pos, 1 ); in client_handler()
102 client, ret, strerror(errno) ); in client_handler()
105 if (client->in_buff[client->in_pos] == '\r' || in client_handler()
106 client->in_buff[client->in_pos] == '\n' ) { in client_handler()
107 const char* cmd = client->in_buff; in client_handler()
108 client->in_buff[client->in_pos] = 0; in client_handler()
110 if (client->in_pos > 0) { in client_handler()
111 client_handle_line( client, cmd ); in client_handler()
112 client->in_pos = 0; in client_handler()
115 client->in_pos += 1; in client_handler()
121 ret = sys_channel_write( client->channel, client->out_buff + client->out_pos, 1 ); in client_handler()
124 client, ret, strerror(errno) ); in client_handler()
127 client->out_pos += 1; in client_handler()
128 if (client->out_pos == client->out_size) { in client_handler()
129 client->out_size = 0; in client_handler()
130 client->out_pos = 0; in client_handler()
132 sys_channel_on( client->channel, SYS_EVENT_READ, client_handler, client ); in client_handler()
138 printf( "client %p exiting\n", client ); in client_handler()
139 client_free( client ); in client_handler()
144 client_append( Client client, const char* str, int len ) in client_append() argument
151 avail = sizeof(client->out_buff) - client->out_size; in client_append()
155 memcpy( client->out_buff + client->out_size, str, len ); in client_append()
156 if (client->out_size == 0) { in client_append()
157 sys_channel_on( client->channel, SYS_EVENT_READ | SYS_EVENT_WRITE, client_handler, client ); in client_append()
159 client->out_size += len; in client_append()
168 Client client; in accept_func() local
172 client = client_alloc( handler ); in accept_func()
173 printf( "got one. created client %p\n", client ); in accept_func()
176 sys_channel_on( handler, SYS_EVENT_READ, client_handler, client ); in accept_func()