- Timestamp:
- Nov 28, 2012 3:02:01 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/cli/pjlib-util/src/pjlib-util/cli_console.c
r4299 r4302 78 78 ST_ARROWMODE 79 79 } cmd_parse_state; 80 81 /** 82 * This specify the state of output character parsing. 83 */ 84 typedef enum out_parse_state 85 { 86 OP_NORMAL, 87 OP_TYPE, 88 OP_SHORTCUT, 89 OP_CHOICE 90 } out_parse_state; 80 91 81 92 /** … … 366 377 console_recv_buf *recv_buf = &fe->input.recv_buf; 367 378 const pj_cli_hint_info *hint = info->hint; 368 pj_bool_t is_process_sc = PJ_FALSE; 369 pj_bool_t valid_type = PJ_FALSE; 379 out_parse_state parse_state = OP_NORMAL; 370 380 pj_ssize_t max_length = 0; 371 const pj_str_t sc_type = pj_str("SC"); 381 static const pj_str_t sc_type = {"sc", 2}; 382 static const pj_str_t choice_type = {"choice", 6}; 372 383 send_data.ptr = &data[0]; 373 384 send_data.slen = 0; … … 391 402 392 403 for (i=0;i<info->hint_cnt;++i) { 393 if ((&hint[i].type) && (hint[i].type.slen > 0)) { 394 valid_type = PJ_TRUE; 404 pj_strcat2(&send_data, "\r\n "); 405 406 if ((&hint[i].type) && (hint[i].type.slen > 0)) { 395 407 if (pj_stricmp(&hint[i].type, &sc_type) == 0) { 396 if (is_process_sc) { 397 pj_strcat2(&send_data, ", "); 398 } else { 399 pj_strcat2(&send_data, "\r\n\t Shorcut: "); 400 is_process_sc = PJ_TRUE; 408 parse_state = OP_SHORTCUT; 409 } else if (pj_stricmp(&hint[i].type, &choice_type) == 0) { 410 parse_state = OP_CHOICE; 411 } else { 412 parse_state = OP_TYPE; 413 } 414 } else { 415 parse_state = OP_NORMAL; 416 } 417 418 switch (parse_state) { 419 case OP_CHOICE: 420 pj_strcat2(&send_data, "["); 421 pj_strcat(&send_data, &hint[i].name); 422 pj_strcat2(&send_data, "]"); 423 break; 424 case OP_TYPE: 425 pj_strcat2(&send_data, "<"); 426 pj_strcat(&send_data, &hint[i].type); 427 pj_strcat2(&send_data, ">"); 428 break; 429 default: 430 pj_strcat(&send_data, &hint[i].name); 431 break; 432 } 433 434 if ((&hint[i].desc) && (hint[i].desc.slen > 0)) { 435 if (parse_state != OP_TYPE) { 436 for (j=0;j<(max_length-hint[i].name.slen);++j) { 437 pj_strcat2(&send_data, " "); 401 438 } 402 pj_strcat(&send_data, &hint[i].name);403 } else {404 is_process_sc = PJ_FALSE;405 439 } 406 } else { 407 valid_type = PJ_FALSE; 408 is_process_sc = PJ_FALSE; 409 } 410 411 if (!is_process_sc) { 412 pj_strcat2(&send_data, "\r\n\t"); 413 414 if (valid_type) { 415 pj_strcat2(&send_data, "<"); 416 pj_strcat(&send_data, &hint[i].type); 417 pj_strcat2(&send_data, ">"); 418 } else { 419 pj_strcat(&send_data, &hint[i].name); 420 } 421 422 if ((&hint[i].desc) && (hint[i].desc.slen > 0)) { 423 if (!valid_type) { 424 for (j=0;j<(max_length-hint[i].name.slen);++j) { 425 pj_strcat2(&send_data, " "); 426 } 427 } 428 pj_strcat2(&send_data, "\t"); 429 pj_strcat(&send_data, &hint[i].desc); 430 } 431 } 432 } 440 pj_strcat2(&send_data, " "); 441 pj_strcat(&send_data, &hint[i].desc); 442 } 443 } 433 444 pj_strcat2(&send_data, "\r\n"); 434 445 pj_strcat(&send_data, &fe->cfg.prompt_str);
Note: See TracChangeset
for help on using the changeset viewer.