Changeset 2042
- Timestamp:
- Jun 10, 2007, 11:56:35 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/ipc.c
r1959 r2042 108 108 smsg_quit( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg ); 109 109 static void 110 smsg_noop( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg ); 111 static void 110 112 smsg_info( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg ); 111 113 static void … … 126 128 static void 127 129 smsg_str( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg ); 130 static void 131 smsg_sup( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg ); 128 132 static void 129 133 all_default( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg ); … … 168 172 0 > ipc_addmsg( con->msgs, IPC_MSG_GETUPLIMIT, smsg_pref ) || 169 173 0 > ipc_addmsg( con->msgs, IPC_MSG_LOOKUP, smsg_look ) || 174 0 > ipc_addmsg( con->msgs, IPC_MSG_NOOP, smsg_noop ) || 170 175 0 > ipc_addmsg( con->msgs, IPC_MSG_PEX, smsg_int ) || 171 176 0 > ipc_addmsg( con->msgs, IPC_MSG_PORT, smsg_int ) || … … 177 182 0 > ipc_addmsg( con->msgs, IPC_MSG_STOP, smsg_tor ) || 178 183 0 > ipc_addmsg( con->msgs, IPC_MSG_STOPALL, smsg_torall ) || 184 0 > ipc_addmsg( con->msgs, IPC_MSG_SUP, smsg_sup ) || 179 185 0 > ipc_addmsg( con->msgs, IPC_MSG_UPLIMIT, smsg_int ) ) 180 186 { … … 554 560 if( NULL == val || TYPE_LIST != val->type ) 555 561 { 556 simpleresp( con, tag, IPC_MSG_ NOTSUP);562 simpleresp( con, tag, IPC_MSG_BAD ); 557 563 return; 558 564 } … … 587 593 if( NULL == val || TYPE_DICT != val->type ) 588 594 { 589 simpleresp( con, tag, IPC_MSG_ NOTSUP);595 simpleresp( con, tag, IPC_MSG_BAD ); 590 596 return; 591 597 } … … 601 607 ( NULL != start && TYPE_INT != start->type ) ) 602 608 { 603 simpleresp( con, tag, IPC_MSG_ NOTSUP);609 simpleresp( con, tag, IPC_MSG_BAD ); 604 610 return; 605 611 } … … 646 652 647 653 tr_core_quit( srv->core ); 654 } 655 656 static void 657 smsg_noop( enum ipc_msg id SHUTUP, benc_val_t * val SHUTUP, int64_t tag, 658 void * arg ) 659 { 660 simpleresp( arg, tag, IPC_MSG_OK ); 648 661 } 649 662 … … 662 675 if( NULL == val || TYPE_DICT != val->type ) 663 676 { 664 simpleresp( con, tag, IPC_MSG_ NOTSUP);677 simpleresp( con, tag, IPC_MSG_BAD ); 665 678 return; 666 679 } … … 672 685 NULL == types || TYPE_LIST != types->type ) 673 686 { 674 simpleresp( con, tag, IPC_MSG_ NOTSUP);687 simpleresp( con, tag, IPC_MSG_BAD ); 675 688 return; 676 689 } … … 728 741 if( NULL == val || TYPE_LIST != val->type ) 729 742 { 730 simpleresp( con, tag, IPC_MSG_ NOTSUP);743 simpleresp( con, tag, IPC_MSG_BAD ); 731 744 return; 732 745 } … … 806 819 if( NULL == val || TYPE_LIST != val->type ) 807 820 { 808 simpleresp( con, tag, IPC_MSG_ NOTSUP);821 simpleresp( con, tag, IPC_MSG_BAD ); 809 822 return; 810 823 } … … 859 872 if( NULL == val || TYPE_LIST != val->type ) 860 873 { 861 simpleresp( con, tag, IPC_MSG_ NOTSUP);874 simpleresp( con, tag, IPC_MSG_BAD ); 862 875 return; 863 876 } … … 1009 1022 if( NULL == val || TYPE_INT != val->type || INT_MAX < val->val.i ) 1010 1023 { 1011 simpleresp( con, tag, IPC_MSG_ NOTSUP);1024 simpleresp( con, tag, IPC_MSG_BAD ); 1012 1025 return; 1013 1026 } … … 1019 1032 break; 1020 1033 case IPC_MSG_AUTOSTART: 1021 simpleresp( con, tag, IPC_MSG_ NOTSUP);1034 simpleresp( con, tag, IPC_MSG_BAD ); 1022 1035 return; 1023 1036 case IPC_MSG_DOWNLIMIT: … … 1067 1080 if( NULL == val || TYPE_STR != val->type ) 1068 1081 { 1069 simpleresp( con, tag, IPC_MSG_ NOTSUP);1082 simpleresp( con, tag, IPC_MSG_BAD ); 1070 1083 return; 1071 1084 } … … 1083 1096 1084 1097 static void 1098 smsg_sup( enum ipc_msg id SHUTUP, benc_val_t * val, int64_t tag, void * arg ) 1099 { 1100 struct constate * con = arg; 1101 benc_val_t packet, * pkval, * name; 1102 int ii; 1103 enum ipc_msg found; 1104 uint8_t * buf; 1105 size_t size; 1106 1107 if( NULL == val || TYPE_LIST != val->type ) 1108 { 1109 simpleresp( con, tag, IPC_MSG_BAD ); 1110 return; 1111 } 1112 1113 pkval = ipc_initval( &con->ipc, IPC_MSG_SUP, tag, &packet, TYPE_LIST ); 1114 if( NULL == pkval ) 1115 { 1116 simpleresp( con, tag, IPC_MSG_FAIL ); 1117 return; 1118 } 1119 if( tr_bencListReserve( pkval, val->val.l.count ) ) 1120 { 1121 tr_bencFree( &packet ); 1122 simpleresp( con, tag, IPC_MSG_FAIL ); 1123 return; 1124 } 1125 1126 for( ii = 0; val->val.l.count > ii; ii++ ) 1127 { 1128 name = &val->val.l.vals[ii]; 1129 if( NULL == name || TYPE_STR != name->type ) 1130 { 1131 continue; 1132 } 1133 found = ipc_msgid( &con->ipc, name->val.s.s ); 1134 if( IPC__MSG_COUNT == found || !ipc_ishandled( &con->ipc, found ) ) 1135 { 1136 continue; 1137 } 1138 tr_bencInitStr( tr_bencListAdd( pkval ), 1139 name->val.s.s, name->val.s.i, 1 ); 1140 } 1141 1142 buf = ipc_mkval( &packet, &size ); 1143 tr_bencFree( &packet ); 1144 if( NULL == buf ) 1145 { 1146 simpleresp( con, tag, IPC_MSG_FAIL ); 1147 } 1148 else 1149 { 1150 io_send_keepdata( con->source, buf, size ); 1151 } 1152 } 1153 1154 static void 1085 1155 all_default( enum ipc_msg id, benc_val_t * val SHUTUP, int64_t tag, void * arg ) 1086 1156 { … … 1089 1159 case IPC_MSG_FAIL: 1090 1160 case IPC_MSG_NOTSUP: 1161 case IPC_MSG_BAD: 1091 1162 case IPC_MSG_OK: 1092 break;1093 case IPC_MSG_NOOP:1094 simpleresp( arg, tag, IPC_MSG_OK );1095 1163 break; 1096 1164 default:
Note: See TracChangeset
for help on using the changeset viewer.