Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vcos_cmd.c 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /*****************************************************************************
  26. *
  27. * This file provides a generic command line interface which allows
  28. * vcos internals to be manipulated and/or displayed.
  29. *
  30. *****************************************************************************/
  31. /* ---- Include Files ---------------------------------------------------- */
  32. #include "interface/vcos/vcos.h"
  33. #ifdef HAVE_VCOS_VERSION
  34. #include "interface/vcos/vcos_build_info.h"
  35. #endif
  36. #ifdef _VIDEOCORE
  37. #include "vcfw/logging/logging.h"
  38. #endif
  39. /* ---- Public Variables ------------------------------------------------- */
  40. /* ---- Private Constants and Types -------------------------------------- */
  41. #define VCOS_LOG_CATEGORY (&vcos_cmd_log_category)
  42. VCOS_LOG_CAT_T vcos_cmd_log_category;
  43. /* ---- Private Variables ------------------------------------------------ */
  44. static struct VCOS_CMD_GLOBALS_T
  45. {
  46. VCOS_MUTEX_T lock;
  47. VCOS_ONCE_T initialized;
  48. unsigned num_cmd_entries;
  49. unsigned num_cmd_alloc;
  50. VCOS_CMD_T *cmd_entry;
  51. VCOS_LOG_CAT_T *log_category;
  52. } cmd_globals;
  53. #ifdef HAVE_VCOS_VERSION
  54. /* Keep the static strings in the image from being dropped by
  55. * the linker.
  56. */
  57. extern const char *vcos_get_build_strings(unsigned id);
  58. const char *(*vcos_keep_static_strings)(unsigned);
  59. #endif
  60. /* ---- Private Function Prototypes -------------------------------------- */
  61. static VCOS_STATUS_T help_cmd( VCOS_CMD_PARAM_T *param );
  62. /* ---- Functions ------------------------------------------------------- */
  63. /*****************************************************************************
  64. *
  65. * Walks through the commands looking for a particular command
  66. *
  67. *****************************************************************************/
  68. static VCOS_CMD_T *find_cmd( VCOS_CMD_T *cmd_entry, const char *name )
  69. {
  70. VCOS_CMD_T *scan_entry = cmd_entry;
  71. while ( scan_entry->name != NULL )
  72. {
  73. if ( vcos_strcmp( scan_entry->name, name ) == 0 )
  74. {
  75. return scan_entry;
  76. }
  77. scan_entry++;
  78. }
  79. return NULL;
  80. }
  81. /*****************************************************************************
  82. *
  83. * Saves away
  84. * each line individually.
  85. *
  86. *****************************************************************************/
  87. void vcos_cmd_always_log_output( VCOS_LOG_CAT_T *log_category )
  88. {
  89. cmd_globals.log_category = log_category;
  90. }
  91. /*****************************************************************************
  92. *
  93. * Walks through a buffer containing newline separated lines, and logs
  94. * each line individually.
  95. *
  96. *****************************************************************************/
  97. static void cmd_log_results( VCOS_CMD_PARAM_T *param )
  98. {
  99. char *start;
  100. char *end;
  101. start = end = param->result_buf;
  102. while ( *start != '\0' )
  103. {
  104. while (( *end != '\0' ) && ( *end != '\n' ))
  105. end++;
  106. if ( *end == '\n' )
  107. {
  108. *end++ = '\0';
  109. }
  110. if ( cmd_globals.log_category != NULL )
  111. {
  112. if ( vcos_is_log_enabled( cmd_globals.log_category, VCOS_LOG_INFO ))
  113. {
  114. vcos_log_impl( cmd_globals.log_category, VCOS_LOG_INFO, "%s", start );
  115. }
  116. }
  117. else
  118. {
  119. vcos_log_info( "%s", start );
  120. }
  121. start = end;
  122. }
  123. /* Since we logged the buffer, reset the pointer back to the beginning. */
  124. param->result_ptr = param->result_buf;
  125. param->result_buf[0] = '\0';
  126. }
  127. /*****************************************************************************
  128. *
  129. * Since we may have limited output space, we create a generic routine
  130. * which tries to use the result space, but will switch over to using
  131. * logging if the output is too large.
  132. *
  133. *****************************************************************************/
  134. void vcos_cmd_vprintf( VCOS_CMD_PARAM_T *param, const char *fmt, va_list args )
  135. {
  136. int bytes_written;
  137. int bytes_remaining;
  138. bytes_remaining = (int)(param->result_size - ( param->result_ptr - param->result_buf ));
  139. bytes_written = vcos_vsnprintf( param->result_ptr, bytes_remaining, fmt, args );
  140. if ( cmd_globals.log_category != NULL )
  141. {
  142. /* We're going to log each line as we encounter it. If the buffer
  143. * doesn't end in a newline, then we'll wait for one first.
  144. */
  145. if ( (( bytes_written + 1 ) >= bytes_remaining )
  146. || ( param->result_ptr[ bytes_written - 1 ] == '\n' ))
  147. {
  148. cmd_log_results( param );
  149. }
  150. else
  151. {
  152. param->result_ptr += bytes_written;
  153. }
  154. }
  155. else
  156. {
  157. if (( bytes_written + 1 ) >= bytes_remaining )
  158. {
  159. /* Output doesn't fit - switch over to logging */
  160. param->use_log = 1;
  161. *param->result_ptr = '\0'; /* Zap the partial line that didn't fit above. */
  162. cmd_log_results( param ); /* resets result_ptr */
  163. bytes_written = vcos_vsnprintf( param->result_ptr, bytes_remaining, fmt, args );
  164. }
  165. param->result_ptr += bytes_written;
  166. }
  167. }
  168. /*****************************************************************************
  169. *
  170. * Prints the output.
  171. *
  172. *****************************************************************************/
  173. void vcos_cmd_printf( VCOS_CMD_PARAM_T *param, const char *fmt, ... )
  174. {
  175. va_list args;
  176. va_start( args, fmt );
  177. vcos_cmd_vprintf( param, fmt, args );
  178. va_end( args );
  179. }
  180. /*****************************************************************************
  181. *
  182. * Prints the arguments which were on the command line prior to ours.
  183. *
  184. *****************************************************************************/
  185. static void print_argument_prefix( VCOS_CMD_PARAM_T *param )
  186. {
  187. int arg_idx;
  188. for ( arg_idx = 0; &param->argv_orig[arg_idx] != param->argv; arg_idx++ )
  189. {
  190. vcos_cmd_printf( param, "%s ", param->argv_orig[arg_idx] );
  191. }
  192. }
  193. /*****************************************************************************
  194. *
  195. * Prints an error message, prefixed by the command chain required to get
  196. * to where we're at.
  197. *
  198. *****************************************************************************/
  199. void vcos_cmd_error( VCOS_CMD_PARAM_T *param, const char *fmt, ... )
  200. {
  201. va_list args;
  202. print_argument_prefix( param );
  203. va_start( args, fmt );
  204. vcos_cmd_vprintf( param, fmt, args );
  205. va_end( args );
  206. vcos_cmd_printf( param, "\n" );
  207. }
  208. /****************************************************************************
  209. *
  210. * usage - prints command usage for an array of commands.
  211. *
  212. ***************************************************************************/
  213. static void usage( VCOS_CMD_PARAM_T *param, VCOS_CMD_T *cmd_entry )
  214. {
  215. int cmd_idx;
  216. int nameWidth = 0;
  217. int argsWidth = 0;
  218. VCOS_CMD_T *scan_entry;
  219. vcos_cmd_printf( param, "Usage: " );
  220. print_argument_prefix( param );
  221. vcos_cmd_printf( param, "command [args ...]\n" );
  222. vcos_cmd_printf( param, "\n" );
  223. vcos_cmd_printf( param, "Where command is one of the following:\n" );
  224. for ( cmd_idx = 0; cmd_entry[cmd_idx].name != NULL; cmd_idx++ )
  225. {
  226. int aw;
  227. int nw;
  228. scan_entry = &cmd_entry[cmd_idx];
  229. nw = vcos_strlen( scan_entry->name );
  230. aw = vcos_strlen( scan_entry->args );
  231. if ( nw > nameWidth )
  232. {
  233. nameWidth = nw;
  234. }
  235. if ( aw > argsWidth )
  236. {
  237. argsWidth = aw;
  238. }
  239. }
  240. for ( cmd_idx = 0; cmd_entry[cmd_idx].name != NULL; cmd_idx++ )
  241. {
  242. scan_entry = &cmd_entry[cmd_idx];
  243. vcos_cmd_printf( param, " %-*s %-*s - %s\n",
  244. nameWidth, scan_entry->name,
  245. argsWidth, scan_entry->args,
  246. scan_entry->descr );
  247. }
  248. }
  249. /****************************************************************************
  250. *
  251. * Prints the usage for the current command.
  252. *
  253. ***************************************************************************/
  254. void vcos_cmd_usage( VCOS_CMD_PARAM_T *param )
  255. {
  256. VCOS_CMD_T *cmd_entry;
  257. cmd_entry = param->cmd_entry;
  258. if ( cmd_entry->sub_cmd_entry != NULL )
  259. {
  260. /* This command is command with sub-commands */
  261. usage( param, param->cmd_entry->sub_cmd_entry );
  262. }
  263. else
  264. {
  265. vcos_cmd_printf( param, "Usage: " );
  266. print_argument_prefix( param );
  267. vcos_cmd_printf( param, "%s %s - %s\n",
  268. param->argv[0],
  269. param->cmd_entry->args,
  270. param->cmd_entry->descr );
  271. }
  272. }
  273. /*****************************************************************************
  274. *
  275. * Command to print out the help
  276. *
  277. * This help command is only called from the main menu.
  278. *
  279. *****************************************************************************/
  280. static VCOS_STATUS_T help_cmd( VCOS_CMD_PARAM_T *param )
  281. {
  282. VCOS_CMD_T *found_entry;
  283. #if 0
  284. {
  285. int arg_idx;
  286. vcos_log_trace( "%s: argc = %d", __func__, param->argc );
  287. for ( arg_idx = 0; arg_idx < param->argc; arg_idx++ )
  288. {
  289. vcos_log_trace( "%s: argv[%d] = '%s'", __func__, arg_idx, param->argv[arg_idx] );
  290. }
  291. }
  292. #endif
  293. /* If there is an argument after the word help, then we want to print
  294. * help for that command.
  295. */
  296. if ( param->argc == 1 )
  297. {
  298. if ( param->cmd_parent_entry == cmd_globals.cmd_entry )
  299. {
  300. /* Bare help - print the command usage for the root */
  301. usage( param, cmd_globals.cmd_entry );
  302. return VCOS_SUCCESS;
  303. }
  304. /* For all other cases help requires an argument */
  305. vcos_cmd_error( param, "%s requires an argument", param->argv[0] );
  306. return VCOS_EINVAL;
  307. }
  308. /* We were given an argument. */
  309. if (( found_entry = find_cmd( param->cmd_parent_entry, param->argv[1] )) != NULL )
  310. {
  311. /* Make it look like the command that was specified is the one that's
  312. * currently running
  313. */
  314. param->cmd_entry = found_entry;
  315. param->argv[0] = param->argv[1];
  316. param->argv++;
  317. param->argc--;
  318. vcos_cmd_usage( param );
  319. return VCOS_SUCCESS;
  320. }
  321. vcos_cmd_error( param, "- unrecognized command: '%s'", param->argv[1] );
  322. return VCOS_ENOENT;
  323. }
  324. /*****************************************************************************
  325. *
  326. * Command to print out the version/build information.
  327. *
  328. *****************************************************************************/
  329. #ifdef HAVE_VCOS_VERSION
  330. static VCOS_STATUS_T version_cmd( VCOS_CMD_PARAM_T *param )
  331. {
  332. static const char* copyright = "Copyright (c) 2011 Broadcom";
  333. vcos_cmd_printf( param, "%s %s\n%s\nversion %s\nhost %s",
  334. vcos_get_build_date(),
  335. vcos_get_build_time(),
  336. copyright,
  337. vcos_get_build_version(),
  338. vcos_get_build_hostname() );
  339. return VCOS_SUCCESS;
  340. }
  341. #endif
  342. /*****************************************************************************
  343. *
  344. * Internal commands
  345. *
  346. *****************************************************************************/
  347. static VCOS_CMD_T cmd_help = { "help", "[command]", help_cmd, NULL, "Prints command help information" };
  348. #ifdef HAVE_VCOS_VERSION
  349. static VCOS_CMD_T cmd_version = { "version", "", version_cmd, NULL, "Prints build/version information" };
  350. #endif
  351. /*****************************************************************************
  352. *
  353. * Walks the command table and executes the commands
  354. *
  355. *****************************************************************************/
  356. static VCOS_STATUS_T execute_cmd( VCOS_CMD_PARAM_T *param, VCOS_CMD_T *cmd_entry )
  357. {
  358. const char *cmdStr;
  359. VCOS_CMD_T *found_entry;
  360. #if 0
  361. {
  362. int arg_idx;
  363. vcos_cmd_printf( param, "%s: argc = %d", __func__, param->argc );
  364. for ( arg_idx = 0; arg_idx < param->argc; arg_idx++ )
  365. {
  366. vcos_cmd_printf( param, " argv[%d] = '%s'", arg_idx, param->argv[arg_idx] );
  367. }
  368. vcos_cmd_printf( param, "\n" );
  369. }
  370. #endif
  371. if ( param->argc <= 1 )
  372. {
  373. /* No command specified */
  374. vcos_cmd_error( param, "%s - no command specified", param->argv[0] );
  375. return VCOS_EINVAL;
  376. }
  377. /* argv[0] is the command/program that caused us to get invoked, so we strip
  378. * it off.
  379. */
  380. param->argc--;
  381. param->argv++;
  382. param->cmd_parent_entry = cmd_entry;
  383. /* Not the help command, scan for the command and execute it. */
  384. cmdStr = param->argv[0];
  385. if (( found_entry = find_cmd( cmd_entry, cmdStr )) != NULL )
  386. {
  387. if ( found_entry->sub_cmd_entry != NULL )
  388. {
  389. return execute_cmd( param, found_entry->sub_cmd_entry );
  390. }
  391. param->cmd_entry = found_entry;
  392. return found_entry->cmd_fn( param );
  393. }
  394. /* Unrecognized command - check to see if it was the help command */
  395. if ( vcos_strcmp( cmdStr, cmd_help.name ) == 0 )
  396. {
  397. return help_cmd( param );
  398. }
  399. vcos_cmd_error( param, "- unrecognized command: '%s'", cmdStr );
  400. return VCOS_ENOENT;
  401. }
  402. /*****************************************************************************
  403. *
  404. * Initializes the command line parser.
  405. *
  406. *****************************************************************************/
  407. static void vcos_cmd_init( void )
  408. {
  409. vcos_mutex_create( &cmd_globals.lock, "vcos_cmd" );
  410. cmd_globals.num_cmd_entries = 0;
  411. cmd_globals.num_cmd_alloc = 0;
  412. cmd_globals.cmd_entry = NULL;
  413. #ifdef HAVE_VCOS_VERSION
  414. vcos_keep_static_strings = vcos_get_build_strings;
  415. #endif
  416. }
  417. /*****************************************************************************
  418. *
  419. * Shuts down the command line parser.
  420. *
  421. *****************************************************************************/
  422. void vcos_cmd_shutdown( void )
  423. {
  424. vcos_mutex_delete( &cmd_globals.lock );
  425. vcos_free( cmd_globals.cmd_entry );
  426. cmd_globals.cmd_entry = NULL;
  427. }
  428. /*****************************************************************************
  429. *
  430. * Command line processor.
  431. *
  432. *****************************************************************************/
  433. VCOS_STATUS_T vcos_cmd_execute( int argc, char **argv, size_t result_size, char *result_buf )
  434. {
  435. VCOS_STATUS_T rc = VCOS_EINVAL;
  436. VCOS_CMD_PARAM_T param;
  437. vcos_once( &cmd_globals.initialized, vcos_cmd_init );
  438. param.argc = argc;
  439. param.argv = param.argv_orig = argv;
  440. param.use_log = 0;
  441. param.result_size = result_size;
  442. param.result_ptr = result_buf;
  443. param.result_buf = result_buf;
  444. result_buf[0] = '\0';
  445. vcos_mutex_lock( &cmd_globals.lock );
  446. rc = execute_cmd( &param, cmd_globals.cmd_entry );
  447. if ( param.use_log )
  448. {
  449. cmd_log_results( &param );
  450. vcos_snprintf( result_buf, result_size, "results logged" );
  451. }
  452. else
  453. if ( cmd_globals.log_category != NULL )
  454. {
  455. if ( result_buf[0] != '\0' )
  456. {
  457. /* There is a partial line still buffered. */
  458. vcos_cmd_printf( &param, "\n" );
  459. }
  460. }
  461. vcos_mutex_unlock( &cmd_globals.lock );
  462. return rc;
  463. }
  464. /*****************************************************************************
  465. *
  466. * Registers a command entry with the command line processor
  467. *
  468. *****************************************************************************/
  469. VCOS_STATUS_T vcos_cmd_register( VCOS_CMD_T *cmd_entry )
  470. {
  471. VCOS_STATUS_T rc;
  472. VCOS_UNSIGNED new_num_cmd_alloc;
  473. VCOS_CMD_T *new_cmd_entry;
  474. VCOS_CMD_T *old_cmd_entry;
  475. VCOS_CMD_T *scan_entry;
  476. vcos_once( &cmd_globals.initialized, vcos_cmd_init );
  477. vcos_assert( cmd_entry != NULL );
  478. vcos_assert( cmd_entry->name != NULL );
  479. vcos_log_trace( "%s: cmd '%s'", __FUNCTION__, cmd_entry->name );
  480. vcos_assert( cmd_entry->args != NULL );
  481. vcos_assert(( cmd_entry->cmd_fn != NULL ) || ( cmd_entry->sub_cmd_entry != NULL ));
  482. vcos_assert( cmd_entry->descr != NULL );
  483. /* We expect vcos_cmd_init to be called before vcos_logging_init, so we
  484. * need to defer registering our logging category until someplace
  485. * like right here.
  486. */
  487. if ( vcos_cmd_log_category.name == NULL )
  488. {
  489. /*
  490. * If you're using the command interface, you pretty much always want
  491. * log messages from this file to show up. So we change the default
  492. * from ERROR to be the more reasonable INFO level.
  493. */
  494. vcos_log_set_level(&vcos_cmd_log_category, VCOS_LOG_INFO);
  495. vcos_log_register("vcos_cmd", &vcos_cmd_log_category);
  496. /* We register a help command so that it shows up in the usage. */
  497. vcos_cmd_register( &cmd_help );
  498. #ifdef HAVE_VCOS_VERSION
  499. vcos_cmd_register( &cmd_version );
  500. #endif
  501. }
  502. vcos_mutex_lock( &cmd_globals.lock );
  503. if ( cmd_globals.num_cmd_entries >= cmd_globals.num_cmd_alloc )
  504. {
  505. if ( cmd_globals.num_cmd_alloc == 0 )
  506. {
  507. /* We haven't allocated a table yet */
  508. }
  509. /* The number 8 is rather arbitrary. */
  510. new_num_cmd_alloc = cmd_globals.num_cmd_alloc + 8;
  511. /* The + 1 is to ensure that we always have a NULL entry at the end. */
  512. new_cmd_entry = (VCOS_CMD_T *)vcos_calloc( new_num_cmd_alloc + 1, sizeof( *cmd_entry ), "vcos_cmd_entries" );
  513. if ( new_cmd_entry == NULL )
  514. {
  515. rc = VCOS_ENOMEM;
  516. goto out;
  517. }
  518. memcpy( new_cmd_entry, cmd_globals.cmd_entry, cmd_globals.num_cmd_entries * sizeof( *cmd_entry ));
  519. cmd_globals.num_cmd_alloc = new_num_cmd_alloc;
  520. old_cmd_entry = cmd_globals.cmd_entry;
  521. cmd_globals.cmd_entry = new_cmd_entry;
  522. vcos_free( old_cmd_entry );
  523. }
  524. if ( cmd_globals.num_cmd_entries == 0 )
  525. {
  526. /* This is the first command being registered */
  527. cmd_globals.cmd_entry[0] = *cmd_entry;
  528. }
  529. else
  530. {
  531. /* Keep the list in alphabetical order. We start at the end and work backwards
  532. * shuffling entries up one until we find an insertion point.
  533. */
  534. for ( scan_entry = &cmd_globals.cmd_entry[cmd_globals.num_cmd_entries - 1];
  535. scan_entry >= cmd_globals.cmd_entry; scan_entry-- )
  536. {
  537. if ( vcos_strcmp( cmd_entry->name, scan_entry->name ) > 0 )
  538. {
  539. /* We found an insertion point. */
  540. break;
  541. }
  542. scan_entry[1] = scan_entry[0];
  543. }
  544. scan_entry[1] = *cmd_entry;
  545. }
  546. cmd_globals.num_cmd_entries++;
  547. rc = VCOS_SUCCESS;
  548. out:
  549. vcos_mutex_unlock( &cmd_globals.lock );
  550. return rc;
  551. }
  552. /*****************************************************************************
  553. *
  554. * Registers multiple commands.
  555. *
  556. *****************************************************************************/
  557. VCOS_STATUS_T vcos_cmd_register_multiple( VCOS_CMD_T *cmd_entry )
  558. {
  559. VCOS_STATUS_T status;
  560. while ( cmd_entry->name != NULL )
  561. {
  562. if (( status = vcos_cmd_register( cmd_entry )) != VCOS_SUCCESS )
  563. {
  564. return status;
  565. }
  566. cmd_entry++;
  567. }
  568. return VCOS_SUCCESS;
  569. }