Changeset 4513 for pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c
- Timestamp:
- May 3, 2013 8:47:14 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c
r4476 r4513 668 668 cli_telnet_fe *fe = (cli_telnet_fe *)sess->base.fe; 669 669 670 send_data.ptr = &data_str[0];670 send_data.ptr = data_str; 671 671 send_data.slen = 0; 672 672 … … 692 692 cli_telnet_fe *fe = (cli_telnet_fe *)sess->base.fe; 693 693 694 send_data.ptr = &data_str[0];694 send_data.ptr = data_str; 695 695 send_data.slen = 0; 696 696 … … 709 709 pj_strcat(&send_data, &fe->cfg.prompt_str); 710 710 if (with_last_cmd) 711 pj_strcat2(&send_data, (char *) &sess->rcmd->rbuf[0]);711 pj_strcat2(&send_data, (char *)sess->rcmd->rbuf); 712 712 713 713 telnet_sess_send(sess, &send_data); … … 772 772 static const pj_str_t sc_type = {"sc", 2}; 773 773 static const pj_str_t choice_type = {"choice", 6}; 774 send_data.ptr = &data[0];774 send_data.ptr = data; 775 775 send_data.slen = 0; 776 776 … … 787 787 for (i=0;i<info->hint_cnt;++i) { 788 788 if ((&hint[i].type) && (hint[i].type.slen > 0)) { 789 if (pj_stricmp(&hint[i].type, &sc_type) == 0) { 790 //Additional delimiter " | " 791 cmd_length += (hint[i].name.slen + 3); 789 if (pj_stricmp(&hint[i].type, &sc_type) == 0) { 790 if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) { 791 cmd_length += (hint[i].name.slen + 3); 792 } else { 793 cmd_length = hint[i].name.slen; 794 } 792 795 } else { 793 796 cmd_length = hint[i].name.slen; … … 817 820 } 818 821 819 if ((parse_state != OP_SHORTCUT)) { 820 if (cmd_desc) { 821 /* Print data if previous hint is shortcut */ 822 send_hint_arg(sess, &send_data, 823 cmd_desc, cmd_length, 824 max_length); 825 cmd_desc = 0; 826 } 822 if (parse_state != OP_SHORTCUT) { 827 823 pj_strcat2(&send_data, "\r\n "); 828 824 cmd_length = hint[i].name.slen; 829 } 830 825 } 826 831 827 switch (parse_state) { 832 828 case OP_CHOICE: … … 844 840 case OP_SHORTCUT: 845 841 /* Format : "Command | sc | description" */ 846 pj_strcat2(&send_data, " | "); 847 pj_strcat(&send_data, &hint[i].name); 848 cmd_length += (hint[i].name.slen + 3); 842 { 843 cmd_length += hint[i].name.slen; 844 if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) { 845 pj_strcat2(&send_data, " | "); 846 cmd_length += 3; 847 } else { 848 pj_strcat2(&send_data, "\r\n "); 849 } 850 pj_strcat(&send_data, &hint[i].name); 851 } 849 852 break; 850 853 default: … … 856 859 857 860 if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) || 858 ((i+1) >= info->hint_cnt)) 861 ((i+1) >= info->hint_cnt) || 862 (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen))) 859 863 { 860 864 /* Add description info */ … … 862 866 &hint[i].desc, cmd_length, 863 867 max_length); 868 869 cmd_length = 0; 864 870 } 865 871 } … … 867 873 pj_strcat(&send_data, &fe->cfg.prompt_str); 868 874 if (with_last_cmd) 869 pj_strcat2(&send_data, (char *) &sess->rcmd->rbuf[0]);875 pj_strcat2(&send_data, (char *)sess->rcmd->rbuf); 870 876 871 877 telnet_sess_send(sess, &send_data); … … 883 889 pj_strcat2(&info->hint[0].name, " "); 884 890 885 send_data.ptr = &data[0];891 send_data.ptr = data; 886 892 send_data.slen = 0; 887 893 … … 901 907 unsigned char echo[5] = {0x1b, 0x5b, 0x31, 0x40, 0x00}; 902 908 echo[4] = *data; 903 telnet_sess_send2(sess, &echo[0], 5);909 telnet_sess_send2(sess, echo, 5); 904 910 } else { 905 911 /* Append character */ … … 925 931 unsigned char echo[5] = {0x00, 0x1b, 0x5b, 0x31, 0x50}; 926 932 echo[0] = *data; 927 telnet_sess_send2(sess, &echo[0], 5);933 telnet_sess_send2(sess, echo, 5); 928 934 } else { 929 935 const static unsigned char echo[3] = {0x08, 0x20, 0x08}; 930 telnet_sess_send2(sess, &echo[0], 3);936 telnet_sess_send2(sess, echo, 3); 931 937 } 932 938 return PJ_TRUE; … … 987 993 pool, &info); 988 994 989 len = pj_ansi_strlen((char *) &sess->rcmd->rbuf[0]);995 len = pj_ansi_strlen((char *)sess->rcmd->rbuf); 990 996 991 997 switch (status) { … … 1010 1016 if (info.hint_cnt > 0) { 1011 1017 /* Complete command */ 1012 pj_str_t cmd = pj_str((char *) &sess->rcmd->rbuf[0]);1018 pj_str_t cmd = pj_str((char *)sess->rcmd->rbuf); 1013 1019 pj_str_t last_token; 1014 1020 … … 1019 1025 if (hint_info->slen >= last_token.slen) { 1020 1026 hint_info->slen -= last_token.slen; 1021 pj_memmove( &hint_info->ptr[0],1027 pj_memmove(hint_info->ptr, 1022 1028 &hint_info->ptr[last_token.slen], 1023 1029 hint_info->slen); … … 1025 1031 send_comp_arg(sess, &info); 1026 1032 1027 pj_memcpy(&sess->rcmd->rbuf[len], &info.hint[0].name.ptr[0],1033 pj_memcpy(&sess->rcmd->rbuf[len], info.hint[0].name.ptr, 1028 1034 info.hint[0].name.slen); 1029 1035 … … 1136 1142 CLEAR_CHAR = 0x20 1137 1143 }; 1138 send_data.ptr = &str[0];1144 send_data.ptr = str; 1139 1145 send_data.slen = 0; 1140 1146
Note: See TracChangeset
for help on using the changeset viewer.