Lines Matching refs:client

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