| 358 | }; |
| 359 | |
| 360 | int commands_init(void) |
| 361 | { |
| 362 | struct test_command *t; |
| 363 | char *commands; |
| 364 | int commands_len = 0; |
| 365 | |
| 366 | TAILQ_FOREACH(t, &commands_list, next) { |
| 367 | commands_len += strlen(t->command) + 1; |
| 368 | } |
| 369 | |
| 370 | commands = (char *)calloc(commands_len, sizeof(char)); |
| 371 | if (!commands) |
| 372 | return -1; |
| 373 | |
| 374 | TAILQ_FOREACH(t, &commands_list, next) { |
| 375 | strlcat(commands, t->command, commands_len); |
| 376 | if (TAILQ_NEXT(t, next) != NULL) |
| 377 | strlcat(commands, "#", commands_len); |
| 378 | } |
| 379 | |
| 380 | cmd_autotest_autotest.string_data.str = commands; |
| 381 | return 0; |
| 382 | } |