Changeset 6944
- Timestamp:
- Oct 22, 2008, 1:57:30 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/bencode.c
r6894 r6944 1072 1072 ***/ 1073 1073 1074 #if 01075 struct WalkPrint1076 {1077 int depth;1078 FILE * out;1079 };1080 static void1081 printLeadingSpaces( struct WalkPrint * data )1082 {1083 const int width = data->depth * 2;1084 1085 fprintf( data->out, "%*.*s", width, width, " " );1086 }1087 1088 static void1089 printIntFunc( const tr_benc * val,1090 void * vdata )1091 {1092 struct WalkPrint * data = vdata;1093 1094 printLeadingSpaces( data );1095 fprintf( data->out, "int: %" PRId64 "\n", val->val.i );1096 }1097 1098 static void1099 printStringFunc( const tr_benc * val,1100 void * vdata )1101 {1102 int i;1103 struct WalkPrint * data = vdata;1104 1105 printLeadingSpaces( data );1106 fprintf( data->out, "string: " );1107 for( i = 0; i < val->val.s.i; ++i )1108 {1109 if( '\\' == val->val.s.s[i] )1110 {1111 putc( '\\', data->out );1112 putc( '\\', data->out );1113 }1114 else if( isprint( val->val.s.s[i] ) )1115 {1116 putc( val->val.s.s[i], data->out );1117 }1118 else1119 {1120 fprintf( data->out, "\\x%02x", val->val.s.s[i] );1121 }1122 }1123 fprintf( data->out, "\n" );1124 }1125 1126 static void1127 printListBeginFunc( const tr_benc * val UNUSED,1128 void * vdata )1129 {1130 struct WalkPrint * data = vdata;1131 1132 printLeadingSpaces( data );1133 fprintf( data->out, "list\n" );1134 ++data->depth;1135 }1136 1137 static void1138 printDictBeginFunc( const tr_benc * val UNUSED,1139 void * vdata )1140 {1141 struct WalkPrint * data = vdata;1142 1143 printLeadingSpaces( data );1144 fprintf( data->out, "dict\n" );1145 ++data->depth;1146 }1147 1148 static void1149 printContainerEndFunc( const tr_benc * val UNUSED,1150 void * vdata )1151 {1152 struct WalkPrint * data = vdata;1153 1154 --data->depth;1155 }1156 1157 void1158 tr_bencPrint( const tr_benc * val )1159 {1160 struct WalkFuncs walkFuncs;1161 struct WalkPrint walkPrint;1162 1163 walkFuncs.intFunc = printIntFunc;1164 walkFuncs.stringFunc = printStringFunc;1165 walkFuncs.dictBeginFunc = printDictBeginFunc;1166 walkFuncs.listBeginFunc = printListBeginFunc;1167 walkFuncs.containerEndFunc = printContainerEndFunc;1168 1169 walkPrint.out = stderr;1170 walkPrint.depth = 0;1171 bencWalk( val, &walkFuncs, &walkPrint );1172 }1173 1174 #endif1175 1176 /***1177 ****1178 ***/1179 1180 1074 struct ParentState 1181 1075 { -
trunk/libtransmission/natpmp.c
r6795 r6944 16 16 #include <inttypes.h> 17 17 18 #ifdef WIN3219 #include <winsock2.h> /* inet_ntoa */20 #else21 #include <arpa/inet.h> /* inet_ntoa */22 #endif23 24 18 #define ENABLE_STRNATPMPERR 25 19 #include <libnatpmp/natpmp.h> … … 27 21 #include "transmission.h" 28 22 #include "natpmp.h" 23 #include "net.h" /* inet_ntoa() */ 29 24 #include "port-forwarding.h" 30 25 #include "utils.h" -
trunk/libtransmission/net.c
r6906 r6944 120 120 createSocket( int type ) 121 121 { 122 int fd = tr_fdSocketCreate( type ); 123 124 if( fd >= 0 ) 125 fd = makeSocketNonBlocking( fd ); 126 127 #if 0 128 if( fd >= 0 ) 129 { 130 const int buffsize = 1500 * 3; /* 3x MTU for most ethernet/wireless */ 131 setsockopt( fd, SOL_SOCKET, SO_SNDBUF, &buffsize, sizeof( buffsize ) ); 132 } 133 #endif 134 135 return fd; 122 return makeSocketNonBlocking( tr_fdSocketCreate( type ) ); 136 123 } 137 124 -
trunk/libtransmission/peer-mgr.c
r6940 r6944 15 15 #include <string.h> /* memcpy, memcmp, strstr */ 16 16 #include <stdlib.h> /* qsort */ 17 #include <stdio.h> /* printf */18 17 #include <limits.h> /* INT_MAX */ 19 18 … … 1755 1754 1756 1755 struct tr_peer_stat * 1757 tr_peerMgrPeerStats( 1758 const tr_peerMgr * manager, 1759 const uint8_t * 1760 torrentHash, 1761 int * setmeCount UNUSED ) 1756 tr_peerMgrPeerStats( const tr_peerMgr * manager, 1757 const uint8_t * torrentHash, 1758 int * setmeCount UNUSED ) 1762 1759 { 1763 1760 int i, size; -
trunk/libtransmission/rpc-test.c
r6797 r6944 24 24 } \ 25 25 } 26 27 #if 028 extern char* cidrize( const char * in );29 30 extern int tr_rpcTestACL( const void * unused,31 const char * acl,32 char ** setme_errmsg );33 34 static int35 testWildcard( const char * in,36 const char * expected )37 {38 int ok;39 char * str = cidrize( in );40 41 /* fprintf( stderr, "in [%s] out [%s] expected [%s]\n", in, str, expected ); */42 ok = expected ? !strcmp( expected, str ) : !str;43 tr_free( str );44 return ok;45 }46 #endif47 48 static int49 test_acl( void )50 {51 #if 052 int err;53 char * errmsg = NULL;54 55 check( testWildcard( "192.*.*.*", "192.0.0.0/8" ) );56 check( testWildcard( "192.64.*.*", "192.64.0.0/16" ) );57 check( testWildcard( "192.64.0.*", "192.64.0.0/24" ) );58 check( testWildcard( "192.64.0.1", "192.64.0.1/32" ) );59 check( testWildcard( "+192.*.*.*,-192.64.*.*",60 "+192.0.0.0/8,-192.64.0.0/16" ) );61 62 err = tr_rpcTestACL( NULL, "+192.*.*.*", &errmsg );63 check( !err );64 check( !errmsg );65 err = tr_rpcTestACL( NULL, "+192.*.8.*", &errmsg );66 check( err );67 check( errmsg );68 tr_free( errmsg );69 errmsg = NULL;70 err = tr_rpcTestACL( NULL, "+192.*.*.*,-192.168.*.*", &errmsg );71 check( !err );72 check( !errmsg );73 #endif74 75 return 0;76 }77 26 78 27 static int … … 131 80 int i; 132 81 133 if( ( i = test_acl( ) ) )134 return i;135 82 if( ( i = test_list( ) ) ) 136 83 return i;
Note: See TracChangeset
for help on using the changeset viewer.