parse an int */
| 314 | |
| 315 | /* parse an int */ |
| 316 | int |
| 317 | cmdline_get_help_num(cmdline_parse_token_hdr_t *tk, char *dstbuf, unsigned int size) |
| 318 | { |
| 319 | struct cmdline_token_num_data nd; |
| 320 | int ret; |
| 321 | |
| 322 | if (!tk) |
| 323 | return -1; |
| 324 | |
| 325 | memcpy(&nd, &((struct cmdline_token_num *)tk)->num_data, sizeof(nd)); |
| 326 | |
| 327 | /* should not happen.... don't so this test */ |
| 328 | /* if (nd.type >= (sizeof(num_help)/sizeof(const char *))) */ |
| 329 | /* return -1; */ |
| 330 | |
| 331 | ret = strlcpy(dstbuf, num_help[nd.type], size); |
| 332 | if (ret < 0) |
| 333 | return -1; |
| 334 | dstbuf[size-1] = '\0'; |
| 335 | return 0; |
| 336 | } |