Changeset 14314
- Timestamp:
- Jul 3, 2014, 9:58:39 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Transmission.xcodeproj/project.pbxproj
r14310 r14314 461 461 C1077A4E183EB29600634C22 /* error.c in Sources */ = {isa = PBXBuildFile; fileRef = C1077A4A183EB29600634C22 /* error.c */; }; 462 462 C1077A4F183EB29600634C22 /* error.h in Headers */ = {isa = PBXBuildFile; fileRef = C1077A4B183EB29600634C22 /* error.h */; }; 463 C1077A50183EB29600634C22 /* file-posix.c in Sources */ = {isa = PBXBuildFile; fileRef = C1077A4C183EB29600634C22 /* file-posix.c */; }; 464 C1077A51183EB29600634C22 /* file.h in Headers */ = {isa = PBXBuildFile; fileRef = C1077A4D183EB29600634C22 /* file.h */; }; 463 465 D4AF3B2F0C41F7A500D46B6B /* list.c in Sources */ = {isa = PBXBuildFile; fileRef = D4AF3B2D0C41F7A500D46B6B /* list.c */; }; 464 466 D4AF3B300C41F7A600D46B6B /* list.h in Headers */ = {isa = PBXBuildFile; fileRef = D4AF3B2E0C41F7A500D46B6B /* list.h */; }; … … 1197 1199 C1077A4A183EB29600634C22 /* error.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = error.c; path = libtransmission/error.c; sourceTree = "<group>"; }; 1198 1200 C1077A4B183EB29600634C22 /* error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = error.h; path = libtransmission/error.h; sourceTree = "<group>"; }; 1201 C1077A4C183EB29600634C22 /* file-posix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "file-posix.c"; path = "libtransmission/file-posix.c"; sourceTree = "<group>"; }; 1202 C1077A4D183EB29600634C22 /* file.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = file.h; path = libtransmission/file.h; sourceTree = "<group>"; }; 1199 1203 D4AF3B2D0C41F7A500D46B6B /* list.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = list.c; path = libtransmission/list.c; sourceTree = "<group>"; }; 1200 1204 D4AF3B2E0C41F7A500D46B6B /* list.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = list.h; path = libtransmission/list.h; sourceTree = "<group>"; }; … … 1653 1657 C1077A4A183EB29600634C22 /* error.c */, 1654 1658 C1077A4B183EB29600634C22 /* error.h */, 1659 C1077A4C183EB29600634C22 /* file-posix.c */, 1660 C1077A4D183EB29600634C22 /* file.h */, 1655 1661 4D80185710BBC0B0008A4AF2 /* magnet.c */, 1656 1662 4D80185810BBC0B0008A4AF2 /* magnet.h */, … … 2048 2054 buildActionMask = 2147483647; 2049 2055 files = ( 2056 C1077A51183EB29600634C22 /* file.h in Headers */, 2050 2057 BEFC1E290C07861A00B0BB3C /* version.h in Headers */, 2051 2058 BEFC1E2A0C07861A00B0BB3C /* utils.h in Headers */, … … 2679 2686 4D36BA740CA2F00800A63CA5 /* peer-io.c in Sources */, 2680 2687 4D36BA770CA2F00800A63CA5 /* peer-mgr.c in Sources */, 2688 C1077A50183EB29600634C22 /* file-posix.c in Sources */, 2681 2689 4D36BA790CA2F00800A63CA5 /* peer-msgs.c in Sources */, 2682 2690 A25D2CBD0CF4C73E0096A262 /* stats.c in Sources */, -
trunk/libtransmission/Makefile.am
r14299 r14314 73 73 wildmat.c 74 74 75 if WIN32 76 libtransmission_a_SOURCES += file-win32.c 77 else 78 libtransmission_a_SOURCES += file-posix.c 79 endif 80 75 81 noinst_HEADERS = \ 76 82 announcer.h \ … … 86 92 error.h \ 87 93 fdlimit.h \ 94 file.h \ 88 95 handshake.h \ 89 96 history.h \ … … 137 144 crypto-test \ 138 145 error-test \ 146 file-test \ 139 147 history-test \ 140 148 json-test \ … … 192 200 error_test_LDFLAGS = ${apps_ldflags} 193 201 202 file_test_SOURCES = file-test.c $(TEST_SOURCES) 203 file_test_LDADD = ${apps_ldadd} 204 file_test_LDFLAGS = ${apps_ldflags} 205 194 206 history_test_SOURCES = history-test.c $(TEST_SOURCES) 195 207 history_test_LDADD = ${apps_ldadd} -
trunk/libtransmission/utils.c
r14310 r14314 1317 1317 } 1318 1318 1319 #ifdef WIN32 1320 1321 char * 1322 tr_win32_native_to_utf8 (const wchar_t * text, 1323 int text_size) 1324 { 1325 char * ret = NULL; 1326 int size; 1327 1328 size = WideCharToMultiByte (CP_UTF8, 0, text, text_size, NULL, 0, NULL, NULL); 1329 if (size == 0) 1330 goto fail; 1331 1332 ret = tr_new (char, size + 1); 1333 size = WideCharToMultiByte (CP_UTF8, 0, text, text_size, ret, size, NULL, NULL); 1334 if (size == 0) 1335 goto fail; 1336 1337 ret[size] = '\0'; 1338 1339 return ret; 1340 1341 fail: 1342 tr_free (ret); 1343 1344 return NULL; 1345 } 1346 1347 wchar_t * 1348 tr_win32_utf8_to_native (const char * text, 1349 int text_size) 1350 { 1351 return tr_win32_utf8_to_native_ex (text, text_size, 0); 1352 } 1353 1354 wchar_t * 1355 tr_win32_utf8_to_native_ex (const char * text, 1356 int text_size, 1357 int extra_chars) 1358 { 1359 wchar_t * ret = NULL; 1360 int size; 1361 1362 size = MultiByteToWideChar (CP_UTF8, 0, text, text_size, NULL, 0); 1363 if (size == 0) 1364 goto fail; 1365 1366 ret = tr_new (wchar_t, size + extra_chars + 1); 1367 size = MultiByteToWideChar (CP_UTF8, 0, text, text_size, ret, size); 1368 if (size == 0) 1369 goto fail; 1370 1371 ret[size] = L'\0'; 1372 1373 return ret; 1374 1375 fail: 1376 tr_free (ret); 1377 1378 return NULL; 1379 } 1380 1381 char * 1382 tr_win32_format_message (uint32_t code) 1383 { 1384 wchar_t * wide_text = NULL; 1385 DWORD wide_size; 1386 char * text = NULL; 1387 size_t text_size; 1388 1389 wide_size = FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER | 1390 FORMAT_MESSAGE_FROM_SYSTEM | 1391 FORMAT_MESSAGE_IGNORE_INSERTS, 1392 NULL, code, 0, (LPWSTR)&wide_text, 0, NULL); 1393 1394 if (wide_size != 0 && wide_text != NULL) 1395 text = tr_win32_native_to_utf8 (wide_text, wide_size); 1396 1397 LocalFree (wide_text); 1398 1399 /* Most (all?) messages contain "\r\n" in the end, chop it */ 1400 text_size = strlen (text); 1401 while (text_size > 0 && 1402 text[text_size - 1] >= '\0' && 1403 text[text_size - 1] <= ' ') 1404 text[--text_size] = '\0'; 1405 1406 return text; 1407 } 1408 1409 #endif 1410 1319 1411 /*** 1320 1412 **** -
trunk/libtransmission/utils.h
r14310 r14314 179 179 char* tr_utf8clean (const char * str, int len) TR_GNUC_MALLOC; 180 180 181 #ifdef WIN32 182 183 char * tr_win32_native_to_utf8 (const wchar_t * text, 184 int text_size); 185 wchar_t * tr_win32_utf8_to_native (const char * text, 186 int text_size); 187 wchar_t * tr_win32_utf8_to_native_ex (const char * text, 188 int text_size, 189 int extra_chars); 190 char * tr_win32_format_message (uint32_t code); 191 192 #endif 181 193 182 194 /***
Note: See TracChangeset
for help on using the changeset viewer.