Revision 135
removed some TODOs
Command.cpp | ||
---|---|---|
19 | 19 |
Command::~Command() { |
20 | 20 |
} |
21 | 21 |
|
22 |
//TODO: write a function to write data into the write buffers (jason: what was this referring to?) |
|
23 | 22 |
int Command::parse_command(char* command, int pool_index, ConnectionPool * connection_pool) { |
24 | 23 |
char tokens[MAX_TOKENS][MAX_TOKEN_SIZE]; |
25 | 24 |
int number_tokens = 0; |
... | ... | |
208 | 207 |
} |
209 | 208 |
|
210 | 209 |
int Command::parse_request_bom_matrix(ConnectionPool * connection_pool, int pool_index) { |
211 |
//TODO: rename to indicate its actually the response message |
|
212 |
char bom_matrix_buffer[MAX_RESPONSE_LEN]; |
|
210 |
char response_bom_matrix_buffer[MAX_RESPONSE_LEN]; |
|
213 | 211 |
char temp_bom_matrix_buffer[MAX_RESPONSE_LEN]; |
214 | 212 |
|
215 | 213 |
//TODO: change after we start keeping track of bom matrix |
... | ... | |
225 | 223 |
|
226 | 224 |
printf("number of robots is %d\n", number_robots); |
227 | 225 |
|
228 |
//TODO: separate parameters with spaces |
|
229 | 226 |
//TODO: make this better |
230 | 227 |
//TODO: make sure I don't need to do MAX_RESPONSE_LENGTH-1 |
231 |
snprintf(bom_matrix_buffer,MAX_RESPONSE_LEN, "%d %d %d", RESPONSE_TO_CLIENT_REQUEST, REQUEST_BOM_MATRIX, number_robots); |
|
228 |
snprintf(response_bom_matrix_buffer,MAX_RESPONSE_LEN, "%d %d %d", RESPONSE_TO_CLIENT_REQUEST, REQUEST_BOM_MATRIX, number_robots);
|
|
232 | 229 |
for (int ii = 0; ii < number_robots; ii++) { |
233 | 230 |
for (int j = 0; j < number_robots; j++) { |
234 | 231 |
//TODO: don't use strcpy |
235 |
strcpy(temp_bom_matrix_buffer, bom_matrix_buffer); |
|
232 |
strcpy(temp_bom_matrix_buffer, response_bom_matrix_buffer);
|
|
236 | 233 |
//TODO: put length checking in here so array doesn't go out of bounds |
237 | 234 |
//TODO: maybe use strncat? |
238 | 235 |
strcat(temp_bom_matrix_buffer," %d"); |
239 |
snprintf(bom_matrix_buffer, MAX_RESPONSE_LEN, temp_bom_matrix_buffer, bom_matrix[ii][j]); |
|
236 |
snprintf(response_bom_matrix_buffer, MAX_RESPONSE_LEN, temp_bom_matrix_buffer, bom_matrix[ii][j]);
|
|
240 | 237 |
} |
241 | 238 |
} |
242 |
strcat(bom_matrix_buffer,"\n"); |
|
243 |
connection_pool->write_to_client(pool_index, bom_matrix_buffer, strlen(bom_matrix_buffer));
|
|
244 |
printf("Sending %s", bom_matrix_buffer); |
|
239 |
strcat(response_bom_matrix_buffer,"\n");
|
|
240 |
connection_pool->write_to_client(pool_index, response_bom_matrix_buffer, strlen(response_bom_matrix_buffer));
|
|
241 |
printf("Sending %s", response_bom_matrix_buffer);
|
|
245 | 242 |
|
246 | 243 |
return 0; |
247 | 244 |
} |
Also available in: Unified diff